blob: 14cd295353d552e9a912a72d2e257119edf778c1 [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//===-- 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"
25using namespace llvm;
26
27#define DEBUG_TYPE "wasm-mc-target-desc"
28
JF Bastienb9073fb2015-07-22 21:28:15 +000029#define GET_INSTRINFO_MC_DESC
30#include "WebAssemblyGenInstrInfo.inc"
31
Dan Gohman10e730a2015-06-29 23:51:55 +000032#define GET_SUBTARGETINFO_MC_DESC
33#include "WebAssemblyGenSubtargetInfo.inc"
34
JF Bastien5ca0bac2015-07-10 18:23:10 +000035#define GET_REGINFO_MC_DESC
36#include "WebAssemblyGenRegisterInfo.inc"
37
Dan Gohman7a6b9822015-11-29 22:32:02 +000038static MCAsmInfo *createWebAssemblyMCAsmInfo(const MCRegisterInfo & /*MRI*/,
Dan Gohman10e730a2015-06-29 23:51:55 +000039 const Triple &TT) {
JF Bastienae7eebd2015-07-28 17:23:07 +000040 return new WebAssemblyMCAsmInfo(TT);
Dan Gohman10e730a2015-06-29 23:51:55 +000041}
42
Dan Gohmane9361d52015-11-05 19:28:16 +000043static MCInstrInfo *createWebAssemblyMCInstrInfo() {
44 MCInstrInfo *X = new MCInstrInfo();
45 InitWebAssemblyMCInstrInfo(X);
46 return X;
47}
48
Dan Gohman05ac43f2015-12-17 01:39:00 +000049static MCStreamer *createWebAssemblyMCStreamer(const Triple &T, MCContext &Ctx,
50 MCAsmBackend &MAB,
51 raw_pwrite_stream &OS,
52 MCCodeEmitter *Emitter,
53 bool RelaxAll) {
54 return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
55}
56
Dan Gohman10e730a2015-06-29 23:51:55 +000057static MCInstPrinter *
Dan Gohman7a6b9822015-11-29 22:32:02 +000058createWebAssemblyMCInstPrinter(const Triple & /*T*/, unsigned SyntaxVariant,
Dan Gohman10e730a2015-06-29 23:51:55 +000059 const MCAsmInfo &MAI, const MCInstrInfo &MII,
60 const MCRegisterInfo &MRI) {
JF Bastienae7eebd2015-07-28 17:23:07 +000061 assert(SyntaxVariant == 0);
62 return new WebAssemblyInstPrinter(MAI, MII, MRI);
Dan Gohman10e730a2015-06-29 23:51:55 +000063}
64
65// Force static initialization.
66extern "C" void LLVMInitializeWebAssemblyTargetMC() {
Dan Gohmand82494b2015-07-01 21:42:34 +000067 for (Target *T : {&TheWebAssemblyTarget32, &TheWebAssemblyTarget64}) {
Dan Gohman10e730a2015-06-29 23:51:55 +000068 // Register the MC asm info.
69 RegisterMCAsmInfoFn X(*T, createWebAssemblyMCAsmInfo);
70
Dan Gohmane9361d52015-11-05 19:28:16 +000071 // Register the MC instruction info.
72 TargetRegistry::RegisterMCInstrInfo(*T, createWebAssemblyMCInstrInfo);
73
Dan Gohman05ac43f2015-12-17 01:39:00 +000074 // Register the object streamer
75 TargetRegistry::RegisterELFStreamer(*T, createWebAssemblyMCStreamer);
76
Dan Gohman10e730a2015-06-29 23:51:55 +000077 // Register the MCInstPrinter.
78 TargetRegistry::RegisterMCInstPrinter(*T, createWebAssemblyMCInstPrinter);
Dan Gohman05ac43f2015-12-17 01:39:00 +000079
80 // Register the MC code emitter
81 TargetRegistry::RegisterMCCodeEmitter(*T, createWebAssemblyMCCodeEmitter);
82
83 // Register the ASM Backend
84 TargetRegistry::RegisterMCAsmBackend(*T, createWebAssemblyAsmBackend);
Dan Gohman10e730a2015-06-29 23:51:55 +000085 }
86}