LLVM 20.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
21#include <utility>
22
23namespace llvm {
24
25class SelectionDAG;
26
27//===----------------------------------------------------------------------===//
28/// Targets can subclass this to parameterize the
29/// SelectionDAG lowering and instruction selection process.
30///
32public:
33 explicit SelectionDAGTargetInfo() = default;
37
38 /// Returns true if a node with the given target-specific opcode has
39 /// a memory operand. Nodes with such opcodes can only be created with
40 /// `SelectionDAG::getMemIntrinsicNode`.
41 virtual bool isTargetMemoryOpcode(unsigned Opcode) const { return false; }
42
43 /// Returns true if a node with the given target-specific opcode has
44 /// strict floating-point semantics.
45 virtual bool isTargetStrictFPOpcode(unsigned Opcode) const { return false; }
46
47 /// Returns true if a node with the given target-specific opcode
48 /// may raise a floating-point exception.
49 virtual bool mayRaiseFPException(unsigned Opcode) const;
50
51 /// Emit target-specific code that performs a memcpy.
52 /// This can be used by targets to provide code sequences for cases
53 /// that don't fit the target's parameters for simple loads/stores and can be
54 /// more efficient than using a library call. This function can return a null
55 /// SDValue if the target declines to use custom code and a different
56 /// lowering strategy should be used.
57 ///
58 /// If AlwaysInline is true, the size is constant and the target should not
59 /// emit any calls and is strongly encouraged to attempt to emit inline code
60 /// even if it is beyond the usual threshold because this intrinsic is being
61 /// expanded in a place where calls are not feasible (e.g. within the prologue
62 /// for another call). If the target chooses to decline an AlwaysInline
63 /// request here, legalize will resort to using simple loads and stores.
65 SDValue Chain, SDValue Op1,
66 SDValue Op2, SDValue Op3,
67 Align Alignment, bool isVolatile,
68 bool AlwaysInline,
69 MachinePointerInfo DstPtrInfo,
70 MachinePointerInfo SrcPtrInfo) const {
71 return SDValue();
72 }
73
74 /// Emit target-specific code that performs a memmove.
75 /// This can be used by targets to provide code sequences for cases
76 /// that don't fit the target's parameters for simple loads/stores and can be
77 /// more 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.
81 SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Op1,
82 SDValue Op2, SDValue Op3, Align Alignment, bool isVolatile,
83 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo) const {
84 return SDValue();
85 }
86
87 /// Emit target-specific code that performs a memset.
88 /// This can be used by targets to provide code sequences for cases
89 /// that don't fit the target's parameters for simple stores and can be more
90 /// efficient than using a library call. This function can return a null
91 /// SDValue if the target declines to use custom code and a different
92 /// lowering strategy should be used. Note that if AlwaysInline is true the
93 /// function has to return a valid SDValue.
95 SDValue Chain, SDValue Op1,
96 SDValue Op2, SDValue Op3,
97 Align Alignment, bool isVolatile,
98 bool AlwaysInline,
99 MachinePointerInfo DstPtrInfo) const {
100 return SDValue();
101 }
102
103 /// Emit target-specific code that performs a memcmp/bcmp, in cases where that is
104 /// faster than a libcall. The first returned SDValue is the result of the
105 /// memcmp 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>
109 SDValue Op1, SDValue Op2, SDValue Op3,
110 MachinePointerInfo Op1PtrInfo,
111 MachinePointerInfo Op2PtrInfo) const {
112 return std::make_pair(SDValue(), SDValue());
113 }
114
115 /// Emit target-specific code that performs a memchr, in cases where that is
116 /// faster than a libcall. The first returned SDValue is the result of the
117 /// memchr and the second is the chain. Both SDValues can be null if a normal
118 /// libcall should be used.
119 virtual std::pair<SDValue, SDValue>
121 SDValue Src, SDValue Char, SDValue Length,
122 MachinePointerInfo SrcPtrInfo) const {
123 return std::make_pair(SDValue(), SDValue());
124 }
125
126 /// Emit target-specific code that performs a strcpy or stpcpy, in cases
127 /// where that is faster than a libcall.
128 /// The first returned SDValue is the result of the copy (the start
129 /// of the destination string for strcpy, a pointer to the null terminator
130 /// for stpcpy) and the second is the chain. Both SDValues can be null
131 /// if a normal libcall should be used.
132 virtual std::pair<SDValue, SDValue>
134 SDValue Dest, SDValue Src,
135 MachinePointerInfo DestPtrInfo,
136 MachinePointerInfo SrcPtrInfo, bool isStpcpy) const {
137 return std::make_pair(SDValue(), SDValue());
138 }
139
140 /// Emit target-specific code that performs a strcmp, in cases where that is
141 /// faster than a libcall.
142 /// The first returned SDValue is the result of the strcmp and the second is
143 /// the chain. Both SDValues can be null if a normal libcall should be used.
144 virtual std::pair<SDValue, SDValue>
146 SDValue Op1, SDValue Op2,
147 MachinePointerInfo Op1PtrInfo,
148 MachinePointerInfo Op2PtrInfo) const {
149 return std::make_pair(SDValue(), SDValue());
150 }
151
152 virtual std::pair<SDValue, SDValue>
154 SDValue Src, MachinePointerInfo SrcPtrInfo) const {
155 return std::make_pair(SDValue(), SDValue());
156 }
157
158 virtual std::pair<SDValue, SDValue>
160 SDValue Src, SDValue MaxLength,
161 MachinePointerInfo SrcPtrInfo) const {
162 return std::make_pair(SDValue(), SDValue());
163 }
164
166 SDValue Chain, SDValue Addr,
168 MachinePointerInfo DstPtrInfo,
169 bool ZeroData) const {
170 return SDValue();
171 }
172
173 // Return true if the DAG Combiner should disable generic combines.
174 virtual bool disableGenericCombines(CodeGenOptLevel OptLevel) const {
175 return false;
176 }
177};
178
179} // end namespace llvm
180
181#endif // LLVM_CODEGEN_SELECTIONDAGTARGETINFO_H
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
uint64_t Addr
uint64_t Size
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
virtual bool isTargetStrictFPOpcode(unsigned Opcode) const
Returns true if a node with the given target-specific opcode has strict floating-point semantics.
virtual bool mayRaiseFPException(unsigned Opcode) const
Returns true if a node with the given target-specific opcode may raise a floating-point exception.
virtual bool isTargetMemoryOpcode(unsigned Opcode) const
Returns true if a node with the given target-specific opcode has a memory operand.
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.
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrnlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, SDValue MaxLength, MachinePointerInfo SrcPtrInfo) const
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.
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.
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...
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.
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.
SelectionDAGTargetInfo & operator=(const SelectionDAGTargetInfo &)=delete
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.
virtual bool disableGenericCombines(CodeGenOptLevel OptLevel) const
SelectionDAGTargetInfo(const SelectionDAGTargetInfo &)=delete
virtual std::pair< SDValue, SDValue > EmitTargetCodeForStrlen(SelectionDAG &DAG, const SDLoc &DL, SDValue Chain, SDValue Src, MachinePointerInfo SrcPtrInfo) const
virtual SDValue EmitTargetCodeForSetTag(SelectionDAG &DAG, const SDLoc &dl, SDValue Chain, SDValue Addr, SDValue Size, MachinePointerInfo DstPtrInfo, bool ZeroData) const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:228
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Length
Definition: DWP.cpp:480
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
This class contains a discriminated union of information about pointers in memory operands,...