1 //- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
11 /// \brief This file defines the interfaces that WebAssembly uses to lower LLVM
12 /// code into a selection DAG.
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
17 #define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
19 #include "llvm/Target/TargetLowering.h"
23 namespace WebAssemblyISD {
25 enum NodeType : unsigned {
26 FIRST_NUMBER = ISD::BUILTIN_OP_END,
27 #define HANDLE_NODETYPE(NODE) NODE,
28 #include "WebAssemblyISD.def"
29 #undef HANDLE_NODETYPE
32 } // end namespace WebAssemblyISD
34 class WebAssemblySubtarget;
35 class WebAssemblyTargetMachine;
37 class WebAssemblyTargetLowering final : public TargetLowering {
39 WebAssemblyTargetLowering(const TargetMachine &TM,
40 const WebAssemblySubtarget &STI);
43 /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
44 /// right decision when generating code for different targets.
45 const WebAssemblySubtarget *Subtarget;
47 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
48 const TargetLibraryInfo *LibInfo) const override;
49 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
50 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
51 const char *getTargetNodeName(unsigned Opcode) const override;
53 SDValue LowerCall(CallLoweringInfo &CLI,
54 SmallVectorImpl<SDValue> &InVals) const override;
55 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
57 const SmallVectorImpl<ISD::OutputArg> &Outs,
58 LLVMContext &Context) const override;
59 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
60 const SmallVectorImpl<ISD::OutputArg> &Outs,
61 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
62 SelectionDAG &DAG) const override;
63 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
65 const SmallVectorImpl<ISD::InputArg> &Ins,
66 SDLoc DL, SelectionDAG &DAG,
67 SmallVectorImpl<SDValue> &InVals) const override;
69 // Custom lowering hooks.
70 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
71 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
74 namespace WebAssembly {
75 FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
76 const TargetLibraryInfo *libInfo);
77 } // end namespace WebAssembly
79 } // end namespace llvm