LLVM 24.0.0git
SparcAsmPrinter.cpp
Go to the documentation of this file.
1//===-- SparcAsmPrinter.cpp - Sparc LLVM assembly writer ------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file contains a printer that converts from our internal representation
10// of machine-dependent LLVM code to GAS-format SPARC assembly language.
11//
12//===----------------------------------------------------------------------===//
13
18#include "Sparc.h"
19#include "SparcInstrInfo.h"
20#include "SparcTargetMachine.h"
28#include "llvm/IR/Mangler.h"
29#include "llvm/MC/MCAsmInfo.h"
30#include "llvm/MC/MCContext.h"
31#include "llvm/MC/MCInst.h"
32#include "llvm/MC/MCStreamer.h"
33#include "llvm/MC/MCSymbol.h"
37using namespace llvm;
38
39#define DEBUG_TYPE "asm-printer"
40
41namespace {
42class SparcAsmPrinter : public AsmPrinter {
43 SparcTargetStreamer &getTargetStreamer() {
44 return static_cast<SparcTargetStreamer &>(
45 *OutStreamer->getTargetStreamer());
46 }
47
48public:
49 explicit SparcAsmPrinter(TargetMachine &TM,
50 std::unique_ptr<MCStreamer> Streamer)
51 : AsmPrinter(TM, std::move(Streamer), ID) {}
52
53 StringRef getPassName() const override { return "Sparc Assembly Printer"; }
54
55 void printOperand(const MachineInstr *MI, int opNum, raw_ostream &OS);
56 void printMemOperand(const MachineInstr *MI, int opNum, raw_ostream &OS);
57
58 void emitFunctionBodyStart() override;
59 void emitInstruction(const MachineInstr *MI) override;
60
61 static const char *getRegisterName(MCRegister Reg) {
63 }
64
65 bool PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
66 const char *ExtraCode, raw_ostream &O) override;
67 bool PrintAsmMemoryOperand(const MachineInstr *MI, unsigned OpNo,
68 const char *ExtraCode, raw_ostream &O) override;
69 void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &O) override;
70
71 void LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
72 const MCSubtargetInfo &STI);
73
74 MCOperand lowerOperand(const MachineOperand &MO) const;
75
76private:
77 void lowerToMCInst(const MachineInstr *MI, MCInst &OutMI);
78
79public:
80 static char ID;
81};
82} // end of anonymous namespace
83
85 MCContext &OutContext) {
86 const MCSymbolRefExpr *MCSym = MCSymbolRefExpr::create(Sym, OutContext);
87 auto *expr = MCSpecifierExpr::create(MCSym, Kind, OutContext);
88 return MCOperand::createExpr(expr);
89}
91 MCContext &OutContext) {
92 return MCOperand::createExpr(MCSymbolRefExpr::create(Label, OutContext));
93}
94
96 MCSymbol *StartLabel, MCSymbol *CurLabel,
97 MCContext &OutContext) {
98 const MCSymbolRefExpr *GOT = MCSymbolRefExpr::create(GOTLabel, OutContext);
99 const MCSymbolRefExpr *Start = MCSymbolRefExpr::create(StartLabel,
100 OutContext);
101 const MCSymbolRefExpr *Cur = MCSymbolRefExpr::create(CurLabel,
102 OutContext);
103
104 const MCBinaryExpr *Sub = MCBinaryExpr::createSub(Cur, Start, OutContext);
105 const MCBinaryExpr *Add = MCBinaryExpr::createAdd(GOT, Sub, OutContext);
106 auto *expr = MCSpecifierExpr::create(Add, Spec, OutContext);
107 return MCOperand::createExpr(expr);
108}
109
110static void EmitCall(MCStreamer &OutStreamer,
111 MCOperand &Callee,
112 const MCSubtargetInfo &STI)
113{
115 CallInst.setOpcode(SP::CALL);
116 CallInst.addOperand(Callee);
117 OutStreamer.emitInstruction(CallInst, STI);
118}
119
120static void EmitRDPC(MCStreamer &OutStreamer, MCOperand &RD,
121 const MCSubtargetInfo &STI) {
122 MCInst RDPCInst;
123 RDPCInst.setOpcode(SP::RDASR);
124 RDPCInst.addOperand(RD);
125 RDPCInst.addOperand(MCOperand::createReg(SP::ASR5));
126 OutStreamer.emitInstruction(RDPCInst, STI);
127}
128
129static void EmitSETHI(MCStreamer &OutStreamer,
130 MCOperand &Imm, MCOperand &RD,
131 const MCSubtargetInfo &STI)
132{
133 MCInst SETHIInst;
134 SETHIInst.setOpcode(SP::SETHIi);
135 SETHIInst.addOperand(RD);
136 SETHIInst.addOperand(Imm);
137 OutStreamer.emitInstruction(SETHIInst, STI);
138}
139
140static void EmitBinary(MCStreamer &OutStreamer, unsigned Opcode,
141 MCOperand &RS1, MCOperand &Src2, MCOperand &RD,
142 const MCSubtargetInfo &STI)
143{
144 MCInst Inst;
145 Inst.setOpcode(Opcode);
146 Inst.addOperand(RD);
147 Inst.addOperand(RS1);
148 Inst.addOperand(Src2);
149 OutStreamer.emitInstruction(Inst, STI);
150}
151
152static void EmitOR(MCStreamer &OutStreamer,
153 MCOperand &RS1, MCOperand &Imm, MCOperand &RD,
154 const MCSubtargetInfo &STI) {
155 EmitBinary(OutStreamer, SP::ORri, RS1, Imm, RD, STI);
156}
157
158static void EmitADD(MCStreamer &OutStreamer,
159 MCOperand &RS1, MCOperand &RS2, MCOperand &RD,
160 const MCSubtargetInfo &STI) {
161 EmitBinary(OutStreamer, SP::ADDrr, RS1, RS2, RD, STI);
162}
163
164static void EmitSHL(MCStreamer &OutStreamer,
165 MCOperand &RS1, MCOperand &Imm, MCOperand &RD,
166 const MCSubtargetInfo &STI) {
167 EmitBinary(OutStreamer, SP::SLLri, RS1, Imm, RD, STI);
168}
169
170static void emitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, uint16_t HiKind,
171 uint16_t LoKind, MCOperand &RD, MCContext &OutContext,
172 const MCSubtargetInfo &STI) {
173 MCOperand hi = createSparcMCOperand(HiKind, GOTSym, OutContext);
174 MCOperand lo = createSparcMCOperand(LoKind, GOTSym, OutContext);
175 EmitSETHI(OutStreamer, hi, RD, STI);
176 EmitOR(OutStreamer, RD, lo, RD, STI);
177}
178
179void SparcAsmPrinter::LowerGETPCXAndEmitMCInsts(const MachineInstr *MI,
180 const MCSubtargetInfo &STI)
181{
182 MCSymbol *GOTLabel =
183 OutContext.getOrCreateSymbol(Twine("_GLOBAL_OFFSET_TABLE_"));
184
185 const MachineOperand &MO = MI->getOperand(0);
186 assert(MO.getReg() != SP::O7 &&
187 "%o7 is assigned as destination for getpcx!");
188
189 MCOperand MCRegOP = MCOperand::createReg(MO.getReg());
190
191
192 if (!isPositionIndependent()) {
193 // Just load the address of GOT to MCRegOP.
194 switch(TM.getCodeModel()) {
195 default:
196 llvm_unreachable("Unsupported absolute code model");
197 case CodeModel::Small:
198 emitHiLo(*OutStreamer, GOTLabel, ELF::R_SPARC_HI22, ELF::R_SPARC_LO10,
199 MCRegOP, OutContext, STI);
200 break;
201 case CodeModel::Medium: {
202 emitHiLo(*OutStreamer, GOTLabel, ELF::R_SPARC_H44, ELF::R_SPARC_M44,
203 MCRegOP, OutContext, STI);
205 OutContext));
206 EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
207 MCOperand lo =
208 createSparcMCOperand(ELF::R_SPARC_L44, GOTLabel, OutContext);
209 EmitOR(*OutStreamer, MCRegOP, lo, MCRegOP, STI);
210 break;
211 }
212 case CodeModel::Large: {
213 emitHiLo(*OutStreamer, GOTLabel, ELF::R_SPARC_HH22, ELF::R_SPARC_HM10,
214 MCRegOP, OutContext, STI);
216 OutContext));
217 EmitSHL(*OutStreamer, MCRegOP, imm, MCRegOP, STI);
218 // Use register %o7 to load the lower 32 bits.
219 MCOperand RegO7 = MCOperand::createReg(SP::O7);
220 emitHiLo(*OutStreamer, GOTLabel, ELF::R_SPARC_HI22, ELF::R_SPARC_LO10,
221 RegO7, OutContext, STI);
222 EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
223 }
224 }
225 return;
226 }
227
228 MCSymbol *StartLabel = OutContext.createTempSymbol();
229 MCSymbol *EndLabel = OutContext.createTempSymbol();
230 MCSymbol *SethiLabel = OutContext.createTempSymbol();
231
232 MCOperand RegO7 = MCOperand::createReg(SP::O7);
233
234 // <StartLabel>:
235 // <GET-PC> // This will be either `call <EndLabel>` or `rd %pc, %o7`.
236 // <SethiLabel>:
237 // sethi %hi(_GLOBAL_OFFSET_TABLE_+(<SethiLabel>-<StartLabel>)), <MO>
238 // <EndLabel>:
239 // or <MO>, %lo(_GLOBAL_OFFSET_TABLE_+(<EndLabel>-<StartLabel>))), <MO>
240 // add <MO>, %o7, <MO>
241
242 OutStreamer->emitLabel(StartLabel);
243 if (!STI.getTargetTriple().isSPARC64() ||
244 STI.hasFeature(Sparc::TuneSlowRDPC)) {
245 MCOperand Callee = createPCXCallOP(EndLabel, OutContext);
246 EmitCall(*OutStreamer, Callee, STI);
247 } else {
248 // TODO find out whether it is possible to store PC
249 // in other registers, to enable leaf function optimization.
250 // (On the other hand, approx. over 97.8% of GETPCXes happen
251 // in non-leaf functions, so would this be worth the effort?)
252 EmitRDPC(*OutStreamer, RegO7, STI);
253 }
254 OutStreamer->emitLabel(SethiLabel);
255 MCOperand hiImm = createPCXRelExprOp(ELF::R_SPARC_PC22, GOTLabel, StartLabel,
256 SethiLabel, OutContext);
257 EmitSETHI(*OutStreamer, hiImm, MCRegOP, STI);
258 OutStreamer->emitLabel(EndLabel);
259 MCOperand loImm = createPCXRelExprOp(ELF::R_SPARC_PC10, GOTLabel, StartLabel,
260 EndLabel, OutContext);
261 EmitOR(*OutStreamer, MCRegOP, loImm, MCRegOP, STI);
262 EmitADD(*OutStreamer, MCRegOP, RegO7, MCRegOP, STI);
263}
264
265MCOperand SparcAsmPrinter::lowerOperand(const MachineOperand &MO) const {
266 switch (MO.getType()) {
267 default:
268 llvm_unreachable("unknown operand type");
269 break;
271 if (MO.isImplicit())
272 break;
273 return MCOperand::createReg(MO.getReg());
274
276 return MCOperand::createImm(MO.getImm());
277
283 auto RelType = MO.getTargetFlags();
284 const MCSymbol *Symbol = nullptr;
285 switch (MO.getType()) {
286 default:
289 Symbol = MO.getMBB()->getSymbol();
290 break;
292 Symbol = getSymbol(MO.getGlobal());
293 break;
295 Symbol = GetBlockAddressSymbol(MO.getBlockAddress());
296 break;
298 Symbol = GetExternalSymbolSymbol(MO.getSymbolName());
299 break;
301 Symbol = GetCPISymbol(MO.getIndex());
302 break;
303 }
304
305 const MCExpr *expr = MCSymbolRefExpr::create(Symbol, OutContext);
306 if (RelType)
307 expr = MCSpecifierExpr::create(expr, RelType, OutContext);
308 return MCOperand::createExpr(expr);
309 }
310
312 break;
313 }
314 return MCOperand();
315}
316
317void SparcAsmPrinter::lowerToMCInst(const MachineInstr *MI, MCInst &OutMI) {
318 OutMI.setOpcode(MI->getOpcode());
319
320 for (const MachineOperand &MO : MI->operands()) {
321 MCOperand MCOp = lowerOperand(MO);
322 if (MCOp.isValid())
323 OutMI.addOperand(MCOp);
324 }
325}
326
327void SparcAsmPrinter::emitInstruction(const MachineInstr *MI) {
328 Sparc_MC::verifyInstructionPredicates(MI->getOpcode(),
329 getSubtargetInfo().getFeatureBits());
330 if (MI->isBundle()) {
331 const MachineBasicBlock *MBB = MI->getParent();
333 while (I != MBB->instr_end() && I->isInsideBundle()) {
335 ++I;
336 }
337 return;
338 }
339
340 switch (MI->getOpcode()) {
341 default: break;
342 case TargetOpcode::DBG_VALUE:
343 // FIXME: Debug Value.
344 return;
345 case SP::CASArr:
346 case SP::SWAPrr:
347 case SP::SWAPri:
348 case SP::LDSTUBrr:
349 case SP::LDSTUBri:
350 case SP::LDSTUBArr:
351 if (MF->getSubtarget<SparcSubtarget>().fixTN0011())
352 OutStreamer->emitCodeAlignment(Align(16), getSubtargetInfo());
353 break;
354 case SP::GETPCX:
355 LowerGETPCXAndEmitMCInsts(MI, getSubtargetInfo());
356 return;
357 }
359 MachineBasicBlock::const_instr_iterator E = MI->getParent()->instr_end();
360 do {
361 MCInst TmpInst;
362 lowerToMCInst(&*I, TmpInst);
363 EmitToStreamer(*OutStreamer, TmpInst);
364 } while ((++I != E) && I->isInsideBundle()); // Delay slot check.
365}
366
367void SparcAsmPrinter::emitFunctionBodyStart() {
368 if (!MF->getSubtarget<SparcSubtarget>().is64Bit())
369 return;
370
371 const MachineRegisterInfo &MRI = MF->getRegInfo();
372 const unsigned globalRegs[] = { SP::G2, SP::G3, SP::G6, SP::G7, 0 };
373 for (unsigned i = 0; globalRegs[i] != 0; ++i) {
374 unsigned reg = globalRegs[i];
375 if (MRI.use_empty(reg))
376 continue;
377
378 if (reg == SP::G6 || reg == SP::G7)
379 getTargetStreamer().emitSparcRegisterIgnore(reg);
380 else
381 getTargetStreamer().emitSparcRegisterScratch(reg);
382 }
383}
384
385void SparcAsmPrinter::printOperand(const MachineInstr *MI, int opNum,
386 raw_ostream &O) {
387 const DataLayout &DL = getDataLayout();
388 const MachineOperand &MO = MI->getOperand(opNum);
389 switch (MO.getType()) {
391 O << "%" << StringRef(getRegisterName(MO.getReg())).lower();
392 break;
393
395 O << MO.getImm();
396 break;
398 MO.getMBB()->getSymbol()->print(O, MAI);
399 return;
401 PrintSymbolOperand(MO, O);
402 break;
404 O << GetBlockAddressSymbol(MO.getBlockAddress())->getName();
405 break;
407 O << MO.getSymbolName();
408 break;
410 O << DL.getInternalSymbolPrefix() << "CPI" << getFunctionNumber() << "_"
411 << MO.getIndex();
412 break;
414 MO.getMetadata()->printAsOperand(O, MMI->getModule());
415 break;
416 default:
417 llvm_unreachable("<unknown operand type>");
418 }
419}
420
421void SparcAsmPrinter::PrintSymbolOperand(const MachineOperand &MO,
422 raw_ostream &O) {
423 const unsigned RelType = MO.getTargetFlags();
424 StringRef Specifier = Sparc::getSpecifierName(RelType);
425 if (!Specifier.empty())
426 O << '%' << Specifier << '(';
428 if (!Specifier.empty())
429 O << ')';
430}
431
432void SparcAsmPrinter::printMemOperand(const MachineInstr *MI, int opNum,
433 raw_ostream &O) {
434 printOperand(MI, opNum, O);
435
436 if (MI->getOperand(opNum+1).isReg() &&
437 MI->getOperand(opNum+1).getReg() == SP::G0)
438 return; // don't print "+%g0"
439 if (MI->getOperand(opNum+1).isImm() &&
440 MI->getOperand(opNum+1).getImm() == 0)
441 return; // don't print "+0"
442
443 O << "+";
444 printOperand(MI, opNum+1, O);
445}
446
447/// PrintAsmOperand - Print out an operand for an inline asm expression.
448///
449bool SparcAsmPrinter::PrintAsmOperand(const MachineInstr *MI, unsigned OpNo,
450 const char *ExtraCode,
451 raw_ostream &O) {
452 if (ExtraCode && ExtraCode[0]) {
453 if (ExtraCode[1] != 0) return true; // Unknown modifier.
454
455 switch (ExtraCode[0]) {
456 default:
457 // See if this is a generic print operand
458 return AsmPrinter::PrintAsmOperand(MI, OpNo, ExtraCode, O);
459 case 'L': // Low order register of a twin word register operand
460 case 'H': // High order register of a twin word register operand
461 {
462 const SparcSubtarget &Subtarget = MF->getSubtarget<SparcSubtarget>();
463 const MachineOperand &MO = MI->getOperand(OpNo);
464 const SparcRegisterInfo *RegisterInfo = Subtarget.getRegisterInfo();
465 Register MOReg = MO.getReg();
466
467 Register HiReg, LoReg;
468 if (!SP::IntPairRegClass.contains(MOReg)) {
469 // If we aren't given a register pair already, find out which pair it
470 // belongs to. Note that here, the specified register operand, which
471 // refers to the high part of the twinword, needs to be an even-numbered
472 // register.
473 MOReg = RegisterInfo->getMatchingSuperReg(MOReg, SP::sub_even,
474 &SP::IntPairRegClass);
475 if (!MOReg) {
476 SMLoc Loc;
477 OutContext.reportError(
478 Loc, "Hi part of pair should point to an even-numbered register");
479 OutContext.reportError(
480 Loc, "(note that in some cases it might be necessary to manually "
481 "bind the input/output registers instead of relying on "
482 "automatic allocation)");
483 return true;
484 }
485 }
486
487 HiReg = RegisterInfo->getSubReg(MOReg, SP::sub_even);
488 LoReg = RegisterInfo->getSubReg(MOReg, SP::sub_odd);
489
491 switch (ExtraCode[0]) {
492 case 'L':
493 Reg = LoReg;
494 break;
495 case 'H':
496 Reg = HiReg;
497 break;
498 }
499
501 return false;
502 }
503 case 'f':
504 case 'r':
505 break;
506 }
507 }
508
509 printOperand(MI, OpNo, O);
510
511 return false;
512}
513
514bool SparcAsmPrinter::PrintAsmMemoryOperand(const MachineInstr *MI,
515 unsigned OpNo,
516 const char *ExtraCode,
517 raw_ostream &O) {
518 if (ExtraCode && ExtraCode[0])
519 return true; // Unknown modifier
520
521 O << '[';
522 printMemOperand(MI, OpNo, O);
523 O << ']';
524
525 return false;
526}
527
528char SparcAsmPrinter::ID = 0;
529
530INITIALIZE_PASS(SparcAsmPrinter, "sparc-asm-printer", "Sparc Assembly Printer",
531 false, false)
532
533// Force static initialization.
535LLVMInitializeSparcAsmPrinter() {
539}
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
unsigned Imm
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
#define X(NUM, ENUM, NAME)
Definition ELF.h:857
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
#define LLVM_ABI
Definition Compiler.h:215
#define LLVM_EXTERNAL_VISIBILITY
Definition Compiler.h:132
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
static std::string getRegisterName(const TargetRegisterInfo *TRI, Register Reg)
Register Reg
Promote Memory to Register
Definition Mem2Reg.cpp:110
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
static bool contains(SmallPtrSetImpl< ConstantExpr * > &Cache, ConstantExpr *Expr, Constant *C)
Definition Value.cpp:484
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
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 createPCXRelExprOp(uint16_t Spec, MCSymbol *GOTLabel, MCSymbol *StartLabel, MCSymbol *CurLabel, MCContext &OutContext)
static MCOperand createPCXCallOP(MCSymbol *Label, MCContext &OutContext)
static void EmitSHL(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void EmitCall(MCStreamer &OutStreamer, MCOperand &Callee, const MCSubtargetInfo &STI)
static MCOperand createSparcMCOperand(uint16_t Kind, MCSymbol *Sym, MCContext &OutContext)
static void EmitSETHI(MCStreamer &OutStreamer, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void EmitOR(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &Imm, MCOperand &RD, const MCSubtargetInfo &STI)
static void EmitBinary(MCStreamer &OutStreamer, unsigned Opcode, MCOperand &RS1, MCOperand &Src2, MCOperand &RD, const MCSubtargetInfo &STI)
static void EmitRDPC(MCStreamer &OutStreamer, MCOperand &RD, const MCSubtargetInfo &STI)
static void emitHiLo(MCStreamer &OutStreamer, MCSymbol *GOTSym, uint16_t HiKind, uint16_t LoKind, MCOperand &RD, MCContext &OutContext, const MCSubtargetInfo &STI)
static void EmitADD(MCStreamer &OutStreamer, MCOperand &RS1, MCOperand &RS2, MCOperand &RD, const MCSubtargetInfo &STI)
std::unique_ptr< MCStreamer > && Streamer
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
This class is intended to be used as a driving class for all asm writers.
Definition AsmPrinter.h:91
virtual void PrintSymbolOperand(const MachineOperand &MO, raw_ostream &OS)
Print the MachineOperand as a symbol.
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 class represents a function call, abstracting a target machine's calling convention.
Binary assembler expressions.
Definition MCExpr.h:298
static const MCBinaryExpr * createAdd(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:342
static const MCBinaryExpr * createSub(const MCExpr *LHS, const MCExpr *RHS, MCContext &Ctx)
Definition MCExpr.h:427
static LLVM_ABI const MCConstantExpr * create(int64_t Value, MCContext &Ctx, bool PrintInHex=false, unsigned SizeInBytes=0)
Definition MCExpr.cpp:212
Context object for machine code objects.
Definition MCContext.h:83
Instances of this class represent a single low-level machine instruction.
Definition MCInst.h:188
void addOperand(const MCOperand Op)
Definition MCInst.h:215
void setOpcode(unsigned Op)
Definition MCInst.h:201
Instances of this class represent operands of the MCInst class.
Definition MCInst.h:40
static MCOperand createExpr(const MCExpr *Val)
Definition MCInst.h:166
static MCOperand createReg(MCRegister Reg)
Definition MCInst.h:138
static MCOperand createImm(int64_t Val)
Definition MCInst.h:145
bool isValid() const
Definition MCInst.h:64
Wrapper class representing physical registers. Should be passed by value.
Definition MCRegister.h:41
static const MCSpecifierExpr * create(const MCExpr *Expr, Spec S, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.cpp:743
Streaming machine code generation interface.
Definition MCStreamer.h:222
virtual void emitInstruction(const MCInst &Inst, const MCSubtargetInfo &STI)
Emit the given Instruction into the current section.
Generic base class for all target subtargets.
bool hasFeature(unsigned Feature) const
const Triple & getTargetTriple() const
Represent a reference to a symbol from inside an expression.
Definition MCExpr.h:190
static const MCSymbolRefExpr * create(const MCSymbol *Symbol, MCContext &Ctx, SMLoc Loc=SMLoc())
Definition MCExpr.h:213
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition MCSymbol.h:42
LLVM_ABI void print(raw_ostream &OS, const MCAsmInfo *MAI) const
print - Print the value to the stream OS.
Definition MCSymbol.cpp:59
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Instructions::const_iterator const_instr_iterator
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
int64_t getImm() const
const MDNode * getMetadata() const
MachineBasicBlock * getMBB() const
const BlockAddress * getBlockAddress() const
unsigned getTargetFlags() const
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
const char * getSymbolName() const
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_RegisterMask
Mask of preserved registers.
@ MO_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_Metadata
Metadata reference (for debug info)
bool use_empty(Register RegNo) const
use_empty - Return true if there are no instructions using the specified register.
LLVM_ABI void printAsOperand(raw_ostream &OS, const Module *M=nullptr) const
Print as operand.
static const char * getRegisterName(MCRegister Reg, unsigned AltIdx=SP::NoRegAltName)
const SparcRegisterInfo * getRegisterInfo() const override
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
Primary interface to the complete machine description for the target machine.
bool isSPARC64() const
Tests whether the target is 64-bit SPARC (big endian).
Definition Triple.h:1187
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
StringRef getSpecifierName(uint16_t S)
void emitInstruction(MCObjectStreamer &, const MCInst &Inst, const MCSubtargetInfo &STI)
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheSparcTarget()
Target & getTheSparcV9Target()
@ Sub
Subtraction of integers.
@ Add
Sum of integers.
Target & getTheSparcelTarget()
ArrayRef< int > lo(ArrayRef< int > Vuu)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...