LLVM  16.0.0git
SelectionDAGTargetInfo.h
Go to the documentation of this file.
1 //==- llvm/CodeGen/SelectionDAGTargetInfo.h - SelectionDAG Info --*- C++ -*-==//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SelectionDAGTargetInfo class, which targets can
10 // subclass to parameterize the SelectionDAG lowering and instruction
11 // selection process.
12 //
13 //===----------------------------------------------------------------------===//
14 
15 #ifndef LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
16 #define LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
17 
20 #include "llvm/Support/CodeGen.h"
21 #include <utility>
22 
23 namespace llvm {
24 
25 class SelectionDAG;
26 
27 //===----------------------------------------------------------------------===//
28 /// Targets can subclass this to parameterize the
29 /// SelectionDAG lowering and instruction selection process.
30 ///
32 public:
33  explicit SelectionDAGTargetInfo() = default;
36  virtual ~SelectionDAGTargetInfo();
37 
38  /// Emit target-specific code that performs a memcpy.
39  /// This can be used by targets to provide code sequences for cases
40  /// that don't fit the target's parameters for simple loads/stores and can be
41  /// more efficient than using a library call. This function can return a null
42  /// SDValue if the target declines to use custom code and a different
43  /// lowering strategy should be used.
44  ///
45  /// If AlwaysInline is true, the size is constant and the target should not
46  /// emit any calls and is strongly encouraged to attempt to emit inline code
47  /// even if it is beyond the usual threshold because this intrinsic is being
48  /// expanded in a place where calls are not feasible (e.g. within the prologue
49  /// for another call). If the target chooses to decline an AlwaysInline
50  /// request here, legalize will resort to using simple loads and stores.
52  SDValue Chain, SDValue Op1,
53  SDValue Op2, SDValue Op3,
54  Align Alignment, bool isVolatile,
55  bool AlwaysInline,
56  MachinePointerInfo DstPtrInfo,
57  MachinePointerInfo SrcPtrInfo) const {
58  return SDValue();
59  }
60 
61  /// Emit target-specific code that performs a memmove.
62  /// This can be used by targets to provide code sequences for cases
63  /// that don't fit the target's parameters for simple loads/stores and can be
64  /// more efficient than using a library call. This function can return a null
65  /// SDValue if the target declines to use custom code and a different
66  /// lowering strategy should be used.
68  SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
69  SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
70  MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
71  return SDValue();
72  }
73 
74  /// Emit target-specific code that performs a memset.
75  /// This can be used by targets to provide code sequences for cases
76  /// that don't fit the target's parameters for simple stores and can be more
77  /// efficient than using a library call. This function can return a null
78  /// SDValue if the target declines to use custom code and a different
79  /// lowering strategy should be used. Note that if AlwaysInline is true the
80  /// function has to return a valid SDValue.
82  SDValue Chain, SDValue Op1,
83  SDValue Op2, SDValue Op3,
84  Align Alignment, bool isVolatile,
85  bool AlwaysInline,
86  MachinePointerInfo DstPtrInfo) const {
87  return SDValue();
88  }
89 
90  /// Emit target-specific code that performs a memcmp/bcmp, 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>
96  SDValue Op1, SDValue Op2, SDValue Op3,
97  MachinePointerInfo Op1PtrInfo,
98  MachinePointerInfo Op2PtrInfo) const {
99  return std::make_pair(SDValue(), SDValue());
100  }
101 
102  /// Emit target-specific code that performs a memchr, in cases where that is
103  /// faster than a libcall. The first returned SDValue is the result of the
104  /// memchr and the second is the chain. Both SDValues can be null if a normal
105  /// libcall should be used.
106  virtual std::pair<SDValue, SDValue>
108  SDValue Src, SDValue Char, SDValue Length,
109  MachinePointerInfo SrcPtrInfo) const {
110  return std::make_pair(SDValue(), SDValue());
111  }
112 
113  /// Emit target-specific code that performs a strcpy or stpcpy, in cases
114  /// where that is faster than a libcall.
115  /// The first returned SDValue is the result of the copy (the start
116  /// of the destination string for strcpy, a pointer to the null terminator
117  /// for stpcpy) and the second is the chain. Both SDValues can be null
118  /// if a normal libcall should be used.
119  virtual std::pair<SDValue, SDValue>
121  SDValue Dest, SDValue Src,
122  MachinePointerInfo DestPtrInfo,
123  MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
124  return std::make_pair(SDValue(), SDValue());
125  }
126 
127  /// Emit target-specific code that performs a strcmp, in cases where that is
128  /// faster than a libcall.
129  /// The first returned SDValue is the result of the strcmp and the second is
130  /// the chain. Both SDValues can be null if a normal libcall should be used.
131  virtual std::pair<SDValue, SDValue>
133  SDValue Op1, SDValue Op2,
134  MachinePointerInfo Op1PtrInfo,
135  MachinePointerInfo Op2PtrInfo) const {
136  return std::make_pair(SDValue(), SDValue());
137  }
138 
139  virtual std::pair<SDValue, SDValue>
141  SDValue Src, MachinePointerInfo SrcPtrInfo) const {
142  return std::make_pair(SDValue(), SDValue());
143  }
144 
145  virtual std::pair<SDValue, SDValue>
147  SDValue Src, SDValue MaxLength,
148  MachinePointerInfo SrcPtrInfo) const {
149  return std::make_pair(SDValue(), SDValue());
150  }
151 
153  SDValue Chain, SDValue Addr,
154  SDValue Size,
155  MachinePointerInfo DstPtrInfo,
156  bool ZeroData) const {
157  return SDValue();
158  }
159 
160  // Return true if the DAG Combiner should disable generic combines.
161  virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const {
162  return false;
163  }
164 };
165 
166 } // end namespace llvm
167 
168 #endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
llvm::SelectionDAGTargetInfo::EmitTargetCodeForStrnlen
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
Definition: SelectionDAGTargetInfo.h:146
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
llvm::SDLoc
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Definition: SelectionDAGNodes.h:1106
llvm::SelectionDAGTargetInfo::~SelectionDAGTargetInfo
virtual ~SelectionDAGTargetInfo()
llvm::SelectionDAGTargetInfo::SelectionDAGTargetInfo
SelectionDAGTargetInfo()=default
llvm::SelectionDAGTargetInfo::EmitTargetCodeForMemchr
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemchr(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Src, SDValue Char, SDValue Length, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memchr, in cases where that is faster than a libcall.
Definition: SelectionDAGTargetInfo.h:107
llvm::SelectionDAGTargetInfo::operator=
SelectionDAGTargetInfo & operator=(const SelectionDAGTargetInfo &)=delete
llvm::SelectionDAGTargetInfo::EmitTargetCodeForSetTag
virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Addr, SDValue Size, MachinePointerInfo DstPtrInfo, bool ZeroData) const
Definition: SelectionDAGTargetInfo.h:152
llvm::SelectionDAG
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:220
SelectionDAGNodes.h
llvm::SelectionDAGTargetInfo
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
Definition: SelectionDAGTargetInfo.h:31
llvm::SelectionDAGTargetInfo::EmitTargetCodeForStrcpy
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcpy(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Dest, SDValue Src, MachinePointerInfo DestPtrInfo, MachinePointerInfo SrcPtrInfo, bool isStpcpy) const
Emit target-specific code that performs a strcpy or stpcpy, in cases where that is faster than a libc...
Definition: SelectionDAGTargetInfo.h:120
llvm::SelectionDAGTargetInfo::EmitTargetCodeForMemset
virtual SDValue EmitTargetCodeForMemset(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo) const
Emit target-specific code that performs a memset.
Definition: SelectionDAGTargetInfo.h:81
llvm::Align
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
llvm::SelectionDAGTargetInfo::EmitTargetCodeForStrlen
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
Definition: SelectionDAGTargetInfo.h:140
Addr
uint64_t Addr
Definition: ELFObjHandler.cpp:79
llvm::MachinePointerInfo
This class contains a discriminated union of information about pointers in memory operands,...
Definition: MachineMemOperand.h:39
llvm::SelectionDAGTargetInfo::disableGenericCombines
virtual bool disableGenericCombines(CodeGenOpt::Level OptLevel) const
Definition: SelectionDAGTargetInfo.h:161
llvm::SelectionDAGTargetInfo::EmitTargetCodeForMemcmp
virtual std::pair< SDValue, SDValue > EmitTargetCodeForMemcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a memcmp/bcmp, in cases where that is faster than a libcall.
Definition: SelectionDAGTargetInfo.h:95
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::CodeGenOpt::Level
Level
Definition: CodeGen.h:52
llvm::SDValue
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Definition: SelectionDAGNodes.h:145
llvm::SelectionDAGTargetInfo::EmitTargetCodeForMemcpy
virtual SDValue EmitTargetCodeForMemcpy(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, bool AlwaysInline, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memcpy.
Definition: SelectionDAGTargetInfo.h:51
CodeGen.h
llvm::SelectionDAGTargetInfo::EmitTargetCodeForMemmove
virtual SDValue EmitTargetCodeForMemmove(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const
Emit target-specific code that performs a memmove.
Definition: SelectionDAGTargetInfo.h:67
MachineMemOperand.h
llvm::SelectionDAGTargetInfo::EmitTargetCodeForStrcmp
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrcmp(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1, SDValue Op2, MachinePointerInfo Op1PtrInfo, MachinePointerInfo Op2PtrInfo) const
Emit target-specific code that performs a strcmp, in cases where that is faster than a libcall.
Definition: SelectionDAGTargetInfo.h:132