LLVM  15.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"
20 #include "llvm/MC/MCRegisterInfo.h"
22 #include "llvm/MC/TargetRegistry.h"
24 using namespace llvm;
25 
26 #define DEBUG_TYPE "wasm-mc-target-desc"
27 
28 #define GET_INSTRINFO_MC_DESC
29 #include "WebAssemblyGenInstrInfo.inc"
30 
31 #define GET_SUBTARGETINFO_MC_DESC
32 #include "WebAssemblyGenSubtargetInfo.inc"
33 
34 #define GET_REGINFO_MC_DESC
35 #include "WebAssemblyGenRegisterInfo.inc"
36 
37 static MCAsmInfo *createMCAsmInfo(const MCRegisterInfo & /*MRI*/,
38  const Triple &TT,
39  const MCTargetOptions &Options) {
40  return new WebAssemblyMCAsmInfo(TT, Options);
41 }
42 
44  auto *X = new MCInstrInfo();
45  InitWebAssemblyMCInstrInfo(X);
46  return X;
47 }
48 
49 static MCRegisterInfo *createMCRegisterInfo(const Triple & /*T*/) {
50  auto *X = new MCRegisterInfo();
51  InitWebAssemblyMCRegisterInfo(X, 0);
52  return X;
53 }
54 
56  unsigned SyntaxVariant,
57  const MCAsmInfo &MAI,
58  const MCInstrInfo &MII,
59  const MCRegisterInfo &MRI) {
60  assert(SyntaxVariant == 0 && "WebAssembly only has one syntax variant");
61  return new WebAssemblyInstPrinter(MAI, MII, MRI);
62 }
63 
65  MCContext &Ctx) {
66  return createWebAssemblyMCCodeEmitter(MCII);
67 }
68 
69 static MCAsmBackend *createAsmBackend(const Target & /*T*/,
70  const MCSubtargetInfo &STI,
71  const MCRegisterInfo & /*MRI*/,
72  const MCTargetOptions & /*Options*/) {
74 }
75 
77  StringRef FS) {
78  return createWebAssemblyMCSubtargetInfoImpl(TT, CPU, /*TuneCPU*/ CPU, FS);
79 }
80 
81 static MCTargetStreamer *
83  return new WebAssemblyTargetWasmStreamer(S);
84 }
85 
88  MCInstPrinter * /*InstPrint*/,
89  bool /*isVerboseAsm*/) {
90  return new WebAssemblyTargetAsmStreamer(S, OS);
91 }
92 
94  return new WebAssemblyTargetNullStreamer(S);
95 }
96 
97 // Force static initialization.
99  for (Target *T :
101  // Register the MC asm info.
103 
104  // Register the MC instruction info.
106 
107  // Register the MC register info.
109 
110  // Register the MCInstPrinter.
112 
113  // Register the MC code emitter.
115 
116  // Register the ASM Backend.
118 
119  // Register the MC subtarget info.
121 
122  // Register the object target streamer.
125  // Register the asm target streamer.
127  // Register the null target streamer.
129  }
130 }
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:17
llvm::WebAssemblyTargetNullStreamer
This part is for null output.
Definition: WebAssemblyTargetStreamer.h:97
llvm::getTheWebAssemblyTarget32
Target & getTheWebAssemblyTarget32()
Definition: WebAssemblyTargetInfo.cpp:20
T
llvm::MCContext
Context object for machine code objects.
Definition: MCContext.h:74
llvm::Target
Target - Wrapper for Target specific information.
Definition: TargetRegistry.h:140
llvm::MCAsmInfo
This class is intended to be used as a base class for asm properties and features specific to the tar...
Definition: MCAsmInfo.h:56
ErrorHandling.h
createAsmBackend
static MCAsmBackend * createAsmBackend(const Target &, const MCSubtargetInfo &STI, const MCRegisterInfo &, const MCTargetOptions &)
Definition: WebAssemblyMCTargetDesc.cpp:69
llvm::TargetRegistry::RegisterAsmTargetStreamer
static void RegisterAsmTargetStreamer(Target &T, Target::AsmTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:993
llvm::Triple
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
createMCInstrInfo
static MCInstrInfo * createMCInstrInfo()
Definition: WebAssemblyMCTargetDesc.cpp:43
llvm::TargetRegistry::RegisterMCInstPrinter
static void RegisterMCInstPrinter(Target &T, Target::MCInstPrinterCtorTy Fn)
RegisterMCInstPrinter - Register a MCInstPrinter implementation for the given target.
Definition: TargetRegistry.h:947
createCodeEmitter
static MCCodeEmitter * createCodeEmitter(const MCInstrInfo &MCII, MCContext &Ctx)
Definition: WebAssemblyMCTargetDesc.cpp:64
llvm::MCStreamer
Streaming machine code generation interface.
Definition: MCStreamer.h:201
llvm::MCAsmBackend
Generic interface to target specific assembler backends.
Definition: MCAsmBackend.h:42
llvm::createWebAssemblyMCCodeEmitter
MCCodeEmitter * createWebAssemblyMCCodeEmitter(const MCInstrInfo &MCII)
Definition: WebAssemblyMCCodeEmitter.cpp:55
llvm::MCSubtargetInfo::getTargetTriple
const Triple & getTargetTriple() const
Definition: MCSubtargetInfo.h:108
MCInstrInfo.h
MCSubtargetInfo.h
createAsmTargetStreamer
static MCTargetStreamer * createAsmTargetStreamer(MCStreamer &S, formatted_raw_ostream &OS, MCInstPrinter *, bool)
Definition: WebAssemblyMCTargetDesc.cpp:86
Options
const char LLVMTargetMachineRef LLVMPassBuilderOptionsRef Options
Definition: PassBuilderBindings.cpp:48
llvm::MCTargetStreamer
Target specific streamer interface.
Definition: MCStreamer.h:93
createMCAsmInfo
static MCAsmInfo * createMCAsmInfo(const MCRegisterInfo &, const Triple &TT, const MCTargetOptions &Options)
Definition: WebAssemblyMCTargetDesc.cpp:37
llvm::RegisterMCAsmInfoFn
RegisterMCAsmInfoFn - Helper template for registering a target assembly info implementation.
Definition: TargetRegistry.h:1118
X
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
WebAssemblyMCTargetDesc.h
WebAssemblyTargetStreamer.h
llvm::WebAssemblyMCAsmInfo
Definition: WebAssemblyMCAsmInfo.h:23
createNullTargetStreamer
static MCTargetStreamer * createNullTargetStreamer(MCStreamer &S)
Definition: WebAssemblyMCTargetDesc.cpp:93
llvm::TargetRegistry::RegisterMCAsmBackend
static void RegisterMCAsmBackend(Target &T, Target::MCAsmBackendCtorTy Fn)
RegisterMCAsmBackend - Register a MCAsmBackend implementation for the given target.
Definition: TargetRegistry.h:894
llvm::MCInstPrinter
This is an instance of a target assembly language printer that converts an MCInst to valid target ass...
Definition: MCInstPrinter.h:43
LLVM_EXTERNAL_VISIBILITY
#define LLVM_EXTERNAL_VISIBILITY
Definition: Compiler.h:126
WebAssemblyInstPrinter.h
WebAssemblyTargetInfo.h
llvm::TargetRegistry::RegisterObjectTargetStreamer
static void RegisterObjectTargetStreamer(Target &T, Target::ObjectTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:999
MCRegisterInfo.h
llvm::formatted_raw_ostream
formatted_raw_ostream - A raw_ostream that wraps another one and keeps track of line and column posit...
Definition: FormattedStream.h:30
createMCRegisterInfo
static MCRegisterInfo * createMCRegisterInfo(const Triple &)
Definition: WebAssemblyMCTargetDesc.cpp:49
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::TargetRegistry::RegisterMCSubtargetInfo
static void RegisterMCSubtargetInfo(Target &T, Target::MCSubtargetInfoCtorFnTy Fn)
RegisterMCSubtargetInfo - Register a MCSubtargetInfo implementation for the given target.
Definition: TargetRegistry.h:867
llvm::MCTargetOptions
Definition: MCTargetOptions.h:36
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
createMCSubtargetInfo
static MCSubtargetInfo * createMCSubtargetInfo(const Triple &TT, StringRef CPU, StringRef FS)
Definition: WebAssemblyMCTargetDesc.cpp:76
S
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Definition: README.txt:210
llvm::MCRegisterInfo
MCRegisterInfo base class - We assume that the target defines a static array of MCRegisterDesc object...
Definition: MCRegisterInfo.h:135
MRI
unsigned const MachineRegisterInfo * MRI
Definition: AArch64AdvSIMDScalarPass.cpp:105
llvm::WebAssemblyInstPrinter
Definition: WebAssemblyInstPrinter.h:26
llvm::getTheWebAssemblyTarget64
Target & getTheWebAssemblyTarget64()
Definition: WebAssemblyTargetInfo.cpp:24
createMCInstPrinter
static MCInstPrinter * createMCInstPrinter(const Triple &, unsigned SyntaxVariant, const MCAsmInfo &MAI, const MCInstrInfo &MII, const MCRegisterInfo &MRI)
Definition: WebAssemblyMCTargetDesc.cpp:55
llvm::WebAssemblyTargetWasmStreamer
This part is for Wasm object output.
Definition: WebAssemblyTargetStreamer.h:78
llvm::TargetRegistry::RegisterMCInstrInfo
static void RegisterMCInstrInfo(Target &T, Target::MCInstrInfoCtorFnTy Fn)
RegisterMCInstrInfo - Register a MCInstrInfo implementation for the given target.
Definition: TargetRegistry.h:834
llvm::TargetRegistry::RegisterMCCodeEmitter
static void RegisterMCCodeEmitter(Target &T, Target::MCCodeEmitterCtorTy Fn)
RegisterMCCodeEmitter - Register a MCCodeEmitter implementation for the given target.
Definition: TargetRegistry.h:960
llvm::MCInstrInfo
Interface to description of machine instruction set.
Definition: MCInstrInfo.h:26
llvm::MCCodeEmitter
MCCodeEmitter - Generic instruction encoding interface.
Definition: MCCodeEmitter.h:21
llvm::TargetRegistry::RegisterMCRegInfo
static void RegisterMCRegInfo(Target &T, Target::MCRegInfoCtorFnTy Fn)
RegisterMCRegInfo - Register a MCRegisterInfo implementation for the given target.
Definition: TargetRegistry.h:854
llvm::WebAssemblyTargetAsmStreamer
This part is for ascii assembly output.
Definition: WebAssemblyTargetStreamer.h:60
WebAssemblyMCAsmInfo.h
llvm::TargetRegistry::RegisterNullTargetStreamer
static void RegisterNullTargetStreamer(Target &T, Target::NullTargetStreamerCtorTy Fn)
Definition: TargetRegistry.h:988
LLVMInitializeWebAssemblyTargetMC
LLVM_EXTERNAL_VISIBILITY void LLVMInitializeWebAssemblyTargetMC()
Definition: WebAssemblyMCTargetDesc.cpp:98
createObjectTargetStreamer
static MCTargetStreamer * createObjectTargetStreamer(MCStreamer &S, const MCSubtargetInfo &STI)
Definition: WebAssemblyMCTargetDesc.cpp:82
llvm::X86AS::FS
@ FS
Definition: X86.h:188
llvm::createWebAssemblyAsmBackend
MCAsmBackend * createWebAssemblyAsmBackend(const Triple &TT)
Definition: WebAssemblyAsmBackend.cpp:127
TargetRegistry.h
llvm::MCSubtargetInfo
Generic base class for all target subtargets.
Definition: MCSubtargetInfo.h:76