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,
71 bool PrintAsmMemoryOperand(
const MachineInstr *MI,
unsigned OpNum,
77 void EmitFunctionEntryLabel()
override;
79 void EmitFunctionBodyStart()
override;
80 void EmitFunctionBodyEnd()
override;
91 "Unexpected linkage");
94 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
96 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Global);
97 OutStreamer->EmitAssignment(SymGlob,
102 OutStreamer->EmitSymbolAttribute(SymGlob,
MCSA_Weak);
107 void XCoreAsmPrinter::EmitGlobalVariable(
const GlobalVariable *GV) {
110 EmitSpecialLLVMGlobal(GV))
114 OutStreamer->SwitchSection(getObjFileLowering().SectionForGlobal(GV,
TM));
121 getTargetStreamer().emitCCTopData(GVSym->
getName());
132 emitArrayBound(GVSym, GV);
133 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Global);
137 OutStreamer->EmitSymbolAttribute(GVSym,
MCSA_Weak);
152 if (MAI->hasDotTypeDotSizeDirective()) {
156 OutStreamer->EmitLabel(GVSym);
158 EmitGlobalConstant(DL, C);
162 OutStreamer->EmitZeros(4 - Size);
165 getTargetStreamer().emitCCBottomData(GVSym->
getName());
168 void XCoreAsmPrinter::EmitFunctionBodyStart() {
169 MCInstLowering.Initialize(&MF->getContext());
174 void XCoreAsmPrinter::EmitFunctionBodyEnd() {
176 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
179 void XCoreAsmPrinter::EmitFunctionEntryLabel() {
181 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
182 OutStreamer->EmitLabel(CurrentFnSym);
185 void XCoreAsmPrinter::
187 const std::string &directive) {
192 const std::vector<MachineBasicBlock*> &JTBBs = JT[JTI].MBBs;
193 O <<
"\t" << directive <<
" ";
194 for (
unsigned i = 0,
e = JTBBs.size(); i !=
e; ++i) {
217 PrintSymbolOperand(MO, O);
233 bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *MI,
unsigned OpNo,
236 if (!ExtraCode || !ExtraCode[0]) {
245 bool XCoreAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *MI,
247 const char *ExtraCode,
249 if (ExtraCode && ExtraCode[0]) {
259 void XCoreAsmPrinter::EmitInstruction(
const MachineInstr *MI) {
264 case XCore::DBG_VALUE:
266 case XCore::ADD_2rus:
271 OutStreamer->EmitRawText(O.
str());
280 printInlineJT(MI, 0, O);
282 printInlineJT32(MI, 0, O);
284 OutStreamer->EmitRawText(O.
str());
289 MCInstLowering.Lower(MI, TmpInst);
291 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.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreAsmPrinter()
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.
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
Instances of this class represent a single low-level machine instruction.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false)
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...
TypeSize getTypeAllocSize(Type *Ty) const
Returns the offset in bytes between successive objects of the specified type, including alignment pad...
This class is intended to be used as a driving class for all asm writers.
unsigned getPrefTypeAlignment(Type *Ty) const
Returns the preferred stack/global alignment for the specified type.
Address of a basic block.
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.
This struct is a compact representation of a valid (non-zero power of two) alignment.
bool hasWeakLinkage() const
Target & getTheXCoreTarget()
Align max(MaybeAlign Lhs, Align Rhs)
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.
virtual bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo, const char *ExtraCode, raw_ostream &OS)
Print the specified operand of MI, an INLINEASM instruction, using the specified assembler variant...
StringRef str()
Return a StringRef for the vector contents.
#define LLVM_EXTERNAL_VISIBILITY
const MachineBasicBlock * getParent() const
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.
#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.
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.
Register getReg() const
getReg - Returns the register number.
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 char * getRegisterName(unsigned RegNo)
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.