LLVM  8.0.1
WebAssemblyMCTargetDesc.cpp
Go to the documentation of this file.
1 //===-- WebAssemblyMCTargetDesc.cpp - WebAssembly 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 /// \file
11 /// This file provides WebAssembly-specific target descriptions.
12 ///
13 //===----------------------------------------------------------------------===//
14 
17 #include "WebAssemblyMCAsmInfo.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
24 using namespace llvm;
25 
26 #define DEBUG_TYPE "wasm-mc-target-desc"
27 
28 #define GET_INSTRINFO_MC_DESC
29 #include "WebAssemblyGenInstrInfo.inc"
30 
31 #define GET_SUBTARGETINFO_MC_DESC
32 #include "WebAssemblyGenSubtargetInfo.inc"
33 
34 #define GET_REGINFO_MC_DESC
35 #include "WebAssemblyGenRegisterInfo.inc"
36 
37 static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & /*MRI*/,
38  const Triple &TT) {
39  return new WebAssemblyMCAsmInfo(TT);
40 }
41 
43  MCInstrInfo *X = new MCInstrInfo();
44  InitWebAssemblyMCInstrInfo(X);
45  return X;
46 }
47 
48 static MCRegisterInfo *createMCRegisterInfo(const Triple & /*T*/) {
50  InitWebAssemblyMCRegisterInfo(X, 0);
51  return X;
52 }
53 
55  unsigned SyntaxVariant,
56  const MCAsmInfo &MAI,
57  const MCInstrInfo &MII,
58  const MCRegisterInfo &MRI) {
59  assert(SyntaxVariant == 0 && "WebAssembly only has one syntax variant");
60  return new WebAssemblyInstPrinter(MAI, MII, MRI);
61 }
62 
64  const MCRegisterInfo & /*MRI*/,
65  MCContext &Ctx) {
66  return createWebAssemblyMCCodeEmitter(MCII);
67 }
68 
69 static MCAsmBackend *createAsmBackend(const Target & /*T*/,
70  const MCSubtargetInfo &STI,
71  const MCRegisterInfo & /*MRI*/,
72  const MCTargetOptions & /*Options*/) {
74 }
75 
77  StringRef FS) {
78  return createWebAssemblyMCSubtargetInfoImpl(TT, CPU, FS);
79 }
80 
81 static MCTargetStreamer *
83  return new WebAssemblyTargetWasmStreamer(S);
84 }
85 
88  MCInstPrinter * /*InstPrint*/,
89  bool /*isVerboseAsm*/) {
90  return new WebAssemblyTargetAsmStreamer(S, OS);
91 }
92 
94  return new WebAssemblyTargetNullStreamer(S);
95 }
96 
97 // Force static initialization.
99  for (Target *T :
101  // Register the MC asm info.
103 
104  // Register the MC instruction info.
106 
107  // Register the MC register info.
109 
110  // Register the MCInstPrinter.
112 
113  // Register the MC code emitter.
115 
116  // Register the ASM Backend.
118 
119  // Register the MC subtarget info.
121 
122  // Register the object target streamer.
125  // Register the asm target streamer.
127  // Register the null target streamer.
129  }
130 }
131 
133  switch (Ty.SimpleTy) {
134  case MVT::i32:
135  return wasm::ValType::I32;
136  case MVT::i64:
137  return wasm::ValType::I64;
138  case MVT::f32:
139  return wasm::ValType::F32;
140  case MVT::f64:
141  return wasm::ValType::F64;
142  case MVT::v16i8:
143  case MVT::v8i16:
144  case MVT::v4i32:
145  case MVT::v2i64:
146  case MVT::v4f32:
147  case MVT::v2f64:
148  return wasm::ValType::V128;
149  case MVT::ExceptRef:
151  default:
152  llvm_unreachable("unexpected type");
153  }
154 }
static MCInstrInfo * createMCInstrInfo()
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This class represents lattice values for constants.
Definition: AllocatorList.h:24
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This class prints an WebAssembly MCInst to wasm file syntax.
Target specific streamer interface.
Definition: MCStreamer.h:84
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static MCAsmBackend * createAsmBackend(const Target &, const MCSubtargetInfo &STI, const MCRegisterInfo &, const MCTargetOptions &)
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
const Triple & getTargetTriple() const
SimpleValueType SimpleTy
Context object for machine code objects.
Definition: MCContext.h:63
wasm::ValType toValType(const MVT &Ty)
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 MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *, bool)
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
Machine Value Type.
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII)
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:22
This file provides WebAssembly-specific target descriptions.
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:24
static MCRegisterInfo * createMCRegisterInfo(const Triple &)
static MCCodeEmitter * createCodeEmitter(const MCInstrInfo &MCII, const MCRegisterInfo &, MCContext &Ctx)
This part is for ascii assembly output.
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)
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
This file declares WebAssembly-specific target streamer classes.
static MCSubtargetInfo * createMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Target - Wrapper for Target specific information.
This file contains the declaration of the WebAssemblyMCAsmInfo class.
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:40
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target. ...
This part is for Wasm object output.
Generic base class for all target subtargets.
void LLVMInitializeWebAssemblyTargetMC()
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
static MCInstPrinter * createMCInstPrinter(const Triple &, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
static MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &, const Triple &TT)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:49
Target & getTheWebAssemblyTarget32()
Target & getTheWebAssemblyTarget64()