[llvm] 8f3b87f - [SPIRV] Add support for SPV_INTEL_optnone
Paulo Matos via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 1 03:54:11 PDT 2023
Author: Paulo Matos
Date: 2023-08-01T12:53:54+02:00
New Revision: 8f3b87fc14bd61c27562ef0575a64dff210a73a7
URL: https://github.com/llvm/llvm-project/commit/8f3b87fc14bd61c27562ef0575a64dff210a73a7
DIFF: https://github.com/llvm/llvm-project/commit/8f3b87fc14bd61c27562ef0575a64dff210a73a7.diff
LOG: [SPIRV] Add support for SPV_INTEL_optnone
Adds support for SPV_INTEL_optnone.
Currently still in draft form but I wanted to open this revision
to ask some questions.
Differential Revision: https://reviews.llvm.org/D156297
Added:
Modified:
llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
llvm/test/CodeGen/SPIRV/optnone.ll
Removed:
################################################################################
diff --git a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
index 22746788607b8c..c3fc255e4b3df1 100644
--- a/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVModuleAnalysis.cpp
@@ -552,6 +552,10 @@ void RequirementHandler::initAvailableCapabilities(const SPIRVSubtarget &ST) {
// TODO: verify if this needs some checks.
addAvailableCaps({Capability::Float16, Capability::Float64});
+ // Add cap for SPV_INTEL_optnone.
+ // FIXME: this should be added only if the target has the extension.
+ addAvailableCaps({Capability::OptNoneINTEL});
+
// TODO: add OpenCL extensions.
}
} // namespace SPIRV
@@ -898,6 +902,13 @@ static void collectReqs(const Module &M, SPIRV::ModuleAnalysisInfo &MAI,
MAI.Reqs.getAndAddRequirements(
SPIRV::OperandCategory::ExecutionModeOperand,
SPIRV::ExecutionMode::VecTypeHint, ST);
+
+ if (F.hasOptNone() &&
+ ST.canUseExtension(SPIRV::Extension::SPV_INTEL_optnone)) {
+ // Output OpCapability OptNoneINTEL.
+ MAI.Reqs.addExtension(SPIRV::Extension::SPV_INTEL_optnone);
+ MAI.Reqs.addCapability(SPIRV::Capability::OptNoneINTEL);
+ }
}
}
diff --git a/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp b/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
index 0f047b09c5214b..05f871a88db0df 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVSubtarget.cpp
@@ -96,8 +96,11 @@ void SPIRVSubtarget::initAvailableExtensions() {
if (!isOpenCLEnv())
return;
// A default extension for testing.
+ // FIXME: This should be changed when we can select extensions through a
+ // command line flag.
AvailableExtensions.insert(
SPIRV::Extension::SPV_KHR_no_integer_wrap_decoration);
+ AvailableExtensions.insert(SPIRV::Extension::SPV_INTEL_optnone);
}
// TODO: use command line args for this rather than just defaults.
diff --git a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
index e37a1957132f69..a7d2a3fc41cf38 100644
--- a/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
+++ b/llvm/lib/Target/SPIRV/SPIRVSymbolicOperands.td
@@ -243,6 +243,7 @@ defm SPV_KHR_shader_clock : ExtensionOperand<54>;
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 ComputeDerivativeGroupLinearNV : CapabilityOperand<5350, 0, 0, [], []>;
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
diff --git a/llvm/test/CodeGen/SPIRV/optnone.ll b/llvm/test/CodeGen/SPIRV/optnone.ll
index 95c390ce7bf144..238a8193173745 100644
--- a/llvm/test/CodeGen/SPIRV/optnone.ll
+++ b/llvm/test/CodeGen/SPIRV/optnone.ll
@@ -1,6 +1,9 @@
;; Check that optnone is correctly ignored when extension is not enabled
; RUN: llc -O0 -mtriple=spirv32-unknown-unknown %s -o - | FileCheck %s --check-prefix=CHECK-SPIRV
+; CHECK-SPIRV: OpCapability OptNoneINTEL
+; CHECK-SPIRV: OpExtension "SPV_INTEL_optnone"
+
;; Per SPIR-V spec:
;; FunctionControlDontInlineMask = 0x2 (2)
; CHECK-SPIRV: %[[#]] = OpFunction %[[#]] DontInline
More information about the llvm-commits
mailing list