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 //===----------------------------------------------------------------------===//
127 GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup,
128 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_BASE(WaveMultiPrefixBitAnd,
151 subgroup_multi_prefix_bit_and)
153 wave_multi_prefix_bit_or,
154 subgroup_multi_prefix_bit_or)
155 GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixBitXor,
157 subgroup_multi_prefix_bit_xor)
159 wave_multi_prefix_product,
160 subgroup_multi_prefix_product)
161 GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixUProduct,
163 subgroup_multi_prefix_product)
165 wave_multi_prefix_sum,
166 subgroup_multi_prefix_sum)
167 GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixUSum,
169 subgroup_multi_prefix_sum)
170 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMax, wave_reduce_max)
171 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMax, wave_reduce_umax)
172 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveMin, wave_reduce_min)
173 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveUMin, wave_reduce_umin)
174 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveActiveCountBits, wave_active_countbits)
175 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
176 GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveGetLaneCount, wave_get_lane_count,
177 subgroup_size)
178 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
179 GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneFirst, wave_readlane_first)
180 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadAll, quad_all)
181 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossX, quad_read_across_x)
182 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossY, quad_read_across_y)
183 GENERATE_HLSL_INTRINSIC_FUNCTION(QuadReadAcrossDiagonal,
184 quad_read_across_diagonal)
185 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitUHigh, firstbituhigh)
186 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitSHigh, firstbitshigh)
187 GENERATE_HLSL_INTRINSIC_FUNCTION(FirstBitLow, firstbitlow)
191
192 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetBasePointer,
193 resource_getbasepointer)
194 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateResourceGetPointer,
195 resource_getpointer)
197 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleClamp, resource_sample_clamp)
198 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBias, resource_samplebias)
199 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleBiasClamp, resource_samplebias_clamp)
200 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGrad, resource_samplegrad)
201 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleGradClamp, resource_samplegrad_clamp)
202 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleLevel, resource_samplelevel)
203 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmp, resource_samplecmp)
204 GENERATE_HLSL_INTRINSIC_FUNCTION(SampleCmpClamp, resource_samplecmp_clamp)
206 resource_samplecmplevelzero)
207 GENERATE_HLSL_INTRINSIC_FUNCTION(Gather, resource_gather)
208 GENERATE_HLSL_INTRINSIC_FUNCTION(GatherCmp, resource_gather_cmp)
209 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromBinding,
210 resource_handlefrombinding)
211 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromImplicitBinding,
212 resource_handlefromimplicitbinding)
213 GENERATE_HLSL_INTRINSIC_FUNCTION(CreateHandleFromHeap,
214 resource_handlefromheap)
215 GENERATE_HLSL_INTRINSIC_FUNCTION(NonUniformResourceIndex,
216 resource_nonuniformindex)
217 GENERATE_HLSL_INTRINSIC_FUNCTION(BufferUpdateCounter, resource_updatecounter)
218 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrier, all_memory_barrier)
219 GENERATE_HLSL_INTRINSIC_FUNCTION(AllMemoryBarrierWithGroupSync,
220 all_memory_barrier_with_group_sync)
221 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrier, device_memory_barrier)
222 GENERATE_HLSL_INTRINSIC_FUNCTION(DeviceMemoryBarrierWithGroupSync,
223 device_memory_barrier_with_group_sync)
224 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrier, group_memory_barrier)
225 GENERATE_HLSL_INTRINSIC_FUNCTION(GroupMemoryBarrierWithGroupSync,
226 group_memory_barrier_with_group_sync)
228 assert(getArch() == llvm::Triple::dxil &&
229 "Barrier by memory type is only supported for DXIL");
230 return llvm::Intrinsic::dx_barrier_by_memory_type;
231 }
232 llvm::Intrinsic::ID getBarrierByMemoryHandleIntrinsic() {
233 assert(getArch() == llvm::Triple::dxil &&
234 "Barrier by memory handle is only supported for DXIL");
235 return llvm::Intrinsic::dx_barrier_by_memory_handle;
236 }
237 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsX, resource_getdimensions_x)
238 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsXY, resource_getdimensions_xy)
239 GENERATE_HLSL_INTRINSIC_FUNCTION(GetDimensionsLevelsXY,
240 resource_getdimensions_levels_xy)
241 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadLevel, resource_load_level)
242 GENERATE_HLSL_INTRINSIC_FUNCTION(LoadMS, resource_load_ms)
243 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLod, resource_calculate_lod)
244 GENERATE_HLSL_INTRINSIC_FUNCTION(CalculateLodUnclamped,
245 resource_calculate_lod_unclamped)
246 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxCoarse, ddx_coarse)
247 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyCoarse, ddy_coarse)
248 GENERATE_HLSL_INTRINSIC_FUNCTION(DdxFine, ddx_fine)
249 GENERATE_HLSL_INTRINSIC_FUNCTION(DdyFine, ddy_fine)
250
251 //===----------------------------------------------------------------------===//
252 // End of reserved area for HLSL intrinsic getters.
253 //===----------------------------------------------------------------------===//
254
255protected:
257 llvm::SmallVectorImpl<llvm::hlsl::SemanticSignatureElement>;
258
260
262 llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl,
263 HLSLAppliedSemanticAttr *Semantic,
264 llvm::dxbc::PSV::SemanticKind SemanticKind,
265 llvm::Triple::EnvironmentType Stage, std::optional<unsigned> Index,
266 SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode);
267
268 void emitSystemSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
269 const clang::DeclaratorDecl *Decl,
270 HLSLAppliedSemanticAttr *Semantic,
271 llvm::dxbc::PSV::SemanticKind SemanticKind,
272 llvm::Triple::EnvironmentType Stage,
273 std::optional<unsigned> Index,
274 SemanticSignatures &Signature,
275 llvm::hlsl::InterpolationMode InterpMode);
276
278 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type,
279 const clang::DeclaratorDecl *Decl, HLSLAppliedSemanticAttr *Semantic,
280 SemanticSignatures &Signature, llvm::hlsl::InterpolationMode InterpMode);
281
282 void handleScalarSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
283 llvm::Value *Source,
284 const clang::DeclaratorDecl *Decl,
285 HLSLAppliedSemanticAttr *Semantic,
286 SemanticSignatures &Signature,
287 llvm::hlsl::InterpolationMode InterpMode);
288
289 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
291 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Type *Type,
292 const clang::DeclaratorDecl *Decl,
293 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
294 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
295 SemanticSignatures &Signature,
296 llvm::hlsl::InterpolationModifier Modifiers);
297
298 specific_attr_iterator<HLSLAppliedSemanticAttr> handleStructSemanticStore(
299 llvm::IRBuilder<> &B, const FunctionDecl *FD, llvm::Value *Source,
300 const clang::DeclaratorDecl *Decl,
301 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
302 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
303 SemanticSignatures &Signature,
304 llvm::hlsl::InterpolationModifier Modifiers);
305
306 std::pair<llvm::Value *, specific_attr_iterator<HLSLAppliedSemanticAttr>>
307 handleSemanticLoad(llvm::IRBuilder<> &B, const FunctionDecl *FD,
309 specific_attr_iterator<HLSLAppliedSemanticAttr> begin,
310 specific_attr_iterator<HLSLAppliedSemanticAttr> end,
311 SemanticSignatures &Signature,
312 llvm::hlsl::InterpolationModifier Modifiers =
313 llvm::hlsl::InterpolationModifier::None);
314
315 specific_attr_iterator<HLSLAppliedSemanticAttr>
316 handleSemanticStore(llvm::IRBuilder<> &B, const FunctionDecl *FD,
317 llvm::Value *Source, const clang::DeclaratorDecl *Decl,
318 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrBegin,
319 specific_attr_iterator<HLSLAppliedSemanticAttr> AttrEnd,
320 SemanticSignatures &Signature,
321 llvm::hlsl::InterpolationModifier Modifiers =
322 llvm::hlsl::InterpolationModifier::None);
323
324public:
326 virtual ~CGHLSLRuntime() {}
327
328 llvm::Type *convertHLSLSpecificType(const Type *T,
329 const CGHLSLOffsetInfo &OffsetInfo);
330 llvm::Type *convertHLSLSpecificType(const Type *T) {
332 }
333
335
336 void addBuffer(const HLSLBufferDecl *D);
338 void finishCodeGen();
339
340 void setHLSLEntryAttributes(const FunctionDecl *FD, llvm::Function *Fn);
341
342 void emitEntryFunction(const FunctionDecl *FD, llvm::Function *Fn);
343 void handleGlobalVarDefinition(const VarDecl *VD, llvm::GlobalVariable *Var);
344
345 llvm::Instruction *getConvergenceToken(llvm::BasicBlock &BB);
346
347 llvm::StructType *getHLSLBufferLayoutType(const RecordType *LayoutStructTy);
348 void addHLSLBufferLayoutType(const RecordType *LayoutStructTy,
349 llvm::StructType *LayoutTy);
351
352 std::optional<LValue>
354 CodeGenFunction &CGF);
355
356 bool emitGlobalResourceArray(CodeGenFunction &CGF, const Expr *E,
357 AggValueSlot &DestSlot);
358 std::optional<LValue>
360 const VarDecl *ArrayDecl);
361
362 std::optional<LValue> emitBufferArraySubscriptExpr(
363 const ArraySubscriptExpr *E, CodeGenFunction &CGF,
364 llvm::function_ref<llvm::Value *(bool Promote)> EmitIdxAfterBase);
365
367 CodeGenFunction &CGF);
368
369 bool emitBufferCopy(CodeGenFunction &CGF, const Expr *E, const LValue &SrcLV,
370 AggValueSlot &DestSlot);
371
373 std::optional<LValue> emitResourceMemberExpr(CodeGenFunction &CGF,
374 const MemberExpr *E);
375
376private:
377 void emitBufferGlobalsAndMetadata(const HLSLBufferDecl *BufDecl,
378 llvm::GlobalVariable *BufGV,
379 const CGHLSLOffsetInfo &OffsetInfo);
380 void initializeBufferFromBinding(const HLSLBufferDecl *BufDecl,
381 llvm::GlobalVariable *GV);
382
383 llvm::Value *emitSPIRVUserSemanticLoad(
384 llvm::IRBuilder<> &B, llvm::Type *Type, const clang::DeclaratorDecl *Decl,
385 HLSLAppliedSemanticAttr *Semantic, std::optional<unsigned> Index,
386 llvm::hlsl::InterpolationMode InterpMode);
387 llvm::Value *emitDXILUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
389 HLSLAppliedSemanticAttr *Semantic,
390 std::optional<unsigned> Index,
391 SemanticSignatures &Signature);
392 llvm::Value *emitUserSemanticLoad(llvm::IRBuilder<> &B, llvm::Type *Type,
394 HLSLAppliedSemanticAttr *Semantic,
395 std::optional<unsigned> Index,
396 SemanticSignatures &Signature,
397 llvm::hlsl::InterpolationMode InterpMode);
398
399 void emitSPIRVUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
401 HLSLAppliedSemanticAttr *Semantic,
402 std::optional<unsigned> Index,
403 llvm::hlsl::InterpolationMode InterpMode);
404 void emitDXILUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
406 HLSLAppliedSemanticAttr *Semantic,
407 std::optional<unsigned> Index,
408 SemanticSignatures &Signature);
409 void emitUserSemanticStore(llvm::IRBuilder<> &B, llvm::Value *Source,
411 HLSLAppliedSemanticAttr *Semantic,
412 std::optional<unsigned> Index,
413 SemanticSignatures &Signature,
414 llvm::hlsl::InterpolationMode InterpMode);
415
416 bool initializeGlobalResourceArray(CodeGenFunction &CGF,
417 const VarDecl *ArrayDecl,
418 AggValueSlot &DestSlot);
419
420 llvm::Triple::ArchType getArch();
421
422 llvm::DenseMap<const clang::RecordType *, llvm::StructType *> LayoutTypes;
423 unsigned SPIRVLastAssignedInputSemanticLocation = 0;
424 unsigned SPIRVLastAssignedOutputSemanticLocation = 0;
425};
426
427} // namespace CodeGen
428} // namespace clang
429
430#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:63
__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()
subgroup_multi_prefix_bit_and subgroup_multi_prefix_bit_xor wave_multi_prefix_uproduct
subgroup_multi_prefix_bit_and subgroup_multi_prefix_bit_xor subgroup_multi_prefix_product subgroup_multi_prefix_sum quad_read_across_diagonal resource_getpointer resource_handlefrombinding resource_handlefromheap all_memory_barrier_with_group_sync group_memory_barrier_with_group_sync llvm::Intrinsic::ID getBarrierByMemoryTypeIntrinsic()
std::optional< LValue > emitGlobalResourceArrayAsLValue(CodeGenFunction &CGF, const VarDecl *ArrayDecl)
subgroup_multi_prefix_bit_and subgroup_multi_prefix_bit_xor subgroup_multi_prefix_product wave_multi_prefix_usum
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)
GENERATE_HLSL_INTRINSIC_FUNCTION(FlattenedThreadIdInGroup, flattened_thread_id_in_group) GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixBitAnd
subgroup_multi_prefix_bit_and wave_multi_prefix_bit_xor
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)
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)
subgroup_multi_prefix_bit_and GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixBitOr, wave_multi_prefix_bit_or, subgroup_multi_prefix_bit_or) GENERATE_HLSL_INTRINSIC_FUNCTION_BASE(WaveMultiPrefixBitXor
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:2082
HLSLBufferDecl - Represent a cbuffer or tbuffer declaration.
Definition Decl.h:5380
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.