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// Function generator macros for picking the right intrinsic for the target.
37#define GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(FunctionName, DxilPostfix, \
38 SpirvPostfix) \
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_##DxilPostfix; \
44 case llvm::Triple::spirv: \
45 return llvm::Intrinsic::spv_##SpirvPostfix; \
46 default: \
47 llvm_unreachable(#FunctionName " not supported by target architecture"); \
48 } \
49 }
50
51#define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix) \
52 GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(FunctionName, IntrinsicPostfix, \
53 IntrinsicPostfix)
54
55using ResourceClass = llvm::dxil::ResourceClass;
56
57namespace llvm {
58class GlobalVariable;
59class Function;
60class StructType;
61class Metadata;
62} // namespace llvm
63
64namespace clang {
65class NamedDecl;
66class VarDecl;
67class ParmVarDecl;
68class InitListExpr;
69class HLSLBufferDecl;
71class HLSLVkBindingAttr;
72class Type;
73class RecordType;
74class DeclContext;
75class HLSLPackOffsetAttr;
77
78class FunctionDecl;
79
80namespace CodeGen {
81
82class CodeGenModule;
83class CodeGenFunction;
84class LValue;
85class AggValueSlot;
86
89
90public:
91 static const uint32_t Unspecified = ~0U;
92
93 /// Iterates over all declarations in the HLSL buffer and based on the
94 /// packoffset or register(c#) annotations it fills outs the Offsets vector
95 /// with the user-specified layout offsets. The buffer offsets can be
96 /// specified 2 ways: 1. declarations in cbuffer {} block can have a
97 /// packoffset annotation (translates to HLSLPackOffsetAttr) 2. default
98 /// constant buffer declarations at global scope can have register(c#)
99 /// annotations (translates to HLSLResourceBindingAttr with RegisterType::C)
100 /// It is not guaranteed that all declarations in a buffer have an annotation.
101 /// For those where it is not specified a `~0U` value is added to the Offsets
102 /// vector. In the final layout these declarations will be placed at the end
103 /// of the HLSL buffer after all of the elements with specified offset.
104 static CGHLSLOffsetInfo fromDecl(const HLSLBufferDecl &BufDecl);
105
106 /// Comparison function for offsets received from `operator[]` suitable for
107 /// use in a `stable_sort`. This will order implicit bindings after explicit
108 /// offsets.
109 static bool compareOffsets(uint32_t LHS, uint32_t RHS) { return LHS < RHS; }
110
111 /// Get the given offset, or `~0U` if there is no offset for the member.
112 uint32_t operator[](size_t I) const {
113 if (Offsets.empty())
114 return Unspecified;
115 return Offsets[I];
116 }
117
118 bool empty() const { return Offsets.empty(); }
119};
120
122public:
123 //===----------------------------------------------------------------------===//
124 // Start of reserved area for HLSL intrinsic getters.
125 //===----------------------------------------------------------------------===//
126
130 GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup,
131 flattened_thread_id_in_group)
136 GENERATE_HLSL_INTRINSIC_FUNCTION(Saturate, saturate)
138 GENERATE_HLSL_INTRINSIC_FUNCTION(ThreadId, thread_id)
139 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupThreadId, thread_id_in_group)
140 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupId, group_id)
144 GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddI8Packed, dot4add_i8packed)
145 GENERATE_HLSL_INTRINSIC_FUNCTION(Dot4AddU8Packed, dot4add_u8packed)
146 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAllEqual, wave_all_equal)
147 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAllTrue, wave_all)
148 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveAnyTrue, wave_any)
149 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitOr, wave_reduce_or)
150 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitXor, wave_reduce_xor)
151 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveBitAnd, wave_reduce_and)
152 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMax, wave_reduce_max)
153 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMax, wave_reduce_umax)
154 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMin, wave_reduce_min)
155 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMin, wave_reduce_umin)
156 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveCountBits, wave_active_countbits)
157 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
159 subgroup_size)
160 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
161 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneFirst, wave_readlane_first)
162 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossX, quad_read_across_x)
163 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossY, quad_read_across_y)
164 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossDiagonal,
165 quad_read_across_diagonal)
166 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitUHigh, firstbituhigh)
167 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitSHigh, firstbitshigh)
168 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitLow, firstbitlow)
172
173 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetBasePointer,
174 resource_getbasepointer)
175 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointer,
176 resource_getpointer)
178 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleClamp, resource_sample_clamp)
179 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBias, resource_samplebias)
180 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBiasClamp, resource_samplebias_clamp)
181 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGrad, resource_samplegrad)
182 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGradClamp, resource_samplegrad_clamp)
183 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleLevel, resource_samplelevel)
184 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmp, resource_samplecmp)
185 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmpClamp, resource_samplecmp_clamp)
186 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmpLevelZero,
187 resource_samplecmplevelzero)
188 GENERATE_HLSL_INTRINSIC_FUNCTION(Gather, resource_gather)
189 GENERATE_HLSL_INTRINSIC_FUNCTION(GatherCmp, resource_gather_cmp)
190 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding,
191 resource_handlefrombinding)
192 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromImplicitBinding,
193 resource_handlefromimplicitbinding)
195 resource_handlefromheap)
196 GENERATE_HLSL_INTRINSIC_FUNCTION(NonUniformResourceIndex,
197 resource_nonuniformindex)
198 GENERATE_HLSL_INTRINSIC_FUNCTION(BufferUpdateCounter, resource_updatecounter)
199 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrier, all_memory_barrier)
200 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrierWithGroupSync,
201 all_memory_barrier_with_group_sync)
202 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrier, device_memory_barrier)
203 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrierWithGroupSync,
204 device_memory_barrier_with_group_sync)
205 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrier, group_memory_barrier)
206 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrierWithGroupSync,
207 group_memory_barrier_with_group_sync)
208 llvm::Intrinsic::ID getBarrierByMemoryTypeIntrinsic() {
209 assert(getArch() == llvm::Triple::dxil &&
210 "Barrier by memory type is only supported for DXIL");
211 return llvm::Intrinsic::dx_barrier_by_memory_type;
212 }
213 llvm::Intrinsic::ID getBarrierByMemoryHandleIntrinsic() {
214 assert(getArch() == llvm::Triple::dxil &&
215 "Barrier by memory handle is only supported for DXIL");
216 return llvm::Intrinsic::dx_barrier_by_memory_handle;
217 }
218 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsX, resource_getdimensions_x)
219 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsXY, resource_getdimensions_xy)
220 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsLevelsXY,
221 resource_getdimensions_levels_xy)
222 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadLevel, resource_load_level)
223 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadMS, resource_load_ms)
224 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLod, resource_calculate_lod)
225 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLodUnclamped,
226 resource_calculate_lod_unclamped)
227 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxCoarse, ddx_coarse)
228 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyCoarse, ddy_coarse)
229 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxFine, ddx_fine)
230 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyFine, ddy_fine)
231
232 //===----------------------------------------------------------------------===//
233 // End of reserved area for HLSL intrinsic getters.
234 //===----------------------------------------------------------------------===//
235
236protected:
238 llvm::SmallVectorImpl<llvm::hlsl::SemanticSignatureElement>;
239
241
243 llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl,
244 HLSLAppliedSemanticAttr *Semantic,
245 llvm::dxbc::PSV::SemanticKind SemanticKind,
246 llvm::Triple::EnvironmentType Stage, std::optional<unsigned> Index,
247 SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode);
248
249 void emitSystemSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
250 const clang::DeclaratorDecl *Decl,
251 HLSLAppliedSemanticAttr *Semantic,
252 llvm::dxbc::PSV::SemanticKind SemanticKind,
253 llvm::Triple::EnvironmentType Stage,
254 std::optional<unsigned> Index,
255 SemanticSignatures &Signature,
256 llvm::hlsl::InterpolationMode InterpMode);
257
259 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type,
260 const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic,
261 SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode);
262
263 void handleScalarSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
264 llvm::Value *Source,
265 const clang::DeclaratorDecl *Decl,
266 HLSLAppliedSemanticAttr *Semantic,
267 SemanticSignatures &Signature,
268 llvm::hlsl::InterpolationMode InterpMode);
269
270 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
272 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type,
273 const clang::DeclaratorDecl *Decl,
274 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
275 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
276 SemanticSignatures &Signature,
277 llvm::hlsl::InterpolationModifier Modifiers);
278
279 specific_attr_iterator<HLSLAppliedSemanticAttr> handleStructSemanticStore(
280 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source,
281 const clang::DeclaratorDecl *Decl,
282 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
283 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
284 SemanticSignatures &Signature,
285 llvm::hlsl::InterpolationModifier Modifiers);
286
287 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
288 handleSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD,
290 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
291 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
292 SemanticSignatures &Signature,
293 llvm::hlsl::InterpolationModifier Modifiers =
294 llvm::hlsl::InterpolationModifier::None);
295
296 specific_attr_iterator<HLSLAppliedSemanticAttr>
297 handleSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
298 llvm::Value *Source, const clang::DeclaratorDecl *Decl,
299 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
300 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
301 SemanticSignatures &Signature,
302 llvm::hlsl::InterpolationModifier Modifiers =
303 llvm::hlsl::InterpolationModifier::None);
304
305public:
307 virtual ~CGHLSLRuntime() {}
308
309 llvm::Type *convertHLSLSpecificType(const Type *T,
310 const CGHLSLOffsetInfo &OffsetInfo);
311 llvm::Type *convertHLSLSpecificType(const Type *T) {
313 }
314
316
317 void addBuffer(const HLSLBufferDecl *D);
319 void finishCodeGen();
320
321 void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
322
323 void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
324 void handleGlobalVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Var);
325
326 llvm::Instruction *getConvergenceToken(llvm::BasicBlock &BB);
327
328 llvm::StructType *getHLSLBufferLayoutType(const RecordType *LayoutStructTy);
329 void addHLSLBufferLayoutType(const RecordType *LayoutStructTy,
330 llvm::StructType *LayoutTy);
332
333 std::optional<LValue>
335 CodeGenFunction &CGF);
336
337 bool emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E,
338 AggValueSlot &DestSlot);
339 std::optional<LValue>
341 const VarDecl *ArrayDecl);
342
343 std::optional<LValue> emitBufferArraySubscriptExpr(
344 const ArraySubscriptExpr *E, CodeGenFunction &CGF,
345 llvm::function_ref<llvm::Value *(bool Promote)> EmitIdxAfterBase);
346
348 CodeGenFunction &CGF);
349
350 bool emitBufferCopy(CodeGenFunction &CGF, const Expr *E, const LValue &SrcLV,
351 AggValueSlot &DestSlot);
352
354 std::optional<LValue> emitResourceMemberExpr(CodeGenFunction &CGF,
355 const MemberExpr *E);
356
357private:
358 void emitBufferGlobalsAndMetadata(const HLSLBufferDecl *BufDecl,
359 llvm::GlobalVariable *BufGV,
360 const CGHLSLOffsetInfo &OffsetInfo);
361 void initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
362 llvm::GlobalVariable *GV);
363
364 llvm::Value *emitSPIRVUserSemanticLoad(
365 llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl,
366 HLSLAppliedSemanticAttr *Semantic, std::optional<unsigned> Index,
367 llvm::hlsl::InterpolationMode InterpMode);
368 llvm::Value *emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
370 HLSLAppliedSemanticAttr *Semantic,
371 std::optional<unsigned> Index,
372 SemanticSignatures &Signature);
373 llvm::Value *emitUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
375 HLSLAppliedSemanticAttr *Semantic,
376 std::optional<unsigned> Index,
377 SemanticSignatures &Signature,
378 llvm::hlsl::InterpolationMode InterpMode);
379
380 void emitSPIRVUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
382 HLSLAppliedSemanticAttr *Semantic,
383 std::optional<unsigned> Index,
384 llvm::hlsl::InterpolationMode InterpMode);
385 void emitDXILUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
387 HLSLAppliedSemanticAttr *Semantic,
388 std::optional<unsigned> Index,
389 SemanticSignatures &Signature);
390 void emitUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
392 HLSLAppliedSemanticAttr *Semantic,
393 std::optional<unsigned> Index,
394 SemanticSignatures &Signature,
395 llvm::hlsl::InterpolationMode InterpMode);
396
397 bool initializeGlobalResourceArray(CodeGenFunction &CGF,
398 const VarDecl *ArrayDecl,
399 AggValueSlot &DestSlot);
400
401 llvm::Triple::ArchType getArch();
402
403 llvm::DenseMap<const clang::RecordType *, llvm::StructType *> LayoutTypes;
404 unsigned SPIRVLastAssignedInputSemanticLocation = 0;
405 unsigned SPIRVLastAssignedOutputSemanticLocation = 0;
406};
407
408} // namespace CodeGen
409} // namespace clang
410
411#endif
Defines enum values for all the target-independent builtin functions.
#define GENERATE_HLSL_INTRINSIC_FUNCTION(FunctionName, IntrinsicPostfix)
llvm::dxil::ResourceClass ResourceClass
#define GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(FunctionName, DxilPostfix, SpirvPostfix)
Defines helper utilities for supporting the HLSL runtime environment.
llvm::dxbc::PSV::SemanticKind SemanticKind
Definition SemaHLSL.cpp:62
__DEVICE__ bool isnan(float __x)
Test for a NaN.
__DEVICE__ bool isfinite(float __x)
Test for finite value.
__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:2790
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)
void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn)
llvm::Value * handleScalarSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode)
llvm::StructType * getHLSLBufferLayoutType(const RecordType *LayoutStructTy)
void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn)
void handleGlobalVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Var)
void handleScalarSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source, const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic, SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode)
std::optional< LValue > emitResourceMemberExpr(CodeGenFunction &CGF, const MemberExpr *E)
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::hlsl::InterpolationModifier Modifiers)
llvm::SmallVectorImpl< llvm::hlsl::SemanticSignatureElement > SemanticSignatures
void addHLSLBufferLayoutType(const RecordType *LayoutStructTy, llvm::StructType *LayoutTy)
llvm::Intrinsic::ID getBarrierByMemoryHandleIntrinsic()
std::optional< LValue > emitGlobalResourceArrayAsLValue(CodeGenFunction &CGF, const VarDecl *ArrayDecl)
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::hlsl::InterpolationMode InterpMode)
bool emitBufferCopy(CodeGenFunction &CGF, const Expr *E, const LValue &SrcLV, AggValueSlot &DestSlot)
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::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, llvm::hlsl::InterpolationMode InterpMode)
llvm::Type * convertHLSLSpecificType(const Type *T)
llvm::Type * convertHLSLSpecificType(const Type *T, const CGHLSLOffsetInfo &OffsetInfo)
RawAddress createBufferMatrixTempAddress(const LValue &LV, CodeGenFunction &CGF)
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, llvm::hlsl::InterpolationModifier Modifiers=llvm::hlsl::InterpolationModifier::None)
GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup, flattened_thread_id_in_group) GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveGetLaneCount
void addBuffer(const HLSLBufferDecl *D)
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, llvm::hlsl::InterpolationModifier Modifiers)
bool emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E, AggValueSlot &DestSlot)
void emitInitListOpaqueValues(CodeGenFunction &CGF, InitListExpr *E)
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, llvm::hlsl::InterpolationModifier Modifiers=llvm::hlsl::InterpolationModifier::None)
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:1467
Represents a ValueDecl that came out of a declarator.
Definition Decl.h:782
This represents one expression.
Definition Expr.h:114
Represents a function declaration or definition.
Definition Decl.h:2071
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition Decl.h:5348
Describes an C or C++ initializer list.
Definition Expr.h:5377
MemberExpr - [C99 6.5.2.3] Structure and Union Members.
Definition Expr.h:3433
This represents a decl that may have a name.
Definition Decl.h:276
Represents a parameter to a function.
Definition Decl.h:1832
The base class of the type hierarchy.
Definition TypeBase.h:1879
Represents a variable declaration or definition.
Definition Decl.h:934
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.