diff options
author | Michael Berg <michael_c_berg@apple.com> | 2018-09-19 18:52:08 +0000 |
---|---|---|
committer | Michael Berg <michael_c_berg@apple.com> | 2018-09-19 18:52:08 +0000 |
commit | 894c39f770298e8972d3518c9b3531b59c819f56 (patch) | |
tree | 721a8e1beaa40223277cb09d25a6b44fb064f5e0 /llvm/lib/CodeGen/MachineInstr.cpp | |
parent | 1a1c0ee59942f98f2affae96c81b6230c2bf0edb (diff) | |
download | bcm5719-llvm-894c39f770298e8972d3518c9b3531b59c819f56.tar.gz bcm5719-llvm-894c39f770298e8972d3518c9b3531b59c819f56.zip |
Copy utilities updated and added for MI flags
Summary: This patch adds a GlobalIsel copy utility into MI for flags and updates the instruction emitter for the SDAG path. Some tests show new behavior and I added one for GlobalIsel which mirrors an SDAG test for handling nsw/nuw.
Reviewers: spatel, wristow, arsenm
Reviewed By: arsenm
Subscribers: wdng
Differential Revision: https://reviews.llvm.org/D52006
llvm-svn: 342576
Diffstat (limited to 'llvm/lib/CodeGen/MachineInstr.cpp')
-rw-r--r-- | llvm/lib/CodeGen/MachineInstr.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/MachineInstr.cpp b/llvm/lib/CodeGen/MachineInstr.cpp index 2f323597741..4a0799f69cf 100644 --- a/llvm/lib/CodeGen/MachineInstr.cpp +++ b/llvm/lib/CodeGen/MachineInstr.cpp @@ -52,6 +52,7 @@ #include "llvm/IR/ModuleSlotTracker.h" #include "llvm/IR/Type.h" #include "llvm/IR/Value.h" +#include "llvm/IR/Operator.h" #include "llvm/MC/MCInstrDesc.h" #include "llvm/MC/MCRegisterInfo.h" #include "llvm/MC/MCSymbol.h" @@ -517,6 +518,41 @@ uint16_t MachineInstr::mergeFlagsWith(const MachineInstr &Other) const { return getFlags() | Other.getFlags(); } +void MachineInstr::copyIRFlags(const Instruction &I) { + // Copy the wrapping flags. + if (const OverflowingBinaryOperator *OB = + dyn_cast<OverflowingBinaryOperator>(&I)) { + if (OB->hasNoSignedWrap()) + setFlag(MachineInstr::MIFlag::NoSWrap); + if (OB->hasNoUnsignedWrap()) + setFlag(MachineInstr::MIFlag::NoUWrap); + } + + // Copy the exact flag. + if (const PossiblyExactOperator *PE = dyn_cast<PossiblyExactOperator>(&I)) + if (PE->isExact()) + setFlag(MachineInstr::MIFlag::IsExact); + + // Copy the fast-math flags. + if (const FPMathOperator *FP = dyn_cast<FPMathOperator>(&I)) { + const FastMathFlags Flags = FP->getFastMathFlags(); + if (Flags.noNaNs()) + setFlag(MachineInstr::MIFlag::FmNoNans); + if (Flags.noInfs()) + setFlag(MachineInstr::MIFlag::FmNoInfs); + if (Flags.noSignedZeros()) + setFlag(MachineInstr::MIFlag::FmNsz); + if (Flags.allowReciprocal()) + setFlag(MachineInstr::MIFlag::FmArcp); + if (Flags.allowContract()) + setFlag(MachineInstr::MIFlag::FmContract); + if (Flags.approxFunc()) + setFlag(MachineInstr::MIFlag::FmAfn); + if (Flags.allowReassoc()) + setFlag(MachineInstr::MIFlag::FmReassoc); + } +} + bool MachineInstr::hasPropertyInBundle(uint64_t Mask, QueryType Type) const { assert(!isBundledWithPred() && "Must be called on bundle header"); for (MachineBasicBlock::const_instr_iterator MII = getIterator();; ++MII) { |