Path: blob/main/contrib/llvm-project/llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.h
35294 views
//- WebAssemblyISelLowering.h - WebAssembly DAG Lowering Interface -*- C++ -*-//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7///8/// \file9/// This file defines the interfaces that WebAssembly uses to lower LLVM10/// code into a selection DAG.11///12//===----------------------------------------------------------------------===//1314#ifndef LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H15#define LLVM_LIB_TARGET_WEBASSEMBLY_WEBASSEMBLYISELLOWERING_H1617#include "llvm/CodeGen/TargetLowering.h"1819namespace llvm {2021namespace WebAssemblyISD {2223enum NodeType : unsigned {24FIRST_NUMBER = ISD::BUILTIN_OP_END,25#define HANDLE_NODETYPE(NODE) NODE,26#define HANDLE_MEM_NODETYPE(NODE)27#include "WebAssemblyISD.def"28FIRST_MEM_OPCODE = ISD::FIRST_TARGET_MEMORY_OPCODE,29#undef HANDLE_NODETYPE30#undef HANDLE_MEM_NODETYPE31#define HANDLE_NODETYPE(NODE)32#define HANDLE_MEM_NODETYPE(NODE) NODE,33#include "WebAssemblyISD.def"34#undef HANDLE_NODETYPE35#undef HANDLE_MEM_NODETYPE36};3738} // end namespace WebAssemblyISD3940class WebAssemblySubtarget;4142class WebAssemblyTargetLowering final : public TargetLowering {43public:44WebAssemblyTargetLowering(const TargetMachine &TM,45const WebAssemblySubtarget &STI);4647MVT getPointerTy(const DataLayout &DL, uint32_t AS = 0) const override;48MVT getPointerMemTy(const DataLayout &DL, uint32_t AS = 0) const override;4950private:51/// Keep a pointer to the WebAssemblySubtarget around so that we can make the52/// right decision when generating code for different targets.53const WebAssemblySubtarget *Subtarget;5455AtomicExpansionKind shouldExpandAtomicRMWInIR(AtomicRMWInst *) const override;56bool shouldScalarizeBinop(SDValue VecOp) const override;57FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,58const TargetLibraryInfo *LibInfo) const override;59MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;60MachineBasicBlock *61EmitInstrWithCustomInserter(MachineInstr &MI,62MachineBasicBlock *MBB) const override;63const char *getTargetNodeName(unsigned Opcode) const override;64std::pair<unsigned, const TargetRegisterClass *>65getRegForInlineAsmConstraint(const TargetRegisterInfo *TRI,66StringRef Constraint, MVT VT) const override;67bool isCheapToSpeculateCttz(Type *Ty) const override;68bool isCheapToSpeculateCtlz(Type *Ty) const override;69bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,70unsigned AS,71Instruction *I = nullptr) const override;72bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, Align Alignment,73MachineMemOperand::Flags Flags,74unsigned *Fast) const override;75bool isIntDivCheap(EVT VT, AttributeList Attr) const override;76bool isVectorLoadExtDesirable(SDValue ExtVal) const override;77bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;78bool shouldSinkOperands(Instruction *I,79SmallVectorImpl<Use *> &Ops) const override;80EVT getSetCCResultType(const DataLayout &DL, LLVMContext &Context,81EVT VT) const override;82bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,83MachineFunction &MF,84unsigned Intrinsic) const override;8586void computeKnownBitsForTargetNode(const SDValue Op, KnownBits &Known,87const APInt &DemandedElts,88const SelectionDAG &DAG,89unsigned Depth) const override;9091TargetLoweringBase::LegalizeTypeAction92getPreferredVectorAction(MVT VT) const override;9394SDValue LowerCall(CallLoweringInfo &CLI,95SmallVectorImpl<SDValue> &InVals) const override;96bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,97bool isVarArg,98const SmallVectorImpl<ISD::OutputArg> &Outs,99LLVMContext &Context) const override;100SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,101const SmallVectorImpl<ISD::OutputArg> &Outs,102const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,103SelectionDAG &DAG) const override;104SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,105bool IsVarArg,106const SmallVectorImpl<ISD::InputArg> &Ins,107const SDLoc &DL, SelectionDAG &DAG,108SmallVectorImpl<SDValue> &InVals) const override;109110void ReplaceNodeResults(SDNode *N, SmallVectorImpl<SDValue> &Results,111SelectionDAG &DAG) const override;112113bool114shouldSimplifyDemandedVectorElts(SDValue Op,115const TargetLoweringOpt &TLO) const override;116117// Custom lowering hooks.118SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;119SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;120SDValue LowerRETURNADDR(SDValue Op, SelectionDAG &DAG) const;121SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;122SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;123SDValue LowerGlobalTLSAddress(SDValue Op, SelectionDAG &DAG) const;124SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;125SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;126SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;127SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;128SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;129SDValue LowerIntrinsic(SDValue Op, SelectionDAG &DAG) const;130SDValue LowerSIGN_EXTEND_INREG(SDValue Op, SelectionDAG &DAG) const;131SDValue LowerEXTEND_VECTOR_INREG(SDValue Op, SelectionDAG &DAG) const;132SDValue LowerBUILD_VECTOR(SDValue Op, SelectionDAG &DAG) const;133SDValue LowerVECTOR_SHUFFLE(SDValue Op, SelectionDAG &DAG) const;134SDValue LowerSETCC(SDValue Op, SelectionDAG &DAG) const;135SDValue LowerAccessVectorElement(SDValue Op, SelectionDAG &DAG) const;136SDValue LowerShift(SDValue Op, SelectionDAG &DAG) const;137SDValue LowerFP_TO_INT_SAT(SDValue Op, SelectionDAG &DAG) const;138SDValue LowerLoad(SDValue Op, SelectionDAG &DAG) const;139SDValue LowerStore(SDValue Op, SelectionDAG &DAG) const;140141// Custom DAG combine hooks142SDValue143PerformDAGCombine(SDNode *N,144TargetLowering::DAGCombinerInfo &DCI) const override;145};146147namespace WebAssembly {148FastISel *createFastISel(FunctionLoweringInfo &funcInfo,149const TargetLibraryInfo *libInfo);150} // end namespace WebAssembly151152} // end namespace llvm153154#endif155156157