LLVM 22.0.0git
WebAssemblyISelLowering.h
Go to the documentation of this file.
1//- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- 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///
9/// \file
10/// This file defines the interfaces that WebAssembly uses to lower LLVM
11/// code into a selection DAG.
12///
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
16#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
17
19
20namespace llvm {
21
23
25public:
27 const WebAssemblySubtarget &STI);
28
29 MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const override;
30 MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const override;
31
32 bool softPromoteHalfType() const override { return true; }
33
34private:
35 /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
36 /// right decision when generating code for different targets.
37 const WebAssemblySubtarget *Subtarget;
38
39 AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override;
40 bool shouldScalarizeBinop(SDValue VecOp) const override;
41 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
42 const TargetLibraryInfo *LibInfo) const override;
43 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
45 EmitInstrWithCustomInserter(MachineInstr &MI,
46 MachineBasicBlock *MBB) const override;
47 std::pair<unsigned, const TargetRegisterClass *>
48 getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,
49 StringRef Constraint, MVT VT) const override;
50 bool isCheapToSpeculateCttz(Type *Ty) const override;
51 bool isCheapToSpeculateCtlz(Type *Ty) const override;
52 bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
53 unsigned AS,
54 Instruction *I = nullptr) const override;
55 bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, Align Alignment,
57 unsigned *Fast) const override;
58 bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
59 bool isVectorLoadExtDesirable(SDValue ExtVal) const override;
60 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
61 EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
62 EVT VT) const override;
63 bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallBase &I,
65 unsigned Intrinsic) const override;
66
67 void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,
68 const APInt &DemandedElts,
69 const SelectionDAG &DAG,
70 unsigned Depth) const override;
71
73 getPreferredVectorAction(MVT VT) const override;
74 bool isFMAFasterThanFMulAndFAdd(const MachineFunction &MF,
75 EVT VT) const override;
76
77 SDValue LowerCall(CallLoweringInfo &CLI,
78 SmallVectorImpl<SDValue> &InVals) const override;
79 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
80 bool isVarArg,
82 LLVMContext &Context, const Type *RetTy) const override;
83 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
85 const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
86 SelectionDAG &DAG) const override;
87 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
88 bool IsVarArg,
90 const SDLoc &DL, SelectionDAG &DAG,
91 SmallVectorImpl<SDValue> &InVals) const override;
92
93 void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,
94 SelectionDAG &DAG) const override;
95
96 bool
97 shouldSimplifyDemandedVectorElts(SDValue Op,
98 const TargetLoweringOpt &TLO) const override;
99
100 // Custom lowering hooks.
101 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
102 SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
105 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
106 SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;
107 SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
108 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
109 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
111 SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;
112 SDValue LowerIntrinsic(SDValue Op, SelectionDAG &DAG) const;
113 SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;
115 SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;
117 SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;
118 SDValue LowerAccessVectorElement(SDValue Op, SelectionDAG &DAG) const;
123 SDValue LowerMUL_LOHI(SDValue Op, SelectionDAG &DAG) const;
124 SDValue Replace128Op(SDNode *N, SelectionDAG &DAG) const;
125 SDValue LowerUADDO(SDValue Op, SelectionDAG &DAG) const;
126
127 // Custom DAG combine hooks
128 SDValue
129 PerformDAGCombine(SDNode *N,
130 TargetLowering::DAGCombinerInfo &DCI) const override;
131};
132
133namespace WebAssembly {
134FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
135 const TargetLibraryInfo *libInfo);
136} // end namespace WebAssembly
137
138} // end namespace llvm
139
140#endif
static SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG)
static SDValue LowerShift(SDNode *N, SelectionDAG &DAG, const ARMSubtarget *ST)
static SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG, const ARMSubtarget *ST)
static SDValue LowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG, const ARMSubtarget *Subtarget)
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
Analysis containing CSE Info
Definition CSEInfo.cpp:27
IRTranslator LLVM IR MI
#define I(x, y, z)
Definition MD5.cpp:57
Register const TargetRegisterInfo * TRI
static SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG, const SparcSubtarget *Subtarget)
static SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG, const SparcTargetLowering &TLI, const SparcSubtarget *Subtarget)
This file describes how to lower LLVM code to machine code.
static SDValue LowerStore(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
static SDValue LowerLoad(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
static SDValue LowerEXTEND_VECTOR_INREG(SDValue Op, const X86Subtarget &Subtarget, SelectionDAG &DAG)
Class for arbitrary precision integers.
Definition APInt.h:78
an instruction that atomically reads a memory location, combines it with another value,...
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition FastISel.h:66
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
Machine Value Type.
Representation of each machine instruction.
Flags
Flags values. These may be or'd together.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
Provides information about what library functions are available for the current target.
LegalizeTypeAction
This enum indicates whether a types are legal for a target, and if not, what action should be used to...
AtomicExpansionKind
Enum that specifies what an atomic load/AtomicRMWInst is expanded to, if at all.
TargetLowering(const TargetLowering &)=delete
Primary interface to the complete machine description for the target machine.
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:45
WebAssemblyTargetLowering(const TargetMachine &TM, const WebAssemblySubtarget &STI)
MVT getPointerTy(const DataLayout &DL, uint32_t AS=0) const override
Return the pointer type for the given address space, defaults to the pointer type from the data layou...
MVT getPointerMemTy(const DataLayout &DL, uint32_t AS=0) const override
Return the in-memory pointer type for the given address space, defaults to the pointer type from the ...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition CallingConv.h:24
@ Fast
Attempts to make calls as fast as possible (e.g.
Definition CallingConv.h:41
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
This is an optimization pass for GlobalISel generic memory operations.
Definition Types.h:26
DWARFExpression::Operation Op
#define N
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Extended Value Type.
Definition ValueTypes.h:35