diff --git a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp b/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp --- a/llvm/lib/Target/SPIRV/SPIRVAsmPrinter.cpp +++ b/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( + 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); } diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td --- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td +++ b/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