#include "MCTargetDesc/WebAssemblyMCTargetDesc.h"
#include "MCTargetDesc/WebAssemblyInstPrinter.h"
#include "MCTargetDesc/WebAssemblyMCAsmInfo.h"
#include "MCTargetDesc/WebAssemblyTargetStreamer.h"
#include "TargetInfo/WebAssemblyTargetInfo.h"
#include "llvm/MC/MCInstrInfo.h"
#include "llvm/MC/MCRegisterInfo.h"
#include "llvm/MC/MCSubtargetInfo.h"
#include "llvm/MC/TargetRegistry.h"
#include "llvm/Support/ErrorHandling.h"
using namespace llvm;
#define DEBUG_TYPE "wasm-mc-target-desc"
#define GET_INSTRINFO_MC_DESC
#define ENABLE_INSTR_PREDICATE_VERIFIER
#include "WebAssemblyGenInstrInfo.inc"
#define GET_SUBTARGETINFO_MC_DESC
#include "WebAssemblyGenSubtargetInfo.inc"
#define GET_REGINFO_MC_DESC
#include "WebAssemblyGenRegisterInfo.inc"
static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & ,
const Triple &TT,
const MCTargetOptions &Options) {
return new WebAssemblyMCAsmInfo(TT, Options);
}
static MCInstrInfo *createMCInstrInfo() {
auto *X = new MCInstrInfo();
InitWebAssemblyMCInstrInfo(X);
return X;
}
static MCRegisterInfo *createMCRegisterInfo(const Triple & ) {
auto *X = new MCRegisterInfo();
InitWebAssemblyMCRegisterInfo(X, 0);
return X;
}
static MCInstPrinter *createMCInstPrinter(const Triple & ,
unsigned SyntaxVariant,
const MCAsmInfo &MAI,
const MCInstrInfo &MII,
const MCRegisterInfo &MRI) {
assert(SyntaxVariant == 0 && "WebAssembly only has one syntax variant");
return new WebAssemblyInstPrinter(MAI, MII, MRI);
}
static MCCodeEmitter *createCodeEmitter(const MCInstrInfo &MCII,
MCContext &Ctx) {
return createWebAssemblyMCCodeEmitter(MCII);
}
static MCAsmBackend *createAsmBackend(const Target & ,
const MCSubtargetInfo &STI,
const MCRegisterInfo & ,
const MCTargetOptions & ) {
return createWebAssemblyAsmBackend(STI.getTargetTriple());
}
static MCSubtargetInfo *createMCSubtargetInfo(const Triple &TT, StringRef CPU,
StringRef FS) {
return createWebAssemblyMCSubtargetInfoImpl(TT, CPU, CPU, FS);
}
static MCTargetStreamer *
createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI) {
return new WebAssemblyTargetWasmStreamer(S);
}
static MCTargetStreamer *createAsmTargetStreamer(MCStreamer &S,
formatted_raw_ostream &OS,
MCInstPrinter * ,
bool ) {
return new WebAssemblyTargetAsmStreamer(S, OS);
}
static MCTargetStreamer *createNullTargetStreamer(MCStreamer &S) {
return new WebAssemblyTargetNullStreamer(S);
}
extern "C" LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTargetMC() {
for (Target *T :
{&getTheWebAssemblyTarget32(), &getTheWebAssemblyTarget64()}) {
RegisterMCAsmInfoFn X(*T, createMCAsmInfo);
TargetRegistry::RegisterMCInstrInfo(*T, createMCInstrInfo);
TargetRegistry::RegisterMCRegInfo(*T, createMCRegisterInfo);
TargetRegistry::RegisterMCInstPrinter(*T, createMCInstPrinter);
TargetRegistry::RegisterMCCodeEmitter(*T, createCodeEmitter);
TargetRegistry::RegisterMCAsmBackend(*T, createAsmBackend);
TargetRegistry::RegisterMCSubtargetInfo(*T, createMCSubtargetInfo);
TargetRegistry::RegisterObjectTargetStreamer(*T,
createObjectTargetStreamer);
TargetRegistry::RegisterAsmTargetStreamer(*T, createAsmTargetStreamer);
TargetRegistry::RegisterNullTargetStreamer(*T, createNullTargetStreamer);
}
}