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
|
2018-05-01 23:54:18 +08:00
|
|
|
/// This file defines the interfaces that WebAssembly uses to lower LLVM
|
2015-06-30 07:51:55 +08:00
|
|
|
/// code into a selection DAG.
|
|
|
|
///
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
|
|
|
|
#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H
|
|
|
|
|
2017-11-17 09:07:10 +08:00
|
|
|
#include "llvm/CodeGen/TargetLowering.h"
|
2015-06-30 07:51:55 +08:00
|
|
|
|
|
|
|
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;
|
2017-11-28 09:13:40 +08:00
|
|
|
MachineBasicBlock *
|
|
|
|
EmitInstrWithCustomInserter(MachineInstr &MI,
|
|
|
|
MachineBasicBlock *MBB) 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,
|
2017-07-21 19:59:37 +08:00
|
|
|
unsigned AS,
|
|
|
|
Instruction *I = nullptr) const override;
|
2016-01-26 11:39:31 +08:00
|
|
|
bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, unsigned Align,
|
|
|
|
bool *Fast) const override;
|
Rename AttributeSet to AttributeList
Summary:
This class is a list of AttributeSetNodes corresponding the function
prototype of a call or function declaration. This class used to be
called ParamAttrListPtr, then AttrListPtr, then AttributeSet. It is
typically accessed by parameter and return value index, so
"AttributeList" seems like a more intuitive name.
Rename AttributeSetImpl to AttributeListImpl to follow suit.
It's useful to rename this class so that we can rename AttributeSetNode
to AttributeSet later. AttributeSet is the set of attributes that apply
to a single function, argument, or return value.
Reviewers: sanjoy, javed.absar, chandlerc, pete
Reviewed By: pete
Subscribers: pete, jholewinski, arsenm, dschuff, mehdi_amini, jfb, nhaehnle, sbc100, void, llvm-commits
Differential Revision: https://reviews.llvm.org/D31102
llvm-svn: 298393
2017-03-22 00:57:19 +08:00
|
|
|
bool isIntDivCheap(EVT VT, AttributeList Attr) const override;
|
2015-08-12 04:13:18 +08:00
|
|
|
|
2018-06-29 01:27:09 +08:00
|
|
|
EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,
|
|
|
|
EVT VT) const override;
|
|
|
|
|
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,
|
2016-06-12 23:39:02 +08:00
|
|
|
const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
|
2015-07-23 05:28:15 +08:00
|
|
|
SelectionDAG &DAG) const override;
|
|
|
|
SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
|
|
|
|
bool IsVarArg,
|
|
|
|
const SmallVectorImpl<ISD::InputArg> &Ins,
|
2016-06-12 23:39:02 +08:00
|
|
|
const SDLoc &DL, SelectionDAG &DAG,
|
2015-07-23 05:28:15 +08:00
|
|
|
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;
|
[WebAssembly] Support instruction selection for catching exceptions
Summary:
This lowers exception catching-related instructions:
1. Lowers `wasm.catch` intrinsic to `catch` instruction
2. Removes `catchpad` and `cleanuppad` instructions; they are not
necessary after isel phase. (`MachineBasicBlock::isEHFuncletEntry()` or
`MachineBasicBlock::isEHPad()` can be used instead.)
3. Lowers `catchret` and `cleanupret` instructions to pseudo `catchret`
and `cleanupret` instructions in isel, which will be replaced with other
instructions in `WebAssemblyExceptionPrepare` pass.
4. Adds 'WebAssemblyExceptionPrepare` pass, which is for running various
transformation for EH. Currently this pass only replaces `catchret` and
`cleanupret` instructions into appropriate wasm instructions to make
this patch successfully run until the end.
Currently this does not handle lowering of intrinsics related to LSDA
info generation (`wasm.landingpad.index` and `wasm.lsda`), because they
cannot be tested without implementing `EHStreamer`'s wasm-specific
handlers. They are marked as TODO, which is needed to make isel pass.
Also this does not generate `try` and `end_try` markers yet, which will
be handled in later patches.
This patch is based on the first wasm EH proposal.
(https://github.com/WebAssembly/exception-handling/blob/master/proposals/Exceptions.md)
Reviewers: dschuff, majnemer
Subscribers: jfb, sbc100, jgravelle-google, sunfish, llvm-commits
Differential Revision: https://reviews.llvm.org/D44090
llvm-svn: 333705
2018-06-01 06:25:54 +08:00
|
|
|
SDValue LowerINTRINSIC_WO_CHAIN(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
|