[llvm] [DirectX][NFC] Change all DXIL TableGen tokens to CamelCase (PR #80714)

S. Bharadwaj Yadavalli via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 5 11:26:20 PST 2024


================
@@ -7,138 +7,139 @@
 //===----------------------------------------------------------------------===//
 ///
 /// \file
-/// This is a target description file for DXIL operation.
+/// This is a target description file for DXIL operations.
 ///
 //===----------------------------------------------------------------------===//
 
 include "llvm/IR/Intrinsics.td"
 
-class dxil_class<string _name> {
-  string name = _name;
+// Abstract representation of the class a DXIL Operation belongs to.
+class DXILOpClass<string name> {
+  string Name = name;
 }
-class dxil_category<string _name> {
-  string name = _name;
+
+// Abstract representation of the category a DXIL Operation belongs to
+class DXILOpCategory<string name> {
+  string Name = name;
 }
 
-def Unary : dxil_class<"Unary">;
-def Binary : dxil_class<"Binary">;
-def FlattenedThreadIdInGroupClass : dxil_class<"FlattenedThreadIdInGroup">;
-def ThreadIdInGroupClass : dxil_class<"ThreadIdInGroup">;
-def ThreadIdClass : dxil_class<"ThreadId">;
-def GroupIdClass : dxil_class<"GroupId">;
-
-def binary_uint : dxil_category<"Binary uint">;
-def unary_float : dxil_category<"Unary float">;
-def ComputeID : dxil_category<"Compute/Mesh/Amplification shader">;
-
-
-// The parameter description for a DXIL instruction
-class dxil_param<int _pos, string type, string _name, string _doc,
-                 bit _is_const = 0, string _enum_name = "",
-                 int _max_value = 0> {
-  int pos = _pos;           // position in parameter list
-  string llvm_type = type; // llvm type name, $o for overload, $r for resource
-                           // type, $cb for legacy cbuffer, $u4 for u4 struct
-  string name = _name;      // short, unique name
-  string doc = _doc;        // the documentation description of this parameter
-  bit is_const =
-      _is_const; // whether this argument requires a constant value in the IR
-  string enum_name = _enum_name; // the name of the enum type if applicable
-  int max_value =
-      _max_value; // the maximum value for this parameter if applicable
+def UnaryClass : DXILOpClass<"Unary">;
+def BinaryClass : DXILOpClass<"Binary">;
+def FlattenedThreadIdInGroupClass : DXILOpClass<"FlattenedThreadIdInGroup">;
+def ThreadIdInGroupClass : DXILOpClass<"ThreadIdInGroup">;
+def ThreadIdClass : DXILOpClass<"ThreadId">;
+def GroupIdClass : DXILOpClass<"GroupId">;
+
+def BinaryUintCategory : DXILOpCategory<"Binary uint">;
+def UnaryFloatCategory : DXILOpCategory<"Unary float">;
+def ComputeIDCategory : DXILOpCategory<"Compute/Mesh/Amplification shader">;
+
+// The parameter description for a DXIL operation
+class DXILOpParameter<int pos, string type, string name, string doc,
+                 bit isConstant = 0, string enumName = "",
+                 int maxValue = 0> {
+  int Pos = pos;               // Position in parameter list
+  string LLVMType = type;      // LLVM type name, $o for overload, $r for resource
+                               // type, $cb for legacy cbuffer, $u4 for u4 struct
+  string Name = name;          // Short, unique parameter name
+  string Doc = doc;            // Description of this parameter
+  bit IsConstant = isConstant; // Whether this parameter requires a constant value in the IR
+  string EnumName = enumName;  // Name of the enum type, if applicable
+  int MaxValue = maxValue;     // Maximum value for this parameter, if applicable
 }
 
-// A representation for a DXIL instruction
-class dxil_inst<string _name> {
-  string name = _name; // short, unique name
-
-  string dxil_op = "";       // name of DXIL operation
-  int dxil_opid = 0;         // ID of DXIL operation
-  dxil_class  op_class;      // name of the opcode class
-  dxil_category category;    // classification for this instruction
-  string doc = "";           // the documentation description of this instruction
-  list<dxil_param> ops = []; // the operands that this instruction takes
-  string oload_types = "";   // overload types if applicable
-  string fn_attr = "";       // attribute shorthands: rn=does not access
-                             // memory,ro=only reads from memory,
-  bit is_deriv = 0;          // whether this is some kind of derivative
-  bit is_gradient = 0;       // whether this requires a gradient calculation
-  bit is_feedback = 0;       // whether this is a sampler feedback op
-  bit is_wave = 0; // whether this requires in-wave, cross-lane functionality
-  bit requires_uniform_inputs = 0; // whether this operation requires that all
-                                   // of its inputs are uniform across the wave
-  // Group dxil operation for stats.
-  // Like how many atomic/float/uint/int/... instructions used in the program.
-  list<string> stats_group = [];
+// A representation for a DXIL operation
+class DXILOperationDesc<string name> {
+  // TODO : Appears redundant. OpName should serve the same purpose
+  string Name = name; // short, unique name
+
+  string OpName = "";         // Name of DXIL operation
+  int OpCode = 0;             // Unique non-negative integer associated with the operation
+  DXILOpClass  OpClass;       // Class of the operation
+  DXILOpCategory OpCategory;  // Category of the operation
+  string Doc = "";            // Description of the operation
+  list<DXILOpParameter> Params = []; // Parameter list of the operation
+  string OverloadTypes = "";  // Overload types, if applicable
+  string Attributes = "";     // Attribute shorthands: rn=does not access
+                              // memory,ro=only reads from memory,
+  bit IsDerivative = 0;       // Whether this is some kind of derivative
+  bit IsGradient = 0;         // Whether this requires a gradient calculation
+  bit IsFeedback = 0;         // Whether this is a sampler feedback operation
+  bit IsWave = 0;             // Whether this requires in-wave, cross-lane functionality
+  bit NeedsUniformInputs = 0; // Whether this operation requires that all
+                              // of its inputs are uniform across the wave
+  // Group DXIL operation for stats - e.g., to accumulate the number of atomic/float/uint/int/...
+  // operations used in the program.
+  list<string> StatsGroup = [];
 }
 
-class dxil_op<string name, int code_id, dxil_class code_class, dxil_category op_category, string _doc,
-              string _oload_types, string _fn_attr, list<dxil_param> op_params,
-              list<string> _stats_group = []> : dxil_inst<name> {
-  let dxil_op = name;
-  let dxil_opid = code_id;
-  let doc = _doc;
-  let ops = op_params;
-  let op_class = code_class;
-  let category = op_category;
-  let oload_types = _oload_types;
-  let fn_attr = _fn_attr;
-  let stats_group = _stats_group;
+class DXILOperation<string name, int opCode, DXILOpClass opClass, DXILOpCategory opCategory, string doc,
----------------
bharadwajy wrote:

> Elsewhere (in DXC), we do have an established pattern of using `Dxil` when in CamelCase with other words, and `DXIL` when used by itself. Perhaps we can establish the preferred pattern here before we have too much code depending on one pattern or the other.

It is good to know of the prevailing established pattern. Thanks!

I'll update the PR to follow the same convention in `DXIL.td`.

https://github.com/llvm/llvm-project/pull/80714


More information about the llvm-commits mailing list