LLVM  5.0.0
BPFAsmPrinter.cpp
Go to the documentation of this file.
1 //===-- BPFAsmPrinter.cpp - BPF LLVM assembly writer ----------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file contains a printer that converts from our internal representation
11 // of machine-dependent LLVM code to the BPF assembly language.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #include "BPF.h"
16 #include "BPFInstrInfo.h"
17 #include "BPFMCInstLower.h"
18 #include "BPFTargetMachine.h"
25 #include "llvm/MC/MCAsmInfo.h"
26 #include "llvm/MC/MCInst.h"
27 #include "llvm/MC/MCStreamer.h"
28 #include "llvm/MC/MCSymbol.h"
31 using namespace llvm;
32 
33 #define DEBUG_TYPE "asm-printer"
34 
35 namespace {
36 class BPFAsmPrinter : public AsmPrinter {
37 public:
38  explicit BPFAsmPrinter(TargetMachine &TM,
39  std::unique_ptr<MCStreamer> Streamer)
40  : AsmPrinter(TM, std::move(Streamer)) {}
41 
42  StringRef getPassName() const override { return "BPF Assembly Printer"; }
43 
44  void EmitInstruction(const MachineInstr *MI) override;
45 };
46 } // namespace
47 
48 void BPFAsmPrinter::EmitInstruction(const MachineInstr *MI) {
49 
50  BPFMCInstLower MCInstLowering(OutContext, *this);
51 
52  MCInst TmpInst;
53  MCInstLowering.Lower(MI, TmpInst);
54  EmitToStreamer(*OutStreamer, TmpInst);
55 }
56 
57 // Force static initialization.
58 extern "C" void LLVMInitializeBPFAsmPrinter() {
62 }
This file declares the MachineConstantPool class which is an abstract constant pool to keep track of ...
zlib-gnu style compression
Instances of this class represent a single low-level machine instruction.
Definition: MCInst.h:159
This class is intended to be used as a driving class for all asm writers.
Definition: AsmPrinter.h:76
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
Representation of each machine instruction.
Definition: MachineInstr.h:59
Target & getTheBPFleTarget()
RegisterAsmPrinter - Helper template for registering a target specific assembly printer, for use in the target machine initialization function.
void LLVMInitializeBPFAsmPrinter()
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:56
IRTranslator LLVM IR MI
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml","ocaml 3.10-compatible collector")
Target & getTheBPFbeTarget()
Target & getTheBPFTarget()