1 //===-- WebAssemblyMCTargetDesc.cpp - WebAssembly Target Descriptions -----===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file provides WebAssembly-specific target descriptions.
13 //===----------------------------------------------------------------------===//
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"
27 #define DEBUG_TYPE "wasm-mc-target-desc"
29 #define GET_INSTRINFO_MC_DESC
30 #include "WebAssemblyGenInstrInfo.inc"
32 #define GET_SUBTARGETINFO_MC_DESC
33 #include "WebAssemblyGenSubtargetInfo.inc"
35 #define GET_REGINFO_MC_DESC
36 #include "WebAssemblyGenRegisterInfo.inc"
38 static MCAsmInfo *createWebAssemblyMCAsmInfo(const MCRegisterInfo &MRI,
40 MCAsmInfo *MAI = new WebAssemblyMCAsmInfo(TT);
44 static MCInstPrinter *
45 createWebAssemblyMCInstPrinter(const Triple &T, unsigned SyntaxVariant,
46 const MCAsmInfo &MAI, const MCInstrInfo &MII,
47 const MCRegisterInfo &MRI) {
48 if (SyntaxVariant == 0 || SyntaxVariant == 1)
49 return new WebAssemblyInstPrinter(MAI, MII, MRI);
53 // Force static initialization.
54 extern "C" void LLVMInitializeWebAssemblyTargetMC() {
55 for (Target *T : {&TheWebAssemblyTarget32, &TheWebAssemblyTarget64}) {
56 // Register the MC asm info.
57 RegisterMCAsmInfoFn X(*T, createWebAssemblyMCAsmInfo);
59 // Register the MCInstPrinter.
60 TargetRegistry::RegisterMCInstPrinter(*T, createWebAssemblyMCInstPrinter);