[llvm] [SPIR-V] Add --spirv-fp-contract option to control kernel ContractionOff emission (PR #206404)
Juan Manuel Martinez CaamaƱo via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 29 05:42:11 PDT 2026
================
@@ -37,13 +37,30 @@
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
#include "llvm/MC/TargetRegistry.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
using namespace llvm;
#define DEBUG_TYPE "asm-printer"
+namespace {
+enum class SPIRVFPContractMode { On, Off, Fast };
+} // namespace
+
+static cl::opt<SPIRVFPContractMode> SPIRVFPContract(
+ "spirv-fp-contract",
+ cl::desc("Override FP contraction policy for SPIR-V kernel entry points"),
+ cl::values(
+ clEnumValN(SPIRVFPContractMode::On, "on",
+ "Follow IR metadata (default)"),
+ clEnumValN(SPIRVFPContractMode::Off, "off",
+ "Force ContractionOff on all kernel entry points"),
+ clEnumValN(SPIRVFPContractMode::Fast, "fast",
+ "Suppress ContractionOff on all kernel entry points")),
+ cl::init(SPIRVFPContractMode::On));
+
namespace {
----------------
jmmartinez wrote:
We could merge the 2 anonymous namespaces:
```suggestion
namespace {
enum class SPIRVFPContractMode { On, Off, Fast };
static cl::opt<SPIRVFPContractMode> SPIRVFPContract(
"spirv-fp-contract",
cl::desc("Override FP contraction policy for SPIR-V kernel entry points"),
cl::values(
clEnumValN(SPIRVFPContractMode::On, "on",
"Follow IR metadata (default)"),
clEnumValN(SPIRVFPContractMode::Off, "off",
"Force ContractionOff on all kernel entry points"),
clEnumValN(SPIRVFPContractMode::Fast, "fast",
"Suppress ContractionOff on all kernel entry points")),
cl::init(SPIRVFPContractMode::On));
```
https://github.com/llvm/llvm-project/pull/206404
More information about the llvm-commits
mailing list