28 #define GET_INSTRINFO_CTOR_DTOR 29 #include "SparcGenInstrInfo.inc" 32 void SparcInstrInfo::anchor() {}
146 return Opc == SP::FBCOND || Opc == SP::BCOND;
150 return Opc == SP::BINDrr || Opc == SP::BINDri;
163 bool AllowModify)
const {
168 if (!isUnpredicatedTerminator(*I))
173 unsigned LastOpc = LastInst->
getOpcode();
176 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
191 unsigned SecondLastOpc = SecondLastInst->
getOpcode();
198 LastInst = SecondLastInst;
200 if (I == MBB.
begin() || !isUnpredicatedTerminator(*--I)) {
205 SecondLastInst = &*
I;
206 SecondLastOpc = SecondLastInst->
getOpcode();
212 if (SecondLastInst && I != MBB.
begin() && isUnpredicatedTerminator(*--I))
234 I->eraseFromParent();
247 int *BytesAdded)
const {
248 assert(TBB &&
"insertBranch must not be told to insert a fallthrough");
250 "Sparc branch conditions should have one component!");
251 assert(!BytesAdded &&
"code size not handled");
254 assert(!FBB &&
"Unconditional branch with multiple successors!");
260 unsigned CC = Cond[0].getImm();
274 int *BytesRemoved)
const {
275 assert(!BytesRemoved &&
"code size not handled");
279 while (I != MBB.
begin()) {
282 if (I->isDebugInstr())
285 if (I->getOpcode() != SP::BA
286 && I->getOpcode() != SP::BCOND
287 && I->getOpcode() != SP::FBCOND)
290 I->eraseFromParent();
309 unsigned numSubRegs = 0;
311 const unsigned *subRegIdx =
nullptr;
312 bool ExtraG0 =
false;
314 const unsigned DW_SubRegsIdx[] = { SP::sub_even, SP::sub_odd };
315 const unsigned DFP_FP_SubRegsIdx[] = { SP::sub_even, SP::sub_odd };
316 const unsigned QFP_DFP_SubRegsIdx[] = { SP::sub_even64, SP::sub_odd64 };
317 const unsigned QFP_FP_SubRegsIdx[] = { SP::sub_even, SP::sub_odd,
318 SP::sub_odd64_then_sub_even,
319 SP::sub_odd64_then_sub_odd };
321 if (SP::IntRegsRegClass.
contains(DestReg, SrcReg))
324 else if (SP::IntPairRegClass.
contains(DestReg, SrcReg)) {
325 subRegIdx = DW_SubRegsIdx;
329 }
else if (SP::FPRegsRegClass.
contains(DestReg, SrcReg))
330 BuildMI(MBB, I, DL,
get(SP::FMOVS), DestReg)
332 else if (SP::DFPRegsRegClass.
contains(DestReg, SrcReg)) {
333 if (Subtarget.
isV9()) {
334 BuildMI(MBB, I, DL,
get(SP::FMOVD), DestReg)
338 subRegIdx = DFP_FP_SubRegsIdx;
342 }
else if (SP::QFPRegsRegClass.
contains(DestReg, SrcReg)) {
343 if (Subtarget.
isV9()) {
345 BuildMI(MBB, I, DL,
get(SP::FMOVQ), DestReg)
349 subRegIdx = QFP_DFP_SubRegsIdx;
355 subRegIdx = QFP_FP_SubRegsIdx;
359 }
else if (SP::ASRRegsRegClass.
contains(DestReg) &&
360 SP::IntRegsRegClass.
contains(SrcReg)) {
361 BuildMI(MBB, I, DL,
get(SP::WRASRrr), DestReg)
364 }
else if (SP::IntRegsRegClass.
contains(DestReg) &&
365 SP::ASRRegsRegClass.
contains(SrcReg)) {
366 BuildMI(MBB, I, DL,
get(SP::RDASR), DestReg)
371 if (numSubRegs == 0 || subRegIdx ==
nullptr || movOpc == 0)
377 for (
unsigned i = 0; i != numSubRegs; ++i) {
380 assert(Dst && Src &&
"Bad sub-register");
396 unsigned SrcReg,
bool isKill,
int FI,
400 if (I != MBB.
end()) DL = I->getDebugLoc();
409 if (RC == &SP::I64RegsRegClass)
412 else if (RC == &SP::IntRegsRegClass)
415 else if (RC == &SP::IntPairRegClass)
418 else if (RC == &SP::FPRegsRegClass)
421 else if (SP::DFPRegsRegClass.hasSubClassEq(RC))
424 else if (SP::QFPRegsRegClass.hasSubClassEq(RC))
435 unsigned DestReg,
int FI,
439 if (I != MBB.
end()) DL = I->getDebugLoc();
447 if (RC == &SP::I64RegsRegClass)
450 else if (RC == &SP::IntRegsRegClass)
453 else if (RC == &SP::IntPairRegClass)
456 else if (RC == &SP::FPRegsRegClass)
459 else if (SP::DFPRegsRegClass.hasSubClassEq(RC))
462 else if (SP::QFPRegsRegClass.hasSubClassEq(RC))
475 if (GlobalBaseReg != 0)
484 Subtarget.
is64Bit() ? &SP::I64RegsRegClass : &SP::IntRegsRegClass;
489 BuildMI(FirstMBB, MBBI, dl,
get(SP::GETPCX), GlobalBaseReg);
496 case TargetOpcode::LOAD_STACK_GUARD: {
498 "Only Linux target is expected to contain LOAD_STACK_GUARD");
Wrapper class representing physical registers. Should be passed by value.
MachineBasicBlock * getMBB() const
bool expandPostRAPseudo(MachineInstr &MI) const override
This class represents lattice values for constants.
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, MCRegister DestReg, MCRegister SrcReg, bool KillSrc) const override
Register createVirtualRegister(const TargetRegisterClass *RegClass, StringRef Name="")
createVirtualRegister - Create and return a new virtual register in the function with the specified r...
void push_back(const T &Elt)
unsigned const TargetRegisterInfo * TRI
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
const MachineInstrBuilder & addMBB(MachineBasicBlock *MBB, unsigned TargetFlags=0) const
return AArch64::GPR64RegClass contains(Reg)
GlobalBaseReg - On Darwin, this node represents the result of the mflr at function entry...
bool isTargetLinux() const
A description of a memory reference used in the backend.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
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.
static bool IsIntegerCC(unsigned CC)
bool addRegisterKilled(Register IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
Register getSubReg(MCRegister Reg, unsigned Idx) const
Returns the physical register number of sub-register "Index" for physical register RegNo...
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().
int64_t getObjectSize(int ObjectIdx) const
Return the size of the specified object.
unsigned getKillRegState(bool B)
static bool isCondBranchOpcode(int Opc)
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.
unsigned getGlobalBaseReg(MachineFunction *MF) const
MachineFrameInfo & getFrameInfo()
getFrameInfo - Return the frame info object for the current function.
size_t size() const
size - Get the array size.
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
const SparcRegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
const MachineInstrBuilder & addFrameIndex(int Idx) const
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
const MachineBasicBlock & front() const
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
The memory access writes data.
static bool isIndirectBranchOpcode(int Opc)
static bool isUncondBranchOpcode(int Opc)
void loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, unsigned DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI) const override
void setDesc(const MCInstrDesc &tid)
Replace the instruction descriptor (thus opcode) of the current instruction with a new one...
unsigned isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot...
const MachineInstrBuilder & addMemOperand(MachineMemOperand *MMO) const
void setGlobalBaseReg(unsigned Reg)
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly. ...
Target - Wrapper for Target specific information.
const MachineBasicBlock * getParent() const
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
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.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
static SPCC::CondCodes GetOppositeBranchCondition(SPCC::CondCodes CC)
const MachineInstrBuilder & addImm(int64_t Val) const
Add a new immediate operand.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
SparcInstrInfo(SparcSubtarget &ST)
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())
unsigned getGlobalBaseReg() const
void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
unsigned isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot...
Wrapper class representing virtual and physical registers.
bool empty() const
empty - Check if the array is empty.