44#define DEBUG_TYPE "asm-printer"
53 std::unique_ptr<MCStreamer> Streamer)
54 :
AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*
this) {}
59 const std::string &directive =
".jmptable");
61 printInlineJT(
MI, opNum, O,
".jmptable32");
86 "Unexpected linkage");
89 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
91 OutStreamer->emitSymbolAttribute(SymGlob,
MCSA_Global);
92 OutStreamer->emitAssignment(SymGlob,
97 OutStreamer->emitSymbolAttribute(SymGlob,
MCSA_Weak);
102void XCoreAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
108 OutStreamer->switchSection(getObjFileLowering().SectionForGlobal(GV, TM));
112 const Align Alignment =
DL.getPrefTypeAlign(
C->getType());
115 getTargetStreamer().emitCCTopData(GVSym->
getName());
126 emitArrayBound(GVSym, GV);
127 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Global);
131 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Weak);
140 emitAlignment(std::max(Alignment,
Align(4)), GV);
145 unsigned Size =
DL.getTypeAllocSize(
C->getType());
146 if (MAI->hasDotTypeDotSizeDirective()) {
150 OutStreamer->emitLabel(GVSym);
152 emitGlobalConstant(
DL,
C);
156 OutStreamer->emitZeros(4 -
Size);
159 getTargetStreamer().emitCCBottomData(GVSym->
getName());
162void XCoreAsmPrinter::emitFunctionBodyStart() {
163 MCInstLowering.Initialize(&MF->getContext());
168void XCoreAsmPrinter::emitFunctionBodyEnd() {
170 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
173void XCoreAsmPrinter::emitFunctionEntryLabel() {
175 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
176 OutStreamer->emitLabel(CurrentFnSym);
179void XCoreAsmPrinter::
181 const std::string &directive) {
182 unsigned JTI =
MI->getOperand(opNum).getIndex();
186 const std::vector<MachineBasicBlock*> &JTBBs =
JT[JTI].MBBs;
187 O <<
"\t" << directive <<
" ";
188 for (
unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
196void XCoreAsmPrinter::printOperand(
const MachineInstr *
MI,
int opNum,
211 PrintSymbolOperand(MO, O);
214 O <<
DL.getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
227bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
230 if (!ExtraCode || !ExtraCode[0]) {
239bool XCoreAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
241 const char *ExtraCode,
243 if (ExtraCode && ExtraCode[0]) {
254 XCore_MC::verifyInstructionPredicates(
MI->getOpcode(),
255 getSubtargetInfo().getFeatureBits());
260 switch (
MI->getOpcode()) {
261 case XCore::DBG_VALUE:
263 case XCore::ADD_2rus:
264 if (
MI->getOperand(2).getImm() == 0) {
268 OutStreamer->emitRawText(
O.str());
276 if (
MI->getOpcode() == XCore::BR_JT)
277 printInlineJT(
MI, 0, O);
279 printInlineJT32(
MI, 0, O);
281 OutStreamer->emitRawText(
O.str());
286 MCInstLowering.Lower(
MI, TmpInst);
288 EmitToStreamer(*OutStreamer, TmpInst);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_EXTERNAL_VISIBILITY
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
This file defines the SmallString class.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreAsmPrinter()
This file contains the declaration of the XCoreInstPrinter class, which is used to print XCore MCInst...
This class is intended to be used as a driving class for all asm writers.
virtual void emitInstruction(const MachineInstr *)
Targets should implement this to emit instructions.
virtual void emitGlobalVariable(const GlobalVariable *GV)
Emit the specified global variable to the .s file.
virtual void emitFunctionBodyStart()
Targets can override this to emit stuff before the first basic block in the function.
virtual bool PrintAsmMemoryOperand(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 as...
virtual void emitFunctionBodyEnd()
Targets can override this to emit stuff after the last basic block in the function.
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
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.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
bool hasLinkOnceLinkage() const
bool hasExternalLinkage() const
bool isThreadLocal() const
If the value is "Thread Local", its value isn't shared by the threads.
LinkageTypes getLinkage() const
bool hasWeakLinkage() const
bool hasCommonLinkage() const
@ PrivateLinkage
Like Internal, but omit from symbol table.
@ CommonLinkage
Tentative definitions.
@ InternalLinkage
Rename collisions when linking (static functions).
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ ExternalLinkage
Externally visible function.
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
@ AppendingLinkage
Special purpose, only applies to global arrays.
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
Type * getValueType() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
bool hasInitializer() const
Definitions have initializers, declarations don't.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Instances of this class represent a single low-level machine instruction.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
StringRef getName() const
getName - Get the symbol name.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
Representation of each machine instruction.
const std::vector< MachineJumpTableEntry > & getJumpTables() const
MachineOperand class - Representation of each machine instruction operand.
MachineBasicBlock * getMBB() const
const BlockAddress * getBlockAddress() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Register getReg() const
getReg - Returns the register number.
@ MO_Immediate
Immediate operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
@ MO_GlobalAddress
Address of a global value.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
SmallString - A SmallString is just a SmallVector with methods and accessors that make it work better...
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
static const char * getRegisterName(MCRegister Reg)
This class is used to lower an MachineInstr into an MCInst.
This class implements an extremely fast bulk output stream that can only output to a stream.
A raw_ostream that writes to an SmallVector or SmallString.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheXCoreTarget()
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
@ MCSA_Global
.type _foo, @gnu_unique_object
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
This struct is a compact representation of a valid (non-zero power of two) alignment.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...