[llvm] r333192 - FastMathFlags: Make it easier to unset individual ones.
Nicola Zaghen via llvm-commits
llvm-commits at lists.llvm.org
Thu May 24 08:15:27 PDT 2018
Author: nzaghen
Date: Thu May 24 08:15:27 2018
New Revision: 333192
URL: http://llvm.org/viewvc/llvm-project?rev=333192&view=rev
Log:
FastMathFlags: Make it easier to unset individual ones.
This makes the various flags similar to current setAllowContract.
Differential Revision: https://reviews.llvm.org/D47323
Modified:
llvm/trunk/include/llvm/IR/Operator.h
Modified: llvm/trunk/include/llvm/IR/Operator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/IR/Operator.h?rev=333192&r1=333191&r2=333192&view=diff
==============================================================================
--- llvm/trunk/include/llvm/IR/Operator.h (original)
+++ llvm/trunk/include/llvm/IR/Operator.h Thu May 24 08:15:27 2018
@@ -207,17 +207,28 @@ public:
bool isFast() const { return all(); }
/// Flag setters
- void setAllowReassoc() { Flags |= AllowReassoc; }
- void setNoNaNs() { Flags |= NoNaNs; }
- void setNoInfs() { Flags |= NoInfs; }
- void setNoSignedZeros() { Flags |= NoSignedZeros; }
- void setAllowReciprocal() { Flags |= AllowReciprocal; }
- // TODO: Change the other set* functions to take a parameter?
- void setAllowContract(bool B) {
+ void setAllowReassoc(bool B = true) {
+ Flags = (Flags & ~AllowReassoc) | B * AllowReassoc;
+ }
+ void setNoNaNs(bool B = true) {
+ Flags = (Flags & ~NoNaNs) | B * NoNaNs;
+ }
+ void setNoInfs(bool B = true) {
+ Flags = (Flags & ~NoInfs) | B * NoInfs;
+ }
+ void setNoSignedZeros(bool B = true) {
+ Flags = (Flags & ~NoSignedZeros) | B * NoSignedZeros;
+ }
+ void setAllowReciprocal(bool B = true) {
+ Flags = (Flags & ~AllowReciprocal) | B * AllowReciprocal;
+ }
+ void setAllowContract(bool B = true) {
Flags = (Flags & ~AllowContract) | B * AllowContract;
}
- void setApproxFunc() { Flags |= ApproxFunc; }
- void setFast() { set(); }
+ void setApproxFunc(bool B = true) {
+ Flags = (Flags & ~ApproxFunc) | B * ApproxFunc;
+ }
+ void setFast(bool B = true) { B ? set() : clear(); }
void operator&=(const FastMathFlags &OtherFlags) {
Flags &= OtherFlags.Flags;
More information about the llvm-commits
mailing list