25#define GET_INSTRINFO_CTOR_DTOR
26#include "XtensaGenInstrInfo.inc"
55 int &FrameIndex)
const {
56 if (
MI.getOpcode() == Xtensa::L32I) {
57 if (
MI.getOperand(1).isFI() &&
MI.getOperand(2).isImm() &&
58 MI.getOperand(2).getImm() == 0) {
59 FrameIndex =
MI.getOperand(1).getIndex();
60 return MI.getOperand(0).getReg();
67 int &FrameIndex)
const {
68 if (
MI.getOpcode() == Xtensa::S32I) {
69 if (
MI.getOperand(1).isFI() &&
MI.getOperand(2).isImm() &&
70 MI.getOperand(2).getImm() == 0) {
71 FrameIndex =
MI.getOperand(1).getIndex();
72 return MI.getOperand(0).getReg();
93 if (isInt<8>(Amount)) {
112 bool RenamableDest,
bool RenamableSrc)
const {
115 if (Xtensa::ARRegClass.
contains(DestReg, SrcReg))
128 unsigned LoadOpcode, StoreOpcode;
142 unsigned LoadOpcode, StoreOpcode;
148 unsigned &LoadOpcode,
149 unsigned &StoreOpcode,
150 int64_t offset)
const {
151 assert((RC == &Xtensa::ARRegClass) &&
152 "Unsupported regclass to load or store");
154 LoadOpcode = Xtensa::L32I;
155 StoreOpcode = Xtensa::S32I;
160 unsigned *Reg, int64_t
Value)
const {
169 }
else if (
Value >= -32768 &&
Value <= 32767) {
175 }
else if (
Value >= -4294967296LL &&
Value <= 4294967295LL) {
179 const Constant *CVal = ConstantInt::get(
193 switch (
MI.getOpcode()) {
194 case TargetOpcode::INLINEASM: {
196 const char *AsmStr =
MI.getOperand(0).getSymbolName();
200 return MI.getDesc().getSize();
206 assert(
Cond.size() <= 4 &&
"Invalid branch condition!");
208 switch (
Cond[0].getImm()) {
210 Cond[0].setImm(Xtensa::BNE);
213 Cond[0].setImm(Xtensa::BEQ);
216 Cond[0].setImm(Xtensa::BGE);
219 Cond[0].setImm(Xtensa::BLT);
222 Cond[0].setImm(Xtensa::BGEU);
225 Cond[0].setImm(Xtensa::BLTU);
228 Cond[0].setImm(Xtensa::BNEI);
231 Cond[0].setImm(Xtensa::BEQI);
234 Cond[0].setImm(Xtensa::BLTI);
237 Cond[0].setImm(Xtensa::BGEI);
240 Cond[0].setImm(Xtensa::BLTUI);
243 Cond[0].setImm(Xtensa::BGEUI);
246 Cond[0].setImm(Xtensa::BNEZ);
249 Cond[0].setImm(Xtensa::BEQZ);
252 Cond[0].setImm(Xtensa::BGEZ);
255 Cond[0].setImm(Xtensa::BLTZ);
264 unsigned OpCode =
MI.getOpcode();
270 return MI.getOperand(0).getMBB();
277 return MI.getOperand(2).getMBB();
284 return MI.getOperand(2).getMBB();
289 return MI.getOperand(1).getMBB();
296 int64_t BrOffset)
const {
300 return isIntN(18, BrOffset);
318 return isIntN(8, BrOffset);
324 return isIntN(12, BrOffset);
334 bool AllowModify =
false)
const {
342 if (
I->isDebugValue())
347 if (!isUnpredicatedTerminator(*
I))
359 if (!ThisTarget->
isMBB())
362 if (ThisCond[0].getImm() == Xtensa::J) {
370 while (std::next(
I) !=
MBB.
end())
389 for (
unsigned int i = 0; i < (
I->getNumExplicitOperands() - 1); i++)
390 Cond.push_back(
I->getOperand(i));
405 unsigned OldCond =
Cond[0].getImm();
406 if (OldCond == ThisCond[0].getImm())
414 int *BytesRemoved)
const {
433 I->eraseFromParent();
467 assert(RS &&
"RegScavenger required for long branching");
469 "new block should be inserted for expanding unconditional branch");
478 if (!isInt<32>(BrOffset))
480 "Branch offsets outside of the signed 32-bit range not supported");
482 Register ScratchReg =
MRI.createVirtualRegister(&Xtensa::ARRegClass);
495 if (ScavRegister != Xtensa::NoRegister)
500 ScavRegister = Xtensa::A12;
502 int FrameIndex = XtensaFI->getBranchRelaxationScratchFrameIndex();
503 if (FrameIndex == -1)
505 "Unable to properly handle scavenged register for indirect jump, "
506 "function code size is significantly larger than estimated");
509 &Xtensa::ARRegClass, &RI,
Register());
514 &Xtensa::ARRegClass, &RI,
Register());
517 JumpToMBB = &RestoreBB;
525 MRI.replaceRegWith(ScratchReg, ScavRegister);
533 "Xtensa branch conditions have less than four components!");
535 if (
Cond.empty() || (
Cond[0].getImm() == Xtensa::J)) {
538 if (BytesAdded &&
MI)
544 unsigned BR_C =
Cond[0].getImm();
578 if (BytesAdded &&
MI)
589 int *BytesAdded)
const {
591 assert(
TBB &&
"InsertBranch must not be told to insert a fallthrough");
593 "Xtensa branch conditions have less than four components!");
595 if (
Cond.empty() || (
Cond[0].getImm() == Xtensa::J)) {
598 if (BytesAdded &&
MI)
604 unsigned BR_C =
Cond[0].getImm();
638 if (BytesAdded &&
MI)
647 unsigned OpCode =
MI->getOpcode();
652 Cond[0].setImm(OpCode);
661 Cond[0].setImm(OpCode);
671 Cond[0].setImm(OpCode);
679 Cond[0].setImm(OpCode);
684 assert(!
MI->getDesc().isBranch() &&
"Unknown branch opcode");
unsigned const MachineRegisterInfo * MRI
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
MachineBasicBlock MachineBasicBlock::iterator MBBI
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
unsigned const TargetRegisterInfo * TRI
static unsigned getReg(const MCDisassembler *D, unsigned RC, unsigned RegNo)
uint64_t IntrinsicInst * II
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
const SmallVectorImpl< MachineOperand > & Cond
This file declares the machine register scavenger class.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
This is an important base class in LLVM.
LLVMContext & getContext() const
getContext - Return a reference to the LLVMContext associated with this function.
Describe properties that are true of each instruction in the target description file.
bool mayStore() const
Return true if this instruction could possibly modify memory.
bool mayLoad() const
Return true if this instruction could possibly read memory.
Wrapper class representing physical registers. Should be passed by value.
unsigned pred_size() const
void eraseFromParent()
This method unlinks 'this' from the containing function and deletes it.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
The MachineConstantPool class keeps track of constants referenced by a function which must be spilled...
unsigned getConstantPoolIndex(const Constant *C, Align Alignment)
getConstantPoolIndex - Create a new entry in the constant pool or return an existing one.
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.
MachineMemOperand * getMachineMemOperand(MachinePointerInfo PtrInfo, MachineMemOperand::Flags f, LLT MemTy, Align 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.
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Function & getFunction()
Return the LLVM function that this machine code represents.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
MachineConstantPool * getConstantPool()
getConstantPool - Return the constant pool object for the current function.
const TargetMachine & getTarget() const
getTarget - Return the target machine this machine code is compiled with
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 & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
Representation of each machine instruction.
void addOperand(MachineFunction &MF, const MachineOperand &Op)
Add the specified operand to the instruction.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ 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)
static MachineOperand CreateCPI(unsigned Idx, int Offset, unsigned TargetFlags=0)
bool isMBB() const
isMBB - Tests if this is a MO_MachineBasicBlock operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void enterBasicBlockEnd(MachineBasicBlock &MBB)
Start tracking liveness from the end of basic block MBB.
void setRegUsed(Register Reg, LaneBitmask LaneMask=LaneBitmask::getAll())
Tell the scavenger a register is used.
Register scavengeRegisterBackwards(const TargetRegisterClass &RC, MachineBasicBlock::iterator To, bool RestoreAfter, int SPAdj, bool AllowSpill=true)
Make a register of the specific register class available from the current position backwards to the p...
Wrapper class representing virtual and physical registers.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
const MCAsmInfo * getMCAsmInfo() const
Return target specific asm information.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Target - Wrapper for Target specific information.
static IntegerType * getInt32Ty(LLVMContext &C)
LLVM Value Representation.
static XtensaConstantPoolMBB * Create(LLVMContext &C, const MachineBasicBlock *M, unsigned ID)
XtensaConstantPoolValue - Xtensa specific constantpool value.
bool isBranch(const MachineBasicBlock::iterator &MI, SmallVectorImpl< MachineOperand > &Cond, const MachineOperand *&Target) const
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t BrOffset) const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
void loadImmediate(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned *Reg, int64_t Value) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
void insertIndirectBranch(MachineBasicBlock &MBB, MachineBasicBlock &DestBB, MachineBasicBlock &RestoreBB, const DebugLoc &DL, int64_t BrOffset=0, RegScavenger *RS=nullptr) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIdx, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
unsigned insertConstBranchAtInst(MachineBasicBlock &MBB, MachineInstr *I, int64_t offset, ArrayRef< MachineOperand > Cond, DebugLoc DL, int *BytesAdded) const
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
void adjustStackPtr(unsigned SP, int64_t Amount, MachineBasicBlock &MBB, MachineBasicBlock::iterator I) const
Adjust SP by Amount bytes.
unsigned insertBranchAtInst(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, MachineBasicBlock *TBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded) const
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
XtensaInstrInfo(const XtensaSubtarget &STI)
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify) const override
void getLoadStoreOpcodes(const TargetRegisterClass *RC, unsigned &LoadOpcode, unsigned &StoreOpcode, int64_t offset) const
bool eliminateFrameIndex(MachineBasicBlock::iterator MI, int SPAdj, unsigned FIOperandNum, RegScavenger *RS=nullptr) const override
self_iterator getIterator()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
@ Kill
The last use of a register.
This is an optimization pass for GlobalISel generic memory operations.
@ Low
Lower the current thread's priority such that it does not affect foreground tasks significantly.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static const MachineInstrBuilder & addFrameReference(const MachineInstrBuilder &MIB, int FI, int Offset=0, bool mem=true)
addFrameReference - This function is used to add a reference to the base of an abstract object on the...
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
unsigned getKillRegState(bool B)
bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
This struct is a compact representation of a valid (non-zero power of two) alignment.
static MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.