[llvm] [DirectX][DXIL] Design document for TableGen Spec of DXIL Operations (PR #85170)
Justin Bogner via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 10:45:28 PDT 2024
================
@@ -0,0 +1,160 @@
+==============================================================
+Specification of DXIL Operations using TableGen Representation
+==============================================================
+.. contents::
+ :local:
+
+.. toctree
+ :hidden
+
+Introduction
+============
+
+`DirectXShaderCompiler <https://github.com/microsoft/DirectXShaderCompiler>`_
+encapsulates, among other information, various DXIL Operations in
+`hctdb.py <https://github.com/microsoft/DirectXShaderCompiler/blob/main/utils/hct/hctdb.py>`_.
+DXIL Operations are represented in one of the following `two ways
+<https://github.com/microsoft/DirectXShaderCompiler/blob/130877392c263888ef06bab768856d3dab1f1c9a/docs/DXIL.rst#L1978>`_:
+
+#. Using LLVM instructions.
+#. Using LLVM External functions. These are represented in LLVM IR as follows:
+ * "Standard" LLVM intrinsics (e.g., ``llvm.sin.*``) and
+ * HLSL intrinsics (defined as LLVM intrinsics in ``llvm/include/llvm/IR/IntrinsicsDirectX.td``, e.g., ``llvm.dx.*``)
+
+ These are collectively referred to as `LLVM Intrinsics` in this note.
+
+Following is the complete list of properties of DXIL Ops with the corresponding field name
+as used in ``hctdb.py``. A DXIL Op is represented by a set of associated properties. These
+are categorized into two groups - viz., those that are (1) consumed in DXIL backend passes
+and (2) consumed in other usage scenarios such as validation, DXIL reader, etc.
+
+A. Properties consumed in DXIL backend passes
+
+ 1. Name of operation (``dxil_op``)
+ 2. The generic or HLSL-specific intrinsic that maps to the operation (``llvm_name``).
+ 3. Unique Integer ID (``dxil_opid``)
+ 4. Operation Class signifying the name and function signature of the operation (``dxil_class``).
+ 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.
+ 5. List of valid overload types for the operation (``oload_types``).
+ 6. Required DXIL Version with support for the operation.
+ 7. A string that documents the operation (``doc``) - This is not strictly necessary but is included
+ for readability and documentation of the operation.
+
+B. Properties consumed in other usage scenarios
+
+ 1. Required minimum Shader Model (``shader_model``).
+ 2. Minimum shader model required with translation by linker (``shader_model_translated``)
+ 3. List of shader stages applicable to (``shader_stages``), empty for all.
----------------
bogner wrote:
I feel like the valid shader stages is as relevant to the backend as the required DXIL version (ie, for validation that we're generating correct DXIL).
https://github.com/llvm/llvm-project/pull/85170
More information about the llvm-commits
mailing list