1 //==-- llvm/Target/TargetSelectionDAGInfo.h - SelectionDAG Info --*- 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 // This file declares the TargetSelectionDAGInfo class, which targets can
11 // subclass to parameterize the SelectionDAG lowering and instruction
12 // selection process.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_TARGET_TARGETSELECTIONDAGINFO_H
17 #define LLVM_TARGET_TARGETSELECTIONDAGINFO_H
18 
19 #include "llvm/CodeGen/SelectionDAGNodes.h"
20 
21 namespace llvm {
22 
23 class DataLayout;
24 
25 //===----------------------------------------------------------------------===//
26 /// TargetSelectionDAGInfo - Targets can subclass this to parameterize the
27 /// SelectionDAG lowering and instruction selection process.
28 ///
29 class TargetSelectionDAGInfo {
30   TargetSelectionDAGInfo(const TargetSelectionDAGInfo &) = delete;
31   void operator=(const TargetSelectionDAGInfo &) = delete;
32 
33   const DataLayout *DL;
34 
35 protected:
getDataLayout()36   const DataLayout *getDataLayout() const { return DL; }
37 
38 public:
39   explicit TargetSelectionDAGInfo(const DataLayout *DL);
40   virtual ~TargetSelectionDAGInfo();
41 
42   /// EmitTargetCodeForMemcpy - Emit target-specific code that performs a
43   /// memcpy. This can be used by targets to provide code sequences for cases
44   /// that don't fit the target's parameters for simple loads/stores and can be
45   /// more efficient than using a library call. This function can return a null
46   /// SDValue if the target declines to use custom code and a different
47   /// lowering strategy should be used.
48   ///
49   /// If AlwaysInline is true, the size is constant and the target should not
50   /// emit any calls and is strongly encouraged to attempt to emit inline code
51   /// even if it is beyond the usual threshold because this intrinsic is being
52   /// expanded in a place where calls are not feasible (e.g. within the prologue
53   /// for another call). If the target chooses to decline an AlwaysInline
54   /// request here, legalize will resort to using simple loads and stores.
55   virtual SDValue
EmitTargetCodeForMemcpy(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,unsigned Align,bool isVolatile,bool AlwaysInline,MachinePointerInfo DstPtrInfo,MachinePointerInfo SrcPtrInfo)56   EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl,
57                           SDValue Chain,
58                           SDValue Op1, SDValue Op2,
59                           SDValue Op3, unsigned Align, bool isVolatile,
60                           bool AlwaysInline,
61                           MachinePointerInfo DstPtrInfo,
62                           MachinePointerInfo SrcPtrInfo) const {
63     return SDValue();
64   }
65 
66   /// EmitTargetCodeForMemmove - Emit target-specific code that performs a
67   /// memmove. This can be used by targets to provide code sequences for cases
68   /// that don't fit the target's parameters for simple loads/stores and can be
69   /// more efficient than using a library call. This function can return a null
70   /// SDValue if the target declines to use custom code and a different
71   /// lowering strategy should be used.
72   virtual SDValue
EmitTargetCodeForMemmove(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,unsigned Align,bool isVolatile,MachinePointerInfo DstPtrInfo,MachinePointerInfo SrcPtrInfo)73   EmitTargetCodeForMemmove(SelectionDAG &DAG, SDLoc dl,
74                            SDValue Chain,
75                            SDValue Op1, SDValue Op2,
76                            SDValue Op3, unsigned Align, bool isVolatile,
77                            MachinePointerInfo DstPtrInfo,
78                            MachinePointerInfo SrcPtrInfo) const {
79     return SDValue();
80   }
81 
82   /// EmitTargetCodeForMemset - Emit target-specific code that performs a
83   /// memset. This can be used by targets to provide code sequences for cases
84   /// that don't fit the target's parameters for simple stores and can be more
85   /// efficient than using a library call. This function can return a null
86   /// SDValue if the target declines to use custom code and a different
87   /// lowering strategy should be used.
88   virtual SDValue
EmitTargetCodeForMemset(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,unsigned Align,bool isVolatile,MachinePointerInfo DstPtrInfo)89   EmitTargetCodeForMemset(SelectionDAG &DAG, SDLoc dl,
90                           SDValue Chain,
91                           SDValue Op1, SDValue Op2,
92                           SDValue Op3, unsigned Align, bool isVolatile,
93                           MachinePointerInfo DstPtrInfo) const {
94     return SDValue();
95   }
96 
97   /// EmitTargetCodeForMemcmp - Emit target-specific code that performs a
98   /// memcmp, in cases where that is faster than a libcall.  The first
99   /// returned SDValue is the result of the memcmp and the second is
100   /// the chain.  Both SDValues can be null if a normal libcall should
101   /// be used.
102   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemcmp(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Op1,SDValue Op2,SDValue Op3,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)103   EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl,
104                           SDValue Chain,
105                           SDValue Op1, SDValue Op2,
106                           SDValue Op3, MachinePointerInfo Op1PtrInfo,
107                           MachinePointerInfo Op2PtrInfo) const {
108     return std::make_pair(SDValue(), SDValue());
109   }
110 
111   /// EmitTargetCodeForMemchr - Emit target-specific code that performs a
112   /// memchr, in cases where that is faster than a libcall.  The first
113   /// returned SDValue is the result of the memchr and the second is
114   /// the chain.  Both SDValues can be null if a normal libcall should
115   /// be used.
116   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForMemchr(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Src,SDValue Char,SDValue Length,MachinePointerInfo SrcPtrInfo)117   EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
118                           SDValue Src, SDValue Char, SDValue Length,
119                           MachinePointerInfo SrcPtrInfo) const {
120     return std::make_pair(SDValue(), SDValue());
121   }
122 
123   /// EmitTargetCodeForStrcpy - Emit target-specific code that performs a
124   /// strcpy or stpcpy, in cases where that is faster than a libcall.
125   /// The first returned SDValue is the result of the copy (the start
126   /// of the destination string for strcpy, a pointer to the null terminator
127   /// for stpcpy) and the second is the chain.  Both SDValues can be null
128   /// if a normal libcall should be used.
129   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcpy(SelectionDAG & DAG,SDLoc DL,SDValue Chain,SDValue Dest,SDValue Src,MachinePointerInfo DestPtrInfo,MachinePointerInfo SrcPtrInfo,bool isStpcpy)130   EmitTargetCodeForStrcpy(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
131                           SDValue Dest, SDValue Src,
132                           MachinePointerInfo DestPtrInfo,
133                           MachinePointerInfo SrcPtrInfo,
134                           bool isStpcpy) const {
135     return std::make_pair(SDValue(), SDValue());
136   }
137 
138   /// EmitTargetCodeForStrcmp - Emit target-specific code that performs a
139   /// strcmp, in cases where that is faster than a libcall.  The first
140   /// returned SDValue is the result of the strcmp and the second is
141   /// the chain.  Both SDValues can be null if a normal libcall should
142   /// be used.
143   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrcmp(SelectionDAG & DAG,SDLoc dl,SDValue Chain,SDValue Op1,SDValue Op2,MachinePointerInfo Op1PtrInfo,MachinePointerInfo Op2PtrInfo)144   EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl,
145                           SDValue Chain,
146                           SDValue Op1, SDValue Op2,
147                           MachinePointerInfo Op1PtrInfo,
148                           MachinePointerInfo Op2PtrInfo) const {
149     return std::make_pair(SDValue(), SDValue());
150   }
151 
152   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrlen(SelectionDAG & DAG,SDLoc DL,SDValue Chain,SDValue Src,MachinePointerInfo SrcPtrInfo)153   EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
154                           SDValue Src, MachinePointerInfo SrcPtrInfo) const {
155     return std::make_pair(SDValue(), SDValue());
156   }
157 
158   virtual std::pair<SDValue, SDValue>
EmitTargetCodeForStrnlen(SelectionDAG & DAG,SDLoc DL,SDValue Chain,SDValue Src,SDValue MaxLength,MachinePointerInfo SrcPtrInfo)159   EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
160                            SDValue Src, SDValue MaxLength,
161                            MachinePointerInfo SrcPtrInfo) const {
162     return std::make_pair(SDValue(), SDValue());
163   }
164 };
165 
166 } // end llvm namespace
167 
168 #endif
169