KhronosGroup / KhronosGroup/SPIRV-Tools
Missing support for SPV_INTEL_inline_assembly extension
- Dominant language
- C++
- Stars
- 1.4k
- Forks
- 709
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 28
Description
`OpAsmINTEL` and `OpAsmTargetINTEL` instructions from [`SPV_INTEL_inline_assembly`](https://github.com/intel/llvm/blob/sycl/sycl/doc/design/spirv-extensions/SPV_INTEL_inline_assembly.asciidoc) should be allowed in the same section as type declarations. This is currently not allowed in SPIRV-Tools which triggers an error during validation.
Reproducible example (using LLVM 19):
```c
// foo.c
void foo (const float * restrict a, const float * restrict b, float * restrict c) {
__asm__ ("nop");
}
```
```bash
> clang -S -emit-llvm foo.c -o foo.ll
> llc -O3 -mtriple=spirv64-unknown-unknown --spirv-ext=+SPV_INTEL_inline_assembly foo.ll -o foo.spt
> spirv-as foo.spt -o foo.spv
> spirv-val foo.spv
error: line 24: AsmTargetINTEL must appear in a block
%12 = OpAsmTargetINTEL "spirv64-unknown-unknown"
```
Note that the `spirv-as` line works only with [fixed headers](https://github.com/KhronosGroup/SPIRV-Headers/pull/468).
When trying to link the module containing inline assembly, `spirv-link` complains with a similar error:
```bash
> spirv-link foo.spv foo.spv -o foo_linked.spv
error: 0: Unhandled inst type (opcode: 5609) found outside function definition.
error: 0: Failed to build module 1 out of 1.
```
@mmerecki FYI
Contributor guide
Research direction
Start by reproducing the LLVM 19 example with spirv-as and spirv-val, then compare how OpAsmINTEL and OpAsmTargetINTEL are handled outside function definitions. Check the corresponding spirv-link path for the similar opcode error. Done means assembling, validating, and linking the module succeed with the SPV_INTEL_inline_assembly instructions in the type-declaration section.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- compilers, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100