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

Paulo Matos via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 00:50:58 PDT 2023


pmatos created this revision.
pmatos added reviewers: mpaszkowski, zuban32.
Herald added subscribers: asb, wingo, ThomasRaoux, hiraditya.
Herald added a project: All.
pmatos requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Adds support for SPV_INTEL_optnone.

Currently still in draft form but I wanted to open this revision
to ask some questions.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156297

Files:
  llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
  llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td


Index: llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -243,6 +243,7 @@
 defm SPV_INTEL_unstructured_loop_controls : ExtensionOperand<55>;
 defm SPV_EXT_demote_to_helper_invocation : ExtensionOperand<56>;
 defm SPV_INTEL_fpga_reg : ExtensionOperand<57>;
+defm SPV_INTEL_optnone : ExtensionOperand<58>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define Capabilities enum values and at the same time
@@ -396,6 +397,7 @@
 defm FragmentDensityEXT : CapabilityOperand<5291, 0, 0, [], [Shader]>;
 defm PhysicalStorageBufferAddressesEXT : CapabilityOperand<5347, 0, 0, [], [Shader]>;
 defm CooperativeMatrixNV : CapabilityOperand<5357, 0, 0, [], [Shader]>;
+defm OptNoneINTEL : CapabilityOperand<6094, 0, 0, [SPV_INTEL_optnone], []>;
 
 //===----------------------------------------------------------------------===//
 // Multiclass used to define SourceLanguage enum values and at the same time
Index: llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
+++ llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp
@@ -11,6 +11,7 @@
 //
 //===----------------------------------------------------------------------===//
 
+#include "MCTargetDesc/SPIRVBaseInfo.h"
 #include "MCTargetDesc/SPIRVInstPrinter.h"
 #include "SPIRV.h"
 #include "SPIRVInstrInfo.h"
@@ -117,6 +118,21 @@
         << GlobalValue::dropLLVMManglingEscape(F.getName()) << '\n';
   }
 
+  // Possibly output Capability and Extension instructions if function is marked
+  // with optnone.
+  if (F.hasOptNone()) {
+    // Output OpCapability OptNoneINTEL.
+    MCInst Inst;
+    Inst.setOpcode(SPIRV::OpCapability);
+    Inst.addOperand(MCOperand::createImm(static_cast<unsigned>(
+        SPIRV::Capability::OptNoneINTEL)));
+    outputMCInst(Inst);
+    // Output OpExtension "SPV_INTEL_optnone".
+    Inst.setOpcode(SPIRV::OpExtension);
+    addStringImm("SPV_INTEL_optnone", Inst);
+    outputMCInst(Inst);
+  }
+
   auto Section = getObjFileLowering().SectionForGlobal(&F, TM);
   MF->setSection(Section);
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156297.544243.patch
Type: text/x-patch
Size: 2299 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230726/c63be725/attachment-0001.bin>


More information about the llvm-commits mailing list