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
9#include "llvm/ADT/StringRef.h"
10#include "llvm/IR/DerivedTypes.h"
11
12namespace clang {
13class RecordType;
14class FieldDecl;
15
16namespace CodeGen {
17class CodeGenModule;
18
19//===----------------------------------------------------------------------===//
20// Implementation of constant buffer layout common between DirectX and
21// SPIR/SPIR-V.
22//===----------------------------------------------------------------------===//
23
25private:
26 CodeGenModule &CGM;
27 llvm::StringRef LayoutTypeName;
28
29public:
30 HLSLBufferLayoutBuilder(CodeGenModule &CGM, llvm::StringRef LayoutTypeName)
31 : CGM(CGM), LayoutTypeName(LayoutTypeName) {}
32
33 // Returns LLVM target extension type with the name LayoutTypeName
34 // for given structure type and layout data. The first number in
35 // the Layout is the size followed by offsets for each struct element.
36 llvm::TargetExtType *
37 createLayoutType(const RecordType *StructType,
38 const llvm::SmallVector<int32_t> *Packoffsets = nullptr);
39
40private:
41 bool layoutField(const clang::FieldDecl *FD, unsigned &EndOffset,
42 unsigned &FieldOffset, llvm::Type *&FieldType,
43 int Packoffset = -1);
44};
45
46} // namespace CodeGen
47} // namespace clang
This class organizes the cross-function state that is used while generating LLVM code.
HLSLBufferLayoutBuilder(CodeGenModule &CGM, llvm::StringRef LayoutTypeName)
llvm::TargetExtType * createLayoutType(const RecordType *StructType, const llvm::SmallVector< int32_t > *Packoffsets=nullptr)
Represents a member of a struct/union/class.
Definition: Decl.h:3157
A helper class that allows the use of isa/cast/dyncast to detect TagType objects of structs/unions/cl...
Definition: TypeBase.h:6502
The JSON file list parser is used to communicate input to InstallAPI.