26#define GET_INSTRINFO_CTOR_DTOR 
   27#include "SparcGenInstrInfo.inc" 
   31    cl::desc(
"Restrict range of BPcc/FBPfcc instructions (DEBUG)"));
 
   35                        cl::desc(
"Restrict range of BPr instructions (DEBUG)"));
 
   38void SparcInstrInfo::anchor() {}
 
   50                                             int &FrameIndex)
 const {
 
   51  if (
MI.getOpcode() == SP::LDri || 
MI.getOpcode() == SP::LDXri ||
 
   52      MI.getOpcode() == SP::LDFri || 
MI.getOpcode() == SP::LDDFri ||
 
   53      MI.getOpcode() == SP::LDQFri) {
 
   54    if (
MI.getOperand(1).isFI() && 
MI.getOperand(2).isImm() &&
 
   55        MI.getOperand(2).getImm() == 0) {
 
   56      FrameIndex = 
MI.getOperand(1).getIndex();
 
   57      return MI.getOperand(0).getReg();
 
 
   69                                            int &FrameIndex)
 const {
 
   70  if (
MI.getOpcode() == SP::STri || 
MI.getOpcode() == SP::STXri ||
 
   71      MI.getOpcode() == SP::STFri || 
MI.getOpcode() == SP::STDFri ||
 
   72      MI.getOpcode() == SP::STQFri) {
 
   73    if (
MI.getOperand(0).isFI() && 
MI.getOperand(1).isImm() &&
 
   74        MI.getOperand(1).getImm() == 0) {
 
   75      FrameIndex = 
MI.getOperand(0).getIndex();
 
   76      return MI.getOperand(2).getReg();
 
 
  162  return Opc == SP::BCOND || 
Opc == SP::BPICC || 
Opc == SP::BPICCA ||
 
  163         Opc == SP::BPICCNT || 
Opc == SP::BPICCANT;
 
 
  167  return Opc == SP::BPXCC || 
Opc == SP::BPXCCA || 
Opc == SP::BPXCCNT ||
 
 
  172  return Opc == SP::BPR || 
Opc == SP::BPRA || 
Opc == SP::BPRNT ||
 
 
  177  return Opc == SP::FBCOND || 
Opc == SP::FBCONDA || 
Opc == SP::FBCOND_V9 ||
 
  178         Opc == SP::FBCONDA_V9;
 
 
  187  return Opc == SP::BINDrr || 
Opc == SP::BINDri;
 
 
  212  switch (
MI.getOpcode()) {
 
  238      return MI.getOperand(0).getMBB();
 
 
  246                                   bool AllowModify)
 const {
 
  251  if (!isUnpredicatedTerminator(*
I))
 
  256  unsigned LastOpc = LastInst->
getOpcode();
 
  259  if (
I == 
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
 
  274  unsigned SecondLastOpc = SecondLastInst->
getOpcode();
 
  281      LastInst = SecondLastInst;
 
  283      if (
I == 
MBB.begin() || !isUnpredicatedTerminator(*--
I)) {
 
  288        SecondLastInst = &*
I;
 
  289        SecondLastOpc = SecondLastInst->
getOpcode();
 
  295  if (SecondLastInst && 
I != 
MBB.begin() && isUnpredicatedTerminator(*--
I))
 
  317      I->eraseFromParent();
 
 
  330                                      int *BytesAdded)
 const {
 
  331  assert(
TBB && 
"insertBranch must not be told to insert a fallthrough");
 
  333         "Sparc branch conditions should have at most three components!");
 
  336    assert(!FBB && 
"Unconditional branch with multiple successors!");
 
  344  unsigned Opc = 
Cond[0].getImm();
 
  345  unsigned CC = 
Cond[1].getImm();
 
 
  366                                      int *BytesRemoved)
 const {
 
  370  while (
I != 
MBB.begin()) {
 
  373    if (
I->isDebugInstr())
 
  381    I->eraseFromParent();
 
  387    *BytesRemoved = Removed;
 
 
  401  assert((
Offset & 0b11) == 0 && 
"Malformed branch offset");
 
 
  440                                 bool RenamableDest, 
bool RenamableSrc)
 const {
 
  441  unsigned numSubRegs = 0;
 
  443  const unsigned *subRegIdx = 
nullptr;
 
  444  bool ExtraG0 = 
false;
 
  446  const unsigned DW_SubRegsIdx[]  = { SP::sub_even, SP::sub_odd };
 
  447  const unsigned DFP_FP_SubRegsIdx[]  = { SP::sub_even, SP::sub_odd };
 
  448  const unsigned QFP_DFP_SubRegsIdx[] = { SP::sub_even64, SP::sub_odd64 };
 
  449  const unsigned QFP_FP_SubRegsIdx[]  = { SP::sub_even, SP::sub_odd,
 
  450                                          SP::sub_odd64_then_sub_even,
 
  451                                          SP::sub_odd64_then_sub_odd };
 
  453  if (SP::IntRegsRegClass.
contains(DestReg, SrcReg))
 
  456  else if (SP::IntPairRegClass.
contains(DestReg, SrcReg)) {
 
  457    subRegIdx  = DW_SubRegsIdx;
 
  461  } 
else if (SP::FPRegsRegClass.
contains(DestReg, SrcReg))
 
  464  else if (SP::DFPRegsRegClass.
contains(DestReg, SrcReg)) {
 
  465    if (Subtarget.isV9()) {
 
  470      subRegIdx  = DFP_FP_SubRegsIdx;
 
  474  } 
else if (SP::QFPRegsRegClass.
contains(DestReg, SrcReg)) {
 
  475    if (Subtarget.isV9()) {
 
  476      if (Subtarget.hasHardQuad()) {
 
  481        subRegIdx  = QFP_DFP_SubRegsIdx;
 
  487      subRegIdx  = QFP_FP_SubRegsIdx;
 
  491  } 
else if (SP::ASRRegsRegClass.
contains(DestReg) &&
 
  492             SP::IntRegsRegClass.
contains(SrcReg)) {
 
  496  } 
else if (SP::IntRegsRegClass.
contains(DestReg) &&
 
  497             SP::ASRRegsRegClass.
contains(SrcReg)) {
 
  503  if (numSubRegs == 0 || subRegIdx == 
nullptr || movOpc == 0)
 
  509  for (
unsigned i = 0; i != numSubRegs; ++i) {
 
  510    Register Dst = 
TRI->getSubReg(DestReg, subRegIdx[i]);
 
  511    Register Src = 
TRI->getSubReg(SrcReg, subRegIdx[i]);
 
  512    assert(Dst && Src && 
"Bad sub-register");
 
 
  528                                         Register SrcReg, 
bool isKill, 
int FI,
 
  534  if (
I != 
MBB.end()) 
DL = 
I->getDebugLoc();
 
  543  if (RC == &SP::I64RegsRegClass)
 
  546  else if (RC == &SP::IntRegsRegClass)
 
  549  else if (RC == &SP::IntPairRegClass)
 
  552  else if (RC == &SP::FPRegsRegClass)
 
  555  else if (SP::DFPRegsRegClass.hasSubClassEq(RC))
 
  558  else if (SP::QFPRegsRegClass.hasSubClassEq(RC))
 
 
  572  if (
I != 
MBB.end()) 
DL = 
I->getDebugLoc();
 
  580  if (RC == &SP::I64RegsRegClass)
 
  583  else if (RC == &SP::IntRegsRegClass)
 
  586  else if (RC == &SP::IntPairRegClass)
 
  589  else if (RC == &SP::FPRegsRegClass)
 
  592  else if (SP::DFPRegsRegClass.hasSubClassEq(RC))
 
  595  else if (SP::QFPRegsRegClass.hasSubClassEq(RC))
 
 
  608    return GlobalBaseReg;
 
  616    Subtarget.is64Bit() ? &SP::I64RegsRegClass : &SP::IntRegsRegClass;
 
  617  GlobalBaseReg = RegInfo.createVirtualRegister(PtrRC);
 
  623  return GlobalBaseReg;
 
 
  627  unsigned Opcode = 
MI.getOpcode();
 
  629  if (
MI.isInlineAsm()) {
 
  631    const char *AsmStr = 
MI.getOperand(0).getSymbolName();
 
  638  if (
MI.hasDelaySlot())
 
  639    return get(Opcode).getSize() * 2;
 
  640  return get(Opcode).getSize();
 
 
  644  switch (
MI.getOpcode()) {
 
  645  case TargetOpcode::LOAD_STACK_GUARD: {
 
  646    assert(Subtarget.getTargetTriple().isOSLinux() &&
 
  647           "Only Linux target is expected to contain LOAD_STACK_GUARD");
 
  649    const int64_t 
Offset = Subtarget.is64Bit() ? 0x28 : 0x14;
 
  650    MI.setDesc(
get(Subtarget.is64Bit() ? SP::LDXri : SP::LDri));
 
  657    assert(!Subtarget.isV9() &&
 
  658           "V8BAR should not be emitted on V9 processors!");
 
 
static void parseCondBranch(MachineInstr *LastInst, MachineBasicBlock *&Target, SmallVectorImpl< MachineOperand > &Cond)
 
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
 
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
 
MachineBasicBlock MachineBasicBlock::iterator MBBI
 
Register const TargetRegisterInfo * TRI
 
const SmallVectorImpl< MachineOperand > MachineBasicBlock * TBB
 
const SmallVectorImpl< MachineOperand > & Cond
 
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
 
This file defines the SmallVector class.
 
static bool isFCondBranchOpcode(int Opc)
 
static bool isRegCondBranchOpcode(int Opc)
 
static SPCC::CondCodes GetOppositeBranchCondition(SPCC::CondCodes CC)
 
static cl::opt< unsigned > BPrDisplacementBits("sparc-bpr-offset-bits", cl::Hidden, cl::init(16), cl::desc("Restrict range of BPr instructions (DEBUG)"))
 
static bool isI32CondBranchOpcode(int Opc)
 
static cl::opt< unsigned > BPccDisplacementBits("sparc-bpcc-offset-bits", cl::Hidden, cl::init(19), cl::desc("Restrict range of BPcc/FBPfcc instructions (DEBUG)"))
 
static bool isI64CondBranchOpcode(int Opc)
 
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
 
Helper class for constructing bundles of MachineInstrs.
 
MachineInstrBundleIterator< MachineInstr > iterator
 
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.
 
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
 
const MachineBasicBlock & front() const
 
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 & 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
 
MachineInstr * getInstr() const
If conversion operators fail, use this method to get the MachineInstr explicitly.
 
Representation of each machine instruction.
 
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
 
LLVM_ABI void eraseFromParent()
Unlink 'this' from the containing basic block and delete it.
 
LLVM_ABI bool addRegisterKilled(Register IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
 
LLVM_ABI void addRegisterDefined(Register Reg, const TargetRegisterInfo *RegInfo=nullptr)
We have determined MI defines a register.
 
const MachineOperand & getOperand(unsigned i) const
 
A description of a memory reference used in the backend.
 
@ MOLoad
The memory access reads data.
 
@ MOStore
The memory access writes data.
 
MachineBasicBlock * getMBB() const
 
static MachineOperand CreateImm(int64_t Val)
 
Register getReg() const
getReg - Returns the register number.
 
static MachineOperand CreateReg(Register Reg, bool isDef, bool isImp=false, bool isKill=false, bool isDead=false, bool isUndef=false, bool isEarlyClobber=false, unsigned SubReg=0, bool isDebug=false, bool isInternalRead=false, bool isRenamable=false)
 
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
 
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 loadRegFromStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register DestReg, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
 
Register isStoreToStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isStoreToStackSlot - If the specified machine instruction is a direct store to a stack slot,...
 
void copyPhysReg(MachineBasicBlock &MBB, MachineBasicBlock::iterator I, const DebugLoc &DL, Register DestReg, Register SrcReg, bool KillSrc, bool RenamableDest=false, bool RenamableSrc=false) const override
 
bool isBranchOffsetInRange(unsigned BranchOpc, int64_t Offset) const override
Determine if the branch target is in range.
 
bool reverseBranchCondition(SmallVectorImpl< MachineOperand > &Cond) const override
 
Register getGlobalBaseReg(MachineFunction *MF) const
 
unsigned removeBranch(MachineBasicBlock &MBB, int *BytesRemoved=nullptr) const override
 
MachineBasicBlock * getBranchDestBlock(const MachineInstr &MI) const override
 
bool analyzeBranch(MachineBasicBlock &MBB, MachineBasicBlock *&TBB, MachineBasicBlock *&FBB, SmallVectorImpl< MachineOperand > &Cond, bool AllowModify=false) const override
 
void storeRegToStackSlot(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI, Register SrcReg, bool isKill, int FrameIndex, const TargetRegisterClass *RC, const TargetRegisterInfo *TRI, Register VReg, MachineInstr::MIFlag Flags=MachineInstr::NoFlags) const override
 
Register isLoadFromStackSlot(const MachineInstr &MI, int &FrameIndex) const override
isLoadFromStackSlot - If the specified machine instruction is a direct load from a stack slot,...
 
SparcInstrInfo(const SparcSubtarget &ST)
 
const SparcRegisterInfo & getRegisterInfo() const
getRegisterInfo - TargetInstrInfo is a superset of MRegister info.
 
unsigned getInstSizeInBytes(const MachineInstr &MI) const override
GetInstSize - Return the number of bytes of code the specified instruction may be.
 
unsigned insertBranch(MachineBasicBlock &MBB, MachineBasicBlock *TBB, MachineBasicBlock *FBB, ArrayRef< MachineOperand > Cond, const DebugLoc &DL, int *BytesAdded=nullptr) const override
 
bool expandPostRAPseudo(MachineInstr &MI) const override
 
Register getGlobalBaseReg() const
 
void setGlobalBaseReg(Register Reg)
 
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.
 
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
 
initializer< Ty > init(const Ty &Val)
 
This is an optimization pass for GlobalISel generic memory operations.
 
static bool isCondBranchOpcode(int Opc)
 
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
 
static bool isIndirectBranchOpcode(int Opc)
 
decltype(auto) get(const PointerIntPair< PointerTy, IntBits, IntType, PtrTraits, Info > &Pair)
 
FunctionAddr VTableAddr Count
 
unsigned getKillRegState(bool B)
 
static bool isUncondBranchOpcode(int Opc)
 
constexpr bool isIntN(unsigned N, int64_t x)
Checks if an signed integer fits into the given (dynamic) bit width.
 
static LLVM_ABI MachinePointerInfo getFixedStack(MachineFunction &MF, int FI, int64_t Offset=0)
Return a MachinePointerInfo record that refers to the specified FrameIndex.