blob: 9af4e455ad267e20cd69fd464e73d98be37e1006 [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 Bastien600aee92015-07-31 17:53:38 +000027 RETURN,
28 ARGUMENT,
Dan Gohman10e730a2015-06-29 23:51:55 +000029
30 // 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
JF Bastienfda53372015-08-03 00:00:11 +000048 MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
49
JF Bastien480c8402015-08-11 20:13:18 +000050 const char *getTargetNodeName(unsigned Opcode) const override;
51
JF Bastienb9073fb2015-07-22 21:28:15 +000052 bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
53 bool isVarArg,
54 const SmallVectorImpl<ISD::OutputArg> &Outs,
55 LLVMContext &Context) const override;
56
57 SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
58 const SmallVectorImpl<ISD::OutputArg> &Outs,
59 const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
60 SelectionDAG &DAG) const override;
61
62 SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
63 bool IsVarArg,
64 const SmallVectorImpl<ISD::InputArg> &Ins,
65 SDLoc DL, SelectionDAG &DAG,
66 SmallVectorImpl<SDValue> &InVals) const override;
Dan Gohman10e730a2015-06-29 23:51:55 +000067};
68
69} // end namespace llvm
70
71#endif