Skip to content

Commit 230e5a1

Browse files
authored
NFC: hctdb.py: add experimental opcode value in comment (#8105)
For each experimental opcode, when generating DxilConstants.h, add a comment that prints the opcode number in three formats: hex, unsigned decimal, and signed i32 decimal. This should make it easier to read/review DXIL IR and help during debugging.
1 parent 7602425 commit 230e5a1

2 files changed

Lines changed: 44 additions & 1 deletion

File tree

include/dxc/DXIL/DxilConstants.h

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1196,98 +1196,133 @@ enum class OpCode : unsigned {
11961196

11971197
// OpCodeTableID = 32768
11981198
// ExperimentalOps
1199+
// ExperimentalNop = 0x80000000, 2147483648U, -2147483648
11991200
EXP_OPCODE(ExperimentalOps, ExperimentalNop), // nop does nothing
1201+
// GetGroupWaveIndex = 0x80000001, 2147483649U, -2147483647
12001202
EXP_OPCODE(
12011203
ExperimentalOps,
12021204
GetGroupWaveIndex), // returns the index of the wave in the thread group
1205+
// GetGroupWaveCount = 0x80000002, 2147483650U, -2147483646
12031206
EXP_OPCODE(
12041207
ExperimentalOps,
12051208
GetGroupWaveCount), // returns the number of waves in the thread group
1209+
// ClusterID = 0x80000003, 2147483651U, -2147483645
12061210
EXP_OPCODE(
12071211
ExperimentalOps,
12081212
ClusterID), // returns the user-defined ClusterID of the intersected CLAS
1213+
// RayQuery_CandidateClusterID = 0x80000004, 2147483652U, -2147483644
12091214
EXP_OPCODE(ExperimentalOps,
12101215
RayQuery_CandidateClusterID), // returns candidate hit cluster ID
1216+
// RayQuery_CommittedClusterID = 0x80000005, 2147483653U, -2147483643
12111217
EXP_OPCODE(ExperimentalOps,
12121218
RayQuery_CommittedClusterID), // returns committed hit cluster ID
1219+
// HitObject_ClusterID = 0x80000006, 2147483654U, -2147483642
12131220
EXP_OPCODE(
12141221
ExperimentalOps,
12151222
HitObject_ClusterID), // returns the cluster ID of this committed hit
1223+
// TriangleObjectPosition = 0x80000007, 2147483655U, -2147483641
12161224
EXP_OPCODE(ExperimentalOps,
12171225
TriangleObjectPosition), // returns triangle vertices in object
12181226
// space as <9 x float>
1227+
// RayQuery_CandidateTriangleObjectPosition = 0x80000008, 2147483656U,
1228+
// -2147483640
12191229
EXP_OPCODE(
12201230
ExperimentalOps,
12211231
RayQuery_CandidateTriangleObjectPosition), // returns candidate triangle
12221232
// vertices in object space as
12231233
// <9 x float>
1234+
// RayQuery_CommittedTriangleObjectPosition = 0x80000009, 2147483657U,
1235+
// -2147483639
12241236
EXP_OPCODE(
12251237
ExperimentalOps,
12261238
RayQuery_CommittedTriangleObjectPosition), // returns committed triangle
12271239
// vertices in object space as
12281240
// <9 x float>
1241+
// HitObject_TriangleObjectPosition = 0x8000000A, 2147483658U, -2147483638
12291242
EXP_OPCODE(ExperimentalOps,
12301243
HitObject_TriangleObjectPosition), // returns triangle vertices in
12311244
// object space as <9 x float>
1232-
EXP_OPCODE(ExperimentalOps, CreateMatrix), // creates a handle to a Matrix
1245+
// CreateMatrix = 0x8000000B, 2147483659U, -2147483637
1246+
EXP_OPCODE(ExperimentalOps, CreateMatrix), // creates a handle to a Matrix
1247+
// FillMatrix = 0x8000000C, 2147483660U, -2147483636
12331248
EXP_OPCODE(ExperimentalOps, FillMatrix), // fills a matrix with a scalar value
1249+
// CopyConvertMatrix = 0x8000000D, 2147483661U, -2147483635
12341250
EXP_OPCODE(ExperimentalOps,
12351251
CopyConvertMatrix), // Converts and copies the element and use type
12361252
// of the source matrix to the destination
12371253
// matrix with optional transpose
1254+
// MatrixLoadFromDescriptor = 0x8000000E, 2147483662U, -2147483634
12381255
EXP_OPCODE(ExperimentalOps,
12391256
MatrixLoadFromDescriptor), // fills a matrix with data from a
12401257
// [RW]ByteAddressBuffer
1258+
// MatrixLoadFromMemory = 0x8000000F, 2147483663U, -2147483633
12411259
EXP_OPCODE(ExperimentalOps, MatrixLoadFromMemory), // fills a matrix with data
12421260
// from a groupshared array
1261+
// MatrixLength = 0x80000010, 2147483664U, -2147483632
12431262
EXP_OPCODE(
12441263
ExperimentalOps,
12451264
MatrixLength), // returns the number of elements stored in thread-local
12461265
// storage on the active thread for the provided matrix
1266+
// MatrixGetCoordinate = 0x80000011, 2147483665U, -2147483631
12471267
EXP_OPCODE(ExperimentalOps,
12481268
MatrixGetCoordinate), // returns a two element vector containing
12491269
// the column and row of the matrix that the
12501270
// thread-local index corresponds to
1271+
// MatrixGetElement = 0x80000012, 2147483666U, -2147483630
12511272
EXP_OPCODE(
12521273
ExperimentalOps,
12531274
MatrixGetElement), // returns the element of the matrix corresponding to
12541275
// the provided thread-local index
1276+
// MatrixSetElement = 0x80000013, 2147483667U, -2147483629
12551277
EXP_OPCODE(ExperimentalOps,
12561278
MatrixSetElement), // sets the element of the matrix corresponding
12571279
// to the provided thread-local index
1280+
// MatrixStoreToDescriptor = 0x80000014, 2147483668U, -2147483628
12581281
EXP_OPCODE(
12591282
ExperimentalOps,
12601283
MatrixStoreToDescriptor), // stores a matrix to a RWByteAddressBuffer
1284+
// MatrixStoreToMemory = 0x80000015, 2147483669U, -2147483627
12611285
EXP_OPCODE(ExperimentalOps,
12621286
MatrixStoreToMemory), // stores a matrix to groupshared memory
1287+
// MatrixQueryAccumulatorLayout = 0x80000016, 2147483670U, -2147483626
12631288
EXP_OPCODE(
12641289
ExperimentalOps,
12651290
MatrixQueryAccumulatorLayout), // returns comptime 0 when accumulator
12661291
// matrix are A layout, 1 when B layout
1292+
// MatrixMulOp = 0x80000017, 2147483671U, -2147483625
12671293
EXP_OPCODE(ExperimentalOps,
12681294
MatrixMulOp), // applies a multiplication op to matrix C using A
12691295
// and B as parameters
1296+
// MatrixAccumulate = 0x80000018, 2147483672U, -2147483624
12701297
EXP_OPCODE(ExperimentalOps,
12711298
MatrixAccumulate), // accumulate A or B matrix into Accumulator
12721299
// matrix following LHS += RHS
1300+
// MatrixVecMul = 0x80000019, 2147483673U, -2147483623
12731301
EXP_OPCODE(ExperimentalOps,
12741302
MatrixVecMul), // Multiplies a MxK dimension matrix and a K sized
12751303
// input vector
1304+
// MatrixVecMulAdd = 0x8000001A, 2147483674U, -2147483622
12761305
EXP_OPCODE(
12771306
ExperimentalOps,
12781307
MatrixVecMulAdd), // Multiplies a MxK dimension matrix and a K sized input
12791308
// vector then adds a M sized bias vector
1309+
// MatrixAccumulateToDescriptor = 0x8000001B, 2147483675U, -2147483621
12801310
EXP_OPCODE(ExperimentalOps,
12811311
MatrixAccumulateToDescriptor), // accumulates a matrix to a
12821312
// RWByteAddressBuffer
1313+
// MatrixAccumulateToMemory = 0x8000001C, 2147483676U, -2147483620
12831314
EXP_OPCODE(
12841315
ExperimentalOps,
12851316
MatrixAccumulateToMemory), // accumulates a matrix to groupshared memory
1317+
// MatrixOuterProduct = 0x8000001D, 2147483677U, -2147483619
12861318
EXP_OPCODE(ExperimentalOps,
12871319
MatrixOuterProduct), // Outer products an M sized vector and a K
12881320
// sized vector producing an MxK matrix
1321+
// LinAlgMatrixReserved0 = 0x8000001E, 2147483678U, -2147483618
12891322
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved0), // reserved
1323+
// LinAlgMatrixReserved1 = 0x8000001F, 2147483679U, -2147483617
12901324
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved1), // reserved
1325+
// LinAlgMatrixReserved2 = 0x80000020, 2147483680U, -2147483616
12911326
EXP_OPCODE(ExperimentalOps, LinAlgMatrixReserved2), // reserved
12921327
};
12931328
// OPCODE-ENUM:END

utils/hct/hctdb.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,14 @@ def build_opcode_enum(self):
598598
v.category = i.category
599599
class_dict[i.dxil_class] = i.category
600600
if table != self.core_table:
601+
# // <op> = 0x<hex id>, <id>U, <signed i32 id>
602+
# Signed id is useful for comparing with IR opcodes, which
603+
# are printed as signed i32 values.
604+
signed_opid = ((i.dxil_opid + 0x80000000) & 0xFFFFFFFF) - 0x80000000
605+
postfix.append(
606+
f"// {i.dxil_op} = 0x{table.id:04X}{i.dxil_op_index():04X},"
607+
+ f" {i.dxil_opid}U, {signed_opid}"
608+
)
601609
postfix.append(f"EXP_OPCODE({table.name}, {i.dxil_op}), // {i.doc}")
602610

603611
# Build OpCodeClass enum

0 commit comments

Comments
 (0)