33 #define DEBUG_TYPE "bpf-mi-zext-elim" 35 STATISTIC(ZExtElemNum,
"Number of zero extension shifts eliminated");
55 bool eliminateZExtSeq(
void);
66 return eliminateZExtSeq();
88 if (DefInsn->
isPHI()) {
89 for (
unsigned i = 1, e = DefInsn->
getNumOperands(); i < e; i += 2) {
97 if (!PhiDef || PhiDef->
isPHI() || PhiDef->
getOpcode() == BPF::COPY)
119 bool BPFMIPeephole::eliminateZExtSeq(
void) {
121 bool Eliminated =
false;
136 if (
MI.getOpcode() == BPF::SRL_ri &&
137 MI.getOperand(2).getImm() == 32) {
138 unsigned DstReg =
MI.getOperand(0).getReg();
139 unsigned ShfReg =
MI.getOperand(1).getReg();
157 MovMI->getOpcode() != BPF::MOV_32_64)
163 unsigned SubReg = MovMI->getOperand(1).getReg();
164 if (!isMovFrom32Def(MovMI)) {
166 <<
" One ZExt elim sequence failed qualifying elim.\n");
170 BuildMI(MBB,
MI,
MI.getDebugLoc(), TII->get(BPF::SUBREG_TO_REG), DstReg)
174 MovMI->eraseFromParent();
190 "BPF MachineSSA Peephole Optimization",
false,
false)
192 char BPFMIPeephole::ID = 0;
195 STATISTIC(RedundantMovElemNum,
"Number of redundant moves eliminated");
213 bool eliminateRedundantMov(
void);
224 return eliminateRedundantMov();
235 bool BPFMIPreEmitPeephole::eliminateRedundantMov(
void) {
237 bool Eliminated =
false;
257 if (
MI.getOpcode() == BPF::MOV_32_64) {
258 unsigned dst =
MI.getOperand(0).getReg();
259 unsigned dst_sub = TRI->
getSubReg(dst, BPF::sub_32);
260 unsigned src =
MI.getOperand(1).getReg();
266 RedundantMovElemNum++;
278 "BPF PreEmit Peephole Optimization",
false,
false)
280 char BPFMIPreEmitPeephole::ID = 0;
283 return new BPFMIPreEmitPeephole();
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
void initializeBPFMIPeepholePass(PassRegistry &)
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
This class represents lattice values for constants.
FunctionPass * createBPFMIPreEmitPeepholePass()
void initializeBPFMIPreEmitPeepholePass(PassRegistry &)
unsigned getReg() const
getReg - Returns the register number.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
STATISTIC(NumFunctions, "Total number of functions")
unsigned const TargetRegisterInfo * TRI
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const HexagonInstrInfo * TII
unsigned getNumOperands() const
Retuns the total number of operands.
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
unsigned getSubReg(unsigned Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
FunctionPass class - This class is used to implement most global optimizations.
FunctionPass * createBPFMIPeepholePass()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
MachineOperand class - Representation of each machine instruction operand.
const Function & getFunction() const
Return the LLVM function that this machine code represents.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
static void initialize(TargetLibraryInfoImpl &TLI, const Triple &T, ArrayRef< StringRef > StandardNames)
Initialize the set of available library functions based on the specified target triple.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
const MachineOperand & getOperand(unsigned i) const