Skip to content

Commit 2e0ddfc

Browse files
[DirectX][docs] Expand DXILArchitecture documentation (#84077)
This just seeks to give a high level overview of the current state of the DirectX backend. It doesn't go in too deep, but should be a starting point for further documentation. --------- Co-authored-by: S. Bharadwaj Yadavalli <[email protected]>
1 parent 81798d5 commit 2e0ddfc

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

llvm/docs/DirectX/DXILArchitecture.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,52 @@ leverage LLVM's current bitcode libraries to do a lot of the work, but
8989
it's possible that at some point in the future it will need to be
9090
completely separate as modern LLVM bitcode evolves.
9191

92+
DirectX Backend Flow
93+
--------------------
94+
95+
The code generation flow for DXIL is broken into a series of passes. The passes
96+
are grouped into two flows:
97+
98+
#. Generating DXIL IR.
99+
#. Generating DXIL Binary.
100+
101+
The passes to generate DXIL IR follow the flow:
102+
103+
DXILOpLowering -> DXILPrepare -> DXILTranslateMetadata
104+
105+
Each of these passes has a defined responsibility:
106+
107+
#. DXILOpLowering translates LLVM intrinsic calls to dx.op calls.
108+
#. DXILPrepare transforms the DXIL IR to be compatible with LLVM 3.7, and
109+
inserts bitcasts to allow typed pointers to be inserted.
110+
#. DXILTranslateMetadata emits the DXIL Metadata structures.
111+
112+
The passes to encode DXIL to binary in the DX Container follow the flow:
113+
114+
DXILEmbedder -> DXContainerGlobals -> AsmPrinter
115+
116+
Each of these passes have the following defined responsibilities:
117+
118+
#. DXILEmbedder runs the DXIL bitcode writer to generate a bitcode stream and
119+
embeds the binary data inside a global in the original module.
120+
#. DXContainerGlobals generates binary data globals for the other DX Container
121+
parts based on computed analysis passes.
122+
#. AsmPrinter is the standard LLVM infrastructure for emitting object files.
123+
124+
When emitting DXIL into a DX Container file the MC layer is used in a similar
125+
way to how the Clang ``-fembed-bitcode`` option operates. The DX Container
126+
object writer knows how to construct the headers and structural fields of the
127+
container, and reads global variables from the module to fill in the remaining
128+
part data.
129+
130+
DirectX Container
131+
-----------------
132+
133+
The DirectX container format is treated in LLVM as an object file format.
134+
Reading is implemented between the BinaryFormat and Object libraries, and
135+
writing is implemented in the MC layer. Additional testing and inspection
136+
support are implemented in the ObjectYAML library and tools.
137+
92138
Testing
93139
=======
94140

0 commit comments

Comments
 (0)