25#include "llvm/IR/IntrinsicsWebAssembly.h"
27#define DEBUG_TYPE "wasm-isel"
33#define GET_GLOBALISEL_PREDICATE_BITSET
34#include "WebAssemblyGenGlobalISel.inc"
35#undef GET_GLOBALISEL_PREDICATE_BITSET
57#define GET_GLOBALISEL_PREDICATES_DECL
58#include "WebAssemblyGenGlobalISel.inc"
59#undef GET_GLOBALISEL_PREDICATES_DECL
61#define GET_GLOBALISEL_TEMPORARIES_DECL
62#include "WebAssemblyGenGlobalISel.inc"
63#undef GET_GLOBALISEL_TEMPORARIES_DECL
68#define GET_GLOBALISEL_IMPL
69#include "WebAssemblyGenGlobalISel.inc"
70#undef GET_GLOBALISEL_IMPL
72WebAssemblyInstructionSelector::WebAssemblyInstructionSelector(
75 : TM(TM),
TII(*STI.getInstrInfo()),
76 TRI(*STI.getRegisterInfo()), RBI(RBI),
79#include
"WebAssemblyGenGlobalISel.inc"
82#include
"WebAssemblyGenGlobalISel.inc"
87bool WebAssemblyInstructionSelector::selectCopy(
89 const TargetRegisterClass *DstRC =
90 TRI.getConstrainedRegClassForOperand(
I.getOperand(0), MRI);
94 const TargetRegisterClass *SrcRC =
95 TRI.getConstrainedRegClassForOperand(
I.getOperand(1), MRI);
99 Register DstReg =
I.getOperand(0).getReg();
100 Register SrcReg =
I.getOperand(1).getReg();
107 if (DstRC != SrcRC) {
110 "classes not currently supported");
112 if (DstRC == &WebAssembly::I32RegClass &&
113 SrcRC == &WebAssembly::F32RegClass) {
114 I.setDesc(
TII.get(WebAssembly::I32_REINTERPRET_F32));
117 if (DstRC == &WebAssembly::F32RegClass &&
118 SrcRC == &WebAssembly::I32RegClass) {
119 I.setDesc(
TII.get(WebAssembly::F32_REINTERPRET_I32));
122 if (DstRC == &WebAssembly::I64RegClass &&
123 SrcRC == &WebAssembly::F64RegClass) {
124 I.setDesc(
TII.get(WebAssembly::I64_REINTERPRET_F64));
127 if (DstRC == &WebAssembly::F64RegClass &&
128 SrcRC == &WebAssembly::I64RegClass) {
129 I.setDesc(
TII.get(WebAssembly::F64_REINTERPRET_I64));
139bool WebAssemblyInstructionSelector::select(MachineInstr &
I) {
144 if (!
I.isPreISelOpcode()) {
150 if (selectImpl(
I, *CoverageInfo))
153 using namespace TargetOpcode;
155 switch (
I.getOpcode()) {
156 case G_IMPLICIT_DEF: {
157 const Register DefReg =
I.getOperand(0).getReg();
159 const TargetRegisterClass *DefRC =
160 TRI.getConstrainedRegClassForOperand(
I.getOperand(0), MRI);
165 I.setDesc(
TII.get(TargetOpcode::IMPLICIT_DEF));
180 return new WebAssemblyInstructionSelector(TM, Subtarget, RBI);
#define GET_GLOBALISEL_PREDICATES_INIT
#define GET_GLOBALISEL_TEMPORARIES_INIT
static bool selectCopy(MachineInstr &I, const TargetInstrInfo &TII, MachineRegisterInfo &MRI, const TargetRegisterInfo &TRI, const RegisterBankInfo &RBI)
const HexagonInstrInfo * TII
This file declares the MachineIRBuilder class.
Register const TargetRegisterInfo * TRI
Promote Memory to Register
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.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
static const TargetRegisterClass * constrainGenericRegister(Register Reg, const TargetRegisterClass &RC, MachineRegisterInfo &MRI)
Constrain the (possibly generic) virtual register Reg to RC.
constexpr bool isVirtual() const
Return true if the specified register number is in the virtual register namespace.
constexpr bool isPhysical() const
Return true if the specified register number is in the physical register namespace.
This class provides the information for the target register banks.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
This is an optimization pass for GlobalISel generic memory operations.
InstructionSelector * createWebAssemblyInstructionSelector(const WebAssemblyTargetMachine &TM, const WebAssemblySubtarget &Subtarget, const WebAssemblyRegisterBankInfo &RBI)