[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
================
@@ -3319,6 +3319,52 @@ void LLVMSetArgOperand(LLVMValueRef Funclet, unsigned i, LLVMValueRef value) {
/*--.. Arithmetic ..........................................................--*/
+static FastMathFlags mapFromLLVMFastMathFlags(LLVMFastMathFlags FMF) {
+ FastMathFlags NewFMF;
+ // First, check if all bits are set
+ // If not, check each one explicitly
+ if (FMF == static_cast<LLVMFastMathFlags>(LLVMFastMathAll))
+ NewFMF.set();
+ else {
+ NewFMF.setAllowReassoc((FMF & LLVMFastMathAllowReassoc) != 0);
+ NewFMF.setNoNaNs((FMF & LLVMFastMathNoNaNs) != 0);
+ NewFMF.setNoInfs((FMF & LLVMFastMathNoInfs) != 0);
+ NewFMF.setNoSignedZeros((FMF & LLVMFastMathNoSignedZeros) != 0);
+ NewFMF.setAllowReciprocal((FMF & LLVMFastMathAllowReciprocal) != 0);
+ NewFMF.setAllowContract((FMF & LLVMFastMathAllowContract) != 0);
+ NewFMF.setApproxFunc((FMF & LLVMFastMathApproxFunc) != 0);
+ }
+
+ return NewFMF;
+}
+
+static LLVMFastMathFlags mapToLLVMFastMathFlags(FastMathFlags FMF) {
+
----------------
nikic wrote:
Stray newline.
https://github.com/llvm/llvm-project/pull/75123
More information about the llvm-commits
mailing list