25 #define GET_INSTRINFO_CTOR_DTOR
26 #include "XCoreGenInstrInfo.inc"
44 void XCoreInstrInfo::anchor() {}
63 if (Opcode == XCore::LDWFI)
85 if (Opcode == XCore::STWFI)
102 static inline bool IsBRU(
unsigned BrOpc) {
103 return BrOpc == XCore::BRFU_u6
104 || BrOpc == XCore::BRFU_lu6
105 || BrOpc == XCore::BRBU_u6
106 || BrOpc == XCore::BRBU_lu6;
109 static inline bool IsBRT(
unsigned BrOpc) {
110 return BrOpc == XCore::BRFT_ru6
111 || BrOpc == XCore::BRFT_lru6
112 || BrOpc == XCore::BRBT_ru6
113 || BrOpc == XCore::BRBT_lru6;
116 static inline bool IsBRF(
unsigned BrOpc) {
117 return BrOpc == XCore::BRFF_ru6
118 || BrOpc == XCore::BRFF_lru6
119 || BrOpc == XCore::BRBF_ru6
120 || BrOpc == XCore::BRBF_lru6;
138 }
else if (
IsBRF(BrOpc)) {
194 bool AllowModify)
const {
197 if (I == MBB.
begin())
200 while (I->isDebugValue()) {
201 if (I == MBB.
begin())
205 if (!isUnpredicatedTerminator(I))
212 if (I == MBB.
begin() || !isUnpredicatedTerminator(--I)) {
235 if (SecondLastInst && I != MBB.
begin() &&
236 isUnpredicatedTerminator(--I))
239 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
284 assert(TBB &&
"InsertBranch must not be told to insert a fallthrough");
285 assert((Cond.
size() == 2 || Cond.
size() == 0) &&
286 "Unexpected number of components!");
302 assert(Cond.
size() == 2 &&
"Unexpected number of components!");
313 if (I == MBB.
begin())
return 0;
315 while (I->isDebugValue()) {
316 if (I == MBB.
begin())
324 I->eraseFromParent();
328 if (I == MBB.
begin())
return 1;
334 I->eraseFromParent();
340 unsigned DestReg,
unsigned SrcReg,
341 bool KillSrc)
const {
342 bool GRDest = XCore::GRRegsRegClass.contains(DestReg);
343 bool GRSrc = XCore::GRRegsRegClass.contains(SrcReg);
345 if (GRDest && GRSrc) {
346 BuildMI(MBB, I, DL,
get(XCore::ADD_2rus), DestReg)
352 if (GRDest && SrcReg == XCore::SP) {
353 BuildMI(MBB, I, DL,
get(XCore::LDAWSP_ru6), DestReg).
addImm(0);
357 if (DestReg == XCore::SP && GRSrc) {
358 BuildMI(MBB, I, DL,
get(XCore::SETSP_1r))
367 unsigned SrcReg,
bool isKill,
373 if (I != MBB.
end()) DL = I->getDebugLoc();
374 BuildMI(MBB, I, DL,
get(XCore::STWFI))
387 if (I != MBB.
end()) DL = I->getDebugLoc();
388 BuildMI(MBB, I, DL,
get(XCore::LDWFI), DestReg)
397 assert((Cond.
size() == 2) &&
398 "Invalid XCore branch condition!");
void push_back(const T &Elt)
static bool IsBRT(unsigned BrOpc)
MachineBasicBlock * getMBB() const
static XCore::CondCode GetOppositeBranchCondition(XCore::CondCode CC)
virtual void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
static bool IsBRF(unsigned BrOpc)
const MachineInstrBuilder & addImm(int64_t Val) const
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
bool LLVM_ATTRIBUTE_UNUSED_RESULT empty() const
static bool IsBRU(unsigned BrOpc)
unsigned getKillRegState(bool B)
bundle_iterator< MachineInstr, instr_iterator > iterator
const MachineOperand & getOperand(unsigned i) const
MachineInstrBuilder BuildMI(MachineFunction &MF, DebugLoc DL, const MCInstrDesc &MCID)
static unsigned GetCondBranchFromCond(XCore::CondCode CC)
virtual bool ReverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
virtual void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const
static bool IsCondBranch(unsigned BrOpc)
virtual unsigned RemoveBranch(MachineBasicBlock &MBB) const
static XCore::CondCode GetCondFromBranchOpc(unsigned BrOpc)
virtual unsigned InsertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, const SmallVectorImpl< MachineOperand > &Cond, DebugLoc DL) const
virtual bool AnalyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const
static MachineOperand CreateImm(int64_t Val)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
unsigned getReg() const
getReg - Returns the register number.
virtual unsigned isLoadFromStackSlot(const MachineInstr *MI, int &FrameIndex) const
virtual void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, DebugLoc DL, unsigned DestReg, unsigned SrcReg, bool KillSrc) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned char TargetFlags=0) const
virtual unsigned isStoreToStackSlot(const MachineInstr *MI, int &FrameIndex) const
const MachineInstrBuilder & addReg(unsigned RegNo, unsigned flags=0, unsigned SubReg=0) const
static bool IsBR_JT(unsigned BrOpc)
static bool isZeroImm(const MachineOperand &op)