49#define DEBUG_TYPE "asm-printer"
58 std::unique_ptr<MCStreamer> Streamer)
59 :
AsmPrinter(TM, std::move(Streamer)), MCInstLowering(*
this) {}
64 const std::string &directive =
".jmptable");
66 printInlineJT(
MI, opNum, O,
".jmptable32");
91 "Unexpected linkage");
94 MCSymbol *SymGlob = OutContext.getOrCreateSymbol(
96 OutStreamer->emitSymbolAttribute(SymGlob,
MCSA_Global);
97 OutStreamer->emitAssignment(SymGlob,
102 OutStreamer->emitSymbolAttribute(SymGlob,
MCSA_Weak);
107void XCoreAsmPrinter::emitGlobalVariable(
const GlobalVariable *GV) {
113 OutStreamer->switchSection(getObjFileLowering().SectionForGlobal(GV, TM));
117 const Align Alignment =
DL.getPrefTypeAlign(
C->getType());
120 getTargetStreamer().emitCCTopData(GVSym->
getName());
131 emitArrayBound(GVSym, GV);
132 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Global);
136 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Weak);
145 emitAlignment(std::max(Alignment,
Align(4)), GV);
150 unsigned Size =
DL.getTypeAllocSize(
C->getType());
151 if (MAI->hasDotTypeDotSizeDirective()) {
155 OutStreamer->emitLabel(GVSym);
157 emitGlobalConstant(
DL,
C);
161 OutStreamer->emitZeros(4 -
Size);
164 getTargetStreamer().emitCCBottomData(GVSym->
getName());
167void XCoreAsmPrinter::emitFunctionBodyStart() {
168 MCInstLowering.Initialize(&MF->getContext());
173void XCoreAsmPrinter::emitFunctionBodyEnd() {
175 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
178void XCoreAsmPrinter::emitFunctionEntryLabel() {
180 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
181 OutStreamer->emitLabel(CurrentFnSym);
184void XCoreAsmPrinter::
186 const std::string &directive) {
187 unsigned JTI =
MI->getOperand(opNum).getIndex();
191 const std::vector<MachineBasicBlock*> &JTBBs =
JT[JTI].MBBs;
192 O <<
"\t" << directive <<
" ";
193 for (
unsigned i = 0, e = JTBBs.size(); i != e; ++i) {
201void XCoreAsmPrinter::printOperand(
const MachineInstr *
MI,
int opNum,
216 PrintSymbolOperand(MO, O);
219 O <<
DL.getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
232bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
235 if (!ExtraCode || !ExtraCode[0]) {
244bool XCoreAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
246 const char *ExtraCode,
248 if (ExtraCode && ExtraCode[0]) {
259 XCore_MC::verifyInstructionPredicates(
MI->getOpcode(),
260 getSubtargetInfo().getFeatureBits());
265 switch (
MI->getOpcode()) {
266 case XCore::DBG_VALUE:
268 case XCore::ADD_2rus:
269 if (
MI->getOperand(2).getImm() == 0) {
273 OutStreamer->emitRawText(
O.str());
281 if (
MI->getOpcode() == XCore::BR_JT)
282 printInlineJT(
MI, 0, O);
284 printInlineJT32(
MI, 0, O);
286 OutStreamer->emitRawText(
O.str());
291 MCInstLowering.Lower(
MI, TmpInst);
293 EmitToStreamer(*OutStreamer, TmpInst);
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define LLVM_EXTERNAL_VISIBILITY
This file contains the declarations for the subclasses of Constant, which represent the different fla...
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 ...
Module.h This file contains the declarations for the Module class.
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,...