clang -cc1 -cc1 -triple amd64-unknown-openbsd7.0 -analyze -disable-free -disable-llvm-verifier -discard-value-names -main-file-name X86SelectionDAGInfo.cpp -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 1 -fhalf-no-semantic-interposition -mframe-pointer=all -relaxed-aliasing -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/usr/src/gnu/usr.bin/clang/libLLVM/obj -resource-dir /usr/local/lib/clang/13.0.0 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/AMDGPU -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Analysis -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ASMParser -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/BinaryFormat -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitcode -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitcode -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Bitstream -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /include/llvm/CodeGen -I /include/llvm/CodeGen/PBQP -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/IR -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/IR -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Coroutines -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ProfileData/Coverage -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/CodeView -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/DWARF -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/MSF -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/PDB -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Demangle -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine/JITLink -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ExecutionEngine/Orc -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend/OpenACC -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Frontend/OpenMP -I /include/llvm/CodeGen/GlobalISel -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/IRReader -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/InstCombine -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/Transforms/InstCombine -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/LTO -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Linker -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/MC -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/MC/MCParser -I /include/llvm/CodeGen/MIRParser -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Object -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Option -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Passes -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ProfileData -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Scalar -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/ADT -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Support -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/DebugInfo/Symbolize -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Target -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Utils -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/Vectorize -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include/llvm/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86 -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include/llvm/Transforms/IPO -I /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/include -I /usr/src/gnu/usr.bin/clang/libLLVM/../include -I /usr/src/gnu/usr.bin/clang/libLLVM/obj -I /usr/src/gnu/usr.bin/clang/libLLVM/obj/../include -D NDEBUG -D __STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -D __STDC_FORMAT_MACROS -D LLVM_PREFIX="/usr" -D PIC -internal-isystem /usr/include/c++/v1 -internal-isystem /usr/local/lib/clang/13.0.0/include -internal-externc-isystem /usr/include -O2 -Wno-unused-parameter -Wwrite-strings -Wno-missing-field-initializers -Wno-long-long -Wno-comment -std=c++14 -fdeprecated-macro -fdebug-compilation-dir=/usr/src/gnu/usr.bin/clang/libLLVM/obj -ferror-limit 19 -fvisibility-inlines-hidden -fwrapv -D_RET_PROTECTOR -ret-protector -fno-rtti -fgnuc-version=4.2.1 -vectorize-loops -vectorize-slp -fno-builtin-malloc -fno-builtin-calloc -fno-builtin-realloc -fno-builtin-valloc -fno-builtin-free -fno-builtin-strdup -fno-builtin-strndup -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/ben/Projects/vmm/scan-build/2022-01-12-194120-40624-1 -x c++ /usr/src/gnu/usr.bin/clang/libLLVM/../../../llvm/llvm/lib/Target/X86/X86SelectionDAGInfo.cpp
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | #ifndef LLVM_CODEGEN_SELECTIONDAG_H |
15 | #define LLVM_CODEGEN_SELECTIONDAG_H |
16 | |
17 | #include "llvm/ADT/APFloat.h" |
18 | #include "llvm/ADT/APInt.h" |
19 | #include "llvm/ADT/ArrayRef.h" |
20 | #include "llvm/ADT/DenseMap.h" |
21 | #include "llvm/ADT/DenseSet.h" |
22 | #include "llvm/ADT/FoldingSet.h" |
23 | #include "llvm/ADT/SetVector.h" |
24 | #include "llvm/ADT/SmallVector.h" |
25 | #include "llvm/ADT/StringMap.h" |
26 | #include "llvm/ADT/ilist.h" |
27 | #include "llvm/ADT/iterator.h" |
28 | #include "llvm/ADT/iterator_range.h" |
29 | #include "llvm/CodeGen/DAGCombine.h" |
30 | #include "llvm/CodeGen/ISDOpcodes.h" |
31 | #include "llvm/CodeGen/MachineFunction.h" |
32 | #include "llvm/CodeGen/MachineMemOperand.h" |
33 | #include "llvm/CodeGen/SelectionDAGNodes.h" |
34 | #include "llvm/CodeGen/ValueTypes.h" |
35 | #include "llvm/IR/DebugLoc.h" |
36 | #include "llvm/IR/Instructions.h" |
37 | #include "llvm/IR/Metadata.h" |
38 | #include "llvm/Support/Allocator.h" |
39 | #include "llvm/Support/ArrayRecycler.h" |
40 | #include "llvm/Support/AtomicOrdering.h" |
41 | #include "llvm/Support/Casting.h" |
42 | #include "llvm/Support/CodeGen.h" |
43 | #include "llvm/Support/ErrorHandling.h" |
44 | #include "llvm/Support/MachineValueType.h" |
45 | #include "llvm/Support/RecyclingAllocator.h" |
46 | #include <algorithm> |
47 | #include <cassert> |
48 | #include <cstdint> |
49 | #include <functional> |
50 | #include <map> |
51 | #include <string> |
52 | #include <tuple> |
53 | #include <utility> |
54 | #include <vector> |
55 | |
56 | namespace llvm { |
57 | |
58 | class AAResults; |
59 | class BlockAddress; |
60 | class BlockFrequencyInfo; |
61 | class Constant; |
62 | class ConstantFP; |
63 | class ConstantInt; |
64 | class DataLayout; |
65 | struct fltSemantics; |
66 | class FunctionLoweringInfo; |
67 | class GlobalValue; |
68 | struct KnownBits; |
69 | class LegacyDivergenceAnalysis; |
70 | class LLVMContext; |
71 | class MachineBasicBlock; |
72 | class MachineConstantPoolValue; |
73 | class MCSymbol; |
74 | class OptimizationRemarkEmitter; |
75 | class ProfileSummaryInfo; |
76 | class SDDbgValue; |
77 | class SDDbgOperand; |
78 | class SDDbgLabel; |
79 | class SelectionDAG; |
80 | class SelectionDAGTargetInfo; |
81 | class TargetLibraryInfo; |
82 | class TargetLowering; |
83 | class TargetMachine; |
84 | class TargetSubtargetInfo; |
85 | class Value; |
86 | |
87 | class SDVTListNode : public FoldingSetNode { |
88 | friend struct FoldingSetTrait<SDVTListNode>; |
89 | |
90 | |
91 | |
92 | |
93 | |
94 | |
95 | FoldingSetNodeIDRef FastID; |
96 | const EVT *VTs; |
97 | unsigned int NumVTs; |
98 | |
99 | |
100 | unsigned HashValue; |
101 | |
102 | public: |
103 | SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) : |
104 | FastID(ID), VTs(VT), NumVTs(Num) { |
105 | HashValue = ID.ComputeHash(); |
106 | } |
107 | |
108 | SDVTList getSDVTList() { |
109 | SDVTList result = {VTs, NumVTs}; |
110 | return result; |
111 | } |
112 | }; |
113 | |
114 | |
115 | |
116 | template<> struct FoldingSetTrait<SDVTListNode> : DefaultFoldingSetTrait<SDVTListNode> { |
117 | static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) { |
118 | ID = X.FastID; |
119 | } |
120 | |
121 | static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, |
122 | unsigned IDHash, FoldingSetNodeID &TempID) { |
123 | if (X.HashValue != IDHash) |
124 | return false; |
125 | return ID == X.FastID; |
126 | } |
127 | |
128 | static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) { |
129 | return X.HashValue; |
130 | } |
131 | }; |
132 | |
133 | template <> struct ilist_alloc_traits<SDNode> { |
134 | static void deleteNode(SDNode *) { |
135 | llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!"); |
136 | } |
137 | }; |
138 | |
139 | |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | |
149 | |
150 | class SDDbgInfo { |
151 | BumpPtrAllocator Alloc; |
152 | SmallVector<SDDbgValue*, 32> DbgValues; |
153 | SmallVector<SDDbgValue*, 32> ByvalParmDbgValues; |
154 | SmallVector<SDDbgLabel*, 4> DbgLabels; |
155 | using DbgValMapType = DenseMap<const SDNode *, SmallVector<SDDbgValue *, 2>>; |
156 | DbgValMapType DbgValMap; |
157 | |
158 | public: |
159 | SDDbgInfo() = default; |
160 | SDDbgInfo(const SDDbgInfo &) = delete; |
161 | SDDbgInfo &operator=(const SDDbgInfo &) = delete; |
162 | |
163 | void add(SDDbgValue *V, bool isParameter); |
164 | |
165 | void add(SDDbgLabel *L) { DbgLabels.push_back(L); } |
166 | |
167 | |
168 | |
169 | void erase(const SDNode *Node); |
170 | |
171 | void clear() { |
172 | DbgValMap.clear(); |
173 | DbgValues.clear(); |
174 | ByvalParmDbgValues.clear(); |
175 | DbgLabels.clear(); |
176 | Alloc.Reset(); |
177 | } |
178 | |
179 | BumpPtrAllocator &getAlloc() { return Alloc; } |
180 | |
181 | bool empty() const { |
182 | return DbgValues.empty() && ByvalParmDbgValues.empty() && DbgLabels.empty(); |
183 | } |
184 | |
185 | ArrayRef<SDDbgValue*> getSDDbgValues(const SDNode *Node) const { |
186 | auto I = DbgValMap.find(Node); |
187 | if (I != DbgValMap.end()) |
188 | return I->second; |
189 | return ArrayRef<SDDbgValue*>(); |
190 | } |
191 | |
192 | using DbgIterator = SmallVectorImpl<SDDbgValue*>::iterator; |
193 | using DbgLabelIterator = SmallVectorImpl<SDDbgLabel*>::iterator; |
194 | |
195 | DbgIterator DbgBegin() { return DbgValues.begin(); } |
196 | DbgIterator DbgEnd() { return DbgValues.end(); } |
197 | DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); } |
198 | DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); } |
199 | DbgLabelIterator DbgLabelBegin() { return DbgLabels.begin(); } |
200 | DbgLabelIterator DbgLabelEnd() { return DbgLabels.end(); } |
201 | }; |
202 | |
203 | void checkForCycles(const SelectionDAG *DAG, bool force = false); |
204 | |
205 | |
206 | |
207 | |
208 | |
209 | |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | |
216 | class SelectionDAG { |
217 | const TargetMachine &TM; |
218 | const SelectionDAGTargetInfo *TSI = nullptr; |
219 | const TargetLowering *TLI = nullptr; |
220 | const TargetLibraryInfo *LibInfo = nullptr; |
221 | MachineFunction *MF; |
222 | Pass *SDAGISelPass = nullptr; |
223 | LLVMContext *Context; |
224 | CodeGenOpt::Level OptLevel; |
225 | |
226 | LegacyDivergenceAnalysis * DA = nullptr; |
227 | FunctionLoweringInfo * FLI = nullptr; |
228 | |
229 | |
230 | |
231 | OptimizationRemarkEmitter *ORE; |
232 | |
233 | ProfileSummaryInfo *PSI = nullptr; |
234 | BlockFrequencyInfo *BFI = nullptr; |
235 | |
236 | |
237 | SDNode EntryNode; |
238 | |
239 | |
240 | SDValue Root; |
241 | |
242 | |
243 | ilist<SDNode> AllNodes; |
244 | |
245 | |
246 | |
247 | using NodeAllocatorType = RecyclingAllocator<BumpPtrAllocator, SDNode, |
248 | sizeof(LargestSDNode), |
249 | alignof(MostAlignedSDNode)>; |
250 | |
251 | |
252 | NodeAllocatorType NodeAllocator; |
253 | |
254 | |
255 | |
256 | FoldingSet<SDNode> CSEMap; |
257 | |
258 | |
259 | BumpPtrAllocator OperandAllocator; |
260 | ArrayRecycler<SDUse> OperandRecycler; |
261 | |
262 | |
263 | BumpPtrAllocator Allocator; |
264 | |
265 | |
266 | SDDbgInfo *DbgInfo; |
267 | |
268 | using CallSiteInfo = MachineFunction::CallSiteInfo; |
269 | using CallSiteInfoImpl = MachineFunction::CallSiteInfoImpl; |
270 | |
271 | struct CallSiteDbgInfo { |
272 | CallSiteInfo CSInfo; |
273 | MDNode *HeapAllocSite = nullptr; |
274 | bool NoMerge = false; |
275 | }; |
276 | |
277 | DenseMap<const SDNode *, CallSiteDbgInfo> SDCallSiteDbgInfo; |
278 | |
279 | uint16_t NextPersistentId = 0; |
280 | |
281 | public: |
282 | |
283 | |
284 | |
285 | |
286 | |
287 | |
288 | struct DAGUpdateListener { |
289 | DAGUpdateListener *const Next; |
290 | SelectionDAG &DAG; |
291 | |
292 | explicit DAGUpdateListener(SelectionDAG &D) |
293 | : Next(D.UpdateListeners), DAG(D) { |
294 | DAG.UpdateListeners = this; |
295 | } |
296 | |
297 | virtual ~DAGUpdateListener() { |
298 | assert(DAG.UpdateListeners == this && |
299 | "DAGUpdateListeners must be destroyed in LIFO order"); |
300 | DAG.UpdateListeners = Next; |
301 | } |
302 | |
303 | |
304 | |
305 | virtual void NodeDeleted(SDNode *N, SDNode *E); |
306 | |
307 | |
308 | virtual void NodeUpdated(SDNode *N); |
309 | |
310 | |
311 | virtual void NodeInserted(SDNode *N); |
312 | }; |
313 | |
314 | struct DAGNodeDeletedListener : public DAGUpdateListener { |
315 | std::function<void(SDNode *, SDNode *)> Callback; |
316 | |
317 | DAGNodeDeletedListener(SelectionDAG &DAG, |
318 | std::function<void(SDNode *, SDNode *)> Callback) |
319 | : DAGUpdateListener(DAG), Callback(std::move(Callback)) {} |
320 | |
321 | void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); } |
322 | |
323 | private: |
324 | virtual void anchor(); |
325 | }; |
326 | |
327 | |
328 | |
329 | class FlagInserter { |
330 | SelectionDAG &DAG; |
331 | SDNodeFlags Flags; |
332 | FlagInserter *LastInserter; |
333 | |
334 | public: |
335 | FlagInserter(SelectionDAG &SDAG, SDNodeFlags Flags) |
336 | : DAG(SDAG), Flags(Flags), |
337 | LastInserter(SDAG.getFlagInserter()) { |
338 | SDAG.setFlagInserter(this); |
339 | } |
340 | FlagInserter(SelectionDAG &SDAG, SDNode *N) |
341 | : FlagInserter(SDAG, N->getFlags()) {} |
342 | |
343 | FlagInserter(const FlagInserter &) = delete; |
344 | FlagInserter &operator=(const FlagInserter &) = delete; |
345 | ~FlagInserter() { DAG.setFlagInserter(LastInserter); } |
346 | |
347 | SDNodeFlags getFlags() const { return Flags; } |
348 | }; |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | bool NewNodesMustHaveLegalTypes = false; |
356 | |
357 | private: |
358 | |
359 | friend struct DAGUpdateListener; |
360 | |
361 | |
362 | |
363 | DAGUpdateListener *UpdateListeners = nullptr; |
364 | |
365 | |
366 | |
367 | bool setSubgraphColorHelper(SDNode *N, const char *Color, |
368 | DenseSet<SDNode *> &visited, |
369 | int level, bool &printed); |
370 | |
371 | template <typename SDNodeT, typename... ArgTypes> |
372 | SDNodeT *newSDNode(ArgTypes &&... Args) { |
373 | return new (NodeAllocator.template Allocate<SDNodeT>()) |
374 | SDNodeT(std::forward<ArgTypes>(Args)...); |
375 | } |
376 | |
377 | |
378 | |
379 | |
380 | |
381 | |
382 | |
383 | template <typename SDNodeT, typename... ArgTypes> |
384 | static uint16_t getSyntheticNodeSubclassData(unsigned IROrder, |
385 | ArgTypes &&... Args) { |
386 | |
387 | |
388 | |
389 | return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...) |
390 | .getRawSubclassData(); |
391 | } |
392 | |
393 | template <typename SDNodeTy> |
394 | static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order, |
395 | SDVTList VTs, EVT MemoryVT, |
396 | MachineMemOperand *MMO) { |
397 | return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO) |
398 | .getRawSubclassData(); |
399 | } |
400 | |
401 | void createOperands(SDNode *Node, ArrayRef<SDValue> Vals); |
402 | |
403 | void removeOperands(SDNode *Node) { |
404 | if (!Node->OperandList) |
405 | return; |
406 | OperandRecycler.deallocate( |
407 | ArrayRecycler<SDUse>::Capacity::get(Node->NumOperands), |
408 | Node->OperandList); |
409 | Node->NumOperands = 0; |
410 | Node->OperandList = nullptr; |
411 | } |
412 | void CreateTopologicalOrder(std::vector<SDNode*>& Order); |
413 | |
414 | public: |
415 | |
416 | static constexpr unsigned MaxRecursionDepth = 6; |
417 | |
418 | explicit SelectionDAG(const TargetMachine &TM, CodeGenOpt::Level); |
419 | SelectionDAG(const SelectionDAG &) = delete; |
420 | SelectionDAG &operator=(const SelectionDAG &) = delete; |
421 | ~SelectionDAG(); |
422 | |
423 | |
424 | void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, |
425 | Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, |
426 | LegacyDivergenceAnalysis * Divergence, |
427 | ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin); |
428 | |
429 | void setFunctionLoweringInfo(FunctionLoweringInfo * FuncInfo) { |
430 | FLI = FuncInfo; |
431 | } |
432 | |
433 | |
434 | |
435 | void clear(); |
436 | |
437 | MachineFunction &getMachineFunction() const { return *MF; } |
438 | const Pass *getPass() const { return SDAGISelPass; } |
439 | |
440 | const DataLayout &getDataLayout() const { return MF->getDataLayout(); } |
441 | const TargetMachine &getTarget() const { return TM; } |
442 | const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); } |
443 | const TargetLowering &getTargetLoweringInfo() const { return *TLI; } |
444 | const TargetLibraryInfo &getLibInfo() const { return *LibInfo; } |
445 | const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; } |
446 | const LegacyDivergenceAnalysis *getDivergenceAnalysis() const { return DA; } |
447 | LLVMContext *getContext() const { return Context; } |
448 | OptimizationRemarkEmitter &getORE() const { return *ORE; } |
449 | ProfileSummaryInfo *getPSI() const { return PSI; } |
450 | BlockFrequencyInfo *getBFI() const { return BFI; } |
451 | |
452 | FlagInserter *getFlagInserter() { return Inserter; } |
453 | void setFlagInserter(FlagInserter *FI) { Inserter = FI; } |
454 | |
455 | |
456 | |
457 | |
458 | |
459 | |
460 | |
461 | |
462 | #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP) |
463 | LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title); |
464 | #endif |
465 | |
466 | |
467 | void viewGraph(const std::string &Title); |
468 | void viewGraph(); |
469 | |
470 | #ifndef NDEBUG |
471 | std::map<const SDNode *, std::string> NodeGraphAttrs; |
472 | #endif |
473 | |
474 | |
475 | |
476 | void clearGraphAttrs(); |
477 | |
478 | |
479 | void setGraphAttrs(const SDNode *N, const char *Attrs); |
480 | |
481 | |
482 | |
483 | std::string getGraphAttrs(const SDNode *N) const; |
484 | |
485 | |
486 | void setGraphColor(const SDNode *N, const char *Color); |
487 | |
488 | |
489 | void setSubgraphColor(SDNode *N, const char *Color); |
490 | |
491 | using allnodes_const_iterator = ilist<SDNode>::const_iterator; |
492 | |
493 | allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); } |
494 | allnodes_const_iterator allnodes_end() const { return AllNodes.end(); } |
495 | |
496 | using allnodes_iterator = ilist<SDNode>::iterator; |
497 | |
498 | allnodes_iterator allnodes_begin() { return AllNodes.begin(); } |
499 | allnodes_iterator allnodes_end() { return AllNodes.end(); } |
500 | |
501 | ilist<SDNode>::size_type allnodes_size() const { |
502 | return AllNodes.size(); |
503 | } |
504 | |
505 | iterator_range<allnodes_iterator> allnodes() { |
506 | return make_range(allnodes_begin(), allnodes_end()); |
507 | } |
508 | iterator_range<allnodes_const_iterator> allnodes() const { |
509 | return make_range(allnodes_begin(), allnodes_end()); |
510 | } |
511 | |
512 | |
513 | const SDValue &getRoot() const { return Root; } |
514 | |
515 | |
516 | SDValue getEntryNode() const { |
517 | return SDValue(const_cast<SDNode *>(&EntryNode), 0); |
518 | } |
519 | |
520 | |
521 | |
522 | const SDValue &setRoot(SDValue N) { |
523 | assert((!N.getNode() || N.getValueType() == MVT::Other) && |
524 | "DAG root value is not a chain!"); |
525 | if (N.getNode()) |
526 | checkForCycles(N.getNode(), this); |
527 | Root = N; |
528 | if (N.getNode()) |
529 | checkForCycles(this); |
530 | return Root; |
531 | } |
532 | |
533 | #ifndef NDEBUG |
534 | void VerifyDAGDiverence(); |
535 | #endif |
536 | |
537 | |
538 | |
539 | |
540 | |
541 | void Combine(CombineLevel Level, AAResults *AA, |
542 | CodeGenOpt::Level OptLevel); |
543 | |
544 | |
545 | |
546 | |
547 | |
548 | |
549 | |
550 | bool LegalizeTypes(); |
551 | |
552 | |
553 | |
554 | |
555 | |
556 | |
557 | |
558 | void Legalize(); |
559 | |
560 | |
561 | |
562 | |
563 | |
564 | |
565 | |
566 | |
567 | |
568 | |
569 | |
570 | |
571 | |
572 | |
573 | |
574 | |
575 | |
576 | |
577 | |
578 | |
579 | bool LegalizeOp(SDNode *N, SmallSetVector<SDNode *, 16> &UpdatedNodes); |
580 | |
581 | |
582 | |
583 | |
584 | |
585 | |
586 | |
587 | |
588 | |
589 | |
590 | |
591 | |
592 | bool LegalizeVectors(); |
593 | |
594 | |
595 | void RemoveDeadNodes(); |
596 | |
597 | |
598 | |
599 | void DeleteNode(SDNode *N); |
600 | |
601 | |
602 | SDVTList getVTList(EVT VT); |
603 | SDVTList getVTList(EVT VT1, EVT VT2); |
604 | SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3); |
605 | SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4); |
606 | SDVTList getVTList(ArrayRef<EVT> VTs); |
607 | |
608 | |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | |
615 | |
616 | |
617 | SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, |
618 | bool isTarget = false, bool isOpaque = false); |
619 | SDValue getConstant(const APInt &Val, const SDLoc &DL, EVT VT, |
620 | bool isTarget = false, bool isOpaque = false); |
621 | |
622 | SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget = false, |
623 | bool IsOpaque = false) { |
624 | return getConstant(APInt::getAllOnesValue(VT.getScalarSizeInBits()), DL, |
625 | VT, IsTarget, IsOpaque); |
626 | } |
627 | |
628 | SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT, |
629 | bool isTarget = false, bool isOpaque = false); |
630 | SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, |
631 | bool isTarget = false); |
632 | SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL, |
633 | bool LegalTypes = true); |
634 | SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, |
635 | bool isTarget = false); |
636 | |
637 | SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, |
638 | bool isOpaque = false) { |
639 | return getConstant(Val, DL, VT, true, isOpaque); |
640 | } |
641 | SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT, |
642 | bool isOpaque = false) { |
643 | return getConstant(Val, DL, VT, true, isOpaque); |
644 | } |
645 | SDValue getTargetConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT, |
646 | bool isOpaque = false) { |
647 | return getConstant(Val, DL, VT, true, isOpaque); |
648 | } |
649 | |
650 | |
651 | |
652 | SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT); |
653 | |
654 | |
655 | |
656 | |
657 | |
658 | |
659 | |
660 | |
661 | |
662 | |
663 | SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, |
664 | bool isTarget = false); |
665 | SDValue getConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT, |
666 | bool isTarget = false); |
667 | SDValue getConstantFP(const ConstantFP &V, const SDLoc &DL, EVT VT, |
668 | bool isTarget = false); |
669 | SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT) { |
670 | return getConstantFP(Val, DL, VT, true); |
671 | } |
672 | SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT) { |
673 | return getConstantFP(Val, DL, VT, true); |
674 | } |
675 | SDValue getTargetConstantFP(const ConstantFP &Val, const SDLoc &DL, EVT VT) { |
676 | return getConstantFP(Val, DL, VT, true); |
677 | } |
678 | |
679 | |
680 | SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, |
681 | int64_t offset = 0, bool isTargetGA = false, |
682 | unsigned TargetFlags = 0); |
683 | SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, |
684 | int64_t offset = 0, unsigned TargetFlags = 0) { |
685 | return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags); |
686 | } |
687 | SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false); |
688 | SDValue getTargetFrameIndex(int FI, EVT VT) { |
689 | return getFrameIndex(FI, VT, true); |
690 | } |
691 | SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false, |
692 | unsigned TargetFlags = 0); |
693 | SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags = 0) { |
694 | return getJumpTable(JTI, VT, true, TargetFlags); |
695 | } |
696 | SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align = None, |
697 | int Offs = 0, bool isT = false, |
698 | unsigned TargetFlags = 0); |
699 | SDValue getTargetConstantPool(const Constant *C, EVT VT, |
700 | MaybeAlign Align = None, int Offset = 0, |
701 | unsigned TargetFlags = 0) { |
702 | return getConstantPool(C, VT, Align, Offset, true, TargetFlags); |
703 | } |
704 | SDValue getConstantPool(MachineConstantPoolValue *C, EVT VT, |
705 | MaybeAlign Align = None, int Offs = 0, |
706 | bool isT = false, unsigned TargetFlags = 0); |
707 | SDValue getTargetConstantPool(MachineConstantPoolValue *C, EVT VT, |
708 | MaybeAlign Align = None, int Offset = 0, |
709 | unsigned TargetFlags = 0) { |
710 | return getConstantPool(C, VT, Align, Offset, true, TargetFlags); |
711 | } |
712 | SDValue getTargetIndex(int Index, EVT VT, int64_t Offset = 0, |
713 | unsigned TargetFlags = 0); |
714 | |
715 | |
716 | SDValue getBasicBlock(MachineBasicBlock *MBB); |
717 | SDValue getExternalSymbol(const char *Sym, EVT VT); |
718 | SDValue getTargetExternalSymbol(const char *Sym, EVT VT, |
719 | unsigned TargetFlags = 0); |
720 | SDValue getMCSymbol(MCSymbol *Sym, EVT VT); |
721 | |
722 | SDValue getValueType(EVT); |
723 | SDValue getRegister(unsigned Reg, EVT VT); |
724 | SDValue getRegisterMask(const uint32_t *RegMask); |
725 | SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label); |
726 | SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root, |
727 | MCSymbol *Label); |
728 | SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset = 0, |
729 | bool isTarget = false, unsigned TargetFlags = 0); |
730 | SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, |
731 | int64_t Offset = 0, unsigned TargetFlags = 0) { |
732 | return getBlockAddress(BA, VT, Offset, true, TargetFlags); |
733 | } |
734 | |
735 | SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, |
736 | SDValue N) { |
737 | return getNode(ISD::CopyToReg, dl, MVT::Other, Chain, |
738 | getRegister(Reg, N.getValueType()), N); |
739 | } |
740 | |
741 | |
742 | |
743 | |
744 | SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N, |
745 | SDValue Glue) { |
746 | SDVTList VTs = getVTList(MVT::Other, MVT::Glue); |
747 | SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue }; |
| 10 | | Calling 'SDValue::getValueType' | |
|
748 | return getNode(ISD::CopyToReg, dl, VTs, |
749 | makeArrayRef(Ops, Glue.getNode() ? 4 : 3)); |
750 | } |
751 | |
752 | |
753 | SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, SDValue Reg, SDValue N, |
754 | SDValue Glue) { |
755 | SDVTList VTs = getVTList(MVT::Other, MVT::Glue); |
756 | SDValue Ops[] = { Chain, Reg, N, Glue }; |
757 | return getNode(ISD::CopyToReg, dl, VTs, |
758 | makeArrayRef(Ops, Glue.getNode() ? 4 : 3)); |
759 | } |
760 | |
761 | SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT) { |
762 | SDVTList VTs = getVTList(VT, MVT::Other); |
763 | SDValue Ops[] = { Chain, getRegister(Reg, VT) }; |
764 | return getNode(ISD::CopyFromReg, dl, VTs, Ops); |
765 | } |
766 | |
767 | |
768 | |
769 | |
770 | SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT, |
771 | SDValue Glue) { |
772 | SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue); |
773 | SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue }; |
774 | return getNode(ISD::CopyFromReg, dl, VTs, |
775 | makeArrayRef(Ops, Glue.getNode() ? 3 : 2)); |
776 | } |
777 | |
778 | SDValue getCondCode(ISD::CondCode Cond); |
779 | |
780 | |
781 | |
782 | |
783 | SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, |
784 | ArrayRef<int> Mask); |
785 | |
786 | |
787 | |
788 | |
789 | |
790 | SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef<SDValue> Ops) { |
791 | |
792 | return getNode(ISD::BUILD_VECTOR, DL, VT, Ops); |
793 | } |
794 | |
795 | |
796 | |
797 | |
798 | |
799 | SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef<SDUse> Ops) { |
800 | |
801 | return getNode(ISD::BUILD_VECTOR, DL, VT, Ops); |
802 | } |
803 | |
804 | |
805 | |
806 | |
807 | SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op) { |
808 | |
809 | if (Op.getOpcode() == ISD::UNDEF) { |
810 | assert((VT.getVectorElementType() == Op.getValueType() || |
811 | (VT.isInteger() && |
812 | VT.getVectorElementType().bitsLE(Op.getValueType()))) && |
813 | "A splatted value must have a width equal or (for integers) " |
814 | "greater than the vector element type!"); |
815 | return getNode(ISD::UNDEF, SDLoc(), VT); |
816 | } |
817 | |
818 | SmallVector<SDValue, 16> Ops(VT.getVectorNumElements(), Op); |
819 | return getNode(ISD::BUILD_VECTOR, DL, VT, Ops); |
820 | } |
821 | |
822 | |
823 | |
824 | SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op) { |
825 | if (Op.getOpcode() == ISD::UNDEF) { |
826 | assert((VT.getVectorElementType() == Op.getValueType() || |
827 | (VT.isInteger() && |
828 | VT.getVectorElementType().bitsLE(Op.getValueType()))) && |
829 | "A splatted value must have a width equal or (for integers) " |
830 | "greater than the vector element type!"); |
831 | return getNode(ISD::UNDEF, SDLoc(), VT); |
832 | } |
833 | return getNode(ISD::SPLAT_VECTOR, DL, VT, Op); |
834 | } |
835 | |
836 | |
837 | |
838 | SDValue getStepVector(const SDLoc &DL, EVT ResVT, APInt StepVal); |
839 | |
840 | |
841 | |
842 | SDValue getStepVector(const SDLoc &DL, EVT ResVT); |
843 | |
844 | |
845 | |
846 | |
847 | |
848 | SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV); |
849 | |
850 | |
851 | |
852 | SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT); |
853 | |
854 | |
855 | |
856 | std::pair<SDValue, SDValue> |
857 | getStrictFPExtendOrRound(SDValue Op, SDValue Chain, const SDLoc &DL, EVT VT); |
858 | |
859 | |
860 | |
861 | SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT); |
862 | |
863 | |
864 | |
865 | SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT); |
866 | |
867 | |
868 | |
869 | SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT); |
870 | |
871 | |
872 | |
873 | SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT); |
874 | |
875 | |
876 | |
877 | |
878 | SDValue getPtrExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT); |
879 | |
880 | |
881 | |
882 | |
883 | SDValue getPtrExtendInReg(SDValue Op, const SDLoc &DL, EVT VT); |
884 | |
885 | |
886 | |
887 | |
888 | SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT); |
889 | |
890 | |
891 | SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT); |
892 | |
893 | |
894 | SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT); |
895 | |
896 | |
897 | |
898 | SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, |
899 | const SDNodeFlags Flags = SDNodeFlags()); |
900 | SDValue getMemBasePlusOffset(SDValue Base, SDValue Offset, const SDLoc &DL, |
901 | const SDNodeFlags Flags = SDNodeFlags()); |
902 | |
903 | |
904 | |
905 | |
906 | SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset) { |
907 | SDNodeFlags Flags; |
908 | Flags.setNoUnsignedWrap(true); |
909 | return getMemBasePlusOffset(Ptr, Offset, SL, Flags); |
910 | } |
911 | |
912 | SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, SDValue Offset) { |
913 | |
914 | |
915 | SDNodeFlags Flags; |
916 | Flags.setNoUnsignedWrap(true); |
917 | return getMemBasePlusOffset(Ptr, Offset, SL, Flags); |
918 | } |
919 | |
920 | |
921 | |
922 | |
923 | SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, |
924 | const SDLoc &DL) { |
925 | SDVTList VTs = getVTList(MVT::Other, MVT::Glue); |
926 | SDValue Ops[] = { Chain, |
927 | getIntPtrConstant(InSize, DL, true), |
928 | getIntPtrConstant(OutSize, DL, true) }; |
929 | return getNode(ISD::CALLSEQ_START, DL, VTs, Ops); |
930 | } |
931 | |
932 | |
933 | |
934 | |
935 | SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, |
936 | SDValue InGlue, const SDLoc &DL) { |
937 | SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue); |
938 | SmallVector<SDValue, 4> Ops; |
939 | Ops.push_back(Chain); |
940 | Ops.push_back(Op1); |
941 | Ops.push_back(Op2); |
942 | if (InGlue.getNode()) |
943 | Ops.push_back(InGlue); |
944 | return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops); |
945 | } |
946 | |
947 | |
948 | bool isUndef(unsigned Opcode, ArrayRef<SDValue> Ops); |
949 | |
950 | |
951 | SDValue getUNDEF(EVT VT) { |
952 | return getNode(ISD::UNDEF, SDLoc(), VT); |
953 | } |
954 | |
955 | |
956 | SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm) { |
957 | assert(MulImm.getMinSignedBits() <= VT.getSizeInBits() && |
958 | "Immediate does not fit VT"); |
959 | return getNode(ISD::VSCALE, DL, VT, |
960 | getConstant(MulImm.sextOrTrunc(VT.getSizeInBits()), DL, VT)); |
961 | } |
962 | |
963 | |
964 | SDValue getGLOBAL_OFFSET_TABLE(EVT VT) { |
965 | return getNode(ISD::GLOBAL_OFFSET_TABLE, SDLoc(), VT); |
966 | } |
967 | |
968 | |
969 | |
970 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, |
971 | ArrayRef<SDUse> Ops); |
972 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, |
973 | ArrayRef<SDValue> Ops, const SDNodeFlags Flags); |
974 | SDValue getNode(unsigned Opcode, const SDLoc &DL, ArrayRef<EVT> ResultTys, |
975 | ArrayRef<SDValue> Ops); |
976 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, |
977 | ArrayRef<SDValue> Ops, const SDNodeFlags Flags); |
978 | |
979 | |
980 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, |
981 | ArrayRef<SDValue> Ops); |
982 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, |
983 | ArrayRef<SDValue> Ops); |
984 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand); |
985 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
986 | SDValue N2); |
987 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
988 | SDValue N2, SDValue N3); |
989 | |
990 | |
991 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT); |
992 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand, |
993 | const SDNodeFlags Flags); |
994 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
995 | SDValue N2, const SDNodeFlags Flags); |
996 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
997 | SDValue N2, SDValue N3, const SDNodeFlags Flags); |
998 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
999 | SDValue N2, SDValue N3, SDValue N4); |
1000 | SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1, |
1001 | SDValue N2, SDValue N3, SDValue N4, SDValue N5); |
1002 | |
1003 | |
1004 | |
1005 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList); |
1006 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N); |
1007 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1, |
1008 | SDValue N2); |
1009 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1, |
1010 | SDValue N2, SDValue N3); |
1011 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1, |
1012 | SDValue N2, SDValue N3, SDValue N4); |
1013 | SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1, |
1014 | SDValue N2, SDValue N3, SDValue N4, SDValue N5); |
1015 | |
1016 | |
1017 | |
1018 | |
1019 | SDValue getStackArgumentTokenFactor(SDValue Chain); |
1020 | |
1021 | SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, |
1022 | SDValue Size, Align Alignment, bool isVol, |
1023 | bool AlwaysInline, bool isTailCall, |
1024 | MachinePointerInfo DstPtrInfo, |
1025 | MachinePointerInfo SrcPtrInfo, |
1026 | const AAMDNodes &AAInfo = AAMDNodes()); |
1027 | |
1028 | SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, |
1029 | SDValue Size, Align Alignment, bool isVol, bool isTailCall, |
1030 | MachinePointerInfo DstPtrInfo, |
1031 | MachinePointerInfo SrcPtrInfo, |
1032 | const AAMDNodes &AAInfo = AAMDNodes()); |
1033 | |
1034 | SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, |
1035 | SDValue Size, Align Alignment, bool isVol, bool isTailCall, |
1036 | MachinePointerInfo DstPtrInfo, |
1037 | const AAMDNodes &AAInfo = AAMDNodes()); |
1038 | |
1039 | SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, |
1040 | unsigned DstAlign, SDValue Src, unsigned SrcAlign, |
1041 | SDValue Size, Type *SizeTy, unsigned ElemSz, |
1042 | bool isTailCall, MachinePointerInfo DstPtrInfo, |
1043 | MachinePointerInfo SrcPtrInfo); |
1044 | |
1045 | SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, |
1046 | unsigned DstAlign, SDValue Src, unsigned SrcAlign, |
1047 | SDValue Size, Type *SizeTy, unsigned ElemSz, |
1048 | bool isTailCall, MachinePointerInfo DstPtrInfo, |
1049 | MachinePointerInfo SrcPtrInfo); |
1050 | |
1051 | SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, |
1052 | unsigned DstAlign, SDValue Value, SDValue Size, |
1053 | Type *SizeTy, unsigned ElemSz, bool isTailCall, |
1054 | MachinePointerInfo DstPtrInfo); |
1055 | |
1056 | |
1057 | |
1058 | SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, |
1059 | ISD::CondCode Cond, SDValue Chain = SDValue(), |
1060 | bool IsSignaling = false) { |
1061 | assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() && |
1062 | "Cannot compare scalars to vectors"); |
1063 | assert(LHS.getValueType().isVector() == VT.isVector() && |
1064 | "Cannot compare scalars to vectors"); |
1065 | assert(Cond != ISD::SETCC_INVALID && |
1066 | "Cannot create a setCC of an invalid node."); |
1067 | if (Chain) |
1068 | return getNode(IsSignaling ? ISD::STRICT_FSETCCS : ISD::STRICT_FSETCC, DL, |
1069 | {VT, MVT::Other}, {Chain, LHS, RHS, getCondCode(Cond)}); |
1070 | return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond)); |
1071 | } |
1072 | |
1073 | |
1074 | |
1075 | SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, |
1076 | SDValue RHS) { |
1077 | assert(LHS.getValueType() == RHS.getValueType() && |
1078 | "Cannot use select on differing types"); |
1079 | assert(VT.isVector() == LHS.getValueType().isVector() && |
1080 | "Cannot mix vectors and scalars"); |
1081 | auto Opcode = Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT; |
1082 | return getNode(Opcode, DL, VT, Cond, LHS, RHS); |
1083 | } |
1084 | |
1085 | |
1086 | |
1087 | SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, |
1088 | SDValue False, ISD::CondCode Cond) { |
1089 | return getNode(ISD::SELECT_CC, DL, True.getValueType(), LHS, RHS, True, |
1090 | False, getCondCode(Cond)); |
1091 | } |
1092 | |
1093 | |
1094 | SDValue simplifySelect(SDValue Cond, SDValue TVal, SDValue FVal); |
1095 | |
1096 | |
1097 | SDValue simplifyShift(SDValue X, SDValue Y); |
1098 | |
1099 | |
1100 | |
1101 | SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y, |
1102 | SDNodeFlags Flags); |
1103 | |
1104 | |
1105 | |
1106 | SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, |
1107 | SDValue SV, unsigned Align); |
1108 | |
1109 | |
1110 | |
1111 | |
1112 | |
1113 | SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, |
1114 | SDVTList VTs, SDValue Chain, SDValue Ptr, |
1115 | SDValue Cmp, SDValue Swp, MachineMemOperand *MMO); |
1116 | |
1117 | |
1118 | |
1119 | SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, |
1120 | SDValue Ptr, SDValue Val, MachineMemOperand *MMO); |
1121 | |
1122 | |
1123 | |
1124 | SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, EVT VT, |
1125 | SDValue Chain, SDValue Ptr, MachineMemOperand *MMO); |
1126 | |
1127 | |
1128 | |
1129 | SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, |
1130 | SDVTList VTList, ArrayRef<SDValue> Ops, |
1131 | MachineMemOperand *MMO); |
1132 | |
1133 | |
1134 | |
1135 | |
1136 | |
1137 | SDValue getMemIntrinsicNode( |
1138 | unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops, |
1139 | EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment, |
1140 | MachineMemOperand::Flags Flags = MachineMemOperand::MOLoad | |
1141 | MachineMemOperand::MOStore, |
1142 | uint64_t Size = 0, const AAMDNodes &AAInfo = AAMDNodes()); |
1143 | |
1144 | inline SDValue getMemIntrinsicNode( |
1145 | unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops, |
1146 | EVT MemVT, MachinePointerInfo PtrInfo, MaybeAlign Alignment = None, |
1147 | MachineMemOperand::Flags Flags = MachineMemOperand::MOLoad | |
1148 | MachineMemOperand::MOStore, |
1149 | uint64_t Size = 0, const AAMDNodes &AAInfo = AAMDNodes()) { |
1150 | |
1151 | return getMemIntrinsicNode(Opcode, dl, VTList, Ops, MemVT, PtrInfo, |
1152 | Alignment.getValueOr(getEVTAlign(MemVT)), Flags, |
1153 | Size, AAInfo); |
1154 | } |
1155 | |
1156 | SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, |
1157 | ArrayRef<SDValue> Ops, EVT MemVT, |
1158 | MachineMemOperand *MMO); |
1159 | |
1160 | |
1161 | |
1162 | |
1163 | SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain, |
1164 | int FrameIndex, int64_t Size, int64_t Offset = -1); |
1165 | |
1166 | |
1167 | |
1168 | |
1169 | SDValue getPseudoProbeNode(const SDLoc &Dl, SDValue Chain, uint64_t Guid, |
1170 | uint64_t Index, uint32_t Attr); |
1171 | |
1172 | |
1173 | SDValue getMergeValues(ArrayRef<SDValue> Ops, const SDLoc &dl); |
1174 | |
1175 | |
1176 | |
1177 | |
1178 | |
1179 | |
1180 | SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, |
1181 | MachinePointerInfo PtrInfo, |
1182 | MaybeAlign Alignment = MaybeAlign(), |
1183 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1184 | const AAMDNodes &AAInfo = AAMDNodes(), |
1185 | const MDNode *Ranges = nullptr); |
1186 | |
1187 | inline SDValue |
1188 | getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, |
1189 | MachinePointerInfo PtrInfo, unsigned Alignment, |
1190 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1191 | const AAMDNodes &AAInfo = AAMDNodes(), |
1192 | const MDNode *Ranges = nullptr) { |
1193 | return getLoad(VT, dl, Chain, Ptr, PtrInfo, MaybeAlign(Alignment), MMOFlags, |
1194 | AAInfo, Ranges); |
1195 | } |
1196 | SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, |
1197 | MachineMemOperand *MMO); |
1198 | SDValue |
1199 | getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, |
1200 | SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, |
1201 | MaybeAlign Alignment = MaybeAlign(), |
1202 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1203 | const AAMDNodes &AAInfo = AAMDNodes()); |
1204 | |
1205 | inline SDValue |
1206 | getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, |
1207 | SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, |
1208 | unsigned Alignment, |
1209 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1210 | const AAMDNodes &AAInfo = AAMDNodes()) { |
1211 | return getExtLoad(ExtType, dl, VT, Chain, Ptr, PtrInfo, MemVT, |
1212 | MaybeAlign(Alignment), MMOFlags, AAInfo); |
1213 | } |
1214 | SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, |
1215 | SDValue Chain, SDValue Ptr, EVT MemVT, |
1216 | MachineMemOperand *MMO); |
1217 | SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, |
1218 | SDValue Offset, ISD::MemIndexedMode AM); |
1219 | SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, |
1220 | const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, |
1221 | MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment, |
1222 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1223 | const AAMDNodes &AAInfo = AAMDNodes(), |
1224 | const MDNode *Ranges = nullptr); |
1225 | inline SDValue getLoad( |
1226 | ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, |
1227 | SDValue Chain, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, |
1228 | EVT MemVT, MaybeAlign Alignment = MaybeAlign(), |
1229 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1230 | const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) { |
1231 | |
1232 | return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT, |
1233 | Alignment.getValueOr(getEVTAlign(MemVT)), MMOFlags, AAInfo, |
1234 | Ranges); |
1235 | } |
1236 | |
1237 | inline SDValue |
1238 | getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, |
1239 | const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, |
1240 | MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment, |
1241 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1242 | const AAMDNodes &AAInfo = AAMDNodes(), |
1243 | const MDNode *Ranges = nullptr) { |
1244 | return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT, |
1245 | MaybeAlign(Alignment), MMOFlags, AAInfo, Ranges); |
1246 | } |
1247 | SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, |
1248 | const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, |
1249 | EVT MemVT, MachineMemOperand *MMO); |
1250 | |
1251 | |
1252 | |
1253 | |
1254 | |
1255 | |
1256 | SDValue |
1257 | getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1258 | MachinePointerInfo PtrInfo, Align Alignment, |
1259 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1260 | const AAMDNodes &AAInfo = AAMDNodes()); |
1261 | inline SDValue |
1262 | getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1263 | MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(), |
1264 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1265 | const AAMDNodes &AAInfo = AAMDNodes()) { |
1266 | return getStore(Chain, dl, Val, Ptr, PtrInfo, |
1267 | Alignment.getValueOr(getEVTAlign(Val.getValueType())), |
1268 | MMOFlags, AAInfo); |
1269 | } |
1270 | |
1271 | inline SDValue |
1272 | getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1273 | MachinePointerInfo PtrInfo, unsigned Alignment, |
1274 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1275 | const AAMDNodes &AAInfo = AAMDNodes()) { |
1276 | return getStore(Chain, dl, Val, Ptr, PtrInfo, MaybeAlign(Alignment), |
1277 | MMOFlags, AAInfo); |
1278 | } |
1279 | SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1280 | MachineMemOperand *MMO); |
1281 | SDValue |
1282 | getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1283 | MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, |
1284 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1285 | const AAMDNodes &AAInfo = AAMDNodes()); |
1286 | inline SDValue |
1287 | getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1288 | MachinePointerInfo PtrInfo, EVT SVT, |
1289 | MaybeAlign Alignment = MaybeAlign(), |
1290 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1291 | const AAMDNodes &AAInfo = AAMDNodes()) { |
1292 | return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT, |
1293 | Alignment.getValueOr(getEVTAlign(SVT)), MMOFlags, |
1294 | AAInfo); |
1295 | } |
1296 | |
1297 | inline SDValue |
1298 | getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, |
1299 | MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment, |
1300 | MachineMemOperand::Flags MMOFlags = MachineMemOperand::MONone, |
1301 | const AAMDNodes &AAInfo = AAMDNodes()) { |
1302 | return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT, |
1303 | MaybeAlign(Alignment), MMOFlags, AAInfo); |
1304 | } |
1305 | SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, |
1306 | SDValue Ptr, EVT SVT, MachineMemOperand *MMO); |
1307 | SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, |
1308 | SDValue Offset, ISD::MemIndexedMode AM); |
1309 | |
1310 | SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base, |
1311 | SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT, |
1312 | MachineMemOperand *MMO, ISD::MemIndexedMode AM, |
1313 | ISD::LoadExtType, bool IsExpanding = false); |
1314 | SDValue getIndexedMaskedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, |
1315 | SDValue Offset, ISD::MemIndexedMode AM); |
1316 | SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, |
1317 | SDValue Base, SDValue Offset, SDValue Mask, EVT MemVT, |
1318 | MachineMemOperand *MMO, ISD::MemIndexedMode AM, |
1319 | bool IsTruncating = false, bool IsCompressing = false); |
1320 | SDValue getIndexedMaskedStore(SDValue OrigStore, const SDLoc &dl, |
1321 | SDValue Base, SDValue Offset, |
1322 | ISD::MemIndexedMode AM); |
1323 | SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl, |
1324 | ArrayRef<SDValue> Ops, MachineMemOperand *MMO, |
1325 | ISD::MemIndexType IndexType, ISD::LoadExtType ExtTy); |
1326 | SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl, |
1327 | ArrayRef<SDValue> Ops, MachineMemOperand *MMO, |
1328 | ISD::MemIndexType IndexType, |
1329 | bool IsTruncating = false); |
1330 | |
1331 | |
1332 | SDValue getSrcValue(const Value *v); |
1333 | |
1334 | |
1335 | SDValue getMDNode(const MDNode *MD); |
1336 | |
1337 | |
1338 | |
1339 | SDValue getBitcast(EVT VT, SDValue V); |
1340 | |
1341 | |
1342 | SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, |
1343 | unsigned DestAS); |
1344 | |
1345 | |
1346 | SDValue getFreeze(SDValue V); |
1347 | |
1348 | |
1349 | SDValue getAssertAlign(const SDLoc &DL, SDValue V, Align A); |
1350 | |
1351 | |
1352 | |
1353 | SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op); |
1354 | |
1355 | |
1356 | SDValue expandVAArg(SDNode *Node); |
1357 | |
1358 | |
1359 | SDValue expandVACopy(SDNode *Node); |
1360 | |
1361 | |
1362 | |
1363 | |
1364 | |
1365 | SDValue getSymbolFunctionGlobalAddress(SDValue Op, |
1366 | Function **TargetFunction = nullptr); |
1367 | |
1368 | |
1369 | |
1370 | |
1371 | |
1372 | |
1373 | |
1374 | SDNode *UpdateNodeOperands(SDNode *N, SDValue Op); |
1375 | SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2); |
1376 | SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, |
1377 | SDValue Op3); |
1378 | SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, |
1379 | SDValue Op3, SDValue Op4); |
1380 | SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2, |
1381 | SDValue Op3, SDValue Op4, SDValue Op5); |
1382 | SDNode *UpdateNodeOperands(SDNode *N, ArrayRef<SDValue> Ops); |
1383 | |
1384 | |
1385 | |
1386 | |
1387 | SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl<SDValue> &Vals); |
1388 | |
1389 | |
1390 | |
1391 | void setNodeMemRefs(MachineSDNode *N, |
1392 | ArrayRef<MachineMemOperand *> NewMemRefs); |
1393 | |
1394 | |
1395 | bool calculateDivergence(SDNode *N); |
1396 | |
1397 | |
1398 | void updateDivergence(SDNode * N); |
1399 | |
1400 | |
1401 | |
1402 | |
1403 | |
1404 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT); |
1405 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, SDValue Op1); |
1406 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, |
1407 | SDValue Op1, SDValue Op2); |
1408 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, |
1409 | SDValue Op1, SDValue Op2, SDValue Op3); |
1410 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, |
1411 | ArrayRef<SDValue> Ops); |
1412 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, EVT VT2); |
1413 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, |
1414 | EVT VT2, ArrayRef<SDValue> Ops); |
1415 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, |
1416 | EVT VT2, EVT VT3, ArrayRef<SDValue> Ops); |
1417 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, |
1418 | EVT VT2, SDValue Op1, SDValue Op2); |
1419 | SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, SDVTList VTs, |
1420 | ArrayRef<SDValue> Ops); |
1421 | |
1422 | |
1423 | |
1424 | SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, |
1425 | ArrayRef<SDValue> Ops); |
1426 | |
1427 | |
1428 | |
1429 | |
1430 | SDNode *mutateStrictFPToFP(SDNode *Node); |
1431 | |
1432 | |
1433 | |
1434 | |
1435 | |
1436 | |
1437 | |
1438 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT); |
1439 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT, |
1440 | SDValue Op1); |
1441 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT, |
1442 | SDValue Op1, SDValue Op2); |
1443 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT, |
1444 | SDValue Op1, SDValue Op2, SDValue Op3); |
1445 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT, |
1446 | ArrayRef<SDValue> Ops); |
1447 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1448 | EVT VT2, SDValue Op1, SDValue Op2); |
1449 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1450 | EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3); |
1451 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1452 | EVT VT2, ArrayRef<SDValue> Ops); |
1453 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1454 | EVT VT2, EVT VT3, SDValue Op1, SDValue Op2); |
1455 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1456 | EVT VT2, EVT VT3, SDValue Op1, SDValue Op2, |
1457 | SDValue Op3); |
1458 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1, |
1459 | EVT VT2, EVT VT3, ArrayRef<SDValue> Ops); |
1460 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, |
1461 | ArrayRef<EVT> ResultTys, ArrayRef<SDValue> Ops); |
1462 | MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, SDVTList VTs, |
1463 | ArrayRef<SDValue> Ops); |
1464 | |
1465 | |
1466 | SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, |
1467 | SDValue Operand); |
1468 | |
1469 | |
1470 | SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, |
1471 | SDValue Operand, SDValue Subreg); |
1472 | |
1473 | |
1474 | SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList, |
1475 | ArrayRef<SDValue> Ops, const SDNodeFlags Flags); |
1476 | SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList, |
1477 | ArrayRef<SDValue> Ops); |
1478 | |
1479 | |
1480 | bool doesNodeExist(unsigned Opcode, SDVTList VTList, ArrayRef<SDValue> Ops); |
1481 | |
1482 | |
1483 | SDDbgValue *getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, |
1484 | unsigned R, bool IsIndirect, const DebugLoc &DL, |
1485 | unsigned O); |
1486 | |
1487 | |
1488 | SDDbgValue *getConstantDbgValue(DIVariable *Var, DIExpression *Expr, |
1489 | const Value *C, const DebugLoc &DL, |
1490 | unsigned O); |
1491 | |
1492 | |
1493 | SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, |
1494 | unsigned FI, bool IsIndirect, |
1495 | const DebugLoc &DL, unsigned O); |
1496 | |
1497 | |
1498 | SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, |
1499 | unsigned FI, |
1500 | ArrayRef<SDNode *> Dependencies, |
1501 | bool IsIndirect, const DebugLoc &DL, |
1502 | unsigned O); |
1503 | |
1504 | |
1505 | SDDbgValue *getVRegDbgValue(DIVariable *Var, DIExpression *Expr, |
1506 | unsigned VReg, bool IsIndirect, |
1507 | const DebugLoc &DL, unsigned O); |
1508 | |
1509 | |
1510 | SDDbgValue *getDbgValueList(DIVariable *Var, DIExpression *Expr, |
1511 | ArrayRef<SDDbgOperand> Locs, |
1512 | ArrayRef<SDNode *> Dependencies, bool IsIndirect, |
1513 | const DebugLoc &DL, unsigned O, bool IsVariadic); |
1514 | |
1515 | |
1516 | SDDbgLabel *getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O); |
1517 | |
1518 | |
1519 | |
1520 | |
1521 | void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0, |
1522 | unsigned SizeInBits = 0, bool InvalidateDbg = true); |
1523 | |
1524 | |
1525 | |
1526 | |
1527 | void RemoveDeadNode(SDNode *N); |
1528 | |
1529 | |
1530 | |
1531 | void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes); |
1532 | |
1533 | |
1534 | |
1535 | |
1536 | |
1537 | |
1538 | |
1539 | |
1540 | |
1541 | |
1542 | |
1543 | |
1544 | |
1545 | |
1546 | |
1547 | |
1548 | void ReplaceAllUsesWith(SDValue From, SDValue To); |
1549 | void ReplaceAllUsesWith(SDNode *From, SDNode *To); |
1550 | void ReplaceAllUsesWith(SDNode *From, const SDValue *To); |
1551 | |
1552 | |
1553 | |
1554 | void ReplaceAllUsesOfValueWith(SDValue From, SDValue To); |
1555 | |
1556 | |
1557 | |
1558 | |
1559 | void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, |
1560 | unsigned Num); |
1561 | |
1562 | |
1563 | |
1564 | |
1565 | |
1566 | |
1567 | SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain); |
1568 | |
1569 | |
1570 | |
1571 | |
1572 | |
1573 | |
1574 | SDValue makeEquivalentMemoryOrdering(LoadSDNode *OldLoad, SDValue NewMemOp); |
1575 | |
1576 | |
1577 | |
1578 | |
1579 | unsigned AssignTopologicalOrder(); |
1580 | |
1581 | |
1582 | |
1583 | |
1584 | void RepositionNode(allnodes_iterator Position, SDNode *N) { |
1585 | AllNodes.insert(Position, AllNodes.remove(N)); |
1586 | } |
1587 | |
1588 | |
1589 | |
1590 | static const fltSemantics &EVTToAPFloatSemantics(EVT VT) { |
1591 | switch (VT.getScalarType().getSimpleVT().SimpleTy) { |
1592 | default: llvm_unreachable("Unknown FP format"); |
1593 | case MVT::f16: return APFloat::IEEEhalf(); |
1594 | case MVT::bf16: return APFloat::BFloat(); |
1595 | case MVT::f32: return APFloat::IEEEsingle(); |
1596 | case MVT::f64: return APFloat::IEEEdouble(); |
1597 | case MVT::f80: return APFloat::x87DoubleExtended(); |
1598 | case MVT::f128: return APFloat::IEEEquad(); |
1599 | case MVT::ppcf128: return APFloat::PPCDoubleDouble(); |
1600 | } |
1601 | } |
1602 | |
1603 | |
1604 | |
1605 | void AddDbgValue(SDDbgValue *DB, bool isParameter); |
1606 | |
1607 | |
1608 | void AddDbgLabel(SDDbgLabel *DB); |
1609 | |
1610 | |
1611 | ArrayRef<SDDbgValue*> GetDbgValues(const SDNode* SD) const { |
1612 | return DbgInfo->getSDDbgValues(SD); |
1613 | } |
1614 | |
1615 | public: |
1616 | |
1617 | |
1618 | bool hasDebugValues() const { return !DbgInfo->empty(); } |
1619 | |
1620 | SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); } |
1621 | SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); } |
1622 | |
1623 | SDDbgInfo::DbgIterator ByvalParmDbgBegin() const { |
1624 | return DbgInfo->ByvalParmDbgBegin(); |
1625 | } |
1626 | SDDbgInfo::DbgIterator ByvalParmDbgEnd() const { |
1627 | return DbgInfo->ByvalParmDbgEnd(); |
1628 | } |
1629 | |
1630 | SDDbgInfo::DbgLabelIterator DbgLabelBegin() const { |
1631 | return DbgInfo->DbgLabelBegin(); |
1632 | } |
1633 | SDDbgInfo::DbgLabelIterator DbgLabelEnd() const { |
1634 | return DbgInfo->DbgLabelEnd(); |
1635 | } |
1636 | |
1637 | |
1638 | |
1639 | void salvageDebugInfo(SDNode &N); |
1640 | |
1641 | void dump() const; |
1642 | |
1643 | |
1644 | |
1645 | |
1646 | |
1647 | Align getReducedAlign(EVT VT, bool UseABI); |
1648 | |
1649 | |
1650 | SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment); |
1651 | |
1652 | |
1653 | |
1654 | SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1); |
1655 | |
1656 | |
1657 | |
1658 | SDValue CreateStackTemporary(EVT VT1, EVT VT2); |
1659 | |
1660 | SDValue FoldSymbolOffset(unsigned Opcode, EVT VT, |
1661 | const GlobalAddressSDNode *GA, |
1662 | const SDNode *N2); |
1663 | |
1664 | SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, |
1665 | ArrayRef<SDValue> Ops); |
1666 | |
1667 | SDValue FoldConstantVectorArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, |
1668 | ArrayRef<SDValue> Ops, |
1669 | const SDNodeFlags Flags = SDNodeFlags()); |
1670 | |
1671 | |
1672 | |
1673 | SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT, |
1674 | SDValue N1, SDValue N2); |
1675 | |
1676 | |
1677 | SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, |
1678 | const SDLoc &dl); |
1679 | |
1680 | |
1681 | |
1682 | |
1683 | |
1684 | |
1685 | |
1686 | SDValue GetDemandedBits(SDValue V, const APInt &DemandedBits); |
1687 | |
1688 | |
1689 | |
1690 | |
1691 | |
1692 | |
1693 | |
1694 | |
1695 | SDValue GetDemandedBits(SDValue V, const APInt &DemandedBits, |
1696 | const APInt &DemandedElts); |
1697 | |
1698 | |
1699 | |
1700 | bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const; |
1701 | |
1702 | |
1703 | |
1704 | |
1705 | bool MaskedValueIsZero(SDValue Op, const APInt &Mask, |
1706 | unsigned Depth = 0) const; |
1707 | |
1708 | |
1709 | |
1710 | |
1711 | bool MaskedValueIsZero(SDValue Op, const APInt &Mask, |
1712 | const APInt &DemandedElts, unsigned Depth = 0) const; |
1713 | |
1714 | |
1715 | |
1716 | bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask, |
1717 | unsigned Depth = 0) const; |
1718 | |
1719 | |
1720 | |
1721 | |
1722 | |
1723 | |
1724 | KnownBits computeKnownBits(SDValue Op, unsigned Depth = 0) const; |
1725 | |
1726 | |
1727 | |
1728 | |
1729 | |
1730 | |
1731 | KnownBits computeKnownBits(SDValue Op, const APInt &DemandedElts, |
1732 | unsigned Depth = 0) const; |
1733 | |
1734 | |
1735 | |
1736 | |
1737 | |
1738 | enum OverflowKind { |
1739 | OFK_Never, |
1740 | OFK_Sometime, |
1741 | OFK_Always, |
1742 | }; |
1743 | |
1744 | |
1745 | OverflowKind computeOverflowKind(SDValue N0, SDValue N1) const; |
1746 | |
1747 | |
1748 | |
1749 | |
1750 | bool isKnownToBeAPowerOfTwo(SDValue Val) const; |
1751 | |
1752 | |
1753 | |
1754 | |
1755 | |
1756 | |
1757 | |
1758 | |
1759 | unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const; |
1760 | |
1761 | |
1762 | |
1763 | |
1764 | |
1765 | |
1766 | |
1767 | |
1768 | |
1769 | unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts, |
1770 | unsigned Depth = 0) const; |
1771 | |
1772 | |
1773 | |
1774 | bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, bool PoisonOnly = false, |
1775 | unsigned Depth = 0) const; |
1776 | |
1777 | |
1778 | |
1779 | |
1780 | bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, const APInt &DemandedElts, |
1781 | bool PoisonOnly = false, |
1782 | unsigned Depth = 0) const; |
1783 | |
1784 | |
1785 | bool isGuaranteedNotToBePoison(SDValue Op, unsigned Depth = 0) const { |
1786 | return isGuaranteedNotToBeUndefOrPoison(Op, true, Depth); |
1787 | } |
1788 | |
1789 | |
1790 | |
1791 | bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts, |
1792 | unsigned Depth = 0) const { |
1793 | return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts, |
1794 | true, Depth); |
1795 | } |
1796 | |
1797 | |
1798 | |
1799 | |
1800 | |
1801 | |
1802 | bool isBaseWithConstantOffset(SDValue Op) const; |
1803 | |
1804 | |
1805 | |
1806 | |
1807 | bool isKnownNeverNaN(SDValue Op, bool SNaN = false, unsigned Depth = 0) const; |
1808 | |
1809 | |
1810 | bool isKnownNeverSNaN(SDValue Op, unsigned Depth = 0) const { |
1811 | return isKnownNeverNaN(Op, true, Depth); |
1812 | } |
1813 | |
1814 | |
1815 | |
1816 | bool isKnownNeverZeroFloat(SDValue Op) const; |
1817 | |
1818 | |
1819 | bool isKnownNeverZero(SDValue Op) const; |
1820 | |
1821 | |
1822 | |
1823 | |
1824 | bool isEqualTo(SDValue A, SDValue B) const; |
1825 | |
1826 | |
1827 | |
1828 | bool haveNoCommonBitsSet(SDValue A, SDValue B) const; |
1829 | |
1830 | |
1831 | |
1832 | |
1833 | |
1834 | |
1835 | |
1836 | |
1837 | bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts, |
1838 | unsigned Depth = 0); |
1839 | |
1840 | |
1841 | bool isSplatValue(SDValue V, bool AllowUndefs = false); |
1842 | |
1843 | |
1844 | SDValue getSplatSourceVector(SDValue V, int &SplatIndex); |
1845 | |
1846 | |
1847 | |
1848 | |
1849 | |
1850 | SDValue getSplatValue(SDValue V, bool LegalTypes = false); |
1851 | |
1852 | |
1853 | |
1854 | const APInt *getValidShiftAmountConstant(SDValue V, |
1855 | const APInt &DemandedElts) const; |
1856 | |
1857 | |
1858 | |
1859 | const APInt * |
1860 | getValidMinimumShiftAmountConstant(SDValue V, |
1861 | const APInt &DemandedElts) const; |
1862 | |
1863 | |
1864 | |
1865 | const APInt * |
1866 | getValidMaximumShiftAmountConstant(SDValue V, |
1867 | const APInt &DemandedElts) const; |
1868 | |
1869 | |
1870 | |
1871 | |
1872 | |
1873 | |
1874 | |
1875 | |
1876 | |
1877 | SDValue matchBinOpReduction(SDNode *Extract, ISD::NodeType &BinOp, |
1878 | ArrayRef<ISD::NodeType> CandidateBinOps, |
1879 | bool AllowPartials = false); |
1880 | |
1881 | |
1882 | |
1883 | |
1884 | |
1885 | |
1886 | |
1887 | SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0); |
1888 | |
1889 | |
1890 | |
1891 | std::pair<SDValue, SDValue> UnrollVectorOverflowOp(SDNode *N, |
1892 | unsigned ResNE = 0); |
1893 | |
1894 | |
1895 | |
1896 | |
1897 | |
1898 | bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, |
1899 | unsigned Bytes, int Dist) const; |
1900 | |
1901 | |
1902 | |
1903 | MaybeAlign InferPtrAlign(SDValue Ptr) const; |
1904 | |
1905 | |
1906 | |
1907 | std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const; |
1908 | |
1909 | |
1910 | |
1911 | |
1912 | std::pair<EVT, EVT> GetDependentSplitDestVTs(const EVT &VT, const EVT &EnvVT, |
1913 | bool *HiIsEmpty) const; |
1914 | |
1915 | |
1916 | |
1917 | std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL, |
1918 | const EVT &LoVT, const EVT &HiVT); |
1919 | |
1920 | |
1921 | std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) { |
1922 | EVT LoVT, HiVT; |
1923 | std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType()); |
1924 | return SplitVector(N, DL, LoVT, HiVT); |
1925 | } |
1926 | |
1927 | |
1928 | |
1929 | std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo) |
1930 | { |
1931 | return SplitVector(N->getOperand(OpNo), SDLoc(N)); |
1932 | } |
1933 | |
1934 | |
1935 | SDValue WidenVector(const SDValue &N, const SDLoc &DL); |
1936 | |
1937 | |
1938 | |
1939 | |
1940 | |
1941 | void ExtractVectorElements(SDValue Op, SmallVectorImpl<SDValue> &Args, |
1942 | unsigned Start = 0, unsigned Count = 0, |
1943 | EVT EltVT = EVT()); |
1944 | |
1945 | |
1946 | Align getEVTAlign(EVT MemoryVT) const; |
1947 | |
1948 | |
1949 | inline unsigned getEVTAlignment(EVT MemoryVT) const { |
1950 | return getEVTAlign(MemoryVT).value(); |
1951 | } |
1952 | |
1953 | |
1954 | SDNode *isConstantIntBuildVectorOrConstantInt(SDValue N) const; |
1955 | |
1956 | |
1957 | SDNode *isConstantFPBuildVectorOrConstantFP(SDValue N) const ; |
1958 | |
1959 | |
1960 | |
1961 | inline bool isConstantValueOfAnyType(SDValue N) const { |
1962 | return isConstantIntBuildVectorOrConstantInt(N) || |
1963 | isConstantFPBuildVectorOrConstantFP(N); |
1964 | } |
1965 | |
1966 | void addCallSiteInfo(const SDNode *CallNode, CallSiteInfoImpl &&CallInfo) { |
1967 | SDCallSiteDbgInfo[CallNode].CSInfo = std::move(CallInfo); |
1968 | } |
1969 | |
1970 | CallSiteInfo getSDCallSiteInfo(const SDNode *CallNode) { |
1971 | auto I = SDCallSiteDbgInfo.find(CallNode); |
1972 | if (I != SDCallSiteDbgInfo.end()) |
1973 | return std::move(I->second).CSInfo; |
1974 | return CallSiteInfo(); |
1975 | } |
1976 | |
1977 | void addHeapAllocSite(const SDNode *Node, MDNode *MD) { |
1978 | SDCallSiteDbgInfo[Node].HeapAllocSite = MD; |
1979 | } |
1980 | |
1981 | |
1982 | MDNode *getHeapAllocSite(const SDNode *Node) { |
1983 | auto It = SDCallSiteDbgInfo.find(Node); |
1984 | if (It == SDCallSiteDbgInfo.end()) |
1985 | return nullptr; |
1986 | return It->second.HeapAllocSite; |
1987 | } |
1988 | |
1989 | void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) { |
1990 | if (NoMerge) |
1991 | SDCallSiteDbgInfo[Node].NoMerge = NoMerge; |
1992 | } |
1993 | |
1994 | bool getNoMergeSiteInfo(const SDNode *Node) { |
1995 | auto I = SDCallSiteDbgInfo.find(Node); |
1996 | if (I == SDCallSiteDbgInfo.end()) |
1997 | return false; |
1998 | return I->second.NoMerge; |
1999 | } |
2000 | |
2001 | |
2002 | |
2003 | DenormalMode getDenormalMode(EVT VT) const { |
2004 | return MF->getDenormalMode(EVTToAPFloatSemantics(VT)); |
2005 | } |
2006 | |
2007 | bool shouldOptForSize() const; |
2008 | |
2009 | |
2010 | SDValue getNeutralElement(unsigned Opcode, const SDLoc &DL, EVT VT, |
2011 | SDNodeFlags Flags); |
2012 | |
2013 | private: |
2014 | void InsertNode(SDNode *N); |
2015 | bool RemoveNodeFromCSEMaps(SDNode *N); |
2016 | void AddModifiedNodeToCSEMaps(SDNode *N); |
2017 | SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos); |
2018 | SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2, |
2019 | void *&InsertPos); |
2020 | SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops, |
2021 | void *&InsertPos); |
2022 | SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc); |
2023 | |
2024 | void DeleteNodeNotInCSEMaps(SDNode *N); |
2025 | void DeallocateNode(SDNode *N); |
2026 | |
2027 | void allnodes_clear(); |
2028 | |
2029 | |
2030 | |
2031 | |
2032 | |
2033 | SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos); |
2034 | |
2035 | |
2036 | |
2037 | |
2038 | SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, const SDLoc &DL, |
2039 | void *&InsertPos); |
2040 | |
2041 | |
2042 | FoldingSet<SDVTListNode> VTListMap; |
2043 | |
2044 | |
2045 | std::vector<CondCodeSDNode*> CondCodeNodes; |
2046 | |
2047 | std::vector<SDNode*> ValueTypeNodes; |
2048 | std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes; |
2049 | StringMap<SDNode*> ExternalSymbols; |
2050 | |
2051 | std::map<std::pair<std::string, unsigned>, SDNode *> TargetExternalSymbols; |
2052 | DenseMap<MCSymbol *, SDNode *> MCSymbols; |
2053 | |
2054 | FlagInserter *Inserter = nullptr; |
2055 | }; |
2056 | |
2057 | template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> { |
2058 | using nodes_iterator = pointer_iterator<SelectionDAG::allnodes_iterator>; |
2059 | |
2060 | static nodes_iterator nodes_begin(SelectionDAG *G) { |
2061 | return nodes_iterator(G->allnodes_begin()); |
2062 | } |
2063 | |
2064 | static nodes_iterator nodes_end(SelectionDAG *G) { |
2065 | return nodes_iterator(G->allnodes_end()); |
2066 | } |
2067 | }; |
2068 | |
2069 | } |
2070 | |
2071 | #endif // LLVM_CODEGEN_SELECTIONDAG_H |
1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | |
10 | |
11 | |
12 | |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | #ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H |
19 | #define LLVM_CODEGEN_SELECTIONDAGNODES_H |
20 | |
21 | #include "llvm/ADT/APFloat.h" |
22 | #include "llvm/ADT/ArrayRef.h" |
23 | #include "llvm/ADT/BitVector.h" |
24 | #include "llvm/ADT/FoldingSet.h" |
25 | #include "llvm/ADT/GraphTraits.h" |
26 | #include "llvm/ADT/SmallPtrSet.h" |
27 | #include "llvm/ADT/SmallVector.h" |
28 | #include "llvm/ADT/ilist_node.h" |
29 | #include "llvm/ADT/iterator.h" |
30 | #include "llvm/ADT/iterator_range.h" |
31 | #include "llvm/CodeGen/ISDOpcodes.h" |
32 | #include "llvm/CodeGen/MachineMemOperand.h" |
33 | #include "llvm/CodeGen/Register.h" |
34 | #include "llvm/CodeGen/ValueTypes.h" |
35 | #include "llvm/IR/Constants.h" |
36 | #include "llvm/IR/DebugLoc.h" |
37 | #include "llvm/IR/Instruction.h" |
38 | #include "llvm/IR/Instructions.h" |
39 | #include "llvm/IR/Metadata.h" |
40 | #include "llvm/IR/Operator.h" |
41 | #include "llvm/Support/AlignOf.h" |
42 | #include "llvm/Support/AtomicOrdering.h" |
43 | #include "llvm/Support/Casting.h" |
44 | #include "llvm/Support/ErrorHandling.h" |
45 | #include "llvm/Support/MachineValueType.h" |
46 | #include "llvm/Support/TypeSize.h" |
47 | #include <algorithm> |
48 | #include <cassert> |
49 | #include <climits> |
50 | #include <cstddef> |
51 | #include <cstdint> |
52 | #include <cstring> |
53 | #include <iterator> |
54 | #include <string> |
55 | #include <tuple> |
56 | |
57 | namespace llvm { |
58 | |
59 | class APInt; |
60 | class Constant; |
61 | template <typename T> struct DenseMapInfo; |
62 | class GlobalValue; |
63 | class MachineBasicBlock; |
64 | class MachineConstantPoolValue; |
65 | class MCSymbol; |
66 | class raw_ostream; |
67 | class SDNode; |
68 | class SelectionDAG; |
69 | class Type; |
70 | class Value; |
71 | |
72 | void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr, |
73 | bool force = false); |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | struct SDVTList { |
80 | const EVT *VTs; |
81 | unsigned int NumVTs; |
82 | }; |
83 | |
84 | namespace ISD { |
85 | |
86 | |
87 | |
88 | |
89 | |
90 | |
91 | bool isConstantSplatVector(const SDNode *N, APInt &SplatValue); |
92 | |
93 | |
94 | |
95 | |
96 | bool isConstantSplatVectorAllOnes(const SDNode *N, |
97 | bool BuildVectorOnly = false); |
98 | |
99 | |
100 | |
101 | |
102 | bool isConstantSplatVectorAllZeros(const SDNode *N, |
103 | bool BuildVectorOnly = false); |
104 | |
105 | |
106 | |
107 | bool isBuildVectorAllOnes(const SDNode *N); |
108 | |
109 | |
110 | |
111 | bool isBuildVectorAllZeros(const SDNode *N); |
112 | |
113 | |
114 | |
115 | bool isBuildVectorOfConstantSDNodes(const SDNode *N); |
116 | |
117 | |
118 | |
119 | bool isBuildVectorOfConstantFPSDNodes(const SDNode *N); |
120 | |
121 | |
122 | |
123 | bool allOperandsUndef(const SDNode *N); |
124 | |
125 | } |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | |
134 | |
135 | |
136 | |
137 | |
138 | class SDValue { |
139 | friend struct DenseMapInfo<SDValue>; |
140 | |
141 | SDNode *Node = nullptr; |
142 | unsigned ResNo = 0; |
143 | |
144 | public: |
145 | SDValue() = default; |
146 | SDValue(SDNode *node, unsigned resno); |
147 | |
148 | |
149 | unsigned getResNo() const { return ResNo; } |
150 | |
151 | |
152 | SDNode *getNode() const { return Node; } |
153 | |
154 | |
155 | void setNode(SDNode *N) { Node = N; } |
156 | |
157 | inline SDNode *operator->() const { return Node; } |
158 | |
159 | bool operator==(const SDValue &O) const { |
160 | return Node == O.Node && ResNo == O.ResNo; |
161 | } |
162 | bool operator!=(const SDValue &O) const { |
163 | return !operator==(O); |
164 | } |
165 | bool operator<(const SDValue &O) const { |
166 | return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo); |
167 | } |
168 | explicit operator bool() const { |
169 | return Node != nullptr; |
170 | } |
171 | |
172 | SDValue getValue(unsigned R) const { |
173 | return SDValue(Node, R); |
174 | } |
175 | |
176 | |
177 | bool isOperandOf(const SDNode *N) const; |
178 | |
179 | |
180 | inline EVT getValueType() const; |
181 | |
182 | |
183 | MVT getSimpleValueType() const { |
184 | return getValueType().getSimpleVT(); |
185 | } |
186 | |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | TypeSize getValueSizeInBits() const { |
193 | return getValueType().getSizeInBits(); |
194 | } |
195 | |
196 | uint64_t getScalarValueSizeInBits() const { |
197 | return getValueType().getScalarType().getFixedSizeInBits(); |
198 | } |
199 | |
200 | |
201 | inline unsigned getOpcode() const; |
202 | inline unsigned getNumOperands() const; |
203 | inline const SDValue &getOperand(unsigned i) const; |
204 | inline uint64_t getConstantOperandVal(unsigned i) const; |
205 | inline const APInt &getConstantOperandAPInt(unsigned i) const; |
206 | inline bool isTargetMemoryOpcode() const; |
207 | inline bool isTargetOpcode() const; |
208 | inline bool isMachineOpcode() const; |
209 | inline bool isUndef() const; |
210 | inline unsigned getMachineOpcode() const; |
211 | inline const DebugLoc &getDebugLoc() const; |
212 | inline void dump() const; |
213 | inline void dump(const SelectionDAG *G) const; |
214 | inline void dumpr() const; |
215 | inline void dumpr(const SelectionDAG *G) const; |
216 | |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | bool reachesChainWithoutSideEffects(SDValue Dest, |
223 | unsigned Depth = 2) const; |
224 | |
225 | |
226 | inline bool use_empty() const; |
227 | |
228 | |
229 | inline bool hasOneUse() const; |
230 | }; |
231 | |
232 | template<> struct DenseMapInfo<SDValue> { |
233 | static inline SDValue getEmptyKey() { |
234 | SDValue V; |
235 | V.ResNo = -1U; |
236 | return V; |
237 | } |
238 | |
239 | static inline SDValue getTombstoneKey() { |
240 | SDValue V; |
241 | V.ResNo = -2U; |
242 | return V; |
243 | } |
244 | |
245 | static unsigned getHashValue(const SDValue &Val) { |
246 | return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^ |
247 | (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo(); |
248 | } |
249 | |
250 | static bool isEqual(const SDValue &LHS, const SDValue &RHS) { |
251 | return LHS == RHS; |
252 | } |
253 | }; |
254 | |
255 | |
256 | |
257 | template<> struct simplify_type<SDValue> { |
258 | using SimpleType = SDNode *; |
259 | |
260 | static SimpleType getSimplifiedValue(SDValue &Val) { |
261 | return Val.getNode(); |
262 | } |
263 | }; |
264 | template<> struct simplify_type<const SDValue> { |
265 | using SimpleType = SDNode *; |
266 | |
267 | static SimpleType getSimplifiedValue(const SDValue &Val) { |
268 | return Val.getNode(); |
269 | } |
270 | }; |
271 | |
272 | |
273 | |
274 | |
275 | |
276 | |
277 | class SDUse { |
278 | |
279 | SDValue Val; |
280 | |
281 | SDNode *User = nullptr; |
282 | |
283 | |
284 | SDUse **Prev = nullptr; |
285 | SDUse *Next = nullptr; |
286 | |
287 | public: |
288 | SDUse() = default; |
289 | SDUse(const SDUse &U) = delete; |
290 | SDUse &operator=(const SDUse &) = delete; |
291 | |
292 | |
293 | operator const SDValue&() const { return Val; } |
294 | |
295 | |
296 | |
297 | const SDValue &get() const { return Val; } |
298 | |
299 | |
300 | SDNode *getUser() { return User; } |
301 | |
302 | |
303 | SDUse *getNext() const { return Next; } |
304 | |
305 | |
306 | SDNode *getNode() const { return Val.getNode(); } |
307 | |
308 | unsigned getResNo() const { return Val.getResNo(); } |
309 | |
310 | EVT getValueType() const { return Val.getValueType(); } |
311 | |
312 | |
313 | bool operator==(const SDValue &V) const { |
314 | return Val == V; |
315 | } |
316 | |
317 | |
318 | bool operator!=(const SDValue &V) const { |
319 | return Val != V; |
320 | } |
321 | |
322 | |
323 | bool operator<(const SDValue &V) const { |
324 | return Val < V; |
325 | } |
326 | |
327 | private: |
328 | friend class SelectionDAG; |
329 | friend class SDNode; |
330 | |
331 | friend class HandleSDNode; |
332 | |
333 | void setUser(SDNode *p) { User = p; } |
334 | |
335 | |
336 | |
337 | inline void set(const SDValue &V); |
338 | |
339 | |
340 | inline void setInitial(const SDValue &V); |
341 | |
342 | |
343 | inline void setNode(SDNode *N); |
344 | |
345 | void addToList(SDUse **List) { |
346 | Next = *List; |
347 | if (Next) Next->Prev = &Next; |
348 | Prev = List; |
349 | *List = this; |
350 | } |
351 | |
352 | void removeFromList() { |
353 | *Prev = Next; |
354 | if (Next) Next->Prev = Prev; |
355 | } |
356 | }; |
357 | |
358 | |
359 | |
360 | template<> struct simplify_type<SDUse> { |
361 | using SimpleType = SDNode *; |
362 | |
363 | static SimpleType getSimplifiedValue(SDUse &Val) { |
364 | return Val.getNode(); |
365 | } |
366 | }; |
367 | |
368 | |
369 | |
370 | |
371 | struct SDNodeFlags { |
372 | private: |
373 | bool NoUnsignedWrap : 1; |
374 | bool NoSignedWrap : 1; |
375 | bool Exact : 1; |
376 | bool NoNaNs : 1; |
377 | bool NoInfs : 1; |
378 | bool NoSignedZeros : 1; |
379 | bool AllowReciprocal : 1; |
380 | bool AllowContract : 1; |
381 | bool ApproximateFuncs : 1; |
382 | bool AllowReassociation : 1; |
383 | |
384 | |
385 | |
386 | |
387 | |
388 | |
389 | bool NoFPExcept : 1; |
390 | |
391 | public: |
392 | |
393 | SDNodeFlags() |
394 | : NoUnsignedWrap(false), NoSignedWrap(false), Exact(false), NoNaNs(false), |
395 | NoInfs(false), NoSignedZeros(false), AllowReciprocal(false), |
396 | AllowContract(false), ApproximateFuncs(false), |
397 | AllowReassociation(false), NoFPExcept(false) {} |
398 | |
399 | |
400 | void copyFMF(const FPMathOperator &FPMO) { |
401 | setNoNaNs(FPMO.hasNoNaNs()); |
402 | setNoInfs(FPMO.hasNoInfs()); |
403 | setNoSignedZeros(FPMO.hasNoSignedZeros()); |
404 | setAllowReciprocal(FPMO.hasAllowReciprocal()); |
405 | setAllowContract(FPMO.hasAllowContract()); |
406 | setApproximateFuncs(FPMO.hasApproxFunc()); |
407 | setAllowReassociation(FPMO.hasAllowReassoc()); |
408 | } |
409 | |
410 | |
411 | void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; } |
412 | void setNoSignedWrap(bool b) { NoSignedWrap = b; } |
413 | void setExact(bool b) { Exact = b; } |
414 | void setNoNaNs(bool b) { NoNaNs = b; } |
415 | void setNoInfs(bool b) { NoInfs = b; } |
416 | void setNoSignedZeros(bool b) { NoSignedZeros = b; } |
417 | void setAllowReciprocal(bool b) { AllowReciprocal = b; } |
418 | void setAllowContract(bool b) { AllowContract = b; } |
419 | void setApproximateFuncs(bool b) { ApproximateFuncs = b; } |
420 | void setAllowReassociation(bool b) { AllowReassociation = b; } |
421 | void setNoFPExcept(bool b) { NoFPExcept = b; } |
422 | |
423 | |
424 | bool hasNoUnsignedWrap() const { return NoUnsignedWrap; } |
425 | bool hasNoSignedWrap() const { return NoSignedWrap; } |
426 | bool hasExact() const { return Exact; } |
427 | bool hasNoNaNs() const { return NoNaNs; } |
428 | bool hasNoInfs() const { return NoInfs; } |
429 | bool hasNoSignedZeros() const { return NoSignedZeros; } |
430 | bool hasAllowReciprocal() const { return AllowReciprocal; } |
431 | bool hasAllowContract() const { return AllowContract; } |
432 | bool hasApproximateFuncs() const { return ApproximateFuncs; } |
433 | bool hasAllowReassociation() const { return AllowReassociation; } |
434 | bool hasNoFPExcept() const { return NoFPExcept; } |
435 | |
436 | |
437 | |
438 | void intersectWith(const SDNodeFlags Flags) { |
439 | NoUnsignedWrap &= Flags.NoUnsignedWrap; |
440 | NoSignedWrap &= Flags.NoSignedWrap; |
441 | Exact &= Flags.Exact; |
442 | NoNaNs &= Flags.NoNaNs; |
443 | NoInfs &= Flags.NoInfs; |
444 | NoSignedZeros &= Flags.NoSignedZeros; |
445 | AllowReciprocal &= Flags.AllowReciprocal; |
446 | AllowContract &= Flags.AllowContract; |
447 | ApproximateFuncs &= Flags.ApproximateFuncs; |
448 | AllowReassociation &= Flags.AllowReassociation; |
449 | NoFPExcept &= Flags.NoFPExcept; |
450 | } |
451 | }; |
452 | |
453 | |
454 | |
455 | class SDNode : public FoldingSetNode, public ilist_node<SDNode> { |
456 | private: |
457 | |
458 | int16_t NodeType; |
459 | |
460 | protected: |
461 | |
462 | |
463 | |
464 | |
465 | #if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__)) |
466 | |
467 | |
468 | #define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)") |
469 | #define END_TWO_BYTE_PACK() _Pragma("pack(pop)") |
470 | #else |
471 | #define BEGIN_TWO_BYTE_PACK() |
472 | #define END_TWO_BYTE_PACK() |
473 | #endif |
474 | |
475 | BEGIN_TWO_BYTE_PACK() |
476 | class SDNodeBitfields { |
477 | friend class SDNode; |
478 | friend class MemIntrinsicSDNode; |
479 | friend class MemSDNode; |
480 | friend class SelectionDAG; |
481 | |
482 | uint16_t HasDebugValue : 1; |
483 | uint16_t IsMemIntrinsic : 1; |
484 | uint16_t IsDivergent : 1; |
485 | }; |
486 | enum { NumSDNodeBits = 3 }; |
487 | |
488 | class ConstantSDNodeBitfields { |
489 | friend class ConstantSDNode; |
490 | |
491 | uint16_t : NumSDNodeBits; |
492 | |
493 | uint16_t IsOpaque : 1; |
494 | }; |
495 | |
496 | class MemSDNodeBitfields { |
497 | friend class MemSDNode; |
498 | friend class MemIntrinsicSDNode; |
499 | friend class AtomicSDNode; |
500 | |
501 | uint16_t : NumSDNodeBits; |
502 | |
503 | uint16_t IsVolatile : 1; |
504 | uint16_t IsNonTemporal : 1; |
505 | uint16_t IsDereferenceable : 1; |
506 | uint16_t IsInvariant : 1; |
507 | }; |
508 | enum { NumMemSDNodeBits = NumSDNodeBits + 4 }; |
509 | |
510 | class LSBaseSDNodeBitfields { |
511 | friend class LSBaseSDNode; |
512 | friend class MaskedLoadStoreSDNode; |
513 | friend class MaskedGatherScatterSDNode; |
514 | |
515 | uint16_t : NumMemSDNodeBits; |
516 | |
517 | |
518 | |
519 | |
520 | |
521 | |
522 | uint16_t AddressingMode : 3; |
523 | }; |
524 | enum { NumLSBaseSDNodeBits = NumMemSDNodeBits + 3 }; |
525 | |
526 | class LoadSDNodeBitfields { |
527 | friend class LoadSDNode; |
528 | friend class MaskedLoadSDNode; |
529 | friend class MaskedGatherSDNode; |
530 | |
531 | uint16_t : NumLSBaseSDNodeBits; |
532 | |
533 | uint16_t ExtTy : 2; |
534 | uint16_t IsExpanding : 1; |
535 | }; |
536 | |
537 | class StoreSDNodeBitfields { |
538 | friend class StoreSDNode; |
539 | friend class MaskedStoreSDNode; |
540 | friend class MaskedScatterSDNode; |
541 | |
542 | uint16_t : NumLSBaseSDNodeBits; |
543 | |
544 | uint16_t IsTruncating : 1; |
545 | uint16_t IsCompressing : 1; |
546 | }; |
547 | |
548 | union { |
549 | char RawSDNodeBits[sizeof(uint16_t)]; |
550 | SDNodeBitfields SDNodeBits; |
551 | ConstantSDNodeBitfields ConstantSDNodeBits; |
552 | MemSDNodeBitfields MemSDNodeBits; |
553 | LSBaseSDNodeBitfields LSBaseSDNodeBits; |
554 | LoadSDNodeBitfields LoadSDNodeBits; |
555 | StoreSDNodeBitfields StoreSDNodeBits; |
556 | }; |
557 | END_TWO_BYTE_PACK() |
558 | #undef BEGIN_TWO_BYTE_PACK |
559 | #undef END_TWO_BYTE_PACK |
560 | |
561 | |
562 | |
563 | |
564 | static_assert(sizeof(SDNodeBitfields) <= 2, "field too wide"); |
565 | static_assert(sizeof(ConstantSDNodeBitfields) <= 2, "field too wide"); |
566 | static_assert(sizeof(MemSDNodeBitfields) <= 2, "field too wide"); |
567 | static_assert(sizeof(LSBaseSDNodeBitfields) <= 2, "field too wide"); |
568 | static_assert(sizeof(LoadSDNodeBitfields) <= 2, "field too wide"); |
569 | static_assert(sizeof(StoreSDNodeBitfields) <= 2, "field too wide"); |
570 | |
571 | private: |
572 | friend class SelectionDAG; |
573 | |
574 | friend class HandleSDNode; |
575 | |
576 | |
577 | int NodeId = -1; |
578 | |
579 | |
580 | SDUse *OperandList = nullptr; |
581 | |
582 | |
583 | |
584 | const EVT *ValueList; |
585 | |
586 | |
587 | SDUse *UseList = nullptr; |
588 | |
589 | |
590 | unsigned short NumOperands = 0; |
591 | unsigned short NumValues; |
592 | |
593 | |
594 | |
595 | |
596 | |
597 | |
598 | unsigned IROrder; |
599 | |
600 | |
601 | DebugLoc debugLoc; |
602 | |
603 | |
604 | static const EVT *getValueTypeList(EVT VT); |
605 | |
606 | SDNodeFlags Flags; |
607 | |
608 | public: |
609 | |
610 | |
611 | uint16_t PersistentId; |
612 | |
613 | |
614 | |
615 | |
616 | |
617 | |
618 | |
619 | |
620 | |
621 | unsigned getOpcode() const { return (unsigned short)NodeType; } |
622 | |
623 | |
624 | |
625 | bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; } |
626 | |
627 | |
628 | |
629 | |
630 | |
631 | |
632 | bool isTargetStrictFPOpcode() const { |
633 | return NodeType >= ISD::FIRST_TARGET_STRICTFP_OPCODE; |
634 | } |
635 | |
636 | |
637 | |
638 | |
639 | bool isTargetMemoryOpcode() const { |
640 | return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE; |
641 | } |
642 | |
643 | |
644 | bool isUndef() const { return NodeType == ISD::UNDEF; } |
645 | |
646 | |
647 | |
648 | |
649 | |
650 | |
651 | bool isMemIntrinsic() const { |
652 | return (NodeType == ISD::INTRINSIC_W_CHAIN || |
653 | NodeType == ISD::INTRINSIC_VOID) && |
654 | SDNodeBits.IsMemIntrinsic; |
655 | } |
656 | |
657 | |
658 | bool isStrictFPOpcode() { |
659 | switch (NodeType) { |
660 | default: |
661 | return false; |
662 | case ISD::STRICT_FP16_TO_FP: |
663 | case ISD::STRICT_FP_TO_FP16: |
664 | #define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \ |
665 | case ISD::STRICT_##DAGN: |
666 | #include "llvm/IR/ConstrainedOps.def" |
667 | return true; |
668 | } |
669 | } |
670 | |
671 | |
672 | |
673 | bool isMachineOpcode() const { return NodeType < 0; } |
674 | |
675 | |
676 | |
677 | |
678 | unsigned getMachineOpcode() const { |
679 | assert(isMachineOpcode() && "Not a MachineInstr opcode!"); |
680 | return ~NodeType; |
681 | } |
682 | |
683 | bool getHasDebugValue() const { return SDNodeBits.HasDebugValue; } |
684 | void setHasDebugValue(bool b) { SDNodeBits.HasDebugValue = b; } |
685 | |
686 | bool isDivergent() const { return SDNodeBits.IsDivergent; } |
687 | |
688 | |
689 | bool use_empty() const { return UseList == nullptr; } |
690 | |
691 | |
692 | bool hasOneUse() const { return hasSingleElement(uses()); } |
693 | |
694 | |
695 | |
696 | size_t use_size() const { return std::distance(use_begin(), use_end()); } |
697 | |
698 | |
699 | int getNodeId() const { return NodeId; } |
700 | |
701 | |
702 | void setNodeId(int Id) { NodeId = Id; } |
703 | |
704 | |
705 | unsigned getIROrder() const { return IROrder; } |
706 | |
707 | |
708 | void setIROrder(unsigned Order) { IROrder = Order; } |
709 | |
710 | |
711 | const DebugLoc &getDebugLoc() const { return debugLoc; } |
712 | |
713 | |
714 | |
715 | void setDebugLoc(DebugLoc dl) { debugLoc = std::move(dl); } |
716 | |
717 | |
718 | |
719 | class use_iterator { |
720 | friend class SDNode; |
721 | |
722 | SDUse *Op = nullptr; |
723 | |
724 | explicit use_iterator(SDUse *op) : Op(op) {} |
725 | |
726 | public: |
727 | using iterator_category = std::forward_iterator_tag; |
728 | using value_type = SDUse; |
729 | using difference_type = std::ptrdiff_t; |
730 | using pointer = value_type *; |
731 | using reference = value_type &; |
732 | |
733 | use_iterator() = default; |
734 | use_iterator(const use_iterator &I) : Op(I.Op) {} |
735 | |
736 | bool operator==(const use_iterator &x) const { |
737 | return Op == x.Op; |
738 | } |
739 | bool operator!=(const use_iterator &x) const { |
740 | return !operator==(x); |
741 | } |
742 | |
743 | |
744 | bool atEnd() const { return Op == nullptr; } |
745 | |
746 | |
747 | use_iterator &operator++() { |
748 | assert(Op && "Cannot increment end iterator!"); |
749 | Op = Op->getNext(); |
750 | return *this; |
751 | } |
752 | |
753 | use_iterator operator++(int) { |
754 | use_iterator tmp = *this; ++*this; return tmp; |
755 | } |
756 | |
757 | |
758 | SDNode *operator*() const { |
759 | assert(Op && "Cannot dereference end iterator!"); |
760 | return Op->getUser(); |
761 | } |
762 | |
763 | SDNode *operator->() const { return operator*(); } |
764 | |
765 | SDUse &getUse() const { return *Op; } |
766 | |
767 | |
768 | unsigned getOperandNo() const { |
769 | assert(Op && "Cannot dereference end iterator!"); |
770 | return (unsigned)(Op - Op->getUser()->OperandList); |
771 | } |
772 | }; |
773 | |
774 | |
775 | use_iterator use_begin() const { |
776 | return use_iterator(UseList); |
777 | } |
778 | |
779 | static use_iterator use_end() { return use_iterator(nullptr); } |
780 | |
781 | inline iterator_range<use_iterator> uses() { |
782 | return make_range(use_begin(), use_end()); |
783 | } |
784 | inline iterator_range<use_iterator> uses() const { |
785 | return make_range(use_begin(), use_end()); |
786 | } |
787 | |
788 | |
789 | |
790 | bool hasNUsesOfValue(unsigned NUses, unsigned Value) const; |
791 | |
792 | |
793 | |
794 | bool hasAnyUseOfValue(unsigned Value) const; |
795 | |
796 | |
797 | bool isOnlyUserOf(const SDNode *N) const; |
798 | |
799 | |
800 | bool isOperandOf(const SDNode *N) const; |
801 | |
802 | |
803 | |
804 | |
805 | bool isPredecessorOf(const SDNode *N) const { |
806 | return N->hasPredecessor(this); |
807 | } |
808 | |
809 | |
810 | |
811 | |
812 | |
813 | bool hasPredecessor(const SDNode *N) const; |
814 | |
815 | |
816 | |
817 | |
818 | |
819 | |
820 | |
821 | |
822 | |
823 | |
824 | static bool hasPredecessorHelper(const SDNode *N, |
825 | SmallPtrSetImpl<const SDNode *> &Visited, |
826 | SmallVectorImpl<const SDNode *> &Worklist, |
827 | unsigned int MaxSteps = 0, |
828 | bool TopologicalPrune = false) { |
829 | SmallVector<const SDNode *, 8> DeferredNodes; |
830 | if (Visited.count(N)) |
831 | return true; |
832 | |
833 | |
834 | |
835 | |
836 | |
837 | |
838 | |
839 | |
840 | |
841 | |
842 | |
843 | |
844 | int NId = N->getNodeId(); |
845 | |
846 | if (NId < -1) |
847 | NId = -(NId + 1); |
848 | |
849 | bool Found = false; |
850 | while (!Worklist.empty()) { |
851 | const SDNode *M = Worklist.pop_back_val(); |
852 | int MId = M->getNodeId(); |
853 | if (TopologicalPrune && M->getOpcode() != ISD::TokenFactor && (NId > 0) && |
854 | (MId > 0) && (MId < NId)) { |
855 | DeferredNodes.push_back(M); |
856 | continue; |
857 | } |
858 | for (const SDValue &OpV : M->op_values()) { |
859 | SDNode *Op = OpV.getNode(); |
860 | if (Visited.insert(Op).second) |
861 | Worklist.push_back(Op); |
862 | if (Op == N) |
863 | Found = true; |
864 | } |
865 | if (Found) |
866 | break; |
867 | if (MaxSteps != 0 && Visited.size() >= MaxSteps) |
868 | break; |
869 | } |
870 | |
871 | Worklist.append(DeferredNodes.begin(), DeferredNodes.end()); |
872 | |
873 | if (MaxSteps != 0 && Visited.size() >= MaxSteps) |
874 | return true; |
875 | return Found; |
876 | } |
877 | |
878 | |
879 | |
880 | static bool areOnlyUsersOf(ArrayRef<const SDNode *> Nodes, const SDNode *N); |
881 | |
882 | |
883 | unsigned getNumOperands() const { return NumOperands; } |
884 | |
885 | |
886 | static constexpr size_t getMaxNumOperands() { |
887 | return std::numeric_limits<decltype(SDNode::NumOperands)>::max(); |
888 | } |
889 | |
890 | |
891 | inline uint64_t getConstantOperandVal(unsigned Num) const; |
892 | |
893 | |
894 | inline const APInt &getConstantOperandAPInt(unsigned Num) const; |
895 | |
896 | const SDValue &getOperand(unsigned Num) const { |
897 | assert(Num < NumOperands && "Invalid child # of SDNode!"); |
898 | return OperandList[Num]; |
899 | } |
900 | |
901 | using op_iterator = SDUse *; |
902 | |
903 | op_iterator op_begin() const { return OperandList; } |
904 | op_iterator op_end() const { return OperandList+NumOperands; } |
905 | ArrayRef<SDUse> ops() const { return makeArrayRef(op_begin(), op_end()); } |
906 | |
907 | |
908 | struct value_op_iterator |
909 | : iterator_adaptor_base<value_op_iterator, op_iterator, |
910 | std::random_access_iterator_tag, SDValue, |
911 | ptrdiff_t, value_op_iterator *, |
912 | value_op_iterator *> { |
913 | explicit value_op_iterator(SDUse *U = nullptr) |
914 | : iterator_adaptor_base(U) {} |
915 | |
916 | const SDValue &operator*() const { return I->get(); } |
917 | }; |
918 | |
919 | iterator_range<value_op_iterator> op_values() const { |
920 | return make_range(value_op_iterator(op_begin()), |
921 | value_op_iterator(op_end())); |
922 | } |
923 | |
924 | SDVTList getVTList() const { |
925 | SDVTList X = { ValueList, NumValues }; |
926 | return X; |
927 | } |
928 | |
929 | |
930 | |
931 | SDNode *getGluedNode() const { |
932 | if (getNumOperands() != 0 && |
933 | getOperand(getNumOperands()-1).getValueType() == MVT::Glue) |
934 | return getOperand(getNumOperands()-1).getNode(); |
935 | return nullptr; |
936 | } |
937 | |
938 | |
939 | |
940 | SDNode *getGluedUser() const { |
941 | for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI) |
942 | if (UI.getUse().get().getValueType() == MVT::Glue) |
943 | return *UI; |
944 | return nullptr; |
945 | } |
946 | |
947 | SDNodeFlags getFlags() const { return Flags; } |
948 | void setFlags(SDNodeFlags NewFlags) { Flags = NewFlags; } |
949 | |
950 | |
951 | |
952 | void intersectFlagsWith(const SDNodeFlags Flags); |
953 | |
954 | |
955 | unsigned getNumValues() const { return NumValues; } |
956 | |
957 | |
958 | EVT getValueType(unsigned ResNo) const { |
959 | assert(ResNo < NumValues && "Illegal result number!"); |
960 | return ValueList[ResNo]; |
961 | } |
962 | |
963 | |
964 | MVT getSimpleValueType(unsigned ResNo) const { |
965 | return getValueType(ResNo).getSimpleVT(); |
966 | } |
967 | |
968 | |
969 | |
970 | |
971 | |
972 | |
973 | TypeSize getValueSizeInBits(unsigned ResNo) const { |
974 | return getValueType(ResNo).getSizeInBits(); |
975 | } |
976 | |
977 | using value_iterator = const EVT *; |
978 | |
979 | value_iterator value_begin() const { return ValueList; } |
980 | value_iterator value_end() const { return ValueList+NumValues; } |
981 | iterator_range<value_iterator> values() const { |
982 | return llvm::make_range(value_begin(), value_end()); |
983 | } |
984 | |
985 | |
986 | std::string getOperationName(const SelectionDAG *G = nullptr) const; |
987 | static const char* getIndexedModeName(ISD::MemIndexedMode AM); |
988 | void print_types(raw_ostream &OS, const SelectionDAG *G) const; |
989 | void print_details(raw_ostream &OS, const SelectionDAG *G) const; |
990 | void print(raw_ostream &OS, const SelectionDAG *G = nullptr) const; |
991 | void printr(raw_ostream &OS, const SelectionDAG *G = nullptr) const; |
992 | |
993 | |
994 | |
995 | |
996 | |
997 | |
998 | |
999 | void printrFull(raw_ostream &O, const SelectionDAG *G = nullptr) const; |
1000 | |
1001 | |
1002 | |
1003 | |
1004 | |
1005 | |
1006 | |
1007 | void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr, |
1008 | unsigned depth = 100) const; |
1009 | |
1010 | |
1011 | void dump() const; |
1012 | |
1013 | |
1014 | void dumpr() const; |
1015 | |
1016 | |
1017 | |
1018 | |
1019 | void dump(const SelectionDAG *G) const; |
1020 | |
1021 | |
1022 | |
1023 | |
1024 | void dumpr(const SelectionDAG *G) const; |
1025 | |
1026 | |
1027 | |
1028 | |
1029 | |
1030 | void dumprFull(const SelectionDAG *G = nullptr) const; |
1031 | |
1032 | |
1033 | |
1034 | |
1035 | |
1036 | |
1037 | void dumprWithDepth(const SelectionDAG *G = nullptr, |
1038 | unsigned depth = 100) const; |
1039 | |
1040 | |
1041 | void Profile(FoldingSetNodeID &ID) const; |
1042 | |
1043 | |
1044 | void addUse(SDUse &U) { U.addToList(&UseList); } |
1045 | |
1046 | protected: |
1047 | static SDVTList getSDVTList(EVT VT) { |
1048 | SDVTList Ret = { getValueTypeList(VT), 1 }; |
1049 | return Ret; |
1050 | } |
1051 | |
1052 | |
1053 | |
1054 | |
1055 | |
1056 | SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs) |
1057 | : NodeType(Opc), ValueList(VTs.VTs), NumValues(VTs.NumVTs), |
1058 | IROrder(Order), debugLoc(std::move(dl)) { |
1059 | memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits)); |
1060 | assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor"); |
1061 | assert(NumValues == VTs.NumVTs && |
1062 | "NumValues wasn't wide enough for its operands!"); |
1063 | } |
1064 | |
1065 | |
1066 | void DropOperands(); |
1067 | }; |
1068 | |
1069 | |
1070 | |
1071 | |
1072 | |
1073 | |
1074 | |
1075 | |
1076 | |
1077 | |
1078 | class SDLoc { |
1079 | private: |
1080 | DebugLoc DL; |
1081 | int IROrder = 0; |
1082 | |
1083 | public: |
1084 | SDLoc() = default; |
1085 | SDLoc(const SDNode *N) : DL(N->getDebugLoc()), IROrder(N->getIROrder()) {} |
1086 | SDLoc(const SDValue V) : SDLoc(V.getNode()) {} |
1087 | SDLoc(const Instruction *I, int Order) : IROrder(Order) { |
1088 | assert(Order >= 0 && "bad IROrder"); |
1089 | if (I) |
1090 | DL = I->getDebugLoc(); |
1091 | } |
1092 | |
1093 | unsigned getIROrder() const { return IROrder; } |
1094 | const DebugLoc &getDebugLoc() const { return DL; } |
1095 | }; |
1096 | |
1097 | |
1098 | |
1099 | inline SDValue::SDValue(SDNode *node, unsigned resno) |
1100 | : Node(node), ResNo(resno) { |
1101 | |
1102 | |
1103 | |
1104 | assert((!Node || !ResNo || ResNo < Node->getNumValues()) && |
1105 | "Invalid result number for the given node!"); |
1106 | assert(ResNo < -2U && "Cannot use result numbers reserved for DenseMaps."); |
1107 | } |
1108 | |
1109 | inline unsigned SDValue::getOpcode() const { |
1110 | return Node->getOpcode(); |
1111 | } |
1112 | |
1113 | inline EVT SDValue::getValueType() const { |
1114 | return Node->getValueType(ResNo); |
| 11 | | Called C++ object pointer is null |
|
1115 | } |
1116 | |
1117 | inline unsigned SDValue::getNumOperands() const { |
1118 | return Node->getNumOperands(); |
1119 | } |
1120 | |
1121 | inline const SDValue &SDValue::getOperand(unsigned i) const { |
1122 | return Node->getOperand(i); |
1123 | } |
1124 | |
1125 | inline uint64_t SDValue::getConstantOperandVal(unsigned i) const { |
1126 | return Node->getConstantOperandVal(i); |
1127 | } |
1128 | |
1129 | inline const APInt &SDValue::getConstantOperandAPInt(unsigned i) const { |
1130 | return Node->getConstantOperandAPInt(i); |
1131 | } |
1132 | |
1133 | inline bool SDValue::isTargetOpcode() const { |
1134 | return Node->isTargetOpcode(); |
1135 | } |
1136 | |
1137 | inline bool SDValue::isTargetMemoryOpcode() const { |
1138 | return Node->isTargetMemoryOpcode(); |
1139 | } |
1140 | |
1141 | inline bool SDValue::isMachineOpcode() const { |
1142 | return Node->isMachineOpcode(); |
1143 | } |
1144 | |
1145 | inline unsigned SDValue::getMachineOpcode() const { |
1146 | return Node->getMachineOpcode(); |
1147 | } |
1148 | |
1149 | inline bool SDValue::isUndef() const { |
1150 | return Node->isUndef(); |
1151 | } |
1152 | |
1153 | inline bool SDValue::use_empty() const { |
1154 | return !Node->hasAnyUseOfValue(ResNo); |
1155 | } |
1156 | |
1157 | inline bool SDValue::hasOneUse() const { |
1158 | return Node->hasNUsesOfValue(1, ResNo); |
1159 | } |
1160 | |
1161 | inline const DebugLoc &SDValue::getDebugLoc() const { |
1162 | return Node->getDebugLoc(); |
1163 | } |
1164 | |
1165 | inline void SDValue::dump() const { |
1166 | return Node->dump(); |
1167 | } |
1168 | |
1169 | inline void SDValue::dump(const SelectionDAG *G) const { |
1170 | return Node->dump(G); |
1171 | } |
1172 | |
1173 | inline void SDValue::dumpr() const { |
1174 | return Node->dumpr(); |
1175 | } |
1176 | |
1177 | inline void SDValue::dumpr(const SelectionDAG *G) const { |
1178 | return Node->dumpr(G); |
1179 | } |
1180 | |
1181 | |
1182 | |
1183 | inline void SDUse::set(const SDValue &V) { |
1184 | if (Val.getNode()) removeFromList(); |
1185 | Val = V; |
1186 | if (V.getNode()) V.getNode()->addUse(*this); |
1187 | } |
1188 | |
1189 | inline void SDUse::setInitial(const SDValue &V) { |
1190 | Val = V; |
1191 | V.getNode()->addUse(*this); |
1192 | } |
1193 | |
1194 | inline void SDUse::setNode(SDNode *N) { |
1195 | if (Val.getNode()) removeFromList(); |
1196 | Val.setNode(N); |
1197 | if (N) N->addUse(*this); |
1198 | } |
1199 | |
1200 | |
1201 | |
1202 | |
1203 | |
1204 | class HandleSDNode : public SDNode { |
1205 | SDUse Op; |
1206 | |
1207 | public: |
1208 | explicit HandleSDNode(SDValue X) |
1209 | : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) { |
1210 | |
1211 | |
1212 | PersistentId = 0xffff; |
1213 | |
1214 | |
1215 | |
1216 | |
1217 | |
1218 | Op.setUser(this); |
1219 | Op.setInitial(X); |
1220 | NumOperands = 1; |
1221 | OperandList = &Op; |
1222 | } |
1223 | ~HandleSDNode(); |
1224 | |
1225 | const SDValue &getValue() const { return Op; } |
1226 | }; |
1227 | |
1228 | class AddrSpaceCastSDNode : public SDNode { |
1229 | private: |
1230 | unsigned SrcAddrSpace; |
1231 | unsigned DestAddrSpace; |
1232 | |
1233 | public: |
1234 | AddrSpaceCastSDNode(unsigned Order, const DebugLoc &dl, EVT VT, |
1235 | unsigned SrcAS, unsigned DestAS); |
1236 | |
1237 | unsigned getSrcAddressSpace() const { return SrcAddrSpace; } |
1238 | unsigned getDestAddressSpace() const { return DestAddrSpace; } |
1239 | |
1240 | static bool classof(const SDNode *N) { |
1241 | return N->getOpcode() == ISD::ADDRSPACECAST; |
1242 | } |
1243 | }; |
1244 | |
1245 | |
1246 | class MemSDNode : public SDNode { |
1247 | private: |
1248 | |
1249 | EVT MemoryVT; |
1250 | |
1251 | protected: |
1252 | |
1253 | MachineMemOperand *MMO; |
1254 | |
1255 | public: |
1256 | MemSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTs, |
1257 | EVT memvt, MachineMemOperand *MMO); |
1258 | |
1259 | bool readMem() const { return MMO->isLoad(); } |
1260 | bool writeMem() const { return MMO->isStore(); } |
1261 | |
1262 | |
1263 | Align getOriginalAlign() const { return MMO->getBaseAlign(); } |
1264 | Align getAlign() const { return MMO->getAlign(); } |
1265 | |
1266 | unsigned getAlignment() const { return MMO->getAlign().value(); } |
1267 | |
1268 | |
1269 | |
1270 | |
1271 | |
1272 | |
1273 | |
1274 | unsigned getRawSubclassData() const { |
1275 | uint16_t Data; |
1276 | union { |
1277 | char RawSDNodeBits[sizeof(uint16_t)]; |
1278 | SDNodeBitfields SDNodeBits; |
1279 | }; |
1280 | memcpy(&RawSDNodeBits, &this->RawSDNodeBits, sizeof(this->RawSDNodeBits)); |
1281 | SDNodeBits.HasDebugValue = 0; |
1282 | SDNodeBits.IsDivergent = false; |
1283 | memcpy(&Data, &RawSDNodeBits, sizeof(RawSDNodeBits)); |
1284 | return Data; |
1285 | } |
1286 | |
1287 | bool isVolatile() const { return MemSDNodeBits.IsVolatile; } |
1288 | bool isNonTemporal() const { return MemSDNodeBits.IsNonTemporal; } |
1289 | bool isDereferenceable() const { return MemSDNodeBits.IsDereferenceable; } |
1290 | bool isInvariant() const { return MemSDNodeBits.IsInvariant; } |
1291 | |
1292 | |
1293 | int64_t getSrcValueOffset() const { return MMO->getOffset(); } |
1294 | |
1295 | |
1296 | AAMDNodes getAAInfo() const { return MMO->getAAInfo(); } |
1297 | |
1298 | |
1299 | const MDNode *getRanges() const { return MMO->getRanges(); } |
1300 | |
1301 | |
1302 | SyncScope::ID getSyncScopeID() const { return MMO->getSyncScopeID(); } |
1303 | |
1304 | |
1305 | |
1306 | |
1307 | AtomicOrdering getSuccessOrdering() const { |
1308 | return MMO->getSuccessOrdering(); |
1309 | } |
1310 | |
1311 | |
1312 | |
1313 | |
1314 | AtomicOrdering getMergedOrdering() const { return MMO->getMergedOrdering(); } |
1315 | |
1316 | |
1317 | bool isAtomic() const { return MMO->isAtomic(); } |
1318 | |
1319 | |
1320 | |
1321 | |
1322 | bool isUnordered() const { return MMO->isUnordered(); } |
1323 | |
1324 | |
1325 | bool isSimple() const { return !isAtomic() && !isVolatile(); } |
1326 | |
1327 | |
1328 | EVT getMemoryVT() const { return MemoryVT; } |
1329 | |
1330 | |
1331 | |
1332 | MachineMemOperand *getMemOperand() const { return MMO; } |
1333 | |
1334 | const MachinePointerInfo &getPointerInfo() const { |
1335 | return MMO->getPointerInfo(); |
1336 | } |
1337 | |
1338 | |
1339 | unsigned getAddressSpace() const { |
1340 | return getPointerInfo().getAddrSpace(); |
1341 | } |
1342 | |
1343 | |
1344 | |
1345 | |
1346 | |
1347 | void refineAlignment(const MachineMemOperand *NewMMO) { |
1348 | MMO->refineAlignment(NewMMO); |
1349 | } |
1350 | |
1351 | const SDValue &getChain() const { return getOperand(0); } |
1352 | |
1353 | const SDValue &getBasePtr() const { |
1354 | switch (getOpcode()) { |
1355 | case ISD::STORE: |
1356 | case ISD::MSTORE: |
1357 | return getOperand(2); |
1358 | case ISD::MGATHER: |
1359 | case ISD::MSCATTER: |
1360 | return getOperand(3); |
1361 | default: |
1362 | return getOperand(1); |
1363 | } |
1364 | } |
1365 | |
1366 | |
1367 | static bool classof(const SDNode *N) { |
1368 | |
1369 | |
1370 | switch (N->getOpcode()) { |
1371 | case ISD::LOAD: |
1372 | case ISD::STORE: |
1373 | case ISD::PREFETCH: |
1374 | case ISD::ATOMIC_CMP_SWAP: |
1375 | case ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS: |
1376 | case ISD::ATOMIC_SWAP: |
1377 | case ISD::ATOMIC_LOAD_ADD: |
1378 | case ISD::ATOMIC_LOAD_SUB: |
1379 | case ISD::ATOMIC_LOAD_AND: |
1380 | case ISD::ATOMIC_LOAD_CLR: |
1381 | case ISD::ATOMIC_LOAD_OR: |
1382 | case ISD::ATOMIC_LOAD_XOR: |
1383 | case ISD::ATOMIC_LOAD_NAND: |
1384 | case ISD::ATOMIC_LOAD_MIN: |
1385 | case ISD::ATOMIC_LOAD_MAX: |
1386 | case ISD::ATOMIC_LOAD_UMIN: |
1387 | case ISD::ATOMIC_LOAD_UMAX: |
1388 | case ISD::ATOMIC_LOAD_FADD: |
1389 | case ISD::ATOMIC_LOAD_FSUB: |
1390 | case ISD::ATOMIC_LOAD: |
1391 | case ISD::ATOMIC_STORE: |
1392 | case ISD::MLOAD: |
1393 | case ISD::MSTORE: |
1394 | case ISD::MGATHER: |
1395 | case ISD::MSCATTER: |
1396 | return true; |
1397 | default: |
1398 | return N->isMemIntrinsic() || N->isTargetMemoryOpcode(); |
1399 | } |
1400 | } |
1401 | }; |
1402 | |
1403 | |
1404 | class AtomicSDNode : public MemSDNode { |
1405 | public: |
1406 | AtomicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTL, |
1407 | EVT MemVT, MachineMemOperand *MMO) |
1408 | : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) { |
1409 | assert(((Opc != ISD::ATOMIC_LOAD && Opc != ISD::ATOMIC_STORE) || |
1410 | MMO->isAtomic()) && "then why are we using an AtomicSDNode?"); |
1411 | } |
1412 | |
1413 | const SDValue &getBasePtr() const { return getOperand(1); } |
1414 | const SDValue &getVal() const { return getOperand(2); } |
1415 | |
1416 | |
1417 | |
1418 | bool isCompareAndSwap() const { |
1419 | unsigned Op = getOpcode(); |
1420 | return Op == ISD::ATOMIC_CMP_SWAP || |
1421 | Op == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS; |
1422 | } |
1423 | |
1424 | |
1425 | |
1426 | AtomicOrdering getFailureOrdering() const { |
1427 | assert(isCompareAndSwap() && "Must be cmpxchg operation"); |
1428 | return MMO->getFailureOrdering(); |
1429 | } |
1430 | |
1431 | |
1432 | static bool classof(const SDNode *N) { |
1433 | return N->getOpcode() == ISD::ATOMIC_CMP_SWAP || |
1434 | N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS || |
1435 | N->getOpcode() == ISD::ATOMIC_SWAP || |
1436 | N->getOpcode() == ISD::ATOMIC_LOAD_ADD || |
1437 | N->getOpcode() == ISD::ATOMIC_LOAD_SUB || |
1438 | N->getOpcode() == ISD::ATOMIC_LOAD_AND || |
1439 | N->getOpcode() == ISD::ATOMIC_LOAD_CLR || |
1440 | N->getOpcode() == ISD::ATOMIC_LOAD_OR || |
1441 | N->getOpcode() == ISD::ATOMIC_LOAD_XOR || |
1442 | N->getOpcode() == ISD::ATOMIC_LOAD_NAND || |
1443 | N->getOpcode() == ISD::ATOMIC_LOAD_MIN || |
1444 | N->getOpcode() == ISD::ATOMIC_LOAD_MAX || |
1445 | N->getOpcode() == ISD::ATOMIC_LOAD_UMIN || |
1446 | N->getOpcode() == ISD::ATOMIC_LOAD_UMAX || |
1447 | N->getOpcode() == ISD::ATOMIC_LOAD_FADD || |
1448 | N->getOpcode() == ISD::ATOMIC_LOAD_FSUB || |
1449 | N->getOpcode() == ISD::ATOMIC_LOAD || |
1450 | N->getOpcode() == ISD::ATOMIC_STORE; |
1451 | } |
1452 | }; |
1453 | |
1454 | |
1455 | |
1456 | |
1457 | |
1458 | class MemIntrinsicSDNode : public MemSDNode { |
1459 | public: |
1460 | MemIntrinsicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, |
1461 | SDVTList VTs, EVT MemoryVT, MachineMemOperand *MMO) |
1462 | : MemSDNode(Opc, Order, dl, VTs, MemoryVT, MMO) { |
1463 | SDNodeBits.IsMemIntrinsic = true; |
1464 | } |
1465 | |
1466 | |
1467 | static bool classof(const SDNode *N) { |
1468 | |
1469 | |
1470 | return N->isMemIntrinsic() || |
1471 | N->getOpcode() == ISD::PREFETCH || |
1472 | N->isTargetMemoryOpcode(); |
1473 | } |
1474 | }; |
1475 | |
1476 | |
1477 | |
1478 | |
1479 | |
1480 | |
1481 | |
1482 | |
1483 | |
1484 | class ShuffleVectorSDNode : public SDNode { |
1485 | |
1486 | |
1487 | const int *Mask; |
1488 | |
1489 | protected: |
1490 | friend class SelectionDAG; |
1491 | |
1492 | ShuffleVectorSDNode(EVT VT, unsigned Order, const DebugLoc &dl, const int *M) |
1493 | : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, getSDVTList(VT)), Mask(M) {} |
1494 | |
1495 | public: |
1496 | ArrayRef<int> getMask() const { |
1497 | EVT VT = getValueType(0); |
1498 | return makeArrayRef(Mask, VT.getVectorNumElements()); |
1499 | } |
1500 | |
1501 | int getMaskElt(unsigned Idx) const { |
1502 | assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!"); |
1503 | return Mask[Idx]; |
1504 | } |
1505 | |
1506 | bool isSplat() const { return isSplatMask(Mask, getValueType(0)); } |
1507 | |
1508 | int getSplatIndex() const { |
1509 | assert(isSplat() && "Cannot get splat index for non-splat!"); |
1510 | EVT VT = getValueType(0); |
1511 | for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i) |
1512 | if (Mask[i] >= 0) |
1513 | return Mask[i]; |
1514 | |
1515 | |
1516 | |
1517 | return 0; |
1518 | } |
1519 | |
1520 | static bool isSplatMask(const int *Mask, EVT VT); |
1521 | |
1522 | |
1523 | |
1524 | static void commuteMask(MutableArrayRef<int> Mask) { |
1525 | unsigned NumElems = Mask.size(); |
1526 | for (unsigned i = 0; i != NumElems; ++i) { |
1527 | int idx = Mask[i]; |
1528 | if (idx < 0) |
1529 | continue; |
1530 | else if (idx < (int)NumElems) |
1531 | Mask[i] = idx + NumElems; |
1532 | else |
1533 | Mask[i] = idx - NumElems; |
1534 | } |
1535 | } |
1536 | |
1537 | static bool classof(const SDNode *N) { |
1538 | return N->getOpcode() == ISD::VECTOR_SHUFFLE; |
1539 | } |
1540 | }; |
1541 | |
1542 | class ConstantSDNode : public SDNode { |
1543 | friend class SelectionDAG; |
1544 | |
1545 | const ConstantInt *Value; |
1546 | |
1547 | ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val, EVT VT) |
1548 | : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DebugLoc(), |
1549 | getSDVTList(VT)), |
1550 | Value(val) { |
1551 | ConstantSDNodeBits.IsOpaque = isOpaque; |
1552 | } |
1553 | |
1554 | public: |
1555 | const ConstantInt *getConstantIntValue() const { return Value; } |
1556 | const APInt &getAPIntValue() const { return Value->getValue(); } |
1557 | uint64_t getZExtValue() const { return Value->getZExtValue(); } |
1558 | int64_t getSExtValue() const { return Value->getSExtValue(); } |
1559 | uint64_t getLimitedValue(uint64_t Limit = UINT64_MAX) { |
1560 | return Value->getLimitedValue(Limit); |
1561 | } |
1562 | MaybeAlign getMaybeAlignValue() const { return Value->getMaybeAlignValue(); } |
1563 | Align getAlignValue() const { return Value->getAlignValue(); } |
1564 | |
1565 | bool isOne() const { return Value->isOne(); } |
1566 | bool isNullValue() const { return Value->isZero(); } |
1567 | bool isAllOnesValue() const { return Value->isMinusOne(); } |
1568 | bool isMaxSignedValue() const { return Value->isMaxValue(true); } |
1569 | bool isMinSignedValue() const { return Value->isMinValue(true); } |
1570 | |
1571 | bool isOpaque() const { return ConstantSDNodeBits.IsOpaque; } |
1572 | |
1573 | static bool classof(const SDNode *N) { |
1574 | return N->getOpcode() == ISD::Constant || |
1575 | N->getOpcode() == ISD::TargetConstant; |
1576 | } |
1577 | }; |
1578 | |
1579 | uint64_t SDNode::getConstantOperandVal(unsigned Num) const { |
1580 | return cast<ConstantSDNode>(getOperand(Num))->getZExtValue(); |
1581 | } |
1582 | |
1583 | const APInt &SDNode::getConstantOperandAPInt(unsigned Num) const { |
1584 | return cast<ConstantSDNode>(getOperand(Num))->getAPIntValue(); |
1585 | } |
1586 | |
1587 | class ConstantFPSDNode : public SDNode { |
1588 | friend class SelectionDAG; |
1589 | |
1590 | const ConstantFP *Value; |
1591 | |
1592 | ConstantFPSDNode(bool isTarget, const ConstantFP *val, EVT VT) |
1593 | : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0, |
1594 | DebugLoc(), getSDVTList(VT)), |
1595 | Value(val) {} |
1596 | |
1597 | public: |
1598 | const APFloat& getValueAPF() const { return Value->getValueAPF(); } |
1599 | const ConstantFP *getConstantFPValue() const { return Value; } |
1600 | |
1601 | |
1602 | bool isZero() const { return Value->isZero(); } |
1603 | |
1604 | |
1605 | bool isNaN() const { return Value->isNaN(); } |
1606 | |
1607 | |
1608 | bool isInfinity() const { return Value->isInfinity(); } |
1609 | |
1610 | |
1611 | bool isNegative() const { return Value->isNegative(); } |
1612 | |
1613 | |
1614 | |
1615 | |
1616 | |
1617 | |
1618 | |
1619 | |
1620 | |
1621 | bool isExactlyValue(double V) const { |
1622 | return Value->getValueAPF().isExactlyValue(V); |
1623 | } |
1624 | bool isExactlyValue(const APFloat& V) const; |
1625 | |
1626 | static bool isValueValidForType(EVT VT, const APFloat& Val); |
1627 | |
1628 | static bool classof(const SDNode *N) { |
1629 | return N->getOpcode() == ISD::ConstantFP || |
1630 | N->getOpcode() == ISD::TargetConstantFP; |
1631 | } |
1632 | }; |
1633 | |
1634 | |
1635 | bool isNullConstant(SDValue V); |
1636 | |
1637 | |
1638 | bool isNullFPConstant(SDValue V); |
1639 | |
1640 | |
1641 | bool isAllOnesConstant(SDValue V); |
1642 | |
1643 | |
1644 | bool isOneConstant(SDValue V); |
1645 | |
1646 | |
1647 | |
1648 | SDValue peekThroughBitcasts(SDValue V); |
1649 | |
1650 | |
1651 | |
1652 | SDValue peekThroughOneUseBitcasts(SDValue V); |
1653 | |
1654 | |
1655 | |
1656 | SDValue peekThroughExtractSubvectors(SDValue V); |
1657 | |
1658 | |
1659 | |
1660 | bool isBitwiseNot(SDValue V, bool AllowUndefs = false); |
1661 | |
1662 | |
1663 | ConstantSDNode *isConstOrConstSplat(SDValue N, bool AllowUndefs = false, |
1664 | bool AllowTruncation = false); |
1665 | |
1666 | |
1667 | |
1668 | ConstantSDNode *isConstOrConstSplat(SDValue N, const APInt &DemandedElts, |
1669 | bool AllowUndefs = false, |
1670 | bool AllowTruncation = false); |
1671 | |
1672 | |
1673 | ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, bool AllowUndefs = false); |
1674 | |
1675 | |
1676 | |
1677 | ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, const APInt &DemandedElts, |
1678 | bool AllowUndefs = false); |
1679 | |
1680 | |
1681 | |
1682 | |
1683 | bool isNullOrNullSplat(SDValue V, bool AllowUndefs = false); |
1684 | |
1685 | |
1686 | |
1687 | |
1688 | bool isOneOrOneSplat(SDValue V, bool AllowUndefs = false); |
1689 | |
1690 | |
1691 | |
1692 | |
1693 | bool isAllOnesOrAllOnesSplat(SDValue V, bool AllowUndefs = false); |
1694 | |
1695 | |
1696 | inline bool isIntOrFPConstant(SDValue V) { |
1697 | return isa<ConstantSDNode>(V) || isa<ConstantFPSDNode>(V); |
1698 | } |
1699 | |
1700 | class GlobalAddressSDNode : public SDNode { |
1701 | friend class SelectionDAG; |
1702 | |
1703 | const GlobalValue *TheGlobal; |
1704 | int64_t Offset; |
1705 | unsigned TargetFlags; |
1706 | |
1707 | GlobalAddressSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, |
1708 | const GlobalValue *GA, EVT VT, int64_t o, |
1709 | unsigned TF); |
1710 | |
1711 | public: |
1712 | const GlobalValue *getGlobal() const { return TheGlobal; } |
1713 | int64_t getOffset() const { return Offset; } |
1714 | unsigned getTargetFlags() const { return TargetFlags; } |
1715 | |
1716 | unsigned getAddressSpace() const; |
1717 | |
1718 | static bool classof(const SDNode *N) { |
1719 | return N->getOpcode() == ISD::GlobalAddress || |
1720 | N->getOpcode() == ISD::TargetGlobalAddress || |
1721 | N->getOpcode() == ISD::GlobalTLSAddress || |
1722 | N->getOpcode() == ISD::TargetGlobalTLSAddress; |
1723 | } |
1724 | }; |
1725 | |
1726 | class FrameIndexSDNode : public SDNode { |
1727 | friend class SelectionDAG; |
1728 | |
1729 | int FI; |
1730 | |
1731 | FrameIndexSDNode(int fi, EVT VT, bool isTarg) |
1732 | : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, |
1733 | 0, DebugLoc(), getSDVTList(VT)), FI(fi) { |
1734 | } |
1735 | |
1736 | public: |
1737 | int getIndex() const { return FI; } |
1738 | |
1739 | static bool classof(const SDNode *N) { |
1740 | return N->getOpcode() == ISD::FrameIndex || |
1741 | N->getOpcode() == ISD::TargetFrameIndex; |
1742 | } |
1743 | }; |
1744 | |
1745 | |
1746 | |
1747 | class LifetimeSDNode : public SDNode { |
1748 | friend class SelectionDAG; |
1749 | int64_t Size; |
1750 | int64_t Offset; |
1751 | |
1752 | LifetimeSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, |
1753 | SDVTList VTs, int64_t Size, int64_t Offset) |
1754 | : SDNode(Opcode, Order, dl, VTs), Size(Size), Offset(Offset) {} |
1755 | public: |
1756 | int64_t getFrameIndex() const { |
1757 | return cast<FrameIndexSDNode>(getOperand(1))->getIndex(); |
1758 | } |
1759 | |
1760 | bool hasOffset() const { return Offset >= 0; } |
1761 | int64_t getOffset() const { |
1762 | assert(hasOffset() && "offset is unknown"); |
1763 | return Offset; |
1764 | } |
1765 | int64_t getSize() const { |
1766 | assert(hasOffset() && "offset is unknown"); |
1767 | return Size; |
1768 | } |
1769 | |
1770 | |
1771 | static bool classof(const SDNode *N) { |
1772 | return N->getOpcode() == ISD::LIFETIME_START || |
1773 | N->getOpcode() == ISD::LIFETIME_END; |
1774 | } |
1775 | }; |
1776 | |
1777 | |
1778 | |
1779 | |
1780 | |
1781 | class PseudoProbeSDNode : public SDNode { |
1782 | friend class SelectionDAG; |
1783 | uint64_t Guid; |
1784 | uint64_t Index; |
1785 | uint32_t Attributes; |
1786 | |
1787 | PseudoProbeSDNode(unsigned Opcode, unsigned Order, const DebugLoc &Dl, |
1788 | SDVTList VTs, uint64_t Guid, uint64_t Index, uint32_t Attr) |
1789 | : SDNode(Opcode, Order, Dl, VTs), Guid(Guid), Index(Index), |
1790 | Attributes(Attr) {} |
1791 | |
1792 | public: |
1793 | uint64_t getGuid() const { return Guid; } |
1794 | uint64_t getIndex() const { return Index; } |
1795 | uint32_t getAttributes() const { return Attributes; } |
1796 | |
1797 | |
1798 | static bool classof(const SDNode *N) { |
1799 | return N->getOpcode() == ISD::PSEUDO_PROBE; |
1800 | } |
1801 | }; |
1802 | |
1803 | class JumpTableSDNode : public SDNode { |
1804 | friend class SelectionDAG; |
1805 | |
1806 | int JTI; |
1807 | unsigned TargetFlags; |
1808 | |
1809 | JumpTableSDNode(int jti, EVT VT, bool isTarg, unsigned TF) |
1810 | : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, |
1811 | 0, DebugLoc(), getSDVTList(VT)), JTI(jti), TargetFlags(TF) { |
1812 | } |
1813 | |
1814 | public: |
1815 | int getIndex() const { return JTI; } |
1816 | unsigned getTargetFlags() const { return TargetFlags; } |
1817 | |
1818 | static bool classof(const SDNode *N) { |
1819 | return N->getOpcode() == ISD::JumpTable || |
1820 | N->getOpcode() == ISD::TargetJumpTable; |
1821 | } |
1822 | }; |
1823 | |
1824 | class ConstantPoolSDNode : public SDNode { |
1825 | friend class SelectionDAG; |
1826 | |
1827 | union { |
1828 | const Constant *ConstVal; |
1829 | MachineConstantPoolValue *MachineCPVal; |
1830 | } Val; |
1831 | int Offset; |
1832 | Align Alignment; |
1833 | unsigned TargetFlags; |
1834 | |
1835 | ConstantPoolSDNode(bool isTarget, const Constant *c, EVT VT, int o, |
1836 | Align Alignment, unsigned TF) |
1837 | : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, |
1838 | DebugLoc(), getSDVTList(VT)), |
1839 | Offset(o), Alignment(Alignment), TargetFlags(TF) { |
1840 | assert(Offset >= 0 && "Offset is too large"); |
1841 | Val.ConstVal = c; |
1842 | } |
1843 | |
1844 | ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, EVT VT, int o, |
1845 | Align Alignment, unsigned TF) |
1846 | : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0, |
1847 | DebugLoc(), getSDVTList(VT)), |
1848 | Offset(o), Alignment(Alignment), TargetFlags(TF) { |
1849 | assert(Offset >= 0 && "Offset is too large"); |
1850 | Val.MachineCPVal = v; |
1851 | Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1); |
1852 | } |
1853 | |
1854 | public: |
1855 | bool isMachineConstantPoolEntry() const { |
1856 | return Offset < 0; |
1857 | } |
1858 | |
1859 | const Constant *getConstVal() const { |
1860 | assert(!isMachineConstantPoolEntry() && "Wrong constantpool type"); |
1861 | return Val.ConstVal; |
1862 | } |
1863 | |
1864 | MachineConstantPoolValue *getMachineCPVal() const { |
1865 | assert(isMachineConstantPoolEntry() && "Wrong constantpool type"); |
1866 | return Val.MachineCPVal; |
1867 | } |
1868 | |
1869 | int getOffset() const { |
1870 | return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1)); |
1871 | } |
1872 | |
1873 | |
1874 | |
1875 | Align getAlign() const { return Alignment; } |
1876 | unsigned getTargetFlags() const { return TargetFlags; } |
1877 | |
1878 | Type *getType() const; |
1879 | |
1880 | static bool classof(const SDNode *N) { |
1881 | return N->getOpcode() == ISD::ConstantPool || |
1882 | N->getOpcode() == ISD::TargetConstantPool; |
1883 | } |
1884 | }; |
1885 | |
1886 | |
1887 | class TargetIndexSDNode : public SDNode { |
1888 | friend class SelectionDAG; |
1889 | |
1890 | unsigned TargetFlags; |
1891 | int Index; |
1892 | int64_t Offset; |
1893 | |
1894 | public: |
1895 | TargetIndexSDNode(int Idx, EVT VT, int64_t Ofs, unsigned TF) |
1896 | : SDNode(ISD::TargetIndex, 0, DebugLoc(), getSDVTList(VT)), |
1897 | TargetFlags(TF), Index(Idx), Offset(Ofs) {} |
1898 | |
1899 | unsigned getTargetFlags() const { return TargetFlags; } |
1900 | int getIndex() const { return Index; } |
1901 | int64_t getOffset() const { return Offset; } |
1902 | |
1903 | static bool classof(const SDNode *N) { |
1904 | return N->getOpcode() == ISD::TargetIndex; |
1905 | } |
1906 | }; |
1907 | |
1908 | class BasicBlockSDNode : public SDNode { |
1909 | friend class SelectionDAG; |
1910 | |
1911 | MachineBasicBlock *MBB; |
1912 | |
1913 | |
1914 | |
1915 | |
1916 | explicit BasicBlockSDNode(MachineBasicBlock *mbb) |
1917 | : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb) |
1918 | {} |
1919 | |
1920 | public: |
1921 | MachineBasicBlock *getBasicBlock() const { return MBB; } |
1922 | |
1923 | static bool classof(const SDNode *N) { |
1924 | return N->getOpcode() == ISD::BasicBlock; |
1925 | } |
1926 | }; |
1927 | |
1928 | |
1929 | class BuildVectorSDNode : public SDNode { |
1930 | public: |
1931 | |
1932 | explicit BuildVectorSDNode() = delete; |
1933 | |
1934 | |
1935 | |
1936 | |
1937 | |
1938 | |
1939 | |
1940 | |
1941 | |
1942 | |
1943 | bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, |
1944 | unsigned &SplatBitSize, bool &HasAnyUndefs, |
1945 | unsigned MinSplatBits = 0, |
1946 | bool isBigEndian = false) const; |
1947 | |
1948 | |
1949 | |
1950 | |
1951 | |
1952 | |
1953 | |
1954 | SDValue getSplatValue(const APInt &DemandedElts, |
1955 | BitVector *UndefElements = nullptr) const; |
1956 | |
1957 | |
1958 | |
1959 | |
1960 | |
1961 | SDValue getSplatValue(BitVector *UndefElements = nullptr) const; |
1962 | |
1963 | |
1964 | |
1965 | |
1966 | |
1967 | |
1968 | |
1969 | |
1970 | |
1971 | |
1972 | |
1973 | |
1974 | bool getRepeatedSequence(const APInt &DemandedElts, |
1975 | SmallVectorImpl<SDValue> &Sequence, |
1976 | BitVector *UndefElements = nullptr) const; |
1977 | |
1978 | |
1979 | |
1980 | |
1981 | |
1982 | |
1983 | |
1984 | |
1985 | |
1986 | |
1987 | bool getRepeatedSequence(SmallVectorImpl<SDValue> &Sequence, |
1988 | BitVector *UndefElements = nullptr) const; |
1989 | |
1990 | |
1991 | |
1992 | |
1993 | |
1994 | |
1995 | |
1996 | ConstantSDNode * |
1997 | getConstantSplatNode(const APInt &DemandedElts, |
1998 | BitVector *UndefElements = nullptr) const; |
1999 | |
2000 | |
2001 | |
2002 | |
2003 | |
2004 | |
2005 | ConstantSDNode * |
2006 | getConstantSplatNode(BitVector *UndefElements = nullptr) const; |
2007 | |
2008 | |
2009 | |
2010 | |
2011 | |
2012 | |
2013 | |
2014 | ConstantFPSDNode * |
2015 | getConstantFPSplatNode(const APInt &DemandedElts, |
2016 | BitVector *UndefElements = nullptr) const; |
2017 | |
2018 | |
2019 | |
2020 | |
2021 | |
2022 | |
2023 | ConstantFPSDNode * |
2024 | getConstantFPSplatNode(BitVector *UndefElements = nullptr) const; |
2025 | |
2026 | |
2027 | |
2028 | |
2029 | |
2030 | |
2031 | int32_t getConstantFPSplatPow2ToLog2Int(BitVector *UndefElements, |
2032 | uint32_t BitWidth) const; |
2033 | |
2034 | bool isConstant() const; |
2035 | |
2036 | static bool classof(const SDNode *N) { |
2037 | return N->getOpcode() == ISD::BUILD_VECTOR; |
2038 | } |
2039 | }; |
2040 | |
2041 | |
2042 | |
2043 | |
2044 | |
2045 | class SrcValueSDNode : public SDNode { |
2046 | friend class SelectionDAG; |
2047 | |
2048 | const Value *V; |
2049 | |
2050 | |
2051 | explicit SrcValueSDNode(const Value *v) |
2052 | : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {} |
2053 | |
2054 | public: |
2055 | |
2056 | const Value *getValue() const { return V; } |
2057 | |
2058 | static bool classof(const SDNode *N) { |
2059 | return N->getOpcode() == ISD::SRCVALUE; |
2060 | } |
2061 | }; |
2062 | |
2063 | class MDNodeSDNode : public SDNode { |
2064 | friend class SelectionDAG; |
2065 | |
2066 | const MDNode *MD; |
2067 | |
2068 | explicit MDNodeSDNode(const MDNode *md) |
2069 | : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md) |
2070 | {} |
2071 | |
2072 | public: |
2073 | const MDNode *getMD() const { return MD; } |
2074 | |
2075 | static bool classof(const SDNode *N) { |
2076 | return N->getOpcode() == ISD::MDNODE_SDNODE; |
2077 | } |
2078 | }; |
2079 | |
2080 | class RegisterSDNode : public SDNode { |
2081 | friend class SelectionDAG; |
2082 | |
2083 | Register Reg; |
2084 | |
2085 | RegisterSDNode(Register reg, EVT VT) |
2086 | : SDNode(ISD::Register, 0, DebugLoc(), getSDVTList(VT)), Reg(reg) {} |
2087 | |
2088 | public: |
2089 | Register getReg() const { return Reg; } |
2090 | |
2091 | static bool classof(const SDNode *N) { |
2092 | return N->getOpcode() == ISD::Register; |
2093 | } |
2094 | }; |
2095 | |
2096 | class RegisterMaskSDNode : public SDNode { |
2097 | friend class SelectionDAG; |
2098 | |
2099 | |
2100 | const uint32_t *RegMask; |
2101 | |
2102 | RegisterMaskSDNode(const uint32_t *mask) |
2103 | : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)), |
2104 | RegMask(mask) {} |
2105 | |
2106 | public: |
2107 | const uint32_t *getRegMask() const { return RegMask; } |
2108 | |
2109 | static bool classof(const SDNode *N) { |
2110 | return N->getOpcode() == ISD::RegisterMask; |
2111 | } |
2112 | }; |
2113 | |
2114 | class BlockAddressSDNode : public SDNode { |
2115 | friend class SelectionDAG; |
2116 | |
2117 | const BlockAddress *BA; |
2118 | int64_t Offset; |
2119 | unsigned TargetFlags; |
2120 | |
2121 | BlockAddressSDNode(unsigned NodeTy, EVT VT, const BlockAddress *ba, |
2122 | int64_t o, unsigned Flags) |
2123 | : SDNode(NodeTy, 0, DebugLoc(), getSDVTList(VT)), |
2124 | BA(ba), Offset(o), TargetFlags(Flags) {} |
2125 | |
2126 | public: |
2127 | const BlockAddress *getBlockAddress() const { return BA; } |
2128 | int64_t getOffset() const { return Offset; } |
2129 | unsigned getTargetFlags() const { return TargetFlags; } |
2130 | |
2131 | static bool classof(const SDNode *N) { |
2132 | return N->getOpcode() == ISD::BlockAddress || |
2133 | N->getOpcode() == ISD::TargetBlockAddress; |
2134 | } |
2135 | }; |
2136 | |
2137 | class LabelSDNode : public SDNode { |
2138 | friend class SelectionDAG; |
2139 | |
2140 | MCSymbol *Label; |
2141 | |
2142 | LabelSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, MCSymbol *L) |
2143 | : SDNode(Opcode, Order, dl, getSDVTList(MVT::Other)), Label(L) { |
2144 | assert(LabelSDNode::classof(this) && "not a label opcode"); |
2145 | } |
2146 | |
2147 | public: |
2148 | MCSymbol *getLabel() const { return Label; } |
2149 | |
2150 | static bool classof(const SDNode *N) { |
2151 | return N->getOpcode() == ISD::EH_LABEL || |
2152 | N->getOpcode() == ISD::ANNOTATION_LABEL; |
2153 | } |
2154 | }; |
2155 | |
2156 | class ExternalSymbolSDNode : public SDNode { |
2157 | friend class SelectionDAG; |
2158 | |
2159 | const char *Symbol; |
2160 | unsigned TargetFlags; |
2161 | |
2162 | ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned TF, EVT VT) |
2163 | : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 0, |
2164 | DebugLoc(), getSDVTList(VT)), |
2165 | Symbol(Sym), TargetFlags(TF) {} |
2166 | |
2167 | public: |
2168 | const char *getSymbol() const { return Symbol; } |
2169 | unsigned getTargetFlags() const { return TargetFlags; } |
2170 | |
2171 | static bool classof(const SDNode *N) { |
2172 | return N->getOpcode() == ISD::ExternalSymbol || |
2173 | N->getOpcode() == ISD::TargetExternalSymbol; |
2174 | } |
2175 | }; |
2176 | |
2177 | class MCSymbolSDNode : public SDNode { |
2178 | friend class SelectionDAG; |
2179 | |
2180 | MCSymbol *Symbol; |
2181 | |
2182 | MCSymbolSDNode(MCSymbol *Symbol, EVT VT) |
2183 | : SDNode(ISD::MCSymbol, 0, DebugLoc(), getSDVTList(VT)), Symbol(Symbol) {} |
2184 | |
2185 | public: |
2186 | MCSymbol *getMCSymbol() const { return Symbol; } |
2187 | |
2188 | static bool classof(const SDNode *N) { |
2189 | return N->getOpcode() == ISD::MCSymbol; |
2190 | } |
2191 | }; |
2192 | |
2193 | class CondCodeSDNode : public SDNode { |
2194 | friend class SelectionDAG; |
2195 | |
2196 | ISD::CondCode Condition; |
2197 | |
2198 | explicit CondCodeSDNode(ISD::CondCode Cond) |
2199 | : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)), |
2200 | Condition(Cond) {} |
2201 | |
2202 | public: |
2203 | ISD::CondCode get() const { return Condition; } |
2204 | |
2205 | static bool classof(const SDNode *N) { |
2206 | return N->getOpcode() == ISD::CONDCODE; |
2207 | } |
2208 | }; |
2209 | |
2210 | |
2211 | |
2212 | class VTSDNode : public SDNode { |
2213 | friend class SelectionDAG; |
2214 | |
2215 | EVT ValueType; |
2216 | |
2217 | explicit VTSDNode(EVT VT) |
2218 | : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)), |
2219 | ValueType(VT) {} |
2220 | |
2221 | public: |
2222 | EVT getVT() const { return ValueType; } |
2223 | |
2224 | static bool classof(const SDNode *N) { |
2225 | return N->getOpcode() == ISD::VALUETYPE; |
2226 | } |
2227 | }; |
2228 | |
2229 | |
2230 | class LSBaseSDNode : public MemSDNode { |
2231 | public: |
2232 | LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, |
2233 | SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT, |
2234 | MachineMemOperand *MMO) |
2235 | : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) { |
2236 | LSBaseSDNodeBits.AddressingMode = AM; |
2237 | assert(getAddressingMode() == AM && "Value truncated"); |
2238 | } |
2239 | |
2240 | const SDValue &getOffset() const { |
2241 | return getOperand(getOpcode() == ISD::LOAD ? 2 : 3); |
2242 | } |
2243 | |
2244 | |
2245 | |
2246 | ISD::MemIndexedMode getAddressingMode() const { |
2247 | return static_cast<ISD::MemIndexedMode>(LSBaseSDNodeBits.AddressingMode); |
2248 | } |
2249 | |
2250 | |
2251 | bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } |
2252 | |
2253 | |
2254 | bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } |
2255 | |
2256 | static bool classof(const SDNode *N) { |
2257 | return N->getOpcode() == ISD::LOAD || |
2258 | N->getOpcode() == ISD::STORE; |
2259 | } |
2260 | }; |
2261 | |
2262 | |
2263 | class LoadSDNode : public LSBaseSDNode { |
2264 | friend class SelectionDAG; |
2265 | |
2266 | LoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2267 | ISD::MemIndexedMode AM, ISD::LoadExtType ETy, EVT MemVT, |
2268 | MachineMemOperand *MMO) |
2269 | : LSBaseSDNode(ISD::LOAD, Order, dl, VTs, AM, MemVT, MMO) { |
2270 | LoadSDNodeBits.ExtTy = ETy; |
2271 | assert(readMem() && "Load MachineMemOperand is not a load!"); |
2272 | assert(!writeMem() && "Load MachineMemOperand is a store!"); |
2273 | } |
2274 | |
2275 | public: |
2276 | |
2277 | |
2278 | ISD::LoadExtType getExtensionType() const { |
2279 | return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy); |
2280 | } |
2281 | |
2282 | const SDValue &getBasePtr() const { return getOperand(1); } |
2283 | const SDValue &getOffset() const { return getOperand(2); } |
2284 | |
2285 | static bool classof(const SDNode *N) { |
2286 | return N->getOpcode() == ISD::LOAD; |
2287 | } |
2288 | }; |
2289 | |
2290 | |
2291 | class StoreSDNode : public LSBaseSDNode { |
2292 | friend class SelectionDAG; |
2293 | |
2294 | StoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2295 | ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT, |
2296 | MachineMemOperand *MMO) |
2297 | : LSBaseSDNode(ISD::STORE, Order, dl, VTs, AM, MemVT, MMO) { |
2298 | StoreSDNodeBits.IsTruncating = isTrunc; |
2299 | assert(!readMem() && "Store MachineMemOperand is a load!"); |
2300 | assert(writeMem() && "Store MachineMemOperand is not a store!"); |
2301 | } |
2302 | |
2303 | public: |
2304 | |
2305 | |
2306 | |
2307 | bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; } |
2308 | void setTruncatingStore(bool Truncating) { |
2309 | StoreSDNodeBits.IsTruncating = Truncating; |
2310 | } |
2311 | |
2312 | const SDValue &getValue() const { return getOperand(1); } |
2313 | const SDValue &getBasePtr() const { return getOperand(2); } |
2314 | const SDValue &getOffset() const { return getOperand(3); } |
2315 | |
2316 | static bool classof(const SDNode *N) { |
2317 | return N->getOpcode() == ISD::STORE; |
2318 | } |
2319 | }; |
2320 | |
2321 | |
2322 | class MaskedLoadStoreSDNode : public MemSDNode { |
2323 | public: |
2324 | friend class SelectionDAG; |
2325 | |
2326 | MaskedLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order, |
2327 | const DebugLoc &dl, SDVTList VTs, |
2328 | ISD::MemIndexedMode AM, EVT MemVT, |
2329 | MachineMemOperand *MMO) |
2330 | : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) { |
2331 | LSBaseSDNodeBits.AddressingMode = AM; |
2332 | assert(getAddressingMode() == AM && "Value truncated"); |
2333 | } |
2334 | |
2335 | |
2336 | |
2337 | |
2338 | const SDValue &getOffset() const { |
2339 | return getOperand(getOpcode() == ISD::MLOAD ? 2 : 3); |
2340 | } |
2341 | const SDValue &getMask() const { |
2342 | return getOperand(getOpcode() == ISD::MLOAD ? 3 : 4); |
2343 | } |
2344 | |
2345 | |
2346 | |
2347 | ISD::MemIndexedMode getAddressingMode() const { |
2348 | return static_cast<ISD::MemIndexedMode>(LSBaseSDNodeBits.AddressingMode); |
2349 | } |
2350 | |
2351 | |
2352 | bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; } |
2353 | |
2354 | |
2355 | bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; } |
2356 | |
2357 | static bool classof(const SDNode *N) { |
2358 | return N->getOpcode() == ISD::MLOAD || |
2359 | N->getOpcode() == ISD::MSTORE; |
2360 | } |
2361 | }; |
2362 | |
2363 | |
2364 | class MaskedLoadSDNode : public MaskedLoadStoreSDNode { |
2365 | public: |
2366 | friend class SelectionDAG; |
2367 | |
2368 | MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2369 | ISD::MemIndexedMode AM, ISD::LoadExtType ETy, |
2370 | bool IsExpanding, EVT MemVT, MachineMemOperand *MMO) |
2371 | : MaskedLoadStoreSDNode(ISD::MLOAD, Order, dl, VTs, AM, MemVT, MMO) { |
2372 | LoadSDNodeBits.ExtTy = ETy; |
2373 | LoadSDNodeBits.IsExpanding = IsExpanding; |
2374 | } |
2375 | |
2376 | ISD::LoadExtType getExtensionType() const { |
2377 | return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy); |
2378 | } |
2379 | |
2380 | const SDValue &getBasePtr() const { return getOperand(1); } |
2381 | const SDValue &getOffset() const { return getOperand(2); } |
2382 | const SDValue &getMask() const { return getOperand(3); } |
2383 | const SDValue &getPassThru() const { return getOperand(4); } |
2384 | |
2385 | static bool classof(const SDNode *N) { |
2386 | return N->getOpcode() == ISD::MLOAD; |
2387 | } |
2388 | |
2389 | bool isExpandingLoad() const { return LoadSDNodeBits.IsExpanding; } |
2390 | }; |
2391 | |
2392 | |
2393 | class MaskedStoreSDNode : public MaskedLoadStoreSDNode { |
2394 | public: |
2395 | friend class SelectionDAG; |
2396 | |
2397 | MaskedStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2398 | ISD::MemIndexedMode AM, bool isTrunc, bool isCompressing, |
2399 | EVT MemVT, MachineMemOperand *MMO) |
2400 | : MaskedLoadStoreSDNode(ISD::MSTORE, Order, dl, VTs, AM, MemVT, MMO) { |
2401 | StoreSDNodeBits.IsTruncating = isTrunc; |
2402 | StoreSDNodeBits.IsCompressing = isCompressing; |
2403 | } |
2404 | |
2405 | |
2406 | |
2407 | |
2408 | bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; } |
2409 | |
2410 | |
2411 | |
2412 | |
2413 | |
2414 | bool isCompressingStore() const { return StoreSDNodeBits.IsCompressing; } |
2415 | |
2416 | const SDValue &getValue() const { return getOperand(1); } |
2417 | const SDValue &getBasePtr() const { return getOperand(2); } |
2418 | const SDValue &getOffset() const { return getOperand(3); } |
2419 | const SDValue &getMask() const { return getOperand(4); } |
2420 | |
2421 | static bool classof(const SDNode *N) { |
2422 | return N->getOpcode() == ISD::MSTORE; |
2423 | } |
2424 | }; |
2425 | |
2426 | |
2427 | |
2428 | |
2429 | class MaskedGatherScatterSDNode : public MemSDNode { |
2430 | public: |
2431 | friend class SelectionDAG; |
2432 | |
2433 | MaskedGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order, |
2434 | const DebugLoc &dl, SDVTList VTs, EVT MemVT, |
2435 | MachineMemOperand *MMO, ISD::MemIndexType IndexType) |
2436 | : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) { |
2437 | LSBaseSDNodeBits.AddressingMode = IndexType; |
2438 | assert(getIndexType() == IndexType && "Value truncated"); |
2439 | } |
2440 | |
2441 | |
2442 | ISD::MemIndexType getIndexType() const { |
2443 | return static_cast<ISD::MemIndexType>(LSBaseSDNodeBits.AddressingMode); |
2444 | } |
2445 | void setIndexType(ISD::MemIndexType IndexType) { |
2446 | LSBaseSDNodeBits.AddressingMode = IndexType; |
2447 | } |
2448 | bool isIndexScaled() const { |
2449 | return (getIndexType() == ISD::SIGNED_SCALED) || |
2450 | (getIndexType() == ISD::UNSIGNED_SCALED); |
2451 | } |
2452 | bool isIndexSigned() const { |
2453 | return (getIndexType() == ISD::SIGNED_SCALED) || |
2454 | (getIndexType() == ISD::SIGNED_UNSCALED); |
2455 | } |
2456 | |
2457 | |
2458 | |
2459 | |
2460 | |
2461 | const SDValue &getBasePtr() const { return getOperand(3); } |
2462 | const SDValue &getIndex() const { return getOperand(4); } |
2463 | const SDValue &getMask() const { return getOperand(2); } |
2464 | const SDValue &getScale() const { return getOperand(5); } |
2465 | |
2466 | static bool classof(const SDNode *N) { |
2467 | return N->getOpcode() == ISD::MGATHER || |
2468 | N->getOpcode() == ISD::MSCATTER; |
2469 | } |
2470 | }; |
2471 | |
2472 | |
2473 | |
2474 | class MaskedGatherSDNode : public MaskedGatherScatterSDNode { |
2475 | public: |
2476 | friend class SelectionDAG; |
2477 | |
2478 | MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2479 | EVT MemVT, MachineMemOperand *MMO, |
2480 | ISD::MemIndexType IndexType, ISD::LoadExtType ETy) |
2481 | : MaskedGatherScatterSDNode(ISD::MGATHER, Order, dl, VTs, MemVT, MMO, |
2482 | IndexType) { |
2483 | LoadSDNodeBits.ExtTy = ETy; |
2484 | } |
2485 | |
2486 | const SDValue &getPassThru() const { return getOperand(1); } |
2487 | |
2488 | ISD::LoadExtType getExtensionType() const { |
2489 | return ISD::LoadExtType(LoadSDNodeBits.ExtTy); |
2490 | } |
2491 | |
2492 | static bool classof(const SDNode *N) { |
2493 | return N->getOpcode() == ISD::MGATHER; |
2494 | } |
2495 | }; |
2496 | |
2497 | |
2498 | |
2499 | class MaskedScatterSDNode : public MaskedGatherScatterSDNode { |
2500 | public: |
2501 | friend class SelectionDAG; |
2502 | |
2503 | MaskedScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, |
2504 | EVT MemVT, MachineMemOperand *MMO, |
2505 | ISD::MemIndexType IndexType, bool IsTrunc) |
2506 | : MaskedGatherScatterSDNode(ISD::MSCATTER, Order, dl, VTs, MemVT, MMO, |
2507 | IndexType) { |
2508 | StoreSDNodeBits.IsTruncating = IsTrunc; |
2509 | } |
2510 | |
2511 | |
2512 | |
2513 | |
2514 | bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; } |
2515 | |
2516 | const SDValue &getValue() const { return getOperand(1); } |
2517 | |
2518 | static bool classof(const SDNode *N) { |
2519 | return N->getOpcode() == ISD::MSCATTER; |
2520 | } |
2521 | }; |
2522 | |
2523 | |
2524 | |
2525 | |
2526 | |
2527 | |
2528 | |
2529 | |
2530 | class MachineSDNode : public SDNode { |
2531 | private: |
2532 | friend class SelectionDAG; |
2533 | |
2534 | MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, SDVTList VTs) |
2535 | : SDNode(Opc, Order, DL, VTs) {} |
2536 | |
2537 | |
2538 | |
2539 | |
2540 | |
2541 | |
2542 | |
2543 | |
2544 | |
2545 | |
2546 | |
2547 | |
2548 | |
2549 | |
2550 | |
2551 | PointerUnion<MachineMemOperand *, MachineMemOperand **> MemRefs = {}; |
2552 | |
2553 | |
2554 | |
2555 | |
2556 | |
2557 | int NumMemRefs = 0; |
2558 | |
2559 | public: |
2560 | using mmo_iterator = ArrayRef<MachineMemOperand *>::const_iterator; |
2561 | |
2562 | ArrayRef<MachineMemOperand *> memoperands() const { |
2563 | |
2564 | if (NumMemRefs == 0) |
2565 | return {}; |
2566 | if (NumMemRefs == 1) |
2567 | return makeArrayRef(MemRefs.getAddrOfPtr1(), 1); |
2568 | |
2569 | |
2570 | return makeArrayRef(MemRefs.get<MachineMemOperand **>(), NumMemRefs); |
2571 | } |
2572 | mmo_iterator memoperands_begin() const { return memoperands().begin(); } |
2573 | mmo_iterator memoperands_end() const { return memoperands().end(); } |
2574 | bool memoperands_empty() const { return memoperands().empty(); } |
2575 | |
2576 | |
2577 | void clearMemRefs() { |
2578 | MemRefs = nullptr; |
2579 | NumMemRefs = 0; |
2580 | } |
2581 | |
2582 | static bool classof(const SDNode *N) { |
2583 | return N->isMachineOpcode(); |
2584 | } |
2585 | }; |
2586 | |
2587 | |
2588 | |
2589 | class AssertAlignSDNode : public SDNode { |
2590 | Align Alignment; |
2591 | |
2592 | public: |
2593 | AssertAlignSDNode(unsigned Order, const DebugLoc &DL, EVT VT, Align A) |
2594 | : SDNode(ISD::AssertAlign, Order, DL, getSDVTList(VT)), Alignment(A) {} |
2595 | |
2596 | Align getAlign() const { return Alignment; } |
2597 | |
2598 | static bool classof(const SDNode *N) { |
2599 | return N->getOpcode() == ISD::AssertAlign; |
2600 | } |
2601 | }; |
2602 | |
2603 | class SDNodeIterator { |
2604 | const SDNode *Node; |
2605 | unsigned Operand; |
2606 | |
2607 | SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {} |
2608 | |
2609 | public: |
2610 | using iterator_category = std::forward_iterator_tag; |
2611 | using value_type = SDNode; |
2612 | using difference_type = std::ptrdiff_t; |
2613 | using pointer = value_type *; |
2614 | using reference = value_type &; |
2615 | |
2616 | bool operator==(const SDNodeIterator& x) const { |
2617 | return Operand == x.Operand; |
2618 | } |
2619 | bool operator!=(const SDNodeIterator& x) const { return !operator==(x); } |
2620 | |
2621 | pointer operator*() const { |
2622 | return Node->getOperand(Operand).getNode(); |
2623 | } |
2624 | pointer operator->() const { return operator*(); } |
2625 | |
2626 | SDNodeIterator& operator++() { |
2627 | ++Operand; |
2628 | return *this; |
2629 | } |
2630 | SDNodeIterator operator++(int) { |
2631 | SDNodeIterator tmp = *this; ++*this; return tmp; |
2632 | } |
2633 | size_t operator-(SDNodeIterator Other) const { |
2634 | assert(Node == Other.Node && |
2635 | "Cannot compare iterators of two different nodes!"); |
2636 | return Operand - Other.Operand; |
2637 | } |
2638 | |
2639 | static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); } |
2640 | static SDNodeIterator end (const SDNode *N) { |
2641 | return SDNodeIterator(N, N->getNumOperands()); |
2642 | } |
2643 | |
2644 | unsigned getOperand() const { return Operand; } |
2645 | const SDNode *getNode() const { return Node; } |
2646 | }; |
2647 | |
2648 | template <> struct GraphTraits<SDNode*> { |
2649 | using NodeRef = SDNode *; |
2650 | using ChildIteratorType = SDNodeIterator; |
2651 | |
2652 | static NodeRef getEntryNode(SDNode *N) { return N; } |
2653 | |
2654 | static ChildIteratorType child_begin(NodeRef N) { |
2655 | return SDNodeIterator::begin(N); |
2656 | } |
2657 | |
2658 | static ChildIteratorType child_end(NodeRef N) { |
2659 | return SDNodeIterator::end(N); |
2660 | } |
2661 | }; |
2662 | |
2663 | |
2664 | |
2665 | |
2666 | |
2667 | using LargestSDNode = AlignedCharArrayUnion<AtomicSDNode, TargetIndexSDNode, |
2668 | BlockAddressSDNode, |
2669 | GlobalAddressSDNode, |
2670 | PseudoProbeSDNode>; |
2671 | |
2672 | |
2673 | using MostAlignedSDNode = GlobalAddressSDNode; |
2674 | |
2675 | namespace ISD { |
2676 | |
2677 | |
2678 | inline bool isNormalLoad(const SDNode *N) { |
2679 | const LoadSDNode *Ld = dyn_cast<LoadSDNode>(N); |
2680 | return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD && |
2681 | Ld->getAddressingMode() == ISD::UNINDEXED; |
2682 | } |
2683 | |
2684 | |
2685 | inline bool isNON_EXTLoad(const SDNode *N) { |
2686 | return isa<LoadSDNode>(N) && |
2687 | cast<LoadSDNode>(N)->getExtensionType() == ISD::NON_EXTLOAD; |
2688 | } |
2689 | |
2690 | |
2691 | inline bool isEXTLoad(const SDNode *N) { |
2692 | return isa<LoadSDNode>(N) && |
2693 | cast<LoadSDNode>(N)->getExtensionType() == ISD::EXTLOAD; |
2694 | } |
2695 | |
2696 | |
2697 | inline bool isSEXTLoad(const SDNode *N) { |
2698 | return isa<LoadSDNode>(N) && |
2699 | cast<LoadSDNode>(N)->getExtensionType() == ISD::SEXTLOAD; |
2700 | } |
2701 | |
2702 | |
2703 | inline bool isZEXTLoad(const SDNode *N) { |
2704 | return isa<LoadSDNode>(N) && |
2705 | cast<LoadSDNode>(N)->getExtensionType() == ISD::ZEXTLOAD; |
2706 | } |
2707 | |
2708 | |
2709 | inline bool isUNINDEXEDLoad(const SDNode *N) { |
2710 | return isa<LoadSDNode>(N) && |
2711 | cast<LoadSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; |
2712 | } |
2713 | |
2714 | |
2715 | |
2716 | inline bool isNormalStore(const SDNode *N) { |
2717 | const StoreSDNode *St = dyn_cast<StoreSDNode>(N); |
2718 | return St && !St->isTruncatingStore() && |
2719 | St->getAddressingMode() == ISD::UNINDEXED; |
2720 | } |
2721 | |
2722 | |
2723 | inline bool isUNINDEXEDStore(const SDNode *N) { |
2724 | return isa<StoreSDNode>(N) && |
2725 | cast<StoreSDNode>(N)->getAddressingMode() == ISD::UNINDEXED; |
2726 | } |
2727 | |
2728 | |
2729 | |
2730 | |
2731 | bool matchUnaryPredicate(SDValue Op, |
2732 | std::function<bool(ConstantSDNode *)> Match, |
2733 | bool AllowUndefs = false); |
2734 | |
2735 | |
2736 | |
2737 | |
2738 | |
2739 | bool matchBinaryPredicate( |
2740 | SDValue LHS, SDValue RHS, |
2741 | std::function<bool(ConstantSDNode *, ConstantSDNode *)> Match, |
2742 | bool AllowUndefs = false, bool AllowTypeMismatch = false); |
2743 | |
2744 | |
2745 | |
2746 | inline bool isOverflowIntrOpRes(SDValue Op) { |
2747 | unsigned Opc = Op.getOpcode(); |
2748 | return (Op.getResNo() == 1 && |
2749 | (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO || |
2750 | Opc == ISD::USUBO || Opc == ISD::SMULO || Opc == ISD::UMULO)); |
2751 | } |
2752 | |
2753 | } |
2754 | |
2755 | } |
2756 | |
2757 | #endif // LLVM_CODEGEN_SELECTIONDAGNODES_H |