WebAssemblyISelLowering.h revision 309124
176082Sbmah//- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//
276082Sbmah//
376082Sbmah//                     The LLVM Compiler Infrastructure
476082Sbmah//
576082Sbmah// This file is distributed under the University of Illinois Open Source
676082Sbmah// License. See LICENSE.TXT for details.
776082Sbmah//
876082Sbmah//===----------------------------------------------------------------------===//
976082Sbmah///
1076082Sbmah/// \file
1176082Sbmah/// \brief This file defines the interfaces that WebAssembly uses to lower LLVM
1276082Sbmah/// code into a selection DAG.
1386157Solgeni///
1476082Sbmah//===----------------------------------------------------------------------===//
1576082Sbmah
1676082Sbmah#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
1776082Sbmah#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
1876082Sbmah
1976082Sbmah#include "llvm/Target/TargetLowering.h"
2086157Solgeni
2176082Sbmahnamespace llvm {
2276082Sbmah
2376560Sbmahnamespace WebAssemblyISD {
2476560Sbmah
2576560Sbmahenum NodeType : unsigned {
2676560Sbmah  FIRST_NUMBER = ISD::BUILTIN_OP_END,
2776560Sbmah#define HANDLE_NODETYPE(NODE) NODE,
2876560Sbmah#include "WebAssemblyISD.def"
2976560Sbmah#undef HANDLE_NODETYPE
3076082Sbmah};
3176082Sbmah
3276082Sbmah}  // end namespace WebAssemblyISD
3376598Sbmah
3476598Sbmahclass WebAssemblySubtarget;
3576598Sbmahclass WebAssemblyTargetMachine;
3676598Sbmah
3776082Sbmahclass WebAssemblyTargetLowering final : public TargetLowering {
3876082Sbmah public:
3976082Sbmah  WebAssemblyTargetLowering(const TargetMachine &TM,
4085416Sbmah                            const WebAssemblySubtarget &STI);
4176082Sbmah
4276082Sbmah private:
4376082Sbmah  /// Keep a pointer to the WebAssemblySubtarget around so that we can make the
4476560Sbmah  /// right decision when generating code for different targets.
4576560Sbmah  const WebAssemblySubtarget *Subtarget;
4676560Sbmah
4776560Sbmah  FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
4876082Sbmah                           const TargetLibraryInfo *LibInfo) const override;
4976082Sbmah  bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
5087808Sbmah  MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
5176082Sbmah  const char *getTargetNodeName(unsigned Opcode) const override;
5276082Sbmah  std::pair<unsigned, const TargetRegisterClass *> getRegForInlineAsmConstraint(
5376082Sbmah      const TargetRegisterInfo *TRI, StringRef Constraint,
5476082Sbmah      MVT VT) const override;
5576082Sbmah  bool isCheapToSpeculateCttz() const override;
5684568Sbmah  bool isCheapToSpeculateCtlz() const override;
5776082Sbmah  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
5876082Sbmah                             unsigned AS) const override;
5976082Sbmah  bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, unsigned Align,
6076082Sbmah                                      bool *Fast) const override;
6176082Sbmah  bool isIntDivCheap(EVT VT, AttributeSet Attr) const override;
6276082Sbmah
6376082Sbmah  SDValue LowerCall(CallLoweringInfo &CLI,
6476082Sbmah                    SmallVectorImpl<SDValue> &InVals) const override;
6576082Sbmah  bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
6676082Sbmah                      bool isVarArg,
6776082Sbmah                      const SmallVectorImpl<ISD::OutputArg> &Outs,
6888889Sbmah                      LLVMContext &Context) const override;
6976082Sbmah  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
7076082Sbmah                      const SmallVectorImpl<ISD::OutputArg> &Outs,
7176082Sbmah                      const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
7276082Sbmah                      SelectionDAG &DAG) const override;
7376082Sbmah  SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
7486055Sbmah                               bool IsVarArg,
7576082Sbmah                               const SmallVectorImpl<ISD::InputArg> &Ins,
7676082Sbmah                               const SDLoc &DL, SelectionDAG &DAG,
7776082Sbmah                               SmallVectorImpl<SDValue> &InVals) const override;
7876082Sbmah
7976082Sbmah  // Custom lowering hooks.
8084568Sbmah  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
8176082Sbmah  SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
8276082Sbmah  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
8376082Sbmah  SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
8476082Sbmah  SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
8576082Sbmah  SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
8676082Sbmah  SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
8776082Sbmah  SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
8876082Sbmah  SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;
8987357Sbmah};
9087357Sbmah
9187357Sbmahnamespace WebAssembly {
9287357SbmahFastISel *createFastISel(FunctionLoweringInfo &funcInfo,
9387357Sbmah                         const TargetLibraryInfo *libInfo);
9487357Sbmah}  // end namespace WebAssembly
9576082Sbmah
9676082Sbmah}  // end namespace llvm
9776082Sbmah
9886055Sbmah#endif
9976082Sbmah