[llvm] [C API] Add getters and setters for fast-math flags on relevant instructions (PR #75123)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 12 01:00:17 PST 2023


================
@@ -4075,6 +4095,32 @@ LLVMBool LLVMGetNNeg(LLVMValueRef NonNegInst);
  */
 void LLVMSetNNeg(LLVMValueRef NonNegInst, LLVMBool IsNonNeg);
 
+/**
+ * Get the flags for which fast-math-style optimizations are allowed for this
+ * value
+ *
+ * Only valid on floating point instructions
+ * @see LLVMGetCanUseFastMathFlags
+ */
+LLVMFastMathFlags LLVMGetFastMathFlags(LLVMValueRef FPMathInst);
+/**
+ * Sets the flags for which fast-math-style optimizations are allowed for this
+ * value
+ *
+ * Only valid on floating point instructions
+ * @see LLVMGetCanUseFastMathFlags
+ */
+void LLVMSetFastMathFlags(LLVMValueRef FPMathInst, LLVMFastMathFlags FMF);
+
+/**
+ * Check if a given value can potentially have fast math flags
+ *
+ * Will return true for floating point arithmetic instructions, and for select,
+ * phi, and call instructions whose type is a floating point type, or a vector
+ * or array thereof See https://llvm.org/docs/LangRef.html#fast-math-flags
----------------
nikic wrote:

```suggestion
 * or array thereof. See https://llvm.org/docs/LangRef.html#fast-math-flags
```

https://github.com/llvm/llvm-project/pull/75123


More information about the llvm-commits mailing list