You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -19,10 +19,10 @@ DXIL Operations are represented in one of the following `two ways
19
19
#. Using LLVM instructions
20
20
#. Using LLVM External functions. These are represented in LLVM IR as follows:
21
21
22
-
* "Standard" LLVM intrinsics (e.g., ``llvm.sin.*``) and
23
-
* HLSL intrinsics (defined as LLVM intrinsics in ``llvm/include/llvm/IR/IntrinsicsDirectX.td``, e.g., ``llvm.dx.*``)
22
+
* "Standard" LLVM intrinsics (e.g., ``llvm.sin.*``) and
23
+
* HLSL intrinsics (defined as LLVM intrinsics in ``llvm/include/llvm/IR/IntrinsicsDirectX.td``, e.g., ``llvm.dx.*``)
24
24
25
-
These are collectively referred to as `LLVM Intrinsics` in this note.
25
+
These are collectively referred to as `LLVM Intrinsics` in this note.
26
26
27
27
DXIL Ops, as currently represented in ``hctdb.py`` have the following attributes
28
28
@@ -61,23 +61,25 @@ Motivation
61
61
``DXILLowering`` pass needs to lower the LLVM intrinsics. TableGen file -
62
62
``llvm/lib/Target/DirectX/DXIL.td`` - is used to specify the properties of DXIL
63
63
Ops including the mapping of each of them to LLVM intrinsics they correspond to, if any.
64
-
``utils/hct/hctdb.py`` serves this purpose in ``DirectXShaderCompier`` repo.
65
-
Anologously, ``DXIL.td`` is planned to be the single source of reference
64
+
This purpose is served by ``utils/hct/hctdb.py`` in ``DirectXShaderCompiler`` repo.
65
+
Analogously, ``DXIL.td`` is planned to be the single source of reference
66
66
for the properties and LLVM intrinsic mapping of DXIL Ops for DXIL backend
67
-
implemetation in ``llvm-project`` repo. It needs to have a rich representation
67
+
implementation in ``llvm-project`` repo. It needs to have a rich representation
68
68
abilities that TableGen backends (such as ``DXILEmitter``) can rely on. Additionally,
69
-
the DXIL Op specification should be easy to read and comprehend.
69
+
the DXIL Op specification should be declarative - as much as possible - making it
70
+
easy to read and comprehend.
70
71
71
72
Design
72
73
======
73
74
74
-
Distilling the essential attributes of DXIL Op from the above (as a start), following
75
+
Distilling the essential attributes of DXIL Op from the above, following
75
76
attributes form the core of its specification.
76
77
77
78
#. ``dxil_opid`` or ``OpCode``
78
79
#. ``dxil_class`` or ``OpClass`` - this string is an integral part of the DXIL Op function name and is constructed in the format ``dx.op.<class-name>.<overload-type>``. The DXIL validator checks for any deviation from this for each of the DXIL Op call.
79
80
#. ``ops`` - list of operands encapsulating the index and valid (fixed or overload) types
80
81
#. ``oload_types`` - Valid overload types of the DXIL op
82
+
#. Rest of the attributes represented using ``is_*`` booleans
81
83
82
84
Each of the LLVM intrinsics maps to an external function represented by a call to an
83
85
external function of the form ``dx.op.<class-name>.<overload-type>`` as noted above.
@@ -94,61 +96,54 @@ Following is a basic TableGen class structure to encapsulate the mapping of LLVM
94
96
string Doc = ""; // A short description of the operation
95
97
list<LLVMType> OpTypes = ?; // Valid types of DXIL Operation in the
96
98
// format [returnTy, param1ty, ...]
99
+
list<DXILAttribute> OpAttributes = ? // List of various attributes including
100
+
// bool fields above
97
101
}
98
102
99
103
Various options considered to represent this mapping - keeping the goals of rich
100
-
representation and readability stated above - are discussed in the remainder
104
+
representation and declarative readability stated above - are discussed in the remainder
101
105
of the note. The basic difference between these options is the way return and
102
106
parameter types are represented for DXIL Ops with valid overload types.
103
107
Valid overload types for several DXIL Ops would be over-specified using LLVM's
104
108
``llvm_any*_ty`` types. For example, ``half`` and ``float`` are only valid for
105
109
DXIL ``Sin`` and would be overspecified using ``llvm_anyfloat_ty``. The options
106
110
listed below address the need to model such overload types specific types
107
111
precisely for correct code generation. They each provide specifications with
108
-
varying levels in (a) ease of readablility and maintainability and
112
+
varying levels in (a) ease of readability and maintainability and
109
113
(b) of compactness / richness.
110
114
111
115
Option 1 : Specify ``OpType`` as a list of valid fixed types.
0 commit comments