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);
A parsed version of the target data layout string in and methods for querying it. ...
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
const std::vector< MachineJumpTableEntry > & getJumpTables() const
Special purpose, only applies to global arrays.
MachineBasicBlock * getMBB() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class represents lattice values for constants.
.type _foo, STT_OBJECT # aka
StringRef getPrivateGlobalPrefix() 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.
unsigned getReg() const
getReg - Returns the register number.
Like Internal, but omit from symbol table.
Externally visible function.
A raw_ostream that writes to an SmallVector or SmallString.
MachineBasicBlock reference.
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 getOpcode() const
Returns the opcode of this MachineInstr.
bool hasCommonLinkage() const
bool hasExternalLinkage() const
Type * getType() const
All values are typed, get the type of this value.
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.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
LinkageTypes getLinkage() const
bool hasLinkOnceLinkage() const
Expected< const typename ELFT::Sym * > getSymbol(typename ELFT::SymRange Symbols, uint32_t Index)
Instances of this class represent a single low-level machine instruction.
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 GlobalValue * getGlobal() 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.
void LLVMInitializeXCoreAsmPrinter()
static void print(raw_ostream &Out, object::Archive::Kind Kind, T Val)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool hasWeakLinkage() const
Target & getTheXCoreTarget()
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.
StringRef str()
Return a StringRef for the vector contents.
const MachineBasicBlock * getParent() const
uint64_t getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
BR_JT - Jumptable branch.
Representation of each machine instruction.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
const BlockAddress * getBlockAddress() const
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Type * getValueType() const
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...
StringRef getName() const
getName - Get the symbol name.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool hasInitializer() const
Definitions have initializers, declarations don't.
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.
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
StringRef - Represent a constant reference to a string, i.e.
Address of indexed Constant in Constant Pool.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
const MachineOperand & getOperand(unsigned i) const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx)
static const char * getRegisterName(unsigned RegNo)
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.