15 #define DEBUG_TYPE "mips-asm-printer"
68 #include "MipsGenMCPseudoLowering.inc"
80 if (InConstantPool && MI->
getOpcode() != Mips::CONSTPOOL_ENTRY) {
82 InConstantPool =
false;
84 if (MI->
getOpcode() == Mips::CONSTPOOL_ENTRY) {
96 if (!InConstantPool) {
98 InConstantPool =
true;
133 }
while ((++I != E) && I->isInsideBundle());
175 unsigned CPUBitmask = 0, FPUBitmask = 0;
176 int CPUTopSavedRegOff, FPUTopSavedRegOff;
182 unsigned CPURegSize = Mips::GPR32RegClass.getSize();
183 unsigned FGR32RegSize = Mips::FGR32RegClass.getSize();
184 unsigned AFGR64RegSize = Mips::AFGR64RegClass.getSize();
185 bool HasAFGR64Reg =
false;
186 unsigned CSFPRegsSize = 0;
187 unsigned i, e = CSI.size();
190 for (i = 0; i != e; ++i) {
191 unsigned Reg = CSI[i].getReg();
192 if (Mips::GPR32RegClass.contains(Reg))
196 if (Mips::AFGR64RegClass.contains(Reg)) {
197 FPUBitmask |= (3 << RegNum);
198 CSFPRegsSize += AFGR64RegSize;
203 FPUBitmask |= (1 << RegNum);
204 CSFPRegsSize += FGR32RegSize;
208 for (; i != e; ++i) {
209 unsigned Reg = CSI[i].getReg();
211 CPUBitmask |= (1 << RegNum);
215 FPUTopSavedRegOff = FPUBitmask ?
216 (HasAFGR64Reg ? -AFGR64RegSize : -FGR32RegSize) : 0;
219 CPUTopSavedRegOff = CPUBitmask ? -CSFPRegsSize - CPURegSize : 0;
223 O <<
',' << CPUTopSavedRegOff <<
'\n';
227 O <<
"," << FPUTopSavedRegOff <<
'\n';
233 for (
int i = 7; i >= 0; i--)
234 O.
write_hex((Value & (0xF << (i*4))) >> (i*4));
252 "," +
Twine(stackSize) +
",$" +
289 bool IsNakedFunction =
293 if (!IsNakedFunction)
299 if (!IsNakedFunction)
328 InConstantPool =
false;
343 if (isa<SwitchInst>(bb->getTerminator()))
369 while (I != Pred->
begin() && !(--
I)->isTerminator()) ;
371 return !I->isBarrier();
376 unsigned AsmVariant,
const char *ExtraCode,
379 if (ExtraCode && ExtraCode[0]) {
380 if (ExtraCode[1] != 0)
return true;
383 switch (ExtraCode[0]) {
411 int64_t Val = MO.
getImm();
425 if (!FlagsOP.
isImm())
440 unsigned RegOp = OpNum;
444 switch(ExtraCode[0]) {
477 unsigned OpNum,
unsigned AsmVariant,
478 const char *ExtraCode,
483 if (ExtraCode[0] ==
'D')
490 assert(MO.
isReg() &&
"unexpected inline asm memory operand");
565 if (closeP) O <<
")";
572 O << (
unsigned short int)MO.
getImm();
581 O << (
unsigned short int)(
unsigned char)MO.
getImm();
609 const char *Modifier) {
654 EFlags |= ELF::EF_MIPS_CPIC;
657 EFlags |= ELF::EF_MIPS_ARCH_ASE_M16;
659 EFlags |= ELF::EF_MIPS_NOREORDER;
663 EFlags |= ELF::EF_MIPS_ARCH_64R2;
665 EFlags |= ELF::EF_MIPS_ARCH_64;
667 EFlags |= ELF::EF_MIPS_ARCH_32R2;
669 EFlags |= ELF::EF_MIPS_ARCH_32;
672 EFlags |= ELF::EF_MIPS_MICROMIPS;
676 EFlags |= ELF::EF_MIPS_ABI_O32;
681 EFlags |= ELF::EF_MIPS_PIC;
MachineConstantPoolValue * MachineCPVal
const GlobalValue * getGlobal() const
void printHex32(unsigned int Value, raw_ostream &O)
instr_iterator instr_end()
void EmitRawText(const Twine &String)
MCSymbol * getSymbol(const GlobalValue *GV) const
MachineBasicBlock * getMBB() const
The main container class for the LLVM Intermediate Representation.
void Lower(const MachineInstr *MI, MCInst &OutMI) const
MO_TLSGD - Represents the offset into the global offset table at which.
const char * getPrivateGlobalPrefix() const
const MachineFunction * MF
The current machine function.
Reloc::Model getRelocationModel() const
void printSavedRegsBitmask(raw_ostream &O)
virtual bool hasRawTextSupport() const
virtual void EmitInstruction(const MCInst &Inst)=0
unsigned getFunctionNumber() const
const char * getSymbolName() const
unsigned getTargetABI() const
const Function * getFunction() const
void Initialize(MCContext *C)
bool hasAttribute(unsigned Index, Attribute::AttrKind Kind) const
Return true if the attribute exists at the given index.
Address of indexed Jump Table for switch.
const std::vector< CalleeSavedInfo > & getCalleeSavedInfo() const
uint64_t getStackSize() const
static std::string utohexstr(uint64_t X)
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
#define llvm_unreachable(msg)
void LLVMInitializeMipsAsmPrinter()
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Abstract Stack Frame Information.
virtual void emitMipsHackSTOCG(MCSymbol *Sym, unsigned Val)=0
virtual unsigned getFrameRegister(const MachineFunction &MF) const =0
Debug information queries.
unsigned getNumOperands() const
raw_ostream & write_hex(unsigned long long N)
write_hex - Output N in hexadecimal, without any prefix or padding.
An entry in a MachineConstantPool.
MCContext & getContext() const
void PrintDebugValueComment(const MachineInstr *MI, raw_ostream &OS)
Address of indexed Constant in Constant Pool.
const BasicBlock * getBasicBlock() const
bool isMachineConstantPoolEntry() const
const MachineBasicBlock * getParent() const
const Constant * ConstVal
bool isDebugValue() const
void printFCCOperand(const MachineInstr *MI, int opNum, raw_ostream &O, const char *Modifier=0)
unsigned getTargetFlags() const
const MipsReginfo & getMReginfo() const
void EmitInstruction(const MachineInstr *MI)
EmitInstruction - Targets should implement this to emit instructions.
LLVM Basic Block Representation.
virtual bool runOnMachineFunction(MachineFunction &MF)
const MachineOperand & getOperand(unsigned i) const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
static unsigned getNumOperandRegisters(unsigned Flag)
void EmitEndOfAsmFile(Module &M)
void printUnsignedImm8(const MachineInstr *MI, int opNum, raw_ostream &O)
int64_t getOffset() const
bool inMicroMipsMode() const
const char * getCurrentABIString() const
Emit Set directives.
MachineConstantPool * getConstantPool()
bool inMips16Mode() const
MipsMCInstLower MCInstLowering
union llvm::MachineConstantPoolEntry::@29 Val
The constant itself.
pred_iterator pred_begin()
MCSymbol * getSymbol() const
MO_GOTTPREL - Represents the offset from the thread pointer (Initial.
virtual void EmitDataRegion(MCDataRegionType Kind)
EmitDataRegion - Note in the output the specified region Kind.
std::vector< MachineBasicBlock * >::const_iterator const_pred_iterator
bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNum, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O)
virtual void EmitLabel(MCSymbol *Symbol)
void EmitGlobalConstant(const Constant *CV)
Print a general LLVM constant to the .s file.
void printUnsignedImm(const MachineInstr *MI, int opNum, raw_ostream &O)
MachineFrameInfo * getFrameInfo()
virtual void EmitFunctionBodyStart()
const char * MipsFCCToString(Mips::CondCode CC)
MO_TPREL_HI/LO - Represents the hi and low part of the offset from.
virtual void EmitMachineConstantPoolValue(MachineConstantPoolValue *MCPV)
void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &O)
MachineOperandType getType() const
bundle_iterator< const MachineInstr, const_instr_iterator > const_iterator
bool isLandingPad() const
void emitMipsReginfoSectionCG(MCStreamer &OS, const TargetLoweringObjectFile &TLOF, const MipsSubtarget &MST) const
StringRef getName() const
getName - Get the symbol name.
const MipsSubtarget * Subtarget
virtual bool runOnMachineFunction(MachineFunction &MF)
virtual void EmitFunctionBodyEnd()
MCTargetStreamer & getTargetStreamer()
MCSymbol * GetBlockAddressSymbol(const BlockAddress *BA) const
void printOperand(const MachineInstr *MI, int opNum, raw_ostream &O)
bool allowMixed16_32() const
bool isABI_EABI() const
Only O32 and EABI supported right now.
virtual const TargetRegisterInfo * getRegisterInfo() const
static void emitELFHeaderFlagsCG(MipsTargetStreamer &TargetStreamer, const MipsSubtarget &Subtarget)
AttributeSet getAttributes(LLVMContext &C, ID id)
void printMemOperandEA(const MachineInstr *MI, int opNum, raw_ostream &O)
MCSymbol * GetCPISymbol(unsigned CPID) const
GetCPISymbol - Return the symbol for the specified constant pool entry.
unsigned getReg() const
getReg - Returns the register number.
const TargetLoweringObjectFile & getObjFileLowering() const
getObjFileLowering - Return information about object file lowering.
static const char * getRegisterName(unsigned RegNo)
uint16_t getEncodingValue(unsigned RegNo) const
Returns the encoding for RegNo.
LLVM Value Representation.
virtual bool isBlockOnlyReachableByFallthrough(const MachineBasicBlock *MBB) const
Address of a basic block.
MCOperand LowerOperand(const MachineOperand &MO, unsigned offset=0) const
const MipsFunctionInfo * MipsFI
const std::vector< MachineConstantPoolEntry > & getConstants() const
void emitFrameDirective()
Frame Directive.
virtual void emitMipsHackELFFlags(unsigned Flags)=0
const BlockAddress * getBlockAddress() const
void EmitStartOfAsmFile(Module &M)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
unsigned getRARegister() const
This method should return the register where the return address can be found.
bool isLayoutSuccessor(const MachineBasicBlock *MBB) const
MCSymbol * GetExternalSymbolSymbol(StringRef Sym) const
bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &O)
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
std::string lower() const
MachineBasicBlock reference.
virtual void EmitFunctionEntryLabel()
Address of a global value.
Name of external global symbol.