Go to the documentation of this file.
34 #define DEBUG_TYPE "asm-printer"
37 "Number of RISC-V Compressed instructions emitted");
46 std::unique_ptr<MCStreamer> Streamer)
49 StringRef getPassName()
const override {
return "RISCV Assembly Printer"; }
61 bool emitPseudoExpansionLowering(
MCStreamer &OutStreamer,
69 void emitStartOfAsmFile(
Module &M)
override;
70 void emitEndOfAsmFile(
Module &M)
override;
72 void emitFunctionEntryLabel()
override;
75 void emitAttributes();
79 #define GEN_COMPRESS_INSTR
80 #include "RISCVGenCompressInstEmitter.inc"
83 bool Res = compressInst(CInst, Inst, *STI, OutStreamer->getContext());
85 ++RISCVNumInstrsCompressed;
91 #include "RISCVGenMCPseudoLowering.inc"
95 if (emitPseudoExpansionLowering(*OutStreamer,
MI))
100 EmitToStreamer(*OutStreamer, TmpInst);
103 bool RISCVAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
110 if (ExtraCode && ExtraCode[0]) {
111 if (ExtraCode[1] != 0)
114 switch (ExtraCode[0]) {
138 PrintSymbolOperand(MO, OS);
152 bool RISCVAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
154 const char *ExtraCode,
174 OutStreamer->getContext().getSubtargetCopy(*
TM.getMCSubtargetInfo());
179 SetupMachineFunction(MF);
184 void RISCVAsmPrinter::emitStartOfAsmFile(
Module &M) {
185 if (
TM.getTargetTriple().isOSBinFormatELF())
189 void RISCVAsmPrinter::emitEndOfAsmFile(
Module &M) {
193 if (
TM.getTargetTriple().isOSBinFormatELF())
197 void RISCVAsmPrinter::emitAttributes() {
203 void RISCVAsmPrinter::emitFunctionEntryLabel() {
@ 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 ...
void emitTargetAttributes(const MCSubtargetInfo &STI)
Target & getTheRISCV64Target()
const BlockAddress * getBlockAddress() const
void setFeatureBits(const FeatureBitset &FeatureBits_)
Instances of this class represent a single low-level machine instruction.
@ MO_Register
Register operand.
void EmitToStreamer(MCStreamer &S, const MCInst &Inst)
Streaming machine code generation interface.
@ MO_GlobalAddress
Address of a global value.
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...
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
bool lowerRISCVMachineInstrToMCInst(const MachineInstr *MI, MCInst &OutMI, AsmPrinter &AP)
virtual void emitFunctionEntryLabel()
EmitFunctionEntryLabel - Emit the label that is the entrypoint for the function.
MachineOperand class - Representation of each machine instruction operand.
const FeatureBitset & getFeatureBits() const
STATISTIC(NumFunctions, "Total number of functions")
This class implements an extremely fast bulk output stream that can only output to a stream.
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")
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Representation of each machine instruction.
#define LLVM_EXTERNAL_VISIBILITY
bool lowerRISCVMachineOperandToMCOperand(const MachineOperand &MO, MCOperand &MCOp, const AsmPrinter &AP)
MachineOperandType getType() const
getType - Returns the MachineOperandType for this operand.
Primary interface to the complete machine description for the target machine.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Register getReg() const
getReg - Returns the register number.
A Module instance is used to store all the information related to an LLVM module.
virtual void finishAttributeSection()
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeRISCVAsmPrinter()
StringRef - Represent a constant reference to a string, i.e.
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
void setTargetABI(RISCVABI::ABI ABI)
This class is intended to be used as a driving class for all asm writers.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
const char LLVMTargetMachineRef TM
Instances of this class represent operands of the MCInst class.
static const char * getRegisterName(unsigned RegNo)
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...
Generic base class for all target subtargets.
Target & getTheRISCV32Target()
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.