26#define GET_INSTRINFO_CTOR_DTOR
27#include "LanaiGenInstrInfo.inc"
31 Lanai::ADJCALLSTACKUP),
38 Register SourceRegister,
bool KillSource,
39 bool RenamableDest,
bool RenamableSrc)
const {
40 if (!Lanai::GPRRegClass.
contains(DestinationRegister, SourceRegister)) {
51 Register SourceRegister,
bool IsKill,
int FrameIndex,
55 if (Position !=
MBB.end()) {
56 DL = Position->getDebugLoc();
59 if (!Lanai::GPRRegClass.hasSubClassEq(RegisterClass)) {
71 Register DestinationRegister,
int FrameIndex,
75 if (Position !=
MBB.end()) {
76 DL = Position->getDebugLoc();
79 if (!Lanai::GPRRegClass.hasSubClassEq(RegisterClass)) {
103 int64_t OffsetA = 0, OffsetB = 0;
109 int LowOffset = std::min(OffsetA, OffsetB);
110 int HighOffset = std::max(OffsetA, OffsetB);
111 LocationSize LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
113 LowOffset + (
int)LowWidth.
getValue() <= HighOffset)
163std::pair<unsigned, unsigned>
165 return std::make_pair(TF, 0u);
171 static const std::pair<unsigned, const char *> TargetFlags[] = {
172 {MO_ABS_HI,
"lanai-hi"},
173 {MO_ABS_LO,
"lanai-lo"},
174 {MO_NO_FLAG,
"lanai-nf"}};
179 Register &SrcReg2, int64_t &CmpMask,
180 int64_t &CmpValue)
const {
181 switch (
MI.getOpcode()) {
184 case Lanai::SFSUB_F_RI_LO:
185 case Lanai::SFSUB_F_RI_HI:
186 SrcReg =
MI.getOperand(0).getReg();
189 CmpValue =
MI.getOperand(1).getImm();
191 case Lanai::SFSUB_F_RR:
192 SrcReg =
MI.getOperand(0).getReg();
193 SrcReg2 =
MI.getOperand(1).getReg();
207 unsigned SrcReg2, int64_t ImmValue,
209 if (CmpI->
getOpcode() == Lanai::SFSUB_F_RR &&
217 if (((CmpI->
getOpcode() == Lanai::SFSUB_F_RI_LO &&
219 (CmpI->
getOpcode() == Lanai::SFSUB_F_RI_HI &&
229 case Lanai::ADD_I_HI:
230 return Lanai::ADD_F_I_HI;
231 case Lanai::ADD_I_LO:
232 return Lanai::ADD_F_I_LO;
234 return Lanai::ADD_F_R;
235 case Lanai::ADDC_I_HI:
236 return Lanai::ADDC_F_I_HI;
237 case Lanai::ADDC_I_LO:
238 return Lanai::ADDC_F_I_LO;
240 return Lanai::ADDC_F_R;
241 case Lanai::AND_I_HI:
242 return Lanai::AND_F_I_HI;
243 case Lanai::AND_I_LO:
244 return Lanai::AND_F_I_LO;
246 return Lanai::AND_F_R;
248 return Lanai::OR_F_I_HI;
250 return Lanai::OR_F_I_LO;
252 return Lanai::OR_F_R;
254 return Lanai::SL_F_I;
256 return Lanai::SRL_F_R;
258 return Lanai::SA_F_I;
260 return Lanai::SRA_F_R;
261 case Lanai::SUB_I_HI:
262 return Lanai::SUB_F_I_HI;
263 case Lanai::SUB_I_LO:
264 return Lanai::SUB_F_I_LO;
266 return Lanai::SUB_F_R;
267 case Lanai::SUBB_I_HI:
268 return Lanai::SUBB_F_I_HI;
269 case Lanai::SUBB_I_LO:
270 return Lanai::SUBB_F_I_LO;
272 return Lanai::SUBB_F_R;
273 case Lanai::XOR_I_HI:
274 return Lanai::XOR_F_I_HI;
275 case Lanai::XOR_I_LO:
276 return Lanai::XOR_F_I_LO;
278 return Lanai::XOR_F_R;
286 int64_t , int64_t CmpValue,
309 else if (
MI->getParent() != CmpInstr.
getParent() || CmpValue != 0) {
313 if (CmpInstr.
getOpcode() == Lanai::SFSUB_F_RI_LO)
322 for (--
I;
I != E; --
I) {
325 if (Instr.modifiesRegister(Lanai::SR,
TRI) ||
326 Instr.readsRegister(Lanai::SR,
TRI))
357 while (!isSafe && ++
I != E) {
359 for (
unsigned IO = 0, EO = Instr.getNumOperands(); !isSafe && IO != EO;
384 if (SrcReg2 != 0 &&
Sub->getOperand(1).getReg() == SrcReg2 &&
385 Sub->getOperand(2).getReg() == SrcReg) {
387 std::make_pair(&((*I).getOperand(IO - 1)), NewCC));
424 if (Succ->isLiveIn(Lanai::SR))
430 MI->addRegisterDefined(Lanai::SR);
442 if (!
Reg.isVirtual())
450 if (!
MI->isPredicable())
456 if (MO.isFI() || MO.isCPI() || MO.isJTI())
463 if (MO.getReg().isPhysical())
465 if (MO.isDef() && !MO.isDead())
468 bool DontMoveAcrossStores =
true;
469 if (!
MI->isSafeToMove(DontMoveAcrossStores))
478 assert(
MI.getOpcode() == Lanai::SELECT &&
"unknown select instruction");
481 bool Invert = !
DefMI;
501 i != e && !DefDesc.
operands()[i].isPredicate(); ++i)
504 unsigned CondCode =
MI.getOperand(3).getImm();
526 if (
DefMI->getParent() !=
MI.getParent())
530 DefMI->eraseFromParent();
548 bool AllowModify)
const {
582 FalseBlock =
nullptr;
599 if (Opcode != Lanai::BRCC)
604 if (Condition.
empty()) {
609 FalseBlock = TrueBlock;
629 "Lanai branch conditions should have one component.");
645 int *BytesAdded)
const {
647 assert(TrueBlock &&
"insertBranch must not be told to insert a fallthrough");
648 assert(!BytesAdded &&
"code size not handled");
651 if (Condition.
empty()) {
652 assert(!FalseBlock &&
"Unconditional branch with multiple successors!");
659 "Lanai branch conditions should have one component.");
660 unsigned ConditionalCode = Condition[0].getImm();
673 int *BytesRemoved)
const {
674 assert(!BytesRemoved &&
"code size not handled");
698 int &FrameIndex)
const {
699 if (
MI.getOpcode() == Lanai::LDW_RI)
700 if (
MI.getOperand(1).isFI() &&
MI.getOperand(2).isImm() &&
701 MI.getOperand(2).getImm() == 0) {
702 FrameIndex =
MI.getOperand(1).getIndex();
703 return MI.getOperand(0).getReg();
709 int &FrameIndex)
const {
710 if (
MI.getOpcode() == Lanai::LDW_RI) {
727 int &FrameIndex)
const {
728 if (
MI.getOpcode() == Lanai::SW_RI)
729 if (
MI.getOperand(0).isFI() &&
MI.getOperand(1).isImm() &&
730 MI.getOperand(1).getImm() == 0) {
731 FrameIndex =
MI.getOperand(0).getIndex();
732 return MI.getOperand(2).getReg();
773 if (!BaseOp->
isReg())
795 OffsetIsScalable =
false;
MachineInstrBuilder MachineInstrBuilder & DefMI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static bool isRedundantFlagInstr(const MachineInstr *CmpI, Register SrcReg, Register SrcReg2, int64_t ImmValue, const MachineInstr *OI, bool &IsThumb1)
isRedundantFlagInstr - check whether the first instruction, whose only purpose is to update flags,...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
DXIL Forward Handle Accesses
static LPCC::CondCode getOppositeCondition(LPCC::CondCode CC)
static unsigned flagSettingOpcodeVariant(unsigned OldOpcode)
static MachineInstr * canFoldIntoSelect(Register Reg, const MachineRegisterInfo &MRI)
Register const TargetRegisterInfo * TRI
Promote Memory to Register
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
This file defines the SmallVector class.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
size_t size() const
Get the array size.
bool empty() const
Check if the array is empty.
LLVM_ABI InstListType::iterator eraseFromParent()
This method unlinks 'this' from the containing basic block and deletes it.
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock, MachineBasicBlock *FalseBlock, ArrayRef< MachineOperand > Condition, const DebugLoc &DL, int *BytesAdded=nullptr) const override
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool getMemOperandsWithOffsetWidth(const MachineInstr &LdSt, SmallVectorImpl< const MachineOperand * > &BaseOps, int64_t &Offset, bool &OffsetIsScalable, LocationSize &Width) const override
Register isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TrueBlock, MachineBasicBlock *&FalseBlock, SmallVectorImpl< MachineOperand > &Condition, bool AllowModify) const override
virtual const LanaiRegisterInfo & getRegisterInfo() const
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr * > &SeenMIs, bool PreferFalse) const override
bool expandPostRAPseudo(MachineInstr &MI) const override
LanaiInstrInfo(const LanaiSubtarget &STI)
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, Register SourceRegister, bool IsKill, int FrameIndex, const TargetRegisterClass *RegisterClass, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool optimizeCompareInstr(MachineInstr &CmpInstr, Register SrcReg, Register SrcReg2, int64_t CmpMask, int64_t CmpValue, const MachineRegisterInfo *MRI) const override
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, Register DestinationRegister, int FrameIndex, const TargetRegisterClass *RegisterClass, Register VReg, unsigned SubReg=0, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
bool analyzeCompare(const MachineInstr &MI, Register &SrcReg, Register &SrcReg2, int64_t &CmpMask, int64_t &CmpValue) const override
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
bool getMemOperandWithOffsetWidth(const MachineInstr &LdSt, const MachineOperand *&BaseOp, int64_t &Offset, LocationSize &Width) const
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Condition) const override
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, const DebugLoc &DL, Register DestinationRegister, Register SourceRegister, bool KillSource, bool RenamableDest=false, bool RenamableSrc=false) const override
static LocationSize precise(uint64_t Value)
TypeSize getValue() const
Describe properties that are true of each instruction in the target description file.
unsigned getNumOperands() const
Return the number of declared MachineOperands for this MachineInstruction.
ArrayRef< MCOperandInfo > operands() const
MachineInstrBundleIterator< MachineInstr > iterator
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 & add(const MachineOperand &MO) const
const MachineInstrBuilder & addFrameIndex(int Idx) const
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
Representation of each machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
const MachineBasicBlock * getParent() const
unsigned getNumOperands() const
Retuns the total number of operands.
LLVM_ABI bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore,...
LLVM_ABI void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.
LLVM_ABI bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
const MachineOperand & getOperand(unsigned i) const
LLVM_ABI void clearKillInfo()
Clears kill flags on all operands.
LLVM_ABI MachineInstrBundleIterator< MachineInstr > eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
MachineOperand class - Representation of each machine instruction operand.
void setImplicit(bool Val=true)
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
static MachineOperand CreateImm(int64_t Val)
Register getReg() const
getReg - Returns the register number.
LLVM_ABI bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
static bool clobbersPhysReg(const uint32_t *RegMask, MCRegister PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
LLVM_ABI bool hasOneNonDBGUse(Register RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register.
const TargetRegisterClass * getRegClass(Register Reg) const
Return the register class of the specified virtual register.
LLVM_ABI LLVM_READONLY MachineInstr * getVRegDef(Register Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
LLVM_ABI const TargetRegisterClass * constrainRegClass(Register Reg, const TargetRegisterClass *RC, unsigned MinNumRegs=0)
constrainRegClass - Constrain the register class of the specified virtual register to be a common sub...
LLVM_ABI LLVM_READONLY MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
Wrapper class representing virtual and physical registers.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool erase(PtrType Ptr)
Remove pointer from the set.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
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.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
Value * getOperand(unsigned i) const
#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.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
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)
MachineInstr * getImm(const MachineOperand &MO, const MachineRegisterInfo *MRI)
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
@ Sub
Subtraction of integers.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
ArrayRef(const T &OneElt) -> ArrayRef< T >
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
MCRegisterClass TargetRegisterClass