27 #define GET_INSTRINFO_CTOR_DTOR 28 #include "ARCGenInstrInfo.inc" 30 #define DEBUG_TYPE "arc-inst-info" 32 void ARCInstrInfo::anchor() {}
42 return Opcode == ARC::LD_rs9 || Opcode == ARC::LDH_rs9 ||
43 Opcode == ARC::LDB_rs9;
47 return Opcode == ARC::ST_rs9 || Opcode == ARC::STH_rs9 ||
48 Opcode == ARC::STB_rs9;
128 return Opc == ARC::BRcc_rr_p || Opc == ARC::BRcc_ru6_p;
162 bool AllowModify)
const {
165 if (I == MBB.
begin())
169 while (
isPredicated(*I) || I->isTerminator() || I->isDebugValue()) {
173 bool CantAnalyze =
false;
176 while (I->isDebugInstr() || !I->isTerminator()) {
177 if (I == MBB.
begin())
187 TBB = I->getOperand(0).getMBB();
193 assert(!FBB &&
"FBB should have been null.");
195 TBB = I->getOperand(0).getMBB();
199 }
else if (I->isReturn()) {
220 while (DI != MBB.
end()) {
231 if (I == MBB.
begin())
243 int *BytesRemoved)
const {
244 assert(!BytesRemoved &&
"Code size not handled");
254 I->eraseFromParent();
258 if (I == MBB.
begin())
265 I->eraseFromParent();
271 const DebugLoc &dl,
unsigned DestReg,
272 unsigned SrcReg,
bool KillSrc)
const {
274 "Only GPR32 src copy supported.");
276 "Only GPR32 dest copy supported.");
277 BuildMI(MBB, I, dl,
get(ARC::MOV_rr), DestReg)
283 unsigned SrcReg,
bool isKill,
296 assert(MMO &&
"Couldn't get MachineMemOperand for store to stack.");
298 "Only support 4-byte stores to stack now.");
299 assert(ARC::GPR32RegClass.hasSubClassEq(RC) &&
300 "Only support GPR32 stores to stack now.");
302 <<
" to FrameIndex=" << FrameIndex <<
"\n");
303 BuildMI(MBB, I, dl,
get(ARC::ST_rs9))
323 assert(MMO &&
"Couldn't get MachineMemOperand for store to stack.");
325 "Only support 4-byte loads from stack now.");
326 assert(ARC::GPR32RegClass.hasSubClassEq(RC) &&
327 "Only support GPR32 stores to stack now.");
329 <<
" from FrameIndex=" << FrameIndex <<
"\n");
330 BuildMI(MBB, I, dl,
get(ARC::LD_rs9))
340 assert((Cond.
size() == 3) &&
"Invalid ARC branch condition!");
348 uint64_t
Value)
const {
350 if (isInt<12>(Value)) {
351 return BuildMI(MBB, MI, dl,
get(ARC::MOV_rs12), Reg)
362 const DebugLoc &dl,
int *BytesAdded)
const {
363 assert(!BytesAdded &&
"Code size not handled.");
366 assert(TBB &&
"InsertBranch must not be told to insert a fallthrough");
368 "ARC branch conditions have two components!");
374 int BccOpc = Cond[1].isImm() ? ARC::BRcc_ru6_p : ARC::BRcc_rr_p;
377 for (
unsigned i = 0; i < 3; i++) {
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
This class represents lattice values for constants.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &dl, unsigned DestReg, unsigned SrcReg, bool KillSrc) const override
void push_back(const T &Elt)
unsigned getReg() const
getReg - Returns the register number.
unsigned const TargetRegisterInfo * TRI
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
MachineBasicBlock::iterator loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Reg, uint64_t Value) const
unsigned getSpillSize(const TargetRegisterClass &RC) const
Return the size in bytes of the stack slot allocated to hold a spilled copy of a register from class ...
return AArch64::GPR64RegClass contains(Reg)
A description of a memory reference used in the backend.
Printable printReg(unsigned Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
static bool isZeroImm(const MachineOperand &Op)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static bool isLoad(int Opcode)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const char * getSymbolName() const
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, uint64_t s, unsigned base_alignment, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
INLINEASM - Represents an inline asm block.
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
static bool isStore(int Opcode)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
iterator getLastNonDebugInstr()
Returns an iterator to the last non-debug instruction in the basic block, or end().
static bool isJumpOpcode(int Opc)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getKillRegState(bool B)
static ARCCC::CondCode GetOppositeBranchCondition(ARCCC::CondCode CC)
Return the inverse of passed condition, i.e. turning COND_E to COND_NE.
static bool isCondBranchOpcode(int Opc)
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
unsigned getObjectAlignment(int ObjectIdx) const
Return the alignment of the specified stack object.
Control flow instructions. These all have token chains.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
DebugLoc findDebugLoc(instr_iterator MBBI)
Find the next valid DebugLoc starting at MBBI, skipping any DBG_VALUE and DBG_LABEL instructions...
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &dl, int *BytesAdded=nullptr) const override
const MachineInstrBuilder & addFrameIndex(int Idx) const
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
The memory access writes data.
static bool isUncondBranchOpcode(int Opc)
MachineOperand class - Representation of each machine instruction operand.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
If the specified machine instruction is a direct store to a stack slot, return the virtual or physica...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
Return the inverse opcode of the specified Branch instruction.
bool isPredicated(MCInstrInfo const &MCII, MCInst const &MCI)
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
Analyze the branching code at the end of MBB, returning true if it cannot be understood (e...
const MachineBasicBlock * getParent() const
The memory access reads data.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.
Representation of each machine instruction.
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
LLVM_NODISCARD bool empty() const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
const MachineOperand & getOperand(unsigned i) const
bool empty() const
empty - Check if the array is empty.
unsigned getSize() const
Return the number of bytes in the encoding of this instruction, or zero if the encoding size cannot b...
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
If the specified machine instruction is a direct load from a stack slot, return the virtual or physic...