LLVM  4.0.0
WebAssemblyISelLowering.h
Go to the documentation of this file.
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 
20 
21 namespace llvm {
22 
23 namespace WebAssemblyISD {
24 
25 enum NodeType : unsigned {
27 #define HANDLE_NODETYPE(NODE) NODE,
28 #include "WebAssemblyISD.def"
29 #undef HANDLE_NODETYPE
30 };
31 
32 } // end namespace WebAssemblyISD
33 
34 class WebAssemblySubtarget;
35 class WebAssemblyTargetMachine;
36 
38  public:
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;
46 
47  FastISel *createFastISel(FunctionLoweringInfo &FuncInfo,
48  const TargetLibraryInfo *LibInfo) const override;
49  bool isOffsetFoldingLegal(const GlobalAddressSDNode *GA) const override;
50  MVT getScalarShiftAmountTy(const DataLayout &DL, EVT) const override;
51  const char *getTargetNodeName(unsigned Opcode) const override;
52  std::pair<unsigned, const TargetRegisterClass *> getRegForInlineAsmConstraint(
53  const TargetRegisterInfo *TRI, StringRef Constraint,
54  MVT VT) const override;
55  bool isCheapToSpeculateCttz() const override;
56  bool isCheapToSpeculateCtlz() const override;
57  bool isLegalAddressingMode(const DataLayout &DL, const AddrMode &AM, Type *Ty,
58  unsigned AS) const override;
59  bool allowsMisalignedMemoryAccesses(EVT, unsigned AddrSpace, unsigned Align,
60  bool *Fast) const override;
61  bool isIntDivCheap(EVT VT, AttributeSet Attr) const override;
62 
63  SDValue LowerCall(CallLoweringInfo &CLI,
64  SmallVectorImpl<SDValue> &InVals) const override;
65  bool CanLowerReturn(CallingConv::ID CallConv, MachineFunction &MF,
66  bool isVarArg,
68  LLVMContext &Context) const override;
69  SDValue LowerReturn(SDValue Chain, CallingConv::ID CallConv, bool isVarArg,
71  const SmallVectorImpl<SDValue> &OutVals, const SDLoc &dl,
72  SelectionDAG &DAG) const override;
73  SDValue LowerFormalArguments(SDValue Chain, CallingConv::ID CallConv,
74  bool IsVarArg,
76  const SDLoc &DL, SelectionDAG &DAG,
77  SmallVectorImpl<SDValue> &InVals) const override;
78 
79  // Custom lowering hooks.
80  SDValue LowerOperation(SDValue Op, SelectionDAG &DAG) const override;
81  SDValue LowerFrameIndex(SDValue Op, SelectionDAG &DAG) const;
82  SDValue LowerFRAMEADDR(SDValue Op, SelectionDAG &DAG) const;
83  SDValue LowerGlobalAddress(SDValue Op, SelectionDAG &DAG) const;
84  SDValue LowerExternalSymbol(SDValue Op, SelectionDAG &DAG) const;
85  SDValue LowerBR_JT(SDValue Op, SelectionDAG &DAG) const;
86  SDValue LowerJumpTable(SDValue Op, SelectionDAG &DAG) const;
87  SDValue LowerVASTART(SDValue Op, SelectionDAG &DAG) const;
88  SDValue LowerCopyToReg(SDValue Op, SelectionDAG &DAG) const;
89 };
90 
91 namespace WebAssembly {
93  const TargetLibraryInfo *libInfo);
94 } // end namespace WebAssembly
95 
96 } // end namespace llvm
97 
98 #endif
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:762
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:102
This represents an addressing mode of: BaseGV + BaseOffs + BaseReg + Scale*ScaleReg If BaseGV is null...
LLVMContext & Context
FastISel * createFastISel(FunctionLoweringInfo &funcInfo, const TargetLibraryInfo *libInfo)
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:32
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This is a fast-path instruction selection class that generates poor code and doesn't support illegal ...
Definition: FastISel.h:31
MVT - Machine Value Type.
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:48
EVT - Extended Value Type.
Definition: ValueTypes.h:31
TargetRegisterInfo base class - We assume that the target defines a static array of TargetRegisterDes...
This structure contains all information that is necessary for lowering calls.
WebAssemblyTargetLowering(const TargetMachine &TM, const WebAssemblySubtarget &STI)
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:166
Provides information about what library functions are available for the current target.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Primary interface to the complete machine description for the target machine.
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:47
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Fast - This calling convention attempts to make calls as fast as possible (e.g.
Definition: CallingConv.h:42
This file describes how to lower LLVM code to machine code.