2015-06-30 07:51:55 +08:00
|
|
|
//- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
///
|
|
|
|
/// \file
|
|
|
|
/// \brief This file defines the interfaces that WebAssembly uses to lower LLVM
|
|
|
|
/// code into a selection DAG.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
|
|
|
|
|
|
|
|
#include "llvm/Target/TargetLowering.h"
|
|
|
|
|
|
|
|
namespace llvm {
|
|
|
|
|
|
|
|
namespace WebAssemblyISD {
|
|
|
|
|
2015-08-12 04:13:18 +08:00
|
|
|
enum NodeType : unsigned {
|
2015-06-30 07:51:55 +08:00
|
|
|
FIRST_NUMBER = ISD::BUILTIN_OP_END,
|
2015-08-25 06:16:48 +08:00
|
|
|
#define HANDLE_NODETYPE(NODE) NODE,
|
|
|
|
#include "WebAssemblyISD.def"
|
|
|
|
#undef HANDLE_NODETYPE
|
2015-06-30 07:51:55 +08:00
|
|
|
};
|
|
|
|
|
2016-02-12 04:57:09 +08:00
|
|
|
} // end namespace WebAssemblyISD
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
class WebAssemblySubtarget;
|
|
|
|
class WebAssemblyTargetMachine;
|
|
|
|
|
|
|
|
class WebAssemblyTargetLowering final : public TargetLowering {
|
2016-02-12 04:57:09 +08:00
|
|
|
public:
|
2015-06-30 07:51:55 +08:00
|
|
|
WebAssemblyTargetLowering(const TargetMachine &TM,
|
|
|
|
const WebAssemblySubtarget &STI);
|
|
|
|
|
2016-02-12 04:57:09 +08:00
|
|
|
private:
|
2015-06-30 07:51:55 +08:00
|
|
|
/// Keep a pointer to the WebAssemblySubtarget around so that we can make the
|
|
|
|
/// right decision when generating code for different targets.
|
|
|
|
const WebAssemblySubtarget *Subtarget;
|
2015-07-23 05:28:15 +08:00
|
|
|
|
2015-08-25 02:44:37 +08:00
|
|
|
FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
|
|
|
|
const TargetLibraryInfo *LibInfo) const override;
|
2015-08-25 06:16:48 +08:00
|
|
|
bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
|
2015-08-03 08:00:11 +08:00
|
|
|
MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
|
2015-08-12 04:13:18 +08:00
|
|
|
const char *getTargetNodeName(unsigned Opcode) const override;
|
2016-02-12 04:57:09 +08:00
|
|
|
std::pair<unsigned, const TargetRegisterClass *> getRegForInlineAsmConstraint(
|
|
|
|
const TargetRegisterInfo *TRI, StringRef Constraint,
|
|
|
|
MVT VT) const override;
|
2015-11-20 07:04:59 +08:00
|
|
|
bool isCheapToSpeculateCttz() const override;
|
|
|
|
bool isCheapToSpeculateCtlz() const override;
|
2015-12-16 06:01:29 +08:00
|
|
|
bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
|
|
|
|
unsigned AS) const override;
|
2016-01-26 11:39:31 +08:00
|
|
|
bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, unsigned Align,
|
|
|
|
bool *Fast) const override;
|
2015-08-12 04:13:18 +08:00
|
|
|
|
2015-08-25 06:16:48 +08:00
|
|
|
SDValue LowerCall(CallLoweringInfo &CLI,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2015-07-23 05:28:15 +08:00
|
|
|
bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
|
|
|
|
bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
LLVMContext &Context) const override;
|
|
|
|
SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
|
|
|
|
const SmallVectorImpl<ISD::OutputArg> &Outs,
|
|
|
|
const SmallVectorImpl<SDValue> &OutVals, SDLoc dl,
|
|
|
|
SelectionDAG &DAG) const override;
|
|
|
|
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
|
|
|
SDLoc DL, SelectionDAG &DAG,
|
|
|
|
SmallVectorImpl<SDValue> &InVals) const override;
|
2015-08-25 06:16:48 +08:00
|
|
|
|
|
|
|
// Custom lowering hooks.
|
|
|
|
SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
|
2015-12-12 07:49:46 +08:00
|
|
|
SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
|
2016-02-17 07:48:04 +08:00
|
|
|
SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
|
2015-08-25 06:16:48 +08:00
|
|
|
SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
|
2015-11-26 00:55:01 +08:00
|
|
|
SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
|
2015-09-17 00:51:30 +08:00
|
|
|
SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
|
|
|
|
SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
|
2015-12-05 07:22:35 +08:00
|
|
|
SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
|
2016-02-17 02:18:36 +08:00
|
|
|
SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;
|
2015-06-30 07:51:55 +08:00
|
|
|
};
|
|
|
|
|
2015-08-25 02:44:37 +08:00
|
|
|
namespace WebAssembly {
|
|
|
|
FastISel *createFastISel(FunctionLoweringInfo &funcInfo,
|
|
|
|
const TargetLibraryInfo *libInfo);
|
2016-02-12 04:57:09 +08:00
|
|
|
} // end namespace WebAssembly
|
2015-08-25 02:44:37 +08:00
|
|
|
|
2016-02-12 04:57:09 +08:00
|
|
|
} // end namespace llvm
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
#endif
|