summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp')
-rw-r--r--llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp140
1 files changed, 51 insertions, 89 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp b/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp
index 3cec6def6b5..783b916e04b 100644
--- a/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp
+++ b/llvm/lib/Target/Hexagon/HexagonConstPropagation.cpp
@@ -12,27 +12,40 @@
#include "HexagonInstrInfo.h"
#include "HexagonRegisterInfo.h"
#include "HexagonSubtarget.h"
-
+#include "llvm/ADT/APFloat.h"
+#include "llvm/ADT/APInt.h"
#include "llvm/ADT/PostOrderIterator.h"
#include "llvm/ADT/SetVector.h"
+#include "llvm/ADT/SmallVector.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/CodeGen/MachineBasicBlock.h"
#include "llvm/CodeGen/MachineFunction.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
+#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
+#include "llvm/CodeGen/MachineOperand.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/IR/Constants.h"
-#include "llvm/Support/CommandLine.h"
+#include "llvm/Pass.h"
+#include "llvm/Support/Casting.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/TargetInstrInfo.h"
-
+#include "llvm/Target/TargetRegisterInfo.h"
+#include <cassert>
+#include <cstdint>
+#include <cstring>
+#include <iterator>
#include <map>
#include <queue>
#include <set>
+#include <utility>
+#include <vector>
using namespace llvm;
namespace {
- class LatticeCell;
// Properties of a value that are tracked by the propagation.
// A property that is marked as present (i.e. bit is set) dentes that the
@@ -62,23 +75,24 @@ namespace {
static uint32_t deduce(const Constant *C);
};
-
// A representation of a register as it can appear in a MachineOperand,
// i.e. a pair register:subregister.
struct Register {
unsigned Reg, SubReg;
+
explicit Register(unsigned R, unsigned SR = 0) : Reg(R), SubReg(SR) {}
explicit Register(const MachineOperand &MO)
: Reg(MO.getReg()), SubReg(MO.getSubReg()) {}
- void print(const TargetRegisterInfo *TRI = 0) const {
+
+ void print(const TargetRegisterInfo *TRI = nullptr) const {
dbgs() << PrintReg(Reg, TRI, SubReg);
}
+
bool operator== (const Register &R) const {
return (Reg == R.Reg) && (SubReg == R.SubReg);
}
};
-
// Lattice cell, based on that was described in the W-Z paper on constant
// propagation.
// Latice cell will be allowed to hold multiple constant values. While
@@ -89,7 +103,9 @@ namespace {
class LatticeCell {
private:
enum { Normal, Top, Bottom };
+
static const unsigned MaxCellSize = 4;
+
unsigned Kind:2;
unsigned Size:3;
unsigned IsSpecial:1;
@@ -104,7 +120,7 @@ namespace {
LatticeCell() : Kind(Top), Size(0), IsSpecial(false) {
for (unsigned i = 0; i < MaxCellSize; ++i)
- Values[i] = 0;
+ Values[i] = nullptr;
}
bool meet(const LatticeCell &L);
@@ -130,6 +146,7 @@ namespace {
bool isProperty() const { return IsSpecial; }
bool isTop() const { return Kind == Top; }
bool isBottom() const { return Kind == Bottom; }
+
bool setBottom() {
bool Changed = (Kind != Bottom);
Kind = Bottom;
@@ -137,6 +154,7 @@ namespace {
IsSpecial = false;
return Changed;
}
+
void print(raw_ostream &os) const;
private:
@@ -145,6 +163,7 @@ namespace {
Size = 0;
Kind = Normal;
}
+
bool convertToProperty();
};
@@ -177,7 +196,9 @@ namespace {
assert(Top.isTop());
Bottom.setBottom();
}
+
void clear() { Map.clear(); }
+
bool has(unsigned R) const {
// All non-virtual registers are considered "bottom".
if (!TargetRegisterInfo::isVirtualRegister(R))
@@ -185,6 +206,7 @@ namespace {
MapType::const_iterator F = Map.find(R);
return F != Map.end();
}
+
const LatticeCell &get(unsigned R) const {
if (!TargetRegisterInfo::isVirtualRegister(R))
return Bottom;
@@ -193,11 +215,14 @@ namespace {
return F->second;
return Top;
}
+
// Invalidates any const references.
void update(unsigned R, const LatticeCell &L) {
Map[R] = L;
}
+
void print(raw_ostream &os, const TargetRegisterInfo &TRI) const;
+
private:
typedef std::map<unsigned,LatticeCell> MapType;
MapType Map;
@@ -205,6 +230,7 @@ namespace {
// this cell in "get". Also, have a "Bottom" cell to return from
// get when a value of a physical register is requested.
LatticeCell Top, Bottom;
+
public:
typedef MapType::const_iterator const_iterator;
const_iterator begin() const { return Map.begin(); }
@@ -240,7 +266,6 @@ namespace {
QueueOfCFGEdge FlowQ;
};
-
// The "evaluator/rewriter" of machine instructions. This is an abstract
// base class that provides the interface that the propagator will use,
// as well as some helper functions that are target-independent.
@@ -249,7 +274,7 @@ namespace {
MachineConstEvaluator(MachineFunction &Fn)
: TRI(*Fn.getSubtarget().getRegisterInfo()),
MF(Fn), CX(Fn.getFunction()->getContext()) {}
- virtual ~MachineConstEvaluator() {}
+ virtual ~MachineConstEvaluator() = default;
// The required interface:
// - A set of three "evaluate" functions. Each returns "true" if the
@@ -299,6 +324,7 @@ namespace {
GTu = G | U,
GEu = G | EQ | U
};
+
static uint32_t negate(uint32_t Cmp) {
if (Cmp == EQ)
return NE;
@@ -381,7 +407,7 @@ namespace {
APInt &Result);
};
-}
+} // end anonymous namespace
uint32_t ConstantProperties::deduce(const Constant *C) {
if (isa<ConstantInt>(C)) {
@@ -413,7 +439,6 @@ uint32_t ConstantProperties::deduce(const Constant *C) {
return Unknown;
}
-
// Convert a cell from a set of specific values to a cell that tracks
// properties.
bool LatticeCell::convertToProperty() {
@@ -433,7 +458,6 @@ bool LatticeCell::convertToProperty() {
return true;
}
-
void LatticeCell::print(raw_ostream &os) const {
if (isProperty()) {
os << "{ ";
@@ -472,7 +496,6 @@ void LatticeCell::print(raw_ostream &os) const {
os << " }";
}
-
// "Meet" operation on two cells. This is the key of the propagation
// algorithm.
bool LatticeCell::meet(const LatticeCell &L) {
@@ -497,7 +520,6 @@ bool LatticeCell::meet(const LatticeCell &L) {
return Changed;
}
-
// Add a new constant to the cell. This is actually where the cell update
// happens. If a cell has room for more constants, the new constant is added.
// Otherwise, the cell is converted to a "property" cell (i.e. a cell that
@@ -545,7 +567,6 @@ bool LatticeCell::add(const Constant *LC) {
return Changed;
}
-
// Add a property to the cell. This will force the cell to become a property-
// tracking cell.
bool LatticeCell::add(uint32_t Property) {
@@ -557,7 +578,6 @@ bool LatticeCell::add(uint32_t Property) {
return true;
}
-
// Return the properties of the values in the cell. This is valid for any
// cell, and does not alter the cell itself.
uint32_t LatticeCell::properties() const {
@@ -577,14 +597,12 @@ uint32_t LatticeCell::properties() const {
return Ps;
}
-
void MachineConstPropagator::CellMap::print(raw_ostream &os,
const TargetRegisterInfo &TRI) const {
for (auto &I : Map)
dbgs() << " " << PrintReg(I.first, &TRI) << " -> " << I.second << '\n';
}
-
void MachineConstPropagator::visitPHI(const MachineInstr &PN) {
const MachineBasicBlock *MB = PN.getParent();
unsigned MBN = MB->getNumber();
@@ -642,7 +660,6 @@ Bottomize:
visitUsesOf(DefR.Reg);
}
-
void MachineConstPropagator::visitNonBranch(const MachineInstr &MI) {
DEBUG(dbgs() << "Visiting MI(BB#" << MI.getParent()->getNumber()
<< "): " << MI);
@@ -686,7 +703,6 @@ void MachineConstPropagator::visitNonBranch(const MachineInstr &MI) {
}
}
-
// \brief Starting at a given branch, visit remaining branches in the block.
// Traverse over the subsequent branches for as long as the preceding one
// can fall through. Add all the possible targets to the flow work queue,
@@ -750,7 +766,6 @@ void MachineConstPropagator::visitBranchesFrom(const MachineInstr &BrI) {
}
}
-
void MachineConstPropagator::visitUsesOf(unsigned Reg) {
DEBUG(dbgs() << "Visiting uses of " << PrintReg(Reg, &MCE.TRI)
<< Cells.get(Reg) << '\n');
@@ -814,7 +829,6 @@ bool MachineConstPropagator::computeBlockSuccessors(const MachineBasicBlock *MB,
return true;
}
-
void MachineConstPropagator::removeCFGEdge(MachineBasicBlock *From,
MachineBasicBlock *To) {
// First, remove the CFG successor/predecessor information.
@@ -834,7 +848,6 @@ void MachineConstPropagator::removeCFGEdge(MachineBasicBlock *From,
}
}
-
void MachineConstPropagator::propagate(MachineFunction &MF) {
MachineBasicBlock *Entry = GraphTraits<MachineFunction*>::getEntryNode(&MF);
unsigned EntryNum = Entry->getNumber();
@@ -916,7 +929,6 @@ void MachineConstPropagator::propagate(MachineFunction &MF) {
});
}
-
bool MachineConstPropagator::rewrite(MachineFunction &MF) {
bool Changed = false;
// Rewrite all instructions based on the collected cell information.
@@ -1013,7 +1025,6 @@ bool MachineConstPropagator::rewrite(MachineFunction &MF) {
return Changed;
}
-
// This is the constant propagation algorithm as described by Wegman-Zadeck.
// Most of the terminology comes from there.
bool MachineConstPropagator::run(MachineFunction &MF) {
@@ -1037,7 +1048,6 @@ bool MachineConstPropagator::run(MachineFunction &MF) {
return Changed;
}
-
// --------------------------------------------------------------------
// Machine const evaluator.
@@ -1054,7 +1064,6 @@ bool MachineConstEvaluator::getCell(const Register &R, const CellMap &Inputs,
return Eval && !RC.isBottom();
}
-
bool MachineConstEvaluator::constToInt(const Constant *C,
APInt &Val) const {
const ConstantInt *CI = dyn_cast<ConstantInt>(C);
@@ -1064,12 +1073,10 @@ bool MachineConstEvaluator::constToInt(const Constant *C,
return true;
}
-
const ConstantInt *MachineConstEvaluator::intToConst(const APInt &Val) const {
return ConstantInt::get(CX, Val);
}
-
bool MachineConstEvaluator::evaluateCMPrr(uint32_t Cmp, const Register &R1,
const Register &R2, const CellMap &Inputs, bool &Result) {
assert(Inputs.has(R1.Reg) && Inputs.has(R2.Reg));
@@ -1109,7 +1116,6 @@ bool MachineConstEvaluator::evaluateCMPrr(uint32_t Cmp, const Register &R1,
return IsTrue || IsFalse;
}
-
bool MachineConstEvaluator::evaluateCMPri(uint32_t Cmp, const Register &R1,
const APInt &A2, const CellMap &Inputs, bool &Result) {
assert(Inputs.has(R1.Reg));
@@ -1137,7 +1143,6 @@ bool MachineConstEvaluator::evaluateCMPri(uint32_t Cmp, const Register &R1,
return IsTrue || IsFalse;
}
-
bool MachineConstEvaluator::evaluateCMPrp(uint32_t Cmp, const Register &R1,
uint64_t Props2, const CellMap &Inputs, bool &Result) {
assert(Inputs.has(R1.Reg));
@@ -1164,7 +1169,6 @@ bool MachineConstEvaluator::evaluateCMPrp(uint32_t Cmp, const Register &R1,
return IsTrue || IsFalse;
}
-
bool MachineConstEvaluator::evaluateCMPii(uint32_t Cmp, const APInt &A1,
const APInt &A2, bool &Result) {
// NE is a special kind of comparison (not composed of smaller properties).
@@ -1206,7 +1210,6 @@ bool MachineConstEvaluator::evaluateCMPii(uint32_t Cmp, const APInt &A1,
return true;
}
-
bool MachineConstEvaluator::evaluateCMPpi(uint32_t Cmp, uint32_t Props,
const APInt &A2, bool &Result) {
if (Props == ConstantProperties::Unknown)
@@ -1273,7 +1276,6 @@ bool MachineConstEvaluator::evaluateCMPpi(uint32_t Cmp, uint32_t Props,
return false;
}
-
bool MachineConstEvaluator::evaluateCMPpp(uint32_t Cmp, uint32_t Props1,
uint32_t Props2, bool &Result) {
typedef ConstantProperties P;
@@ -1333,13 +1335,11 @@ bool MachineConstEvaluator::evaluateCMPpp(uint32_t Cmp, uint32_t Props1,
return false;
}
-
bool MachineConstEvaluator::evaluateCOPY(const Register &R1,
const CellMap &Inputs, LatticeCell &Result) {
return getCell(R1, Inputs, Result);
}
-
bool MachineConstEvaluator::evaluateANDrr(const Register &R1,
const Register &R2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg) && Inputs.has(R2.Reg));
@@ -1371,7 +1371,6 @@ bool MachineConstEvaluator::evaluateANDrr(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateANDri(const Register &R1,
const APInt &A2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1402,14 +1401,12 @@ bool MachineConstEvaluator::evaluateANDri(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateANDii(const APInt &A1,
const APInt &A2, APInt &Result) {
Result = A1 & A2;
return true;
}
-
bool MachineConstEvaluator::evaluateORrr(const Register &R1,
const Register &R2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg) && Inputs.has(R2.Reg));
@@ -1441,7 +1438,6 @@ bool MachineConstEvaluator::evaluateORrr(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateORri(const Register &R1,
const APInt &A2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1472,14 +1468,12 @@ bool MachineConstEvaluator::evaluateORri(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateORii(const APInt &A1,
const APInt &A2, APInt &Result) {
Result = A1 | A2;
return true;
}
-
bool MachineConstEvaluator::evaluateXORrr(const Register &R1,
const Register &R2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg) && Inputs.has(R2.Reg));
@@ -1509,7 +1503,6 @@ bool MachineConstEvaluator::evaluateXORrr(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateXORri(const Register &R1,
const APInt &A2, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1537,14 +1530,12 @@ bool MachineConstEvaluator::evaluateXORri(const Register &R1,
return !Result.isBottom();
}
-
bool MachineConstEvaluator::evaluateXORii(const APInt &A1,
const APInt &A2, APInt &Result) {
Result = A1 ^ A2;
return true;
}
-
bool MachineConstEvaluator::evaluateZEXTr(const Register &R1, unsigned Width,
unsigned Bits, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1566,7 +1557,6 @@ bool MachineConstEvaluator::evaluateZEXTr(const Register &R1, unsigned Width,
return true;
}
-
bool MachineConstEvaluator::evaluateZEXTi(const APInt &A1, unsigned Width,
unsigned Bits, APInt &Result) {
unsigned BW = A1.getBitWidth();
@@ -1577,7 +1567,6 @@ bool MachineConstEvaluator::evaluateZEXTi(const APInt &A1, unsigned Width,
return true;
}
-
bool MachineConstEvaluator::evaluateSEXTr(const Register &R1, unsigned Width,
unsigned Bits, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1599,7 +1588,6 @@ bool MachineConstEvaluator::evaluateSEXTr(const Register &R1, unsigned Width,
return true;
}
-
bool MachineConstEvaluator::evaluateSEXTi(const APInt &A1, unsigned Width,
unsigned Bits, APInt &Result) {
unsigned BW = A1.getBitWidth();
@@ -1644,7 +1632,6 @@ bool MachineConstEvaluator::evaluateSEXTi(const APInt &A1, unsigned Width,
return true;
}
-
bool MachineConstEvaluator::evaluateCLBr(const Register &R1, bool Zeros,
bool Ones, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1666,7 +1653,6 @@ bool MachineConstEvaluator::evaluateCLBr(const Register &R1, bool Zeros,
return true;
}
-
bool MachineConstEvaluator::evaluateCLBi(const APInt &A1, bool Zeros,
bool Ones, APInt &Result) {
unsigned BW = A1.getBitWidth();
@@ -1681,7 +1667,6 @@ bool MachineConstEvaluator::evaluateCLBi(const APInt &A1, bool Zeros,
return true;
}
-
bool MachineConstEvaluator::evaluateCTBr(const Register &R1, bool Zeros,
bool Ones, const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(R1.Reg));
@@ -1703,7 +1688,6 @@ bool MachineConstEvaluator::evaluateCTBr(const Register &R1, bool Zeros,
return true;
}
-
bool MachineConstEvaluator::evaluateCTBi(const APInt &A1, bool Zeros,
bool Ones, APInt &Result) {
unsigned BW = A1.getBitWidth();
@@ -1718,7 +1702,6 @@ bool MachineConstEvaluator::evaluateCTBi(const APInt &A1, bool Zeros,
return true;
}
-
bool MachineConstEvaluator::evaluateEXTRACTr(const Register &R1,
unsigned Width, unsigned Bits, unsigned Offset, bool Signed,
const CellMap &Inputs, LatticeCell &Result) {
@@ -1751,7 +1734,6 @@ bool MachineConstEvaluator::evaluateEXTRACTr(const Register &R1,
return true;
}
-
bool MachineConstEvaluator::evaluateEXTRACTi(const APInt &A1, unsigned Bits,
unsigned Offset, bool Signed, APInt &Result) {
unsigned BW = A1.getBitWidth();
@@ -1778,7 +1760,6 @@ bool MachineConstEvaluator::evaluateEXTRACTi(const APInt &A1, unsigned Bits,
return true;
}
-
bool MachineConstEvaluator::evaluateSplatr(const Register &R1,
unsigned Bits, unsigned Count, const CellMap &Inputs,
LatticeCell &Result) {
@@ -1801,7 +1782,6 @@ bool MachineConstEvaluator::evaluateSplatr(const Register &R1,
return true;
}
-
bool MachineConstEvaluator::evaluateSplati(const APInt &A1, unsigned Bits,
unsigned Count, APInt &Result) {
assert(Count > 0);
@@ -1819,16 +1799,18 @@ bool MachineConstEvaluator::evaluateSplati(const APInt &A1, unsigned Bits,
return true;
}
-
// ----------------------------------------------------------------------
// Hexagon-specific code.
namespace llvm {
+
FunctionPass *createHexagonConstPropagationPass();
void initializeHexagonConstPropagationPass(PassRegistry &Registry);
-}
+
+} // end namespace llvm
namespace {
+
class HexagonConstEvaluator : public MachineConstEvaluator {
public:
HexagonConstEvaluator(MachineFunction &Fn);
@@ -1842,7 +1824,6 @@ namespace {
override;
bool rewrite(MachineInstr &MI, const CellMap &Inputs) override;
-
private:
unsigned getRegBitWidth(unsigned Reg) const;
@@ -1880,17 +1861,19 @@ namespace {
const HexagonRegisterInfo &HRI;
};
-
class HexagonConstPropagation : public MachineFunctionPass {
public:
static char ID;
+
HexagonConstPropagation() : MachineFunctionPass(ID) {
PassRegistry &Registry = *PassRegistry::getPassRegistry();
initializeHexagonConstPropagationPass(Registry);
}
+
StringRef getPassName() const override {
return "Hexagon Constant Propagation";
}
+
bool runOnMachineFunction(MachineFunction &MF) override {
const Function *F = MF.getFunction();
if (!F)
@@ -1904,12 +1887,12 @@ namespace {
};
char HexagonConstPropagation::ID = 0;
-}
+
+} // end anonymous namespace
INITIALIZE_PASS(HexagonConstPropagation, "hcp", "Hexagon Constant Propagation",
false, false)
-
HexagonConstEvaluator::HexagonConstEvaluator(MachineFunction &Fn)
: MachineConstEvaluator(Fn),
HII(*Fn.getSubtarget<HexagonSubtarget>().getInstrInfo()),
@@ -1917,7 +1900,6 @@ HexagonConstEvaluator::HexagonConstEvaluator(MachineFunction &Fn)
MRI = &Fn.getRegInfo();
}
-
bool HexagonConstEvaluator::evaluate(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
if (MI.isCall())
@@ -2081,6 +2063,7 @@ bool HexagonConstEvaluator::evaluate(const MachineInstr &MI,
case Hexagon::S2_ct1p:
{
using namespace Hexagon;
+
bool Ones = (Opc == S2_ct1) || (Opc == S2_ct1p);
Register R1(MI.getOperand(1));
assert(Inputs.has(R1.Reg));
@@ -2111,6 +2094,7 @@ bool HexagonConstEvaluator::evaluate(const MachineInstr &MI,
case Hexagon::S2_clbp:
{
using namespace Hexagon;
+
bool OnlyZeros = (Opc == S2_cl0) || (Opc == S2_cl0p);
bool OnlyOnes = (Opc == S2_cl1) || (Opc == S2_cl1p);
Register R1(MI.getOperand(1));
@@ -2192,7 +2176,6 @@ bool HexagonConstEvaluator::evaluate(const MachineInstr &MI,
return true;
}
-
bool HexagonConstEvaluator::evaluate(const Register &R,
const LatticeCell &Input, LatticeCell &Result) {
if (!R.SubReg) {
@@ -2248,7 +2231,6 @@ bool HexagonConstEvaluator::evaluate(const Register &R,
return true;
}
-
bool HexagonConstEvaluator::evaluate(const MachineInstr &BrI,
const CellMap &Inputs, SetVector<const MachineBasicBlock*> &Targets,
bool &FallsThru) {
@@ -2317,7 +2299,6 @@ Undetermined:
return true;
}
-
bool HexagonConstEvaluator::rewrite(MachineInstr &MI, const CellMap &Inputs) {
if (MI.isBranch())
return rewriteHexBranch(MI, Inputs);
@@ -2350,7 +2331,6 @@ bool HexagonConstEvaluator::rewrite(MachineInstr &MI, const CellMap &Inputs) {
return Changed;
}
-
unsigned HexagonConstEvaluator::getRegBitWidth(unsigned Reg) const {
const TargetRegisterClass *RC = MRI->getRegClass(Reg);
if (Hexagon::IntRegsRegClass.hasSubClassEq(RC))
@@ -2363,7 +2343,6 @@ unsigned HexagonConstEvaluator::getRegBitWidth(unsigned Reg) const {
return 0;
}
-
uint32_t HexagonConstEvaluator::getCmp(unsigned Opc) {
switch (Opc) {
case Hexagon::C2_cmpeq:
@@ -2459,7 +2438,6 @@ uint32_t HexagonConstEvaluator::getCmp(unsigned Opc) {
return Comparison::Unk;
}
-
APInt HexagonConstEvaluator::getCmpImm(unsigned Opc, unsigned OpX,
const MachineOperand &MO) {
bool Signed = false;
@@ -2502,14 +2480,12 @@ APInt HexagonConstEvaluator::getCmpImm(unsigned Opc, unsigned OpX,
return APInt(32, Val, Signed);
}
-
void HexagonConstEvaluator::replaceWithNop(MachineInstr &MI) {
MI.setDesc(HII.get(Hexagon::A2_nop));
while (MI.getNumOperands() > 0)
MI.RemoveOperand(0);
}
-
bool HexagonConstEvaluator::evaluateHexRSEQ32(Register RL, Register RH,
const CellMap &Inputs, LatticeCell &Result) {
assert(Inputs.has(RL.Reg) && Inputs.has(RH.Reg));
@@ -2547,7 +2523,6 @@ bool HexagonConstEvaluator::evaluateHexRSEQ32(Register RL, Register RH,
return !Result.isBottom();
}
-
bool HexagonConstEvaluator::evaluateHexCompare(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
unsigned Opc = MI.getOpcode();
@@ -2593,7 +2568,6 @@ bool HexagonConstEvaluator::evaluateHexCompare(const MachineInstr &MI,
return false;
}
-
bool HexagonConstEvaluator::evaluateHexCompare2(unsigned Opc,
const MachineOperand &Src1, const MachineOperand &Src2,
const CellMap &Inputs, bool &Result) {
@@ -2624,7 +2598,6 @@ bool HexagonConstEvaluator::evaluateHexCompare2(unsigned Opc,
return false;
}
-
bool HexagonConstEvaluator::evaluateHexLogical(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
unsigned Opc = MI.getOpcode();
@@ -2668,7 +2641,6 @@ bool HexagonConstEvaluator::evaluateHexLogical(const MachineInstr &MI,
return Eval;
}
-
bool HexagonConstEvaluator::evaluateHexCondMove(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
// Dst0 = Cond1 ? Src2 : Src3
@@ -2712,7 +2684,6 @@ bool HexagonConstEvaluator::evaluateHexCondMove(const MachineInstr &MI,
return false;
}
-
bool HexagonConstEvaluator::evaluateHexExt(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
// Dst0 = ext R1
@@ -2755,7 +2726,6 @@ bool HexagonConstEvaluator::evaluateHexExt(const MachineInstr &MI,
return true;
}
-
bool HexagonConstEvaluator::evaluateHexVector1(const MachineInstr &MI,
const CellMap &Inputs, CellMap &Outputs) {
// DefR = op R1
@@ -2785,7 +2755,6 @@ bool HexagonConstEvaluator::evaluateHexVector1(const MachineInstr &MI,
return true;
}
-
bool HexagonConstEvaluator::rewriteHexConstDefs(MachineInstr &MI,
const CellMap &Inputs, bool &AllDefs) {
AllDefs = false;
@@ -2793,8 +2762,7 @@ bool HexagonConstEvaluator::rewriteHexConstDefs(MachineInstr &MI,
// Some diagnostics.
// DEBUG({...}) gets confused with all this code as an argument.
#ifndef NDEBUG
- bool Debugging = llvm::DebugFlag &&
- llvm::isCurrentDebugType(DEBUG_TYPE);
+ bool Debugging = DebugFlag && isCurrentDebugType(DEBUG_TYPE);
if (Debugging) {
bool Const = true, HasUse = false;
for (const MachineOperand &MO : MI.operands()) {
@@ -2950,7 +2918,6 @@ bool HexagonConstEvaluator::rewriteHexConstDefs(MachineInstr &MI,
return ChangedNum > 0;
}
-
bool HexagonConstEvaluator::rewriteHexConstUses(MachineInstr &MI,
const CellMap &Inputs) {
bool Changed = false;
@@ -2958,7 +2925,7 @@ bool HexagonConstEvaluator::rewriteHexConstUses(MachineInstr &MI,
MachineBasicBlock &B = *MI.getParent();
const DebugLoc &DL = MI.getDebugLoc();
MachineBasicBlock::iterator At = MI.getIterator();
- MachineInstr *NewMI = NULL;
+ MachineInstr *NewMI = nullptr;
switch (Opc) {
case Hexagon::M2_maci:
@@ -3115,7 +3082,6 @@ bool HexagonConstEvaluator::rewriteHexConstUses(MachineInstr &MI,
return Changed;
}
-
void HexagonConstEvaluator::replaceAllRegUsesWith(unsigned FromReg,
unsigned ToReg) {
assert(TargetRegisterInfo::isVirtualRegister(FromReg));
@@ -3127,7 +3093,6 @@ void HexagonConstEvaluator::replaceAllRegUsesWith(unsigned FromReg,
}
}
-
bool HexagonConstEvaluator::rewriteHexBranch(MachineInstr &BrI,
const CellMap &Inputs) {
MachineBasicBlock &B = *BrI.getParent();
@@ -3179,9 +3144,6 @@ bool HexagonConstEvaluator::rewriteHexBranch(MachineInstr &BrI,
return true;
}
-
-// --------------------------------------------------------------------
FunctionPass *llvm::createHexagonConstPropagationPass() {
return new HexagonConstPropagation();
}
-
OpenPOWER on IntegriCloud