Go to the documentation of this file.
36 #define DEBUG_TYPE "asm-printer"
42 *OutStreamer->getTargetStreamer());
46 std::unique_ptr<MCStreamer> Streamer)
49 StringRef getPassName()
const override {
return "Sparc Assembly Printer"; }
53 const char *Modifier =
nullptr);
55 void emitFunctionBodyStart()
override;
146 EmitBinary(OutStreamer, SP::ADDrr, RS1, RS2, RD, STI);
166 EmitOR(OutStreamer, RD, lo, RD, STI);
169 void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(
const MachineInstr *
MI,
173 OutContext.getOrCreateSymbol(
Twine(
"_GLOBAL_OFFSET_TABLE_"));
177 "%o7 is assigned as destination for getpcx!");
182 if (!isPositionIndependent()) {
184 switch(
TM.getCodeModel()) {
190 MCRegOP, OutContext, STI);
195 MCRegOP, OutContext, STI);
198 EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
200 GOTLabel, OutContext);
201 EmitOR(*OutStreamer, MCRegOP, lo, MCRegOP, STI);
207 MCRegOP, OutContext, STI);
210 EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
215 RegO7, OutContext, STI);
216 EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
222 MCSymbol *StartLabel = OutContext.createTempSymbol();
223 MCSymbol *EndLabel = OutContext.createTempSymbol();
224 MCSymbol *SethiLabel = OutContext.createTempSymbol();
236 OutStreamer->emitLabel(StartLabel);
238 EmitCall(*OutStreamer, Callee, STI);
239 OutStreamer->emitLabel(SethiLabel);
241 GOTLabel, StartLabel, SethiLabel,
243 EmitSETHI(*OutStreamer, hiImm, MCRegOP, STI);
244 OutStreamer->emitLabel(EndLabel);
246 GOTLabel, StartLabel, EndLabel,
248 EmitOR(*OutStreamer, MCRegOP, loImm, MCRegOP, STI);
249 EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
254 switch (
MI->getOpcode()) {
256 case TargetOpcode::DBG_VALUE:
260 LowerGETPCXAndEmitMCInsts(
MI, getSubtargetInfo());
268 EmitToStreamer(*OutStreamer, TmpInst);
269 }
while ((++
I !=
E) &&
I->isInsideBundle());
272 void SparcAsmPrinter::emitFunctionBodyStart() {
277 const unsigned globalRegs[] = { SP::G2, SP::G3, SP::G6, SP::G7, 0 };
278 for (
unsigned i = 0; globalRegs[
i] != 0; ++
i) {
279 unsigned reg = globalRegs[
i];
283 if (reg == SP::G6 || reg == SP::G7)
284 getTargetStreamer().emitSparcRegisterIgnore(reg);
286 getTargetStreamer().emitSparcRegisterScratch(reg);
301 "Cannot handle target flags on call address");
302 else if (
MI->getOpcode() == SP::SETHIi ||
MI->getOpcode() == SP::SETHIXi)
312 "Invalid target flags for address operand on sethi");
317 "Cannot handle target flags on tls call address");
318 else if (
MI->getOpcode() == SP::TLS_ADDrr)
323 "Cannot handle target flags on add for TLS");
324 else if (
MI->getOpcode() == SP::TLS_LDrr)
326 "Cannot handle target flags on ld for TLS");
327 else if (
MI->getOpcode() == SP::TLS_LDXrr)
329 "Cannot handle target flags on ldx for TLS");
330 else if (
MI->getOpcode() == SP::XORri ||
MI->getOpcode() == SP::XORXri)
333 "Cannot handle target flags on xor for TLS");
342 "Invalid target flags for small address operand");
361 PrintSymbolOperand(MO,
O);
370 O <<
DL.getPrivateGlobalPrefix() <<
"CPI" << getFunctionNumber() <<
"_"
379 if (CloseParen)
O <<
")";
387 if (Modifier && !strcmp(Modifier,
"arith")) {
393 if (
MI->getOperand(opNum+1).isReg() &&
394 MI->getOperand(opNum+1).getReg() == SP::G0)
396 if (
MI->getOperand(opNum+1).isImm() &&
397 MI->getOperand(opNum+1).getImm() == 0)
406 bool SparcAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
407 const char *ExtraCode,
409 if (ExtraCode && ExtraCode[0]) {
410 if (ExtraCode[1] != 0)
return true;
412 switch (ExtraCode[0]) {
427 bool SparcAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
429 const char *ExtraCode,
431 if (ExtraCode && ExtraCode[0])
@ 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 ...
A parsed version of the target data layout string in and methods for querying it.
static MCOperand createExpr(const MCExpr *Val)
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
Context object for machine code objects.
static const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
const BlockAddress * getBlockAddress() const
static void EmitSHL(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
Target & getTheSparcTarget()
static void EmitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, SparcMCExpr::VariantKind HiKind, SparcMCExpr::VariantKind LoKind, MCOperand &RD, MCContext &OutContext, const MCSubtargetInfo &STI)
static MCOperand createPCXRelExprOp(SparcMCExpr::VariantKind Kind, MCSymbol *GOTLabel, MCSymbol *StartLabel, MCSymbol *CurLabel, MCContext &OutContext)
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
Instances of this class represent a single low-level machine instruction.
Binary assembler expressions.
@ MO_Register
Register operand.
void setOpcode(unsigned Op)
MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Streaming machine code generation interface.
@ MO_GlobalAddress
Address of a global value.
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static const SparcMCExpr * create(VariantKind Kind, const MCExpr *Expr, MCContext &Ctx)
static void EmitBinary(MCStreamer &OutStreamer, unsigned Opcode, MCOperand &RS1, MCOperand &Src2, MCOperand &RD, const MCSubtargetInfo &STI)
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
static void EmitCall(MCStreamer &OutStreamer, MCOperand &Callee, const MCSubtargetInfo &STI)
Target & getTheSparcelTarget()
MachineOperand class - Representation of each machine instruction operand.
This class implements an extremely fast bulk output stream that can only output to a stream.
static const char * getRegisterName(unsigned RegNo)
void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
void addOperand(const MCOperand Op)
const MDNode * getMetadata() const
@ MO_Metadata
Metadata reference (for debug info)
unsigned getTargetFlags() const
Representation of each machine instruction.
#define LLVM_EXTERNAL_VISIBILITY
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
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
void LowerSparcMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
LLVM_NODISCARD std::string lower() const
bool isCPI() const
isCPI - Tests if this is a MO_ConstantPoolIndex operand.
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
static void printMemOperand(raw_ostream &OS, const MachineMemOperand &MMO, const MachineFunction *MF, const Module *M, const MachineFrameInfo *MFI, const TargetInstrInfo *TII, LLVMContext &Ctx)
static MCOperand createPCXCallOP(MCSymbol *Label, MCContext &OutContext)
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
Primary interface to the complete machine description for the target machine.
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Register getReg() const
getReg - Returns the register number.
Represent a reference to a symbol from inside an expression.
static void EmitOR(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
MachineBasicBlock * getMBB() const
StringRef - Represent a constant reference to a string, i.e.
static bool printVariantKind(raw_ostream &OS, VariantKind Kind)
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeSparcAsmPrinter()
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
static MCOperand createReg(unsigned Reg)
static MCOperand createSparcMCOperand(SparcMCExpr::VariantKind Kind, MCSymbol *Sym, MCContext &OutContext)
static void EmitADD(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &RS2, MCOperand &RD, const MCSubtargetInfo &STI)
@ MO_MachineBasicBlock
MachineBasicBlock reference.
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
unsigned const MachineRegisterInfo * MRI
amdgpu Simplify well known AMD library false FunctionCallee Callee
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Iterator for intrusive lists based on ilist_node.
@ MO_ExternalSymbol
Name of external global symbol.
static void EmitSETHI(MCStreamer &OutStreamer, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
This class is intended to be used as a driving class for all asm writers.
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx)
const char * getSymbolName() const
const char LLVMTargetMachineRef TM
Instances of this class represent operands of the MCInst class.
This class represents a function call, abstracting a target machine's calling convention.
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Generic base class for all target subtargets.
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.
Target & getTheSparcV9Target()
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
@ MO_ConstantPoolIndex
Address of indexed Constant in Constant Pool.
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)