blob: 23e0c597a33ed12b23a689c416afec7d859ac7fd [file] [log] [blame]
Dan Gohman10e730a2015-06-29 23:51:55 +00001//- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9///
10/// \file
11/// \brief This file defines the interfaces that WebAssembly uses to lower LLVM
12/// code into a selection DAG.
13///
14//===----------------------------------------------------------------------===//
15
16#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
17#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
18
19#include "llvm/Target/TargetLowering.h"
20
21namespace llvm {
22
23namespace WebAssemblyISD {
24
JF Bastien480c8402015-08-11 20:13:18 +000025enum NodeType : unsigned {
Dan Gohman10e730a2015-06-29 23:51:55 +000026 FIRST_NUMBER = ISD::BUILTIN_OP_END,
JF Bastienaf111db2015-08-24 22:16:48 +000027#define HANDLE_NODETYPE(NODE) NODE,
28#include "WebAssemblyISD.def"
29#undef HANDLE_NODETYPE
Dan Gohman10e730a2015-06-29 23:51:55 +000030};
31
32} // end namespace WebAssemblyISD
33
34class WebAssemblySubtarget;
35class WebAssemblyTargetMachine;
36
37class WebAssemblyTargetLowering final : public TargetLowering {
38public:
39 WebAssemblyTargetLowering(const TargetMachine &TM,
40 const WebAssemblySubtarget &STI);
41
42private:
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;
JF Bastienb9073fb2015-07-22 21:28:15 +000046
Dan Gohman7b634842015-08-24 18:44:37 +000047 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
48 const TargetLibraryInfo *LibInfo) const override;
JF Bastienaf111db2015-08-24 22:16:48 +000049 bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
JF Bastienfda53372015-08-03 00:00:11 +000050 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
JF Bastien480c8402015-08-11 20:13:18 +000051 const char *getTargetNodeName(unsigned Opcode) const override;
52
JF Bastienaf111db2015-08-24 22:16:48 +000053 SDValue LowerCall(CallLoweringInfo &CLI,
54 SmallVectorImpl<SDValue> &InVals) const override;
JF Bastienb9073fb2015-07-22 21:28:15 +000055 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
56 bool isVarArg,
57 const SmallVectorImpl<ISD::OutputArg> &Outs,
58 LLVMContext &Context) const override;
JF Bastienb9073fb2015-07-22 21:28:15 +000059 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;
JF Bastienb9073fb2015-07-22 21:28:15 +000063 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
64 bool IsVarArg,
65 const SmallVectorImpl<ISD::InputArg> &Ins,
66 SDLoc DL, SelectionDAG &DAG,
67 SmallVectorImpl<SDValue> &InVals) const override;
JF Bastienaf111db2015-08-24 22:16:48 +000068
69 // Custom lowering hooks.
70 SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
71 SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman950a13c2015-09-16 16:51:30 +000072 SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
73 SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
Dan Gohman10e730a2015-06-29 23:51:55 +000074};
75
Dan Gohman7b634842015-08-24 18:44:37 +000076namespace WebAssembly {
77FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
78 const TargetLibraryInfo *libInfo);
79} // end namespace WebAssembly
80
Dan Gohman10e730a2015-06-29 23:51:55 +000081} // end namespace llvm
82
83#endif