15 #define DEBUG_TYPE "asm-printer"
56 MCInstLowering(*
this) {}
58 virtual const char *getPassName()
const {
59 return "XCore Assembly Printer";
63 const std::string &directive =
".jmptable");
65 printInlineJT(MI, opNum, O,
".jmptable32");
68 bool PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
69 unsigned AsmVariant,
const char *ExtraCode,
75 void EmitFunctionEntryLabel();
77 void EmitFunctionBodyStart();
78 void EmitFunctionBodyEnd();
87 cast<PointerType>(GV->
getType())->getElementType())) {
89 MCSymbol *SymGlob = OutContext.GetOrCreateSymbol(
91 OutStreamer.EmitSymbolAttribute(SymGlob,
MCSA_Global);
92 OutStreamer.EmitAssignment(SymGlob,
97 OutStreamer.EmitSymbolAttribute(SymGlob,
MCSA_Weak);
102 void XCoreAsmPrinter::EmitGlobalVariable(
const GlobalVariable *GV) {
105 EmitSpecialLLVMGlobal(GV))
109 OutStreamer.SwitchSection(getObjFileLowering().SectionForGlobal(GV, Mang,
TM));
117 OutStreamer.EmitRawText(
"\t.cc_top " +
Twine(GVSym->
getName()) +
".data," +
128 emitArrayBound(GVSym, GV);
129 OutStreamer.EmitSymbolAttribute(GVSym,
MCSA_Global);
133 OutStreamer.EmitSymbolAttribute(GVSym,
MCSA_Weak);
146 EmitAlignment(Align > 2 ? Align : 2, GV);
152 if (MAI->hasDotTypeDotSizeDirective()) {
154 OutStreamer.EmitRawText(
"\t.size " +
Twine(GVSym->
getName()) +
"," +
157 OutStreamer.EmitLabel(GVSym);
159 EmitGlobalConstant(C);
163 OutStreamer.EmitZeros(4 - Size);
166 OutStreamer.EmitRawText(
"\t.cc_bottom " +
Twine(GVSym->
getName()) +
".data");
169 void XCoreAsmPrinter::EmitFunctionBodyStart() {
170 MCInstLowering.Initialize(Mang, &MF->getContext());
175 void XCoreAsmPrinter::EmitFunctionBodyEnd() {
177 OutStreamer.EmitRawText(
"\t.cc_bottom " +
Twine(CurrentFnSym->getName()) +
181 void XCoreAsmPrinter::EmitFunctionEntryLabel() {
183 OutStreamer.EmitRawText(
"\t.cc_top " +
Twine(CurrentFnSym->getName()) +
184 ".function," + CurrentFnSym->getName());
185 OutStreamer.EmitLabel(CurrentFnSym);
188 void XCoreAsmPrinter::
190 const std::string &directive) {
194 const std::vector<MachineJumpTableEntry> &JT = MJTI->
getJumpTables();
195 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
196 O <<
"\t" << directive <<
" ";
197 for (
unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
205 void XCoreAsmPrinter::printOperand(
const MachineInstr *MI,
int opNum,
225 O << MAI->getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber()
229 O << MAI->getPrivateGlobalPrefix() <<
"JTI" << getFunctionNumber()
242 bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
243 unsigned AsmVariant,
const char *ExtraCode,
246 if (!ExtraCode || !ExtraCode[0]) {
247 printOperand(MI, OpNo, O);
255 void XCoreAsmPrinter::EmitInstruction(
const MachineInstr *MI) {
262 case XCore::ADD_2rus:
267 OutStreamer.EmitRawText(O.str());
276 printInlineJT(MI, 0, O);
278 printInlineJT32(MI, 0, O);
280 OutStreamer.EmitRawText(O.str());
285 MCInstLowering.Lower(MI, TmpInst);
287 OutStreamer.EmitInstruction(TmpInst);
const MachineFunction * getParent() const
LinkageTypes getLinkage() const
const GlobalValue * getGlobal() const
Special purpose, only applies to global arrays.
.type _foo, STT_OBJECT # aka
MachineBasicBlock * getMBB() const
static const MCConstantExpr * Create(int64_t Value, MCContext &Ctx)
Same, but only replaced by something equivalent.
This class is used to lower an MachineInstr into an MCInst.
Like Internal, but omit from symbol table.
Externally visible function.
const char * getSymbolName() const
const Constant * getInitializer() const
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Address of indexed Jump Table for switch.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
unsigned getPreferredTypeAlignmentShift(Type *Ty) const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
#define llvm_unreachable(msg)
Function to be imported from DLL.
const MachineJumpTableInfo * getJumpTableInfo() const
Address of indexed Constant in Constant Pool.
const MachineBasicBlock * getParent() const
Same, but only replaced by something equivalent.
LLVM Constant Representation.
const MachineOperand & getOperand(unsigned i) const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
void LLVMInitializeXCoreAsmPrinter()
Function to be accessible from DLL.
bool hasWeakLinkage() const
MCSymbol * getSymbol() const
bool hasExternalLinkage() const
const STC & getSubtarget() const
uint64_t getTypeAllocSize(Type *Ty) const
Keep one copy of function when linking (inline)
bool hasInitializer() const
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(DefaultAlign), cl::values(clEnumValN(DefaultAlign,"arm-default-align","Generate unaligned accesses only on hardware/OS ""combinations that are known to support them"), clEnumValN(StrictAlign,"arm-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"arm-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
bool hasLinkOnceLinkage() const
MachineOperandType getType() const
PointerType * getType() const
getType - Global values are always pointers.
StringRef getName() const
getName - Get the symbol name.
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
Keep one copy of named function when linking (weak)
Rename collisions when linking (static functions).
This file contains the declaration of the XCoreInstPrinter class, which is used to print XCore MCInst...
unsigned getReg() const
getReg - Returns the register number.
Address of a basic block.
const BlockAddress * getBlockAddress() const
static RegisterPass< NVPTXAllocaHoisting > X("alloca-hoisting","Hoisting alloca instructions in non-entry ""blocks to the entry block")
INITIALIZE_PASS(GlobalMerge,"global-merge","Global Merge", false, false) bool GlobalMerge const DataLayout * TD
MachineBasicBlock reference.
static const char * getRegisterName(unsigned RegNo)
Address of a global value.
Name of external global symbol.