2015-06-30 07:51:55 +08:00
|
|
|
//===-- WebAssemblyMCTargetDesc.cpp - WebAssembly Target Descriptions -----===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file provides WebAssembly-specific target descriptions.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#include "WebAssemblyMCTargetDesc.h"
|
|
|
|
#include "InstPrinter/WebAssemblyInstPrinter.h"
|
|
|
|
#include "WebAssemblyMCAsmInfo.h"
|
|
|
|
#include "llvm/MC/MCCodeGenInfo.h"
|
|
|
|
#include "llvm/MC/MCInstrInfo.h"
|
|
|
|
#include "llvm/MC/MCRegisterInfo.h"
|
|
|
|
#include "llvm/MC/MCStreamer.h"
|
|
|
|
#include "llvm/MC/MCSubtargetInfo.h"
|
|
|
|
#include "llvm/Support/ErrorHandling.h"
|
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "wasm-mc-target-desc"
|
|
|
|
|
2015-07-23 05:28:15 +08:00
|
|
|
#define GET_INSTRINFO_MC_DESC
|
|
|
|
#include "WebAssemblyGenInstrInfo.inc"
|
|
|
|
|
2015-06-30 07:51:55 +08:00
|
|
|
#define GET_SUBTARGETINFO_MC_DESC
|
|
|
|
#include "WebAssemblyGenSubtargetInfo.inc"
|
|
|
|
|
2015-07-11 02:23:10 +08:00
|
|
|
#define GET_REGINFO_MC_DESC
|
|
|
|
#include "WebAssemblyGenRegisterInfo.inc"
|
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & /*MRI*/,
|
|
|
|
const Triple &TT) {
|
2015-07-29 01:23:07 +08:00
|
|
|
return new WebAssemblyMCAsmInfo(TT);
|
2015-06-30 07:51:55 +08:00
|
|
|
}
|
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
static MCInstrInfo *createMCInstrInfo() {
|
2015-11-06 03:28:16 +08:00
|
|
|
MCInstrInfo *X = new MCInstrInfo();
|
|
|
|
InitWebAssemblyMCInstrInfo(X);
|
|
|
|
return X;
|
|
|
|
}
|
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
static MCStreamer *createMCStreamer(const Triple & /*T*/, MCContext &Ctx,
|
|
|
|
MCAsmBackend &MAB, raw_pwrite_stream &OS,
|
|
|
|
MCCodeEmitter *Emitter, bool RelaxAll) {
|
2015-12-17 09:39:00 +08:00
|
|
|
return createELFStreamer(Ctx, MAB, OS, Emitter, RelaxAll);
|
|
|
|
}
|
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
static MCInstPrinter *createMCInstPrinter(const Triple & /*T*/,
|
|
|
|
unsigned SyntaxVariant,
|
|
|
|
const MCAsmInfo &MAI,
|
|
|
|
const MCInstrInfo &MII,
|
|
|
|
const MCRegisterInfo &MRI) {
|
2015-07-29 01:23:07 +08:00
|
|
|
assert(SyntaxVariant == 0);
|
|
|
|
return new WebAssemblyInstPrinter(MAI, MII, MRI);
|
2015-06-30 07:51:55 +08:00
|
|
|
}
|
|
|
|
|
2016-01-08 08:43:54 +08:00
|
|
|
static MCCodeEmitter *createCodeEmitter(const MCInstrInfo &MCII,
|
|
|
|
const MCRegisterInfo & /*MRI*/,
|
|
|
|
MCContext &Ctx) {
|
|
|
|
return createWebAssemblyMCCodeEmitter(MCII, Ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
static MCAsmBackend *createAsmBackend(const Target & /*T*/,
|
|
|
|
const MCRegisterInfo & /*MRI*/,
|
|
|
|
const Triple &TT, StringRef /*CPU*/) {
|
|
|
|
return createWebAssemblyAsmBackend(TT);
|
|
|
|
}
|
|
|
|
|
2016-01-12 11:30:06 +08:00
|
|
|
static MCSubtargetInfo *createMCSubtargetInfo(const Triple &TT, StringRef CPU,
|
|
|
|
StringRef FS) {
|
|
|
|
return createWebAssemblyMCSubtargetInfoImpl(TT, CPU, FS);
|
|
|
|
}
|
|
|
|
|
2015-06-30 07:51:55 +08:00
|
|
|
// Force static initialization.
|
|
|
|
extern "C" void LLVMInitializeWebAssemblyTargetMC() {
|
2015-07-02 05:42:34 +08:00
|
|
|
for (Target *T : {&TheWebAssemblyTarget32, &TheWebAssemblyTarget64}) {
|
2015-06-30 07:51:55 +08:00
|
|
|
// Register the MC asm info.
|
2016-01-08 08:43:54 +08:00
|
|
|
RegisterMCAsmInfoFn X(*T, createMCAsmInfo);
|
2015-06-30 07:51:55 +08:00
|
|
|
|
2015-11-06 03:28:16 +08:00
|
|
|
// Register the MC instruction info.
|
2016-01-08 08:43:54 +08:00
|
|
|
TargetRegistry::RegisterMCInstrInfo(*T, createMCInstrInfo);
|
2015-11-06 03:28:16 +08:00
|
|
|
|
2016-01-08 09:18:00 +08:00
|
|
|
// Register the object streamer.
|
2016-01-08 08:43:54 +08:00
|
|
|
TargetRegistry::RegisterELFStreamer(*T, createMCStreamer);
|
2015-12-17 09:39:00 +08:00
|
|
|
|
2015-06-30 07:51:55 +08:00
|
|
|
// Register the MCInstPrinter.
|
2016-01-08 08:43:54 +08:00
|
|
|
TargetRegistry::RegisterMCInstPrinter(*T, createMCInstPrinter);
|
2015-12-17 09:39:00 +08:00
|
|
|
|
2016-01-08 09:18:00 +08:00
|
|
|
// Register the MC code emitter.
|
2016-01-08 08:43:54 +08:00
|
|
|
TargetRegistry::RegisterMCCodeEmitter(*T, createCodeEmitter);
|
2015-12-17 09:39:00 +08:00
|
|
|
|
2016-01-08 09:18:00 +08:00
|
|
|
// Register the ASM Backend.
|
2016-01-08 08:43:54 +08:00
|
|
|
TargetRegistry::RegisterMCAsmBackend(*T, createAsmBackend);
|
2016-01-12 11:30:06 +08:00
|
|
|
|
|
|
|
// Register the MC subtarget info.
|
|
|
|
TargetRegistry::RegisterMCSubtargetInfo(*T, createMCSubtargetInfo);
|
2015-06-30 07:51:55 +08:00
|
|
|
}
|
|
|
|
}
|