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"
23 //===----------------------------------------------------------------------===//
24 /// Targets can subclass this to parameterize the
25 /// SelectionDAG lowering and instruction selection process.
27 class TargetSelectionDAGInfo {
28 TargetSelectionDAGInfo(const TargetSelectionDAGInfo &) = delete;
29 void operator=(const TargetSelectionDAGInfo &) = delete;
32 explicit TargetSelectionDAGInfo() = default;
33 virtual ~TargetSelectionDAGInfo();
35 /// Emit target-specific code that performs a memcpy.
36 /// 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.
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.
49 EmitTargetCodeForMemcpy(SelectionDAG &DAG, SDLoc dl,
51 SDValue Op1, SDValue Op2,
52 SDValue Op3, unsigned Align, bool isVolatile,
54 MachinePointerInfo DstPtrInfo,
55 MachinePointerInfo SrcPtrInfo) const {
59 /// Emit target-specific code that performs a memmove.
60 /// 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.
66 EmitTargetCodeForMemmove(SelectionDAG &DAG, SDLoc dl,
68 SDValue Op1, SDValue Op2,
69 SDValue Op3, unsigned Align, bool isVolatile,
70 MachinePointerInfo DstPtrInfo,
71 MachinePointerInfo SrcPtrInfo) const {
75 /// Emit target-specific code that performs a memset.
76 /// 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.
82 EmitTargetCodeForMemset(SelectionDAG &DAG, SDLoc dl,
84 SDValue Op1, SDValue Op2,
85 SDValue Op3, unsigned Align, bool isVolatile,
86 MachinePointerInfo DstPtrInfo) const {
90 /// Emit target-specific code that performs a memcmp, in cases where that is
91 /// faster than a libcall. The first returned SDValue is the result of the
92 /// memcmp and the second is the chain. Both SDValues can be null if a normal
93 /// libcall should be used.
94 virtual std::pair<SDValue, SDValue>
95 EmitTargetCodeForMemcmp(SelectionDAG &DAG, SDLoc dl,
97 SDValue Op1, SDValue Op2,
98 SDValue Op3, MachinePointerInfo Op1PtrInfo,
99 MachinePointerInfo Op2PtrInfo) const {
100 return std::make_pair(SDValue(), SDValue());
103 /// Emit target-specific code that performs a memchr, in cases where that is
104 /// faster than a libcall. The first returned SDValue is the result of the
105 /// memchr and the second is the chain. Both SDValues can be null if a normal
106 /// libcall should be used.
107 virtual std::pair<SDValue, SDValue>
108 EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
109 SDValue Src, SDValue Char, SDValue Length,
110 MachinePointerInfo SrcPtrInfo) const {
111 return std::make_pair(SDValue(), SDValue());
114 /// Emit target-specific code that performs a strcpy or stpcpy, in cases
115 /// where that is faster than a libcall.
116 /// The first returned SDValue is the result of the copy (the start
117 /// of the destination string for strcpy, a pointer to the null terminator
118 /// for stpcpy) and the second is the chain. Both SDValues can be null
119 /// if a normal libcall should be used.
120 virtual std::pair<SDValue, SDValue>
121 EmitTargetCodeForStrcpy(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
122 SDValue Dest, SDValue Src,
123 MachinePointerInfo DestPtrInfo,
124 MachinePointerInfo SrcPtrInfo,
125 bool isStpcpy) const {
126 return std::make_pair(SDValue(), SDValue());
129 /// Emit target-specific code that performs a strcmp, in cases where that is
130 /// faster than a libcall.
131 /// The first returned SDValue is the result of the strcmp and the second is
132 /// the chain. Both SDValues can be null if a normal libcall should be used.
133 virtual std::pair<SDValue, SDValue>
134 EmitTargetCodeForStrcmp(SelectionDAG &DAG, SDLoc dl,
136 SDValue Op1, SDValue Op2,
137 MachinePointerInfo Op1PtrInfo,
138 MachinePointerInfo Op2PtrInfo) const {
139 return std::make_pair(SDValue(), SDValue());
142 virtual std::pair<SDValue, SDValue>
143 EmitTargetCodeForStrlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
144 SDValue Src, MachinePointerInfo SrcPtrInfo) const {
145 return std::make_pair(SDValue(), SDValue());
148 virtual std::pair<SDValue, SDValue>
149 EmitTargetCodeForStrnlen(SelectionDAG &DAG, SDLoc DL, SDValue Chain,
150 SDValue Src, SDValue MaxLength,
151 MachinePointerInfo SrcPtrInfo) const {
152 return std::make_pair(SDValue(), SDValue());
156 } // end llvm namespace