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