27 #define GET_INSTRINFO_CTOR_DTOR 28 #include "LanaiGenInstrInfo.inc" 39 bool KillSource)
const {
40 if (!Lanai::GPRRegClass.
contains(DestinationRegister, SourceRegister)) {
44 BuildMI(MBB, Position, DL,
get(Lanai::OR_I_LO), DestinationRegister)
51 unsigned SourceRegister,
bool IsKill,
int FrameIndex,
55 if (Position != MBB.
end()) {
56 DL = Position->getDebugLoc();
59 if (!Lanai::GPRRegClass.hasSubClassEq(RegisterClass)) {
62 BuildMI(MBB, Position, DL,
get(Lanai::SW_RI))
75 if (Position != MBB.
end()) {
76 DL = Position->getDebugLoc();
79 if (!Lanai::GPRRegClass.hasSubClassEq(RegisterClass)) {
82 BuildMI(MBB, Position, DL,
get(Lanai::LDW_RI), DestinationRegister)
104 int64_t OffsetA = 0, OffsetB = 0;
105 unsigned int WidthA = 0, WidthB = 0;
109 int LowOffset = std::min(OffsetA, OffsetB);
110 int HighOffset =
std::max(OffsetA, OffsetB);
111 int LowWidth = (LowOffset == OffsetA) ? WidthA : WidthB;
112 if (LowOffset + LowWidth <= HighOffset)
162 std::pair<unsigned, unsigned>
164 return std::make_pair(TF, 0u);
169 using namespace LanaiII;
170 static const std::pair<unsigned, const char *> TargetFlags[] = {
178 unsigned &SrcReg2,
int &CmpMask,
179 int &CmpValue)
const {
183 case Lanai::SFSUB_F_RI_LO:
184 case Lanai::SFSUB_F_RI_HI:
190 case Lanai::SFSUB_F_RR:
206 unsigned SrcReg2,
int ImmValue,
208 if (CmpI->
getOpcode() == Lanai::SFSUB_F_RR &&
216 if (((CmpI->
getOpcode() == Lanai::SFSUB_F_RI_LO &&
218 (CmpI->
getOpcode() == Lanai::SFSUB_F_RI_HI &&
228 case Lanai::ADD_I_HI:
229 return Lanai::ADD_F_I_HI;
230 case Lanai::ADD_I_LO:
231 return Lanai::ADD_F_I_LO;
233 return Lanai::ADD_F_R;
234 case Lanai::ADDC_I_HI:
235 return Lanai::ADDC_F_I_HI;
236 case Lanai::ADDC_I_LO:
237 return Lanai::ADDC_F_I_LO;
239 return Lanai::ADDC_F_R;
240 case Lanai::AND_I_HI:
241 return Lanai::AND_F_I_HI;
242 case Lanai::AND_I_LO:
243 return Lanai::AND_F_I_LO;
245 return Lanai::AND_F_R;
247 return Lanai::OR_F_I_HI;
249 return Lanai::OR_F_I_LO;
251 return Lanai::OR_F_R;
253 return Lanai::SL_F_I;
255 return Lanai::SRL_F_R;
257 return Lanai::SA_F_I;
259 return Lanai::SRA_F_R;
260 case Lanai::SUB_I_HI:
261 return Lanai::SUB_F_I_HI;
262 case Lanai::SUB_I_LO:
263 return Lanai::SUB_F_I_LO;
265 return Lanai::SUB_F_R;
266 case Lanai::SUBB_I_HI:
267 return Lanai::SUBB_F_I_HI;
268 case Lanai::SUBB_I_LO:
269 return Lanai::SUBB_F_I_LO;
271 return Lanai::SUBB_F_R;
272 case Lanai::XOR_I_HI:
273 return Lanai::XOR_F_I_HI;
274 case Lanai::XOR_I_LO:
275 return Lanai::XOR_F_I_LO;
277 return Lanai::XOR_F_R;
284 MachineInstr &CmpInstr,
unsigned SrcReg,
unsigned SrcReg2,
int ,
311 if (CmpInstr.
getOpcode() == Lanai::SFSUB_F_RI_LO)
320 for (--I; I !=
E; --
I) {
355 while (!isSafe && ++I != E) {
357 for (
unsigned IO = 0, EO = Instr.
getNumOperands(); !isSafe && IO != EO;
385 std::make_pair(&((*I).getOperand(IO - 1)), NewCC));
424 if ((*SI)->isLiveIn(Lanai::SR))
440 unsigned &TrueOp,
unsigned &FalseOp,
441 bool &Optimizable)
const {
486 bool DontMoveAcrossStores =
true;
499 bool Invert = !
DefMI;
509 if (!MRI.constrainRegClass(DestReg, PreviousClass))
518 for (
unsigned i = 1,
e = DefDesc.getNumOperands();
519 i !=
e && !DefDesc.OpInfo[i].isPredicate(); ++i)
538 SeenMIs.
erase(DefMI);
566 bool AllowModify)
const {
572 while (Instruction != MBB.
begin()) {
576 if (Instruction->isDebugInstr())
581 if (!isUnpredicatedTerminator(*Instruction))
586 if (!Instruction->isBranch())
590 if (Instruction->getOpcode() ==
Lanai::BT) {
592 TrueBlock = Instruction->getOperand(0).getMBB();
597 while (std::next(Instruction) != MBB.
end()) {
598 std::next(Instruction)->eraseFromParent();
602 FalseBlock =
nullptr;
607 Instruction->eraseFromParent();
608 Instruction = MBB.
end();
613 TrueBlock = Instruction->getOperand(0).getMBB();
618 unsigned Opcode = Instruction->getOpcode();
619 if (Opcode != Lanai::BRCC)
624 if (Condition.
empty()) {
629 FalseBlock = TrueBlock;
630 TrueBlock = Instruction->getOperand(0).getMBB();
649 "Lanai branch conditions should have one component.");
665 int *BytesAdded)
const {
667 assert(TrueBlock &&
"insertBranch must not be told to insert a fallthrough");
668 assert(!BytesAdded &&
"code size not handled");
671 if (Condition.
empty()) {
672 assert(!FalseBlock &&
"Unconditional branch with multiple successors!");
679 "Lanai branch conditions should have one component.");
680 unsigned ConditionalCode = Condition[0].getImm();
693 int *BytesRemoved)
const {
694 assert(!BytesRemoved &&
"code size not handled");
699 while (Instruction != MBB.
begin()) {
701 if (Instruction->isDebugInstr())
703 if (Instruction->getOpcode() !=
Lanai::BT &&
704 Instruction->getOpcode() != Lanai::BRCC) {
709 Instruction->eraseFromParent();
710 Instruction = MBB.
end();
736 if (hasLoadFromStackSlot(MI, Accesses)){
738 cast<FixedStackPseudoSourceValue>(Accesses.
front()->getPseudoValue())
792 if (!BaseOp->
isReg())
bool isRegMask() const
isRegMask - Tests if this is a MO_RegisterMask operand.
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, unsigned SourceRegister, bool IsKill, int FrameIndex, const TargetRegisterClass *RegisterClass, const TargetRegisterInfo *RegisterInfo) const override
const MachineInstrBuilder & add(const MachineOperand &MO) const
Wrapper class representing physical registers. Should be passed by value.
This class represents lattice values for constants.
void push_back(const T &Elt)
const DebugLoc & getDebugLoc() const
Returns the debug location id of this MachineInstr.
static bool isPhysicalRegister(unsigned Reg)
Return true if the specified register number is in the physical register namespace.
Describe properties that are true of each instruction in the target description file.
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TrueBlock, MachineBasicBlock *&FalseBlock, SmallVectorImpl< MachineOperand > &Condition, bool AllowModify) const override
bool isPredicable(QueryType Type=AllInBundle) const
Return true if this instruction has a predicate operand that controls execution.
bool mayLoadOrStore(QueryType Type=AnyInBundle) const
Return true if this instruction could possibly read or modify memory.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
unsigned const TargetRegisterInfo * TRI
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
return AArch64::GPR64RegClass contains(Reg)
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
void clearKillInfo()
Clears kill flags on all operands.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, const DebugLoc &DL, MCRegister DestinationRegister, MCRegister SourceRegister, bool KillSource) const override
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
unsigned getNumOperands() const
Retuns the total number of operands.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void setImplicit(bool Val=true)
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
bool expandPostRAPseudo(MachineInstr &MI) const override
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
static bool isRedundantFlagInstr(MachineInstr *CmpI, unsigned SrcReg, unsigned SrcReg2, int ImmValue, MachineInstr *OI)
Position
Position to insert a new instruction relative to an existing instruction.
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
MachineInstr * getVRegDef(unsigned Reg) const
getVRegDef - Return the machine instr that defines the specified virtual register or null if none is ...
MachineInstr * optimizeSelect(MachineInstr &MI, SmallPtrSetImpl< MachineInstr *> &SeenMIs, bool PreferFalse) const override
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Condition) const override
const MCInstrDesc & getDesc() const
Returns the target instruction descriptor of this MachineInstr.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
unsigned getKillRegState(bool B)
bool isIdenticalTo(const MachineOperand &Other) const
Returns true if this operand is identical to the specified operand except for liveness related flags ...
MachineInstrBuilder BuildMI(MachineFunction &MF, const DebugLoc &DL, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
unsigned const MachineRegisterInfo * MRI
size_t size() const
size - Get the array size.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
bool analyzeSelect(const MachineInstr &MI, SmallVectorImpl< MachineOperand > &Cond, unsigned &TrueOp, unsigned &FalseOp, bool &Optimizable) const override
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
ArrayRef< std::pair< unsigned, const char * > > getSerializableDirectMachineOperandTargetFlags() const override
std::pair< unsigned, unsigned > decomposeMachineOperandsTargetFlags(unsigned TF) const override
const MachineInstrBuilder & addFrameIndex(int Idx) const
succ_iterator succ_begin()
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool readsRegister(Register Reg, const TargetRegisterInfo *TRI=nullptr) const
Return true if the MachineInstr reads the specified register.
bool isJTI() const
isJTI - Tests if this is a MO_JumpTableIndex operand.
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
Align max(MaybeAlign Lhs, Align Rhs)
bool erase(PtrType Ptr)
erase - If the set contains the specified pointer, remove it and return true, otherwise return false...
static LPCC::CondCode getOppositeCondition(LPCC::CondCode CC)
MachineOperand class - Representation of each machine instruction operand.
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator Position, unsigned DestinationRegister, int FrameIndex, const TargetRegisterClass *RegisterClass, const TargetRegisterInfo *RegisterInfo) const override
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TrueBlock, MachineBasicBlock *FalseBlock, ArrayRef< MachineOperand > Condition, const DebugLoc &DL, int *BytesAdded=nullptr) const override
MachineInstrBuilder MachineInstrBuilder & DefMI
bool modifiesRegister(Register Reg, const TargetRegisterInfo *TRI) const
Return true if the MachineInstr modifies (fully define or partially define) the specified register...
bool hasOrderedMemoryRef() const
Return true if this instruction may have an ordered or volatile memory reference, or if the informati...
unsigned isLoadFromStackSlotPostFE(const MachineInstr &MI, int &FrameIndex) const override
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
Return true if the specified MBB will be emitted immediately after this block, such that if this bloc...
bool optimizeCompareInstr(MachineInstr &CmpInstr, unsigned SrcReg, unsigned SrcReg2, int CmpMask, int CmpValue, const MachineRegisterInfo *MRI) const override
MachineInstr * getUniqueVRegDef(unsigned Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
static bool clobbersPhysReg(const uint32_t *RegMask, unsigned PhysReg)
clobbersPhysReg - Returns true if this RegMask clobbers PhysReg.
Select(COND, TRUEVAL, FALSEVAL).
const MachineInstrBuilder & copyImplicitOps(const MachineInstr &OtherMI) const
Copy all the implicit operands from OtherMI onto this one.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
static MachineInstr * canFoldIntoSelect(unsigned Reg, const MachineRegisterInfo &MRI)
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
static unsigned flagSettingOpcodeVariant(unsigned OldOpcode)
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
LLVM_NODISCARD bool empty() const
static MachineOperand CreateImm(int64_t Val)
bool areMemAccessesTriviallyDisjoint(const MachineInstr &MIa, const MachineInstr &MIb) const override
bool isFI() const
isFI - Tests if this is a MO_FrameIndex operand.
virtual const LanaiRegisterInfo & getRegisterInfo() const
bool hasOneNonDBGUse(unsigned RegNo) const
hasOneNonDBGUse - Return true if there is exactly one non-Debug use of the specified register...
bool isReg() const
isReg - Tests if this is a MO_Register operand.
bool analyzeCompare(const MachineInstr &MI, unsigned &SrcReg, unsigned &SrcReg2, int &CmpMask, int &CmpValue) const override
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isSafeToMove(AAResults *AA, bool &SawStore) const
Return true if it is safe to move this instruction.
void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
static bool isVirtualRegister(unsigned Reg)
Return true if the specified register number is in the virtual register namespace.
bool hasUnmodeledSideEffects() const
Return true if this instruction has side effects that are not modeled by mayLoad / mayStore...
bool getMemOperandWithOffsetWidth(const MachineInstr &LdSt, const MachineOperand *&BaseOp, int64_t &Offset, unsigned &Width, const TargetRegisterInfo *TRI) const
Register getReg() const
getReg - Returns the register number.
const MachineOperand & getOperand(unsigned i) const
const MachineInstrBuilder & addReg(Register RegNo, unsigned flags=0, unsigned SubReg=0) const
Add a new virtual register operand.
std::vector< MachineBasicBlock * >::iterator succ_iterator
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.
bool getMemOperandWithOffset(const MachineInstr &LdSt, const MachineOperand *&BaseOp, int64_t &Offset, const TargetRegisterInfo *TRI) const override
void tieOperands(unsigned DefIdx, unsigned UseIdx)
Add a tie between the register operands at DefIdx and UseIdx.