1 //==-- llvm/Target/TargetSelectionDAGInfo.h - SelectionDAG Info --*- C++ -*-==//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // This file declares the TargetSelectionDAGInfo class, which targets can
11 // subclass to parameterize the SelectionDAG lowering and instruction
14 //===----------------------------------------------------------------------===//
16 #ifndef LLVM_TARGET_TARGETSELECTIONDAGINFO_H
17 #define LLVM_TARGET_TARGETSELECTIONDAGINFO_H
19 #include "llvm/CodeGen/SelectionDAGNodes.h"
25 //===----------------------------------------------------------------------===//
26 /// TargetSelectionDAGInfo - Targets can subclass this to parameterize the
27 /// SelectionDAG lowering and instruction selection process.
29 class TargetSelectionDAGInfo {
30 TargetSelectionDAGInfo(const TargetSelectionDAGInfo &) = delete;
31 void operator=(const TargetSelectionDAGInfo &) = delete;
36 const DataLayout *getDataLayout() const { return DL; }
39 explicit TargetSelectionDAGInfo(const DataLayout *DL);
40 virtual ~TargetSelectionDAGInfo();
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.
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.
56 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl,
58 SDValue Op1, SDValue Op2,
59 SDValue Op3, unsigned Align, bool isVolatile,
61 MachinePointerInfo DstPtrInfo,
62 MachinePointerInfo SrcPtrInfo) const {
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.
73 EmitTargetCodeForMemmove(SelectionDAG &DAG, SDLoc dl,
75 SDValue Op1, SDValue Op2,
76 SDValue Op3, unsigned Align, bool isVolatile,
77 MachinePointerInfo DstPtrInfo,
78 MachinePointerInfo SrcPtrInfo) const {
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.
89 EmitTargetCodeForMemset(SelectionDAG &DAG, SDLoc dl,
91 SDValue Op1, SDValue Op2,
92 SDValue Op3, unsigned Align, bool isVolatile,
93 MachinePointerInfo DstPtrInfo) const {
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
102 virtual std::pair<SDValue, SDValue>
103 EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl,
105 SDValue Op1, SDValue Op2,
106 SDValue Op3, MachinePointerInfo Op1PtrInfo,
107 MachinePointerInfo Op2PtrInfo) const {
108 return std::make_pair(SDValue(), SDValue());
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
116 virtual std::pair<SDValue, SDValue>
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());
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>
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());
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
143 virtual std::pair<SDValue, SDValue>
144 EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl,
146 SDValue Op1, SDValue Op2,
147 MachinePointerInfo Op1PtrInfo,
148 MachinePointerInfo Op2PtrInfo) const {
149 return std::make_pair(SDValue(), SDValue());
152 virtual std::pair<SDValue, SDValue>
153 EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
154 SDValue Src, MachinePointerInfo SrcPtrInfo) const {
155 return std::make_pair(SDValue(), SDValue());
158 virtual std::pair<SDValue, SDValue>
159 EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
160 SDValue Src, SDValue MaxLength,
161 MachinePointerInfo SrcPtrInfo) const {
162 return std::make_pair(SDValue(), SDValue());
166 } // end llvm namespace