Go to the documentation of this file.
49 #define DEBUG_TYPE "asm-printer"
58 std::unique_ptr<MCStreamer> Streamer)
61 StringRef getPassName()
const override {
return "XCore Assembly Printer"; }
64 const std::string &directive =
".jmptable");
66 printInlineJT(
MI, opNum,
O,
".jmptable32");
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) {
113 OutStreamer->switchSection(getObjFileLowering().SectionForGlobal(GV,
TM));
117 const Align Alignment(
DL.getPrefTypeAlignment(
C->getType()));
120 getTargetStreamer().emitCCTopData(GVSym->
getName());
131 emitArrayBound(GVSym, GV);
132 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Global);
136 OutStreamer->emitSymbolAttribute(GVSym,
MCSA_Weak);
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());
167 void XCoreAsmPrinter::emitFunctionBodyStart() {
168 MCInstLowering.Initialize(&MF->getContext());
173 void XCoreAsmPrinter::emitFunctionBodyEnd() {
175 getTargetStreamer().emitCCBottomFunction(CurrentFnSym->getName());
178 void XCoreAsmPrinter::emitFunctionEntryLabel() {
180 getTargetStreamer().emitCCTopFunction(CurrentFnSym->getName());
181 OutStreamer->emitLabel(CurrentFnSym);
184 void 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) {
216 PrintSymbolOperand(MO,
O);
219 O <<
DL.getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber() <<
'_'
232 bool XCoreAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
235 if (!ExtraCode || !ExtraCode[0]) {
244 bool 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());
282 printInlineJT(
MI, 0,
O);
284 printInlineJT32(
MI, 0,
O);
286 OutStreamer->emitRawText(
O.str());
291 MCInstLowering.Lower(
MI, TmpInst);
293 EmitToStreamer(*OutStreamer, TmpInst);
@ MO_BlockAddress
Address of a basic block.
@ MO_Immediate
Immediate operand.
This is an optimization pass for GlobalISel generic memory operations.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
bool hasCommonLinkage() const
A parsed version of the target data layout string in and methods for querying it.
@ LinkOnceAnyLinkage
Keep one copy of function when linking (inline)
@ BR_JT
BR_JT - Jumptable branch.
bool hasExternalLinkage() const
LinkageTypes getLinkage() const
@ MCSA_ELF_TypeObject
.type _foo, STT_OBJECT # aka @object
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
bool hasWeakLinkage() const
const BlockAddress * getBlockAddress() const
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
Expected< ExpressionValue > max(const ExpressionValue &Lhs, const ExpressionValue &Rhs)
Instances of this class represent a single low-level machine instruction.
Class to represent array types.
@ MO_Register
Register operand.
bool hasInitializer() const
Definitions have initializers, declarations don't.
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
@ MO_GlobalAddress
Address of a global value.
(vector float) vec_cmpeq(*A, *B) C
MachineOperand class - Representation of each machine instruction operand.
void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
This class implements an extremely fast bulk output stream that can only output to a stream.
StringRef getName() const
getName - Get the symbol name.
@ InternalLinkage
Rename collisions when linking (static functions).
This struct is a compact representation of a valid (non-zero power of two) alignment.
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
Target & getTheXCoreTarget()
const std::vector< MachineJumpTableEntry > & getJumpTables() const
const Constant * getInitializer() const
getInitializer - Return the initializer for this global variable.
This is an important base class in LLVM.
Representation of each machine instruction.
#define LLVM_EXTERNAL_VISIBILITY
@ WeakAnyLinkage
Keep one copy of named function when linking (weak)
compiles ldr LCPI1_0 ldr ldr mov lsr tst moveq r1 ldr LCPI1_1 and r0 bx lr It would be better to do something like to fold the shift into the conditional move
static const char * getRegisterName(unsigned RegNo)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
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.
Register getReg() const
getReg - Returns the register number.
@ AppendingLinkage
Special purpose, only applies to global arrays.
MachineBasicBlock * getMBB() const
StringRef - Represent a constant reference to a string, i.e.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ WeakODRLinkage
Same, but only replaced by something equivalent.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
@ CommonLinkage
Tentative definitions.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
This class is used to lower an MachineInstr into an MCInst.
This class is intended to be used as a driving class for all asm writers.
@ MCSA_Global
.type _foo, @gnu_unique_object
@ ExternalLinkage
Externally visible function.
@ PrivateLinkage
Like Internal, but omit from symbol table.
A raw_ostream that writes to an SmallVector or SmallString.
bool hasLinkOnceLinkage() const
Type * getValueType() const
const char LLVMTargetMachineRef TM
const MachineJumpTableInfo * getJumpTableInfo() const
getJumpTableInfo - Return the jump table info object for the current function.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
@ LinkOnceODRLinkage
Same, but only replaced by something equivalent.
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.
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeXCoreAsmPrinter()
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.