34#define DEBUG_TYPE "asm-printer"
40 std::unique_ptr<MCStreamer> Streamer)
43 StringRef getPassName()
const override {
return "BPF Assembly Printer"; }
44 bool doInitialization(
Module &M)
override;
60bool BPFAsmPrinter::doInitialization(
Module &M) {
64 if (MAI->doesSupportDebugInformation() && !
M.debug_compile_units().empty()) {
65 BTF =
new BTFDebug(
this);
66 Handlers.push_back(std::unique_ptr<BTFDebug>(BTF));
72void BPFAsmPrinter::printOperand(
const MachineInstr *
MI,
int OpNum,
74 const MachineOperand &MO =
MI->getOperand(OpNum);
110bool BPFAsmPrinter::PrintAsmOperand(
const MachineInstr *
MI,
unsigned OpNo,
111 const char *ExtraCode, raw_ostream &O) {
112 if (ExtraCode && ExtraCode[0])
119bool BPFAsmPrinter::PrintAsmMemoryOperand(
const MachineInstr *
MI,
120 unsigned OpNum,
const char *ExtraCode,
122 assert(OpNum + 1 <
MI->getNumOperands() &&
"Insufficient operands");
123 const MachineOperand &BaseMO =
MI->getOperand(OpNum);
124 const MachineOperand &OffsetMO =
MI->getOperand(OpNum + 1);
125 assert(BaseMO.
isReg() &&
"Unexpected base pointer for inline asm memory operand.");
126 assert(OffsetMO.
isImm() &&
"Unexpected offset for inline asm memory operand.");
140void BPFAsmPrinter::emitInstruction(
const MachineInstr *
MI) {
141 BPF_MC::verifyInstructionPredicates(
MI->getOpcode(),
142 getSubtargetInfo().getFeatureBits());
147 BPFMCInstLower MCInstLowering(OutContext, *
this);
148 MCInstLowering.Lower(
MI, TmpInst);
150 EmitToStreamer(*OutStreamer, TmpInst);
153char BPFAsmPrinter::ID = 0;
160LLVMInitializeBPFAsmPrinter() {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file contains support for writing BTF debug info.
#define LLVM_EXTERNAL_VISIBILITY
Module.h This file contains the declarations for the Module class.
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static bool printOperand(raw_ostream &OS, const SelectionDAG *G, const SDValue Value)
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static TableGen::Emitter::OptClass< SkeletonEmitter > X("gen-skeleton-class", "Generate example skeleton class")
This class is intended to be used as a driving class for all asm writers.
bool doInitialization(Module &M) override
Set up the AsmPrinter when we are working on a new module.
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.
static const char * getRegisterName(MCRegister Reg)
Collect and emit BTF information.
bool InstLower(const MachineInstr *MI, MCInst &OutMI)
Emit proper patchable instructions.
StringRef getName() const
getName - Get the symbol name.
LLVM_ABI MCSymbol * getSymbol() const
Return the MCSymbol for this basic block.
Representation of each machine instruction.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
MachineBasicBlock * getMBB() const
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
const BlockAddress * getBlockAddress() 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_BlockAddress
Address of a basic block.
@ MO_MachineBasicBlock
MachineBasicBlock reference.
@ MO_Register
Register operand.
@ MO_ExternalSymbol
Name of external global symbol.
@ MO_JumpTableIndex
Address of indexed Jump Table for switch.
A Module instance is used to store all the information related to an LLVM module.
StringRef - Represent a constant reference to a string, i.e.
Primary interface to the complete machine description for the target machine.
This class implements an extremely fast bulk output stream that can only output to a stream.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
Target & getTheBPFleTarget()
Target & getTheBPFbeTarget()
Target & getTheBPFTarget()
RegisterAsmPrinter - Helper template for registering a target specific assembly printer,...