13
13
14
14
include "llvm/IR/Intrinsics.td"
15
15
16
- // Abstract class to represent major and minor version values
17
- class Version<int major, int minor> {
18
- int Major = major;
19
- int Minor = minor;
20
- }
21
-
22
- // Valid minimum Shader model version records
23
-
24
- // Shader Model 6.0 - 6.8
25
- foreach i = 0...8 in {
26
- def SM6_#i : Version<6, i>;
27
- }
28
-
29
- // Abstraction of class mapping valid DXIL Op overloads the minimum
30
- // version of Shader Model they are supported
31
- class DXILOpOverload<Version minsm, list<LLVMType> overloads> {
32
- Version ShaderModel = minsm;
33
- list<LLVMType> OpOverloads = overloads;
34
- }
35
-
36
16
// Abstraction of DXIL Operation class.
37
17
// It encapsulates an associated function signature viz.,
38
18
// returnTy(param1Ty, param2Ty, ...) represented as a list of LLVMTypes.
@@ -44,10 +24,9 @@ class DXILOpClass<list<LLVMType> OpSig> {
44
24
}
45
25
46
26
// Concrete definitions of DXIL Op Classes
47
- // Note that these class name strings are specified as the third argument
48
- // of add_dixil_op in utils/hct/hctdb.py and case converted in
49
- // utils/hct/hctdb_instrhelp.py of DirectXShaderCompiler repo. The function
50
- // name has the format "dx.op.<class-name>.<return-type>", in most cases.
27
+ // Refer to the design document
28
+ // (https://github.com/llvm/llvm-project/blob/main/llvm/docs/DirectX/DXILOpTableGenDesign.rst)
29
+ // for details about the use of DXIL Op Class name.
51
30
52
31
// NOTE: The following list is not complete. Classes need to be defined as new DXIL Ops
53
32
// are added.
@@ -81,123 +60,120 @@ class DXILOpPropertiesBase {
81
60
int OpCode = 0; // Opcode of DXIL Operation
82
61
DXILOpClass OpClass = UnknownOpClass;// Class of DXIL Operation.
83
62
Intrinsic LLVMIntrinsic = ?; // LLVM Intrinsic DXIL Operation maps to
84
- list<DXILOpOverload > OpOverloadTypes = ?; // Valid overload type
63
+ list<LLVMType > OpOverloadTypes = ?; // Valid overload type
85
64
// of DXIL Operation
86
65
string Doc = ""; // A short description of the operation
87
66
}
88
67
89
68
class DXILOpProperties<int opCode,
90
69
Intrinsic intrinsic,
91
- list<DXILOpOverload > overloadTypes,
70
+ list<LLVMType > overloadTypes,
92
71
string doc> : DXILOpPropertiesBase {
93
72
int OpCode = opCode;
94
73
Intrinsic LLVMIntrinsic = intrinsic;
95
- list<DXILOpOverload > OpOverloadTypes = overloadTypes;
74
+ list<LLVMType > OpOverloadTypes = overloadTypes;
96
75
string Doc = doc;
97
76
}
98
77
99
78
// Concrete definitions of DXIL Operation Properties to corresponding LLVM intrinsic
100
79
101
80
// IsSpecialFloat Class
102
81
let OpClass = isSpecialFloat in {
103
- def IsInf : DXILOpProperties<9, int_dx_isinf, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
82
+ def IsInf : DXILOpProperties<9, int_dx_isinf, [llvm_half_ty, llvm_float_ty],
104
83
"Determines if the specified value is infinite.">;
105
84
}
106
85
107
86
let OpClass = unary in {
108
- def Abs : DXILOpProperties<6, int_fabs, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty, llvm_double_ty]> ],
87
+ def Abs : DXILOpProperties<6, int_fabs, [llvm_half_ty, llvm_float_ty, llvm_double_ty],
109
88
"Returns the absolute value of the input.">;
110
89
111
- def Cos : DXILOpProperties<12, int_cos, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
90
+ def Cos : DXILOpProperties<12, int_cos, [llvm_half_ty, llvm_float_ty],
112
91
"Returns cosine(theta) for theta in radians.">;
113
- def Sin : DXILOpProperties<13, int_sin, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
92
+ def Sin : DXILOpProperties<13, int_sin, [llvm_half_ty, llvm_float_ty],
114
93
"Returns sine(theta) for theta in radians.">;
115
- def Tan : DXILOpProperties<14, int_tan, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
94
+ def Tan : DXILOpProperties<14, int_tan, [llvm_half_ty, llvm_float_ty],
116
95
"Returns tangent(theta) for theta in radians.">;
117
- def Exp2 : DXILOpProperties<21, int_exp2, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
96
+ def Exp2 : DXILOpProperties<21, int_exp2, [llvm_half_ty, llvm_float_ty],
118
97
"Returns the base 2 exponential, or 2**x, of the"
119
98
" specified value. exp2(x) = 2**x.">;
120
- def Frac : DXILOpProperties<22, int_dx_frac, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
99
+ def Frac : DXILOpProperties<22, int_dx_frac, [llvm_half_ty, llvm_float_ty],
121
100
"Returns a fraction from 0 to 1 that represents the"
122
101
" decimal part of the input.">;
123
- def Log2 : DXILOpProperties<23, int_log2, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
102
+ def Log2 : DXILOpProperties<23, int_log2, [llvm_half_ty, llvm_float_ty],
124
103
"Returns the base-2 logarithm of the specified value.">;
125
- def Sqrt : DXILOpProperties<24, int_sqrt, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
104
+ def Sqrt : DXILOpProperties<24, int_sqrt, [llvm_half_ty, llvm_float_ty],
126
105
"Returns the square root of the specified floating-point"
127
106
"value, per component.">;
128
- def RSqrt : DXILOpProperties<25, int_dx_rsqrt, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
107
+ def RSqrt : DXILOpProperties<25, int_dx_rsqrt, [llvm_half_ty, llvm_float_ty],
129
108
"Returns the reciprocal of the square root of the"
130
109
" specified value. rsqrt(x) = 1 / sqrt(x).">;
131
- def Round : DXILOpProperties<26, int_roundeven, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
110
+ def Round : DXILOpProperties<26, int_roundeven, [llvm_half_ty, llvm_float_ty],
132
111
"Returns the input rounded to the nearest integer"
133
112
"within a floating-point type.">;
134
- def Floor : DXILOpProperties<27, int_floor, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
113
+ def Floor : DXILOpProperties<27, int_floor, [llvm_half_ty, llvm_float_ty],
135
114
"Returns the largest integer that is less than or equal to the input.">;
136
- def Ceil : DXILOpProperties<28, int_ceil, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
115
+ def Ceil : DXILOpProperties<28, int_ceil, [llvm_half_ty, llvm_float_ty],
137
116
"Returns the smallest integer that is greater than or equal to the input.">;
138
- def Trunc : DXILOpProperties<29, int_trunc, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
117
+ def Trunc : DXILOpProperties<29, int_trunc, [llvm_half_ty, llvm_float_ty],
139
118
"Returns the specified value truncated to the integer component.">;
140
- def Rbits : DXILOpProperties<30, int_bitreverse, [DXILOpOverload<SM6_0, [ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
119
+ def Rbits : DXILOpProperties<30, int_bitreverse, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
141
120
"Returns the specified value with its bits reversed.">;
142
121
}
143
122
144
123
let OpClass = binary in {
145
124
// Float overloads
146
- def FMax : DXILOpProperties<35, int_maxnum, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty, llvm_double_ty]> ],
125
+ def FMax : DXILOpProperties<35, int_maxnum, [llvm_half_ty, llvm_float_ty, llvm_double_ty],
147
126
"Float maximum. FMax(a,b) = a > b ? a : b">;
148
- def FMin : DXILOpProperties<36, int_minnum, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty, llvm_double_ty]> ],
127
+ def FMin : DXILOpProperties<36, int_minnum, [llvm_half_ty, llvm_float_ty, llvm_double_ty],
149
128
"Float minimum. FMin(a,b) = a < b ? a : b">;
150
129
// Int overloads
151
- def SMax : DXILOpProperties<37, int_smax, [DXILOpOverload<SM6_0,[ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
130
+ def SMax : DXILOpProperties<37, int_smax, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
152
131
"Signed integer maximum. SMax(a,b) = a > b ? a : b">;
153
- def SMin : DXILOpProperties<38, int_smin, [DXILOpOverload<SM6_0,[ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
132
+ def SMin : DXILOpProperties<38, int_smin, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
154
133
"Signed integer minimum. SMin(a,b) = a < b ? a : b">;
155
- def UMax : DXILOpProperties<39, int_umax, [DXILOpOverload<SM6_0,[ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
134
+ def UMax : DXILOpProperties<39, int_umax, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
156
135
"Unsigned integer maximum. UMax(a,b) = a > b ? a : b">;
157
- def UMin : DXILOpProperties<40, int_umin, [DXILOpOverload<SM6_0,[ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
136
+ def UMin : DXILOpProperties<40, int_umin, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
158
137
"Unsigned integer minimum. UMin(a,b) = a < b ? a : b">;
159
138
}
160
139
161
140
let OpClass = tertiary in {
162
- def FMad : DXILOpProperties<46, int_fmuladd, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty, llvm_double_ty]> ],
141
+ def FMad : DXILOpProperties<46, int_fmuladd, [llvm_half_ty, llvm_float_ty, llvm_double_ty],
163
142
"Floating point arithmetic multiply/add operation."
164
143
" fmad(m,a,b) = m * a + b.">;
165
144
// Int overloads
166
- def IMad : DXILOpProperties<48, int_dx_imad, [DXILOpOverload<SM6_0, [ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
145
+ def IMad : DXILOpProperties<48, int_dx_imad, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
167
146
"Signed integer arithmetic multiply/add operation."
168
147
" imad(m,a,b) = m * a + b.">;
169
- def UMad : DXILOpProperties<49, int_dx_umad, [DXILOpOverload<SM6_0, [ llvm_i16_ty, llvm_i32_ty, llvm_i64_ty]> ],
148
+ def UMad : DXILOpProperties<49, int_dx_umad, [llvm_i16_ty, llvm_i32_ty, llvm_i64_ty],
170
149
"Unsigned integer arithmetic multiply/add operation."
171
150
" umad(m,a, = m * a + b.">;
172
151
}
173
152
174
- // Dot Operations
175
153
let OpClass = dot2 in
176
- def Dot2 : DXILOpProperties<54, int_dx_dot2, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
154
+ def Dot2 : DXILOpProperties<54, int_dx_dot2, [llvm_half_ty, llvm_float_ty],
177
155
"dot product of two float vectors Dot(a,b) = a[0]*b[0] +"
178
156
" ... + a[n]*b[n] where n is between 0 and 1">;
179
157
let OpClass = dot3 in
180
- def Dot3 : DXILOpProperties<55, int_dx_dot3, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
158
+ def Dot3 : DXILOpProperties<55, int_dx_dot3, [llvm_half_ty, llvm_float_ty],
181
159
"dot product of two float vectors Dot(a,b) = a[0]*b[0] +"
182
160
" ... + a[n]*b[n] where n is between 0 and 2">;
183
161
let OpClass = dot4 in
184
- def Dot4 : DXILOpProperties<56, int_dx_dot4, [DXILOpOverload<SM6_0, [ llvm_half_ty, llvm_float_ty]> ],
162
+ def Dot4 : DXILOpProperties<56, int_dx_dot4, [llvm_half_ty, llvm_float_ty],
185
163
"dot product of two float vectors Dot(a,b) = a[0]*b[0] +"
186
164
" ... + a[n]*b[n] where n is between 0 and 3">;
187
-
188
- // Thread Operations
189
165
let OpClass = threadId in
190
- def ThreadId : DXILOpProperties<93, int_dx_thread_id, [DXILOpOverload<SM6_0, [ llvm_i32_ty]> ],
166
+ def ThreadId : DXILOpProperties<93, int_dx_thread_id, [llvm_i32_ty],
191
167
"Reads the thread ID">;
192
168
let OpClass = groupId in
193
- def GroupId : DXILOpProperties<94, int_dx_group_id, [DXILOpOverload<SM6_0, [ llvm_i32_ty]> ],
169
+ def GroupId : DXILOpProperties<94, int_dx_group_id, [llvm_i32_ty],
194
170
"Reads the group ID (SV_GroupID)">;
195
171
let OpClass = threadIdInGroup in
196
- def ThreadIdInGroup : DXILOpProperties<95, int_dx_thread_id_in_group, [DXILOpOverload<SM6_0, [ llvm_i32_ty]> ],
172
+ def ThreadIdInGroup : DXILOpProperties<95, int_dx_thread_id_in_group, [llvm_i32_ty],
197
173
"Reads the thread ID within the group "
198
174
"(SV_GroupThreadID)">;
199
175
let OpClass = flattenedThreadIdInGroup in
200
176
def FlattenedThreadIdInGroup : DXILOpProperties<96, int_dx_flattened_thread_id_in_group,
201
- [DXILOpOverload<SM6_0, [ llvm_i32_ty]> ],
177
+ [llvm_i32_ty],
202
178
"Provides a flattened index for a given"
203
179
" thread within a given group (SV_GroupIndex)">;
0 commit comments