Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 1 | //- 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 | |
| 21 | namespace llvm { |
| 22 | |
| 23 | namespace WebAssemblyISD { |
| 24 | |
JF Bastien | 480c840 | 2015-08-11 20:13:18 +0000 | [diff] [blame] | 25 | enum NodeType : unsigned { |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 26 | FIRST_NUMBER = ISD::BUILTIN_OP_END, |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 27 | #define HANDLE_NODETYPE(NODE) NODE, |
| 28 | #include "WebAssemblyISD.def" |
| 29 | #undef HANDLE_NODETYPE |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 30 | }; |
| 31 | |
| 32 | } // end namespace WebAssemblyISD |
| 33 | |
| 34 | class WebAssemblySubtarget; |
| 35 | class WebAssemblyTargetMachine; |
| 36 | |
| 37 | class WebAssemblyTargetLowering final : public TargetLowering { |
| 38 | public: |
| 39 | WebAssemblyTargetLowering(const TargetMachine &TM, |
| 40 | const WebAssemblySubtarget &STI); |
| 41 | |
| 42 | private: |
| 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 Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 46 | |
Dan Gohman | 7b63484 | 2015-08-24 18:44:37 +0000 | [diff] [blame] | 47 | FastISel *createFastISel(FunctionLoweringInfo &FuncInfo, |
| 48 | const TargetLibraryInfo *LibInfo) const override; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 49 | bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override; |
JF Bastien | fda5337 | 2015-08-03 00:00:11 +0000 | [diff] [blame] | 50 | MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override; |
JF Bastien | 480c840 | 2015-08-11 20:13:18 +0000 | [diff] [blame] | 51 | const char *getTargetNodeName(unsigned Opcode) const override; |
Dan Gohman | f19ed56 | 2015-11-13 01:42:29 +0000 | [diff] [blame] | 52 | std::pair<unsigned, const TargetRegisterClass *> |
| 53 | getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI, |
| 54 | StringRef Constraint, MVT VT) const override; |
Dan Gohman | 3192ddf | 2015-11-19 23:04:59 +0000 | [diff] [blame] | 55 | bool isCheapToSpeculateCttz() const override; |
| 56 | bool isCheapToSpeculateCtlz() const override; |
Dan Gohman | 4b9d791 | 2015-12-15 22:01:29 +0000 | [diff] [blame] | 57 | bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty, |
| 58 | unsigned AS) const override; |
JF Bastien | 480c840 | 2015-08-11 20:13:18 +0000 | [diff] [blame] | 59 | |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 60 | SDValue LowerCall(CallLoweringInfo &CLI, |
| 61 | SmallVectorImpl<SDValue> &InVals) const override; |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 62 | bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF, |
| 63 | bool isVarArg, |
| 64 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 65 | LLVMContext &Context) const override; |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 66 | SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg, |
| 67 | const SmallVectorImpl<ISD::OutputArg> &Outs, |
| 68 | const SmallVectorImpl<SDValue> &OutVals, SDLoc dl, |
| 69 | SelectionDAG &DAG) const override; |
JF Bastien | b9073fb | 2015-07-22 21:28:15 +0000 | [diff] [blame] | 70 | SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv, |
| 71 | bool IsVarArg, |
| 72 | const SmallVectorImpl<ISD::InputArg> &Ins, |
| 73 | SDLoc DL, SelectionDAG &DAG, |
| 74 | SmallVectorImpl<SDValue> &InVals) const override; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 75 | |
| 76 | // Custom lowering hooks. |
| 77 | SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override; |
Derek Schuff | 9769deb | 2015-12-11 23:49:46 +0000 | [diff] [blame] | 78 | SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const; |
JF Bastien | af111db | 2015-08-24 22:16:48 +0000 | [diff] [blame] | 79 | SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 81719f8 | 2015-11-25 16:55:01 +0000 | [diff] [blame] | 80 | SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 950a13c | 2015-09-16 16:51:30 +0000 | [diff] [blame] | 81 | SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const; |
| 82 | SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 35bfb24 | 2015-12-04 23:22:35 +0000 | [diff] [blame] | 83 | SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const; |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 84 | }; |
| 85 | |
Dan Gohman | 7b63484 | 2015-08-24 18:44:37 +0000 | [diff] [blame] | 86 | namespace WebAssembly { |
| 87 | FastISel *createFastISel(FunctionLoweringInfo &funcInfo, |
| 88 | const TargetLibraryInfo *libInfo); |
| 89 | } // end namespace WebAssembly |
| 90 | |
Dan Gohman | 10e730a | 2015-06-29 23:51:55 +0000 | [diff] [blame] | 91 | } // end namespace llvm |
| 92 | |
| 93 | #endif |