49 #define DEBUG_TYPE "asm-printer"
58 std::unique_ptr<MCStreamer> Streamer)
59 :
AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*
this) {}
61 StringRef getPassName()
const override {
return "XCore Assembly Printer"; }
64 const std::string &directive =
".jmptable");
66 printInlineJT(MI, opNum, O,
".jmptable32");
69 bool PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
70 unsigned AsmVariant,
const char *ExtraCode,
72 bool PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
73 unsigned AsmVariant,
const char *ExtraCode,
79 void EmitFunctionEntryLabel()
override;
81 void EmitFunctionBodyStart()
override;
82 void EmitFunctionBodyEnd()
override;
93 "Unexpected linkage");
96 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
98 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Global);
99 OutStreamer->EmitAssignment(SymGlob,
104 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Weak);
109 void XCoreAsmPrinter::EmitGlobalVariable(
const GlobalVariable *GV) {
112 EmitSpecialLLVMGlobal(GV))
116 OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(GV,
TM));
123 getTargetStreamer().emitCCTopData(GVSym->
getName());
134 emitArrayBound(GVSym, GV);
135 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Global);
139 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Weak);
148 EmitAlignment(Align > 2 ? Align : 2, GV);
154 if (MAI->hasDotTypeDotSizeDirective()) {
158 OutStreamer->EmitLabel(GVSym);
160 EmitGlobalConstant(DL, C);
164 OutStreamer->EmitZeros(4 - Size);
167 getTargetStreamer().emitCCBottomData(GVSym->
getName());
170 void XCoreAsmPrinter::EmitFunctionBodyStart() {
171 MCInstLowering.Initialize(&MF->getContext());
176 void XCoreAsmPrinter::EmitFunctionBodyEnd() {
178 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
181 void XCoreAsmPrinter::EmitFunctionEntryLabel() {
183 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
184 OutStreamer->EmitLabel(CurrentFnSym);
187 void XCoreAsmPrinter::
189 const std::string &directive) {
194 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
195 O <<
"\t" << directive <<
" ";
196 for (
unsigned i = 0, e = JTBBs.size();
i != e; ++
i) {
235 bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
236 unsigned AsmVariant,
const char *ExtraCode,
239 if (!ExtraCode || !ExtraCode[0]) {
248 bool XCoreAsmPrinter::
249 PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
250 unsigned AsmVariant,
const char *ExtraCode,
252 if (ExtraCode && ExtraCode[0]) {
262 void XCoreAsmPrinter::EmitInstruction(
const MachineInstr *MI) {
267 case XCore::DBG_VALUE:
269 case XCore::ADD_2rus:
274 OutStreamer->EmitRawText(O.str());
283 printInlineJT(MI, 0, O);
285 printInlineJT32(MI, 0, O);
287 OutStreamer->EmitRawText(O.str());
292 MCInstLowering.Lower(MI, TmpInst);
294 EmitToStreamer(*OutStreamer, TmpInst);
const MachineFunction * getParent() const
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
StringRef getPrivateGlobalPrefix() 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.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
.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.
Type * getValueType() 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.
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...
Class to represent array types.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
Instances of this class represent a single low-level machine instruction.
unsigned getOpcode() const
Returns the opcode of this MachineInstr.
const MachineBasicBlock * getParent() const
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
Return the MCSymbol for this basic block.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool hasExternalLinkage() const
Target & getTheXCoreTarget()
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 GCRegistry::Add< ShadowStackGC > C("shadow-stack","Very portable GC for uncooperative code generators")
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.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
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.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
#define LLVM_FALLTHROUGH
LLVM_FALLTHROUGH - Mark fallthrough cases in switch statements.
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.
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)