Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 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 | |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 29 | #define GET_INSTRINFO_MC_DESC |
| 30 | #include "WebAssemblyGenInstrInfo.inc" |
| 31 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 32 | #define GET_SUBTARGETINFO_MC_DESC |
| 33 | #include "WebAssemblyGenSubtargetInfo.inc" |
| 34 | |
JF Bastien | 5ca0bac | 2015-07-10 18:23:10 +0000 | [diff] [blame] | 35 | #define GET_REGINFO_MC_DESC |
| 36 | #include "WebAssemblyGenRegisterInfo.inc" |
| 37 | |
Dan Gohman | 7a6b982 | 2015-11-29 22:32:02 +0000 | [diff] [blame^] | 38 | static MCAsmInfo *createWebAssemblyMCAsmInfo(const MCRegisterInfo & /*MRI*/, |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 39 | const Triple &TT) { |
JF Bastien | ae7eebd | 2015-07-28 17:23:07 +0000 | [diff] [blame] | 40 | return new WebAssemblyMCAsmInfo(TT); |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 41 | } |
| 42 | |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 43 | static MCInstrInfo *createWebAssemblyMCInstrInfo() { |
| 44 | MCInstrInfo *X = new MCInstrInfo(); |
| 45 | InitWebAssemblyMCInstrInfo(X); |
| 46 | return X; |
| 47 | } |
| 48 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 49 | static MCInstPrinter * |
Dan Gohman | 7a6b982 | 2015-11-29 22:32:02 +0000 | [diff] [blame^] | 50 | createWebAssemblyMCInstPrinter(const Triple & /*T*/, unsigned SyntaxVariant, |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 51 | const MCAsmInfo &MAI, const MCInstrInfo &MII, |
| 52 | const MCRegisterInfo &MRI) { |
JF Bastien | ae7eebd | 2015-07-28 17:23:07 +0000 | [diff] [blame] | 53 | assert(SyntaxVariant == 0); |
| 54 | return new WebAssemblyInstPrinter(MAI, MII, MRI); |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 55 | } |
| 56 | |
| 57 | // Force static initialization. |
| 58 | extern "C" void LLVMInitializeWebAssemblyTargetMC() { |
Dan Gohman | d82494b | 2015-07-01 21:42:34 +0000 | [diff] [blame] | 59 | for (Target *T : {&TheWebAssemblyTarget32, &TheWebAssemblyTarget64}) { |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 60 | // Register the MC asm info. |
| 61 | RegisterMCAsmInfoFn X(*T, createWebAssemblyMCAsmInfo); |
| 62 | |
Dan Gohman | e9361d5 | 2015-11-05 19:28:16 +0000 | [diff] [blame] | 63 | // Register the MC instruction info. |
| 64 | TargetRegistry::RegisterMCInstrInfo(*T, createWebAssemblyMCInstrInfo); |
| 65 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 66 | // Register the MCInstPrinter. |
| 67 | TargetRegistry::RegisterMCInstPrinter(*T, createWebAssemblyMCInstPrinter); |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 68 | } |
| 69 | } |