LLVM 20.0.0git
SelectionDAG.h
Go to the documentation of this file.
1//===- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the SelectionDAG class, and transitively defines the
10// SDNode class and subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_SELECTIONDAG_H
15#define LLVM_CODEGEN_SELECTIONDAG_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/StringMap.h"
23#include "llvm/ADT/ilist.h"
24#include "llvm/ADT/iterator.h"
35#include "llvm/IR/DebugLoc.h"
36#include "llvm/IR/Metadata.h"
43#include <cassert>
44#include <cstdint>
45#include <functional>
46#include <map>
47#include <set>
48#include <string>
49#include <tuple>
50#include <utility>
51#include <vector>
52
53namespace llvm {
54
55class DIExpression;
56class DILabel;
57class DIVariable;
58class Function;
59class Pass;
60class Type;
61template <class GraphType> struct GraphTraits;
62template <typename T, unsigned int N> class SmallSetVector;
63template <typename T, typename Enable> struct FoldingSetTrait;
64class AAResults;
65class BlockAddress;
66class BlockFrequencyInfo;
67class Constant;
68class ConstantFP;
69class ConstantInt;
70class DataLayout;
71struct fltSemantics;
72class FunctionLoweringInfo;
73class FunctionVarLocs;
74class GlobalValue;
75struct KnownBits;
76class LLVMContext;
77class MachineBasicBlock;
78class MachineConstantPoolValue;
79class MachineModuleInfo;
80class MCSymbol;
81class OptimizationRemarkEmitter;
82class ProfileSummaryInfo;
83class SDDbgValue;
84class SDDbgOperand;
85class SDDbgLabel;
86class SelectionDAG;
87class SelectionDAGTargetInfo;
88class TargetLibraryInfo;
89class TargetLowering;
90class TargetMachine;
91class TargetSubtargetInfo;
92class Value;
93
94template <typename T> class GenericSSAContext;
95using SSAContext = GenericSSAContext<Function>;
96template <typename T> class GenericUniformityInfo;
97using UniformityInfo = GenericUniformityInfo<SSAContext>;
98
100 friend struct FoldingSetTrait<SDVTListNode>;
101
102 /// A reference to an Interned FoldingSetNodeID for this node.
103 /// The Allocator in SelectionDAG holds the data.
104 /// SDVTList contains all types which are frequently accessed in SelectionDAG.
105 /// The size of this list is not expected to be big so it won't introduce
106 /// a memory penalty.
107 FoldingSetNodeIDRef FastID;
108 const EVT *VTs;
109 unsigned int NumVTs;
110 /// The hash value for SDVTList is fixed, so cache it to avoid
111 /// hash calculation.
112 unsigned HashValue;
113
114public:
115 SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) :
116 FastID(ID), VTs(VT), NumVTs(Num) {
117 HashValue = ID.ComputeHash();
118 }
119
121 SDVTList result = {VTs, NumVTs};
122 return result;
123 }
124};
125
126/// Specialize FoldingSetTrait for SDVTListNode
127/// to avoid computing temp FoldingSetNodeID and hash value.
128template<> struct FoldingSetTrait<SDVTListNode> : DefaultFoldingSetTrait<SDVTListNode> {
129 static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) {
130 ID = X.FastID;
131 }
132
133 static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID,
134 unsigned IDHash, FoldingSetNodeID &TempID) {
135 if (X.HashValue != IDHash)
136 return false;
137 return ID == X.FastID;
138 }
139
140 static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) {
141 return X.HashValue;
142 }
143};
144
145template <> struct ilist_alloc_traits<SDNode> {
146 static void deleteNode(SDNode *) {
147 llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!");
148 }
149};
150
151/// Keeps track of dbg_value information through SDISel. We do
152/// not build SDNodes for these so as not to perturb the generated code;
153/// instead the info is kept off to the side in this structure. Each SDNode may
154/// have one or more associated dbg_value entries. This information is kept in
155/// DbgValMap.
156/// Byval parameters are handled separately because they don't use alloca's,
157/// which busts the normal mechanism. There is good reason for handling all
158/// parameters separately: they may not have code generated for them, they
159/// should always go at the beginning of the function regardless of other code
160/// motion, and debug info for them is potentially useful even if the parameter
161/// is unused. Right now only byval parameters are handled separately.
163 BumpPtrAllocator Alloc;
165 SmallVector<SDDbgValue*, 32> ByvalParmDbgValues;
168 DbgValMapType DbgValMap;
169
170public:
171 SDDbgInfo() = default;
172 SDDbgInfo(const SDDbgInfo &) = delete;
173 SDDbgInfo &operator=(const SDDbgInfo &) = delete;
174
175 void add(SDDbgValue *V, bool isParameter);
176
177 void add(SDDbgLabel *L) { DbgLabels.push_back(L); }
178
179 /// Invalidate all DbgValues attached to the node and remove
180 /// it from the Node-to-DbgValues map.
181 void erase(const SDNode *Node);
182
183 void clear() {
184 DbgValMap.clear();
185 DbgValues.clear();
186 ByvalParmDbgValues.clear();
187 DbgLabels.clear();
188 Alloc.Reset();
189 }
190
191 BumpPtrAllocator &getAlloc() { return Alloc; }
192
193 bool empty() const {
194 return DbgValues.empty() && ByvalParmDbgValues.empty() && DbgLabels.empty();
195 }
196
198 auto I = DbgValMap.find(Node);
199 if (I != DbgValMap.end())
200 return I->second;
201 return ArrayRef<SDDbgValue*>();
202 }
203
206
207 DbgIterator DbgBegin() { return DbgValues.begin(); }
208 DbgIterator DbgEnd() { return DbgValues.end(); }
209 DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
210 DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
211 DbgLabelIterator DbgLabelBegin() { return DbgLabels.begin(); }
212 DbgLabelIterator DbgLabelEnd() { return DbgLabels.end(); }
213};
214
215void checkForCycles(const SelectionDAG *DAG, bool force = false);
216
217/// This is used to represent a portion of an LLVM function in a low-level
218/// Data Dependence DAG representation suitable for instruction selection.
219/// This DAG is constructed as the first step of instruction selection in order
220/// to allow implementation of machine specific optimizations
221/// and code simplifications.
222///
223/// The representation used by the SelectionDAG is a target-independent
224/// representation, which has some similarities to the GCC RTL representation,
225/// but is significantly more simple, powerful, and is a graph form instead of a
226/// linear form.
227///
229 const TargetMachine &TM;
230 const SelectionDAGTargetInfo *TSI = nullptr;
231 const TargetLowering *TLI = nullptr;
232 const TargetLibraryInfo *LibInfo = nullptr;
233 const FunctionVarLocs *FnVarLocs = nullptr;
234 MachineFunction *MF;
235 MachineFunctionAnalysisManager *MFAM = nullptr;
236 Pass *SDAGISelPass = nullptr;
237 LLVMContext *Context;
238 CodeGenOptLevel OptLevel;
239
240 UniformityInfo *UA = nullptr;
241 FunctionLoweringInfo * FLI = nullptr;
242
243 /// The function-level optimization remark emitter. Used to emit remarks
244 /// whenever manipulating the DAG.
246
247 ProfileSummaryInfo *PSI = nullptr;
248 BlockFrequencyInfo *BFI = nullptr;
249 MachineModuleInfo *MMI = nullptr;
250
251 /// Extended EVTs used for single value VTLists.
252 std::set<EVT, EVT::compareRawBits> EVTs;
253
254 /// List of non-single value types.
255 FoldingSet<SDVTListNode> VTListMap;
256
257 /// Pool allocation for misc. objects that are created once per SelectionDAG.
258 BumpPtrAllocator Allocator;
259
260 /// The starting token.
261 SDNode EntryNode;
262
263 /// The root of the entire DAG.
264 SDValue Root;
265
266 /// A linked list of nodes in the current DAG.
267 ilist<SDNode> AllNodes;
268
269 /// The AllocatorType for allocating SDNodes. We use
270 /// pool allocation with recycling.
272 sizeof(LargestSDNode),
273 alignof(MostAlignedSDNode)>;
274
275 /// Pool allocation for nodes.
276 NodeAllocatorType NodeAllocator;
277
278 /// This structure is used to memoize nodes, automatically performing
279 /// CSE with existing nodes when a duplicate is requested.
280 FoldingSet<SDNode> CSEMap;
281
282 /// Pool allocation for machine-opcode SDNode operands.
283 BumpPtrAllocator OperandAllocator;
284 ArrayRecycler<SDUse> OperandRecycler;
285
286 /// Tracks dbg_value and dbg_label information through SDISel.
287 SDDbgInfo *DbgInfo;
288
290
291 struct NodeExtraInfo {
292 CallSiteInfo CSInfo;
293 MDNode *HeapAllocSite = nullptr;
294 MDNode *PCSections = nullptr;
295 MDNode *MMRA = nullptr;
296 bool NoMerge = false;
297 };
298 /// Out-of-line extra information for SDNodes.
300
301 /// PersistentId counter to be used when inserting the next
302 /// SDNode to this SelectionDAG. We do not place that under
303 /// `#if LLVM_ENABLE_ABI_BREAKING_CHECKS` intentionally because
304 /// it adds unneeded complexity without noticeable
305 /// benefits (see discussion with @thakis in D120714).
306 uint16_t NextPersistentId = 0;
307
308public:
309 /// Clients of various APIs that cause global effects on
310 /// the DAG can optionally implement this interface. This allows the clients
311 /// to handle the various sorts of updates that happen.
312 ///
313 /// A DAGUpdateListener automatically registers itself with DAG when it is
314 /// constructed, and removes itself when destroyed in RAII fashion.
318
320 : Next(D.UpdateListeners), DAG(D) {
321 DAG.UpdateListeners = this;
322 }
323
325 assert(DAG.UpdateListeners == this &&
326 "DAGUpdateListeners must be destroyed in LIFO order");
327 DAG.UpdateListeners = Next;
328 }
329
330 /// The node N that was deleted and, if E is not null, an
331 /// equivalent node E that replaced it.
332 virtual void NodeDeleted(SDNode *N, SDNode *E);
333
334 /// The node N that was updated.
335 virtual void NodeUpdated(SDNode *N);
336
337 /// The node N that was inserted.
338 virtual void NodeInserted(SDNode *N);
339 };
340
342 std::function<void(SDNode *, SDNode *)> Callback;
343
345 std::function<void(SDNode *, SDNode *)> Callback)
347
348 void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); }
349
350 private:
351 virtual void anchor();
352 };
353
355 std::function<void(SDNode *)> Callback;
356
358 std::function<void(SDNode *)> Callback)
360
361 void NodeInserted(SDNode *N) override { Callback(N); }
362
363 private:
364 virtual void anchor();
365 };
366
367 /// Help to insert SDNodeFlags automatically in transforming. Use
368 /// RAII to save and resume flags in current scope.
370 SelectionDAG &DAG;
371 SDNodeFlags Flags;
372 FlagInserter *LastInserter;
373
374 public:
376 : DAG(SDAG), Flags(Flags),
377 LastInserter(SDAG.getFlagInserter()) {
378 SDAG.setFlagInserter(this);
379 }
381 : FlagInserter(SDAG, N->getFlags()) {}
382
383 FlagInserter(const FlagInserter &) = delete;
385 ~FlagInserter() { DAG.setFlagInserter(LastInserter); }
386
387 SDNodeFlags getFlags() const { return Flags; }
388 };
389
390 /// When true, additional steps are taken to
391 /// ensure that getConstant() and similar functions return DAG nodes that
392 /// have legal types. This is important after type legalization since
393 /// any illegally typed nodes generated after this point will not experience
394 /// type legalization.
396
397private:
398 /// DAGUpdateListener is a friend so it can manipulate the listener stack.
399 friend struct DAGUpdateListener;
400
401 /// Linked list of registered DAGUpdateListener instances.
402 /// This stack is maintained by DAGUpdateListener RAII.
403 DAGUpdateListener *UpdateListeners = nullptr;
404
405 /// Implementation of setSubgraphColor.
406 /// Return whether we had to truncate the search.
407 bool setSubgraphColorHelper(SDNode *N, const char *Color,
408 DenseSet<SDNode *> &visited,
409 int level, bool &printed);
410
411 template <typename SDNodeT, typename... ArgTypes>
412 SDNodeT *newSDNode(ArgTypes &&... Args) {
413 return new (NodeAllocator.template Allocate<SDNodeT>())
414 SDNodeT(std::forward<ArgTypes>(Args)...);
415 }
416
417 /// Build a synthetic SDNodeT with the given args and extract its subclass
418 /// data as an integer (e.g. for use in a folding set).
419 ///
420 /// The args to this function are the same as the args to SDNodeT's
421 /// constructor, except the second arg (assumed to be a const DebugLoc&) is
422 /// omitted.
423 template <typename SDNodeT, typename... ArgTypes>
424 static uint16_t getSyntheticNodeSubclassData(unsigned IROrder,
425 ArgTypes &&... Args) {
426 // The compiler can reduce this expression to a constant iff we pass an
427 // empty DebugLoc. Thankfully, the debug location doesn't have any bearing
428 // on the subclass data.
429 return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...)
430 .getRawSubclassData();
431 }
432
433 template <typename SDNodeTy>
434 static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order,
435 SDVTList VTs, EVT MemoryVT,
436 MachineMemOperand *MMO) {
437 return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO)
438 .getRawSubclassData();
439 }
440
441 void createOperands(SDNode *Node, ArrayRef<SDValue> Vals);
442
443 void removeOperands(SDNode *Node) {
444 if (!Node->OperandList)
445 return;
446 OperandRecycler.deallocate(
448 Node->OperandList);
449 Node->NumOperands = 0;
450 Node->OperandList = nullptr;
451 }
452 void CreateTopologicalOrder(std::vector<SDNode*>& Order);
453
454public:
455 // Maximum depth for recursive analysis such as computeKnownBits, etc.
456 static constexpr unsigned MaxRecursionDepth = 6;
457
458 // Returns the maximum steps for SDNode->hasPredecessor() like searches.
459 static unsigned getHasPredecessorMaxSteps();
460
461 explicit SelectionDAG(const TargetMachine &TM, CodeGenOptLevel);
462 SelectionDAG(const SelectionDAG &) = delete;
465
466 /// Prepare this SelectionDAG to process code in the given MachineFunction.
468 Pass *PassPtr, const TargetLibraryInfo *LibraryInfo,
471 FunctionVarLocs const *FnVarLocs);
472
475 const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA,
477 MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs) {
478 init(NewMF, NewORE, nullptr, LibraryInfo, UA, PSIin, BFIin, MMI, FnVarLocs);
479 MFAM = &AM;
480 }
481
483 FLI = FuncInfo;
484 }
485
486 /// Clear state and free memory necessary to make this
487 /// SelectionDAG ready to process a new block.
488 void clear();
489
490 MachineFunction &getMachineFunction() const { return *MF; }
491 const Pass *getPass() const { return SDAGISelPass; }
493
494 CodeGenOptLevel getOptLevel() const { return OptLevel; }
495 const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
496 const TargetMachine &getTarget() const { return TM; }
497 const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
498 template <typename STC> const STC &getSubtarget() const {
499 return MF->getSubtarget<STC>();
500 }
501 const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
502 const TargetLibraryInfo &getLibInfo() const { return *LibInfo; }
503 const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; }
504 const UniformityInfo *getUniformityInfo() const { return UA; }
505 /// Returns the result of the AssignmentTrackingAnalysis pass if it's
506 /// available, otherwise return nullptr.
507 const FunctionVarLocs *getFunctionVarLocs() const { return FnVarLocs; }
508 LLVMContext *getContext() const { return Context; }
509 OptimizationRemarkEmitter &getORE() const { return *ORE; }
510 ProfileSummaryInfo *getPSI() const { return PSI; }
511 BlockFrequencyInfo *getBFI() const { return BFI; }
512 MachineModuleInfo *getMMI() const { return MMI; }
513
514 FlagInserter *getFlagInserter() { return Inserter; }
515 void setFlagInserter(FlagInserter *FI) { Inserter = FI; }
516
517 /// Just dump dot graph to a user-provided path and title.
518 /// This doesn't open the dot viewer program and
519 /// helps visualization when outside debugging session.
520 /// FileName expects absolute path. If provided
521 /// without any path separators then the file
522 /// will be created in the current directory.
523 /// Error will be emitted if the path is insane.
524#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
525 LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title);
526#endif
527
528 /// Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
529 void viewGraph(const std::string &Title);
530 void viewGraph();
531
532#if LLVM_ENABLE_ABI_BREAKING_CHECKS
533 std::map<const SDNode *, std::string> NodeGraphAttrs;
534#endif
535
536 /// Clear all previously defined node graph attributes.
537 /// Intended to be used from a debugging tool (eg. gdb).
538 void clearGraphAttrs();
539
540 /// Set graph attributes for a node. (eg. "color=red".)
541 void setGraphAttrs(const SDNode *N, const char *Attrs);
542
543 /// Get graph attributes for a node. (eg. "color=red".)
544 /// Used from getNodeAttributes.
545 std::string getGraphAttrs(const SDNode *N) const;
546
547 /// Convenience for setting node color attribute.
548 void setGraphColor(const SDNode *N, const char *Color);
549
550 /// Convenience for setting subgraph color attribute.
551 void setSubgraphColor(SDNode *N, const char *Color);
552
554
555 allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
556 allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
557
559
560 allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
561 allnodes_iterator allnodes_end() { return AllNodes.end(); }
562
564 return AllNodes.size();
565 }
566
569 }
572 }
573
574 /// Return the root tag of the SelectionDAG.
575 const SDValue &getRoot() const { return Root; }
576
577 /// Return the token chain corresponding to the entry of the function.
579 return SDValue(const_cast<SDNode *>(&EntryNode), 0);
580 }
581
582 /// Set the current root tag of the SelectionDAG.
583 ///
585 assert((!N.getNode() || N.getValueType() == MVT::Other) &&
586 "DAG root value is not a chain!");
587 if (N.getNode())
588 checkForCycles(N.getNode(), this);
589 Root = N;
590 if (N.getNode())
591 checkForCycles(this);
592 return Root;
593 }
594
595#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
596 void VerifyDAGDivergence();
597#endif
598
599 /// This iterates over the nodes in the SelectionDAG, folding
600 /// certain types of nodes together, or eliminating superfluous nodes. The
601 /// Level argument controls whether Combine is allowed to produce nodes and
602 /// types that are illegal on the target.
603 void Combine(CombineLevel Level, AAResults *AA, CodeGenOptLevel OptLevel);
604
605 /// This transforms the SelectionDAG into a SelectionDAG that
606 /// only uses types natively supported by the target.
607 /// Returns "true" if it made any changes.
608 ///
609 /// Note that this is an involved process that may invalidate pointers into
610 /// the graph.
611 bool LegalizeTypes();
612
613 /// This transforms the SelectionDAG into a SelectionDAG that is
614 /// compatible with the target instruction selector, as indicated by the
615 /// TargetLowering object.
616 ///
617 /// Note that this is an involved process that may invalidate pointers into
618 /// the graph.
619 void Legalize();
620
621 /// Transforms a SelectionDAG node and any operands to it into a node
622 /// that is compatible with the target instruction selector, as indicated by
623 /// the TargetLowering object.
624 ///
625 /// \returns true if \c N is a valid, legal node after calling this.
626 ///
627 /// This essentially runs a single recursive walk of the \c Legalize process
628 /// over the given node (and its operands). This can be used to incrementally
629 /// legalize the DAG. All of the nodes which are directly replaced,
630 /// potentially including N, are added to the output parameter \c
631 /// UpdatedNodes so that the delta to the DAG can be understood by the
632 /// caller.
633 ///
634 /// When this returns false, N has been legalized in a way that make the
635 /// pointer passed in no longer valid. It may have even been deleted from the
636 /// DAG, and so it shouldn't be used further. When this returns true, the
637 /// N passed in is a legal node, and can be immediately processed as such.
638 /// This may still have done some work on the DAG, and will still populate
639 /// UpdatedNodes with any new nodes replacing those originally in the DAG.
640 bool LegalizeOp(SDNode *N, SmallSetVector<SDNode *, 16> &UpdatedNodes);
641
642 /// This transforms the SelectionDAG into a SelectionDAG
643 /// that only uses vector math operations supported by the target. This is
644 /// necessary as a separate step from Legalize because unrolling a vector
645 /// operation can introduce illegal types, which requires running
646 /// LegalizeTypes again.
647 ///
648 /// This returns true if it made any changes; in that case, LegalizeTypes
649 /// is called again before Legalize.
650 ///
651 /// Note that this is an involved process that may invalidate pointers into
652 /// the graph.
653 bool LegalizeVectors();
654
655 /// This method deletes all unreachable nodes in the SelectionDAG.
656 void RemoveDeadNodes();
657
658 /// Remove the specified node from the system. This node must
659 /// have no referrers.
660 void DeleteNode(SDNode *N);
661
662 /// Return an SDVTList that represents the list of values specified.
664 SDVTList getVTList(EVT VT1, EVT VT2);
665 SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
666 SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
668
669 //===--------------------------------------------------------------------===//
670 // Node creation methods.
671
672 /// Create a ConstantSDNode wrapping a constant value.
673 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
674 ///
675 /// If only legal types can be produced, this does the necessary
676 /// transformations (e.g., if the vector element type is illegal).
677 /// @{
678 SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT,
679 bool isTarget = false, bool isOpaque = false);
680 SDValue getConstant(const APInt &Val, const SDLoc &DL, EVT VT,
681 bool isTarget = false, bool isOpaque = false);
682
683 SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT,
684 bool isTarget = false, bool isOpaque = false);
685
686 SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget = false,
687 bool IsOpaque = false);
688
689 SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
690 bool isTarget = false, bool isOpaque = false);
692 bool isTarget = false);
694 SDValue getShiftAmountConstant(const APInt &Val, EVT VT, const SDLoc &DL);
696 bool isTarget = false);
697
699 bool isOpaque = false) {
700 return getConstant(Val, DL, VT, true, isOpaque);
701 }
702 SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT,
703 bool isOpaque = false) {
704 return getConstant(Val, DL, VT, true, isOpaque);
705 }
707 bool isOpaque = false) {
708 return getConstant(Val, DL, VT, true, isOpaque);
709 }
710 SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT,
711 bool isOpaque = false) {
712 return getSignedConstant(Val, DL, VT, true, isOpaque);
713 }
714
715 /// Create a true or false constant of type \p VT using the target's
716 /// BooleanContent for type \p OpVT.
717 SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT);
718 /// @}
719
720 /// Create a ConstantFPSDNode wrapping a constant value.
721 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
722 ///
723 /// If only legal types can be produced, this does the necessary
724 /// transformations (e.g., if the vector element type is illegal).
725 /// The forms that take a double should only be used for simple constants
726 /// that can be exactly represented in VT. No checks are made.
727 /// @{
728 SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT,
729 bool isTarget = false);
730 SDValue getConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT,
731 bool isTarget = false);
732 SDValue getConstantFP(const ConstantFP &V, const SDLoc &DL, EVT VT,
733 bool isTarget = false);
734 SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT) {
735 return getConstantFP(Val, DL, VT, true);
736 }
737 SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT) {
738 return getConstantFP(Val, DL, VT, true);
739 }
741 return getConstantFP(Val, DL, VT, true);
742 }
743 /// @}
744
745 SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT,
746 int64_t offset = 0, bool isTargetGA = false,
747 unsigned TargetFlags = 0);
749 int64_t offset = 0, unsigned TargetFlags = 0) {
750 return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags);
751 }
752 SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
754 return getFrameIndex(FI, VT, true);
755 }
756 SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
757 unsigned TargetFlags = 0);
758 SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags = 0) {
759 return getJumpTable(JTI, VT, true, TargetFlags);
760 }
761 SDValue getJumpTableDebugInfo(int JTI, SDValue Chain, const SDLoc &DL);
763 MaybeAlign Align = std::nullopt, int Offs = 0,
764 bool isT = false, unsigned TargetFlags = 0);
766 MaybeAlign Align = std::nullopt, int Offset = 0,
767 unsigned TargetFlags = 0) {
768 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
769 }
771 MaybeAlign Align = std::nullopt, int Offs = 0,
772 bool isT = false, unsigned TargetFlags = 0);
774 MaybeAlign Align = std::nullopt, int Offset = 0,
775 unsigned TargetFlags = 0) {
776 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
777 }
778 // When generating a branch to a BB, we don't in general know enough
779 // to provide debug info for the BB at that time, so keep this one around.
781 SDValue getExternalSymbol(const char *Sym, EVT VT);
782 SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
783 unsigned TargetFlags = 0);
785
788 SDValue getRegisterMask(const uint32_t *RegMask);
789 SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label);
790 SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root,
791 MCSymbol *Label);
792 SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset = 0,
793 bool isTarget = false, unsigned TargetFlags = 0);
795 int64_t Offset = 0, unsigned TargetFlags = 0) {
796 return getBlockAddress(BA, VT, Offset, true, TargetFlags);
797 }
798
800 SDValue N) {
801 return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
802 getRegister(Reg, N.getValueType()), N);
803 }
804
805 // This version of the getCopyToReg method takes an extra operand, which
806 // indicates that there is potentially an incoming glue value (if Glue is not
807 // null) and that there should be a glue result.
809 SDValue Glue) {
810 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
811 SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
812 return getNode(ISD::CopyToReg, dl, VTs,
813 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
814 }
815
816 // Similar to last getCopyToReg() except parameter Reg is a SDValue
818 SDValue Glue) {
819 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
820 SDValue Ops[] = { Chain, Reg, N, Glue };
821 return getNode(ISD::CopyToReg, dl, VTs,
822 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
823 }
824
826 SDVTList VTs = getVTList(VT, MVT::Other);
827 SDValue Ops[] = { Chain, getRegister(Reg, VT) };
828 return getNode(ISD::CopyFromReg, dl, VTs, Ops);
829 }
830
831 // This version of the getCopyFromReg method takes an extra operand, which
832 // indicates that there is potentially an incoming glue value (if Glue is not
833 // null) and that there should be a glue result.
835 SDValue Glue) {
836 SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
837 SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
838 return getNode(ISD::CopyFromReg, dl, VTs,
839 ArrayRef(Ops, Glue.getNode() ? 3 : 2));
840 }
841
843
844 /// Return an ISD::VECTOR_SHUFFLE node. The number of elements in VT,
845 /// which must be a vector type, must match the number of mask elements
846 /// NumElts. An integer mask element equal to -1 is treated as undefined.
847 SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2,
848 ArrayRef<int> Mask);
849
850 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
851 /// which must be a vector type, must match the number of operands in Ops.
852 /// The operands must have the same type as (or, for integers, a type wider
853 /// than) VT's element type.
855 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
856 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
857 }
858
859 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
860 /// which must be a vector type, must match the number of operands in Ops.
861 /// The operands must have the same type as (or, for integers, a type wider
862 /// than) VT's element type.
864 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
865 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
866 }
867
868 /// Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all
869 /// elements. VT must be a vector type. Op's type must be the same as (or,
870 /// for integers, a type wider than) VT's element type.
872 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
873 if (Op.getOpcode() == ISD::UNDEF) {
874 assert((VT.getVectorElementType() == Op.getValueType() ||
875 (VT.isInteger() &&
876 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
877 "A splatted value must have a width equal or (for integers) "
878 "greater than the vector element type!");
879 return getNode(ISD::UNDEF, SDLoc(), VT);
880 }
881
883 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
884 }
885
886 // Return a splat ISD::SPLAT_VECTOR node, consisting of Op splatted to all
887 // elements.
889 if (Op.getOpcode() == ISD::UNDEF) {
890 assert((VT.getVectorElementType() == Op.getValueType() ||
891 (VT.isInteger() &&
892 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
893 "A splatted value must have a width equal or (for integers) "
894 "greater than the vector element type!");
895 return getNode(ISD::UNDEF, SDLoc(), VT);
896 }
897 return getNode(ISD::SPLAT_VECTOR, DL, VT, Op);
898 }
899
900 /// Returns a node representing a splat of one value into all lanes
901 /// of the provided vector type. This is a utility which returns
902 /// either a BUILD_VECTOR or SPLAT_VECTOR depending on the
903 /// scalability of the desired vector type.
905 assert(VT.isVector() && "Can't splat to non-vector type");
906 return VT.isScalableVector() ?
908 }
909
910 /// Returns a vector of type ResVT whose elements contain the linear sequence
911 /// <0, Step, Step * 2, Step * 3, ...>
912 SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal);
913
914 /// Returns a vector of type ResVT whose elements contain the linear sequence
915 /// <0, 1, 2, 3, ...>
916 SDValue getStepVector(const SDLoc &DL, EVT ResVT);
917
918 /// Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to
919 /// the shuffle node in input but with swapped operands.
920 ///
921 /// Example: shuffle A, B, <0,5,2,7> -> shuffle B, A, <4,1,6,3>
923
924 /// Convert Op, which must be of float type, to the
925 /// float type VT, by either extending or rounding (by truncation).
927
928 /// Convert Op, which must be a STRICT operation of float type, to the
929 /// float type VT, by either extending or rounding (by truncation).
930 std::pair<SDValue, SDValue>
932
933 /// Convert *_EXTEND_VECTOR_INREG to *_EXTEND opcode.
934 static unsigned getOpcode_EXTEND(unsigned Opcode) {
935 switch (Opcode) {
936 case ISD::ANY_EXTEND:
938 return ISD::ANY_EXTEND;
939 case ISD::ZERO_EXTEND:
941 return ISD::ZERO_EXTEND;
942 case ISD::SIGN_EXTEND:
944 return ISD::SIGN_EXTEND;
945 }
946 llvm_unreachable("Unknown opcode");
947 }
948
949 /// Convert *_EXTEND to *_EXTEND_VECTOR_INREG opcode.
950 static unsigned getOpcode_EXTEND_VECTOR_INREG(unsigned Opcode) {
951 switch (Opcode) {
952 case ISD::ANY_EXTEND:
955 case ISD::ZERO_EXTEND:
958 case ISD::SIGN_EXTEND:
961 }
962 llvm_unreachable("Unknown opcode");
963 }
964
965 /// Convert Op, which must be of integer type, to the
966 /// integer type VT, by either any-extending or truncating it.
968
969 /// Convert Op, which must be of integer type, to the
970 /// integer type VT, by either sign-extending or truncating it.
972
973 /// Convert Op, which must be of integer type, to the
974 /// integer type VT, by either zero-extending or truncating it.
976
977 /// Convert Op, which must be of integer type, to the
978 /// integer type VT, by either any/sign/zero-extending (depending on IsAny /
979 /// IsSigned) or truncating it.
981 EVT VT, unsigned Opcode) {
982 switch(Opcode) {
983 case ISD::ANY_EXTEND:
984 return getAnyExtOrTrunc(Op, DL, VT);
985 case ISD::ZERO_EXTEND:
986 return getZExtOrTrunc(Op, DL, VT);
987 case ISD::SIGN_EXTEND:
988 return getSExtOrTrunc(Op, DL, VT);
989 }
990 llvm_unreachable("Unsupported opcode");
991 }
992
993 /// Convert Op, which must be of integer type, to the
994 /// integer type VT, by either sign/zero-extending (depending on IsSigned) or
995 /// truncating it.
996 SDValue getExtOrTrunc(bool IsSigned, SDValue Op, const SDLoc &DL, EVT VT) {
997 return IsSigned ? getSExtOrTrunc(Op, DL, VT) : getZExtOrTrunc(Op, DL, VT);
998 }
999
1000 /// Convert Op, which must be of integer type, to the
1001 /// integer type VT, by first bitcasting (from potential vector) to
1002 /// corresponding scalar type then either any-extending or truncating it.
1004
1005 /// Convert Op, which must be of integer type, to the
1006 /// integer type VT, by first bitcasting (from potential vector) to
1007 /// corresponding scalar type then either sign-extending or truncating it.
1009
1010 /// Convert Op, which must be of integer type, to the
1011 /// integer type VT, by first bitcasting (from potential vector) to
1012 /// corresponding scalar type then either zero-extending or truncating it.
1014
1015 /// Return the expression required to zero extend the Op
1016 /// value assuming it was the smaller SrcTy value.
1018
1019 /// Return the expression required to zero extend the Op
1020 /// value assuming it was the smaller SrcTy value.
1022 const SDLoc &DL, EVT VT);
1023
1024 /// Convert Op, which must be of integer type, to the integer type VT, by
1025 /// either truncating it or performing either zero or sign extension as
1026 /// appropriate extension for the pointer's semantics.
1028
1029 /// Return the expression required to extend the Op as a pointer value
1030 /// assuming it was the smaller SrcTy value. This may be either a zero extend
1031 /// or a sign extend.
1033
1034 /// Convert Op, which must be of integer type, to the integer type VT,
1035 /// by using an extension appropriate for the target's
1036 /// BooleanContent for type OpVT or truncating it.
1037 SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT);
1038
1039 /// Create negative operation as (SUB 0, Val).
1040 SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT);
1041
1042 /// Create a bitwise NOT operation as (XOR Val, -1).
1043 SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT);
1044
1045 /// Create a logical NOT operation as (XOR Val, BooleanOne).
1046 SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT);
1047
1048 /// Create a vector-predicated logical NOT operation as (VP_XOR Val,
1049 /// BooleanOne, Mask, EVL).
1050 SDValue getVPLogicalNOT(const SDLoc &DL, SDValue Val, SDValue Mask,
1051 SDValue EVL, EVT VT);
1052
1053 /// Convert a vector-predicated Op, which must be an integer vector, to the
1054 /// vector-type VT, by performing either vector-predicated zext or truncating
1055 /// it. The Op will be returned as-is if Op and VT are vectors containing
1056 /// integer with same width.
1058 SDValue EVL);
1059
1060 /// Convert a vector-predicated Op, which must be of integer type, to the
1061 /// vector-type integer type VT, by either truncating it or performing either
1062 /// vector-predicated zero or sign extension as appropriate extension for the
1063 /// pointer's semantics. This function just redirects to getVPZExtOrTrunc
1064 /// right now.
1066 SDValue EVL);
1067
1068 /// Returns sum of the base pointer and offset.
1069 /// Unlike getObjectPtrOffset this does not set NoUnsignedWrap by default.
1071 const SDNodeFlags Flags = SDNodeFlags());
1073 const SDNodeFlags Flags = SDNodeFlags());
1074
1075 /// Create an add instruction with appropriate flags when used for
1076 /// addressing some offset of an object. i.e. if a load is split into multiple
1077 /// components, create an add nuw from the base pointer to the offset.
1080 }
1081
1083 // The object itself can't wrap around the address space, so it shouldn't be
1084 // possible for the adds of the offsets to the split parts to overflow.
1086 }
1087
1088 /// Return a new CALLSEQ_START node, that starts new call frame, in which
1089 /// InSize bytes are set up inside CALLSEQ_START..CALLSEQ_END sequence and
1090 /// OutSize specifies part of the frame set up prior to the sequence.
1092 const SDLoc &DL) {
1093 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
1094 SDValue Ops[] = { Chain,
1095 getIntPtrConstant(InSize, DL, true),
1096 getIntPtrConstant(OutSize, DL, true) };
1097 return getNode(ISD::CALLSEQ_START, DL, VTs, Ops);
1098 }
1099
1100 /// Return a new CALLSEQ_END node, which always must have a
1101 /// glue result (to ensure it's not CSE'd).
1102 /// CALLSEQ_END does not have a useful SDLoc.
1104 SDValue InGlue, const SDLoc &DL) {
1105 SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue);
1107 Ops.push_back(Chain);
1108 Ops.push_back(Op1);
1109 Ops.push_back(Op2);
1110 if (InGlue.getNode())
1111 Ops.push_back(InGlue);
1112 return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops);
1113 }
1114
1116 SDValue Glue, const SDLoc &DL) {
1117 return getCALLSEQ_END(
1118 Chain, getIntPtrConstant(Size1, DL, /*isTarget=*/true),
1119 getIntPtrConstant(Size2, DL, /*isTarget=*/true), Glue, DL);
1120 }
1121
1122 /// Return true if the result of this operation is always undefined.
1123 bool isUndef(unsigned Opcode, ArrayRef<SDValue> Ops);
1124
1125 /// Return an UNDEF node. UNDEF does not have a useful SDLoc.
1127 return getNode(ISD::UNDEF, SDLoc(), VT);
1128 }
1129
1130 /// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
1131 SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm,
1132 bool ConstantFold = true);
1133
1135 bool ConstantFold = true);
1136
1137 /// Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
1139 return getNode(ISD::GLOBAL_OFFSET_TABLE, SDLoc(), VT);
1140 }
1141
1142 /// Gets or creates the specified node.
1143 ///
1144 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1145 ArrayRef<SDUse> Ops);
1146 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1147 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1148 SDValue getNode(unsigned Opcode, const SDLoc &DL, ArrayRef<EVT> ResultTys,
1149 ArrayRef<SDValue> Ops);
1150 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1151 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1152
1153 // Use flags from current flag inserter.
1154 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1155 ArrayRef<SDValue> Ops);
1156 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1157 ArrayRef<SDValue> Ops);
1158 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand);
1159 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1160 SDValue N2);
1161 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1162 SDValue N2, SDValue N3);
1163
1164 // Specialize based on number of operands.
1165 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT);
1166 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand,
1167 const SDNodeFlags Flags);
1168 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1169 SDValue N2, const SDNodeFlags Flags);
1170 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1171 SDValue N2, SDValue N3, const SDNodeFlags Flags);
1172 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1173 SDValue N2, SDValue N3, SDValue N4);
1174 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1175 SDValue N2, SDValue N3, SDValue N4, const SDNodeFlags Flags);
1176 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1177 SDValue N2, SDValue N3, SDValue N4, SDValue N5);
1178 SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1179 SDValue N2, SDValue N3, SDValue N4, SDValue N5,
1180 const SDNodeFlags Flags);
1181
1182 // Specialize again based on number of operands for nodes with a VTList
1183 // rather than a single VT.
1184 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList);
1185 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N);
1186 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
1187 SDValue N2);
1188 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
1189 SDValue N2, SDValue N3);
1190 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
1191 SDValue N2, SDValue N3, SDValue N4);
1192 SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
1193 SDValue N2, SDValue N3, SDValue N4, SDValue N5);
1194
1195 /// Compute a TokenFactor to force all the incoming stack arguments to be
1196 /// loaded from the stack. This is used in tail call lowering to protect
1197 /// stack arguments from being clobbered.
1199
1200 /* \p CI if not null is the memset call being lowered.
1201 * \p OverrideTailCall is an optional parameter that can be used to override
1202 * the tail call optimization decision. */
1203 SDValue
1204 getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
1205 SDValue Size, Align Alignment, bool isVol, bool AlwaysInline,
1206 const CallInst *CI, std::optional<bool> OverrideTailCall,
1207 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo,
1208 const AAMDNodes &AAInfo = AAMDNodes(), AAResults *AA = nullptr);
1209
1210 /* \p CI if not null is the memset call being lowered.
1211 * \p OverrideTailCall is an optional parameter that can be used to override
1212 * the tail call optimization decision. */
1213 SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
1214 SDValue Size, Align Alignment, bool isVol,
1215 const CallInst *CI, std::optional<bool> OverrideTailCall,
1216 MachinePointerInfo DstPtrInfo,
1217 MachinePointerInfo SrcPtrInfo,
1218 const AAMDNodes &AAInfo = AAMDNodes(),
1219 AAResults *AA = nullptr);
1220
1221 SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
1222 SDValue Size, Align Alignment, bool isVol,
1223 bool AlwaysInline, const CallInst *CI,
1224 MachinePointerInfo DstPtrInfo,
1225 const AAMDNodes &AAInfo = AAMDNodes());
1226
1227 SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst,
1228 SDValue Src, SDValue Size, Type *SizeTy,
1229 unsigned ElemSz, bool isTailCall,
1230 MachinePointerInfo DstPtrInfo,
1231 MachinePointerInfo SrcPtrInfo);
1232
1233 SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
1234 SDValue Src, SDValue Size, Type *SizeTy,
1235 unsigned ElemSz, bool isTailCall,
1236 MachinePointerInfo DstPtrInfo,
1237 MachinePointerInfo SrcPtrInfo);
1238
1239 SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
1240 SDValue Value, SDValue Size, Type *SizeTy,
1241 unsigned ElemSz, bool isTailCall,
1242 MachinePointerInfo DstPtrInfo);
1243
1244 /// Helper function to make it easier to build SetCC's if you just have an
1245 /// ISD::CondCode instead of an SDValue.
1247 ISD::CondCode Cond, SDValue Chain = SDValue(),
1248 bool IsSignaling = false) {
1249 assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() &&
1250 "Vector/scalar operand type mismatch for setcc");
1251 assert(LHS.getValueType().isVector() == VT.isVector() &&
1252 "Vector/scalar result type mismatch for setcc");
1254 "Cannot create a setCC of an invalid node.");
1255 if (Chain)
1256 return getNode(IsSignaling ? ISD::STRICT_FSETCCS : ISD::STRICT_FSETCC, DL,
1257 {VT, MVT::Other}, {Chain, LHS, RHS, getCondCode(Cond)});
1258 return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond));
1259 }
1260
1261 /// Helper function to make it easier to build VP_SETCCs if you just have an
1262 /// ISD::CondCode instead of an SDValue.
1264 ISD::CondCode Cond, SDValue Mask, SDValue EVL) {
1265 assert(LHS.getValueType().isVector() && RHS.getValueType().isVector() &&
1266 "Cannot compare scalars");
1268 "Cannot create a setCC of an invalid node.");
1269 return getNode(ISD::VP_SETCC, DL, VT, LHS, RHS, getCondCode(Cond), Mask,
1270 EVL);
1271 }
1272
1273 /// Helper function to make it easier to build Select's if you just have
1274 /// operands and don't want to check for vector.
1276 SDValue RHS, SDNodeFlags Flags = SDNodeFlags()) {
1277 assert(LHS.getValueType() == VT && RHS.getValueType() == VT &&
1278 "Cannot use select on differing types");
1279 auto Opcode = Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT;
1280 return getNode(Opcode, DL, VT, Cond, LHS, RHS, Flags);
1281 }
1282
1283 /// Helper function to make it easier to build SelectCC's if you just have an
1284 /// ISD::CondCode instead of an SDValue.
1286 SDValue False, ISD::CondCode Cond) {
1287 return getNode(ISD::SELECT_CC, DL, True.getValueType(), LHS, RHS, True,
1288 False, getCondCode(Cond));
1289 }
1290
1291 /// Try to simplify a select/vselect into 1 of its operands or a constant.
1293
1294 /// Try to simplify a shift into 1 of its operands or a constant.
1296
1297 /// Try to simplify a floating-point binary operation into 1 of its operands
1298 /// or a constant.
1299 SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y,
1300 SDNodeFlags Flags);
1301
1302 /// VAArg produces a result and token chain, and takes a pointer
1303 /// and a source value as input.
1304 SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1305 SDValue SV, unsigned Align);
1306
1307 /// Gets a node for an atomic cmpxchg op. There are two
1308 /// valid Opcodes. ISD::ATOMIC_CMO_SWAP produces the value loaded and a
1309 /// chain result. ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS produces the value loaded,
1310 /// a success flag (initially i1), and a chain.
1311 SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1312 SDVTList VTs, SDValue Chain, SDValue Ptr,
1313 SDValue Cmp, SDValue Swp, MachineMemOperand *MMO);
1314
1315 /// Gets a node for an atomic op, produces result (if relevant)
1316 /// and chain and takes 2 operands.
1317 SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain,
1319
1320 /// Gets a node for an atomic op, produces result and chain and
1321 /// takes 1 operand.
1322 SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, EVT VT,
1323 SDValue Chain, SDValue Ptr, MachineMemOperand *MMO);
1324
1325 /// Gets a node for an atomic op, produces result and chain and takes N
1326 /// operands.
1327 SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1328 SDVTList VTList, ArrayRef<SDValue> Ops,
1329 MachineMemOperand *MMO);
1330
1331 /// Creates a MemIntrinsicNode that may produce a
1332 /// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
1333 /// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not
1334 /// less than FIRST_TARGET_MEMORY_OPCODE.
1336 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1337 EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment,
1340 LocationSize Size = 0, const AAMDNodes &AAInfo = AAMDNodes());
1341
1343 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1344 EVT MemVT, MachinePointerInfo PtrInfo,
1345 MaybeAlign Alignment = std::nullopt,
1348 LocationSize Size = 0, const AAMDNodes &AAInfo = AAMDNodes()) {
1349 // Ensure that codegen never sees alignment 0
1350 return getMemIntrinsicNode(Opcode, dl, VTList, Ops, MemVT, PtrInfo,
1351 Alignment.value_or(getEVTAlign(MemVT)), Flags,
1352 Size, AAInfo);
1353 }
1354
1355 SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList,
1356 ArrayRef<SDValue> Ops, EVT MemVT,
1357 MachineMemOperand *MMO);
1358
1359 /// Creates a LifetimeSDNode that starts (`IsStart==true`) or ends
1360 /// (`IsStart==false`) the lifetime of the portion of `FrameIndex` between
1361 /// offsets `Offset` and `Offset + Size`.
1362 SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain,
1363 int FrameIndex, int64_t Size, int64_t Offset = -1);
1364
1365 /// Creates a PseudoProbeSDNode with function GUID `Guid` and
1366 /// the index of the block `Index` it is probing, as well as the attributes
1367 /// `attr` of the probe.
1369 uint64_t Index, uint32_t Attr);
1370
1371 /// Create a MERGE_VALUES node from the given operands.
1373
1374 /// Loads are not normal binary operators: their result type is not
1375 /// determined by their operands, and they produce a value AND a token chain.
1376 ///
1377 /// This function will set the MOLoad flag on MMOFlags, but you can set it if
1378 /// you want. The MOStore flag must not be set.
1379 SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1380 MachinePointerInfo PtrInfo,
1381 MaybeAlign Alignment = MaybeAlign(),
1383 const AAMDNodes &AAInfo = AAMDNodes(),
1384 const MDNode *Ranges = nullptr);
1385 SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1386 MachineMemOperand *MMO);
1387 SDValue
1388 getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1389 SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT,
1390 MaybeAlign Alignment = MaybeAlign(),
1392 const AAMDNodes &AAInfo = AAMDNodes());
1393 SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1394 SDValue Chain, SDValue Ptr, EVT MemVT,
1395 MachineMemOperand *MMO);
1396 SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base,
1399 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1400 MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment,
1402 const AAMDNodes &AAInfo = AAMDNodes(),
1403 const MDNode *Ranges = nullptr);
1405 ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl,
1407 EVT MemVT, MaybeAlign Alignment = MaybeAlign(),
1409 const AAMDNodes &AAInfo = AAMDNodes(), const MDNode *Ranges = nullptr) {
1410 // Ensures that codegen never sees a None Alignment.
1411 return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT,
1412 Alignment.value_or(getEVTAlign(MemVT)), MMOFlags, AAInfo,
1413 Ranges);
1414 }
1416 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1417 EVT MemVT, MachineMemOperand *MMO);
1418
1419 /// Helper function to build ISD::STORE nodes.
1420 ///
1421 /// This function will set the MOStore flag on MMOFlags, but you can set it if
1422 /// you want. The MOLoad and MOInvariant flags must not be set.
1423
1424 SDValue
1425 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1426 MachinePointerInfo PtrInfo, Align Alignment,
1428 const AAMDNodes &AAInfo = AAMDNodes());
1429 inline SDValue
1430 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1431 MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(),
1433 const AAMDNodes &AAInfo = AAMDNodes()) {
1434 return getStore(Chain, dl, Val, Ptr, PtrInfo,
1435 Alignment.value_or(getEVTAlign(Val.getValueType())),
1436 MMOFlags, AAInfo);
1437 }
1438 SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1439 MachineMemOperand *MMO);
1440 SDValue
1441 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1442 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1444 const AAMDNodes &AAInfo = AAMDNodes());
1445 inline SDValue
1447 MachinePointerInfo PtrInfo, EVT SVT,
1448 MaybeAlign Alignment = MaybeAlign(),
1450 const AAMDNodes &AAInfo = AAMDNodes()) {
1451 return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT,
1452 Alignment.value_or(getEVTAlign(SVT)), MMOFlags,
1453 AAInfo);
1454 }
1455 SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1456 SDValue Ptr, EVT SVT, MachineMemOperand *MMO);
1457 SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base,
1459
1461 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1462 SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo,
1463 EVT MemVT, Align Alignment,
1464 MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo,
1465 const MDNode *Ranges = nullptr, bool IsExpanding = false);
1466 inline SDValue
1468 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1469 SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT,
1470 MaybeAlign Alignment = MaybeAlign(),
1472 const AAMDNodes &AAInfo = AAMDNodes(),
1473 const MDNode *Ranges = nullptr, bool IsExpanding = false) {
1474 // Ensures that codegen never sees a None Alignment.
1475 return getLoadVP(AM, ExtType, VT, dl, Chain, Ptr, Offset, Mask, EVL,
1476 PtrInfo, MemVT, Alignment.value_or(getEVTAlign(MemVT)),
1477 MMOFlags, AAInfo, Ranges, IsExpanding);
1478 }
1480 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1481 SDValue Mask, SDValue EVL, EVT MemVT,
1482 MachineMemOperand *MMO, bool IsExpanding = false);
1483 SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1484 SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo,
1485 MaybeAlign Alignment, MachineMemOperand::Flags MMOFlags,
1486 const AAMDNodes &AAInfo, const MDNode *Ranges = nullptr,
1487 bool IsExpanding = false);
1488 SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1489 SDValue Mask, SDValue EVL, MachineMemOperand *MMO,
1490 bool IsExpanding = false);
1491 SDValue getExtLoadVP(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1492 SDValue Chain, SDValue Ptr, SDValue Mask, SDValue EVL,
1493 MachinePointerInfo PtrInfo, EVT MemVT,
1494 MaybeAlign Alignment, MachineMemOperand::Flags MMOFlags,
1495 const AAMDNodes &AAInfo, bool IsExpanding = false);
1496 SDValue getExtLoadVP(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1497 SDValue Chain, SDValue Ptr, SDValue Mask, SDValue EVL,
1498 EVT MemVT, MachineMemOperand *MMO,
1499 bool IsExpanding = false);
1500 SDValue getIndexedLoadVP(SDValue OrigLoad, const SDLoc &dl, SDValue Base,
1502 SDValue getStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1503 SDValue Offset, SDValue Mask, SDValue EVL, EVT MemVT,
1505 bool IsTruncating = false, bool IsCompressing = false);
1506 SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1507 SDValue Ptr, SDValue Mask, SDValue EVL,
1508 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1509 MachineMemOperand::Flags MMOFlags,
1510 const AAMDNodes &AAInfo, bool IsCompressing = false);
1511 SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1512 SDValue Ptr, SDValue Mask, SDValue EVL, EVT SVT,
1513 MachineMemOperand *MMO, bool IsCompressing = false);
1514 SDValue getIndexedStoreVP(SDValue OrigStore, const SDLoc &dl, SDValue Base,
1516
1518 EVT VT, const SDLoc &DL, SDValue Chain, SDValue Ptr,
1519 SDValue Offset, SDValue Stride, SDValue Mask,
1520 SDValue EVL, EVT MemVT, MachineMemOperand *MMO,
1521 bool IsExpanding = false);
1523 SDValue Stride, SDValue Mask, SDValue EVL,
1524 MachineMemOperand *MMO, bool IsExpanding = false);
1526 SDValue Chain, SDValue Ptr, SDValue Stride,
1527 SDValue Mask, SDValue EVL, EVT MemVT,
1528 MachineMemOperand *MMO, bool IsExpanding = false);
1529 SDValue getStridedStoreVP(SDValue Chain, const SDLoc &DL, SDValue Val,
1530 SDValue Ptr, SDValue Offset, SDValue Stride,
1531 SDValue Mask, SDValue EVL, EVT MemVT,
1533 bool IsTruncating = false,
1534 bool IsCompressing = false);
1536 SDValue Ptr, SDValue Stride, SDValue Mask,
1537 SDValue EVL, EVT SVT, MachineMemOperand *MMO,
1538 bool IsCompressing = false);
1539
1540 SDValue getGatherVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1542 ISD::MemIndexType IndexType);
1543 SDValue getScatterVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1545 ISD::MemIndexType IndexType);
1546
1547 SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base,
1548 SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT,
1550 ISD::LoadExtType, bool IsExpanding = false);
1553 SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1554 SDValue Base, SDValue Offset, SDValue Mask, EVT MemVT,
1556 bool IsTruncating = false, bool IsCompressing = false);
1557 SDValue getIndexedMaskedStore(SDValue OrigStore, const SDLoc &dl,
1560 SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1562 ISD::MemIndexType IndexType, ISD::LoadExtType ExtTy);
1563 SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1565 ISD::MemIndexType IndexType,
1566 bool IsTruncating = false);
1567 SDValue getMaskedHistogram(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1569 ISD::MemIndexType IndexType);
1570
1571 SDValue getGetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr, EVT MemVT,
1572 MachineMemOperand *MMO);
1573 SDValue getSetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr, EVT MemVT,
1574 MachineMemOperand *MMO);
1575
1576 /// Construct a node to track a Value* through the backend.
1577 SDValue getSrcValue(const Value *v);
1578
1579 /// Return an MDNodeSDNode which holds an MDNode.
1580 SDValue getMDNode(const MDNode *MD);
1581
1582 /// Return a bitcast using the SDLoc of the value operand, and casting to the
1583 /// provided type. Use getNode to set a custom SDLoc.
1585
1586 /// Return an AddrSpaceCastSDNode.
1587 SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS,
1588 unsigned DestAS);
1589
1590 /// Return a freeze using the SDLoc of the value operand.
1592
1593 /// Return an AssertAlignSDNode.
1595
1596 /// Swap N1 and N2 if Opcode is a commutative binary opcode
1597 /// and the canonical form expects the opposite order.
1598 void canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1,
1599 SDValue &N2) const;
1600
1601 /// Return the specified value casted to
1602 /// the target's desired shift amount type.
1604
1605 /// Create the DAG equivalent of vector_partial_reduce where Op1 and Op2 are
1606 /// its operands and ReducedTY is the intrinsic's return type.
1608 SDValue Op2);
1609
1610 /// Expands a node with multiple results to an FP or vector libcall. The
1611 /// libcall is expected to take all the operands of the \p Node followed by
1612 /// output pointers for each of the results. \p CallRetResNo can be optionally
1613 /// set to indicate that one of the results comes from the libcall's return
1614 /// value.
1617 std::optional<unsigned> CallRetResNo = {});
1618
1619 /// Expand the specified \c ISD::VAARG node as the Legalize pass would.
1620 SDValue expandVAArg(SDNode *Node);
1621
1622 /// Expand the specified \c ISD::VACOPY node as the Legalize pass would.
1623 SDValue expandVACopy(SDNode *Node);
1624
1625 /// Return a GlobalAddress of the function from the current module with
1626 /// name matching the given ExternalSymbol. Additionally can provide the
1627 /// matched function.
1628 /// Panic if the function doesn't exist.
1629 SDValue getSymbolFunctionGlobalAddress(SDValue Op,
1630 Function **TargetFunction = nullptr);
1631
1632 /// *Mutate* the specified node in-place to have the
1633 /// specified operands. If the resultant node already exists in the DAG,
1634 /// this does not modify the specified node, instead it returns the node that
1635 /// already exists. If the resultant node does not exist in the DAG, the
1636 /// input node is returned. As a degenerate case, if you specify the same
1637 /// input operands as the node already has, the input node is returned.
1638 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op);
1639 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2);
1640 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1641 SDValue Op3);
1642 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1643 SDValue Op3, SDValue Op4);
1644 SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1645 SDValue Op3, SDValue Op4, SDValue Op5);
1646 SDNode *UpdateNodeOperands(SDNode *N, ArrayRef<SDValue> Ops);
1647
1648 /// Creates a new TokenFactor containing \p Vals. If \p Vals contains 64k
1649 /// values or more, move values into new TokenFactors in 64k-1 blocks, until
1650 /// the final TokenFactor has less than 64k operands.
1651 SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl<SDValue> &Vals);
1652
1653 /// *Mutate* the specified machine node's memory references to the provided
1654 /// list.
1655 void setNodeMemRefs(MachineSDNode *N,
1656 ArrayRef<MachineMemOperand *> NewMemRefs);
1657
1658 // Calculate divergence of node \p N based on its operands.
1659 bool calculateDivergence(SDNode *N);
1660
1661 // Propagates the change in divergence to users
1662 void updateDivergence(SDNode * N);
1663
1664 /// These are used for target selectors to *mutate* the
1665 /// specified node to have the specified return type, Target opcode, and
1666 /// operands. Note that target opcodes are stored as
1667 /// ~TargetOpcode in the node opcode field. The resultant node is returned.
1668 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT);
1669 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, SDValue Op1);
1670 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1671 SDValue Op1, SDValue Op2);
1672 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1673 SDValue Op1, SDValue Op2, SDValue Op3);
1674 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1675 ArrayRef<SDValue> Ops);
1676 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, EVT VT2);
1677 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1678 EVT VT2, ArrayRef<SDValue> Ops);
1679 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1680 EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1681 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1682 EVT VT2, SDValue Op1, SDValue Op2);
1683 SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, SDVTList VTs,
1684 ArrayRef<SDValue> Ops);
1685
1686 /// This *mutates* the specified node to have the specified
1687 /// return type, opcode, and operands.
1688 SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
1689 ArrayRef<SDValue> Ops);
1690
1691 /// Mutate the specified strict FP node to its non-strict equivalent,
1692 /// unlinking the node from its chain and dropping the metadata arguments.
1693 /// The node must be a strict FP node.
1694 SDNode *mutateStrictFPToFP(SDNode *Node);
1695
1696 /// These are used for target selectors to create a new node
1697 /// with specified return type(s), MachineInstr opcode, and operands.
1698 ///
1699 /// Note that getMachineNode returns the resultant node. If there is already
1700 /// a node of the specified opcode and operands, it returns that node instead
1701 /// of the current one.
1702 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT);
1703 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1704 SDValue Op1);
1705 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1706 SDValue Op1, SDValue Op2);
1707 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1708 SDValue Op1, SDValue Op2, SDValue Op3);
1709 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1710 ArrayRef<SDValue> Ops);
1711 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1712 EVT VT2, SDValue Op1, SDValue Op2);
1713 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1714 EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
1715 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1716 EVT VT2, ArrayRef<SDValue> Ops);
1717 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1718 EVT VT2, EVT VT3, SDValue Op1, SDValue Op2);
1719 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1720 EVT VT2, EVT VT3, SDValue Op1, SDValue Op2,
1721 SDValue Op3);
1722 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1723 EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1724 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1725 ArrayRef<EVT> ResultTys, ArrayRef<SDValue> Ops);
1726 MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, SDVTList VTs,
1727 ArrayRef<SDValue> Ops);
1728
1729 /// A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
1730 SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1731 SDValue Operand);
1732
1733 /// A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
1734 SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1735 SDValue Operand, SDValue Subreg);
1736
1737 /// Get the specified node if it's already available, or else return NULL.
1738 SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1739 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1740 SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1741 ArrayRef<SDValue> Ops);
1742
1743 /// Check if a node exists without modifying its flags.
1744 bool doesNodeExist(unsigned Opcode, SDVTList VTList, ArrayRef<SDValue> Ops);
1745
1746 /// Creates a SDDbgValue node.
1747 SDDbgValue *getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N,
1748 unsigned R, bool IsIndirect, const DebugLoc &DL,
1749 unsigned O);
1750
1751 /// Creates a constant SDDbgValue node.
1752 SDDbgValue *getConstantDbgValue(DIVariable *Var, DIExpression *Expr,
1753 const Value *C, const DebugLoc &DL,
1754 unsigned O);
1755
1756 /// Creates a FrameIndex SDDbgValue node.
1757 SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr,
1758 unsigned FI, bool IsIndirect,
1759 const DebugLoc &DL, unsigned O);
1760
1761 /// Creates a FrameIndex SDDbgValue node.
1762 SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr,
1763 unsigned FI,
1764 ArrayRef<SDNode *> Dependencies,
1765 bool IsIndirect, const DebugLoc &DL,
1766 unsigned O);
1767
1768 /// Creates a VReg SDDbgValue node.
1769 SDDbgValue *getVRegDbgValue(DIVariable *Var, DIExpression *Expr,
1770 unsigned VReg, bool IsIndirect,
1771 const DebugLoc &DL, unsigned O);
1772
1773 /// Creates a SDDbgValue node from a list of locations.
1774 SDDbgValue *getDbgValueList(DIVariable *Var, DIExpression *Expr,
1775 ArrayRef<SDDbgOperand> Locs,
1776 ArrayRef<SDNode *> Dependencies, bool IsIndirect,
1777 const DebugLoc &DL, unsigned O, bool IsVariadic);
1778
1779 /// Creates a SDDbgLabel node.
1780 SDDbgLabel *getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O);
1781
1782 /// Transfer debug values from one node to another, while optionally
1783 /// generating fragment expressions for split-up values. If \p InvalidateDbg
1784 /// is set, debug values are invalidated after they are transferred.
1785 void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0,
1786 unsigned SizeInBits = 0, bool InvalidateDbg = true);
1787
1788 /// Remove the specified node from the system. If any of its
1789 /// operands then becomes dead, remove them as well. Inform UpdateListener
1790 /// for each node deleted.
1791 void RemoveDeadNode(SDNode *N);
1792
1793 /// This method deletes the unreachable nodes in the
1794 /// given list, and any nodes that become unreachable as a result.
1795 void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes);
1796
1797 /// Modify anything using 'From' to use 'To' instead.
1798 /// This can cause recursive merging of nodes in the DAG. Use the first
1799 /// version if 'From' is known to have a single result, use the second
1800 /// if you have two nodes with identical results (or if 'To' has a superset
1801 /// of the results of 'From'), use the third otherwise.
1802 ///
1803 /// These methods all take an optional UpdateListener, which (if not null) is
1804 /// informed about nodes that are deleted and modified due to recursive
1805 /// changes in the dag.
1806 ///
1807 /// These functions only replace all existing uses. It's possible that as
1808 /// these replacements are being performed, CSE may cause the From node
1809 /// to be given new uses. These new uses of From are left in place, and
1810 /// not automatically transferred to To.
1811 ///
1812 void ReplaceAllUsesWith(SDValue From, SDValue To);
1813 void ReplaceAllUsesWith(SDNode *From, SDNode *To);
1814 void ReplaceAllUsesWith(SDNode *From, const SDValue *To);
1815
1816 /// Replace any uses of From with To, leaving
1817 /// uses of other values produced by From.getNode() alone.
1818 void ReplaceAllUsesOfValueWith(SDValue From, SDValue To);
1819
1820 /// Like ReplaceAllUsesOfValueWith, but for multiple values at once.
1821 /// This correctly handles the case where
1822 /// there is an overlap between the From values and the To values.
1823 void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To,
1824 unsigned Num);
1825
1826 /// If an existing load has uses of its chain, create a token factor node with
1827 /// that chain and the new memory node's chain and update users of the old
1828 /// chain to the token factor. This ensures that the new memory node will have
1829 /// the same relative memory dependency position as the old load. Returns the
1830 /// new merged load chain.
1831 SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain);
1832
1833 /// If an existing load has uses of its chain, create a token factor node with
1834 /// that chain and the new memory node's chain and update users of the old
1835 /// chain to the token factor. This ensures that the new memory node will have
1836 /// the same relative memory dependency position as the old load. Returns the
1837 /// new merged load chain.
1838 SDValue makeEquivalentMemoryOrdering(LoadSDNode *OldLoad, SDValue NewMemOp);
1839
1840 /// Topological-sort the AllNodes list and a
1841 /// assign a unique node id for each node in the DAG based on their
1842 /// topological order. Returns the number of nodes.
1843 unsigned AssignTopologicalOrder();
1844
1845 /// Move node N in the AllNodes list to be immediately
1846 /// before the given iterator Position. This may be used to update the
1847 /// topological ordering when the list of nodes is modified.
1849 AllNodes.insert(Position, AllNodes.remove(N));
1850 }
1851
1852 /// Add a dbg_value SDNode. If SD is non-null that means the
1853 /// value is produced by SD.
1854 void AddDbgValue(SDDbgValue *DB, bool isParameter);
1855
1856 /// Add a dbg_label SDNode.
1857 void AddDbgLabel(SDDbgLabel *DB);
1858
1859 /// Get the debug values which reference the given SDNode.
1861 return DbgInfo->getSDDbgValues(SD);
1862 }
1863
1864public:
1865 /// Return true if there are any SDDbgValue nodes associated
1866 /// with this SelectionDAG.
1867 bool hasDebugValues() const { return !DbgInfo->empty(); }
1868
1869 SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); }
1870 SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); }
1871
1873 return DbgInfo->ByvalParmDbgBegin();
1874 }
1876 return DbgInfo->ByvalParmDbgEnd();
1877 }
1878
1880 return DbgInfo->DbgLabelBegin();
1881 }
1883 return DbgInfo->DbgLabelEnd();
1884 }
1885
1886 /// To be invoked on an SDNode that is slated to be erased. This
1887 /// function mirrors \c llvm::salvageDebugInfo.
1888 void salvageDebugInfo(SDNode &N);
1889
1890 void dump() const;
1891
1892 /// In most cases this function returns the ABI alignment for a given type,
1893 /// except for illegal vector types where the alignment exceeds that of the
1894 /// stack. In such cases we attempt to break the vector down to a legal type
1895 /// and return the ABI alignment for that instead.
1896 Align getReducedAlign(EVT VT, bool UseABI);
1897
1898 /// Create a stack temporary based on the size in bytes and the alignment
1899 SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment);
1900
1901 /// Create a stack temporary, suitable for holding the specified value type.
1902 /// If minAlign is specified, the slot size will have at least that alignment.
1903 SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
1904
1905 /// Create a stack temporary suitable for holding either of the specified
1906 /// value types.
1908
1909 SDValue FoldSymbolOffset(unsigned Opcode, EVT VT,
1910 const GlobalAddressSDNode *GA,
1911 const SDNode *N2);
1912
1913 SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1915 SDNodeFlags Flags = SDNodeFlags());
1916
1917 /// Fold floating-point operations when all operands are constants and/or
1918 /// undefined.
1919 SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT,
1920 ArrayRef<SDValue> Ops);
1921
1922 /// Constant fold a setcc to true or false.
1924 const SDLoc &dl);
1925
1926 /// Return true if the sign bit of Op is known to be zero.
1927 /// We use this predicate to simplify operations downstream.
1928 bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
1929
1930 /// Return true if 'Op & Mask' is known to be zero. We
1931 /// use this predicate to simplify operations downstream. Op and Mask are
1932 /// known to be the same type.
1933 bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
1934 unsigned Depth = 0) const;
1935
1936 /// Return true if 'Op & Mask' is known to be zero in DemandedElts. We
1937 /// use this predicate to simplify operations downstream. Op and Mask are
1938 /// known to be the same type.
1939 bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
1940 const APInt &DemandedElts, unsigned Depth = 0) const;
1941
1942 /// Return true if 'Op' is known to be zero in DemandedElts. We
1943 /// use this predicate to simplify operations downstream.
1944 bool MaskedVectorIsZero(SDValue Op, const APInt &DemandedElts,
1945 unsigned Depth = 0) const;
1946
1947 /// Return true if '(Op & Mask) == Mask'.
1948 /// Op and Mask are known to be the same type.
1949 bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask,
1950 unsigned Depth = 0) const;
1951
1952 /// For each demanded element of a vector, see if it is known to be zero.
1954 unsigned Depth = 0) const;
1955
1956 /// Determine which bits of Op are known to be either zero or one and return
1957 /// them in Known. For vectors, the known bits are those that are shared by
1958 /// every vector element.
1959 /// Targets can implement the computeKnownBitsForTargetNode method in the
1960 /// TargetLowering class to allow target nodes to be understood.
1961 KnownBits computeKnownBits(SDValue Op, unsigned Depth = 0) const;
1962
1963 /// Determine which bits of Op are known to be either zero or one and return
1964 /// them in Known. The DemandedElts argument allows us to only collect the
1965 /// known bits that are shared by the requested vector elements.
1966 /// Targets can implement the computeKnownBitsForTargetNode method in the
1967 /// TargetLowering class to allow target nodes to be understood.
1968 KnownBits computeKnownBits(SDValue Op, const APInt &DemandedElts,
1969 unsigned Depth = 0) const;
1970
1971 /// Used to represent the possible overflow behavior of an operation.
1972 /// Never: the operation cannot overflow.
1973 /// Always: the operation will always overflow.
1974 /// Sometime: the operation may or may not overflow.
1979 };
1980
1981 /// Determine if the result of the signed addition of 2 nodes can overflow.
1983
1984 /// Determine if the result of the unsigned addition of 2 nodes can overflow.
1986
1987 /// Determine if the result of the addition of 2 nodes can overflow.
1989 SDValue N1) const {
1990 return IsSigned ? computeOverflowForSignedAdd(N0, N1)
1992 }
1993
1994 /// Determine if the result of the addition of 2 nodes can never overflow.
1995 bool willNotOverflowAdd(bool IsSigned, SDValue N0, SDValue N1) const {
1996 return computeOverflowForAdd(IsSigned, N0, N1) == OFK_Never;
1997 }
1998
1999 /// Determine if the result of the signed sub of 2 nodes can overflow.
2001
2002 /// Determine if the result of the unsigned sub of 2 nodes can overflow.
2004
2005 /// Determine if the result of the sub of 2 nodes can overflow.
2007 SDValue N1) const {
2008 return IsSigned ? computeOverflowForSignedSub(N0, N1)
2010 }
2011
2012 /// Determine if the result of the sub of 2 nodes can never overflow.
2013 bool willNotOverflowSub(bool IsSigned, SDValue N0, SDValue N1) const {
2014 return computeOverflowForSub(IsSigned, N0, N1) == OFK_Never;
2015 }
2016
2017 /// Determine if the result of the signed mul of 2 nodes can overflow.
2019
2020 /// Determine if the result of the unsigned mul of 2 nodes can overflow.
2022
2023 /// Determine if the result of the mul of 2 nodes can overflow.
2025 SDValue N1) const {
2026 return IsSigned ? computeOverflowForSignedMul(N0, N1)
2028 }
2029
2030 /// Determine if the result of the mul of 2 nodes can never overflow.
2031 bool willNotOverflowMul(bool IsSigned, SDValue N0, SDValue N1) const {
2032 return computeOverflowForMul(IsSigned, N0, N1) == OFK_Never;
2033 }
2034
2035 /// Test if the given value is known to have exactly one bit set. This differs
2036 /// from computeKnownBits in that it doesn't necessarily determine which bit
2037 /// is set.
2038 bool isKnownToBeAPowerOfTwo(SDValue Val, unsigned Depth = 0) const;
2039
2040 /// Test if the given _fp_ value is known to be an integer power-of-2, either
2041 /// positive or negative.
2042 bool isKnownToBeAPowerOfTwoFP(SDValue Val, unsigned Depth = 0) const;
2043
2044 /// Return the number of times the sign bit of the register is replicated into
2045 /// the other bits. We know that at least 1 bit is always equal to the sign
2046 /// bit (itself), but other cases can give us information. For example,
2047 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2048 /// to each other, so we return 3. Targets can implement the
2049 /// ComputeNumSignBitsForTarget method in the TargetLowering class to allow
2050 /// target nodes to be understood.
2051 unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
2052
2053 /// Return the number of times the sign bit of the register is replicated into
2054 /// the other bits. We know that at least 1 bit is always equal to the sign
2055 /// bit (itself), but other cases can give us information. For example,
2056 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2057 /// to each other, so we return 3. The DemandedElts argument allows
2058 /// us to only collect the minimum sign bits of the requested vector elements.
2059 /// Targets can implement the ComputeNumSignBitsForTarget method in the
2060 /// TargetLowering class to allow target nodes to be understood.
2061 unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
2062 unsigned Depth = 0) const;
2063
2064 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2065 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2066 /// Similar to the APInt::getSignificantBits function.
2067 /// Helper wrapper to ComputeNumSignBits.
2068 unsigned ComputeMaxSignificantBits(SDValue Op, unsigned Depth = 0) const;
2069
2070 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2071 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2072 /// Similar to the APInt::getSignificantBits function.
2073 /// Helper wrapper to ComputeNumSignBits.
2074 unsigned ComputeMaxSignificantBits(SDValue Op, const APInt &DemandedElts,
2075 unsigned Depth = 0) const;
2076
2077 /// Return true if this function can prove that \p Op is never poison
2078 /// and, if \p PoisonOnly is false, does not have undef bits.
2080 unsigned Depth = 0) const;
2081
2082 /// Return true if this function can prove that \p Op is never poison
2083 /// and, if \p PoisonOnly is false, does not have undef bits. The DemandedElts
2084 /// argument limits the check to the requested vector elements.
2085 bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, const APInt &DemandedElts,
2086 bool PoisonOnly = false,
2087 unsigned Depth = 0) const;
2088
2089 /// Return true if this function can prove that \p Op is never poison.
2090 bool isGuaranteedNotToBePoison(SDValue Op, unsigned Depth = 0) const {
2091 return isGuaranteedNotToBeUndefOrPoison(Op, /*PoisonOnly*/ true, Depth);
2092 }
2093
2094 /// Return true if this function can prove that \p Op is never poison. The
2095 /// DemandedElts argument limits the check to the requested vector elements.
2096 bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts,
2097 unsigned Depth = 0) const {
2098 return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts,
2099 /*PoisonOnly*/ true, Depth);
2100 }
2101
2102 /// Return true if Op can create undef or poison from non-undef & non-poison
2103 /// operands. The DemandedElts argument limits the check to the requested
2104 /// vector elements.
2105 ///
2106 /// \p ConsiderFlags controls whether poison producing flags on the
2107 /// instruction are considered. This can be used to see if the instruction
2108 /// could still introduce undef or poison even without poison generating flags
2109 /// which might be on the instruction. (i.e. could the result of
2110 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2111 bool canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
2112 bool PoisonOnly = false,
2113 bool ConsiderFlags = true,
2114 unsigned Depth = 0) const;
2115
2116 /// Return true if Op can create undef or poison from non-undef & non-poison
2117 /// operands.
2118 ///
2119 /// \p ConsiderFlags controls whether poison producing flags on the
2120 /// instruction are considered. This can be used to see if the instruction
2121 /// could still introduce undef or poison even without poison generating flags
2122 /// which might be on the instruction. (i.e. could the result of
2123 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2124 bool canCreateUndefOrPoison(SDValue Op, bool PoisonOnly = false,
2125 bool ConsiderFlags = true,
2126 unsigned Depth = 0) const;
2127
2128 /// Return true if the specified operand is an ISD::OR or ISD::XOR node
2129 /// that can be treated as an ISD::ADD node.
2130 /// or(x,y) == add(x,y) iff haveNoCommonBitsSet(x,y)
2131 /// xor(x,y) == add(x,y) iff isMinSignedConstant(y) && !NoWrap
2132 /// If \p NoWrap is true, this will not match ISD::XOR.
2133 bool isADDLike(SDValue Op, bool NoWrap = false) const;
2134
2135 /// Return true if the specified operand is an ISD::ADD with a ConstantSDNode
2136 /// on the right-hand side, or if it is an ISD::OR with a ConstantSDNode that
2137 /// is guaranteed to have the same semantics as an ADD. This handles the
2138 /// equivalence:
2139 /// X|Cst == X+Cst iff X&Cst = 0.
2141
2142 /// Test whether the given SDValue (or all elements of it, if it is a
2143 /// vector) is known to never be NaN. If \p SNaN is true, returns if \p Op is
2144 /// known to never be a signaling NaN (it may still be a qNaN).
2145 bool isKnownNeverNaN(SDValue Op, bool SNaN = false, unsigned Depth = 0) const;
2146
2147 /// \returns true if \p Op is known to never be a signaling NaN.
2148 bool isKnownNeverSNaN(SDValue Op, unsigned Depth = 0) const {
2149 return isKnownNeverNaN(Op, true, Depth);
2150 }
2151
2152 /// Test whether the given floating point SDValue is known to never be
2153 /// positive or negative zero.
2154 bool isKnownNeverZeroFloat(SDValue Op) const;
2155
2156 /// Test whether the given SDValue is known to contain non-zero value(s).
2157 bool isKnownNeverZero(SDValue Op, unsigned Depth = 0) const;
2158
2159 /// Test whether the given float value is known to be positive. +0.0, +inf and
2160 /// +nan are considered positive, -0.0, -inf and -nan are not.
2162
2163 /// Test whether two SDValues are known to compare equal. This
2164 /// is true if they are the same value, or if one is negative zero and the
2165 /// other positive zero.
2166 bool isEqualTo(SDValue A, SDValue B) const;
2167
2168 /// Return true if A and B have no common bits set. As an example, this can
2169 /// allow an 'add' to be transformed into an 'or'.
2170 bool haveNoCommonBitsSet(SDValue A, SDValue B) const;
2171
2172 /// Test whether \p V has a splatted value for all the demanded elements.
2173 ///
2174 /// On success \p UndefElts will indicate the elements that have UNDEF
2175 /// values instead of the splat value, this is only guaranteed to be correct
2176 /// for \p DemandedElts.
2177 ///
2178 /// NOTE: The function will return true for a demanded splat of UNDEF values.
2179 bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts,
2180 unsigned Depth = 0) const;
2181
2182 /// Test whether \p V has a splatted value.
2183 bool isSplatValue(SDValue V, bool AllowUndefs = false) const;
2184
2185 /// If V is a splatted value, return the source vector and its splat index.
2186 SDValue getSplatSourceVector(SDValue V, int &SplatIndex);
2187
2188 /// If V is a splat vector, return its scalar source operand by extracting
2189 /// that element from the source vector. If LegalTypes is true, this method
2190 /// may only return a legally-typed splat value. If it cannot legalize the
2191 /// splatted value it will return SDValue().
2192 SDValue getSplatValue(SDValue V, bool LegalTypes = false);
2193
2194 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2195 /// element bit-width of the shift node, return the valid constant range.
2196 std::optional<ConstantRange>
2197 getValidShiftAmountRange(SDValue V, const APInt &DemandedElts,
2198 unsigned Depth) const;
2199
2200 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2201 /// that is less than the element bit-width of the shift node, return it.
2202 std::optional<uint64_t> getValidShiftAmount(SDValue V,
2203 const APInt &DemandedElts,
2204 unsigned Depth = 0) const;
2205
2206 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2207 /// that is less than the element bit-width of the shift node, return it.
2208 std::optional<uint64_t> getValidShiftAmount(SDValue V,
2209 unsigned Depth = 0) const;
2210
2211 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2212 /// element bit-width of the shift node, return the minimum possible value.
2213 std::optional<uint64_t> getValidMinimumShiftAmount(SDValue V,
2214 const APInt &DemandedElts,
2215 unsigned Depth = 0) const;
2216
2217 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2218 /// element bit-width of the shift node, return the minimum possible value.
2219 std::optional<uint64_t> getValidMinimumShiftAmount(SDValue V,
2220 unsigned Depth = 0) const;
2221
2222 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2223 /// element bit-width of the shift node, return the maximum possible value.
2224 std::optional<uint64_t> getValidMaximumShiftAmount(SDValue V,
2225 const APInt &DemandedElts,
2226 unsigned Depth = 0) const;
2227
2228 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2229 /// element bit-width of the shift node, return the maximum possible value.
2230 std::optional<uint64_t> getValidMaximumShiftAmount(SDValue V,
2231 unsigned Depth = 0) const;
2232
2233 /// Match a binop + shuffle pyramid that represents a horizontal reduction
2234 /// over the elements of a vector starting from the EXTRACT_VECTOR_ELT node /p
2235 /// Extract. The reduction must use one of the opcodes listed in /p
2236 /// CandidateBinOps and on success /p BinOp will contain the matching opcode.
2237 /// Returns the vector that is being reduced on, or SDValue() if a reduction
2238 /// was not matched. If \p AllowPartials is set then in the case of a
2239 /// reduction pattern that only matches the first few stages, the extracted
2240 /// subvector of the start of the reduction is returned.
2242 ArrayRef<ISD::NodeType> CandidateBinOps,
2243 bool AllowPartials = false);
2244
2245 /// Utility function used by legalize and lowering to
2246 /// "unroll" a vector operation by splitting out the scalars and operating
2247 /// on each element individually. If the ResNE is 0, fully unroll the vector
2248 /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
2249 /// If the ResNE is greater than the width of the vector op, unroll the
2250 /// vector op and fill the end of the resulting vector with UNDEFS.
2251 SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
2252
2253 /// Like UnrollVectorOp(), but for the [US](ADD|SUB|MUL)O family of opcodes.
2254 /// This is a separate function because those opcodes have two results.
2255 std::pair<SDValue, SDValue> UnrollVectorOverflowOp(SDNode *N,
2256 unsigned ResNE = 0);
2257
2258 /// Return true if loads are next to each other and can be
2259 /// merged. Check that both are nonvolatile and if LD is loading
2260 /// 'Bytes' bytes from a location that is 'Dist' units away from the
2261 /// location that the 'Base' load is loading from.
2263 unsigned Bytes, int Dist) const;
2264
2265 /// Infer alignment of a load / store address. Return std::nullopt if it
2266 /// cannot be inferred.
2268
2269 /// Split the scalar node with EXTRACT_ELEMENT using the provided VTs and
2270 /// return the low/high part.
2271 std::pair<SDValue, SDValue> SplitScalar(const SDValue &N, const SDLoc &DL,
2272 const EVT &LoVT, const EVT &HiVT);
2273
2274 /// Compute the VTs needed for the low/hi parts of a type
2275 /// which is split (or expanded) into two not necessarily identical pieces.
2276 std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const;
2277
2278 /// Compute the VTs needed for the low/hi parts of a type, dependent on an
2279 /// enveloping VT that has been split into two identical pieces. Sets the
2280 /// HisIsEmpty flag when hi type has zero storage size.
2281 std::pair<EVT, EVT> GetDependentSplitDestVTs(const EVT &VT, const EVT &EnvVT,
2282 bool *HiIsEmpty) const;
2283
2284 /// Split the vector with EXTRACT_SUBVECTOR using the provided
2285 /// VTs and return the low/high part.
2286 std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL,
2287 const EVT &LoVT, const EVT &HiVT);
2288
2289 /// Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
2290 std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
2291 EVT LoVT, HiVT;
2292 std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
2293 return SplitVector(N, DL, LoVT, HiVT);
2294 }
2295
2296 /// Split the explicit vector length parameter of a VP operation.
2297 std::pair<SDValue, SDValue> SplitEVL(SDValue N, EVT VecVT, const SDLoc &DL);
2298
2299 /// Split the node's operand with EXTRACT_SUBVECTOR and
2300 /// return the low/high part.
2301 std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
2302 {
2303 return SplitVector(N->getOperand(OpNo), SDLoc(N));
2304 }
2305
2306 /// Widen the vector up to the next power of two using INSERT_SUBVECTOR.
2307 SDValue WidenVector(const SDValue &N, const SDLoc &DL);
2308
2309 /// Append the extracted elements from Start to Count out of the vector Op in
2310 /// Args. If Count is 0, all of the elements will be extracted. The extracted
2311 /// elements will have type EVT if it is provided, and otherwise their type
2312 /// will be Op's element type.
2314 unsigned Start = 0, unsigned Count = 0,
2315 EVT EltVT = EVT());
2316
2317 /// Compute the default alignment value for the given type.
2318 Align getEVTAlign(EVT MemoryVT) const;
2319
2320 /// Test whether the given value is a constant int or similar node.
2322 bool AllowOpaques = true) const;
2323
2324 /// Test whether the given value is a constant FP or similar node.
2326
2327 /// \returns true if \p N is any kind of constant or build_vector of
2328 /// constants, int or float. If a vector, it may not necessarily be a splat.
2332 }
2333
2334 /// Check if a value \op N is a constant using the target's BooleanContent for
2335 /// its type.
2336 std::optional<bool> isBoolConstant(SDValue N,
2337 bool AllowTruncation = false) const;
2338
2339 /// Set CallSiteInfo to be associated with Node.
2341 SDEI[Node].CSInfo = std::move(CallInfo);
2342 }
2343 /// Return CallSiteInfo associated with Node, or a default if none exists.
2345 auto I = SDEI.find(Node);
2346 return I != SDEI.end() ? std::move(I->second).CSInfo : CallSiteInfo();
2347 }
2348 /// Set HeapAllocSite to be associated with Node.
2350 SDEI[Node].HeapAllocSite = MD;
2351 }
2352 /// Return HeapAllocSite associated with Node, or nullptr if none exists.
2354 auto I = SDEI.find(Node);
2355 return I != SDEI.end() ? I->second.HeapAllocSite : nullptr;
2356 }
2357 /// Set PCSections to be associated with Node.
2358 void addPCSections(const SDNode *Node, MDNode *MD) {
2359 SDEI[Node].PCSections = MD;
2360 }
2361 /// Set MMRAMetadata to be associated with Node.
2362 void addMMRAMetadata(const SDNode *Node, MDNode *MMRA) {
2363 SDEI[Node].MMRA = MMRA;
2364 }
2365 /// Return PCSections associated with Node, or nullptr if none exists.
2367 auto It = SDEI.find(Node);
2368 return It != SDEI.end() ? It->second.PCSections : nullptr;
2369 }
2370 /// Return the MMRA MDNode associated with Node, or nullptr if none
2371 /// exists.
2373 auto It = SDEI.find(Node);
2374 return It != SDEI.end() ? It->second.MMRA : nullptr;
2375 }
2376 /// Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
2377 void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) {
2378 if (NoMerge)
2379 SDEI[Node].NoMerge = NoMerge;
2380 }
2381 /// Return NoMerge info associated with Node.
2382 bool getNoMergeSiteInfo(const SDNode *Node) const {
2383 auto I = SDEI.find(Node);
2384 return I != SDEI.end() ? I->second.NoMerge : false;
2385 }
2386
2387 /// Copy extra info associated with one node to another.
2388 void copyExtraInfo(SDNode *From, SDNode *To);
2389
2390 /// Return the current function's default denormal handling kind for the given
2391 /// floating point type.
2393 return MF->getDenormalMode(VT.getFltSemantics());
2394 }
2395
2396 bool shouldOptForSize() const;
2397
2398 /// Get the (commutative) neutral element for the given opcode, if it exists.
2399 SDValue getNeutralElement(unsigned Opcode, const SDLoc &DL, EVT VT,
2400 SDNodeFlags Flags);
2401
2402 /// Some opcodes may create immediate undefined behavior when used with some
2403 /// values (integer division-by-zero for example). Therefore, these operations
2404 /// are not generally safe to move around or change.
2405 bool isSafeToSpeculativelyExecute(unsigned Opcode) const {
2406 switch (Opcode) {
2407 case ISD::SDIV:
2408 case ISD::SREM:
2409 case ISD::SDIVREM:
2410 case ISD::UDIV:
2411 case ISD::UREM:
2412 case ISD::UDIVREM:
2413 return false;
2414 default:
2415 return true;
2416 }
2417 }
2418
2419 /// Check if the provided node is save to speculatively executed given its
2420 /// current arguments. So, while `udiv` the opcode is not safe to
2421 /// speculatively execute, a given `udiv` node may be if the denominator is
2422 /// known nonzero.
2424 switch (N->getOpcode()) {
2425 case ISD::UDIV:
2426 return isKnownNeverZero(N->getOperand(1));
2427 default:
2428 return isSafeToSpeculativelyExecute(N->getOpcode());
2429 }
2430 }
2431
2433 const SDLoc &DLoc);
2434
2435private:
2436 void InsertNode(SDNode *N);
2437 bool RemoveNodeFromCSEMaps(SDNode *N);
2438 void AddModifiedNodeToCSEMaps(SDNode *N);
2439 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
2440 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
2441 void *&InsertPos);
2442 SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops,
2443 void *&InsertPos);
2444 SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc);
2445
2446 void DeleteNodeNotInCSEMaps(SDNode *N);
2447 void DeallocateNode(SDNode *N);
2448
2449 void allnodes_clear();
2450
2451 /// Look up the node specified by ID in CSEMap. If it exists, return it. If
2452 /// not, return the insertion token that will make insertion faster. This
2453 /// overload is for nodes other than Constant or ConstantFP, use the other one
2454 /// for those.
2455 SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos);
2456
2457 /// Look up the node specified by ID in CSEMap. If it exists, return it. If
2458 /// not, return the insertion token that will make insertion faster. Performs
2459 /// additional processing for constant nodes.
2460 SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, const SDLoc &DL,
2461 void *&InsertPos);
2462
2463 /// Maps to auto-CSE operations.
2464 std::vector<CondCodeSDNode*> CondCodeNodes;
2465
2466 std::vector<SDNode*> ValueTypeNodes;
2467 std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
2468 StringMap<SDNode*> ExternalSymbols;
2469
2470 std::map<std::pair<std::string, unsigned>, SDNode *> TargetExternalSymbols;
2472
2473 FlagInserter *Inserter = nullptr;
2474};
2475
2476template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
2478
2480 return nodes_iterator(G->allnodes_begin());
2481 }
2482
2484 return nodes_iterator(G->allnodes_end());
2485 }
2486};
2487
2488} // end namespace llvm
2489
2490#endif // LLVM_CODEGEN_SELECTIONDAG_H
aarch64 AArch64 CCMP Pass
This file defines the StringMap class.
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Function Alias Analysis Results
This file defines the BumpPtrAllocator interface.
BlockVerifier::State From
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
RelocType Type
Definition: COFFYAML.cpp:410
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition: Compiler.h:622
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
uint32_t Index
uint64_t Size
Symbol * Sym
Definition: ELF_riscv.cpp:479
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
This file defines a hash set that can be used to remove duplication of nodes in a graph.
Hexagon Vector Combine
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
unsigned Reg
This file contains the declarations for metadata subclasses.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
This file defines the SmallVector class.
static void removeOperands(MachineInstr &MI, unsigned i)
Value * RHS
Value * LHS
Class for arbitrary precision integers.
Definition: APInt.h:78
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:253
static Capacity get(size_t N)
Get the capacity of an array that can hold at least N elements.
Definition: ArrayRecycler.h:79
Recycle small arrays allocated from a BumpPtrAllocator.
Definition: ArrayRecycler.h:28
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
The address of a basic block.
Definition: Constants.h:893
BlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate IR basic block frequen...
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:66
This class represents a function call, abstracting a target machine's calling convention.
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:271
This is the shared class of boolean and integer constants.
Definition: Constants.h:83
This is an important base class in LLVM.
Definition: Constant.h:42
This class represents an Operation in the Expression.
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:63
A debug info location.
Definition: DebugLoc.h:33
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:156
iterator end()
Definition: DenseMap.h:84
Implements a dense probed hash-table based set.
Definition: DenseSet.h:278
Node - This class is used to maintain the singly linked bucket list in a folding set.
Definition: FoldingSet.h:138
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID,...
Definition: FoldingSet.h:290
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:327
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
Definition: FoldingSet.h:536
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Data structure describing the variable locations in a function.
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:67
This class is used to represent ISD::LOAD nodes.
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
Metadata node.
Definition: Metadata.h:1069
Abstract base class for all machine specific constantpool value subclasses.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
DenormalMode getDenormalMode(const fltSemantics &FPType) const
Returns the denormal handling type for the default rounding mode of the function.
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
The optimization diagnostic interface.
Pass interface - Implemented by all 'passes'.
Definition: Pass.h:94
Analysis providing profile information.
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Keeps track of dbg_value information through SDISel.
Definition: SelectionDAG.h:162
BumpPtrAllocator & getAlloc()
Definition: SelectionDAG.h:191
DbgIterator ByvalParmDbgBegin()
Definition: SelectionDAG.h:209
DbgIterator DbgEnd()
Definition: SelectionDAG.h:208
SDDbgInfo & operator=(const SDDbgInfo &)=delete
SmallVectorImpl< SDDbgLabel * >::iterator DbgLabelIterator
Definition: SelectionDAG.h:205
SDDbgInfo()=default
void add(SDDbgValue *V, bool isParameter)
bool empty() const
Definition: SelectionDAG.h:193
DbgLabelIterator DbgLabelEnd()
Definition: SelectionDAG.h:212
DbgIterator ByvalParmDbgEnd()
Definition: SelectionDAG.h:210
SmallVectorImpl< SDDbgValue * >::iterator DbgIterator
Definition: SelectionDAG.h:204
SDDbgInfo(const SDDbgInfo &)=delete
DbgLabelIterator DbgLabelBegin()
Definition: SelectionDAG.h:211
void add(SDDbgLabel *L)
Definition: SelectionDAG.h:177
DbgIterator DbgBegin()
Definition: SelectionDAG.h:207
void erase(const SDNode *Node)
Invalidate all DbgValues attached to the node and remove it from the Node-to-DbgValues map.
ArrayRef< SDDbgValue * > getSDDbgValues(const SDNode *Node) const
Definition: SelectionDAG.h:197
Holds the information from a dbg_label node through SDISel.
Holds the information from a dbg_value node through SDISel.
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
Represents one node in the SelectionDAG.
SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num)
Definition: SelectionDAG.h:115
SDVTList getSDVTList()
Definition: SelectionDAG.h:120
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
SDNode * getNode() const
get the SDNode which holds the desired result
EVT getValueType() const
Return the ValueType of the referenced return value.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
Help to insert SDNodeFlags automatically in transforming.
Definition: SelectionDAG.h:369
SDNodeFlags getFlags() const
Definition: SelectionDAG.h:387
FlagInserter(SelectionDAG &SDAG, SDNodeFlags Flags)
Definition: SelectionDAG.h:375
FlagInserter(const FlagInserter &)=delete
FlagInserter(SelectionDAG &SDAG, SDNode *N)
Definition: SelectionDAG.h:380
FlagInserter & operator=(const FlagInserter &)=delete
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:228
bool willNotOverflowAdd(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the addition of 2 nodes can never overflow.
static unsigned getOpcode_EXTEND_VECTOR_INREG(unsigned Opcode)
Convert *_EXTEND to *_EXTEND_VECTOR_INREG opcode.
Definition: SelectionDAG.h:950
Align getReducedAlign(EVT VT, bool UseABI)
In most cases this function returns the ABI alignment for a given type, except for illegal vector typ...
SDValue getVPZeroExtendInReg(SDValue Op, SDValue Mask, SDValue EVL, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op)
Return the specified value casted to the target's desired shift amount type.
SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getExtLoadVP(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment, MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo, bool IsExpanding=false)
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:748
SDValue getExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT, unsigned Opcode)
Convert Op, which must be of integer type, to the integer type VT, by either any/sign/zero-extending ...
Definition: SelectionDAG.h:980
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT, SDValue Glue)
Definition: SelectionDAG.h:834
SDValue getSplatSourceVector(SDValue V, int &SplatIndex)
If V is a splatted value, return the source vector and its splat index.
SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root, MCSymbol *Label)
OverflowKind computeOverflowForUnsignedSub(SDValue N0, SDValue N1) const
Determine if the result of the unsigned sub of 2 nodes can overflow.
unsigned ComputeMaxSignificantBits(SDValue Op, unsigned Depth=0) const
Get the upper bound on bit size for this Value Op as a signed integer.
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
Definition: SelectionDAG.h:575
SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType, ISD::LoadExtType ExtTy)
bool isKnownNeverSNaN(SDValue Op, unsigned Depth=0) const
SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
Return an AddrSpaceCastSDNode.
SDValue getStackArgumentTokenFactor(SDValue Chain)
Compute a TokenFactor to force all the incoming stack arguments to be loaded from the stack.
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:497
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
Definition: SelectionDAG.h:799
const Pass * getPass() const
Definition: SelectionDAG.h:491
SDValue getMergeValues(ArrayRef< SDValue > Ops, const SDLoc &dl)
Create a MERGE_VALUES node from the given operands.
SDVTList getVTList(EVT VT)
Return an SDVTList that represents the list of values specified.
OptimizationRemarkEmitter & getORE() const
Definition: SelectionDAG.h:509
BlockFrequencyInfo * getBFI() const
Definition: SelectionDAG.h:511
SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
void updateDivergence(SDNode *N)
SDValue getSplatValue(SDValue V, bool LegalTypes=false)
If V is a splat vector, return its scalar source operand by extracting that element from the source v...
SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, const SDLoc &dl)
Constant fold a setcc to true or false.
SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
MachineSDNode * getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT)
These are used for target selectors to create a new node with specified return type(s),...
void ExtractVectorElements(SDValue Op, SmallVectorImpl< SDValue > &Args, unsigned Start=0, unsigned Count=0, EVT EltVT=EVT())
Append the extracted elements from Start to Count out of the vector Op in Args.
SDValue getNeutralElement(unsigned Opcode, const SDLoc &DL, EVT VT, SDNodeFlags Flags)
Get the (commutative) neutral element for the given opcode, if it exists.
SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Value, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo)
bool LegalizeVectors()
This transforms the SelectionDAG into a SelectionDAG that only uses vector math operations supported ...
SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:737
SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm, bool ConstantFold=true)
Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
SDValue getPseudoProbeNode(const SDLoc &Dl, SDValue Chain, uint64_t Guid, uint64_t Index, uint32_t Attr)
Creates a PseudoProbeSDNode with function GUID Guid and the index of the block Index it is probing,...
SDValue getFreeze(SDValue V)
Return a freeze using the SDLoc of the value operand.
SDNode * SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT)
These are used for target selectors to mutate the specified node to have the specified return type,...
SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), AAResults *AA=nullptr)
SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, MachinePointerInfo DstPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getBitcastedSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by first bitcasting (from potentia...
SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
SDValue getStridedLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &DL, SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Stride, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, bool IsExpanding=false)
SDDbgInfo::DbgIterator ByvalParmDbgEnd() const
SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO)
Gets a node for an atomic cmpxchg op.
MachineModuleInfo * getMMI() const
Definition: SelectionDAG.h:512
SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain)
If an existing load has uses of its chain, create a token factor node with that chain and the new mem...
bool isConstantIntBuildVectorOrConstantInt(SDValue N, bool AllowOpaques=true) const
Test whether the given value is a constant int or similar node.
SDDbgValue * getVRegDbgValue(DIVariable *Var, DIExpression *Expr, unsigned VReg, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a VReg SDDbgValue node.
void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
SDValue getJumpTableDebugInfo(int JTI, SDValue Chain, const SDLoc &DL)
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false)
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
SDValue getSymbolFunctionGlobalAddress(SDValue Op, Function **TargetFunction=nullptr)
Return a GlobalAddress of the function from the current module with name matching the given ExternalS...
bool isSafeToSpeculativelyExecute(unsigned Opcode) const
Some opcodes may create immediate undefined behavior when used with some values (integer division-by-...
void addMMRAMetadata(const SDNode *Node, MDNode *MMRA)
Set MMRAMetadata to be associated with Node.
OverflowKind computeOverflowForSub(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the sub of 2 nodes can overflow.
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, MachineFunctionAnalysisManager &AM, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs)
Definition: SelectionDAG.h:473
SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
SDDbgInfo::DbgIterator ByvalParmDbgBegin() const
void setFunctionLoweringInfo(FunctionLoweringInfo *FuncInfo)
Definition: SelectionDAG.h:482
SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT, bool isTarget=false)
Create a ConstantFPSDNode wrapping a constant value.
OverflowKind
Used to represent the possible overflow behavior of an operation.
static unsigned getHasPredecessorMaxSteps()
bool haveNoCommonBitsSet(SDValue A, SDValue B) const
Return true if A and B have no common bits set.
bool cannotBeOrderedNegativeFP(SDValue Op) const
Test whether the given float value is known to be positive.
SDValue getRegister(Register Reg, EVT VT)
bool calculateDivergence(SDNode *N)
SDValue getElementCount(const SDLoc &DL, EVT VT, ElementCount EC, bool ConstantFold=true)
SDValue getGetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr, EVT MemVT, MachineMemOperand *MMO)
SDValue getAssertAlign(const SDLoc &DL, SDValue V, Align A)
Return an AssertAlignSDNode.
SDNode * mutateStrictFPToFP(SDNode *Node)
Mutate the specified strict FP node to its non-strict equivalent, unlinking the node from its chain a...
SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
Loads are not normal binary operators: their result type is not determined by their operands,...
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
SDValue getBitcastedZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by first bitcasting (from potentia...
SelectionDAG(const SelectionDAG &)=delete
SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal)
Returns a vector of type ResVT whose elements contain the linear sequence <0, Step,...
bool willNotOverflowSub(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the sub of 2 nodes can never overflow.
SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain, SDValue Ptr, SDValue Val, MachineMemOperand *MMO)
Gets a node for an atomic op, produces result (if relevant) and chain and takes 2 operands.
std::optional< uint64_t > getValidMinimumShiftAmount(SDValue V, const APInt &DemandedElts, unsigned Depth=0) const
If a SHL/SRA/SRL node V has shift amounts that are all less than the element bit-width of the shift n...
Align getEVTAlign(EVT MemoryVT) const
Compute the default alignment value for the given type.
void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge)
Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
bool shouldOptForSize() const
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
Split the node's operand with EXTRACT_SUBVECTOR and return the low/high part.
SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
SDValue getVPZExtOrTrunc(const SDLoc &DL, EVT VT, SDValue Op, SDValue Mask, SDValue EVL)
Convert a vector-predicated Op, which must be an integer vector, to the vector-type VT,...
const STC & getSubtarget() const
Definition: SelectionDAG.h:498
SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr)
const TargetLowering & getTargetLoweringInfo() const
Definition: SelectionDAG.h:501
bool isEqualTo(SDValue A, SDValue B) const
Test whether two SDValues are known to compare equal.
static constexpr unsigned MaxRecursionDepth
Definition: SelectionDAG.h:456
SDValue getStridedStoreVP(SDValue Chain, const SDLoc &DL, SDValue Val, SDValue Ptr, SDValue Offset, SDValue Stride, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
bool isGuaranteedNotToBePoison(SDValue Op, unsigned Depth=0) const
Return true if this function can prove that Op is never poison.
SDValue expandVACopy(SDNode *Node)
Expand the specified ISD::VACOPY node as the Legalize pass would.
SDValue getIndexedMaskedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SelectionDAG & operator=(const SelectionDAG &)=delete
SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:702
APInt computeVectorKnownZeroElements(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
For each demanded element of a vector, see if it is known to be zero.
void AddDbgValue(SDDbgValue *DB, bool isParameter)
Add a dbg_value SDNode.
bool NewNodesMustHaveLegalTypes
When true, additional steps are taken to ensure that getConstant() and similar functions return DAG n...
Definition: SelectionDAG.h:395
std::pair< EVT, EVT > GetSplitDestVTs(const EVT &VT) const
Compute the VTs needed for the low/hi parts of a type which is split (or expanded) into two not neces...
MDNode * getHeapAllocSite(const SDNode *Node) const
Return HeapAllocSite associated with Node, or nullptr if none exists.
void salvageDebugInfo(SDNode &N)
To be invoked on an SDNode that is slated to be erased.
SDNode * MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs, ArrayRef< SDValue > Ops)
This mutates the specified node to have the specified return type, opcode, and operands.
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags=0)
Definition: SelectionDAG.h:758
MDNode * getMMRAMetadata(const SDNode *Node) const
Return the MMRA MDNode associated with Node, or nullptr if none exists.
SDValue getLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes(), const MDNode *Ranges=nullptr, bool IsExpanding=false)
std::pair< SDValue, SDValue > UnrollVectorOverflowOp(SDNode *N, unsigned ResNE=0)
Like UnrollVectorOp(), but for the [US](ADD|SUB|MUL)O family of opcodes.
allnodes_const_iterator allnodes_begin() const
Definition: SelectionDAG.h:555
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
SDValue getCALLSEQ_END(SDValue Chain, SDValue Op1, SDValue Op2, SDValue InGlue, const SDLoc &DL)
Return a new CALLSEQ_END node, which always must have a glue result (to ensure it's not CSE'd).
SDValue getGatherVP(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Definition: SelectionDAG.h:854
SDValue getBitcastedAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by first bitcasting (from potentia...
allnodes_const_iterator allnodes_end() const
Definition: SelectionDAG.h:556
bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts, unsigned Depth=0) const
Test whether V has a splatted value for all the demanded elements.
void DeleteNode(SDNode *N)
Remove the specified node from the system.
SDValue getBitcast(EVT VT, SDValue V)
Return a bitcast using the SDLoc of the value operand, and casting to the provided type.
SDDbgValue * getDbgValueList(DIVariable *Var, DIExpression *Expr, ArrayRef< SDDbgOperand > Locs, ArrayRef< SDNode * > Dependencies, bool IsIndirect, const DebugLoc &DL, unsigned O, bool IsVariadic)
Creates a SDDbgValue node from a list of locations.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, Register Reg, EVT VT)
Definition: SelectionDAG.h:825
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build Select's if you just have operands and don't want to check...
SDDbgInfo::DbgIterator DbgEnd() const
SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT)
Create negative operation as (SUB 0, Val).
void setNodeMemRefs(MachineSDNode *N, ArrayRef< MachineMemOperand * > NewMemRefs)
Mutate the specified machine node's memory references to the provided list.
SDValue simplifySelect(SDValue Cond, SDValue TVal, SDValue FVal)
Try to simplify a select/vselect into 1 of its operands or a constant.
CallSiteInfo getCallSiteInfo(const SDNode *Node)
Return CallSiteInfo associated with Node, or a default if none exists.
SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to zero extend the Op value assuming it was the smaller SrcTy value.
bool isConstantFPBuildVectorOrConstantFP(SDValue N) const
Test whether the given value is a constant FP or similar node.
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:495
allnodes_iterator allnodes_begin()
Definition: SelectionDAG.h:560
iterator_range< allnodes_const_iterator > allnodes() const
Definition: SelectionDAG.h:570
MDNode * getPCSections(const SDNode *Node) const
Return PCSections associated with Node, or nullptr if none exists.
ProfileSummaryInfo * getPSI() const
Definition: SelectionDAG.h:510
SDValue expandVAArg(SDNode *Node)
Expand the specified ISD::VAARG node as the Legalize pass would.
SDValue getTargetFrameIndex(int FI, EVT VT)
Definition: SelectionDAG.h:753
void Legalize()
This transforms the SelectionDAG into a SelectionDAG that is compatible with the target instruction s...
SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl< SDValue > &Vals)
Creates a new TokenFactor containing Vals.
void setGraphAttrs(const SDNode *N, const char *Attrs)
Set graph attributes for a node. (eg. "color=red".)
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, SDValue Reg, SDValue N, SDValue Glue)
Definition: SelectionDAG.h:817
bool LegalizeOp(SDNode *N, SmallSetVector< SDNode *, 16 > &UpdatedNodes)
Transforms a SelectionDAG node and any operands to it into a node that is compatible with the target ...
bool doesNodeExist(unsigned Opcode, SDVTList VTList, ArrayRef< SDValue > Ops)
Check if a node exists without modifying its flags.
void addHeapAllocSite(const SDNode *Node, MDNode *MD)
Set HeapAllocSite to be associated with Node.
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
Definition: SelectionDAG.h:503
bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
Return true if loads are next to each other and can be merged.
SDValue getMaskedHistogram(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), AAResults *AA=nullptr)
SDDbgLabel * getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O)
Creates a SDDbgLabel node.
SDValue getTargetConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:706
SDValue getStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL)
Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
OverflowKind computeOverflowForUnsignedMul(SDValue N0, SDValue N1) const
Determine if the result of the unsigned mul of 2 nodes can overflow.
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N, SDValue Glue)
Definition: SelectionDAG.h:808
void copyExtraInfo(SDNode *From, SDNode *To)
Copy extra info associated with one node to another.
SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getMemBasePlusOffset(SDValue Base, TypeSize Offset, const SDLoc &DL, const SDNodeFlags Flags=SDNodeFlags())
Returns sum of the base pointer and offset.
SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, bool isTargetGA=false, unsigned TargetFlags=0)
bool willNotOverflowMul(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the mul of 2 nodes can never overflow.
SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:710
SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue SV, unsigned Align)
VAArg produces a result and token chain, and takes a pointer and a source value as input.
OverflowKind computeOverflowForMul(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the mul of 2 nodes can overflow.
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getMDNode(const MDNode *MD)
Return an MDNodeSDNode which holds an MDNode.
void clear()
Clear state and free memory necessary to make this SelectionDAG ready to process a new block.
SDValue getCALLSEQ_END(SDValue Chain, uint64_t Size1, uint64_t Size2, SDValue Glue, const SDLoc &DL)
void ReplaceAllUsesWith(SDValue From, SDValue To)
Modify anything using 'From' to use 'To' instead.
SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV)
Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to the shuffle node in input but with swa...
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the vector with EXTRACT_SUBVECTOR using the provided VTs and return the low/high part.
SDValue makeStateFunctionCall(unsigned LibFunc, SDValue Ptr, SDValue InChain, const SDLoc &DLoc)
Helper used to make a call to a library function that has one argument of pointer type.
bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, bool PoisonOnly=false, unsigned Depth=0) const
Return true if this function can prove that Op is never poison and, if PoisonOnly is false,...
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
Helper function to build ISD::STORE nodes.
SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
SDValue getIndexedLoadVP(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SDValue getSrcValue(const Value *v)
Construct a node to track a Value* through the backend.
SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op)
Definition: SelectionDAG.h:888
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, MaybeAlign Alignment=std::nullopt, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, LocationSize Size=0, const AAMDNodes &AAInfo=AAMDNodes())
SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
OverflowKind computeOverflowForSignedMul(SDValue N0, SDValue N1) const
Determine if the result of the signed mul of 2 nodes can overflow.
MaybeAlign InferPtrAlign(SDValue Ptr) const
Infer alignment of a load / store address.
FlagInserter * getFlagInserter()
Definition: SelectionDAG.h:514
bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if '(Op & Mask) == Mask'.
SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize, const SDLoc &DL)
Return a new CALLSEQ_START node, that starts new call frame, in which InSize bytes are set up inside ...
bool hasDebugValues() const
Return true if there are any SDDbgValue nodes associated with this SelectionDAG.
bool SignBitIsZero(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero.
void RemoveDeadNodes()
This method deletes all unreachable nodes in the SelectionDAG.
void RemoveDeadNode(SDNode *N)
Remove the specified node from the system.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDUse > Ops)
Return an ISD::BUILD_VECTOR node.
Definition: SelectionDAG.h:863
void AddDbgLabel(SDDbgLabel *DB)
Add a dbg_label SDNode.
bool isConstantValueOfAnyType(SDValue N) const
SDDbgInfo::DbgLabelIterator DbgLabelEnd() const
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const AAMDNodes &AAInfo=AAMDNodes())
allnodes_iterator allnodes_end()
Definition: SelectionDAG.h:561
SDDbgInfo::DbgLabelIterator DbgLabelBegin() const
SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand)
A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
SDValue getBasicBlock(MachineBasicBlock *MBB)
MachineFunctionAnalysisManager * getMFAM()
Definition: SelectionDAG.h:492
SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
bool isKnownToBeAPowerOfTwo(SDValue Val, unsigned Depth=0) const
Test if the given value is known to have exactly one bit set.
SDValue getPartialReduceAdd(SDLoc DL, EVT ReducedTy, SDValue Op1, SDValue Op2)
Create the DAG equivalent of vector_partial_reduce where Op1 and Op2 are its operands and ReducedTY i...
SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label)
std::string getGraphAttrs(const SDNode *N) const
Get graph attributes for a node.
SDValue getIndexedStoreVP(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
bool isKnownNeverZero(SDValue Op, unsigned Depth=0) const
Test whether the given SDValue is known to contain non-zero value(s).
SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops, SDNodeFlags Flags=SDNodeFlags())
SDValue getSetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr, EVT MemVT, MachineMemOperand *MMO)
SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT)
Convert Op, which must be of integer type, to the integer type VT, by using an extension appropriate ...
SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Base, SDValue Offset, SDValue Mask, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
SDValue getExternalSymbol(const char *Sym, EVT VT)
const TargetMachine & getTarget() const
Definition: SelectionDAG.h:496
bool getNoMergeSiteInfo(const SDNode *Node) const
Return NoMerge info associated with Node.
std::pair< SDValue, SDValue > getStrictFPExtendOrRound(SDValue Op, SDValue Chain, const SDLoc &DL, EVT VT)
Convert Op, which must be a STRICT operation of float type, to the float type VT, by either extending...
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, SDValue Offset)
std::pair< SDValue, SDValue > SplitEVL(SDValue N, EVT VecVT, const SDLoc &DL)
Split the explicit vector length parameter of a VP operation.
SDValue getPtrExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either truncating it or perform...
SDValue getVPLogicalNOT(const SDLoc &DL, SDValue Val, SDValue Mask, SDValue EVL, EVT VT)
Create a vector-predicated logical NOT operation as (VP_XOR Val, BooleanOne, Mask,...
SDDbgInfo::DbgIterator DbgBegin() const
SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either any-extending or truncat...
iterator_range< allnodes_iterator > allnodes()
Definition: SelectionDAG.h:567
OverflowKind computeOverflowForAdd(bool IsSigned, SDValue N0, SDValue N1) const
Determine if the result of the addition of 2 nodes can overflow.
SDValue getBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, bool isTarget=false, unsigned TargetFlags=0)
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
bool isKnownNeverZeroFloat(SDValue Op) const
Test whether the given floating point SDValue is known to never be positive or negative zero.
SDValue getLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment, MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo, const MDNode *Ranges=nullptr, bool IsExpanding=false)
SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
SDDbgValue * getConstantDbgValue(DIVariable *Var, DIExpression *Expr, const Value *C, const DebugLoc &DL, unsigned O)
Creates a constant SDDbgValue node.
SDValue getScatterVP(SDVTList VTs, EVT VT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
SDValue getValueType(EVT)
SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:734
ArrayRef< SDDbgValue * > GetDbgValues(const SDNode *SD) const
Get the debug values which reference the given SDNode.
SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDUse > Ops)
Gets or creates the specified node.
OverflowKind computeOverflowForSignedAdd(SDValue N0, SDValue N1) const
Determine if the result of the signed addition of 2 nodes can overflow.
SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of float type, to the float type VT, by either extending or rounding (by tr...
unsigned AssignTopologicalOrder()
Topological-sort the AllNodes list and a assign a unique node id for each node in the DAG based on th...
ilist< SDNode >::size_type allnodes_size() const
Definition: SelectionDAG.h:563
ilist< SDNode >::const_iterator allnodes_const_iterator
Definition: SelectionDAG.h:553
SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
bool isKnownNeverNaN(SDValue Op, bool SNaN=false, unsigned Depth=0) const
Test whether the given SDValue (or all elements of it, if it is a vector) is known to never be NaN.
SDValue getIndexedMaskedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags, const AAMDNodes &AAInfo, bool IsCompressing=false)
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:698
const TargetLibraryInfo & getLibInfo() const
Definition: SelectionDAG.h:502
unsigned ComputeNumSignBits(SDValue Op, unsigned Depth=0) const
Return the number of times the sign bit of the register is replicated into the other bits.
bool MaskedVectorIsZero(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
Return true if 'Op' is known to be zero in DemandedElts.
SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT)
Create a true or false constant of type VT using the target's BooleanContent for type OpVT.
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:794
SDDbgValue * getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr, unsigned FI, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a FrameIndex SDDbgValue node.
const UniformityInfo * getUniformityInfo() const
Definition: SelectionDAG.h:504
SDValue getExtStridedLoadVP(ISD::LoadExtType ExtType, const SDLoc &DL, EVT VT, SDValue Chain, SDValue Ptr, SDValue Stride, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, bool IsExpanding=false)
CodeGenOptLevel getOptLevel() const
Definition: SelectionDAG.h:494
SDValue getJumpTable(int JTI, EVT VT, bool isTarget=false, unsigned TargetFlags=0)
bool isBaseWithConstantOffset(SDValue Op) const
Return true if the specified operand is an ISD::ADD with a ConstantSDNode on the right-hand side,...
SDValue getVPPtrExtOrTrunc(const SDLoc &DL, EVT VT, SDValue Op, SDValue Mask, SDValue EVL)
Convert a vector-predicated Op, which must be of integer type, to the vector-type integer type VT,...
SDValue getVectorIdxConstant(uint64_t Val, const SDLoc &DL, bool isTarget=false)
void ReplaceAllUsesOfValueWith(SDValue From, SDValue To)
Replace any uses of From with To, leaving uses of other values produced by From.getNode() alone.
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:490
SDValue getPtrExtendInReg(SDValue Op, const SDLoc &DL, EVT VT)
Return the expression required to extend the Op as a pointer value assuming it was the smaller SrcTy ...
bool canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts, bool PoisonOnly=false, bool ConsiderFlags=true, unsigned Depth=0) const
Return true if Op can create undef or poison from non-undef & non-poison operands.
OverflowKind computeOverflowForUnsignedAdd(SDValue N0, SDValue N1) const
Determine if the result of the unsigned addition of 2 nodes can overflow.
void setFlagInserter(FlagInserter *FI)
Definition: SelectionDAG.h:515
std::optional< uint64_t > getValidMaximumShiftAmount(SDValue V, const APInt &DemandedElts, unsigned Depth=0) const
If a SHL/SRA/SRL node V has shift amounts that are all less than the element bit-width of the shift n...
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements.
Definition: SelectionDAG.h:871
bool isSafeToSpeculativelyExecuteNode(const SDNode *N) const
Check if the provided node is save to speculatively executed given its current arguments.
SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
SDValue getTruncStridedStoreVP(SDValue Chain, const SDLoc &DL, SDValue Val, SDValue Ptr, SDValue Stride, SDValue Mask, SDValue EVL, EVT SVT, MachineMemOperand *MMO, bool IsCompressing=false)
const FunctionVarLocs * getFunctionVarLocs() const
Returns the result of the AssignmentTrackingAnalysis pass if it's available, otherwise return nullptr...
Definition: SelectionDAG.h:507
void canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1, SDValue &N2) const
Swap N1 and N2 if Opcode is a commutative binary opcode and the canonical form expects the opposite o...
KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
SDValue getRegisterMask(const uint32_t *RegMask)
SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
SDValue getCondCode(ISD::CondCode Cond)
SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain, int FrameIndex, int64_t Size, int64_t Offset=-1)
Creates a LifetimeSDNode that starts (IsStart==true) or ends (IsStart==false) the lifetime of the por...
void addCallSiteInfo(const SDNode *Node, CallSiteInfo &&CallInfo)
Set CallSiteInfo to be associated with Node.
SDValue getExtOrTrunc(bool IsSigned, SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign/zero-extending (dep...
Definition: SelectionDAG.h:996
bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
bool isKnownToBeAPowerOfTwoFP(SDValue Val, unsigned Depth=0) const
Test if the given fp value is known to be an integer power-of-2, either positive or negative.
OverflowKind computeOverflowForSignedSub(SDValue N0, SDValue N1) const
Determine if the result of the signed sub of 2 nodes can overflow.
bool expandMultipleResultFPLibCall(RTLIB::Libcall LC, SDNode *Node, SmallVectorImpl< SDValue > &Results, std::optional< unsigned > CallRetResNo={})
Expands a node with multiple results to an FP or vector libcall.
std::optional< uint64_t > getValidShiftAmount(SDValue V, const APInt &DemandedElts, unsigned Depth=0) const
If a SHL/SRA/SRL node V has a uniform shift amount that is less than the element bit-width of the shi...
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Ptr, TypeSize Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object.
LLVMContext * getContext() const
Definition: SelectionDAG.h:508
SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y, SDNodeFlags Flags)
Try to simplify a floating-point binary operation into 1 of its operands or a constant.
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
Definition: SelectionDAG.h:584
void addPCSections(const SDNode *Node, MDNode *MD)
Set PCSections to be associated with Node.
bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
Return true if this function can prove that Op is never poison.
SDValue getTargetConstantPool(MachineConstantPoolValue *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:773
void clearGraphAttrs()
Clear all previously defined node graph attributes.
SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef< SDValue > Ops, EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags Flags=MachineMemOperand::MOLoad|MachineMemOperand::MOStore, LocationSize Size=0, const AAMDNodes &AAInfo=AAMDNodes())
Creates a MemIntrinsicNode that may produce a result and takes a list of operands.
SDValue getTargetExternalSymbol(const char *Sym, EVT VT, unsigned TargetFlags=0)
SDValue getMCSymbol(MCSymbol *Sym, EVT VT)
bool isUndef(unsigned Opcode, ArrayRef< SDValue > Ops)
Return true if the result of this operation is always undefined.
SDValue getSetCCVP(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Mask, SDValue EVL)
Helper function to make it easier to build VP_SETCCs if you just have an ISD::CondCode instead of an ...
SDValue CreateStackTemporary(TypeSize Bytes, Align Alignment)
Create a stack temporary based on the size in bytes and the alignment.
SDNode * UpdateNodeOperands(SDNode *N, SDValue Op)
Mutate the specified node in-place to have the specified operands.
std::pair< EVT, EVT > GetDependentSplitDestVTs(const EVT &VT, const EVT &EnvVT, bool *HiIsEmpty) const
Compute the VTs needed for the low/hi parts of a type, dependent on an enveloping VT that has been sp...
SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT, ArrayRef< SDValue > Ops)
Fold floating-point operations when all operands are constants and/or undefined.
SDNode * getNodeIfExists(unsigned Opcode, SDVTList VTList, ArrayRef< SDValue > Ops, const SDNodeFlags Flags)
Get the specified node if it's already available, or else return NULL.
SDValue getTargetConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offset=0, unsigned TargetFlags=0)
Definition: SelectionDAG.h:765
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs)
Prepare this SelectionDAG to process code in the given MachineFunction.
std::optional< ConstantRange > getValidShiftAmountRange(SDValue V, const APInt &DemandedElts, unsigned Depth) const
If a SHL/SRA/SRL node V has shift amounts that are all less than the element bit-width of the shift n...
SDValue FoldSymbolOffset(unsigned Opcode, EVT VT, const GlobalAddressSDNode *GA, const SDNode *N2)
void RepositionNode(allnodes_iterator Position, SDNode *N)
Move node N in the AllNodes list to be immediately before the given iterator Position.
std::optional< bool > isBoolConstant(SDValue N, bool AllowTruncation=false) const
Check if a value \op N is a constant using the target's BooleanContent for its type.
SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT, SDValue Operand, SDValue Subreg)
A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
Definition: SelectionDAG.h:578
SDDbgValue * getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N, unsigned R, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a SDDbgValue node.
void setSubgraphColor(SDNode *N, const char *Color)
Convenience for setting subgraph color attribute.
SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Base, SDValue Offset, SDValue Mask, SDValue Src0, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, ISD::LoadExtType, bool IsExpanding=false)
SDValue getTargetConstantFP(const ConstantFP &Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:740
DenormalMode getDenormalMode(EVT VT) const
Return the current function's default denormal handling kind for the given floating point type.
SDValue getSplat(EVT VT, const SDLoc &DL, SDValue Op)
Returns a node representing a splat of one value into all lanes of the provided vector type.
Definition: SelectionDAG.h:904
std::pair< SDValue, SDValue > SplitScalar(const SDValue &N, const SDLoc &DL, const EVT &LoVT, const EVT &HiVT)
Split the scalar node with EXTRACT_ELEMENT using the provided VTs and return the low/high part.
static unsigned getOpcode_EXTEND(unsigned Opcode)
Convert *_EXTEND_VECTOR_INREG to *_EXTEND opcode.
Definition: SelectionDAG.h:934
SDValue matchBinOpReduction(SDNode *Extract, ISD::NodeType &BinOp, ArrayRef< ISD::NodeType > CandidateBinOps, bool AllowPartials=false)
Match a binop + shuffle pyramid that represents a horizontal reduction over the elements of a vector ...
bool isADDLike(SDValue Op, bool NoWrap=false) const
Return true if the specified operand is an ISD::OR or ISD::XOR node that can be treated as an ISD::AD...
SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2, ArrayRef< int > Mask)
Return an ISD::VECTOR_SHUFFLE node.
LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title)
Just dump dot graph to a user-provided path and title.
SDValue simplifyShift(SDValue X, SDValue Y)
Try to simplify a shift into 1 of its operands or a constant.
void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits=0, unsigned SizeInBits=0, bool InvalidateDbg=true)
Transfer debug values from one node to another, while optionally generating fragment expressions for ...
SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a logical NOT operation as (XOR Val, BooleanOne).
SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType, bool IsTruncating=false)
ilist< SDNode >::iterator allnodes_iterator
Definition: SelectionDAG.h:558
bool LegalizeTypes()
This transforms the SelectionDAG into a SelectionDAG that only uses types natively supported by the t...
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:370
bool empty() const
Definition: SmallVector.h:81
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:573
typename SuperClass::iterator iterator
Definition: SmallVector.h:577
void push_back(const T &Elt)
Definition: SmallVector.h:413
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1196
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition: StringMap.h:128
Provides information about what library functions are available for the current target.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:77
TargetSubtargetInfo - Generic base class for all target subtargets.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition: Twine.h:81
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
LLVM Value Representation.
Definition: Value.h:74
pointer remove(iterator &IT)
Definition: ilist.h:188
iterator insert(iterator where, pointer New)
Definition: ilist.h:165
An intrusive list with ownership and callbacks specified/controlled by ilist_traits,...
Definition: ilist.h:328
A range adaptor for a pair of iterators.
This file defines classes to implement an intrusive doubly linked list class (i.e.
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:40
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
Definition: ISDOpcodes.h:780
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
Definition: ISDOpcodes.h:491
@ ConstantFP
Definition: ISDOpcodes.h:77
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition: ISDOpcodes.h:814
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
Definition: ISDOpcodes.h:871
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
Definition: ISDOpcodes.h:262
@ STRICT_FSETCCS
Definition: ISDOpcodes.h:492
@ SIGN_EXTEND
Conversion operators.
Definition: ISDOpcodes.h:805
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
Definition: ISDOpcodes.h:757
@ UNDEF
UNDEF - An undefined node.
Definition: ISDOpcodes.h:218
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
Definition: ISDOpcodes.h:642
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
Definition: ISDOpcodes.h:215
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
Definition: ISDOpcodes.h:209
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition: ISDOpcodes.h:811
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
Definition: ISDOpcodes.h:772
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
Definition: ISDOpcodes.h:860
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
Definition: ISDOpcodes.h:93
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Definition: ISDOpcodes.h:766
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Definition: ISDOpcodes.h:882
@ BlockAddress
Definition: ISDOpcodes.h:84
@ CALLSEQ_START
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence,...
Definition: ISDOpcodes.h:1211
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
Definition: ISDOpcodes.h:530
MemIndexType
MemIndexType enum - This enum defines how to interpret MGATHER/SCATTER's index parameter when calcula...
Definition: ISDOpcodes.h:1575
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:1562
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
Definition: ISDOpcodes.h:1613
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Definition: ISDOpcodes.h:1593
Libcall
RTLIB::Libcall enum - This enum defines all of the runtime library calls the backend can emit.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
@ Offset
Definition: DWP.cpp:480
AlignedCharArrayUnion< AtomicSDNode, TargetIndexSDNode, BlockAddressSDNode, GlobalAddressSDNode, PseudoProbeSDNode > LargestSDNode
A representation of the largest SDNode, for use in sizeof().
GenericSSAContext< Function > SSAContext
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
void checkForCycles(const SelectionDAG *DAG, bool force=false)
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition: Allocator.h:382
CodeGenOptLevel
Code generation optimization level.
Definition: CodeGen.h:54
GenericUniformityInfo< SSAContext > UniformityInfo
CombineLevel
Definition: DAGCombine.h:15
DWARFExpression::Operation Op
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
Definition: STLExtras.h:1873
Implement std::hash so that hash_code can be used in STL containers.
Definition: BitVector.h:858
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:760
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition: Alignment.h:39
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
Definition: FoldingSet.h:233
Represent subnormal handling kind for floating point instruction inputs and outputs.
Extended Value Type.
Definition: ValueTypes.h:35
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:168
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition: ValueTypes.h:174
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition: ValueTypes.h:323
const fltSemantics & getFltSemantics() const
Returns an APFloat semantics tag appropriate for the value type.
Definition: ValueTypes.cpp:320
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:331
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Definition: ValueTypes.h:303
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition: ValueTypes.h:152
static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
Definition: SelectionDAG.h:133
static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID)
Definition: SelectionDAG.h:140
static void Profile(const SDVTListNode &X, FoldingSetNodeID &ID)
Definition: SelectionDAG.h:129
FoldingSetTrait - This trait class is used to define behavior of how to "profile" (in the FoldingSet ...
Definition: FoldingSet.h:263
static nodes_iterator nodes_begin(SelectionDAG *G)
static nodes_iterator nodes_end(SelectionDAG *G)
This class contains a discriminated union of information about pointers in memory operands,...
This struct is a compact representation of a valid (power of two) or undefined (0) alignment.
Definition: Alignment.h:117
These are IR-level optimization flags that may be propagated to SDNodes.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
DAGNodeDeletedListener(SelectionDAG &DAG, std::function< void(SDNode *, SDNode *)> Callback)
Definition: SelectionDAG.h:344
void NodeDeleted(SDNode *N, SDNode *E) override
The node N that was deleted and, if E is not null, an equivalent node E that replaced it.
Definition: SelectionDAG.h:348
std::function< void(SDNode *, SDNode *)> Callback
Definition: SelectionDAG.h:342
std::function< void(SDNode *)> Callback
Definition: SelectionDAG.h:355
void NodeInserted(SDNode *N) override
The node N that was inserted.
Definition: SelectionDAG.h:361
DAGNodeInsertedListener(SelectionDAG &DAG, std::function< void(SDNode *)> Callback)
Definition: SelectionDAG.h:357
Clients of various APIs that cause global effects on the DAG can optionally implement this interface.
Definition: SelectionDAG.h:315
DAGUpdateListener *const Next
Definition: SelectionDAG.h:316
virtual void NodeDeleted(SDNode *N, SDNode *E)
The node N that was deleted and, if E is not null, an equivalent node E that replaced it.
virtual void NodeInserted(SDNode *N)
The node N that was inserted.
virtual void NodeUpdated(SDNode *N)
The node N that was updated.
static void deleteNode(SDNode *)
Definition: SelectionDAG.h:146
Use delete by default for iplist and ilist.
Definition: ilist.h:41