38 #define DEBUG_TYPE "hexagon-peephole"
62 cl::desc(
"Disable Peephole Optimization"));
66 cl::desc(
"Disable Optimization of PNotP"));
70 cl::desc(
"Disable Optimization of Sign/Zero Extends"));
74 cl::desc(
"Disable Optimization of extensions to i64."));
94 const char *getPassName()
const {
95 return "Hexagon optimize redundant zero and size extends";
117 MRI = &MF.getRegInfo();
126 MBBb != MBBe; ++MBBb) {
129 PeepholeDoubleRegsMap.
clear();
141 unsigned DstReg = Dst.
getReg();
142 unsigned SrcReg = Src.
getReg();
149 PeepholeMap[DstReg] = SrcReg;
156 MI->
getOpcode () == Hexagon::COMBINE_Ir_V4) {
163 unsigned DstReg = Dst.
getReg();
164 unsigned SrcReg = Src2.
getReg();
165 PeepholeMap[DstReg] = SrcReg;
173 if (MI->
getOpcode() == Hexagon::LSRd_ri) {
180 unsigned DstReg = Dst.
getReg();
181 unsigned SrcReg = Src1.
getReg();
182 PeepholeDoubleRegsMap[DstReg] =
183 std::make_pair(*&SrcReg, 1);
192 unsigned DstReg = Dst.
getReg();
193 unsigned SrcReg = Src.
getReg();
200 PeepholeMap[DstReg] = SrcReg;
212 if (Src.
getSubReg() != Hexagon::subreg_loreg)
215 unsigned DstReg = Dst.
getReg();
216 unsigned SrcReg = Src.
getReg();
220 if (
unsigned PeepholeSrc = PeepholeMap.
lookup(SrcReg)) {
226 PeepholeDoubleRegsMap.
find(SrcReg);
227 if (DI != PeepholeDoubleRegsMap.
end()) {
228 std::pair<unsigned,unsigned> PeepholeSrc = DI->second;
237 PeepholeSrc.second));
246 if (QII->isPredicated(MI)) {
248 unsigned Reg0 = Op0.
getReg();
250 if (RC0->
getID() == Hexagon::PredRegsRegClassID) {
255 if (
unsigned PeepholeSrc = PeepholeMap.
lookup(Reg0)) {
258 int NewOp = QII->getInvertedPredicatedOpcode(MI->
getOpcode());
270 unsigned PR = 1, S1 = 2, S2 = 3;
273 case Hexagon::TFR_condset_rr:
274 case Hexagon::TFR_condset_ii:
275 case Hexagon::MUX_ii:
276 case Hexagon::MUX_rr:
279 case Hexagon::TFR_condset_ri:
280 NewOp = Hexagon::TFR_condset_ir;
282 case Hexagon::TFR_condset_ir:
283 NewOp = Hexagon::TFR_condset_ri;
285 case Hexagon::MUX_ri:
286 NewOp = Hexagon::MUX_ir;
288 case Hexagon::MUX_ir:
289 NewOp = Hexagon::MUX_ri;
294 if (
unsigned POrig = PeepholeMap.
lookup(PSrc)) {
314 assert (&Dst != &Src &&
"Cannot duplicate into itself");
319 }
else if (Src.
isImm()) {
329 }
else if (Src.
isReg()) {
345 return new HexagonPeephole();
INITIALIZE_PASS(HexagonPeephole,"hexagon-peephole","Hexagon Peephole", false, false) bool HexagonPeephole
static PassRegistry * getPassRegistry()
void ChangeToRegister(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isDebug=false)
static bool isVirtualRegister(unsigned Reg)
static MachineOperand CreateReg(unsigned Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
static cl::opt< bool > DisableOptExtTo64("disable-hexagon-opt-ext-to-64", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Optimization of extensions to i64."))
bool isReg() const
isReg - Tests if this is a MO_Register operand.
ID
LLVM Calling Convention Representation.
static cl::opt< bool > DisablePNotP("disable-hexagon-pnotp", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Optimization of PNotP"))
unsigned getNumOperands() const
void RemoveOperand(unsigned i)
void ChangeToImmediate(int64_t ImmVal)
bundle_iterator< MachineInstr, instr_iterator > iterator
initializer< Ty > init(const Ty &Val)
const MCRegisterClass & getRegClass(unsigned i) const
Returns the register class associated with the enumeration value. See class MCOperandInfo.
const MachineOperand & getOperand(unsigned i) const
void setImm(int64_t immVal)
unsigned getSubReg() const
void initializeHexagonPeepholePass(PassRegistry &)
void setDesc(const MCInstrDesc &tid)
void addOperand(MachineFunction &MF, const MachineOperand &Op)
static cl::opt< bool > DisableOptSZExt("disable-hexagon-optszext", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Optimization of Sign/Zero Extends"))
FunctionPass * createHexagonPeephole()
MachineOperandType getType() const
static cl::opt< bool > DisableHexagonPeephole("disable-hexagon-peephole", cl::Hidden, cl::ZeroOrMore, cl::init(false), cl::desc("Disable Peephole Optimization"))
virtual void getAnalysisUsage(AnalysisUsage &AU) const
void setReg(unsigned Reg)
unsigned getReg() const
getReg - Returns the register number.
ValueT lookup(const KeyT &Val) const
BasicBlockListType::iterator iterator
const MCRegisterInfo & MRI
iterator find(const KeyT &Val)