clang 24.0.0git
CGHLSLRuntime.h
Go to the documentation of this file.
1//===----- CGHLSLRuntime.h - Interface to HLSL Runtimes -----*- 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// This provides an abstract class for HLSL code generation. Concrete
10// subclasses of this implement code generation for specific HLSL
11// runtime libraries.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
16#define LLVM_CLANG_LIB_CODEGEN_CGHLSLRUNTIME_H
17
18#include "Address.h"
19#include "clang/AST/Attr.h"
20#include "clang/AST/Decl.h"
23#include "llvm/ADT/DenseMap.h"
24#include "llvm/ADT/SmallVector.h"
25#include "llvm/ADT/StringRef.h"
26#include "llvm/Frontend/HLSL/HLSLResource.h"
27#include "llvm/Frontend/HLSL/SemanticSignatures.h"
28#include "llvm/IR/IRBuilder.h"
29#include "llvm/IR/Intrinsics.h"
30#include "llvm/IR/IntrinsicsDirectX.h"
31#include "llvm/IR/IntrinsicsSPIRV.h"
32
33#include <optional>
34#include <vector>
35
36// A function generator macro for picking the right intrinsic
37// for the target backend
38#define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix) \
39 llvm::Intrinsic::ID get##FunctionName##Intrinsic() { \
40 llvm::Triple::ArchType Arch = getArch(); \
41 switch (Arch) { \
42 case llvm::Triple::dxil: \
43 return llvm::Intrinsic::dx_##IntrinsicPostfix; \
44 case llvm::Triple::spirv: \
45 return llvm::Intrinsic::spv_##IntrinsicPostfix; \
46 default: \
47 llvm_unreachable("Intrinsic " #IntrinsicPostfix \
48 " not supported by target architecture"); \
49 } \
50 }
51
52using ResourceClass = llvm::dxil::ResourceClass;
53
54namespace llvm {
55class GlobalVariable;
56class Function;
57class StructType;
58class Metadata;
59} // namespace llvm
60
61namespace clang {
62class NamedDecl;
63class VarDecl;
64class ParmVarDecl;
65class InitListExpr;
66class HLSLBufferDecl;
68class HLSLVkBindingAttr;
69class HLSLResourceBindingAttr;
70class Type;
71class RecordType;
72class DeclContext;
73class HLSLPackOffsetAttr;
75
76class FunctionDecl;
77
78namespace CodeGen {
79
80class CodeGenModule;
81class CodeGenFunction;
82class LValue;
83class AggValueSlot;
84
87
88public:
89 static const uint32_t Unspecified = ~0U;
90
91 /// Iterates over all declarations in the HLSL buffer and based on the
92 /// packoffset or register(c#) annotations it fills outs the Offsets vector
93 /// with the user-specified layout offsets. The buffer offsets can be
94 /// specified 2 ways: 1. declarations in cbuffer {} block can have a
95 /// packoffset annotation (translates to HLSLPackOffsetAttr) 2. default
96 /// constant buffer declarations at global scope can have register(c#)
97 /// annotations (translates to HLSLResourceBindingAttr with RegisterType::C)
98 /// It is not guaranteed that all declarations in a buffer have an annotation.
99 /// For those where it is not specified a `~0U` value is added to the Offsets
100 /// vector. In the final layout these declarations will be placed at the end
101 /// of the HLSL buffer after all of the elements with specified offset.
102 static CGHLSLOffsetInfo fromDecl(const HLSLBufferDecl &BufDecl);
103
104 /// Comparison function for offsets received from `operator[]` suitable for
105 /// use in a `stable_sort`. This will order implicit bindings after explicit
106 /// offsets.
107 static bool compareOffsets(uint32_t LHS, uint32_t RHS) { return LHS < RHS; }
108
109 /// Get the given offset, or `~0U` if there is no offset for the member.
110 uint32_t operator[](size_t I) const {
111 if (Offsets.empty())
112 return Unspecified;
113 return Offsets[I];
114 }
115
116 bool empty() const { return Offsets.empty(); }
117};
118
120public:
121 //===----------------------------------------------------------------------===//
122 // Start of reserved area for HLSL intrinsic getters.
123 //===----------------------------------------------------------------------===//
124
128 GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup,
129 flattened_thread_id_in_group)
133 GENERATE_HLSL_INTRINSIC_FUNCTION(Saturate, saturate)
135 GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
136 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupThreadId, thread_id_in_group)
137 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupId, group_id)
141 GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddI8Packed, dot4add_i8packed)
142 GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddU8Packed, dot4add_u8packed)
143 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAllEqual, wave_all_equal)
144 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAllTrue, wave_all)
145 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAnyTrue, wave_any)
146 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitOr, wave_reduce_or)
147 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitXor, wave_reduce_xor)
148 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitAnd, wave_reduce_and)
149 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMax, wave_reduce_max)
150 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMax, wave_reduce_umax)
151 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMin, wave_reduce_min)
152 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMin, wave_reduce_umin)
153 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveCountBits, wave_active_countbits)
154 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
155 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveGetLaneCount, wave_get_lane_count)
156 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
157 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneFirst, wave_readlane_first)
158 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossX, quad_read_across_x)
159 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossY, quad_read_across_y)
160 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossDiagonal,
161 quad_read_across_diagonal)
162 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitUHigh, firstbituhigh)
163 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitSHigh, firstbitshigh)
164 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitLow, firstbitlow)
168
169 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetBasePointer,
170 resource_getbasepointer)
171 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointer,
172 resource_getpointer)
174 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleClamp, resource_sample_clamp)
175 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBias, resource_samplebias)
176 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBiasClamp, resource_samplebias_clamp)
177 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGrad, resource_samplegrad)
178 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGradClamp, resource_samplegrad_clamp)
179 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleLevel, resource_samplelevel)
180 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmp, resource_samplecmp)
181 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmpClamp, resource_samplecmp_clamp)
183 resource_samplecmplevelzero)
184 GENERATE_HLSL_INTRINSIC_FUNCTION(Gather, resource_gather)
185 GENERATE_HLSL_INTRINSIC_FUNCTION(GatherCmp, resource_gather_cmp)
186 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding,
187 resource_handlefrombinding)
188 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromImplicitBinding,
189 resource_handlefromimplicitbinding)
190 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromHeap,
191 resource_handlefromheap)
192 GENERATE_HLSL_INTRINSIC_FUNCTION(NonUniformResourceIndex,
193 resource_nonuniformindex)
194 GENERATE_HLSL_INTRINSIC_FUNCTION(BufferUpdateCounter, resource_updatecounter)
195 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrier, all_memory_barrier)
196 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrierWithGroupSync,
197 all_memory_barrier_with_group_sync)
198 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrier, device_memory_barrier)
199 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrierWithGroupSync,
200 device_memory_barrier_with_group_sync)
201 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrier, group_memory_barrier)
202 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrierWithGroupSync,
203 group_memory_barrier_with_group_sync)
204 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsX, resource_getdimensions_x)
205 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsXY, resource_getdimensions_xy)
206 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsLevelsXY,
207 resource_getdimensions_levels_xy)
208 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadLevel, resource_load_level)
209 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadMS, resource_load_ms)
210 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLod, resource_calculate_lod)
211 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLodUnclamped,
212 resource_calculate_lod_unclamped)
213 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxCoarse, ddx_coarse)
214 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyCoarse, ddy_coarse)
215 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxFine, ddx_fine)
216 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyFine, ddy_fine)
217
218 //===----------------------------------------------------------------------===//
219 // End of reserved area for HLSL intrinsic getters.
220 //===----------------------------------------------------------------------===//
221
222protected:
224 llvm::SmallVectorImpl<llvm::hlsl::SemanticSignatureElement>;
225
227
229 llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl,
230 HLSLAppliedSemanticAttr *Semantic,
231 llvm::dxbc::PSV::SemanticKind SemanticKind,
232 llvm::Triple::EnvironmentType Stage, std::optional<unsigned> Index,
233 SemanticSignatures &Signature);
234
235 void emitSystemSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
236 const clang::DeclaratorDecl *Decl,
237 HLSLAppliedSemanticAttr *Semantic,
238 llvm::dxbc::PSV::SemanticKind SemanticKind,
239 llvm::Triple::EnvironmentType Stage,
240 std::optional<unsigned> Index,
241 SemanticSignatures &Signature);
242
243 llvm::Value *handleScalarSemanticLoad(llvm::IRBuilder<> &B,
244 const FunctionDecl *FD,
245 llvm::Type *Type,
246 const clang::DeclaratorDecl *Decl,
247 HLSLAppliedSemanticAttr *Semantic,
248 SemanticSignatures &Signature);
249
250 void handleScalarSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
251 llvm::Value *Source,
252 const clang::DeclaratorDecl *Decl,
253 HLSLAppliedSemanticAttr *Semantic,
254 SemanticSignatures &Signature);
255
256 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
258 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type,
259 const clang::DeclaratorDecl *Decl,
260 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
261 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
262 SemanticSignatures &Signature);
263
264 specific_attr_iterator<HLSLAppliedSemanticAttr> handleStructSemanticStore(
265 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source,
266 const clang::DeclaratorDecl *Decl,
267 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
268 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
269 SemanticSignatures &Signature);
270
271 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
272 handleSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD,
274 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
275 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
276 SemanticSignatures &Signature);
277
278 specific_attr_iterator<HLSLAppliedSemanticAttr>
279 handleSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
280 llvm::Value *Source, const clang::DeclaratorDecl *Decl,
281 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
282 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
283 SemanticSignatures &Signature);
284
285public:
287 virtual ~CGHLSLRuntime() {}
288
289 llvm::Type *convertHLSLSpecificType(const Type *T,
290 const CGHLSLOffsetInfo &OffsetInfo);
291 llvm::Type *convertHLSLSpecificType(const Type *T) {
293 }
294
296
297 void addBuffer(const HLSLBufferDecl *D);
299 void finishCodeGen();
300
301 void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
302
303 void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
304 void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn);
305 void handleGlobalVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Var);
306
307 llvm::Instruction *getConvergenceToken(llvm::BasicBlock &BB);
308
309 llvm::StructType *getHLSLBufferLayoutType(const RecordType *LayoutStructTy);
310 void addHLSLBufferLayoutType(const RecordType *LayoutStructTy,
311 llvm::StructType *LayoutTy);
313
314 std::optional<LValue>
316 CodeGenFunction &CGF);
317
318 bool emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E,
319 AggValueSlot &DestSlot);
320 std::optional<LValue>
322 const VarDecl *ArrayDecl);
323
324 std::optional<LValue> emitBufferArraySubscriptExpr(
325 const ArraySubscriptExpr *E, CodeGenFunction &CGF,
326 llvm::function_ref<llvm::Value *(bool Promote)> EmitIdxAfterBase);
327
329 CodeGenFunction &CGF);
330
331 bool emitBufferCopy(CodeGenFunction &CGF, const Expr *E, const LValue &SrcLV,
332 AggValueSlot &DestSlot);
333
335 std::optional<LValue> emitResourceMemberExpr(CodeGenFunction &CGF,
336 const MemberExpr *E);
337
338private:
339 void emitBufferGlobalsAndMetadata(const HLSLBufferDecl *BufDecl,
340 llvm::GlobalVariable *BufGV,
341 const CGHLSLOffsetInfo &OffsetInfo);
342 void initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
343 llvm::GlobalVariable *GV);
344 void initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
345 llvm::GlobalVariable *GV,
346 HLSLResourceBindingAttr *RBA);
347
348 llvm::Value *emitSPIRVUserSemanticLoad(llvm::IRBuilder<> &B,
349 const FunctionDecl *FD,
350 llvm::Type *Type,
352 HLSLAppliedSemanticAttr *Semantic,
353 std::optional<unsigned> Index);
354 llvm::Value *emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
356 HLSLAppliedSemanticAttr *Semantic,
357 std::optional<unsigned> Index,
358 SemanticSignatures &Signature);
359 llvm::Value *emitUserSemanticLoad(llvm::IRBuilder<> &B,
360 const FunctionDecl *FD, llvm::Type *Type,
362 HLSLAppliedSemanticAttr *Semantic,
363 std::optional<unsigned> Index,
364 SemanticSignatures &Signature);
365
366 void emitSPIRVUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
368 HLSLAppliedSemanticAttr *Semantic,
369 std::optional<unsigned> Index);
370 void emitDXILUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
372 HLSLAppliedSemanticAttr *Semantic,
373 std::optional<unsigned> Index,
374 SemanticSignatures &Signature);
375 void emitUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
377 HLSLAppliedSemanticAttr *Semantic,
378 std::optional<unsigned> Index,
379 SemanticSignatures &Signature);
380
381 bool initializeGlobalResourceArray(CodeGenFunction &CGF,
382 const VarDecl *ArrayDecl,
383 AggValueSlot &DestSlot);
384
385 llvm::Triple::ArchType getArch();
386
387 llvm::DenseMap<const clang::RecordType *, llvm::StructType *> LayoutTypes;
388 unsigned SPIRVLastAssignedInputSemanticLocation = 0;
389 unsigned SPIRVLastAssignedOutputSemanticLocation = 0;
390};
391
392} // namespace CodeGen
393} // namespace clang
394
395#endif
Defines enum values for all the target-independent builtin functions.
#define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix)
llvm::dxil::ResourceClass ResourceClass
Defines helper utilities for supporting the HLSL runtime environment.
llvm::dxbc::PSV::SemanticKind SemanticKind
Definition SemaHLSL.cpp:59
__DEVICE__ bool isnan(float __x)
Test for a NaN.
__DEVICE__ bool isinf(float __x)
Test for infinity value (+ve or -ve) .
__DEVICE__ double rsqrt(double __a)
ArraySubscriptExpr - [C99 6.5.2.1] Array Subscripting.
Definition Expr.h:2765
An aggregate value slot.
Definition CGValue.h:551
static const uint32_t Unspecified
static bool compareOffsets(uint32_t LHS, uint32_t RHS)
Comparison function for offsets received from operator[] suitable for use in a stable_sort.
static CGHLSLOffsetInfo fromDecl(const HLSLBufferDecl &BufDecl)
Iterates over all declarations in the HLSL buffer and based on the packoffset or register(c#) annotat...
uint32_t operator[](size_t I) const
Get the given offset, or ~0U if there is no offset for the member.
llvm::Instruction * getConvergenceToken(llvm::BasicBlock &BB)
llvm::Value * emitSystemSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, llvm::dxbc::PSV::SemanticKind SemanticKind, llvm::Triple::EnvironmentType Stage, std::optional< unsigned > Index, SemanticSignatures &Signature)
void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn)
specific_attr_iterator< HLSLAppliedSemanticAttr > handleStructSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source, const clang::DeclaratorDecl *Decl, specific_attr_iterator< HLSLAppliedSemanticAttr > AttrBegin, specific_attr_iterator< HLSLAppliedSemanticAttr > AttrEnd, SemanticSignatures &Signature)
llvm::StructType * getHLSLBufferLayoutType(const RecordType *LayoutStructTy)
void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn)
void handleGlobalVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Var)
std::optional< LValue > emitResourceMemberExpr(CodeGenFunction &CGF, const MemberExpr *E)
void emitSystemSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, llvm::dxbc::PSV::SemanticKind SemanticKind, llvm::Triple::EnvironmentType Stage, std::optional< unsigned > Index, SemanticSignatures &Signature)
llvm::SmallVectorImpl< llvm::hlsl::SemanticSignatureElement > SemanticSignatures
void addHLSLBufferLayoutType(const RecordType *LayoutStructTy, llvm::StructType *LayoutTy)
std::optional< LValue > emitGlobalResourceArrayAsLValue(CodeGenFunction &CGF, const VarDecl *ArrayDecl)
GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup, flattened_thread_id_in_group) GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossDiagonal
llvm::Value * handleScalarSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, SemanticSignatures &Signature)
bool emitBufferCopy(CodeGenFunction &CGF, const Expr *E, const LValue &SrcLV, AggValueSlot &DestSlot)
std::pair< llvm::Value *, specific_attr_iterator< HLSLAppliedSemanticAttr > > handleStructSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type, const clang::DeclaratorDecl *Decl, specific_attr_iterator< HLSLAppliedSemanticAttr > begin, specific_attr_iterator< HLSLAppliedSemanticAttr > end, SemanticSignatures &Signature)
specific_attr_iterator< HLSLAppliedSemanticAttr > handleSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source, const clang::DeclaratorDecl *Decl, specific_attr_iterator< HLSLAppliedSemanticAttr > AttrBegin, specific_attr_iterator< HLSLAppliedSemanticAttr > AttrEnd, SemanticSignatures &Signature)
CGHLSLRuntime(CodeGenModule &CGM)
std::optional< LValue > emitBufferArraySubscriptExpr(const ArraySubscriptExpr *E, CodeGenFunction &CGF, llvm::function_ref< llvm::Value *(bool Promote)> EmitIdxAfterBase)
std::optional< LValue > emitResourceArraySubscriptExpr(const ArraySubscriptExpr *E, CodeGenFunction &CGF)
void addRootSignature(const HLSLRootSignatureDecl *D)
LValue emitBufferMemberExpr(CodeGenFunction &CGF, const MemberExpr *E)
llvm::Type * convertHLSLSpecificType(const Type *T)
llvm::Type * convertHLSLSpecificType(const Type *T, const CGHLSLOffsetInfo &OffsetInfo)
RawAddress createBufferMatrixTempAddress(const LValue &LV, CodeGenFunction &CGF)
void addBuffer(const HLSLBufferDecl *D)
bool emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E, AggValueSlot &DestSlot)
void setHLSLFunctionAttributes(const FunctionDecl *FD, llvm::Function *Fn)
std::pair< llvm::Value *, specific_attr_iterator< HLSLAppliedSemanticAttr > > handleSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type, const clang::DeclaratorDecl *Decl, specific_attr_iterator< HLSLAppliedSemanticAttr > begin, specific_attr_iterator< HLSLAppliedSemanticAttr > end, SemanticSignatures &Signature)
void handleScalarSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, SemanticSignatures &Signature)
void emitInitListOpaqueValues(CodeGenFunction &CGF, InitListExpr *E)
CodeGenFunction - This class organizes the per-function state that is used while generating LLVM code...
This class organizes the cross-function state that is used while generating LLVM code.
LValue - This represents an lvalue references.
Definition CGValue.h:183
An abstract representation of an aligned address.
Definition Address.h:42
DeclContext - This is used only as base class of specific decl types that can act as declaration cont...
Definition DeclBase.h:1466
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:781
This represents one expression.
Definition Expr.h:113
Represents a function declaration or definition.
Definition Decl.h:2059
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition Decl.h:5332
Describes an C or C++ initializer list.
Definition Expr.h:5352
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3408
This represents a decl that may have a name.
Definition Decl.h:275
Represents a parameter to a function.
Definition Decl.h:1820
The base class of the type hierarchy.
Definition TypeBase.h:1879
Represents a variable declaration or definition.
Definition Decl.h:933
specific_attr_iterator - Iterates over a subrange of an AttrVec, only providing attributes that are o...
@ Type
The l-value was considered opaque, so the alignment was determined from a type.
Definition CGValue.h:155
@ Decl
The l-value was an access to a declared entity or something equivalently strong, like the address of ...
Definition CGValue.h:146
Top level wrappers for InstallAPI frontend operations.
const FunctionProtoType * T
Diagnostic wrappers for TextAPI types for error reporting.
Definition Dominators.h:30
float __ovld __cnfn sign(float)
Returns 1.0 if x > 0, -0.0 if x = -0.0, +0.0 if x = +0.0, or -1.0 if x < 0.
int __ovld __cnfn all(char)
Returns 1 if the most significant bit in all components of x is set; otherwise returns 0.
int __ovld __cnfn any(char)
Returns 1 if the most significant bit in any component of x is set; otherwise returns 0.
int32_t uint32_t