LLVM 23.0.0git
WebAssemblyInstructionSelector.cpp
Go to the documentation of this file.
1//===- WebAssemblyInstructionSelector.cpp ------------------------*- C++ -*-==//
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/// \file
9/// This file implements the targeting of the InstructionSelector class for
10/// WebAssembly.
11/// \todo This should be generated by TableGen.
12//===----------------------------------------------------------------------===//
13
25#include "llvm/IR/IntrinsicsWebAssembly.h"
26
27#define DEBUG_TYPE "wasm-isel"
28
29using namespace llvm;
30
31namespace {
32
33#define GET_GLOBALISEL_PREDICATE_BITSET
34#include "WebAssemblyGenGlobalISel.inc"
35#undef GET_GLOBALISEL_PREDICATE_BITSET
36
37class WebAssemblyInstructionSelector : public InstructionSelector {
38public:
39 WebAssemblyInstructionSelector(const WebAssemblyTargetMachine &TM,
40 const WebAssemblySubtarget &STI,
42
43 bool select(MachineInstr &I) override;
44
45 static const char *getName() { return DEBUG_TYPE; }
46
47private:
48 bool selectImpl(MachineInstr &I, CodeGenCoverage &CoverageInfo) const;
49
51 // const WebAssemblySubtarget &STI;
55
56#define GET_GLOBALISEL_PREDICATES_DECL
57#include "WebAssemblyGenGlobalISel.inc"
58#undef GET_GLOBALISEL_PREDICATES_DECL
59
60#define GET_GLOBALISEL_TEMPORARIES_DECL
61#include "WebAssemblyGenGlobalISel.inc"
62#undef GET_GLOBALISEL_TEMPORARIES_DECL
63};
64
65} // end anonymous namespace
66
67#define GET_GLOBALISEL_IMPL
68#include "WebAssemblyGenGlobalISel.inc"
69#undef GET_GLOBALISEL_IMPL
70
71WebAssemblyInstructionSelector::WebAssemblyInstructionSelector(
74 : TM(TM), /*STI(STI),*/ TII(*STI.getInstrInfo()),
75 TRI(*STI.getRegisterInfo()), RBI(RBI),
76
78#include "WebAssemblyGenGlobalISel.inc"
81#include "WebAssemblyGenGlobalISel.inc"
83{
84}
85
86bool WebAssemblyInstructionSelector::select(MachineInstr &I) {
87 if (!I.isPreISelOpcode()) {
88 return true;
89 }
90
91 if (selectImpl(I, *CoverageInfo))
92 return true;
93
94 return false;
95}
96
97namespace llvm {
98InstructionSelector *
100 const WebAssemblySubtarget &Subtarget,
101 const WebAssemblyRegisterBankInfo &RBI) {
102 return new WebAssemblyInstructionSelector(TM, Subtarget, RBI);
103}
104} // namespace llvm
#define GET_GLOBALISEL_PREDICATES_INIT
#define GET_GLOBALISEL_TEMPORARIES_INIT
#define DEBUG_TYPE
const HexagonInstrInfo * TII
#define I(x, y, z)
Definition MD5.cpp:57
This file declares the MachineIRBuilder class.
Register const TargetRegisterInfo * TRI
static StringRef getName(Value *V)
This file describes how to lower LLVM code to machine code.
This file provides WebAssembly-specific target descriptions.
This file declares the targeting of the RegisterBankInfo class for WebAssembly.
This file contains the WebAssembly implementation of the WebAssemblyRegisterInfo class.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file declares the WebAssembly-specific subclass of TargetMachine.
Representation of each machine instruction.
This class provides the information for the target register banks.
This is an optimization pass for GlobalISel generic memory operations.
InstructionSelector * createWebAssemblyInstructionSelector(const WebAssemblyTargetMachine &TM, const WebAssemblySubtarget &Subtarget, const WebAssemblyRegisterBankInfo &RBI)