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