[PATCH] D156297: [SPIRV] Add support for SPV_INTEL_optnone

Michal Paszkowski via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 15:16:27 PDT 2023


mpaszkowski added a comment.

In D156297#4534419 <https://reviews.llvm.org/D156297#4534419>, @pmatos wrote:

> This is a draft patch - I want to discuss somethings inline.
>
> The output for optnone.ll is:
>
>   bin/llc -O0 -mtriple=spirv32-unknown-unknown ../llvm/test/CodeGen/SPIRV/optnone.ll -o -
>   	OpCapability Kernel
>   	OpCapability Addresses
>   	OpCapability Linkage
>   	%1 = OpExtInstImport "OpenCL.std"
>   	OpMemoryModel Physical32 OpenCL
>   	OpExecutionMode %4 ContractionOff
>   	OpSource Unknown 0
>   	OpName %4 "_Z3foov"
>   	OpDecorate %4 LinkageAttributes "_Z3foov" Export
>   	%2 = OpTypeVoid
>   	%3 = OpTypeFunction %2
>   	OpCapability OptNoneINTEL               ; -- Begin function _Z3foov
>   	OpExtension "�" "�" "�" "�" "�" "�"
>   	%4 = OpFunction %2 DontInline %3
>   	%5 = OpLabel
>   	OpReturn
>   	OpFunctionEnd
>
> OpExtension emits some funky unicode characters, I feel like I am doing this incorrectly but similarly to what's being done in `SPIRVAsmPrinter::outputGlobalRequirements()` :
>
>   MCInst Inst;
>       Inst.setOpcode(SPIRV::OpExtension);
>       addStringImm(getSymbolicOperandMnemonic(
>                        SPIRV::OperandCategory::ExtensionOperand, Ext),
>                    Inst);
>       outputMCInst(Inst);
>
> The other issue is that afaiu the OpExtension declaractions need to come up the top of the module. How is this organized in the backend so that I can emit these at the top of the module? Do I need to add these to the module requirements somehow?

Thank you for the patch @pmatos!

The OpExtension instructions should be added earlier in the pipeline. If the OpExtension instruction is added explicitly to MIR, it should be added before SPIRVModuleAnalysis. All explicit OpExtension instructions are then collected in this method <https://github.com/KhronosGroup/LLVM-SPIRV-Backend/blob/7f300965866b6fd3825d4fdbd84d880eeb533c02/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp#L215>. Please take a look at the draft pull request adding an extension here <https://github.com/KhronosGroup/LLVM-SPIRV-Backend/pull/250/commits/7f300965866b6fd3825d4fdbd84d880eeb533c02#diff-038dabfa20fbc159869a0cf05af87400ebc2372e835e4c9838a6cfcccda6e969> -- this should also help address the issue with incorrect unicode characters printed out in the SPIR-V assembly.

There are draft patches splitting SPIRVModuleAnalysis into smaller passes on our GitHub, but this can be done later (I am currently a bit busy, but promise to get back to this in August).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156297/new/

https://reviews.llvm.org/D156297



More information about the llvm-commits mailing list