xref: /aosp_15_r20/external/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h (revision 9880d6810fe72a1726cb53787c6711e909410d58)
1*9880d681SAndroid Build Coastguard Worker //- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//
2*9880d681SAndroid Build Coastguard Worker //
3*9880d681SAndroid Build Coastguard Worker //                     The LLVM Compiler Infrastructure
4*9880d681SAndroid Build Coastguard Worker //
5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source
6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details.
7*9880d681SAndroid Build Coastguard Worker //
8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
9*9880d681SAndroid Build Coastguard Worker ///
10*9880d681SAndroid Build Coastguard Worker /// \file
11*9880d681SAndroid Build Coastguard Worker /// \brief This file defines the interfaces that WebAssembly uses to lower LLVM
12*9880d681SAndroid Build Coastguard Worker /// code into a selection DAG.
13*9880d681SAndroid Build Coastguard Worker ///
14*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===//
15*9880d681SAndroid Build Coastguard Worker 
16*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
17*9880d681SAndroid Build Coastguard Worker #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
18*9880d681SAndroid Build Coastguard Worker 
19*9880d681SAndroid Build Coastguard Worker #include "llvm/Target/TargetLowering.h"
20*9880d681SAndroid Build Coastguard Worker 
21*9880d681SAndroid Build Coastguard Worker namespace llvm {
22*9880d681SAndroid Build Coastguard Worker 
23*9880d681SAndroid Build Coastguard Worker namespace WebAssemblyISD {
24*9880d681SAndroid Build Coastguard Worker 
25*9880d681SAndroid Build Coastguard Worker enum NodeType : unsigned {
26*9880d681SAndroid Build Coastguard Worker   FIRST_NUMBER = ISD::BUILTIN_OP_END,
27*9880d681SAndroid Build Coastguard Worker #define HANDLE_NODETYPE(NODE) NODE,
28*9880d681SAndroid Build Coastguard Worker #include "WebAssemblyISD.def"
29*9880d681SAndroid Build Coastguard Worker #undef HANDLE_NODETYPE
30*9880d681SAndroid Build Coastguard Worker };
31*9880d681SAndroid Build Coastguard Worker 
32*9880d681SAndroid Build Coastguard Worker }  // end namespace WebAssemblyISD
33*9880d681SAndroid Build Coastguard Worker 
34*9880d681SAndroid Build Coastguard Worker class WebAssemblySubtarget;
35*9880d681SAndroid Build Coastguard Worker class WebAssemblyTargetMachine;
36*9880d681SAndroid Build Coastguard Worker 
37*9880d681SAndroid Build Coastguard Worker class WebAssemblyTargetLowering final : public TargetLowering {
38*9880d681SAndroid Build Coastguard Worker  public:
39*9880d681SAndroid Build Coastguard Worker   WebAssemblyTargetLowering(const TargetMachine &TM,
40*9880d681SAndroid Build Coastguard Worker                             const WebAssemblySubtarget &STI);
41*9880d681SAndroid Build Coastguard Worker 
42*9880d681SAndroid Build Coastguard Worker  private:
43*9880d681SAndroid Build Coastguard Worker   /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
44*9880d681SAndroid Build Coastguard Worker   /// right decision when generating code for different targets.
45*9880d681SAndroid Build Coastguard Worker   const WebAssemblySubtarget *Subtarget;
46*9880d681SAndroid Build Coastguard Worker 
47*9880d681SAndroid Build Coastguard Worker   FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
48*9880d681SAndroid Build Coastguard Worker                            const TargetLibraryInfo *LibInfo) const override;
49*9880d681SAndroid Build Coastguard Worker   bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
50*9880d681SAndroid Build Coastguard Worker   MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
51*9880d681SAndroid Build Coastguard Worker   const char *getTargetNodeName(unsigned Opcode) const override;
52*9880d681SAndroid Build Coastguard Worker   std::pair<unsigned, const TargetRegisterClass *> getRegForInlineAsmConstraint(
53*9880d681SAndroid Build Coastguard Worker       const TargetRegisterInfo *TRI, StringRef Constraint,
54*9880d681SAndroid Build Coastguard Worker       MVT VT) const override;
55*9880d681SAndroid Build Coastguard Worker   bool isCheapToSpeculateCttz() const override;
56*9880d681SAndroid Build Coastguard Worker   bool isCheapToSpeculateCtlz() const override;
57*9880d681SAndroid Build Coastguard Worker   bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
58*9880d681SAndroid Build Coastguard Worker                              unsigned AS) const override;
59*9880d681SAndroid Build Coastguard Worker   bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, unsigned Align,
60*9880d681SAndroid Build Coastguard Worker                                       bool *Fast) const override;
61*9880d681SAndroid Build Coastguard Worker   bool isIntDivCheap(EVT VT, AttributeSet Attr) const override;
62*9880d681SAndroid Build Coastguard Worker 
63*9880d681SAndroid Build Coastguard Worker   SDValue LowerCall(CallLoweringInfo &CLI,
64*9880d681SAndroid Build Coastguard Worker                     SmallVectorImpl<SDValue> &InVals) const override;
65*9880d681SAndroid Build Coastguard Worker   bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
66*9880d681SAndroid Build Coastguard Worker                       bool isVarArg,
67*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<ISD::OutputArg> &Outs,
68*9880d681SAndroid Build Coastguard Worker                       LLVMContext &Context) const override;
69*9880d681SAndroid Build Coastguard Worker   SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
70*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<ISD::OutputArg> &Outs,
71*9880d681SAndroid Build Coastguard Worker                       const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
72*9880d681SAndroid Build Coastguard Worker                       SelectionDAG &DAG) const override;
73*9880d681SAndroid Build Coastguard Worker   SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
74*9880d681SAndroid Build Coastguard Worker                                bool IsVarArg,
75*9880d681SAndroid Build Coastguard Worker                                const SmallVectorImpl<ISD::InputArg> &Ins,
76*9880d681SAndroid Build Coastguard Worker                                const SDLoc &DL, SelectionDAG &DAG,
77*9880d681SAndroid Build Coastguard Worker                                SmallVectorImpl<SDValue> &InVals) const override;
78*9880d681SAndroid Build Coastguard Worker 
79*9880d681SAndroid Build Coastguard Worker   // Custom lowering hooks.
80*9880d681SAndroid Build Coastguard Worker   SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
81*9880d681SAndroid Build Coastguard Worker   SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
82*9880d681SAndroid Build Coastguard Worker   SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
83*9880d681SAndroid Build Coastguard Worker   SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
84*9880d681SAndroid Build Coastguard Worker   SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
85*9880d681SAndroid Build Coastguard Worker   SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
86*9880d681SAndroid Build Coastguard Worker   SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
87*9880d681SAndroid Build Coastguard Worker   SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
88*9880d681SAndroid Build Coastguard Worker   SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;
89*9880d681SAndroid Build Coastguard Worker };
90*9880d681SAndroid Build Coastguard Worker 
91*9880d681SAndroid Build Coastguard Worker namespace WebAssembly {
92*9880d681SAndroid Build Coastguard Worker FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
93*9880d681SAndroid Build Coastguard Worker                          const TargetLibraryInfo *libInfo);
94*9880d681SAndroid Build Coastguard Worker }  // end namespace WebAssembly
95*9880d681SAndroid Build Coastguard Worker 
96*9880d681SAndroid Build Coastguard Worker }  // end namespace llvm
97*9880d681SAndroid Build Coastguard Worker 
98*9880d681SAndroid Build Coastguard Worker #endif
99