49 #define DEBUG_TYPE "asm-printer"
58 std::unique_ptr<MCStreamer> Streamer)
59 :
AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*
this) {}
61 const char *getPassName()
const override {
62 return "XCore Assembly Printer";
66 const std::string &directive =
".jmptable");
68 printInlineJT(MI, opNum, O,
".jmptable32");
71 bool PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
72 unsigned AsmVariant,
const char *ExtraCode,
74 bool PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
75 unsigned AsmVariant,
const char *ExtraCode,
81 void EmitFunctionEntryLabel()
override;
83 void EmitFunctionBodyStart()
override;
84 void EmitFunctionBodyEnd()
override;
95 "Unexpected linkage");
97 cast<PointerType>(GV->
getType())->getElementType())) {
99 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
101 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Global);
102 OutStreamer->EmitAssignment(SymGlob,
107 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Weak);
112 void XCoreAsmPrinter::EmitGlobalVariable(
const GlobalVariable *GV) {
115 EmitSpecialLLVMGlobal(GV))
119 OutStreamer->SwitchSection(
120 getObjFileLowering().SectionForGlobal(GV, *Mang,
TM));
127 getTargetStreamer().emitCCTopData(GVSym->
getName());
138 emitArrayBound(GVSym, GV);
139 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Global);
143 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Weak);
152 EmitAlignment(Align > 2 ? Align : 2, GV);
158 if (MAI->hasDotTypeDotSizeDirective()) {
160 OutStreamer->emitELFSize(cast<MCSymbolELF>(GVSym),
163 OutStreamer->EmitLabel(GVSym);
165 EmitGlobalConstant(C);
169 OutStreamer->EmitZeros(4 - Size);
172 getTargetStreamer().emitCCBottomData(GVSym->
getName());
175 void XCoreAsmPrinter::EmitFunctionBodyStart() {
176 MCInstLowering.Initialize(Mang, &MF->getContext());
181 void XCoreAsmPrinter::EmitFunctionBodyEnd() {
183 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
186 void XCoreAsmPrinter::EmitFunctionEntryLabel() {
188 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
189 OutStreamer->EmitLabel(CurrentFnSym);
192 void XCoreAsmPrinter::
194 const std::string &directive) {
199 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
200 O <<
"\t" << directive <<
" ";
201 for (
unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
224 getSymbol(MO.
getGlobal())->print(O, MAI);
240 bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
241 unsigned AsmVariant,
const char *ExtraCode,
244 if (!ExtraCode || !ExtraCode[0]) {
253 bool XCoreAsmPrinter::
254 PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
255 unsigned AsmVariant,
const char *ExtraCode,
257 if (ExtraCode && ExtraCode[0]) {
267 void XCoreAsmPrinter::EmitInstruction(
const MachineInstr *MI) {
274 case XCore::ADD_2rus:
279 OutStreamer->EmitRawText(O.str());
288 printInlineJT(MI, 0, O);
290 printInlineJT32(MI, 0, O);
292 OutStreamer->EmitRawText(O.str());
297 MCInstLowering.Lower(MI, TmpInst);
299 EmitToStreamer(*OutStreamer, TmpInst);
const MachineFunction * getParent() const
getParent - Return the MachineFunction containing this basic block.
A parsed version of the target data layout string in and methods for querying it. ...
LinkageTypes getLinkage() const
const GlobalValue * getGlobal() const
Special purpose, only applies to global arrays.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
.type _foo, STT_OBJECT # aka
MachineBasicBlock * getMBB() const
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Same, but only replaced by something equivalent.
This class is used to lower an MachineInstr into an MCInst.
const char * getPrivateGlobalPrefix() const
Like Internal, but omit from symbol table.
Externally visible function.
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(const char *reason, bool gen_crash_diag=true)
Reports a serious error, calling any installed error handler.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
bool hasCommonLinkage() const
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
unsigned getPreferredTypeAlignmentShift(Type *Ty) const
Returns the preferred alignment for the specified type, returned as log2 of the value (a shift amount...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static void printOperand(raw_ostream &OS, uint8_t Opcode, unsigned OperandIdx, uint64_t Operand, uint64_t CodeAlignmentFactor, int64_t DataAlignmentFactor)
Print Opcode's operand number OperandIdx which has value Operand.
ArrayType - Class to represent array types.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
DBG_VALUE - a mapping of the llvm.dbg.value intrinsic.
Address of a global value.
Same, but only replaced by something equivalent.
This is an important base class in LLVM.
This file contains the declarations for the subclasses of Constant, which represent the different fla...
const MachineOperand & getOperand(unsigned i) const
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, unsigned AsmVariant, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
This class is intended to be used as a driving class for all asm writers.
Address of a basic block.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
void LLVMInitializeXCoreAsmPrinter()
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
bool hasWeakLinkage() const
MCSymbol * getSymbol() const
getSymbol - Return the MCSymbol for this basic block.
bool hasExternalLinkage() const
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
MachineOperand class - Representation of each machine instruction operand.
Keep one copy of function when linking (inline)
Module.h This file contains the declarations for the Module class.
Type * getType() const
All values are typed, get the type of this value.
static cl::opt< AlignMode > Align(cl::desc("Load/store alignment support"), cl::Hidden, cl::init(NoStrictAlign), cl::values(clEnumValN(StrictAlign,"aarch64-strict-align","Disallow all unaligned memory accesses"), clEnumValN(NoStrictAlign,"aarch64-no-strict-align","Allow unaligned memory accesses"), clEnumValEnd))
bool hasInitializer() const
Definitions have initializers, declarations don't.
BR_JT - Jumptable branch.
bool hasLinkOnceLinkage() const
Representation of each machine instruction.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
PointerType * getType() const
Global values are always pointers.
StringRef getName() const
getName - Get the symbol name.
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.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
This class implements an extremely fast bulk output stream that can only output to a stream...
Primary interface to the complete machine description for the target machine.
C - The default llvm calling convention, compatible with C.
StringRef - Represent a constant reference to a string, i.e.
const BlockAddress * getBlockAddress() const
Address of indexed Constant in Constant Pool.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
static const char * getRegisterName(unsigned RegNo)