Skip to content

Commit 758fd59

Browse files
authored
[DirectX][NFC] Change usage pattern *Dxil* to *DXIL* for uniformity (llvm#80778)
Match DXIL TableGen class names with structure names in DXIL Emitter. Delete unnecessary Name field.
1 parent 16d1a64 commit 758fd59

File tree

3 files changed

+107
-115
lines changed

3 files changed

+107
-115
lines changed

llvm/lib/Target/DirectX/DXIL.td

Lines changed: 43 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -14,28 +14,28 @@
1414
include "llvm/IR/Intrinsics.td"
1515

1616
// Abstract representation of the class a DXIL Operation belongs to.
17-
class DxilOpClass<string name> {
17+
class DXILOpClass<string name> {
1818
string Name = name;
1919
}
2020

2121
// Abstract representation of the category a DXIL Operation belongs to
22-
class DxilOpCategory<string name> {
22+
class DXILOpCategory<string name> {
2323
string Name = name;
2424
}
2525

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">;
3232

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">;
3636

3737
// 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,
3939
bit isConstant = 0, string enumName = "",
4040
int maxValue = 0> {
4141
int Pos = pos; // Position in parameter list
@@ -49,16 +49,13 @@ class DxilOpParameter<int pos, string type, string name, string doc,
4949
}
5050

5151
// 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 {
5653
string OpName = ""; // Name of DXIL operation
5754
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
6057
string Doc = ""; // Description of the operation
61-
list<DxilOpParameter> Params = []; // Parameter list of the operation
58+
list<DXILOpParameter> Params = []; // Parameter list of the operation
6259
string OverloadTypes = ""; // Overload types, if applicable
6360
string Attributes = ""; // Attribute shorthands: rn=does not access
6461
// memory,ro=only reads from memory,
@@ -73,9 +70,9 @@ class DxilOperationDesc<string name> {
7370
list<string> StatsGroup = [];
7471
}
7572

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 {
7976
let OpName = name;
8077
let OpCode = opCode;
8178
let Doc = doc;
@@ -90,56 +87,56 @@ class DxilOperation<string name, int opCode, DxilOpClass opClass, DxilOpCategory
9087
// LLVM intrinsic that DXIL operation maps to.
9188
class LLVMIntrinsic<Intrinsic llvm_intrinsic_> { Intrinsic llvm_intrinsic = llvm_intrinsic_; }
9289

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.",
9491
"half;float;", "rn",
9592
[
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">
9996
],
10097
["floats"]>,
10198
LLVMIntrinsic<int_sin>;
10299

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",
104101
"i16;i32;i64;", "rn",
105102
[
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">
110107
],
111108
["uints"]>,
112109
LLVMIntrinsic<int_umax>;
113110

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",
115112
[
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)">
119116
]>,
120117
LLVMIntrinsic<int_dx_thread_id>;
121118

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",
123120
[
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">
127124
]>,
128125
LLVMIntrinsic<int_dx_group_id>;
129126

130-
def ThreadIdInGroup : DxilOperation< "ThreadIdInGroup", 95, ThreadIdInGroupClass, ComputeIDCategory,
127+
def ThreadIdInGroup : DXILOperation< "ThreadIdInGroup", 95, ThreadIdInGroupClass, ComputeIDCategory,
131128
"reads the thread ID within the group (SV_GroupThreadID)", "i32;", "rn",
132129
[
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)">
136133
]>,
137134
LLVMIntrinsic<int_dx_thread_id_in_group>;
138135

139-
def FlattenedThreadIdInGroup : DxilOperation< "FlattenedThreadIdInGroup", 96, FlattenedThreadIdInGroupClass, ComputeIDCategory,
136+
def FlattenedThreadIdInGroup : DXILOperation< "FlattenedThreadIdInGroup", 96, FlattenedThreadIdInGroupClass, ComputeIDCategory,
140137
"provides a flattened index for a given thread within a given group (SV_GroupIndex)", "i32;", "rn",
141138
[
142-
DxilOpParameter<0, "i32", "", "result">,
143-
DxilOpParameter<1, "i32", "opcode", "DXIL opcode">
139+
DXILOpParameter<0, "i32", "", "result">,
140+
DXILOpParameter<1, "i32", "opcode", "DXIL opcode">
144141
]>,
145142
LLVMIntrinsic<int_dx_flattened_thread_id_in_group>;

llvm/lib/Target/DirectX/DXILMetadata.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,7 @@ class EntryMD {
213213
// FIXME: add signature for profile other than CS.
214214
// See https://github.com/llvm/llvm-project/issues/57928.
215215
MDTuple *Signatures = nullptr;
216-
return emitDxilEntryPointTuple(
216+
return emitDXILEntryPointTuple(
217217
&F, F.getName().str(), Signatures, Resources,
218218
Props.emitDXILEntryProps(RawShaderFlag, Ctx, /*IsLib*/ false), Ctx);
219219
}
@@ -222,7 +222,7 @@ class EntryMD {
222222
// FIXME: add signature for profile other than CS.
223223
// See https://github.com/llvm/llvm-project/issues/57928.
224224
MDTuple *Signatures = nullptr;
225-
return emitDxilEntryPointTuple(
225+
return emitDXILEntryPointTuple(
226226
&F, F.getName().str(), Signatures,
227227
/*entry in lib doesn't need resources metadata*/ nullptr,
228228
Props.emitDXILEntryProps(RawShaderFlag, Ctx, /*IsLib*/ true), Ctx);
@@ -233,13 +233,13 @@ class EntryMD {
233233
static MDTuple *emitEmptyEntryForLib(MDTuple *Resources,
234234
uint64_t RawShaderFlag,
235235
LLVMContext &Ctx) {
236-
return emitDxilEntryPointTuple(
236+
return emitDXILEntryPointTuple(
237237
nullptr, "", nullptr, Resources,
238238
EntryProps::emitEntryPropsForEmptyEntry(RawShaderFlag, Ctx), Ctx);
239239
}
240240

241241
private:
242-
static MDTuple *emitDxilEntryPointTuple(Function *Fn, const std::string &Name,
242+
static MDTuple *emitDXILEntryPointTuple(Function *Fn, const std::string &Name,
243243
MDTuple *Signatures,
244244
MDTuple *Resources,
245245
MDTuple *Properties,

0 commit comments

Comments
 (0)