[llvm] f357fe3 - [DirectX] Disentangle DXIL.td's op types from LLVMType. NFC
via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 19 10:09:49 PDT 2024
Author: Justin Bogner
Date: 2024-08-19T10:09:46-07:00
New Revision: f357fe371d3f752878abf1fb1d5fb550e2650c8e
URL: https://github.com/llvm/llvm-project/commit/f357fe371d3f752878abf1fb1d5fb550e2650c8e
DIFF: https://github.com/llvm/llvm-project/commit/f357fe371d3f752878abf1fb1d5fb550e2650c8e.diff
LOG: [DirectX] Disentangle DXIL.td's op types from LLVMType. NFC
LLVMType is both too broad and too narrow for defining DXIL operations, in
different ways. It's too broad in the sense that we don't need the full set of
MVTs - the set of types DXIL operations work on is much smaller. It's too
narrow in the sense that it's difficult to use it for the various fixed
structure types in DXIL, like `%dx.types.Handle` or `%dx.Types.ResRet.f32`.
Replace the usage of LLVMType in DXIL.td with DXILOpParamType, a simple class
that we can define an enum of types from. Further, use this to replace the
"ParameterKind" enum in DXILABI.h that has nothing to do with DXIL's ABI.
Pull Request: https://github.com/llvm/llvm-project/pull/104247
Added:
Modified:
llvm/docs/DirectX/DXILOpTableGenDesign.rst
llvm/include/llvm/Support/DXILABI.h
llvm/lib/Target/DirectX/DXIL.td
llvm/lib/Target/DirectX/DXILConstants.h
llvm/lib/Target/DirectX/DXILOpBuilder.cpp
llvm/utils/TableGen/DXILEmitter.cpp
Removed:
################################################################################
diff --git a/llvm/docs/DirectX/DXILOpTableGenDesign.rst b/llvm/docs/DirectX/DXILOpTableGenDesign.rst
index 50d801bd05efdb..46106ee2a50f57 100644
--- a/llvm/docs/DirectX/DXILOpTableGenDesign.rst
+++ b/llvm/docs/DirectX/DXILOpTableGenDesign.rst
@@ -93,18 +93,14 @@ properties are specified as fields of the ``DXILOp`` class as described below.
class DXILOpClass;
Concrete operation records, such as ``unary`` are defined by inheriting from ``DXILOpClass``.
-6. Return type of the operation is represented as ``LLVMType``.
-7. Operation arguments are represented as a list of ``LLVMType`` with each type
- corresponding to the argument position. An overload type, if supported by the operation, is
- denoted as the positional type ``overloadTy`` in the argument or in the result, where
- ``overloadTy`` is defined to be synonymous to ``llvm_any_ty``.
-
- .. code-block::
-
- defvar overloadTy = llvm_any_ty
-
- Empty list, ``[]`` represents an operation with no arguments.
-
+6. A set of type names are defined that represent return and argument types,
+ which all inherit from ``DXILOpParamType``. These represent simple types
+ like ``int32Ty``, DXIL types like ``dx.types.Handle``, and a special
+ ``overloadTy`` which can be any type allowed by ``Overloads``, described
+ below.
+7. Operation return type is represented as a ``DXILOpParamType``, and arguments
+ are represented as a list of the same. An operation with no return value
+ shall specify ``VoidTy`` as its return.
8. Valid operation overload types predicated on DXIL version are specified as
a list of ``Overloads`` records. Representation of ``Overloads``
class is described in a later section.
@@ -145,10 +141,10 @@ TableGen representations of its properties described above.
Intrinsic LLVMIntrinsic = ?;
// Result type of the op.
- LLVMType result;
+ DXILOpParamType result;
// List of argument types of the op. Default to 0 arguments.
- list<LLVMType> arguments = [];
+ list<DXILOpParamType> arguments = [];
// List of valid overload types predicated by DXIL version
list<Overloads> overloads;
@@ -233,9 +229,9 @@ overloads predicated on DXIL version as list of records of the following class
.. code-block::
- class Overloads<Version minver, list<LLVMType> ols> {
+ class Overloads<Version minver, list<DXILOpParamType> ols> {
Version dxil_version = minver;
- list<LLVMType> overload_types = ols;
+ list<DXILOpParamType> overload_types = ols;
}
Following is an example specification of valid overload types for ``DXIL1_0`` and
diff --git a/llvm/include/llvm/Support/DXILABI.h b/llvm/include/llvm/Support/DXILABI.h
index a2222eec09ba85..cf2c42c689889d 100644
--- a/llvm/include/llvm/Support/DXILABI.h
+++ b/llvm/include/llvm/Support/DXILABI.h
@@ -22,23 +22,6 @@
namespace llvm {
namespace dxil {
-enum class ParameterKind : uint8_t {
- Invalid = 0,
- Void,
- Half,
- Float,
- Double,
- I1,
- I8,
- I16,
- I32,
- I64,
- Overload,
- CBufferRet,
- ResourceRet,
- DXILHandle,
-};
-
enum class ResourceClass : uint8_t {
SRV = 0,
UAV,
diff --git a/llvm/lib/Target/DirectX/DXIL.td b/llvm/lib/Target/DirectX/DXIL.td
index 60185c20606b22..34c7f84b1ca5b2 100644
--- a/llvm/lib/Target/DirectX/DXIL.td
+++ b/llvm/lib/Target/DirectX/DXIL.td
@@ -24,19 +24,24 @@ foreach i = 0...8 in {
def DXIL1_ #i : Version<1, i>;
}
-// Overload type alias of llvm_any_ty
-defvar overloadTy = llvm_any_ty;
-
-// Type aliases for DXIL Op types to LLVM Types.
-// TODO: Define DXIL Types independent of LLVM types
-defvar i1Ty = llvm_i1_ty;
-defvar i8Ty = llvm_i8_ty;
-defvar i16Ty = llvm_i16_ty;
-defvar i32Ty = llvm_i32_ty;
-defvar i64Ty = llvm_i64_ty;
-defvar halfTy = llvm_half_ty;
-defvar floatTy = llvm_float_ty;
-defvar doubleTy = llvm_double_ty;
+class DXILOpParamType {
+ int isOverload = 0;
+}
+
+let isOverload = 1 in {
+ def OverloadTy : DXILOpParamType;
+}
+def VoidTy : DXILOpParamType;
+def Int1Ty : DXILOpParamType;
+def Int8Ty : DXILOpParamType;
+def Int16Ty : DXILOpParamType;
+def Int32Ty : DXILOpParamType;
+def Int64Ty : DXILOpParamType;
+def HalfTy : DXILOpParamType;
+def FloatTy : DXILOpParamType;
+def DoubleTy : DXILOpParamType;
+def ResRetTy : DXILOpParamType;
+def HandleTy : DXILOpParamType;
class DXILOpClass;
@@ -268,9 +273,9 @@ def IsWave : DXILAttribute;
def NeedsUniformInputs : DXILAttribute;
def IsBarrier : DXILAttribute;
-class Overloads<Version ver, list<LLVMType> ols> {
+class Overloads<Version ver, list<DXILOpParamType> ols> {
Version dxil_version = ver;
- list<LLVMType> overload_types = ols;
+ list<DXILOpParamType> overload_types = ols;
}
class Stages<Version ver, list<DXILShaderStage> st> {
@@ -298,10 +303,10 @@ class DXILOp<int opcode, DXILOpClass opclass> {
Intrinsic LLVMIntrinsic = ?;
// Result type of the op
- LLVMType result;
+ DXILOpParamType result;
// List of argument types of the op. Default to 0 arguments.
- list<LLVMType> arguments = [];
+ list<DXILOpParamType> arguments = [];
// List of valid overload types predicated by DXIL version
list<Overloads> overloads = [];
@@ -318,9 +323,9 @@ class DXILOp<int opcode, DXILOpClass opclass> {
def Abs : DXILOp<6, unary> {
let Doc = "Returns the absolute value of the input.";
let LLVMIntrinsic = int_fabs;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -328,9 +333,9 @@ def Abs : DXILOp<6, unary> {
def IsInf : DXILOp<9, isSpecialFloat> {
let Doc = "Determines if the specified value is infinite.";
let LLVMIntrinsic = int_dx_isinf;
- let arguments = [overloadTy];
- let result = i1Ty;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = Int1Ty;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -338,9 +343,9 @@ def IsInf : DXILOp<9, isSpecialFloat> {
def Cos : DXILOp<12, unary> {
let Doc = "Returns cosine(theta) for theta in radians.";
let LLVMIntrinsic = int_cos;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -348,9 +353,9 @@ def Cos : DXILOp<12, unary> {
def Sin : DXILOp<13, unary> {
let Doc = "Returns sine(theta) for theta in radians.";
let LLVMIntrinsic = int_sin;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -358,9 +363,9 @@ def Sin : DXILOp<13, unary> {
def Tan : DXILOp<14, unary> {
let Doc = "Returns tangent(theta) for theta in radians.";
let LLVMIntrinsic = int_tan;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -368,9 +373,9 @@ def Tan : DXILOp<14, unary> {
def ACos : DXILOp<15, unary> {
let Doc = "Returns the arccosine of the specified value.";
let LLVMIntrinsic = int_acos;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -378,9 +383,9 @@ def ACos : DXILOp<15, unary> {
def ASin : DXILOp<16, unary> {
let Doc = "Returns the arcsine of the specified value.";
let LLVMIntrinsic = int_asin;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -388,9 +393,9 @@ def ASin : DXILOp<16, unary> {
def ATan : DXILOp<17, unary> {
let Doc = "Returns the arctangent of the specified value.";
let LLVMIntrinsic = int_atan;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -398,9 +403,9 @@ def ATan : DXILOp<17, unary> {
def HCos : DXILOp<18, unary> {
let Doc = "Returns the hyperbolic cosine of the specified value.";
let LLVMIntrinsic = int_cosh;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -408,9 +413,9 @@ def HCos : DXILOp<18, unary> {
def HSin : DXILOp<19, unary> {
let Doc = "Returns the hyperbolic sine of the specified value.";
let LLVMIntrinsic = int_sinh;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -418,9 +423,9 @@ def HSin : DXILOp<19, unary> {
def HTan : DXILOp<20, unary> {
let Doc = "Returns the hyperbolic tan of the specified value.";
let LLVMIntrinsic = int_tanh;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -429,9 +434,9 @@ def Exp2 : DXILOp<21, unary> {
let Doc = "Returns the base 2 exponential, or 2**x, of the specified value. "
"exp2(x) = 2**x.";
let LLVMIntrinsic = int_exp2;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -440,9 +445,9 @@ def Frac : DXILOp<22, unary> {
let Doc = "Returns a fraction from 0 to 1 that represents the decimal part "
"of the input.";
let LLVMIntrinsic = int_dx_frac;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -450,9 +455,9 @@ def Frac : DXILOp<22, unary> {
def Log2 : DXILOp<23, unary> {
let Doc = "Returns the base-2 logarithm of the specified value.";
let LLVMIntrinsic = int_log2;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -461,9 +466,9 @@ def Sqrt : DXILOp<24, unary> {
let Doc = "Returns the square root of the specified floating-point value, "
"per component.";
let LLVMIntrinsic = int_sqrt;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -472,9 +477,9 @@ def RSqrt : DXILOp<25, unary> {
let Doc = "Returns the reciprocal of the square root of the specified value. "
"rsqrt(x) = 1 / sqrt(x).";
let LLVMIntrinsic = int_dx_rsqrt;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -483,9 +488,9 @@ def Round : DXILOp<26, unary> {
let Doc = "Returns the input rounded to the nearest integer within a "
"floating-point type.";
let LLVMIntrinsic = int_roundeven;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -494,9 +499,9 @@ def Floor : DXILOp<27, unary> {
let Doc =
"Returns the largest integer that is less than or equal to the input.";
let LLVMIntrinsic = int_floor;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -505,9 +510,9 @@ def Ceil : DXILOp<28, unary> {
let Doc = "Returns the smallest integer that is greater than or equal to the "
"input.";
let LLVMIntrinsic = int_ceil;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -515,9 +520,9 @@ def Ceil : DXILOp<28, unary> {
def Trunc : DXILOp<29, unary> {
let Doc = "Returns the specified value truncated to the integer component.";
let LLVMIntrinsic = int_trunc;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -525,10 +530,10 @@ def Trunc : DXILOp<29, unary> {
def Rbits : DXILOp<30, unary> {
let Doc = "Returns the specified value with its bits reversed.";
let LLVMIntrinsic = int_bitreverse;
- let arguments = [overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -536,10 +541,10 @@ def Rbits : DXILOp<30, unary> {
def FMax : DXILOp<35, binary> {
let Doc = "Float maximum. FMax(a,b) = a > b ? a : b";
let LLVMIntrinsic = int_maxnum;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
+ [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -547,10 +552,10 @@ def FMax : DXILOp<35, binary> {
def FMin : DXILOp<36, binary> {
let Doc = "Float minimum. FMin(a,b) = a < b ? a : b";
let LLVMIntrinsic = int_minnum;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
+ [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -558,10 +563,10 @@ def FMin : DXILOp<36, binary> {
def SMax : DXILOp<37, binary> {
let Doc = "Signed integer maximum. SMax(a,b) = a > b ? a : b";
let LLVMIntrinsic = int_smax;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -569,10 +574,10 @@ def SMax : DXILOp<37, binary> {
def SMin : DXILOp<38, binary> {
let Doc = "Signed integer minimum. SMin(a,b) = a < b ? a : b";
let LLVMIntrinsic = int_smin;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -580,10 +585,10 @@ def SMin : DXILOp<38, binary> {
def UMax : DXILOp<39, binary> {
let Doc = "Unsigned integer maximum. UMax(a,b) = a > b ? a : b";
let LLVMIntrinsic = int_umax;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -591,10 +596,10 @@ def UMax : DXILOp<39, binary> {
def UMin : DXILOp<40, binary> {
let Doc = "Unsigned integer minimum. UMin(a,b) = a < b ? a : b";
let LLVMIntrinsic = int_umin;
- let arguments = [overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -603,10 +608,10 @@ def FMad : DXILOp<46, tertiary> {
let Doc = "Floating point arithmetic multiply/add operation. fmad(m,a,b) = m "
"* a + b.";
let LLVMIntrinsic = int_fmuladd;
- let arguments = [overloadTy, overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [halfTy, floatTy, doubleTy]>];
+ [Overloads<DXIL1_0, [HalfTy, FloatTy, DoubleTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -615,10 +620,10 @@ def IMad : DXILOp<48, tertiary> {
let Doc = "Signed integer arithmetic multiply/add operation. imad(m,a,b) = m "
"* a + b.";
let LLVMIntrinsic = int_dx_imad;
- let arguments = [overloadTy, overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -627,10 +632,10 @@ def UMad : DXILOp<49, tertiary> {
let Doc = "Unsigned integer arithmetic multiply/add operation. umad(m,a, = m "
"* a + b.";
let LLVMIntrinsic = int_dx_umad;
- let arguments = [overloadTy, overloadTy, overloadTy];
- let result = overloadTy;
+ let arguments = [OverloadTy, OverloadTy, OverloadTy];
+ let result = OverloadTy;
let overloads =
- [Overloads<DXIL1_0, [i16Ty, i32Ty, i64Ty]>];
+ [Overloads<DXIL1_0, [Int16Ty, Int32Ty, Int64Ty]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -639,9 +644,9 @@ def Dot2 : DXILOp<54, dot2> {
let Doc = "dot product of two float vectors Dot(a,b) = a[0]*b[0] + ... + "
"a[n]*b[n] where n is between 0 and 1";
let LLVMIntrinsic = int_dx_dot2;
- let arguments = !listsplat(overloadTy, 4);
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = !listsplat(OverloadTy, 4);
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -650,9 +655,9 @@ def Dot3 : DXILOp<55, dot3> {
let Doc = "dot product of two float vectors Dot(a,b) = a[0]*b[0] + ... + "
"a[n]*b[n] where n is between 0 and 2";
let LLVMIntrinsic = int_dx_dot3;
- let arguments = !listsplat(overloadTy, 6);
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = !listsplat(OverloadTy, 6);
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -661,9 +666,9 @@ def Dot4 : DXILOp<56, dot4> {
let Doc = "dot product of two float vectors Dot(a,b) = a[0]*b[0] + ... + "
"a[n]*b[n] where n is between 0 and 3";
let LLVMIntrinsic = int_dx_dot4;
- let arguments = !listsplat(overloadTy, 8);
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [halfTy, floatTy]>];
+ let arguments = !listsplat(OverloadTy, 8);
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [HalfTy, FloatTy]>];
let stages = [Stages<DXIL1_0, [all_stages]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -671,9 +676,9 @@ def Dot4 : DXILOp<56, dot4> {
def ThreadId : DXILOp<93, threadId> {
let Doc = "Reads the thread ID";
let LLVMIntrinsic = int_dx_thread_id;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [i32Ty]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [Int32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -681,9 +686,9 @@ def ThreadId : DXILOp<93, threadId> {
def GroupId : DXILOp<94, groupId> {
let Doc = "Reads the group ID (SV_GroupID)";
let LLVMIntrinsic = int_dx_group_id;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [i32Ty]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [Int32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -691,9 +696,9 @@ def GroupId : DXILOp<94, groupId> {
def ThreadIdInGroup : DXILOp<95, threadIdInGroup> {
let Doc = "Reads the thread ID within the group (SV_GroupThreadID)";
let LLVMIntrinsic = int_dx_thread_id_in_group;
- let arguments = [overloadTy];
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [i32Ty]>];
+ let arguments = [OverloadTy];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [Int32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
@@ -702,8 +707,8 @@ def FlattenedThreadIdInGroup : DXILOp<96, flattenedThreadIdInGroup> {
let Doc = "Provides a flattened index for a given thread within a given "
"group (SV_GroupIndex)";
let LLVMIntrinsic = int_dx_flattened_thread_id_in_group;
- let result = overloadTy;
- let overloads = [Overloads<DXIL1_0, [i32Ty]>];
+ let result = OverloadTy;
+ let overloads = [Overloads<DXIL1_0, [Int32Ty]>];
let stages = [Stages<DXIL1_0, [compute, mesh, amplification, node]>];
let attributes = [Attributes<DXIL1_0, [ReadNone]>];
}
diff --git a/llvm/lib/Target/DirectX/DXILConstants.h b/llvm/lib/Target/DirectX/DXILConstants.h
index 0c9c1ac38fdbce..022cd57795a063 100644
--- a/llvm/lib/Target/DirectX/DXILConstants.h
+++ b/llvm/lib/Target/DirectX/DXILConstants.h
@@ -25,6 +25,11 @@ enum class OpCodeClass : unsigned {
#include "DXILOperation.inc"
};
+enum class OpParamType : unsigned {
+#define DXIL_OP_PARAM_TYPE(Name) Name,
+#include "DXILOperation.inc"
+};
+
} // namespace dxil
} // namespace llvm
diff --git a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
index 0e2b4601112b5f..ca372026141fbf 100644
--- a/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
+++ b/llvm/lib/Target/DirectX/DXILOpBuilder.cpp
@@ -157,10 +157,8 @@ struct OpCodeProperty {
llvm::SmallVector<OpOverload> Overloads;
llvm::SmallVector<OpStage> Stages;
llvm::SmallVector<OpAttribute> Attributes;
- int OverloadParamIndex; // parameter index which control the overload.
- // When < 0, should be only 1 overload type.
- unsigned NumOfParameters; // Number of parameters include return value.
- unsigned ParameterTableOffset; // Offset in ParameterTable.
+ int OverloadParamIndex; // parameter index which control the overload.
+ // When < 0, should be only 1 overload type.
};
// Include getOpCodeClassName getOpCodeProperty, getOpCodeName and
@@ -211,35 +209,33 @@ static StructType *getHandleType(LLVMContext &Ctx) {
Ctx);
}
-static Type *getTypeFromParameterKind(ParameterKind Kind, LLVMContext &Ctx,
- Type *OverloadTy) {
+static Type *getTypeFromOpParamType(OpParamType Kind, LLVMContext &Ctx,
+ Type *OverloadTy) {
switch (Kind) {
- case ParameterKind::Void:
+ case OpParamType::VoidTy:
return Type::getVoidTy(Ctx);
- case ParameterKind::Half:
+ case OpParamType::HalfTy:
return Type::getHalfTy(Ctx);
- case ParameterKind::Float:
+ case OpParamType::FloatTy:
return Type::getFloatTy(Ctx);
- case ParameterKind::Double:
+ case OpParamType::DoubleTy:
return Type::getDoubleTy(Ctx);
- case ParameterKind::I1:
+ case OpParamType::Int1Ty:
return Type::getInt1Ty(Ctx);
- case ParameterKind::I8:
+ case OpParamType::Int8Ty:
return Type::getInt8Ty(Ctx);
- case ParameterKind::I16:
+ case OpParamType::Int16Ty:
return Type::getInt16Ty(Ctx);
- case ParameterKind::I32:
+ case OpParamType::Int32Ty:
return Type::getInt32Ty(Ctx);
- case ParameterKind::I64:
+ case OpParamType::Int64Ty:
return Type::getInt64Ty(Ctx);
- case ParameterKind::Overload:
+ case OpParamType::OverloadTy:
return OverloadTy;
- case ParameterKind::ResourceRet:
+ case OpParamType::ResRetTy:
return getResRetType(OverloadTy, Ctx);
- case ParameterKind::DXILHandle:
+ case OpParamType::HandleTy:
return getHandleType(Ctx);
- default:
- break;
}
llvm_unreachable("Invalid parameter kind");
return nullptr;
@@ -284,30 +280,34 @@ static ShaderKind getShaderKindEnum(Triple::EnvironmentType EnvType) {
"Shader Kind Not Found - Invalid DXIL Environment Specified");
}
+static SmallVector<Type *>
+getArgTypesFromOpParamTypes(ArrayRef<dxil::OpParamType> Types,
+ LLVMContext &Context, Type *OverloadTy) {
+ SmallVector<Type *> ArgTys;
+ ArgTys.emplace_back(Type::getInt32Ty(Context));
+ for (dxil::OpParamType Ty : Types)
+ ArgTys.emplace_back(getTypeFromOpParamType(Ty, Context, OverloadTy));
+ return ArgTys;
+}
+
/// Construct DXIL function type. This is the type of a function with
/// the following prototype
/// OverloadType dx.op.<opclass>.<return-type>(int opcode, <param types>)
/// <param-types> are constructed from types in Prop.
-static FunctionType *getDXILOpFunctionType(const OpCodeProperty *Prop,
+static FunctionType *getDXILOpFunctionType(dxil::OpCode OpCode,
LLVMContext &Context,
Type *OverloadTy) {
- SmallVector<Type *> ArgTys;
-
- const ParameterKind *ParamKinds = getOpCodeParameterKind(*Prop);
-
- assert(Prop->NumOfParameters && "No return type?");
- // Add return type of the function
- Type *ReturnTy = getTypeFromParameterKind(ParamKinds[0], Context, OverloadTy);
- // Add DXIL Opcode value type viz., Int32 as first argument
- ArgTys.emplace_back(Type::getInt32Ty(Context));
-
- // Add DXIL Operation parameter types as specified in DXIL properties
- for (unsigned I = 1; I < Prop->NumOfParameters; ++I) {
- ParameterKind Kind = ParamKinds[I];
- ArgTys.emplace_back(getTypeFromParameterKind(Kind, Context, OverloadTy));
+ switch (OpCode) {
+#define DXIL_OP_FUNCTION_TYPE(OpCode, RetType, ...) \
+ case OpCode: \
+ return FunctionType::get( \
+ getTypeFromOpParamType(RetType, Context, OverloadTy), \
+ getArgTypesFromOpParamTypes({__VA_ARGS__}, Context, OverloadTy), \
+ /*isVarArg=*/false);
+#include "DXILOperation.inc"
}
- return FunctionType::get(ReturnTy, ArgTys, /*isVarArg=*/false);
+ llvm_unreachable("Invalid OpCode?");
}
/// Get index of the property from PropList valid for the most recent
@@ -372,7 +372,7 @@ Expected<CallInst *> DXILOpBuilder::tryCreateOp(dxil::OpCode OpCode,
OverloadTy = Args[ArgIndex]->getType();
}
FunctionType *DXILOpFT =
- getDXILOpFunctionType(Prop, M.getContext(), OverloadTy);
+ getDXILOpFunctionType(OpCode, M.getContext(), OverloadTy);
std::optional<size_t> OlIndexOrErr =
getPropIndex(ArrayRef(Prop->Overloads), DXILVersion);
diff --git a/llvm/utils/TableGen/DXILEmitter.cpp b/llvm/utils/TableGen/DXILEmitter.cpp
index 53791618e80fe0..9cc1b5ccb8acb9 100644
--- a/llvm/utils/TableGen/DXILEmitter.cpp
+++ b/llvm/utils/TableGen/DXILEmitter.cpp
@@ -18,7 +18,7 @@
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringSet.h"
-#include "llvm/CodeGenTypes/MachineValueType.h"
+#include "llvm/ADT/StringSwitch.h"
#include "llvm/Support/DXILABI.h"
#include "llvm/Support/VersionTuple.h"
#include "llvm/TableGen/Error.h"
@@ -54,40 +54,6 @@ struct DXILOperationDesc {
};
} // end anonymous namespace
-/// Return dxil::ParameterKind corresponding to input LLVMType record
-///
-/// \param R TableGen def record of class LLVMType
-/// \return ParameterKind As defined in llvm/Support/DXILABI.h
-
-static ParameterKind getParameterKind(const Record *R) {
- auto VTRec = R->getValueAsDef("VT");
- switch (getValueType(VTRec)) {
- case MVT::isVoid:
- return ParameterKind::Void;
- case MVT::f16:
- return ParameterKind::Half;
- case MVT::f32:
- return ParameterKind::Float;
- case MVT::f64:
- return ParameterKind::Double;
- case MVT::i1:
- return ParameterKind::I1;
- case MVT::i8:
- return ParameterKind::I8;
- case MVT::i16:
- return ParameterKind::I16;
- case MVT::i32:
- return ParameterKind::I32;
- case MVT::fAny:
- case MVT::iAny:
- case MVT::Any:
- return ParameterKind::Overload;
- default:
- llvm_unreachable(
- "Support for specified parameter type not yet implemented");
- }
-}
-
/// In-place sort TableGen records of class with a field
/// Version dxil_version
/// in the ascending version order.
@@ -134,10 +100,9 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
// llvm/IR/Intrinsics.td
OverloadParamIndex = -1; // A sigil meaning none.
for (unsigned i = 0; i < ParamTypeRecsSize; i++) {
- auto TR = ParamTypeRecs[i];
+ Record *TR = ParamTypeRecs[i];
// Track operation parameter indices of any overload types
- auto isAny = TR->getValueAsInt("isAny");
- if (isAny == 1) {
+ if (TR->getValueAsInt("isOverload")) {
if (OverloadParamIndex != -1) {
assert(TR == ParamTypeRecs[OverloadParamIndex] &&
"Specification of multiple
diff ering overload parameter types "
@@ -148,8 +113,6 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
if (OverloadParamIndex <= 0)
OverloadParamIndex = i;
}
- if (TR->isAnonymous())
- PrintFatalError(TR, "Only concrete types are allowed here");
OpTypes.emplace_back(TR);
}
@@ -208,71 +171,23 @@ DXILOperationDesc::DXILOperationDesc(const Record *R) {
}
}
-/// Return a string representation of ParameterKind enum
-/// \param Kind Parameter Kind enum value
-/// \return std::string string representation of input Kind
-static std::string getParameterKindStr(ParameterKind Kind) {
- switch (Kind) {
- case ParameterKind::Invalid:
- return "Invalid";
- case ParameterKind::Void:
- return "Void";
- case ParameterKind::Half:
- return "Half";
- case ParameterKind::Float:
- return "Float";
- case ParameterKind::Double:
- return "Double";
- case ParameterKind::I1:
- return "I1";
- case ParameterKind::I8:
- return "I8";
- case ParameterKind::I16:
- return "I16";
- case ParameterKind::I32:
- return "I32";
- case ParameterKind::I64:
- return "I64";
- case ParameterKind::Overload:
- return "Overload";
- case ParameterKind::CBufferRet:
- return "CBufferRet";
- case ParameterKind::ResourceRet:
- return "ResourceRet";
- case ParameterKind::DXILHandle:
- return "DXILHandle";
- }
- llvm_unreachable("Unknown llvm::dxil::ParameterKind enum");
-}
-
/// Return a string representation of OverloadKind enum that maps to
/// input LLVMType record
/// \param R TableGen def record of class LLVMType
/// \return std::string string representation of OverloadKind
-static std::string getOverloadKindStr(const Record *R) {
- Record *VTRec = R->getValueAsDef("VT");
- switch (getValueType(VTRec)) {
- case MVT::f16:
- return "OverloadKind::HALF";
- case MVT::f32:
- return "OverloadKind::FLOAT";
- case MVT::f64:
- return "OverloadKind::DOUBLE";
- case MVT::i1:
- return "OverloadKind::I1";
- case MVT::i8:
- return "OverloadKind::I8";
- case MVT::i16:
- return "OverloadKind::I16";
- case MVT::i32:
- return "OverloadKind::I32";
- case MVT::i64:
- return "OverloadKind::I64";
- default:
- llvm_unreachable("Support for specified fixed type option for overload "
- "type not supported");
- }
+static StringRef getOverloadKindStr(const Record *R) {
+ // TODO: This is a hack. We need to rework how we're handling the set of
+ // overloads to avoid this business with the separate OverloadKind enum.
+ return StringSwitch<StringRef>(R->getName())
+ .Case("HalfTy", "OverloadKind::HALF")
+ .Case("FloatTy", "OverloadKind::FLOAT")
+ .Case("DoubleTy", "OverloadKind::DOUBLE")
+ .Case("Int1Ty", "OverloadKind::I1")
+ .Case("Int8Ty", "OverloadKind::I8")
+ .Case("Int16Ty", "OverloadKind::I16")
+ .Case("Int32Ty", "OverloadKind::I32")
+ .Case("Int64Ty", "OverloadKind::I64");
}
/// Return a string representation of valid overload information denoted
@@ -417,8 +332,7 @@ static void emitDXILOpCodes(std::vector<DXILOperationDesc> &Ops,
}
/// Emit a list of DXIL op classes
-static void emitDXILOpClasses(RecordKeeper &Records,
- raw_ostream &OS) {
+static void emitDXILOpClasses(RecordKeeper &Records, raw_ostream &OS) {
OS << "#ifdef DXIL_OPCLASS\n";
std::vector<Record *> OpClasses =
Records.getAllDerivedDefinitions("DXILOpClass");
@@ -428,6 +342,35 @@ static void emitDXILOpClasses(RecordKeeper &Records,
OS << "#endif\n\n";
}
+/// Emit a list of DXIL op parameter types
+static void emitDXILOpParamTypes(RecordKeeper &Records, raw_ostream &OS) {
+ OS << "#ifdef DXIL_OP_PARAM_TYPE\n";
+ std::vector<Record *> OpClasses =
+ Records.getAllDerivedDefinitions("DXILOpParamType");
+ for (Record *OpClass : OpClasses)
+ OS << "DXIL_OP_PARAM_TYPE(" << OpClass->getName() << ")\n";
+ OS << "#undef DXIL_OP_PARAM_TYPE\n";
+ OS << "#endif\n\n";
+}
+
+/// Emit a list of DXIL op function types
+static void emitDXILOpFunctionTypes(ArrayRef<DXILOperationDesc> Ops,
+ raw_ostream &OS) {
+ OS << "#ifndef DXIL_OP_FUNCTION_TYPE\n";
+ OS << "#define DXIL_OP_FUNCTION_TYPE(OpCode, RetType, ...)\n";
+ OS << "#endif\n";
+ for (const DXILOperationDesc &Op : Ops) {
+ OS << "DXIL_OP_FUNCTION_TYPE(dxil::OpCode::" << Op.OpName;
+ for (const Record *Rec : Op.OpTypes)
+ OS << ", dxil::OpParamType::" << Rec->getName();
+ // If there are no arguments, we need an empty comma for the varargs
+ if (Op.OpTypes.size() == 1)
+ OS << ", ";
+ OS << ")\n";
+ }
+ OS << "#undef DXIL_OP_FUNCTION_TYPE\n";
+}
+
/// Emit map of DXIL operation to LLVM or DirectX intrinsic
/// \param A vector of DXIL Ops
/// \param Output stream
@@ -454,9 +397,7 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
// Collect Names.
SequenceToOffsetTable<std::string> OpClassStrings;
SequenceToOffsetTable<std::string> OpStrings;
- SequenceToOffsetTable<SmallVector<ParameterKind>> Parameters;
- StringMap<SmallVector<ParameterKind>> ParameterMap;
StringSet<> ClassSet;
for (auto &Op : Ops) {
OpStrings.add(Op.OpName);
@@ -465,18 +406,11 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
continue;
ClassSet.insert(Op.OpClass);
OpClassStrings.add(Op.OpClass.data());
- SmallVector<ParameterKind> ParamKindVec;
- for (unsigned i = 0; i < Op.OpTypes.size(); i++) {
- ParamKindVec.emplace_back(getParameterKind(Op.OpTypes[i]));
- }
- ParameterMap[Op.OpClass] = ParamKindVec;
- Parameters.add(ParamKindVec);
}
// Layout names.
OpStrings.layout();
OpClassStrings.layout();
- Parameters.layout();
// Emit access function getOpcodeProperty() that embeds DXIL Operation table
// with entries of type struct OpcodeProperty.
@@ -492,8 +426,7 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
<< getOverloadMaskString(Op.OverloadRecs) << ", "
<< getStageMaskString(Op.StageRecs) << ", "
<< getAttributeMaskString(Op.AttrRecs) << ", " << Op.OverloadParamIndex
- << ", " << Op.OpTypes.size() << ", "
- << Parameters.get(ParameterMap[Op.OpClass]) << " }";
+ << " }";
Prefix = ",\n";
}
OS << " };\n";
@@ -531,21 +464,6 @@ static void emitDXILOperationTable(std::vector<DXILOperationDesc> &Ops,
OS << " unsigned Index = Prop.OpCodeClassNameOffset;\n";
OS << " return DXILOpCodeClassNameTable + Index;\n";
- OS << "}\n ";
-
- OS << "static const ParameterKind *getOpCodeParameterKind(const "
- "OpCodeProperty &Prop) "
- "{\n\n";
- OS << " static const ParameterKind DXILOpParameterKindTable[] = {\n";
- Parameters.emit(
- OS,
- [](raw_ostream &ParamOS, ParameterKind Kind) {
- ParamOS << "ParameterKind::" << getParameterKindStr(Kind);
- },
- "ParameterKind::Invalid");
- OS << " };\n\n";
- OS << " unsigned Index = Prop.ParameterTableOffset;\n";
- OS << " return DXILOpParameterKindTable + Index;\n";
OS << "}\n\n";
}
@@ -611,6 +529,8 @@ static void EmitDXILOperation(RecordKeeper &Records, raw_ostream &OS) {
emitDXILOpCodes(DXILOps, OS);
emitDXILOpClasses(Records, OS);
+ emitDXILOpParamTypes(Records, OS);
+ emitDXILOpFunctionTypes(DXILOps, OS);
emitDXILIntrinsicMap(DXILOps, OS);
OS << "#ifdef DXIL_OP_OPERATION_TABLE\n\n";
emitDXILOperationTableDataStructs(Records, OS);
More information about the llvm-commits
mailing list