Skip to content

Commit 00befa1

Browse files
AnastasiaStulovavmaksimo
authored andcommitted
Document use of SPIRV-Tools with asm output
* Document use of SPIRV-Tools with asm output Co-authored-by: Alexey Sotkin <[email protected]> Co-authored-by: Sven van Haastregt <[email protected]> Original commit: KhronosGroup/SPIRV-LLVM-Translator@74dac42
1 parent c2cbfd2 commit 00befa1

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

llvm-spirv/README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,34 @@ Building clang from sources takes time and resources and it can be avoided:
9393
moment, see [KhronosGroup/SPIRV-LLVM-Translator#477](https://github.com/KhronosGroup/SPIRV-LLVM-Translator/issues/477)
9494
to track progress, discuss and contribute.
9595

96+
### Build with SPIRV-Tools
97+
98+
The translator can use [SPIRV-Tools](https://github.com/KhronosGroup/SPIRV-Tools) to generate assembly with widely adopted syntax.
99+
If SPIRV-Tools have been installed prior to the build it will be detected and
100+
used automatically. However it is also possible to enable use of SPIRV-Tools
101+
from a custom location using the following instructions:
102+
103+
1. Checkout, build and install SPIRV-Tools using
104+
[the following instructions](https://github.com/KhronosGroup/SPIRV-Tools#build).
105+
Example using CMake with Ninja:
106+
```
107+
cmake -G Ninja <SPIRV-Tools source location> -DCMAKE_INSTALL_PREFIX=<SPIRV-Tools installation location>
108+
ninja install
109+
```
110+
2. Point pkg-config to the SPIR-V tools installation when configuring the translator by setting
111+
`PKG_CONFIG_PATH=<SPIRV-Tools installation location>/lib/pkgconfig/` variable
112+
before the cmake line invocation.
113+
Example:
114+
```
115+
PKG_CONFIG_PATH=<SPIRV-Tools installation location>/lib/pkgconfig/ cmake <other options>
116+
```
117+
118+
To verify the SPIR-V Tools integration in the translator build, run the following line
119+
```
120+
llvm-spirv --spirv-tools-dis input.bc -o -
121+
```
122+
The output should be printed in the standard assembly syntax.
123+
96124
## Configuring SPIR-V Headers
97125

98126
The translator build is dependent on the official Khronos header file
@@ -153,6 +181,7 @@ To translate between LLVM IR and SPIR-V:
153181
* `-o file_name` - to specify output name
154182
* `-spirv-debug` - output debugging information
155183
* `-spirv-text` - read/write SPIR-V in an internal textual format for debugging purpose. The textual format is not defined by SPIR-V spec.
184+
* `--spirv-tools-dis` - print SPIR-V assembly in SPIRV-Tools format. Only available on [builds with SPIRV-Tools](#build-with-spirv-tools).
156185
* `-help` - to see full list of options
157186
158187
Translation from LLVM IR to SPIR-V and then back to LLVM IR is not guaranteed to

0 commit comments

Comments
 (0)