24#define GET_INSTRINFO_CTOR_DTOR
25#include "BPFGenInstrInfo.inc"
36 bool RenamableDest,
bool RenamableSrc)
const {
37 if (BPF::GPRRegClass.
contains(DestReg, SrcReg))
40 else if (BPF::GPR32RegClass.
contains(DestReg, SrcReg))
51 uint64_t Alignment =
MI->getOperand(3).getImm();
52 Register ScratchReg =
MI->getOperand(4).getReg();
55 unsigned LdOpc, StOpc;
78 unsigned IterationNum = CopyLen >>
Log2_64(Alignment);
79 for(
unsigned I = 0;
I < IterationNum; ++
I) {
88 unsigned BytesLeft = CopyLen & (Alignment - 1);
89 unsigned Offset = IterationNum * Alignment;
90 bool Hanging4Byte = BytesLeft & 0x4;
91 bool Hanging2Byte = BytesLeft & 0x2;
92 bool Hanging1Byte = BytesLeft & 0x1;
118 if (
MI.getOpcode() == BPF::MEMCPY) {
128 Register SrcReg,
bool IsKill,
int FI,
134 DL =
I->getDebugLoc();
136 if (RC == &BPF::GPRRegClass)
141 else if (RC == &BPF::GPR32RegClass)
158 DL =
I->getDebugLoc();
160 if (RC == &BPF::GPRRegClass)
162 else if (RC == &BPF::GPR32RegClass)
172 bool AllowModify)
const {
176 while (
I !=
MBB.begin()) {
178 if (
I->isDebugInstr())
183 if (!isUnpredicatedTerminator(*
I))
188 if (
I->isIndirectBranch())
197 if (
I->getOpcode() == BPF::JMP) {
199 TBB =
I->getOperand(0).getMBB();
204 MBB.erase(std::next(
I),
MBB.end());
209 if (
MBB.isLayoutSuccessor(
I->getOperand(0).getMBB())) {
211 I->eraseFromParent();
217 TBB =
I->getOperand(0).getMBB();
232 int *BytesAdded)
const {
233 assert(!BytesAdded &&
"code size not handled");
236 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
240 assert(!FBB &&
"Unconditional branch with multiple successors!");
249 int *BytesRemoved)
const {
250 assert(!BytesRemoved &&
"code size not handled");
255 while (
I !=
MBB.begin()) {
257 if (
I->isDebugInstr())
259 if (
I->getOpcode() != BPF::JMP)
262 I->eraseFromParent();
271 if (
MI.getOpcode() != BPF::JX)
283 if (!Reg.isVirtual())
286 if (Ldd ==
nullptr || Ldd->
getOpcode() != BPF::LDD)
290 if (!Reg.isVirtual())
293 if (
Add ==
nullptr ||
Add->getOpcode() != BPF::ADD_rr)
296 Reg =
Add->getOperand(1).getReg();
297 if (!Reg.isVirtual())
300 if (LDimm64 ==
nullptr || LDimm64->
getOpcode() != BPF::LD_imm64)
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallVector class.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
int getJumpTableIndex(const MachineInstr &MI) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
BPFInstrInfo(const BPFSubtarget &STI)
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
LLVM_ABI instr_iterator erase(instr_iterator I)
Remove an instruction from the instruction list and delete it.
MachineInstrBundleIterator< MachineInstr > iterator
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
MachineOperand class - Representation of each machine instruction operand.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
Register getReg() const
getReg - Returns the register number.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ Define
Register definition.
@ Kill
The last use of a register.
This is an optimization pass for GlobalISel generic memory operations.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned Log2_64(uint64_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
FunctionAddr VTableAddr Count
unsigned getKillRegState(bool B)