blob: d82bfa61555696ae6a9072a292d7e9fd6cd31acc [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 Bastiend8a9d662015-08-24 21:59:51 +000027#define HANDLE_NODETYPE(NODE) NODE,
28#include "WebAssemblyISD.def"
29#undef HANDLE_NODETYPE
Dan Gohman10e730a2015-06-29 23:51:55 +000030 // add memory opcodes starting at ISD::FIRST_TARGET_MEMORY_OPCODE here...
31};
32
33} // end namespace WebAssemblyISD
34
35class WebAssemblySubtarget;
36class WebAssemblyTargetMachine;
37
38class WebAssemblyTargetLowering final : public TargetLowering {
39public:
40 WebAssemblyTargetLowering(const TargetMachine &TM,
41 const WebAssemblySubtarget &STI);
42
43private:
44 /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
45 /// right decision when generating code for different targets.
46 const WebAssemblySubtarget *Subtarget;
JF Bastienb9073fb2015-07-22 21:28:15 +000047
Dan Gohman7b634842015-08-24 18:44:37 +000048 FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
49 const TargetLibraryInfo *LibInfo) const override;
50
JF Bastienfda53372015-08-03 00:00:11 +000051 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
52
JF Bastien480c8402015-08-11 20:13:18 +000053 const char *getTargetNodeName(unsigned Opcode) const override;
54
JF Bastiend8a9d662015-08-24 21:59:51 +000055 SDValue LowerCall(CallLoweringInfo &CLI,
56 SmallVectorImpl<SDValue> &InVals) const override;
57
JF Bastienb9073fb2015-07-22 21:28:15 +000058 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
59 bool isVarArg,
60 const SmallVectorImpl<ISD::OutputArg> &Outs,
61 LLVMContext &Context) const override;
62
63 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
64 const SmallVectorImpl<ISD::OutputArg> &Outs,
65 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
66 SelectionDAG &DAG) const override;
67
68 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
69 bool IsVarArg,
70 const SmallVectorImpl<ISD::InputArg> &Ins,
71 SDLoc DL, SelectionDAG &DAG,
72 SmallVectorImpl<SDValue> &InVals) const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000073};
74
Dan Gohman7b634842015-08-24 18:44:37 +000075namespace WebAssembly {
76FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
77 const TargetLibraryInfo *libInfo);
78} // end namespace WebAssembly
79
Dan Gohman10e730a2015-06-29 23:51:55 +000080} // end namespace llvm
81
82#endif