LLVM 22.0.0git
CBuffer.h
Go to the documentation of this file.
1//===- CBuffer.h - HLSL constant buffer handling ----------------*- C++ -*-===//
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/// \file This file contains utilities to work with constant buffers in HLSL.
10///
11//===----------------------------------------------------------------------===//
12
13#ifndef LLVM_FRONTEND_HLSL_CBUFFER_H
14#define LLVM_FRONTEND_HLSL_CBUFFER_H
15
17#include "llvm/IR/DataLayout.h"
19#include <optional>
20
21namespace llvm {
22class Module;
23class GlobalVariable;
24class NamedMDNode;
25
26namespace hlsl {
27
34
41
42class CBufferMetadata {
43 NamedMDNode *MD;
45
46 CBufferMetadata(NamedMDNode *MD) : MD(MD) {}
47
48public:
49 static std::optional<CBufferMetadata>
50 get(Module &M, llvm::function_ref<bool(Type *)> IsPadding);
51
53 iterator begin() { return Mappings.begin(); }
54 iterator end() { return Mappings.end(); }
55
56 void eraseFromModule();
57};
58
59} // namespace hlsl
60} // namespace llvm
61
62#endif // LLVM_FRONTEND_HLSL_CBUFFER_H
This file defines the SmallVector class.
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:67
A tuple of MDNodes.
Definition Metadata.h:1757
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
An efficient, type-erasing, non-owning reference to a callable.
SmallVector< CBufferMapping >::iterator iterator
Definition CBuffer.h:52
static std::optional< CBufferMetadata > get(Module &M, llvm::function_ref< bool(Type *)> IsPadding)
Definition CBuffer.cpp:39
This is an optimization pass for GlobalISel generic memory operations.
GlobalVariable * Handle
Definition CBuffer.h:36
SmallVector< CBufferMember > Members
Definition CBuffer.h:37
CBufferMapping(GlobalVariable *Handle)
Definition CBuffer.h:39
GlobalVariable * GV
Definition CBuffer.h:29
CBufferMember(GlobalVariable *GV, size_t Offset)
Definition CBuffer.h:32