LLVM  4.0.0
BPFMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- BPFMCTargetDesc.cpp - BPF Target Descriptions ---------------------===//
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 provides BPF specific target descriptions.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #include "BPF.h"
18 #include "llvm/MC/MCInstrInfo.h"
19 #include "llvm/MC/MCRegisterInfo.h"
21 #include "llvm/Support/Host.h"
23 
24 #define GET_INSTRINFO_MC_DESC
25 #include "BPFGenInstrInfo.inc"
26 
27 #define GET_SUBTARGETINFO_MC_DESC
28 #include "BPFGenSubtargetInfo.inc"
29 
30 #define GET_REGINFO_MC_DESC
31 #include "BPFGenRegisterInfo.inc"
32 
33 using namespace llvm;
34 
36  MCInstrInfo *X = new MCInstrInfo();
37  InitBPFMCInstrInfo(X);
38  return X;
39 }
40 
43  InitBPFMCRegisterInfo(X, BPF::R11 /* RAReg doesn't exist */);
44  return X;
45 }
46 
48  StringRef CPU, StringRef FS) {
49  return createBPFMCSubtargetInfoImpl(TT, CPU, FS);
50 }
51 
53  MCContext &Ctx, MCAsmBackend &MAB,
54  raw_pwrite_stream &OS, MCCodeEmitter *Emitter,
55  bool RelaxAll) {
56  return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
57 }
58 
60  unsigned SyntaxVariant,
61  const MCAsmInfo &MAI,
62  const MCInstrInfo &MII,
63  const MCRegisterInfo &MRI) {
64  if (SyntaxVariant == 0)
65  return new BPFInstPrinter(MAI, MII, MRI);
66  return nullptr;
67 }
68 
69 extern "C" void LLVMInitializeBPFTargetMC() {
70  for (Target *T :
72  // Register the MC asm info.
74 
75  // Register the MC instruction info.
77 
78  // Register the MC register info.
80 
81  // Register the MC subtarget info.
84 
85  // Register the object streamer
87 
88  // Register the MCInstPrinter.
90  }
91 
92  // Register the MC code emitter
97 
98  // Register the ASM Backend
103 
109  } else {
114  }
115 }
static MCSubtargetInfo * createBPFMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
MCAsmBackend * createBPFAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
Context object for machine code objects.
Definition: MCContext.h:51
MCCodeEmitter * createBPFbeMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
static const bool IsLittleEndianHost
Definition: Host.h:40
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:57
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Streaming machine code generation interface.
Definition: MCStreamer.h:161
unsigned const MachineRegisterInfo * MRI
void LLVMInitializeBPFTargetMC()
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang","erlang-compatible garbage collector")
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
MCAsmBackend * createBPFbeAsmBackend(const Target &T, const MCRegisterInfo &MRI, const Triple &TT, StringRef CPU, const MCTargetOptions &Options)
RegisterMCAsmInfo - Helper template for registering a target assembly info implementation.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
MCStreamer * createELFStreamer(MCContext &Ctx, MCAsmBackend &TAB, raw_pwrite_stream &OS, MCCodeEmitter *CE, bool RelaxAll)
Takes ownership of TAB and CE.
static MCInstPrinter * createBPFMCInstPrinter(const Triple &T, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
static MCInstrInfo * createBPFMCInstrInfo()
static MCStreamer * createBPFMCStreamer(const Triple &T, MCContext &Ctx, MCAsmBackend &MAB, raw_pwrite_stream &OS, MCCodeEmitter *Emitter, bool RelaxAll)
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:41
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
MCSubtargetInfo - Generic base class for all target subtargets.
static void RegisterELFStreamer(Target &T, Target::ELFStreamerCtorTy Fn)
An abstract base class for streams implementations that also support a pwrite operation.
Definition: raw_ostream.h:333
Target & getTheBPFleTarget()
cl::opt< bool > RelaxAll("mc-relax-all", cl::desc("When used with filetype=obj, ""relax all fixups in the emitted object file"))
static MCRegisterInfo * createBPFMCRegisterInfo(const Triple &TT)
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:36
MCCodeEmitter * createBPFMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
Target & getTheBPFbeTarget()
Target & getTheBPFTarget()