26 #define GET_INSTRINFO_CTOR_DTOR 27 #include "ARCGenInstrInfo.inc" 29 #define DEBUG_TYPE "arc-inst-info" 44 void ARCInstrInfo::anchor() {}
54 return Opcode == ARC::LD_rs9 || Opcode == ARC::LDH_rs9 ||
55 Opcode == ARC::LDB_rs9;
59 return Opcode == ARC::ST_rs9 || Opcode == ARC::STH_rs9 ||
60 Opcode == ARC::STB_rs9;
140 return Opc == ARC::BRcc_rr_p || Opc == ARC::BRcc_ru6_p;
174 bool AllowModify)
const {
177 if (I == MBB.
begin())
181 while (
isPredicated(*I) || I->isTerminator() || I->isDebugValue()) {
185 bool CantAnalyze =
false;
188 while (I->isDebugInstr() || !I->isTerminator()) {
189 if (I == MBB.
begin())
199 TBB = I->getOperand(0).getMBB();
205 assert(!FBB &&
"FBB should have been null.");
207 TBB = I->getOperand(0).getMBB();
211 }
else if (I->isReturn()) {
232 while (DI != MBB.
end()) {
243 if (I == MBB.
begin())
255 int *BytesRemoved)
const {
256 assert(!BytesRemoved &&
"Code size not handled");
266 I->eraseFromParent();
270 if (I == MBB.
begin())
277 I->eraseFromParent();
286 "Only GPR32 src copy supported.");
288 "Only GPR32 dest copy supported.");
289 BuildMI(MBB, I, dl,
get(ARC::MOV_rr), DestReg)
295 unsigned SrcReg,
bool isKill,
308 assert(MMO &&
"Couldn't get MachineMemOperand for store to stack.");
310 "Only support 4-byte stores to stack now.");
311 assert(ARC::GPR32RegClass.hasSubClassEq(RC) &&
312 "Only support GPR32 stores to stack now.");
314 <<
" to FrameIndex=" << FrameIndex <<
"\n");
315 BuildMI(MBB, I, dl,
get(ARC::ST_rs9))
335 assert(MMO &&
"Couldn't get MachineMemOperand for store to stack.");
337 "Only support 4-byte loads from stack now.");
338 assert(ARC::GPR32RegClass.hasSubClassEq(RC) &&
339 "Only support GPR32 stores to stack now.");
341 <<
" from FrameIndex=" << FrameIndex <<
"\n");
342 BuildMI(MBB, I, dl,
get(ARC::LD_rs9))
352 assert((Cond.
size() == 3) &&
"Invalid ARC branch condition!");
360 uint64_t
Value)
const {
362 if (isInt<12>(Value)) {
363 return BuildMI(MBB, MI, dl,
get(ARC::MOV_rs12), Reg)
374 const DebugLoc &dl,
int *BytesAdded)
const {
375 assert(!BytesAdded &&
"Code size not handled.");
378 assert(TBB &&
"InsertBranch must not be told to insert a fallthrough");
380 "ARC branch conditions have two components!");
386 int BccOpc = Cond[1].isImm() ? ARC::BRcc_ru6_p : ARC::BRcc_rr_p;
389 for (
unsigned i = 0; i < 3; i++) {
426 unsigned &OffsetPos)
const {
const MachineInstrBuilder & add(const MachineOperand &MO) const
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
Wrapper class representing physical registers. Should be passed by value.
This class represents lattice values for constants.
virtual bool getBaseAndOffsetPosition(const MachineInstr &MI, unsigned &BasePos, unsigned &OffsetPos) const override
void push_back(const T &Elt)
Describe properties that are true of each instruction in the target description file.
unsigned const TargetRegisterInfo * TRI
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &dl, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.
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
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) 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.
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.
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.
bool mayStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly modify memory.
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
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.
bool isPostIncrement(const MachineInstr &MI) const override
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 LLVMTargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool mayLoad(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read memory.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
bool isPreIncrement(const MachineInstr &MI) const
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
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
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...