30 #define GET_INSTRINFO_CTOR_DTOR 31 #include "XCoreGenInstrInfo.inc" 46 void XCoreInstrInfo::anchor() {}
65 if (Opcode == XCore::LDWFI)
85 if (Opcode == XCore::STWFI)
101 static inline bool IsBRU(
unsigned BrOpc) {
102 return BrOpc == XCore::BRFU_u6
103 || BrOpc == XCore::BRFU_lu6
104 || BrOpc == XCore::BRBU_u6
105 || BrOpc == XCore::BRBU_lu6;
108 static inline bool IsBRT(
unsigned BrOpc) {
109 return BrOpc == XCore::BRFT_ru6
110 || BrOpc == XCore::BRFT_lru6
111 || BrOpc == XCore::BRBT_ru6
112 || BrOpc == XCore::BRBT_lru6;
115 static inline bool IsBRF(
unsigned BrOpc) {
116 return BrOpc == XCore::BRFF_ru6
117 || BrOpc == XCore::BRFF_lru6
118 || BrOpc == XCore::BRBF_ru6
119 || BrOpc == XCore::BRBF_lru6;
137 }
else if (
IsBRF(BrOpc)) {
193 bool AllowModify)
const {
199 if (!isUnpredicatedTerminator(*I))
206 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
229 if (SecondLastInst && I != MBB.
begin() && isUnpredicatedTerminator(*--I))
232 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
255 I->eraseFromParent();
263 I->eraseFromParent();
276 int *BytesAdded)
const {
278 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
280 "Unexpected number of components!");
281 assert(!BytesAdded &&
"code size not handled");
297 assert(Cond.
size() == 2 &&
"Unexpected number of components!");
307 assert(!BytesRemoved &&
"code size not handled");
317 I->eraseFromParent();
321 if (I == MBB.
begin())
return 1;
327 I->eraseFromParent();
335 bool GRDest = XCore::GRRegsRegClass.contains(DestReg);
336 bool GRSrc = XCore::GRRegsRegClass.contains(SrcReg);
338 if (GRDest && GRSrc) {
339 BuildMI(MBB, I, DL,
get(XCore::ADD_2rus), DestReg)
345 if (GRDest && SrcReg == XCore::SP) {
346 BuildMI(MBB, I, DL,
get(XCore::LDAWSP_ru6), DestReg).
addImm(0);
350 if (DestReg == XCore::SP && GRSrc) {
351 BuildMI(MBB, I, DL,
get(XCore::SETSP_1r))
360 unsigned SrcReg,
bool isKill,
366 if (I != MBB.
end() && !I->isDebugInstr())
367 DL = I->getDebugLoc();
374 BuildMI(MBB, I, DL,
get(XCore::STWFI))
388 if (I != MBB.
end() && !I->isDebugInstr())
389 DL = I->getDebugLoc();
396 BuildMI(MBB, I, DL,
get(XCore::LDWFI), DestReg)
405 "Invalid XCore branch condition!");
411 return val < (1 << 6);
415 return val < (1 << 16);
423 return (N >= 1 && N <= 8) || N == 16 || N == 24 || N == 32;
429 unsigned Reg, uint64_t
Value)
const {
431 if (MI != MBB.
end() && !MI->isDebugInstr())
432 dl = MI->getDebugLoc();
435 return BuildMI(MBB, MI, dl,
get(XCore::MKMSK_rus), Reg)
440 int Opcode =
isImmU6(Value) ? XCore::LDC_ru6 : XCore::LDC_lru6;
447 return BuildMI(MBB, MI, dl,
get(XCore::LDWCP_lru6), Reg)
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
static bool IsBRT(unsigned BrOpc)
Wrapper class representing physical registers. Should be passed by value.
MachineBasicBlock * getMBB() const
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot...
This class represents lattice values for constants.
static bool isImmMskBitp(unsigned val)
void push_back(const T &Elt)
unsigned const TargetRegisterInfo * TRI
static XCore::CondCode GetOppositeBranchCondition(XCore::CondCode CC)
GetOppositeBranchCondition - Return the inverse of the specified condition, e.g.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
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...
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
A description of a memory reference used in the backend.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
static bool IsBRF(unsigned BrOpc)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
The MachineFrameInfo class represents an abstract stack frame until prolog/epilog code is inserted...
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
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 MachineInstrBuilder & addConstantPoolIndex(unsigned Idx, int Offset=0, unsigned TargetFlags=0) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
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 IsBRU(unsigned BrOpc)
static bool isImmU16(unsigned val)
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getKillRegState(bool B)
MachineBasicBlock::iterator loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned Reg, uint64_t Value) const
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.
static bool isImmU6(unsigned val)
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const MachineInstrBuilder & addFrameIndex(int Idx) const
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function. ...
static unsigned GetCondBranchFromCond(XCore::CondCode CC)
GetCondBranchFromCond - Return the Branch instruction opcode that matches the cc. ...
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
The memory access writes data.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineOperand class - Representation of each machine instruction operand.
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...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
static Constant * get(Type *Ty, uint64_t V, bool isSigned=false)
If Ty is a vector type, return a Constant with a splat of the given value.
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot...
const Function & getFunction() const
Return the LLVM function that this machine code represents.
unsigned Log2_32(uint32_t Value)
Return the floor log base 2 of the specified value, -1 if the value is zero.
static bool IsCondBranch(unsigned BrOpc)
static unsigned getReg(const void *D, unsigned RC, unsigned RegNo)
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.
BR_JT - Jumptable branch.
Representation of each machine instruction.
static XCore::CondCode GetCondFromBranchOpc(unsigned BrOpc)
GetCondFromBranchOpc - Return the XCore CC that matches the correspondent Branch instruction opcode...
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static IntegerType * getInt32Ty(LLVMContext &C)
static MachineOperand CreateImm(int64_t Val)
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
static bool IsBR_JT(unsigned BrOpc)
static bool isZeroImm(const MachineOperand &op)
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
unsigned getConstantPoolIndex(const Constant *C, unsigned Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one...
bool empty() const
empty - Check if the array is empty.