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

Ilia Diachkov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 27 15:35:08 PDT 2023


iliya-diyachkov added a comment.

Paulo, please also add a lit test which checks the new feature.



================
Comment at: llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp:127
+    Inst.setOpcode(SPIRV::OpCapability);
+    Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(
+        SPIRV::Capability::OptNoneINTEL)));
----------------
pmatos wrote:
> Is this the best place to issue the instruction or is it preferable to do so during lowering for each function?
A more appropriate place to add the required capability is inside `collectReqs()` in SPIRVModuleAnalysis.cpp.

As for the extension, I'm not sure we should add it by default, having a function with `optnone`. I assume that SPIRV translator issues `OpExtension` instructions if we pass a command line option (like this `--spirv-ext=+SPV_INTEL_optnone`) and have a corresponding trigger in IR (like a function with `optnone`). Probably other ways to enable desirable extensions are suitable (e.g. in module metadata).

We don't have support for the command line option yet, perhaps it can be implemented inside SPIRVSubtarget::initAvailableExtensions using cl::opt<string> and string parsing. Then we check function's `optnone` and availability of the extension inside `collectReqs()` and add the extension, as we do with capabilities.


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