diff options
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp | 42 |
1 files changed, 26 insertions, 16 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp b/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp index 49ddd6961f8..e59bde6770f 100644 --- a/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp +++ b/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp @@ -1,4 +1,4 @@ -//===--- HexagonConstPropagation.cpp --------------------------------------===// +//===- HexagonConstPropagation.cpp ----------------------------------------===// // // The LLVM Compiler Infrastructure // @@ -26,13 +26,16 @@ #include "llvm/CodeGen/MachineOperand.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/IR/Constants.h" +#include "llvm/IR/Type.h" #include "llvm/Pass.h" #include "llvm/Support/Casting.h" +#include "llvm/Support/Compiler.h" #include "llvm/Support/Debug.h" #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MathExtras.h" #include "llvm/Support/raw_ostream.h" #include "llvm/Target/TargetRegisterInfo.h" +#include "llvm/Target/TargetSubtargetInfo.h" #include <cassert> #include <cstdint> #include <cstring> @@ -224,7 +227,8 @@ namespace { void print(raw_ostream &os, const TargetRegisterInfo &TRI) const; private: - typedef std::map<unsigned,LatticeCell> MapType; + using MapType = std::map<unsigned, LatticeCell>; + MapType Map; // To avoid creating "top" entries, return a const reference to // this cell in "get". Also, have a "Bottom" cell to return from @@ -232,7 +236,8 @@ namespace { LatticeCell Top, Bottom; public: - typedef MapType::const_iterator const_iterator; + using const_iterator = MapType::const_iterator; + const_iterator begin() const { return Map.begin(); } const_iterator end() const { return Map.end(); } }; @@ -254,10 +259,10 @@ namespace { MachineRegisterInfo *MRI; MachineConstEvaluator &MCE; - typedef std::pair<unsigned,unsigned> CFGEdge; - typedef std::set<CFGEdge> SetOfCFGEdge; - typedef std::set<const MachineInstr*> SetOfInstr; - typedef std::queue<CFGEdge> QueueOfCFGEdge; + using CFGEdge = std::pair<unsigned, unsigned>; + using SetOfCFGEdge = std::set<CFGEdge>; + using SetOfInstr = std::set<const MachineInstr *>; + using QueueOfCFGEdge = std::queue<CFGEdge>; LatticeCell Bottom; CellMap Cells; @@ -291,7 +296,7 @@ namespace { // - A function "rewrite", that given the cell map after propagation, // could rewrite instruction MI in a more beneficial form. Return // "true" if a change has been made, "false" otherwise. - typedef MachineConstPropagator::CellMap CellMap; + using CellMap = MachineConstPropagator::CellMap; virtual bool evaluate(const MachineInstr &MI, const CellMap &Inputs, CellMap &Outputs) = 0; virtual bool evaluate(const Register &R, const LatticeCell &SrcC, @@ -1028,7 +1033,7 @@ bool MachineConstPropagator::rewrite(MachineFunction &MF) { // This is the constant propagation algorithm as described by Wegman-Zadeck. // Most of the terminology comes from there. bool MachineConstPropagator::run(MachineFunction &MF) { - DEBUG(MF.print(dbgs() << "Starting MachineConstPropagator\n", 0)); + DEBUG(MF.print(dbgs() << "Starting MachineConstPropagator\n", nullptr)); MRI = &MF.getRegInfo(); @@ -1043,7 +1048,7 @@ bool MachineConstPropagator::run(MachineFunction &MF) { DEBUG({ dbgs() << "End of MachineConstPropagator (Changed=" << Changed << ")\n"; if (Changed) - MF.print(dbgs(), 0); + MF.print(dbgs(), nullptr); }); return Changed; } @@ -1278,7 +1283,8 @@ bool MachineConstEvaluator::evaluateCMPpi(uint32_t Cmp, uint32_t Props, bool MachineConstEvaluator::evaluateCMPpp(uint32_t Cmp, uint32_t Props1, uint32_t Props2, bool &Result) { - typedef ConstantProperties P; + using P = ConstantProperties; + if ((Props1 & P::NaN) && (Props2 & P::NaN)) return false; if (!(Props1 & P::Finite) || !(Props2 & P::Finite)) @@ -1886,10 +1892,10 @@ namespace { } }; - char HexagonConstPropagation::ID = 0; - } // end anonymous namespace +char HexagonConstPropagation::ID = 0; + INITIALIZE_PASS(HexagonConstPropagation, "hcp", "Hexagon Constant Propagation", false, false) @@ -2192,7 +2198,8 @@ bool HexagonConstEvaluator::evaluate(const Register &R, if (Input.isBottom()) return false; - typedef ConstantProperties P; + using P = ConstantProperties; + if (Input.isProperty()) { uint32_t Ps = Input.properties(); if (Ps & (P::Zero|P::NaN)) { @@ -2837,7 +2844,8 @@ bool HexagonConstEvaluator::rewriteHexConstDefs(MachineInstr &MI, if (!L.isSingle()) { // If this a zero/non-zero cell, we can fold a definition // of a predicate register. - typedef ConstantProperties P; + using P = ConstantProperties; + uint64_t Ps = L.properties(); if (!(Ps & (P::Zero|P::NonZero))) continue; @@ -3039,7 +3047,9 @@ bool HexagonConstEvaluator::rewriteHexConstUses(MachineInstr &MI, assert(Inputs.has(R1.Reg) && Inputs.has(R2.Reg)); LatticeCell LS1, LS2; unsigned CopyOf = 0; - typedef ConstantProperties P; + + using P = ConstantProperties; + if (getCell(R1, Inputs, LS1) && (LS1.properties() & P::Zero)) CopyOf = 2; else if (getCell(R2, Inputs, LS2) && (LS2.properties() & P::Zero)) |