LLVM 22.0.0git
WebAssemblyMCTargetDesc.cpp
Go to the documentation of this file.
1//===-- WebAssemblyMCTargetDesc.cpp - WebAssembly Target Descriptions -----===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file provides WebAssembly-specific target descriptions.
11///
12//===----------------------------------------------------------------------===//
13
19#include "llvm/MC/MCInstrInfo.h"
25using namespace llvm;
26
27#define DEBUG_TYPE "wasm-mc-target-desc"
28
29#define GET_INSTRINFO_MC_DESC
30#define ENABLE_INSTR_PREDICATE_VERIFIER
31#include "WebAssemblyGenInstrInfo.inc"
32
33#define GET_SUBTARGETINFO_MC_DESC
34#include "WebAssemblyGenSubtargetInfo.inc"
35
36#define GET_REGINFO_MC_DESC
37#include "WebAssemblyGenRegisterInfo.inc"
38
40 const Triple &TT,
41 const MCTargetOptions &Options) {
42 return new WebAssemblyMCAsmInfo(TT, Options);
43}
44
46 auto *X = new MCInstrInfo();
47 InitWebAssemblyMCInstrInfo(X);
48 return X;
49}
50
52 auto *X = new MCRegisterInfo();
53 InitWebAssemblyMCRegisterInfo(X, 0);
54 return X;
55}
56
58 unsigned SyntaxVariant,
59 const MCAsmInfo &MAI,
60 const MCInstrInfo &MII,
61 const MCRegisterInfo &MRI) {
62 assert(SyntaxVariant == 0 && "WebAssembly only has one syntax variant");
63 return new WebAssemblyInstPrinter(MAI, MII, MRI);
64}
65
67 MCContext &Ctx) {
68 return createWebAssemblyMCCodeEmitter(MCII, Ctx);
69}
70
71static MCAsmBackend *createAsmBackend(const Target & /*T*/,
72 const MCSubtargetInfo &STI,
73 const MCRegisterInfo & /*MRI*/,
74 const MCTargetOptions & /*Options*/) {
76}
77
79 StringRef FS) {
80 return createWebAssemblyMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
81}
82
83static MCTargetStreamer *
86}
87
88static MCTargetStreamer *
90 MCInstPrinter * /*InstPrint*/) {
91 return new WebAssemblyTargetAsmStreamer(S, OS);
92}
93
96}
97
98// Force static initialization.
101 for (Target *T :
103 // Register the MC asm info.
105
106 // Register the MC instruction info.
108
109 // Register the MC register info.
111
112 // Register the MCInstPrinter.
114
115 // Register the MC code emitter.
117
118 // Register the ASM Backend.
120
121 // Register the MC subtarget info.
123
124 // Register the object target streamer.
127 // Register the asm target streamer.
129 // Register the null target streamer.
131 }
132}
unsigned const MachineRegisterInfo * MRI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
#define LLVM_ABI
Definition: Compiler.h:213
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:132
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
static LVOptions Options
Definition: LVOptions.cpp:25
raw_pwrite_stream & OS
This class prints an WebAssembly MCInst to wasm file syntax.
This file contains the declaration of the WebAssemblyMCAsmInfo class.
static MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &, const Triple &TT, const MCTargetOptions &Options)
static MCRegisterInfo * createMCRegisterInfo(const Triple &)
static MCInstPrinter * createMCInstPrinter(const Triple &, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
static MCInstrInfo * createMCInstrInfo()
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
static MCAsmBackend * createAsmBackend(const Target &, const MCSubtargetInfo &STI, const MCRegisterInfo &, const MCTargetOptions &)
LLVM_ABI LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTargetMC()
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
static MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *)
static MCCodeEmitter * createCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
static MCSubtargetInfo * createMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
This file provides WebAssembly-specific target descriptions.
This file registers the WebAssembly target.
This file declares WebAssembly-specific target streamer classes.
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:55
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:64
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:23
Context object for machine code objects.
Definition: MCContext.h:83
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:46
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:27
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Streaming machine code generation interface.
Definition: MCStreamer.h:220
Generic base class for all target subtargets.
const Triple & getTargetTriple() const
Target specific streamer interface.
Definition: MCStreamer.h:93
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
Target - Wrapper for Target specific information.
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:47
This part is for ascii assembly output.
This part is for Wasm object output.
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)
Target & getTheWebAssemblyTarget32()
Target & getTheWebAssemblyTarget64()
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)