26#define GET_INSTRINFO_CTOR_DTOR
27#include "XCoreGenInstrInfo.inc"
42void XCoreInstrInfo::anchor() {}
49 return op.isImm() &&
op.getImm() == 0;
58 int &FrameIndex)
const {
59 int Opcode =
MI.getOpcode();
60 if (Opcode == XCore::LDWFI)
62 if ((
MI.getOperand(1).isFI()) &&
63 (
MI.getOperand(2).isImm()) &&
65 FrameIndex =
MI.getOperand(1).getIndex();
66 return MI.getOperand(0).getReg();
78 int &FrameIndex)
const {
79 int Opcode =
MI.getOpcode();
80 if (Opcode == XCore::STWFI)
82 if ((
MI.getOperand(1).isFI()) &&
83 (
MI.getOperand(2).isImm()) &&
85 FrameIndex =
MI.getOperand(1).getIndex();
86 return MI.getOperand(0).getReg();
96static inline bool IsBRU(
unsigned BrOpc) {
97 return BrOpc == XCore::BRFU_u6
98 || BrOpc == XCore::BRFU_lu6
99 || BrOpc == XCore::BRBU_u6
100 || BrOpc == XCore::BRBU_lu6;
103static inline bool IsBRT(
unsigned BrOpc) {
104 return BrOpc == XCore::BRFT_ru6
105 || BrOpc == XCore::BRFT_lru6
106 || BrOpc == XCore::BRBT_ru6
107 || BrOpc == XCore::BRBT_lru6;
110static inline bool IsBRF(
unsigned BrOpc) {
111 return BrOpc == XCore::BRFF_ru6
112 || BrOpc == XCore::BRFF_lru6
113 || BrOpc == XCore::BRBF_ru6
114 || BrOpc == XCore::BRBF_lru6;
122 return BrOpc == XCore::BR_JT
123 || BrOpc == XCore::BR_JT32;
132 }
else if (
IsBRF(BrOpc)) {
188 bool AllowModify)
const {
194 if (!isUnpredicatedTerminator(*
I))
201 if (
I ==
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
224 if (SecondLastInst &&
I !=
MBB.begin() && isUnpredicatedTerminator(*--
I))
227 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
250 I->eraseFromParent();
258 I->eraseFromParent();
271 int *BytesAdded)
const {
273 assert(
TBB &&
"insertBranch must not be told to insert a fallthrough");
275 "Unexpected number of components!");
276 assert(!BytesAdded &&
"code size not handled");
292 assert(
Cond.size() == 2 &&
"Unexpected number of components!");
302 assert(!BytesRemoved &&
"code size not handled");
312 I->eraseFromParent();
316 if (
I ==
MBB.begin())
return 1;
322 I->eraseFromParent();
330 bool RenamableDest,
bool RenamableSrc)
const {
331 bool GRDest = XCore::GRRegsRegClass.contains(DestReg);
332 bool GRSrc = XCore::GRRegsRegClass.contains(SrcReg);
334 if (GRDest && GRSrc) {
341 if (GRDest && SrcReg == XCore::SP) {
346 if (DestReg == XCore::SP && GRSrc) {
360 if (
I !=
MBB.end() && !
I->isDebugInstr())
361 DL =
I->getDebugLoc();
382 if (
I !=
MBB.end() && !
I->isDebugInstr())
383 DL =
I->getDebugLoc();
399 "Invalid XCore branch condition!");
405 return val < (1 << 6);
409 return val < (1 << 16);
417 return (
N >= 1 &&
N <= 8) ||
N == 16 ||
N == 24 ||
N == 32;
423 unsigned Reg, uint64_t
Value)
const {
425 if (
MI !=
MBB.end() && !
MI->isDebugInstr())
426 dl =
MI->getDebugLoc();
434 int Opcode =
isImmU6(
Value) ? XCore::LDC_ru6 : XCore::LDC_lru6;
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isZeroImm(const MachineOperand &Op)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
SmallVector< MachineOperand, 4 > Cond
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
static MCRegister getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
static SPCC::CondCodes GetOppositeBranchCondition(SPCC::CondCodes CC)
static bool isImmU16(unsigned val)
static bool isImmU6(unsigned val)
static XCore::CondCode GetCondFromBranchOpc(unsigned BrOpc)
GetCondFromBranchOpc - Return the XCore CC that matches the correspondent Branch instruction opcode.
static bool IsBRU(unsigned BrOpc)
static bool IsBR_JT(unsigned BrOpc)
static bool isImmMskBitp(unsigned val)
static bool IsBRT(unsigned BrOpc)
static bool IsBRF(unsigned BrOpc)
static bool IsCondBranch(unsigned BrOpc)
static unsigned GetCondBranchFromCond(XCore::CondCode CC)
GetCondBranchFromCond - Return the Branch instruction opcode that matches the cc.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
MachineInstrBundleIterator< MachineInstr > iterator
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted.
Align getObjectAlign(int ObjectIdx) const
Return the alignment of the specified stack object.
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags F, LLT MemTy, Align BaseAlignment, const MMOMetadata &Metadata=MMOMetadata(), SyncScope::ID SSID=SyncScope::System, AtomicOrdering Ordering=AtomicOrdering::NotAtomic, AtomicOrdering FailureOrdering=AtomicOrdering::NotAtomic)
getMachineMemOperand - Allocate a new MachineMemOperand.
const MachineInstrBuilder & addReg(Register RegNo, RegState Flags={}, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineOperand & getOperand(unsigned i) const
A description of a memory reference used in the backend.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getMBB() const
static MachineOperand CreateImm(int64_t Val)
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
analyzeBranch - Analyze the branching code at the end of MBB, returning true if it cannot be understo...
MachineBasicBlock::iterator loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Reg, uint64_t Value) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot,...
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot,...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
XCoreInstrInfo(const XCoreSubtarget &ST)
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) 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
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
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.
constexpr RegState getKillRegState(bool B)
constexpr bool isMask_32(uint32_t Value)
Return true if the argument is a non-empty sequence of ones starting at the least significant bit wit...
int bit_width(T Value)
Returns the number of bits needed to represent Value if Value is nonzero.
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
MCRegisterClass TargetRegisterClass
This struct is a compact representation of a valid (non-zero power of two) alignment.
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.