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