clang 22.0.0git
HLSLBufferLayoutBuilder.h
Go to the documentation of this file.
1//===- HLSLBufferLayoutBuilder.h ------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
10#include "llvm/ADT/StringRef.h"
11#include "llvm/IR/DerivedTypes.h"
12
13namespace clang {
14namespace CodeGen {
16class CodeGenModule;
18
19//===----------------------------------------------------------------------===//
20// Implementation of constant buffer layout common between DirectX and
21// SPIR/SPIR-V.
22//===----------------------------------------------------------------------===//
23
25private:
26 CodeGenModule &CGM;
27
28public:
30
31 /// Lays out a struct type following HLSL buffer rules and considering any
32 /// explicit offset information. Previously created layout structs are cached
33 /// by CGHLSLRuntime.
34 ///
35 /// The function iterates over all fields of the record type (including base
36 /// classes) and works out a padded llvm type to represent the buffer layout.
37 ///
38 /// If a non-empty OffsetInfo is provided (ie, from `packoffset` annotations
39 /// in the source), any provided offsets offsets will be respected. If the
40 /// OffsetInfo is available but has empty entries, those will be layed out at
41 /// the end of the structure.
42 llvm::StructType *layOutStruct(const RecordType *StructType,
43 const CGHLSLOffsetInfo &OffsetInfo);
44
45 /// Lays out an array type following HLSL buffer rules.
46 llvm::Type *layOutArray(const ConstantArrayType *AT);
47
48 /// Lays out a type following HLSL buffer rules. Arrays and structures will be
49 /// padded appropriately and nested objects will be converted as appropriate.
50 llvm::Type *layOutType(QualType Type);
51};
52
53} // namespace CodeGen
54} // namespace clang
C Language Family Type Representation.
This class organizes the cross-function state that is used while generating LLVM code.
llvm::StructType * layOutStruct(const RecordType *StructType, const CGHLSLOffsetInfo &OffsetInfo)
Lays out a struct type following HLSL buffer rules and considering any explicit offset information.
llvm::Type * layOutArray(const ConstantArrayType *AT)
Lays out an array type following HLSL buffer rules.
llvm::Type * layOutType(QualType Type)
Lays out a type following HLSL buffer rules.
Represents the canonical version of C arrays with a specified constant size.
Definition TypeBase.h:3760
A (possibly-)qualified type.
Definition TypeBase.h:937
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
The JSON file list parser is used to communicate input to InstallAPI.