blob: ea845cd4031c5e5158515d39f0db6549144874d2 [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 Bastien19c2e662015-08-24 22:07:33 +000027 RETURN,
28 ARGUMENT,
29
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 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;
59
60 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
61 const SmallVectorImpl<ISD::OutputArg> &Outs,
62 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
63 SelectionDAG &DAG) const override;
64
65 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
66 bool IsVarArg,
67 const SmallVectorImpl<ISD::InputArg> &Ins,
68 SDLoc DL, SelectionDAG &DAG,
69 SmallVectorImpl<SDValue> &InVals) const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000070};
71
Dan Gohman7b634842015-08-24 18:44:37 +000072namespace WebAssembly {
73FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
74 const TargetLibraryInfo *libInfo);
75} // end namespace WebAssembly
76
Dan Gohman10e730a2015-06-29 23:51:55 +000077} // end namespace llvm
78
79#endif