0644fd80bdf141e2a18eaeb6e1b454d9787d25a6
[oota-llvm.git] / lib / Target / WebAssembly / MCTargetDesc / WebAssemblyMCTargetDesc.cpp
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 /// \brief This file provides WebAssembly-specific target descriptions.
12 ///
13 //===----------------------------------------------------------------------===//
14
15 #include "WebAssemblyMCTargetDesc.h"
16 #include "InstPrinter/WebAssemblyInstPrinter.h"
17 #include "WebAssemblyMCAsmInfo.h"
18 #include "llvm/MC/MCCodeGenInfo.h"
19 #include "llvm/MC/MCInstrInfo.h"
20 #include "llvm/MC/MCRegisterInfo.h"
21 #include "llvm/MC/MCStreamer.h"
22 #include "llvm/MC/MCSubtargetInfo.h"
23 #include "llvm/Support/ErrorHandling.h"
24 #include "llvm/Support/TargetRegistry.h"
25 using namespace llvm;
26
27 #define DEBUG_TYPE "wasm-mc-target-desc"
28
29 #define GET_INSTRINFO_MC_DESC
30 #include "WebAssemblyGenInstrInfo.inc"
31
32 #define GET_SUBTARGETINFO_MC_DESC
33 #include "WebAssemblyGenSubtargetInfo.inc"
34
35 #define GET_REGINFO_MC_DESC
36 #include "WebAssemblyGenRegisterInfo.inc"
37
38 static MCAsmInfo *createWebAssemblyMCAsmInfo(const MCRegisterInfo &MRI,
39                                              const Triple &TT) {
40   return new WebAssemblyMCAsmInfo(TT);
41 }
42
43 static MCInstPrinter *
44 createWebAssemblyMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
45                                const MCAsmInfo &MAI, const MCInstrInfo &MII,
46                                const MCRegisterInfo &MRI) {
47   assert(SyntaxVariant == 0);
48   return new WebAssemblyInstPrinter(MAI, MII, MRI);
49 }
50
51 // Force static initialization.
52 extern "C" void LLVMInitializeWebAssemblyTargetMC() {
53   for (Target *T : {&TheWebAssemblyTarget32, &TheWebAssemblyTarget64}) {
54     // Register the MC asm info.
55     RegisterMCAsmInfoFn X(*T, createWebAssemblyMCAsmInfo);
56
57     // Register the MCInstPrinter.
58     TargetRegistry::RegisterMCInstPrinter(*T, createWebAssemblyMCInstPrinter);
59   }
60 }