14
14
include "llvm/IR/Intrinsics.td"
15
15
16
16
// Abstract representation of the class a DXIL Operation belongs to.
17
- class DxilOpClass <string name> {
17
+ class DXILOpClass <string name> {
18
18
string Name = name;
19
19
}
20
20
21
21
// Abstract representation of the category a DXIL Operation belongs to
22
- class DxilOpCategory <string name> {
22
+ class DXILOpCategory <string name> {
23
23
string Name = name;
24
24
}
25
25
26
- def UnaryClass : DxilOpClass <"Unary">;
27
- def BinaryClass : DxilOpClass <"Binary">;
28
- def FlattenedThreadIdInGroupClass : DxilOpClass <"FlattenedThreadIdInGroup">;
29
- def ThreadIdInGroupClass : DxilOpClass <"ThreadIdInGroup">;
30
- def ThreadIdClass : DxilOpClass <"ThreadId">;
31
- def GroupIdClass : DxilOpClass <"GroupId">;
26
+ def UnaryClass : DXILOpClass <"Unary">;
27
+ def BinaryClass : DXILOpClass <"Binary">;
28
+ def FlattenedThreadIdInGroupClass : DXILOpClass <"FlattenedThreadIdInGroup">;
29
+ def ThreadIdInGroupClass : DXILOpClass <"ThreadIdInGroup">;
30
+ def ThreadIdClass : DXILOpClass <"ThreadId">;
31
+ def GroupIdClass : DXILOpClass <"GroupId">;
32
32
33
- def BinaryUintCategory : DxilOpCategory <"Binary uint">;
34
- def UnaryFloatCategory : DxilOpCategory <"Unary float">;
35
- def ComputeIDCategory : DxilOpCategory <"Compute/Mesh/Amplification shader">;
33
+ def BinaryUintCategory : DXILOpCategory <"Binary uint">;
34
+ def UnaryFloatCategory : DXILOpCategory <"Unary float">;
35
+ def ComputeIDCategory : DXILOpCategory <"Compute/Mesh/Amplification shader">;
36
36
37
37
// The parameter description for a DXIL operation
38
- class DxilOpParameter <int pos, string type, string name, string doc,
38
+ class DXILOpParameter <int pos, string type, string name, string doc,
39
39
bit isConstant = 0, string enumName = "",
40
40
int maxValue = 0> {
41
41
int Pos = pos; // Position in parameter list
@@ -49,16 +49,13 @@ class DxilOpParameter<int pos, string type, string name, string doc,
49
49
}
50
50
51
51
// A representation for a DXIL operation
52
- class DxilOperationDesc<string name> {
53
- // TODO : Appears redundant. OpName should serve the same purpose
54
- string Name = name; // short, unique name
55
-
52
+ class DXILOperationDesc {
56
53
string OpName = ""; // Name of DXIL operation
57
54
int OpCode = 0; // Unique non-negative integer associated with the operation
58
- DxilOpClass OpClass; // Class of the operation
59
- DxilOpCategory OpCategory; // Category of the operation
55
+ DXILOpClass OpClass; // Class of the operation
56
+ DXILOpCategory OpCategory; // Category of the operation
60
57
string Doc = ""; // Description of the operation
61
- list<DxilOpParameter > Params = []; // Parameter list of the operation
58
+ list<DXILOpParameter > Params = []; // Parameter list of the operation
62
59
string OverloadTypes = ""; // Overload types, if applicable
63
60
string Attributes = ""; // Attribute shorthands: rn=does not access
64
61
// memory,ro=only reads from memory,
@@ -73,9 +70,9 @@ class DxilOperationDesc<string name> {
73
70
list<string> StatsGroup = [];
74
71
}
75
72
76
- class DxilOperation <string name, int opCode, DxilOpClass opClass, DxilOpCategory opCategory, string doc,
77
- string oloadTypes, string attrs, list<DxilOpParameter > params,
78
- list<string> statsGroup = []> : DxilOperationDesc<name> {
73
+ class DXILOperation <string name, int opCode, DXILOpClass opClass, DXILOpCategory opCategory, string doc,
74
+ string oloadTypes, string attrs, list<DXILOpParameter > params,
75
+ list<string> statsGroup = []> : DXILOperationDesc {
79
76
let OpName = name;
80
77
let OpCode = opCode;
81
78
let Doc = doc;
@@ -90,56 +87,56 @@ class DxilOperation<string name, int opCode, DxilOpClass opClass, DxilOpCategory
90
87
// LLVM intrinsic that DXIL operation maps to.
91
88
class LLVMIntrinsic<Intrinsic llvm_intrinsic_> { Intrinsic llvm_intrinsic = llvm_intrinsic_; }
92
89
93
- def Sin : DxilOperation <"Sin", 13, UnaryClass, UnaryFloatCategory, "returns sine(theta) for theta in radians.",
90
+ def Sin : DXILOperation <"Sin", 13, UnaryClass, UnaryFloatCategory, "returns sine(theta) for theta in radians.",
94
91
"half;float;", "rn",
95
92
[
96
- DxilOpParameter <0, "$o", "", "operation result">,
97
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">,
98
- DxilOpParameter <2, "$o", "value", "input value">
93
+ DXILOpParameter <0, "$o", "", "operation result">,
94
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">,
95
+ DXILOpParameter <2, "$o", "value", "input value">
99
96
],
100
97
["floats"]>,
101
98
LLVMIntrinsic<int_sin>;
102
99
103
- def UMax : DxilOperation < "UMax", 39, BinaryClass, BinaryUintCategory, "unsigned integer maximum. UMax(a,b) = a > b ? a : b",
100
+ def UMax : DXILOperation < "UMax", 39, BinaryClass, BinaryUintCategory, "unsigned integer maximum. UMax(a,b) = a > b ? a : b",
104
101
"i16;i32;i64;", "rn",
105
102
[
106
- DxilOpParameter <0, "$o", "", "operation result">,
107
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">,
108
- DxilOpParameter <2, "$o", "a", "input value">,
109
- DxilOpParameter <3, "$o", "b", "input value">
103
+ DXILOpParameter <0, "$o", "", "operation result">,
104
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">,
105
+ DXILOpParameter <2, "$o", "a", "input value">,
106
+ DXILOpParameter <3, "$o", "b", "input value">
110
107
],
111
108
["uints"]>,
112
109
LLVMIntrinsic<int_umax>;
113
110
114
- def ThreadId : DxilOperation < "ThreadId", 93, ThreadIdClass, ComputeIDCategory, "reads the thread ID", "i32;", "rn",
111
+ def ThreadId : DXILOperation < "ThreadId", 93, ThreadIdClass, ComputeIDCategory, "reads the thread ID", "i32;", "rn",
115
112
[
116
- DxilOpParameter <0, "i32", "", "thread ID component">,
117
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">,
118
- DxilOpParameter <2, "i32", "component", "component to read (x,y,z)">
113
+ DXILOpParameter <0, "i32", "", "thread ID component">,
114
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">,
115
+ DXILOpParameter <2, "i32", "component", "component to read (x,y,z)">
119
116
]>,
120
117
LLVMIntrinsic<int_dx_thread_id>;
121
118
122
- def GroupId : DxilOperation < "GroupId", 94, GroupIdClass, ComputeIDCategory, "reads the group ID (SV_GroupID)", "i32;", "rn",
119
+ def GroupId : DXILOperation < "GroupId", 94, GroupIdClass, ComputeIDCategory, "reads the group ID (SV_GroupID)", "i32;", "rn",
123
120
[
124
- DxilOpParameter <0, "i32", "", "group ID component">,
125
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">,
126
- DxilOpParameter <2, "i32", "component", "component to read">
121
+ DXILOpParameter <0, "i32", "", "group ID component">,
122
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">,
123
+ DXILOpParameter <2, "i32", "component", "component to read">
127
124
]>,
128
125
LLVMIntrinsic<int_dx_group_id>;
129
126
130
- def ThreadIdInGroup : DxilOperation < "ThreadIdInGroup", 95, ThreadIdInGroupClass, ComputeIDCategory,
127
+ def ThreadIdInGroup : DXILOperation < "ThreadIdInGroup", 95, ThreadIdInGroupClass, ComputeIDCategory,
131
128
"reads the thread ID within the group (SV_GroupThreadID)", "i32;", "rn",
132
129
[
133
- DxilOpParameter <0, "i32", "", "thread ID in group component">,
134
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">,
135
- DxilOpParameter <2, "i32", "component", "component to read (x,y,z)">
130
+ DXILOpParameter <0, "i32", "", "thread ID in group component">,
131
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">,
132
+ DXILOpParameter <2, "i32", "component", "component to read (x,y,z)">
136
133
]>,
137
134
LLVMIntrinsic<int_dx_thread_id_in_group>;
138
135
139
- def FlattenedThreadIdInGroup : DxilOperation < "FlattenedThreadIdInGroup", 96, FlattenedThreadIdInGroupClass, ComputeIDCategory,
136
+ def FlattenedThreadIdInGroup : DXILOperation < "FlattenedThreadIdInGroup", 96, FlattenedThreadIdInGroupClass, ComputeIDCategory,
140
137
"provides a flattened index for a given thread within a given group (SV_GroupIndex)", "i32;", "rn",
141
138
[
142
- DxilOpParameter <0, "i32", "", "result">,
143
- DxilOpParameter <1, "i32", "opcode", "DXIL opcode">
139
+ DXILOpParameter <0, "i32", "", "result">,
140
+ DXILOpParameter <1, "i32", "opcode", "DXIL opcode">
144
141
]>,
145
142
LLVMIntrinsic<int_dx_flattened_thread_id_in_group>;
0 commit comments