LLVM  8.0.1
RISCVMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- RISCVMCTargetDesc.cpp - RISCV 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 RISCV-specific target descriptions.
11 ///
12 //===----------------------------------------------------------------------===//
13 
14 #include "RISCVMCTargetDesc.h"
16 #include "RISCVELFStreamer.h"
17 #include "RISCVMCAsmInfo.h"
18 #include "RISCVTargetStreamer.h"
19 #include "llvm/ADT/STLExtras.h"
20 #include "llvm/MC/MCAsmInfo.h"
21 #include "llvm/MC/MCInstrInfo.h"
22 #include "llvm/MC/MCRegisterInfo.h"
23 #include "llvm/MC/MCStreamer.h"
27 
28 #define GET_INSTRINFO_MC_DESC
29 #include "RISCVGenInstrInfo.inc"
30 
31 #define GET_REGINFO_MC_DESC
32 #include "RISCVGenRegisterInfo.inc"
33 
34 #define GET_SUBTARGETINFO_MC_DESC
35 #include "RISCVGenSubtargetInfo.inc"
36 
37 using namespace llvm;
38 
40  MCInstrInfo *X = new MCInstrInfo();
41  InitRISCVMCInstrInfo(X);
42  return X;
43 }
44 
47  InitRISCVMCRegisterInfo(X, RISCV::X1);
48  return X;
49 }
50 
52  const Triple &TT) {
53  return new RISCVMCAsmInfo(TT);
54 }
55 
57  StringRef CPU, StringRef FS) {
58  std::string CPUName = CPU;
59  if (CPUName.empty())
60  CPUName = TT.isArch64Bit() ? "generic-rv64" : "generic-rv32";
61  return createRISCVMCSubtargetInfoImpl(TT, CPUName, FS);
62 }
63 
65  unsigned SyntaxVariant,
66  const MCAsmInfo &MAI,
67  const MCInstrInfo &MII,
68  const MCRegisterInfo &MRI) {
69  return new RISCVInstPrinter(MAI, MII, MRI);
70 }
71 
72 static MCTargetStreamer *
74  const Triple &TT = STI.getTargetTriple();
75  if (TT.isOSBinFormatELF())
76  return new RISCVTargetELFStreamer(S, STI);
77  return nullptr;
78 }
79 
82  MCInstPrinter *InstPrint,
83  bool isVerboseAsm) {
84  return new RISCVTargetAsmStreamer(S, OS);
85 }
86 
87 extern "C" void LLVMInitializeRISCVTargetMC() {
98 
99  // Register the asm target streamer.
101  }
102 }
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
MCAsmBackend * createRISCVAsmBackend(const Target &T, const MCSubtargetInfo &STI, const MCRegisterInfo &MRI, const MCTargetOptions &Options)
This class represents lattice values for constants.
Definition: AllocatorList.h:24
static MCSubtargetInfo * createRISCVMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
bool isOSBinFormatELF() const
Tests whether the OS uses the ELF binary format.
Definition: Triple.h:604
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Target specific streamer interface.
Definition: MCStreamer.h:84
static MCTargetStreamer * createRISCVAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *InstPrint, bool isVerboseAsm)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
const Triple & getTargetTriple() const
Target & getTheRISCV32Target()
static MCTargetStreamer * createRISCVObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
MCCodeEmitter * createRISCVMCCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &MRI, MCContext &Ctx)
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:56
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:189
unsigned const MachineRegisterInfo * MRI
Target & getTheRISCV64Target()
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static MCAsmInfo * createRISCVMCAsmInfo(const MCRegisterInfo &MRI, const Triple &TT)
static void RegisterMCAsmInfo(Target &T, Target::MCAsmInfoCtorFnTy Fn)
RegisterMCAsmInfo - Register a MCAsmInfo implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target...
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static MCRegisterInfo * createRISCVMCRegisterInfo(const Triple &TT)
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static MCInstPrinter * createRISCVMCInstPrinter(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.
void LLVMInitializeRISCVTargetMC()
static MCInstrInfo * createRISCVMCInstrInfo()
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:40
bool isArch64Bit() const
Test whether the architecture is 64-bit.
Definition: Triple.cpp:1269
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
Generic base class for all target subtargets.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49