30
30
#include < optional>
31
31
#include < vector>
32
32
33
- #define GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (FunctionName, \
34
- IntrinsicPostfix) \
35
- GENERATE_HLSL_INTRINSIC_FUNCTION (FunctionName, IntrinsicPostfix, 1 , 1 )
36
-
37
33
// A function generator macro for picking the right intrinsic
38
34
// for the target backend
39
- #define GENERATE_HLSL_INTRINSIC_FUNCTION (FunctionName, IntrinsicPostfix, \
40
- IncludeDXIL, IncludeSPIRV) \
35
+ #define GENERATE_HLSL_INTRINSIC_FUNCTION (FunctionName, IntrinsicPostfix ) \
41
36
llvm::Intrinsic::ID get##FunctionName##Intrinsic() { \
42
37
llvm::Triple::ArchType Arch = getArch (); \
43
38
switch (Arch) { \
44
- /* Include DXIL case only if IncludeDXIL is true */ \
45
- IF_INCLUDE (IncludeDXIL, case llvm::Triple::dxil \
46
- : return llvm::Intrinsic::dx_##IntrinsicPostfix;) \
47
- /* Include SPIRV case only if IncludeSPIRV is true */ \
48
- IF_INCLUDE (IncludeSPIRV, case llvm::Triple::spirv \
49
- : return llvm::Intrinsic::spv_##IntrinsicPostfix;) \
50
- \
39
+ case llvm::Triple::dxil: \
40
+ return llvm::Intrinsic::dx_##IntrinsicPostfix; \
41
+ case llvm::Triple::spirv: \
42
+ return llvm::Intrinsic::spv_##IntrinsicPostfix; \
51
43
default : \
52
44
llvm_unreachable (" Intrinsic " #IntrinsicPostfix \
53
45
" not supported by target architecture" ); \
54
46
} \
55
47
}
56
48
57
- #define IF_INCLUDE (Condition, Code ) IF_INCLUDE_IMPL(Condition, Code)
58
- #define IF_INCLUDE_IMPL (Condition, Code ) IF_INCLUDE_##Condition(Code)
59
-
60
- #define IF_INCLUDE_1 (Code ) Code
61
- #define IF_INCLUDE_0 (Code )
62
-
63
49
namespace llvm {
64
50
class GlobalVariable ;
65
51
class Function ;
@@ -86,39 +72,36 @@ class CGHLSLRuntime {
86
72
// Start of reserved area for HLSL intrinsic getters.
87
73
// ===----------------------------------------------------------------------===//
88
74
89
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (All, all)
90
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Any, any)
91
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Cross, cross)
92
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Degrees, degrees)
93
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Frac, frac)
94
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Lerp, lerp)
95
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Normalize, normalize)
96
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Rsqrt, rsqrt)
97
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Saturate, saturate)
98
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Sign, sign)
99
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Step, step)
100
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Radians, radians)
101
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (ThreadId, thread_id)
102
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (FDot, fdot)
103
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (SDot, sdot)
104
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (UDot, udot)
105
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Dot4AddI8Packed, dot4add_i8packed)
106
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (Dot4AddU8Packed, dot4add_u8packed)
107
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (WaveActiveAnyTrue, wave_any)
108
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (WaveActiveCountBits,
109
- wave_active_countbits)
110
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (WaveIsFirstLane, wave_is_first_lane)
111
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (WaveReadLaneAt, wave_readlane)
112
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (FirstBitUHigh, firstbituhigh)
113
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (FirstBitSHigh, firstbitshigh)
114
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (NClamp, nclamp)
115
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (SClamp, sclamp)
116
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (UClamp, uclamp)
117
-
118
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (CreateHandleFromBinding,
119
- handle_fromBinding)
120
- GENERATE_HLSL_INTRINSIC_FUNCTION_DEFAULT (BufferUpdateCounter,
121
- bufferUpdateCounter)
75
+ GENERATE_HLSL_INTRINSIC_FUNCTION (All, all)
76
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Any, any)
77
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Cross, cross)
78
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Degrees, degrees)
79
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Frac, frac)
80
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Lerp, lerp)
81
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Normalize, normalize)
82
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Rsqrt, rsqrt)
83
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Saturate, saturate)
84
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Sign, sign)
85
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Step, step)
86
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Radians, radians)
87
+ GENERATE_HLSL_INTRINSIC_FUNCTION (ThreadId, thread_id)
88
+ GENERATE_HLSL_INTRINSIC_FUNCTION (FDot, fdot)
89
+ GENERATE_HLSL_INTRINSIC_FUNCTION (SDot, sdot)
90
+ GENERATE_HLSL_INTRINSIC_FUNCTION (UDot, udot)
91
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Dot4AddI8Packed, dot4add_i8packed)
92
+ GENERATE_HLSL_INTRINSIC_FUNCTION (Dot4AddU8Packed, dot4add_u8packed)
93
+ GENERATE_HLSL_INTRINSIC_FUNCTION (WaveActiveAnyTrue, wave_any)
94
+ GENERATE_HLSL_INTRINSIC_FUNCTION (WaveActiveCountBits, wave_active_countbits)
95
+ GENERATE_HLSL_INTRINSIC_FUNCTION (WaveIsFirstLane, wave_is_first_lane)
96
+ GENERATE_HLSL_INTRINSIC_FUNCTION (WaveReadLaneAt, wave_readlane)
97
+ GENERATE_HLSL_INTRINSIC_FUNCTION (FirstBitUHigh, firstbituhigh)
98
+ GENERATE_HLSL_INTRINSIC_FUNCTION (FirstBitSHigh, firstbitshigh)
99
+ GENERATE_HLSL_INTRINSIC_FUNCTION (NClamp, nclamp)
100
+ GENERATE_HLSL_INTRINSIC_FUNCTION (SClamp, sclamp)
101
+ GENERATE_HLSL_INTRINSIC_FUNCTION (UClamp, uclamp)
102
+
103
+ GENERATE_HLSL_INTRINSIC_FUNCTION (CreateHandleFromBinding, handle_fromBinding)
104
+ GENERATE_HLSL_INTRINSIC_FUNCTION (BufferUpdateCounter, bufferUpdateCounter)
122
105
123
106
// ===----------------------------------------------------------------------===//
124
107
// End of reserved area for HLSL intrinsic getters.
0 commit comments