[llvm] [SPIRV] Add option to add all KHR extensions (PR #145535)
Steven Perron via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 24 08:47:32 PDT 2025
https://github.com/s-perron created https://github.com/llvm/llvm-project/pull/145535
In DXC, there is an option to enable all KHR extension. I would like to
extend the existing `-spirv-ext` backend commandline option to have the
same capability. It is like the special case for `all` execept it only
adds the `SPV_KHR_*` extensions.
Part of https://github.com/llvm/llvm-project/issues/137650.
>From 76b2c3127a4d0a172ed9950cfb762049c2b43449 Mon Sep 17 00:00:00 2001
From: Steven Perron <stevenperron at google.com>
Date: Tue, 24 Jun 2025 11:41:12 -0400
Subject: [PATCH] [SPIRV] Add option to add all KHR extensions
In DXC, there is an option to enable all KHR extension. I would like to
extend the existing `-spirv-ext` backend commandline option to have the
same capability. It is like the special case for `all` execept it only
adds the `SPV_KHR_*` extensions.
Part of https://github.com/llvm/llvm-project/issues/137650.
---
llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp | 7 +++++++
.../SPIRV/extensions/enable-all-extensions-but-one.ll | 1 +
2 files changed, 8 insertions(+)
diff --git a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
index fbaca4e0e4d81..365e586ba6018 100644
--- a/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
+++ b/llvm/lib/Target/SPIRV/SPIRVCommandLine.cpp
@@ -119,6 +119,13 @@ bool SPIRVExtensionsParser::parse(cl::Option &O, StringRef ArgName,
continue;
}
+ if (Token == "KHR") {
+ for (const auto &[ExtensionName, ExtensionEnum] : SPIRVExtensionMap)
+ if (StringRef(ExtensionName).starts_with("SPV_KHR_"))
+ EnabledExtensions.insert(ExtensionEnum);
+ continue;
+ }
+
if (Token.empty() || (!Token.starts_with("+") && !Token.starts_with("-")))
return O.error("Invalid extension list format: " + Token.str());
diff --git a/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
index 02d21a1abafa5..7b7bdb193a468 100644
--- a/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
+++ b/llvm/test/CodeGen/SPIRV/extensions/enable-all-extensions-but-one.ll
@@ -1,4 +1,5 @@
; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=all,-SPV_INTEL_arbitrary_precision_integers %s -o - | FileCheck %s
+; RUN: llc -verify-machineinstrs -O0 -mtriple=spirv32-unknown-unknown --spirv-ext=KHR %s -o - | FileCheck %s
define i6 @foo() {
%call = tail call i32 @llvm.bitreverse.i32(i32 42)
More information about the llvm-commits
mailing list