LLVM 19.0.0git
SelectionDAGNodes.h
Go to the documentation of this file.
1//===- llvm/CodeGen/SelectionDAGNodes.h - SelectionDAG Nodes ----*- 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 SDNode class and derived classes, which are used to
10// represent the nodes and operations present in a SelectionDAG. These nodes
11// and operations are machine code level operations, with some similarities to
12// the GCC RTL representation.
13//
14// Clients should include the SelectionDAG.h file instead of this file directly.
15//
16//===----------------------------------------------------------------------===//
17
18#ifndef LLVM_CODEGEN_SELECTIONDAGNODES_H
19#define LLVM_CODEGEN_SELECTIONDAGNODES_H
20
21#include "llvm/ADT/APFloat.h"
22#include "llvm/ADT/ArrayRef.h"
23#include "llvm/ADT/BitVector.h"
24#include "llvm/ADT/FoldingSet.h"
28#include "llvm/ADT/ilist_node.h"
29#include "llvm/ADT/iterator.h"
36#include "llvm/IR/Constants.h"
37#include "llvm/IR/DebugLoc.h"
38#include "llvm/IR/Instruction.h"
40#include "llvm/IR/Metadata.h"
41#include "llvm/IR/Operator.h"
47#include <algorithm>
48#include <cassert>
49#include <climits>
50#include <cstddef>
51#include <cstdint>
52#include <cstring>
53#include <iterator>
54#include <string>
55#include <tuple>
56#include <utility>
57
58namespace llvm {
59
60class APInt;
61class Constant;
62class GlobalValue;
63class MachineBasicBlock;
64class MachineConstantPoolValue;
65class MCSymbol;
66class raw_ostream;
67class SDNode;
68class SelectionDAG;
69class Type;
70class Value;
71
72void checkForCycles(const SDNode *N, const SelectionDAG *DAG = nullptr,
73 bool force = false);
74
75/// This represents a list of ValueType's that has been intern'd by
76/// a SelectionDAG. Instances of this simple value class are returned by
77/// SelectionDAG::getVTList(...).
78///
79struct SDVTList {
80 const EVT *VTs;
81 unsigned int NumVTs;
82};
83
84namespace ISD {
85
86 /// Node predicates
87
88/// If N is a BUILD_VECTOR or SPLAT_VECTOR node whose elements are all the
89/// same constant or undefined, return true and return the constant value in
90/// \p SplatValue.
91bool isConstantSplatVector(const SDNode *N, APInt &SplatValue);
92
93/// Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where
94/// all of the elements are ~0 or undef. If \p BuildVectorOnly is set to
95/// true, it only checks BUILD_VECTOR.
97 bool BuildVectorOnly = false);
98
99/// Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where
100/// all of the elements are 0 or undef. If \p BuildVectorOnly is set to true, it
101/// only checks BUILD_VECTOR.
103 bool BuildVectorOnly = false);
104
105/// Return true if the specified node is a BUILD_VECTOR where all of the
106/// elements are ~0 or undef.
107bool isBuildVectorAllOnes(const SDNode *N);
108
109/// Return true if the specified node is a BUILD_VECTOR where all of the
110/// elements are 0 or undef.
111bool isBuildVectorAllZeros(const SDNode *N);
112
113/// Return true if the specified node is a BUILD_VECTOR node of all
114/// ConstantSDNode or undef.
116
117/// Return true if the specified node is a BUILD_VECTOR node of all
118/// ConstantFPSDNode or undef.
120
121/// Returns true if the specified node is a vector where all elements can
122/// be truncated to the specified element size without a loss in meaning.
123bool isVectorShrinkable(const SDNode *N, unsigned NewEltSize, bool Signed);
124
125/// Return true if the node has at least one operand and all operands of the
126/// specified node are ISD::UNDEF.
127bool allOperandsUndef(const SDNode *N);
128
129/// Return true if the specified node is FREEZE(UNDEF).
130bool isFreezeUndef(const SDNode *N);
131
132} // end namespace ISD
133
134//===----------------------------------------------------------------------===//
135/// Unlike LLVM values, Selection DAG nodes may return multiple
136/// values as the result of a computation. Many nodes return multiple values,
137/// from loads (which define a token and a return value) to ADDC (which returns
138/// a result and a carry value), to calls (which may return an arbitrary number
139/// of values).
140///
141/// As such, each use of a SelectionDAG computation must indicate the node that
142/// computes it as well as which return value to use from that node. This pair
143/// of information is represented with the SDValue value type.
144///
145class SDValue {
146 friend struct DenseMapInfo<SDValue>;
147
148 SDNode *Node = nullptr; // The node defining the value we are using.
149 unsigned ResNo = 0; // Which return value of the node we are using.
150
151public:
152 SDValue() = default;
153 SDValue(SDNode *node, unsigned resno);
154
155 /// get the index which selects a specific result in the SDNode
156 unsigned getResNo() const { return ResNo; }
157
158 /// get the SDNode which holds the desired result
159 SDNode *getNode() const { return Node; }
160
161 /// set the SDNode
162 void setNode(SDNode *N) { Node = N; }
163
164 inline SDNode *operator->() const { return Node; }
165
166 bool operator==(const SDValue &O) const {
167 return Node == O.Node && ResNo == O.ResNo;
168 }
169 bool operator!=(const SDValue &O) const {
170 return !operator==(O);
171 }
172 bool operator<(const SDValue &O) const {
173 return std::tie(Node, ResNo) < std::tie(O.Node, O.ResNo);
174 }
175 explicit operator bool() const {
176 return Node != nullptr;
177 }
178
179 SDValue getValue(unsigned R) const {
180 return SDValue(Node, R);
181 }
182
183 /// Return true if this node is an operand of N.
184 bool isOperandOf(const SDNode *N) const;
185
186 /// Return the ValueType of the referenced return value.
187 inline EVT getValueType() const;
188
189 /// Return the simple ValueType of the referenced return value.
191 return getValueType().getSimpleVT();
192 }
193
194 /// Returns the size of the value in bits.
195 ///
196 /// If the value type is a scalable vector type, the scalable property will
197 /// be set and the runtime size will be a positive integer multiple of the
198 /// base size.
200 return getValueType().getSizeInBits();
201 }
202
205 }
206
207 // Forwarding methods - These forward to the corresponding methods in SDNode.
208 inline unsigned getOpcode() const;
209 inline unsigned getNumOperands() const;
210 inline const SDValue &getOperand(unsigned i) const;
211 inline uint64_t getConstantOperandVal(unsigned i) const;
212 inline const APInt &getConstantOperandAPInt(unsigned i) const;
213 inline bool isTargetMemoryOpcode() const;
214 inline bool isTargetOpcode() const;
215 inline bool isMachineOpcode() const;
216 inline bool isUndef() const;
217 inline unsigned getMachineOpcode() const;
218 inline const DebugLoc &getDebugLoc() const;
219 inline void dump() const;
220 inline void dump(const SelectionDAG *G) const;
221 inline void dumpr() const;
222 inline void dumpr(const SelectionDAG *G) const;
223
224 /// Return true if this operand (which must be a chain) reaches the
225 /// specified operand without crossing any side-effecting instructions.
226 /// In practice, this looks through token factors and non-volatile loads.
227 /// In order to remain efficient, this only
228 /// looks a couple of nodes in, it does not do an exhaustive search.
230 unsigned Depth = 2) const;
231
232 /// Return true if there are no nodes using value ResNo of Node.
233 inline bool use_empty() const;
234
235 /// Return true if there is exactly one node using value ResNo of Node.
236 inline bool hasOneUse() const;
237};
238
239template<> struct DenseMapInfo<SDValue> {
240 static inline SDValue getEmptyKey() {
241 SDValue V;
242 V.ResNo = -1U;
243 return V;
244 }
245
246 static inline SDValue getTombstoneKey() {
247 SDValue V;
248 V.ResNo = -2U;
249 return V;
250 }
251
252 static unsigned getHashValue(const SDValue &Val) {
253 return ((unsigned)((uintptr_t)Val.getNode() >> 4) ^
254 (unsigned)((uintptr_t)Val.getNode() >> 9)) + Val.getResNo();
255 }
256
257 static bool isEqual(const SDValue &LHS, const SDValue &RHS) {
258 return LHS == RHS;
259 }
260};
261
262/// Allow casting operators to work directly on
263/// SDValues as if they were SDNode*'s.
264template<> struct simplify_type<SDValue> {
266
268 return Val.getNode();
269 }
270};
271template<> struct simplify_type<const SDValue> {
272 using SimpleType = /*const*/ SDNode *;
273
275 return Val.getNode();
276 }
277};
278
279/// Represents a use of a SDNode. This class holds an SDValue,
280/// which records the SDNode being used and the result number, a
281/// pointer to the SDNode using the value, and Next and Prev pointers,
282/// which link together all the uses of an SDNode.
283///
284class SDUse {
285 /// Val - The value being used.
286 SDValue Val;
287 /// User - The user of this value.
288 SDNode *User = nullptr;
289 /// Prev, Next - Pointers to the uses list of the SDNode referred by
290 /// this operand.
291 SDUse **Prev = nullptr;
292 SDUse *Next = nullptr;
293
294public:
295 SDUse() = default;
296 SDUse(const SDUse &U) = delete;
297 SDUse &operator=(const SDUse &) = delete;
298
299 /// Normally SDUse will just implicitly convert to an SDValue that it holds.
300 operator const SDValue&() const { return Val; }
301
302 /// If implicit conversion to SDValue doesn't work, the get() method returns
303 /// the SDValue.
304 const SDValue &get() const { return Val; }
305
306 /// This returns the SDNode that contains this Use.
307 SDNode *getUser() { return User; }
308 const SDNode *getUser() const { return User; }
309
310 /// Get the next SDUse in the use list.
311 SDUse *getNext() const { return Next; }
312
313 /// Convenience function for get().getNode().
314 SDNode *getNode() const { return Val.getNode(); }
315 /// Convenience function for get().getResNo().
316 unsigned getResNo() const { return Val.getResNo(); }
317 /// Convenience function for get().getValueType().
318 EVT getValueType() const { return Val.getValueType(); }
319
320 /// Convenience function for get().operator==
321 bool operator==(const SDValue &V) const {
322 return Val == V;
323 }
324
325 /// Convenience function for get().operator!=
326 bool operator!=(const SDValue &V) const {
327 return Val != V;
328 }
329
330 /// Convenience function for get().operator<
331 bool operator<(const SDValue &V) const {
332 return Val < V;
333 }
334
335private:
336 friend class SelectionDAG;
337 friend class SDNode;
338 // TODO: unfriend HandleSDNode once we fix its operand handling.
339 friend class HandleSDNode;
340
341 void setUser(SDNode *p) { User = p; }
342
343 /// Remove this use from its existing use list, assign it the
344 /// given value, and add it to the new value's node's use list.
345 inline void set(const SDValue &V);
346 /// Like set, but only supports initializing a newly-allocated
347 /// SDUse with a non-null value.
348 inline void setInitial(const SDValue &V);
349 /// Like set, but only sets the Node portion of the value,
350 /// leaving the ResNo portion unmodified.
351 inline void setNode(SDNode *N);
352
353 void addToList(SDUse **List) {
354 Next = *List;
355 if (Next) Next->Prev = &Next;
356 Prev = List;
357 *List = this;
358 }
359
360 void removeFromList() {
361 *Prev = Next;
362 if (Next) Next->Prev = Prev;
363 }
364};
365
366/// simplify_type specializations - Allow casting operators to work directly on
367/// SDValues as if they were SDNode*'s.
368template<> struct simplify_type<SDUse> {
370
372 return Val.getNode();
373 }
374};
375
376/// These are IR-level optimization flags that may be propagated to SDNodes.
377/// TODO: This data structure should be shared by the IR optimizer and the
378/// the backend.
380private:
381 bool NoUnsignedWrap : 1;
382 bool NoSignedWrap : 1;
383 bool Exact : 1;
384 bool Disjoint : 1;
385 bool NonNeg : 1;
386 bool NoNaNs : 1;
387 bool NoInfs : 1;
388 bool NoSignedZeros : 1;
389 bool AllowReciprocal : 1;
390 bool AllowContract : 1;
391 bool ApproximateFuncs : 1;
392 bool AllowReassociation : 1;
393
394 // We assume instructions do not raise floating-point exceptions by default,
395 // and only those marked explicitly may do so. We could choose to represent
396 // this via a positive "FPExcept" flags like on the MI level, but having a
397 // negative "NoFPExcept" flag here makes the flag intersection logic more
398 // straightforward.
399 bool NoFPExcept : 1;
400 // Instructions with attached 'unpredictable' metadata on IR level.
401 bool Unpredictable : 1;
402
403public:
404 /// Default constructor turns off all optimization flags.
406 : NoUnsignedWrap(false), NoSignedWrap(false), Exact(false),
407 Disjoint(false), NonNeg(false), NoNaNs(false), NoInfs(false),
408 NoSignedZeros(false), AllowReciprocal(false), AllowContract(false),
409 ApproximateFuncs(false), AllowReassociation(false), NoFPExcept(false),
410 Unpredictable(false) {}
411
412 /// Propagate the fast-math-flags from an IR FPMathOperator.
413 void copyFMF(const FPMathOperator &FPMO) {
414 setNoNaNs(FPMO.hasNoNaNs());
415 setNoInfs(FPMO.hasNoInfs());
421 }
422
423 // These are mutators for each flag.
424 void setNoUnsignedWrap(bool b) { NoUnsignedWrap = b; }
425 void setNoSignedWrap(bool b) { NoSignedWrap = b; }
426 void setExact(bool b) { Exact = b; }
427 void setDisjoint(bool b) { Disjoint = b; }
428 void setNonNeg(bool b) { NonNeg = b; }
429 void setNoNaNs(bool b) { NoNaNs = b; }
430 void setNoInfs(bool b) { NoInfs = b; }
431 void setNoSignedZeros(bool b) { NoSignedZeros = b; }
432 void setAllowReciprocal(bool b) { AllowReciprocal = b; }
433 void setAllowContract(bool b) { AllowContract = b; }
434 void setApproximateFuncs(bool b) { ApproximateFuncs = b; }
435 void setAllowReassociation(bool b) { AllowReassociation = b; }
436 void setNoFPExcept(bool b) { NoFPExcept = b; }
437 void setUnpredictable(bool b) { Unpredictable = b; }
438
439 // These are accessors for each flag.
440 bool hasNoUnsignedWrap() const { return NoUnsignedWrap; }
441 bool hasNoSignedWrap() const { return NoSignedWrap; }
442 bool hasExact() const { return Exact; }
443 bool hasDisjoint() const { return Disjoint; }
444 bool hasNonNeg() const { return NonNeg; }
445 bool hasNoNaNs() const { return NoNaNs; }
446 bool hasNoInfs() const { return NoInfs; }
447 bool hasNoSignedZeros() const { return NoSignedZeros; }
448 bool hasAllowReciprocal() const { return AllowReciprocal; }
449 bool hasAllowContract() const { return AllowContract; }
450 bool hasApproximateFuncs() const { return ApproximateFuncs; }
451 bool hasAllowReassociation() const { return AllowReassociation; }
452 bool hasNoFPExcept() const { return NoFPExcept; }
453 bool hasUnpredictable() const { return Unpredictable; }
454
455 /// Clear any flags in this flag set that aren't also set in Flags. All
456 /// flags will be cleared if Flags are undefined.
457 void intersectWith(const SDNodeFlags Flags) {
458 NoUnsignedWrap &= Flags.NoUnsignedWrap;
459 NoSignedWrap &= Flags.NoSignedWrap;
460 Exact &= Flags.Exact;
461 Disjoint &= Flags.Disjoint;
462 NonNeg &= Flags.NonNeg;
463 NoNaNs &= Flags.NoNaNs;
464 NoInfs &= Flags.NoInfs;
465 NoSignedZeros &= Flags.NoSignedZeros;
466 AllowReciprocal &= Flags.AllowReciprocal;
467 AllowContract &= Flags.AllowContract;
468 ApproximateFuncs &= Flags.ApproximateFuncs;
469 AllowReassociation &= Flags.AllowReassociation;
470 NoFPExcept &= Flags.NoFPExcept;
471 Unpredictable &= Flags.Unpredictable;
472 }
473};
474
475/// Represents one node in the SelectionDAG.
476///
477class SDNode : public FoldingSetNode, public ilist_node<SDNode> {
478private:
479 /// The operation that this node performs.
480 int32_t NodeType;
481
482public:
483 /// Unique and persistent id per SDNode in the DAG. Used for debug printing.
484 /// We do not place that under `#if LLVM_ENABLE_ABI_BREAKING_CHECKS`
485 /// intentionally because it adds unneeded complexity without noticeable
486 /// benefits (see discussion with @thakis in D120714).
488
489protected:
490 // We define a set of mini-helper classes to help us interpret the bits in our
491 // SubclassData. These are designed to fit within a uint16_t so they pack
492 // with PersistentId.
493
494#if defined(_AIX) && (!defined(__GNUC__) || defined(__clang__))
495// Except for GCC; by default, AIX compilers store bit-fields in 4-byte words
496// and give the `pack` pragma push semantics.
497#define BEGIN_TWO_BYTE_PACK() _Pragma("pack(2)")
498#define END_TWO_BYTE_PACK() _Pragma("pack(pop)")
499#else
500#define BEGIN_TWO_BYTE_PACK()
501#define END_TWO_BYTE_PACK()
502#endif
503
506 friend class SDNode;
507 friend class MemIntrinsicSDNode;
508 friend class MemSDNode;
509 friend class SelectionDAG;
510
511 uint16_t HasDebugValue : 1;
512 uint16_t IsMemIntrinsic : 1;
513 uint16_t IsDivergent : 1;
514 };
515 enum { NumSDNodeBits = 3 };
516
518 friend class ConstantSDNode;
519
521
522 uint16_t IsOpaque : 1;
523 };
524
526 friend class MemSDNode;
527 friend class MemIntrinsicSDNode;
528 friend class AtomicSDNode;
529
531
532 uint16_t IsVolatile : 1;
533 uint16_t IsNonTemporal : 1;
534 uint16_t IsDereferenceable : 1;
535 uint16_t IsInvariant : 1;
536 };
538
540 friend class LSBaseSDNode;
545
547
548 // This storage is shared between disparate class hierarchies to hold an
549 // enumeration specific to the class hierarchy in use.
550 // LSBaseSDNode => enum ISD::MemIndexedMode
551 // VPLoadStoreBaseSDNode => enum ISD::MemIndexedMode
552 // MaskedLoadStoreBaseSDNode => enum ISD::MemIndexedMode
553 // VPGatherScatterSDNode => enum ISD::MemIndexType
554 // MaskedGatherScatterSDNode => enum ISD::MemIndexType
556 };
558
560 friend class LoadSDNode;
561 friend class AtomicSDNode;
562 friend class VPLoadSDNode;
564 friend class MaskedLoadSDNode;
565 friend class MaskedGatherSDNode;
566 friend class VPGatherSDNode;
567
569
570 uint16_t ExtTy : 2; // enum ISD::LoadExtType
571 uint16_t IsExpanding : 1;
572 };
573
575 friend class StoreSDNode;
576 friend class VPStoreSDNode;
578 friend class MaskedStoreSDNode;
580 friend class VPScatterSDNode;
581
583
584 uint16_t IsTruncating : 1;
585 uint16_t IsCompressing : 1;
586 };
587
588 union {
589 char RawSDNodeBits[sizeof(uint16_t)];
596 };
598#undef BEGIN_TWO_BYTE_PACK
599#undef END_TWO_BYTE_PACK
600
601 // RawSDNodeBits must cover the entirety of the union. This means that all of
602 // the union's members must have size <= RawSDNodeBits. We write the RHS as
603 // "2" instead of sizeof(RawSDNodeBits) because MSVC can't handle the latter.
604 static_assert(sizeof(SDNodeBitfields) <= 2, "field too wide");
605 static_assert(sizeof(ConstantSDNodeBitfields) <= 2, "field too wide");
606 static_assert(sizeof(MemSDNodeBitfields) <= 2, "field too wide");
607 static_assert(sizeof(LSBaseSDNodeBitfields) <= 2, "field too wide");
608 static_assert(sizeof(LoadSDNodeBitfields) <= 2, "field too wide");
609 static_assert(sizeof(StoreSDNodeBitfields) <= 2, "field too wide");
610
611private:
612 friend class SelectionDAG;
613 // TODO: unfriend HandleSDNode once we fix its operand handling.
614 friend class HandleSDNode;
615
616 /// Unique id per SDNode in the DAG.
617 int NodeId = -1;
618
619 /// The values that are used by this operation.
620 SDUse *OperandList = nullptr;
621
622 /// The types of the values this node defines. SDNode's may
623 /// define multiple values simultaneously.
624 const EVT *ValueList;
625
626 /// List of uses for this SDNode.
627 SDUse *UseList = nullptr;
628
629 /// The number of entries in the Operand/Value list.
630 unsigned short NumOperands = 0;
631 unsigned short NumValues;
632
633 // The ordering of the SDNodes. It roughly corresponds to the ordering of the
634 // original LLVM instructions.
635 // This is used for turning off scheduling, because we'll forgo
636 // the normal scheduling algorithms and output the instructions according to
637 // this ordering.
638 unsigned IROrder;
639
640 /// Source line information.
641 DebugLoc debugLoc;
642
643 /// Return a pointer to the specified value type.
644 static const EVT *getValueTypeList(EVT VT);
645
646 SDNodeFlags Flags;
647
648 uint32_t CFIType = 0;
649
650public:
651 //===--------------------------------------------------------------------===//
652 // Accessors
653 //
654
655 /// Return the SelectionDAG opcode value for this node. For
656 /// pre-isel nodes (those for which isMachineOpcode returns false), these
657 /// are the opcode values in the ISD and <target>ISD namespaces. For
658 /// post-isel opcodes, see getMachineOpcode.
659 unsigned getOpcode() const { return (unsigned)NodeType; }
660
661 /// Test if this node has a target-specific opcode (in the
662 /// <target>ISD namespace).
663 bool isTargetOpcode() const { return NodeType >= ISD::BUILTIN_OP_END; }
664
665 /// Test if this node has a target-specific opcode that may raise
666 /// FP exceptions (in the <target>ISD namespace and greater than
667 /// FIRST_TARGET_STRICTFP_OPCODE). Note that all target memory
668 /// opcode are currently automatically considered to possibly raise
669 /// FP exceptions as well.
671 return NodeType >= ISD::FIRST_TARGET_STRICTFP_OPCODE;
672 }
673
674 /// Test if this node has a target-specific
675 /// memory-referencing opcode (in the <target>ISD namespace and
676 /// greater than FIRST_TARGET_MEMORY_OPCODE).
677 bool isTargetMemoryOpcode() const {
678 return NodeType >= ISD::FIRST_TARGET_MEMORY_OPCODE;
679 }
680
681 /// Return true if the type of the node type undefined.
682 bool isUndef() const { return NodeType == ISD::UNDEF; }
683
684 /// Test if this node is a memory intrinsic (with valid pointer information).
685 /// INTRINSIC_W_CHAIN and INTRINSIC_VOID nodes are sometimes created for
686 /// non-memory intrinsics (with chains) that are not really instances of
687 /// MemSDNode. For such nodes, we need some extra state to determine the
688 /// proper classof relationship.
689 bool isMemIntrinsic() const {
690 return (NodeType == ISD::INTRINSIC_W_CHAIN ||
691 NodeType == ISD::INTRINSIC_VOID) &&
692 SDNodeBits.IsMemIntrinsic;
693 }
694
695 /// Test if this node is a strict floating point pseudo-op.
697 switch (NodeType) {
698 default:
699 return false;
704#define DAG_INSTRUCTION(NAME, NARG, ROUND_MODE, INTRINSIC, DAGN) \
705 case ISD::STRICT_##DAGN:
706#include "llvm/IR/ConstrainedOps.def"
707 return true;
708 }
709 }
710
711 /// Test if this node is a vector predication operation.
712 bool isVPOpcode() const { return ISD::isVPOpcode(getOpcode()); }
713
714 /// Test if this node has a post-isel opcode, directly
715 /// corresponding to a MachineInstr opcode.
716 bool isMachineOpcode() const { return NodeType < 0; }
717
718 /// This may only be called if isMachineOpcode returns
719 /// true. It returns the MachineInstr opcode value that the node's opcode
720 /// corresponds to.
721 unsigned getMachineOpcode() const {
722 assert(isMachineOpcode() && "Not a MachineInstr opcode!");
723 return ~NodeType;
724 }
725
726 bool getHasDebugValue() const { return SDNodeBits.HasDebugValue; }
727 void setHasDebugValue(bool b) { SDNodeBits.HasDebugValue = b; }
728
729 bool isDivergent() const { return SDNodeBits.IsDivergent; }
730
731 /// Return true if there are no uses of this node.
732 bool use_empty() const { return UseList == nullptr; }
733
734 /// Return true if there is exactly one use of this node.
735 bool hasOneUse() const { return hasSingleElement(uses()); }
736
737 /// Return the number of uses of this node. This method takes
738 /// time proportional to the number of uses.
739 size_t use_size() const { return std::distance(use_begin(), use_end()); }
740
741 /// Return the unique node id.
742 int getNodeId() const { return NodeId; }
743
744 /// Set unique node id.
745 void setNodeId(int Id) { NodeId = Id; }
746
747 /// Return the node ordering.
748 unsigned getIROrder() const { return IROrder; }
749
750 /// Set the node ordering.
751 void setIROrder(unsigned Order) { IROrder = Order; }
752
753 /// Return the source location info.
754 const DebugLoc &getDebugLoc() const { return debugLoc; }
755
756 /// Set source location info. Try to avoid this, putting
757 /// it in the constructor is preferable.
758 void setDebugLoc(DebugLoc dl) { debugLoc = std::move(dl); }
759
760 /// This class provides iterator support for SDUse
761 /// operands that use a specific SDNode.
763 friend class SDNode;
764
765 SDUse *Op = nullptr;
766
767 explicit use_iterator(SDUse *op) : Op(op) {}
768
769 public:
770 using iterator_category = std::forward_iterator_tag;
772 using difference_type = std::ptrdiff_t;
775
776 use_iterator() = default;
777 use_iterator(const use_iterator &I) = default;
779
780 bool operator==(const use_iterator &x) const { return Op == x.Op; }
781 bool operator!=(const use_iterator &x) const {
782 return !operator==(x);
783 }
784
785 /// Return true if this iterator is at the end of uses list.
786 bool atEnd() const { return Op == nullptr; }
787
788 // Iterator traversal: forward iteration only.
789 use_iterator &operator++() { // Preincrement
790 assert(Op && "Cannot increment end iterator!");
791 Op = Op->getNext();
792 return *this;
793 }
794
795 use_iterator operator++(int) { // Postincrement
796 use_iterator tmp = *this; ++*this; return tmp;
797 }
798
799 /// Retrieve a pointer to the current user node.
800 SDNode *operator*() const {
801 assert(Op && "Cannot dereference end iterator!");
802 return Op->getUser();
803 }
804
805 SDNode *operator->() const { return operator*(); }
806
807 SDUse &getUse() const { return *Op; }
808
809 /// Retrieve the operand # of this use in its user.
810 unsigned getOperandNo() const {
811 assert(Op && "Cannot dereference end iterator!");
812 return (unsigned)(Op - Op->getUser()->OperandList);
813 }
814 };
815
816 /// Provide iteration support to walk over all uses of an SDNode.
818 return use_iterator(UseList);
819 }
820
821 static use_iterator use_end() { return use_iterator(nullptr); }
822
824 return make_range(use_begin(), use_end());
825 }
827 return make_range(use_begin(), use_end());
828 }
829
830 /// Return true if there are exactly NUSES uses of the indicated value.
831 /// This method ignores uses of other values defined by this operation.
832 bool hasNUsesOfValue(unsigned NUses, unsigned Value) const;
833
834 /// Return true if there are any use of the indicated value.
835 /// This method ignores uses of other values defined by this operation.
836 bool hasAnyUseOfValue(unsigned Value) const;
837
838 /// Return true if this node is the only use of N.
839 bool isOnlyUserOf(const SDNode *N) const;
840
841 /// Return true if this node is an operand of N.
842 bool isOperandOf(const SDNode *N) const;
843
844 /// Return true if this node is a predecessor of N.
845 /// NOTE: Implemented on top of hasPredecessor and every bit as
846 /// expensive. Use carefully.
847 bool isPredecessorOf(const SDNode *N) const {
848 return N->hasPredecessor(this);
849 }
850
851 /// Return true if N is a predecessor of this node.
852 /// N is either an operand of this node, or can be reached by recursively
853 /// traversing up the operands.
854 /// NOTE: This is an expensive method. Use it carefully.
855 bool hasPredecessor(const SDNode *N) const;
856
857 /// Returns true if N is a predecessor of any node in Worklist. This
858 /// helper keeps Visited and Worklist sets externally to allow unions
859 /// searches to be performed in parallel, caching of results across
860 /// queries and incremental addition to Worklist. Stops early if N is
861 /// found but will resume. Remember to clear Visited and Worklists
862 /// if DAG changes. MaxSteps gives a maximum number of nodes to visit before
863 /// giving up. The TopologicalPrune flag signals that positive NodeIds are
864 /// topologically ordered (Operands have strictly smaller node id) and search
865 /// can be pruned leveraging this.
866 static bool hasPredecessorHelper(const SDNode *N,
869 unsigned int MaxSteps = 0,
870 bool TopologicalPrune = false) {
871 SmallVector<const SDNode *, 8> DeferredNodes;
872 if (Visited.count(N))
873 return true;
874
875 // Node Id's are assigned in three places: As a topological
876 // ordering (> 0), during legalization (results in values set to
877 // 0), new nodes (set to -1). If N has a topolgical id then we
878 // know that all nodes with ids smaller than it cannot be
879 // successors and we need not check them. Filter out all node
880 // that can't be matches. We add them to the worklist before exit
881 // in case of multiple calls. Note that during selection the topological id
882 // may be violated if a node's predecessor is selected before it. We mark
883 // this at selection negating the id of unselected successors and
884 // restricting topological pruning to positive ids.
885
886 int NId = N->getNodeId();
887 // If we Invalidated the Id, reconstruct original NId.
888 if (NId < -1)
889 NId = -(NId + 1);
890
891 bool Found = false;
892 while (!Worklist.empty()) {
893 const SDNode *M = Worklist.pop_back_val();
894 int MId = M->getNodeId();
895 if (TopologicalPrune && M->getOpcode() != ISD::TokenFactor && (NId > 0) &&
896 (MId > 0) && (MId < NId)) {
897 DeferredNodes.push_back(M);
898 continue;
899 }
900 for (const SDValue &OpV : M->op_values()) {
901 SDNode *Op = OpV.getNode();
902 if (Visited.insert(Op).second)
903 Worklist.push_back(Op);
904 if (Op == N)
905 Found = true;
906 }
907 if (Found)
908 break;
909 if (MaxSteps != 0 && Visited.size() >= MaxSteps)
910 break;
911 }
912 // Push deferred nodes back on worklist.
913 Worklist.append(DeferredNodes.begin(), DeferredNodes.end());
914 // If we bailed early, conservatively return found.
915 if (MaxSteps != 0 && Visited.size() >= MaxSteps)
916 return true;
917 return Found;
918 }
919
920 /// Return true if all the users of N are contained in Nodes.
921 /// NOTE: Requires at least one match, but doesn't require them all.
922 static bool areOnlyUsersOf(ArrayRef<const SDNode *> Nodes, const SDNode *N);
923
924 /// Return the number of values used by this operation.
925 unsigned getNumOperands() const { return NumOperands; }
926
927 /// Return the maximum number of operands that a SDNode can hold.
928 static constexpr size_t getMaxNumOperands() {
929 return std::numeric_limits<decltype(SDNode::NumOperands)>::max();
930 }
931
932 /// Helper method returns the integer value of a ConstantSDNode operand.
933 inline uint64_t getConstantOperandVal(unsigned Num) const;
934
935 /// Helper method returns the zero-extended integer value of a ConstantSDNode.
936 inline uint64_t getAsZExtVal() const;
937
938 /// Helper method returns the APInt of a ConstantSDNode operand.
939 inline const APInt &getConstantOperandAPInt(unsigned Num) const;
940
941 /// Helper method returns the APInt value of a ConstantSDNode.
942 inline const APInt &getAsAPIntVal() const;
943
944 const SDValue &getOperand(unsigned Num) const {
945 assert(Num < NumOperands && "Invalid child # of SDNode!");
946 return OperandList[Num];
947 }
948
950
951 op_iterator op_begin() const { return OperandList; }
952 op_iterator op_end() const { return OperandList+NumOperands; }
953 ArrayRef<SDUse> ops() const { return ArrayRef(op_begin(), op_end()); }
954
955 /// Iterator for directly iterating over the operand SDValue's.
957 : iterator_adaptor_base<value_op_iterator, op_iterator,
958 std::random_access_iterator_tag, SDValue,
959 ptrdiff_t, value_op_iterator *,
960 value_op_iterator *> {
961 explicit value_op_iterator(SDUse *U = nullptr)
963
964 const SDValue &operator*() const { return I->get(); }
965 };
966
970 }
971
973 SDVTList X = { ValueList, NumValues };
974 return X;
975 }
976
977 /// If this node has a glue operand, return the node
978 /// to which the glue operand points. Otherwise return NULL.
980 if (getNumOperands() != 0 &&
981 getOperand(getNumOperands()-1).getValueType() == MVT::Glue)
982 return getOperand(getNumOperands()-1).getNode();
983 return nullptr;
984 }
985
986 /// If this node has a glue value with a user, return
987 /// the user (there is at most one). Otherwise return NULL.
989 for (use_iterator UI = use_begin(), UE = use_end(); UI != UE; ++UI)
990 if (UI.getUse().get().getValueType() == MVT::Glue)
991 return *UI;
992 return nullptr;
993 }
994
995 SDNodeFlags getFlags() const { return Flags; }
996 void setFlags(SDNodeFlags NewFlags) { Flags = NewFlags; }
997
998 /// Clear any flags in this node that aren't also set in Flags.
999 /// If Flags is not in a defined state then this has no effect.
1000 void intersectFlagsWith(const SDNodeFlags Flags);
1001
1002 void setCFIType(uint32_t Type) { CFIType = Type; }
1003 uint32_t getCFIType() const { return CFIType; }
1004
1005 /// Return the number of values defined/returned by this operator.
1006 unsigned getNumValues() const { return NumValues; }
1007
1008 /// Return the type of a specified result.
1009 EVT getValueType(unsigned ResNo) const {
1010 assert(ResNo < NumValues && "Illegal result number!");
1011 return ValueList[ResNo];
1012 }
1013
1014 /// Return the type of a specified result as a simple type.
1015 MVT getSimpleValueType(unsigned ResNo) const {
1016 return getValueType(ResNo).getSimpleVT();
1017 }
1018
1019 /// Returns MVT::getSizeInBits(getValueType(ResNo)).
1020 ///
1021 /// If the value type is a scalable vector type, the scalable property will
1022 /// be set and the runtime size will be a positive integer multiple of the
1023 /// base size.
1024 TypeSize getValueSizeInBits(unsigned ResNo) const {
1025 return getValueType(ResNo).getSizeInBits();
1026 }
1027
1028 using value_iterator = const EVT *;
1029
1030 value_iterator value_begin() const { return ValueList; }
1031 value_iterator value_end() const { return ValueList+NumValues; }
1034 }
1035
1036 /// Return the opcode of this operation for printing.
1037 std::string getOperationName(const SelectionDAG *G = nullptr) const;
1038 static const char* getIndexedModeName(ISD::MemIndexedMode AM);
1039 void print_types(raw_ostream &OS, const SelectionDAG *G) const;
1040 void print_details(raw_ostream &OS, const SelectionDAG *G) const;
1041 void print(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
1042 void printr(raw_ostream &OS, const SelectionDAG *G = nullptr) const;
1043
1044 /// Print a SelectionDAG node and all children down to
1045 /// the leaves. The given SelectionDAG allows target-specific nodes
1046 /// to be printed in human-readable form. Unlike printr, this will
1047 /// print the whole DAG, including children that appear multiple
1048 /// times.
1049 ///
1050 void printrFull(raw_ostream &O, const SelectionDAG *G = nullptr) const;
1051
1052 /// Print a SelectionDAG node and children up to
1053 /// depth "depth." The given SelectionDAG allows target-specific
1054 /// nodes to be printed in human-readable form. Unlike printr, this
1055 /// will print children that appear multiple times wherever they are
1056 /// used.
1057 ///
1058 void printrWithDepth(raw_ostream &O, const SelectionDAG *G = nullptr,
1059 unsigned depth = 100) const;
1060
1061 /// Dump this node, for debugging.
1062 void dump() const;
1063
1064 /// Dump (recursively) this node and its use-def subgraph.
1065 void dumpr() const;
1066
1067 /// Dump this node, for debugging.
1068 /// The given SelectionDAG allows target-specific nodes to be printed
1069 /// in human-readable form.
1070 void dump(const SelectionDAG *G) const;
1071
1072 /// Dump (recursively) this node and its use-def subgraph.
1073 /// The given SelectionDAG allows target-specific nodes to be printed
1074 /// in human-readable form.
1075 void dumpr(const SelectionDAG *G) const;
1076
1077 /// printrFull to dbgs(). The given SelectionDAG allows
1078 /// target-specific nodes to be printed in human-readable form.
1079 /// Unlike dumpr, this will print the whole DAG, including children
1080 /// that appear multiple times.
1081 void dumprFull(const SelectionDAG *G = nullptr) const;
1082
1083 /// printrWithDepth to dbgs(). The given
1084 /// SelectionDAG allows target-specific nodes to be printed in
1085 /// human-readable form. Unlike dumpr, this will print children
1086 /// that appear multiple times wherever they are used.
1087 ///
1088 void dumprWithDepth(const SelectionDAG *G = nullptr,
1089 unsigned depth = 100) const;
1090
1091 /// Gather unique data for the node.
1092 void Profile(FoldingSetNodeID &ID) const;
1093
1094 /// This method should only be used by the SDUse class.
1095 void addUse(SDUse &U) { U.addToList(&UseList); }
1096
1097protected:
1099 SDVTList Ret = { getValueTypeList(VT), 1 };
1100 return Ret;
1101 }
1102
1103 /// Create an SDNode.
1104 ///
1105 /// SDNodes are created without any operands, and never own the operand
1106 /// storage. To add operands, see SelectionDAG::createOperands.
1107 SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs)
1108 : NodeType(Opc), ValueList(VTs.VTs), NumValues(VTs.NumVTs),
1109 IROrder(Order), debugLoc(std::move(dl)) {
1110 memset(&RawSDNodeBits, 0, sizeof(RawSDNodeBits));
1111 assert(debugLoc.hasTrivialDestructor() && "Expected trivial destructor");
1112 assert(NumValues == VTs.NumVTs &&
1113 "NumValues wasn't wide enough for its operands!");
1114 }
1115
1116 /// Release the operands and set this node to have zero operands.
1117 void DropOperands();
1118};
1119
1120/// Wrapper class for IR location info (IR ordering and DebugLoc) to be passed
1121/// into SDNode creation functions.
1122/// When an SDNode is created from the DAGBuilder, the DebugLoc is extracted
1123/// from the original Instruction, and IROrder is the ordinal position of
1124/// the instruction.
1125/// When an SDNode is created after the DAG is being built, both DebugLoc and
1126/// the IROrder are propagated from the original SDNode.
1127/// So SDLoc class provides two constructors besides the default one, one to
1128/// be used by the DAGBuilder, the other to be used by others.
1129class SDLoc {
1130private:
1131 DebugLoc DL;
1132 int IROrder = 0;
1133
1134public:
1135 SDLoc() = default;
1136 SDLoc(const SDNode *N) : DL(N->getDebugLoc()), IROrder(N->getIROrder()) {}
1137 SDLoc(const SDValue V) : SDLoc(V.getNode()) {}
1138 SDLoc(const Instruction *I, int Order) : IROrder(Order) {
1139 assert(Order >= 0 && "bad IROrder");
1140 if (I)
1141 DL = I->getDebugLoc();
1142 }
1143
1144 unsigned getIROrder() const { return IROrder; }
1145 const DebugLoc &getDebugLoc() const { return DL; }
1146};
1147
1148// Define inline functions from the SDValue class.
1149
1150inline SDValue::SDValue(SDNode *node, unsigned resno)
1151 : Node(node), ResNo(resno) {
1152 // Explicitly check for !ResNo to avoid use-after-free, because there are
1153 // callers that use SDValue(N, 0) with a deleted N to indicate successful
1154 // combines.
1155 assert((!Node || !ResNo || ResNo < Node->getNumValues()) &&
1156 "Invalid result number for the given node!");
1157 assert(ResNo < -2U && "Cannot use result numbers reserved for DenseMaps.");
1158}
1159
1160inline unsigned SDValue::getOpcode() const {
1161 return Node->getOpcode();
1162}
1163
1165 return Node->getValueType(ResNo);
1166}
1167
1168inline unsigned SDValue::getNumOperands() const {
1169 return Node->getNumOperands();
1170}
1171
1172inline const SDValue &SDValue::getOperand(unsigned i) const {
1173 return Node->getOperand(i);
1174}
1175
1177 return Node->getConstantOperandVal(i);
1178}
1179
1180inline const APInt &SDValue::getConstantOperandAPInt(unsigned i) const {
1181 return Node->getConstantOperandAPInt(i);
1182}
1183
1184inline bool SDValue::isTargetOpcode() const {
1185 return Node->isTargetOpcode();
1186}
1187
1189 return Node->isTargetMemoryOpcode();
1190}
1191
1192inline bool SDValue::isMachineOpcode() const {
1193 return Node->isMachineOpcode();
1194}
1195
1196inline unsigned SDValue::getMachineOpcode() const {
1197 return Node->getMachineOpcode();
1198}
1199
1200inline bool SDValue::isUndef() const {
1201 return Node->isUndef();
1202}
1203
1204inline bool SDValue::use_empty() const {
1205 return !Node->hasAnyUseOfValue(ResNo);
1206}
1207
1208inline bool SDValue::hasOneUse() const {
1209 return Node->hasNUsesOfValue(1, ResNo);
1210}
1211
1212inline const DebugLoc &SDValue::getDebugLoc() const {
1213 return Node->getDebugLoc();
1214}
1215
1216inline void SDValue::dump() const {
1217 return Node->dump();
1218}
1219
1220inline void SDValue::dump(const SelectionDAG *G) const {
1221 return Node->dump(G);
1222}
1223
1224inline void SDValue::dumpr() const {
1225 return Node->dumpr();
1226}
1227
1228inline void SDValue::dumpr(const SelectionDAG *G) const {
1229 return Node->dumpr(G);
1230}
1231
1232// Define inline functions from the SDUse class.
1233
1234inline void SDUse::set(const SDValue &V) {
1235 if (Val.getNode()) removeFromList();
1236 Val = V;
1237 if (V.getNode())
1238 V->addUse(*this);
1239}
1240
1241inline void SDUse::setInitial(const SDValue &V) {
1242 Val = V;
1243 V->addUse(*this);
1244}
1245
1246inline void SDUse::setNode(SDNode *N) {
1247 if (Val.getNode()) removeFromList();
1248 Val.setNode(N);
1249 if (N) N->addUse(*this);
1250}
1251
1252/// This class is used to form a handle around another node that
1253/// is persistent and is updated across invocations of replaceAllUsesWith on its
1254/// operand. This node should be directly created by end-users and not added to
1255/// the AllNodes list.
1256class HandleSDNode : public SDNode {
1257 SDUse Op;
1258
1259public:
1261 : SDNode(ISD::HANDLENODE, 0, DebugLoc(), getSDVTList(MVT::Other)) {
1262 // HandleSDNodes are never inserted into the DAG, so they won't be
1263 // auto-numbered. Use ID 65535 as a sentinel.
1264 PersistentId = 0xffff;
1265
1266 // Manually set up the operand list. This node type is special in that it's
1267 // always stack allocated and SelectionDAG does not manage its operands.
1268 // TODO: This should either (a) not be in the SDNode hierarchy, or (b) not
1269 // be so special.
1270 Op.setUser(this);
1271 Op.setInitial(X);
1272 NumOperands = 1;
1273 OperandList = &Op;
1274 }
1275 ~HandleSDNode();
1276
1277 const SDValue &getValue() const { return Op; }
1278};
1279
1281private:
1282 unsigned SrcAddrSpace;
1283 unsigned DestAddrSpace;
1284
1285public:
1286 AddrSpaceCastSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
1287 unsigned SrcAS, unsigned DestAS)
1288 : SDNode(ISD::ADDRSPACECAST, Order, dl, VTs), SrcAddrSpace(SrcAS),
1289 DestAddrSpace(DestAS) {}
1290
1291 unsigned getSrcAddressSpace() const { return SrcAddrSpace; }
1292 unsigned getDestAddressSpace() const { return DestAddrSpace; }
1293
1294 static bool classof(const SDNode *N) {
1295 return N->getOpcode() == ISD::ADDRSPACECAST;
1296 }
1297};
1298
1299/// This is an abstract virtual class for memory operations.
1300class MemSDNode : public SDNode {
1301private:
1302 // VT of in-memory value.
1303 EVT MemoryVT;
1304
1305protected:
1306 /// Memory reference information.
1308
1309public:
1310 MemSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTs,
1311 EVT memvt, MachineMemOperand *MMO);
1312
1313 bool readMem() const { return MMO->isLoad(); }
1314 bool writeMem() const { return MMO->isStore(); }
1315
1316 /// Returns alignment and volatility of the memory access
1318 Align getAlign() const { return MMO->getAlign(); }
1319
1320 /// Return the SubclassData value, without HasDebugValue. This contains an
1321 /// encoding of the volatile flag, as well as bits used by subclasses. This
1322 /// function should only be used to compute a FoldingSetNodeID value.
1323 /// The HasDebugValue bit is masked out because CSE map needs to match
1324 /// nodes with debug info with nodes without debug info. Same is about
1325 /// isDivergent bit.
1326 unsigned getRawSubclassData() const {
1327 uint16_t Data;
1328 union {
1329 char RawSDNodeBits[sizeof(uint16_t)];
1331 };
1332 memcpy(&RawSDNodeBits, &this->RawSDNodeBits, sizeof(this->RawSDNodeBits));
1333 SDNodeBits.HasDebugValue = 0;
1334 SDNodeBits.IsDivergent = false;
1335 memcpy(&Data, &RawSDNodeBits, sizeof(RawSDNodeBits));
1336 return Data;
1337 }
1338
1339 bool isVolatile() const { return MemSDNodeBits.IsVolatile; }
1340 bool isNonTemporal() const { return MemSDNodeBits.IsNonTemporal; }
1341 bool isDereferenceable() const { return MemSDNodeBits.IsDereferenceable; }
1342 bool isInvariant() const { return MemSDNodeBits.IsInvariant; }
1343
1344 // Returns the offset from the location of the access.
1345 int64_t getSrcValueOffset() const { return MMO->getOffset(); }
1346
1347 /// Returns the AA info that describes the dereference.
1348 AAMDNodes getAAInfo() const { return MMO->getAAInfo(); }
1349
1350 /// Returns the Ranges that describes the dereference.
1351 const MDNode *getRanges() const { return MMO->getRanges(); }
1352
1353 /// Returns the synchronization scope ID for this memory operation.
1355
1356 /// Return the atomic ordering requirements for this memory operation. For
1357 /// cmpxchg atomic operations, return the atomic ordering requirements when
1358 /// store occurs.
1360 return MMO->getSuccessOrdering();
1361 }
1362
1363 /// Return a single atomic ordering that is at least as strong as both the
1364 /// success and failure orderings for an atomic operation. (For operations
1365 /// other than cmpxchg, this is equivalent to getSuccessOrdering().)
1367
1368 /// Return true if the memory operation ordering is Unordered or higher.
1369 bool isAtomic() const { return MMO->isAtomic(); }
1370
1371 /// Returns true if the memory operation doesn't imply any ordering
1372 /// constraints on surrounding memory operations beyond the normal memory
1373 /// aliasing rules.
1374 bool isUnordered() const { return MMO->isUnordered(); }
1375
1376 /// Returns true if the memory operation is neither atomic or volatile.
1377 bool isSimple() const { return !isAtomic() && !isVolatile(); }
1378
1379 /// Return the type of the in-memory value.
1380 EVT getMemoryVT() const { return MemoryVT; }
1381
1382 /// Return a MachineMemOperand object describing the memory
1383 /// reference performed by operation.
1385
1387 return MMO->getPointerInfo();
1388 }
1389
1390 /// Return the address space for the associated pointer
1391 unsigned getAddressSpace() const {
1392 return getPointerInfo().getAddrSpace();
1393 }
1394
1395 /// Update this MemSDNode's MachineMemOperand information
1396 /// to reflect the alignment of NewMMO, if it has a greater alignment.
1397 /// This must only be used when the new alignment applies to all users of
1398 /// this MachineMemOperand.
1400 MMO->refineAlignment(NewMMO);
1401 }
1402
1403 const SDValue &getChain() const { return getOperand(0); }
1404
1405 const SDValue &getBasePtr() const {
1406 switch (getOpcode()) {
1407 case ISD::STORE:
1408 case ISD::ATOMIC_STORE:
1409 case ISD::VP_STORE:
1410 case ISD::MSTORE:
1411 case ISD::VP_SCATTER:
1412 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1413 return getOperand(2);
1414 case ISD::MGATHER:
1415 case ISD::MSCATTER:
1416 return getOperand(3);
1417 default:
1418 return getOperand(1);
1419 }
1420 }
1421
1422 // Methods to support isa and dyn_cast
1423 static bool classof(const SDNode *N) {
1424 // For some targets, we lower some target intrinsics to a MemIntrinsicNode
1425 // with either an intrinsic or a target opcode.
1426 switch (N->getOpcode()) {
1427 case ISD::LOAD:
1428 case ISD::STORE:
1429 case ISD::PREFETCH:
1432 case ISD::ATOMIC_SWAP:
1450 case ISD::ATOMIC_LOAD:
1451 case ISD::ATOMIC_STORE:
1452 case ISD::MLOAD:
1453 case ISD::MSTORE:
1454 case ISD::MGATHER:
1455 case ISD::MSCATTER:
1456 case ISD::VP_LOAD:
1457 case ISD::VP_STORE:
1458 case ISD::VP_GATHER:
1459 case ISD::VP_SCATTER:
1460 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
1461 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
1462 case ISD::GET_FPENV_MEM:
1463 case ISD::SET_FPENV_MEM:
1464 return true;
1465 default:
1466 return N->isMemIntrinsic() || N->isTargetMemoryOpcode();
1467 }
1468 }
1469};
1470
1471/// This is an SDNode representing atomic operations.
1472class AtomicSDNode : public MemSDNode {
1473public:
1474 AtomicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTL,
1475 EVT MemVT, MachineMemOperand *MMO)
1476 : MemSDNode(Opc, Order, dl, VTL, MemVT, MMO) {
1477 assert(((Opc != ISD::ATOMIC_LOAD && Opc != ISD::ATOMIC_STORE) ||
1478 MMO->isAtomic()) && "then why are we using an AtomicSDNode?");
1479 }
1480
1482 assert(getOpcode() == ISD::ATOMIC_LOAD && "Only used for atomic loads.");
1483 LoadSDNodeBits.ExtTy = ETy;
1484 }
1485
1487 assert(getOpcode() == ISD::ATOMIC_LOAD && "Only used for atomic loads.");
1488 return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy);
1489 }
1490
1491 const SDValue &getBasePtr() const {
1492 return getOpcode() == ISD::ATOMIC_STORE ? getOperand(2) : getOperand(1);
1493 }
1494 const SDValue &getVal() const {
1495 return getOpcode() == ISD::ATOMIC_STORE ? getOperand(1) : getOperand(2);
1496 }
1497
1498 /// Returns true if this SDNode represents cmpxchg atomic operation, false
1499 /// otherwise.
1500 bool isCompareAndSwap() const {
1501 unsigned Op = getOpcode();
1502 return Op == ISD::ATOMIC_CMP_SWAP ||
1504 }
1505
1506 /// For cmpxchg atomic operations, return the atomic ordering requirements
1507 /// when store does not occur.
1509 assert(isCompareAndSwap() && "Must be cmpxchg operation");
1510 return MMO->getFailureOrdering();
1511 }
1512
1513 // Methods to support isa and dyn_cast
1514 static bool classof(const SDNode *N) {
1515 return N->getOpcode() == ISD::ATOMIC_CMP_SWAP ||
1516 N->getOpcode() == ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS ||
1517 N->getOpcode() == ISD::ATOMIC_SWAP ||
1518 N->getOpcode() == ISD::ATOMIC_LOAD_ADD ||
1519 N->getOpcode() == ISD::ATOMIC_LOAD_SUB ||
1520 N->getOpcode() == ISD::ATOMIC_LOAD_AND ||
1521 N->getOpcode() == ISD::ATOMIC_LOAD_CLR ||
1522 N->getOpcode() == ISD::ATOMIC_LOAD_OR ||
1523 N->getOpcode() == ISD::ATOMIC_LOAD_XOR ||
1524 N->getOpcode() == ISD::ATOMIC_LOAD_NAND ||
1525 N->getOpcode() == ISD::ATOMIC_LOAD_MIN ||
1526 N->getOpcode() == ISD::ATOMIC_LOAD_MAX ||
1527 N->getOpcode() == ISD::ATOMIC_LOAD_UMIN ||
1528 N->getOpcode() == ISD::ATOMIC_LOAD_UMAX ||
1529 N->getOpcode() == ISD::ATOMIC_LOAD_FADD ||
1530 N->getOpcode() == ISD::ATOMIC_LOAD_FSUB ||
1531 N->getOpcode() == ISD::ATOMIC_LOAD_FMAX ||
1532 N->getOpcode() == ISD::ATOMIC_LOAD_FMIN ||
1533 N->getOpcode() == ISD::ATOMIC_LOAD_UINC_WRAP ||
1534 N->getOpcode() == ISD::ATOMIC_LOAD_UDEC_WRAP ||
1535 N->getOpcode() == ISD::ATOMIC_LOAD ||
1536 N->getOpcode() == ISD::ATOMIC_STORE;
1537 }
1538};
1539
1540/// This SDNode is used for target intrinsics that touch
1541/// memory and need an associated MachineMemOperand. Its opcode may be
1542/// INTRINSIC_VOID, INTRINSIC_W_CHAIN, PREFETCH, or a target-specific opcode
1543/// with a value not less than FIRST_TARGET_MEMORY_OPCODE.
1545public:
1546 MemIntrinsicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl,
1547 SDVTList VTs, EVT MemoryVT, MachineMemOperand *MMO)
1548 : MemSDNode(Opc, Order, dl, VTs, MemoryVT, MMO) {
1549 SDNodeBits.IsMemIntrinsic = true;
1550 }
1551
1552 // Methods to support isa and dyn_cast
1553 static bool classof(const SDNode *N) {
1554 // We lower some target intrinsics to their target opcode
1555 // early a node with a target opcode can be of this class
1556 return N->isMemIntrinsic() ||
1557 N->getOpcode() == ISD::PREFETCH ||
1558 N->isTargetMemoryOpcode();
1559 }
1560};
1561
1562/// This SDNode is used to implement the code generator
1563/// support for the llvm IR shufflevector instruction. It combines elements
1564/// from two input vectors into a new input vector, with the selection and
1565/// ordering of elements determined by an array of integers, referred to as
1566/// the shuffle mask. For input vectors of width N, mask indices of 0..N-1
1567/// refer to elements from the LHS input, and indices from N to 2N-1 the RHS.
1568/// An index of -1 is treated as undef, such that the code generator may put
1569/// any value in the corresponding element of the result.
1571 // The memory for Mask is owned by the SelectionDAG's OperandAllocator, and
1572 // is freed when the SelectionDAG object is destroyed.
1573 const int *Mask;
1574
1575protected:
1576 friend class SelectionDAG;
1577
1578 ShuffleVectorSDNode(SDVTList VTs, unsigned Order, const DebugLoc &dl,
1579 const int *M)
1580 : SDNode(ISD::VECTOR_SHUFFLE, Order, dl, VTs), Mask(M) {}
1581
1582public:
1584 EVT VT = getValueType(0);
1585 return ArrayRef(Mask, VT.getVectorNumElements());
1586 }
1587
1588 int getMaskElt(unsigned Idx) const {
1589 assert(Idx < getValueType(0).getVectorNumElements() && "Idx out of range!");
1590 return Mask[Idx];
1591 }
1592
1593 bool isSplat() const { return isSplatMask(Mask, getValueType(0)); }
1594
1595 int getSplatIndex() const {
1596 assert(isSplat() && "Cannot get splat index for non-splat!");
1597 EVT VT = getValueType(0);
1598 for (unsigned i = 0, e = VT.getVectorNumElements(); i != e; ++i)
1599 if (Mask[i] >= 0)
1600 return Mask[i];
1601
1602 // We can choose any index value here and be correct because all elements
1603 // are undefined. Return 0 for better potential for callers to simplify.
1604 return 0;
1605 }
1606
1607 static bool isSplatMask(const int *Mask, EVT VT);
1608
1609 /// Change values in a shuffle permute mask assuming
1610 /// the two vector operands have swapped position.
1612 unsigned NumElems = Mask.size();
1613 for (unsigned i = 0; i != NumElems; ++i) {
1614 int idx = Mask[i];
1615 if (idx < 0)
1616 continue;
1617 else if (idx < (int)NumElems)
1618 Mask[i] = idx + NumElems;
1619 else
1620 Mask[i] = idx - NumElems;
1621 }
1622 }
1623
1624 static bool classof(const SDNode *N) {
1625 return N->getOpcode() == ISD::VECTOR_SHUFFLE;
1626 }
1627};
1628
1629class ConstantSDNode : public SDNode {
1630 friend class SelectionDAG;
1631
1632 const ConstantInt *Value;
1633
1634 ConstantSDNode(bool isTarget, bool isOpaque, const ConstantInt *val,
1635 SDVTList VTs)
1636 : SDNode(isTarget ? ISD::TargetConstant : ISD::Constant, 0, DebugLoc(),
1637 VTs),
1638 Value(val) {
1639 ConstantSDNodeBits.IsOpaque = isOpaque;
1640 }
1641
1642public:
1643 const ConstantInt *getConstantIntValue() const { return Value; }
1644 const APInt &getAPIntValue() const { return Value->getValue(); }
1645 uint64_t getZExtValue() const { return Value->getZExtValue(); }
1646 int64_t getSExtValue() const { return Value->getSExtValue(); }
1648 return Value->getLimitedValue(Limit);
1649 }
1650 MaybeAlign getMaybeAlignValue() const { return Value->getMaybeAlignValue(); }
1651 Align getAlignValue() const { return Value->getAlignValue(); }
1652
1653 bool isOne() const { return Value->isOne(); }
1654 bool isZero() const { return Value->isZero(); }
1655 bool isAllOnes() const { return Value->isMinusOne(); }
1656 bool isMaxSignedValue() const { return Value->isMaxValue(true); }
1657 bool isMinSignedValue() const { return Value->isMinValue(true); }
1658
1659 bool isOpaque() const { return ConstantSDNodeBits.IsOpaque; }
1660
1661 static bool classof(const SDNode *N) {
1662 return N->getOpcode() == ISD::Constant ||
1663 N->getOpcode() == ISD::TargetConstant;
1664 }
1665};
1666
1668 return cast<ConstantSDNode>(getOperand(Num))->getZExtValue();
1669}
1670
1672 return cast<ConstantSDNode>(this)->getZExtValue();
1673}
1674
1675const APInt &SDNode::getConstantOperandAPInt(unsigned Num) const {
1676 return cast<ConstantSDNode>(getOperand(Num))->getAPIntValue();
1677}
1678
1680 return cast<ConstantSDNode>(this)->getAPIntValue();
1681}
1682
1683class ConstantFPSDNode : public SDNode {
1684 friend class SelectionDAG;
1685
1686 const ConstantFP *Value;
1687
1688 ConstantFPSDNode(bool isTarget, const ConstantFP *val, SDVTList VTs)
1689 : SDNode(isTarget ? ISD::TargetConstantFP : ISD::ConstantFP, 0,
1690 DebugLoc(), VTs),
1691 Value(val) {}
1692
1693public:
1694 const APFloat& getValueAPF() const { return Value->getValueAPF(); }
1695 const ConstantFP *getConstantFPValue() const { return Value; }
1696
1697 /// Return true if the value is positive or negative zero.
1698 bool isZero() const { return Value->isZero(); }
1699
1700 /// Return true if the value is a NaN.
1701 bool isNaN() const { return Value->isNaN(); }
1702
1703 /// Return true if the value is an infinity
1704 bool isInfinity() const { return Value->isInfinity(); }
1705
1706 /// Return true if the value is negative.
1707 bool isNegative() const { return Value->isNegative(); }
1708
1709 /// We don't rely on operator== working on double values, as
1710 /// it returns true for things that are clearly not equal, like -0.0 and 0.0.
1711 /// As such, this method can be used to do an exact bit-for-bit comparison of
1712 /// two floating point values.
1713
1714 /// We leave the version with the double argument here because it's just so
1715 /// convenient to write "2.0" and the like. Without this function we'd
1716 /// have to duplicate its logic everywhere it's called.
1717 bool isExactlyValue(double V) const {
1718 return Value->getValueAPF().isExactlyValue(V);
1719 }
1720 bool isExactlyValue(const APFloat& V) const;
1721
1722 static bool isValueValidForType(EVT VT, const APFloat& Val);
1723
1724 static bool classof(const SDNode *N) {
1725 return N->getOpcode() == ISD::ConstantFP ||
1726 N->getOpcode() == ISD::TargetConstantFP;
1727 }
1728};
1729
1730/// Returns true if \p V is a constant integer zero.
1731bool isNullConstant(SDValue V);
1732
1733/// Returns true if \p V is an FP constant with a value of positive zero.
1734bool isNullFPConstant(SDValue V);
1735
1736/// Returns true if \p V is an integer constant with all bits set.
1737bool isAllOnesConstant(SDValue V);
1738
1739/// Returns true if \p V is a constant integer one.
1740bool isOneConstant(SDValue V);
1741
1742/// Returns true if \p V is a constant min signed integer value.
1743bool isMinSignedConstant(SDValue V);
1744
1745/// Returns true if \p V is a neutral element of Opc with Flags.
1746/// When OperandNo is 0, it checks that V is a left identity. Otherwise, it
1747/// checks that V is a right identity.
1748bool isNeutralConstant(unsigned Opc, SDNodeFlags Flags, SDValue V,
1749 unsigned OperandNo);
1750
1751/// Return the non-bitcasted source operand of \p V if it exists.
1752/// If \p V is not a bitcasted value, it is returned as-is.
1753SDValue peekThroughBitcasts(SDValue V);
1754
1755/// Return the non-bitcasted and one-use source operand of \p V if it exists.
1756/// If \p V is not a bitcasted one-use value, it is returned as-is.
1757SDValue peekThroughOneUseBitcasts(SDValue V);
1758
1759/// Return the non-extracted vector source operand of \p V if it exists.
1760/// If \p V is not an extracted subvector, it is returned as-is.
1761SDValue peekThroughExtractSubvectors(SDValue V);
1762
1763/// Return the non-truncated source operand of \p V if it exists.
1764/// If \p V is not a truncation, it is returned as-is.
1765SDValue peekThroughTruncates(SDValue V);
1766
1767/// Returns true if \p V is a bitwise not operation. Assumes that an all ones
1768/// constant is canonicalized to be operand 1.
1769bool isBitwiseNot(SDValue V, bool AllowUndefs = false);
1770
1771/// If \p V is a bitwise not, returns the inverted operand. Otherwise returns
1772/// an empty SDValue. Only bits set in \p Mask are required to be inverted,
1773/// other bits may be arbitrary.
1774SDValue getBitwiseNotOperand(SDValue V, SDValue Mask, bool AllowUndefs);
1775
1776/// Returns the SDNode if it is a constant splat BuildVector or constant int.
1777ConstantSDNode *isConstOrConstSplat(SDValue N, bool AllowUndefs = false,
1778 bool AllowTruncation = false);
1779
1780/// Returns the SDNode if it is a demanded constant splat BuildVector or
1781/// constant int.
1782ConstantSDNode *isConstOrConstSplat(SDValue N, const APInt &DemandedElts,
1783 bool AllowUndefs = false,
1784 bool AllowTruncation = false);
1785
1786/// Returns the SDNode if it is a constant splat BuildVector or constant float.
1787ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, bool AllowUndefs = false);
1788
1789/// Returns the SDNode if it is a demanded constant splat BuildVector or
1790/// constant float.
1791ConstantFPSDNode *isConstOrConstSplatFP(SDValue N, const APInt &DemandedElts,
1792 bool AllowUndefs = false);
1793
1794/// Return true if the value is a constant 0 integer or a splatted vector of
1795/// a constant 0 integer (with no undefs by default).
1796/// Build vector implicit truncation is not an issue for null values.
1797bool isNullOrNullSplat(SDValue V, bool AllowUndefs = false);
1798
1799/// Return true if the value is a constant 1 integer or a splatted vector of a
1800/// constant 1 integer (with no undefs).
1801/// Build vector implicit truncation is allowed, but the truncated bits need to
1802/// be zero.
1803bool isOneOrOneSplat(SDValue V, bool AllowUndefs = false);
1804
1805/// Return true if the value is a constant -1 integer or a splatted vector of a
1806/// constant -1 integer (with no undefs).
1807/// Does not permit build vector implicit truncation.
1808bool isAllOnesOrAllOnesSplat(SDValue V, bool AllowUndefs = false);
1809
1810/// Return true if \p V is either a integer or FP constant.
1812 return isa<ConstantSDNode>(V) || isa<ConstantFPSDNode>(V);
1813}
1814
1816 friend class SelectionDAG;
1817
1818 const GlobalValue *TheGlobal;
1819 int64_t Offset;
1820 unsigned TargetFlags;
1821
1822 GlobalAddressSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL,
1823 const GlobalValue *GA, SDVTList VTs, int64_t o,
1824 unsigned TF)
1825 : SDNode(Opc, Order, DL, VTs), TheGlobal(GA), Offset(o), TargetFlags(TF) {
1826 }
1827
1828public:
1829 const GlobalValue *getGlobal() const { return TheGlobal; }
1830 int64_t getOffset() const { return Offset; }
1831 unsigned getTargetFlags() const { return TargetFlags; }
1832 // Return the address space this GlobalAddress belongs to.
1833 unsigned getAddressSpace() const;
1834
1835 static bool classof(const SDNode *N) {
1836 return N->getOpcode() == ISD::GlobalAddress ||
1837 N->getOpcode() == ISD::TargetGlobalAddress ||
1838 N->getOpcode() == ISD::GlobalTLSAddress ||
1839 N->getOpcode() == ISD::TargetGlobalTLSAddress;
1840 }
1841};
1842
1843class FrameIndexSDNode : public SDNode {
1844 friend class SelectionDAG;
1845
1846 int FI;
1847
1848 FrameIndexSDNode(int fi, SDVTList VTs, bool isTarg)
1849 : SDNode(isTarg ? ISD::TargetFrameIndex : ISD::FrameIndex, 0, DebugLoc(),
1850 VTs),
1851 FI(fi) {}
1852
1853public:
1854 int getIndex() const { return FI; }
1855
1856 static bool classof(const SDNode *N) {
1857 return N->getOpcode() == ISD::FrameIndex ||
1858 N->getOpcode() == ISD::TargetFrameIndex;
1859 }
1860};
1861
1862/// This SDNode is used for LIFETIME_START/LIFETIME_END values, which indicate
1863/// the offet and size that are started/ended in the underlying FrameIndex.
1864class LifetimeSDNode : public SDNode {
1865 friend class SelectionDAG;
1866 int64_t Size;
1867 int64_t Offset; // -1 if offset is unknown.
1868
1869 LifetimeSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl,
1870 SDVTList VTs, int64_t Size, int64_t Offset)
1871 : SDNode(Opcode, Order, dl, VTs), Size(Size), Offset(Offset) {}
1872public:
1873 int64_t getFrameIndex() const {
1874 return cast<FrameIndexSDNode>(getOperand(1))->getIndex();
1875 }
1876
1877 bool hasOffset() const { return Offset >= 0; }
1878 int64_t getOffset() const {
1879 assert(hasOffset() && "offset is unknown");
1880 return Offset;
1881 }
1882 int64_t getSize() const {
1883 assert(hasOffset() && "offset is unknown");
1884 return Size;
1885 }
1886
1887 // Methods to support isa and dyn_cast
1888 static bool classof(const SDNode *N) {
1889 return N->getOpcode() == ISD::LIFETIME_START ||
1890 N->getOpcode() == ISD::LIFETIME_END;
1891 }
1892};
1893
1894/// This SDNode is used for PSEUDO_PROBE values, which are the function guid and
1895/// the index of the basic block being probed. A pseudo probe serves as a place
1896/// holder and will be removed at the end of compilation. It does not have any
1897/// operand because we do not want the instruction selection to deal with any.
1899 friend class SelectionDAG;
1900 uint64_t Guid;
1902 uint32_t Attributes;
1903
1904 PseudoProbeSDNode(unsigned Opcode, unsigned Order, const DebugLoc &Dl,
1905 SDVTList VTs, uint64_t Guid, uint64_t Index, uint32_t Attr)
1906 : SDNode(Opcode, Order, Dl, VTs), Guid(Guid), Index(Index),
1907 Attributes(Attr) {}
1908
1909public:
1910 uint64_t getGuid() const { return Guid; }
1911 uint64_t getIndex() const { return Index; }
1913
1914 // Methods to support isa and dyn_cast
1915 static bool classof(const SDNode *N) {
1916 return N->getOpcode() == ISD::PSEUDO_PROBE;
1917 }
1918};
1919
1920class JumpTableSDNode : public SDNode {
1921 friend class SelectionDAG;
1922
1923 int JTI;
1924 unsigned TargetFlags;
1925
1926 JumpTableSDNode(int jti, SDVTList VTs, bool isTarg, unsigned TF)
1927 : SDNode(isTarg ? ISD::TargetJumpTable : ISD::JumpTable, 0, DebugLoc(),
1928 VTs),
1929 JTI(jti), TargetFlags(TF) {}
1930
1931public:
1932 int getIndex() const { return JTI; }
1933 unsigned getTargetFlags() const { return TargetFlags; }
1934
1935 static bool classof(const SDNode *N) {
1936 return N->getOpcode() == ISD::JumpTable ||
1937 N->getOpcode() == ISD::TargetJumpTable;
1938 }
1939};
1940
1942 friend class SelectionDAG;
1943
1944 union {
1947 } Val;
1948 int Offset; // It's a MachineConstantPoolValue if top bit is set.
1949 Align Alignment; // Minimum alignment requirement of CP.
1950 unsigned TargetFlags;
1951
1952 ConstantPoolSDNode(bool isTarget, const Constant *c, SDVTList VTs, int o,
1953 Align Alignment, unsigned TF)
1954 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1955 DebugLoc(), VTs),
1956 Offset(o), Alignment(Alignment), TargetFlags(TF) {
1957 assert(Offset >= 0 && "Offset is too large");
1958 Val.ConstVal = c;
1959 }
1960
1961 ConstantPoolSDNode(bool isTarget, MachineConstantPoolValue *v, SDVTList VTs,
1962 int o, Align Alignment, unsigned TF)
1963 : SDNode(isTarget ? ISD::TargetConstantPool : ISD::ConstantPool, 0,
1964 DebugLoc(), VTs),
1965 Offset(o), Alignment(Alignment), TargetFlags(TF) {
1966 assert(Offset >= 0 && "Offset is too large");
1967 Val.MachineCPVal = v;
1968 Offset |= 1 << (sizeof(unsigned)*CHAR_BIT-1);
1969 }
1970
1971public:
1973 return Offset < 0;
1974 }
1975
1976 const Constant *getConstVal() const {
1977 assert(!isMachineConstantPoolEntry() && "Wrong constantpool type");
1978 return Val.ConstVal;
1979 }
1980
1982 assert(isMachineConstantPoolEntry() && "Wrong constantpool type");
1983 return Val.MachineCPVal;
1984 }
1985
1986 int getOffset() const {
1987 return Offset & ~(1 << (sizeof(unsigned)*CHAR_BIT-1));
1988 }
1989
1990 // Return the alignment of this constant pool object, which is either 0 (for
1991 // default alignment) or the desired value.
1992 Align getAlign() const { return Alignment; }
1993 unsigned getTargetFlags() const { return TargetFlags; }
1994
1995 Type *getType() const;
1996
1997 static bool classof(const SDNode *N) {
1998 return N->getOpcode() == ISD::ConstantPool ||
1999 N->getOpcode() == ISD::TargetConstantPool;
2000 }
2001};
2002
2003/// Completely target-dependent object reference.
2005 friend class SelectionDAG;
2006
2007 unsigned TargetFlags;
2008 int Index;
2009 int64_t Offset;
2010
2011public:
2012 TargetIndexSDNode(int Idx, SDVTList VTs, int64_t Ofs, unsigned TF)
2013 : SDNode(ISD::TargetIndex, 0, DebugLoc(), VTs), TargetFlags(TF),
2014 Index(Idx), Offset(Ofs) {}
2015
2016 unsigned getTargetFlags() const { return TargetFlags; }
2017 int getIndex() const { return Index; }
2018 int64_t getOffset() const { return Offset; }
2019
2020 static bool classof(const SDNode *N) {
2021 return N->getOpcode() == ISD::TargetIndex;
2022 }
2023};
2024
2025class BasicBlockSDNode : public SDNode {
2026 friend class SelectionDAG;
2027
2029
2030 /// Debug info is meaningful and potentially useful here, but we create
2031 /// blocks out of order when they're jumped to, which makes it a bit
2032 /// harder. Let's see if we need it first.
2033 explicit BasicBlockSDNode(MachineBasicBlock *mbb)
2034 : SDNode(ISD::BasicBlock, 0, DebugLoc(), getSDVTList(MVT::Other)), MBB(mbb)
2035 {}
2036
2037public:
2039
2040 static bool classof(const SDNode *N) {
2041 return N->getOpcode() == ISD::BasicBlock;
2042 }
2043};
2044
2045/// A "pseudo-class" with methods for operating on BUILD_VECTORs.
2047public:
2048 // These are constructed as SDNodes and then cast to BuildVectorSDNodes.
2049 explicit BuildVectorSDNode() = delete;
2050
2051 /// Check if this is a constant splat, and if so, find the
2052 /// smallest element size that splats the vector. If MinSplatBits is
2053 /// nonzero, the element size must be at least that large. Note that the
2054 /// splat element may be the entire vector (i.e., a one element vector).
2055 /// Returns the splat element value in SplatValue. Any undefined bits in
2056 /// that value are zero, and the corresponding bits in the SplatUndef mask
2057 /// are set. The SplatBitSize value is set to the splat element size in
2058 /// bits. HasAnyUndefs is set to true if any bits in the vector are
2059 /// undefined. isBigEndian describes the endianness of the target.
2060 bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef,
2061 unsigned &SplatBitSize, bool &HasAnyUndefs,
2062 unsigned MinSplatBits = 0,
2063 bool isBigEndian = false) const;
2064
2065 /// Returns the demanded splatted value or a null value if this is not a
2066 /// splat.
2067 ///
2068 /// The DemandedElts mask indicates the elements that must be in the splat.
2069 /// If passed a non-null UndefElements bitvector, it will resize it to match
2070 /// the vector width and set the bits where elements are undef.
2071 SDValue getSplatValue(const APInt &DemandedElts,
2072 BitVector *UndefElements = nullptr) const;
2073
2074 /// Returns the splatted value or a null value if this is not a splat.
2075 ///
2076 /// If passed a non-null UndefElements bitvector, it will resize it to match
2077 /// the vector width and set the bits where elements are undef.
2078 SDValue getSplatValue(BitVector *UndefElements = nullptr) const;
2079
2080 /// Find the shortest repeating sequence of values in the build vector.
2081 ///
2082 /// e.g. { u, X, u, X, u, u, X, u } -> { X }
2083 /// { X, Y, u, Y, u, u, X, u } -> { X, Y }
2084 ///
2085 /// Currently this must be a power-of-2 build vector.
2086 /// The DemandedElts mask indicates the elements that must be present,
2087 /// undemanded elements in Sequence may be null (SDValue()). If passed a
2088 /// non-null UndefElements bitvector, it will resize it to match the original
2089 /// vector width and set the bits where elements are undef. If result is
2090 /// false, Sequence will be empty.
2091 bool getRepeatedSequence(const APInt &DemandedElts,
2092 SmallVectorImpl<SDValue> &Sequence,
2093 BitVector *UndefElements = nullptr) const;
2094
2095 /// Find the shortest repeating sequence of values in the build vector.
2096 ///
2097 /// e.g. { u, X, u, X, u, u, X, u } -> { X }
2098 /// { X, Y, u, Y, u, u, X, u } -> { X, Y }
2099 ///
2100 /// Currently this must be a power-of-2 build vector.
2101 /// If passed a non-null UndefElements bitvector, it will resize it to match
2102 /// the original vector width and set the bits where elements are undef.
2103 /// If result is false, Sequence will be empty.
2105 BitVector *UndefElements = nullptr) const;
2106
2107 /// Returns the demanded splatted constant or null if this is not a constant
2108 /// splat.
2109 ///
2110 /// The DemandedElts mask indicates the elements that must be in the splat.
2111 /// If passed a non-null UndefElements bitvector, it will resize it to match
2112 /// the vector width and set the bits where elements are undef.
2114 getConstantSplatNode(const APInt &DemandedElts,
2115 BitVector *UndefElements = nullptr) const;
2116
2117 /// Returns the splatted constant or null if this is not a constant
2118 /// splat.
2119 ///
2120 /// If passed a non-null UndefElements bitvector, it will resize it to match
2121 /// the vector width and set the bits where elements are undef.
2123 getConstantSplatNode(BitVector *UndefElements = nullptr) const;
2124
2125 /// Returns the demanded splatted constant FP or null if this is not a
2126 /// constant FP splat.
2127 ///
2128 /// The DemandedElts mask indicates the elements that must be in the splat.
2129 /// If passed a non-null UndefElements bitvector, it will resize it to match
2130 /// the vector width and set the bits where elements are undef.
2132 getConstantFPSplatNode(const APInt &DemandedElts,
2133 BitVector *UndefElements = nullptr) const;
2134
2135 /// Returns the splatted constant FP or null if this is not a constant
2136 /// FP splat.
2137 ///
2138 /// If passed a non-null UndefElements bitvector, it will resize it to match
2139 /// the vector width and set the bits where elements are undef.
2141 getConstantFPSplatNode(BitVector *UndefElements = nullptr) const;
2142
2143 /// If this is a constant FP splat and the splatted constant FP is an
2144 /// exact power or 2, return the log base 2 integer value. Otherwise,
2145 /// return -1.
2146 ///
2147 /// The BitWidth specifies the necessary bit precision.
2148 int32_t getConstantFPSplatPow2ToLog2Int(BitVector *UndefElements,
2149 uint32_t BitWidth) const;
2150
2151 /// Extract the raw bit data from a build vector of Undef, Constant or
2152 /// ConstantFP node elements. Each raw bit element will be \p
2153 /// DstEltSizeInBits wide, undef elements are treated as zero, and entirely
2154 /// undefined elements are flagged in \p UndefElements.
2155 bool getConstantRawBits(bool IsLittleEndian, unsigned DstEltSizeInBits,
2156 SmallVectorImpl<APInt> &RawBitElements,
2157 BitVector &UndefElements) const;
2158
2159 bool isConstant() const;
2160
2161 /// If this BuildVector is constant and represents the numerical series
2162 /// "<a, a+n, a+2n, a+3n, ...>" where a is integer and n is a non-zero integer,
2163 /// the value "<a,n>" is returned.
2164 std::optional<std::pair<APInt, APInt>> isConstantSequence() const;
2165
2166 /// Recast bit data \p SrcBitElements to \p DstEltSizeInBits wide elements.
2167 /// Undef elements are treated as zero, and entirely undefined elements are
2168 /// flagged in \p DstUndefElements.
2169 static void recastRawBits(bool IsLittleEndian, unsigned DstEltSizeInBits,
2170 SmallVectorImpl<APInt> &DstBitElements,
2171 ArrayRef<APInt> SrcBitElements,
2172 BitVector &DstUndefElements,
2173 const BitVector &SrcUndefElements);
2174
2175 static bool classof(const SDNode *N) {
2176 return N->getOpcode() == ISD::BUILD_VECTOR;
2177 }
2178};
2179
2180/// An SDNode that holds an arbitrary LLVM IR Value. This is
2181/// used when the SelectionDAG needs to make a simple reference to something
2182/// in the LLVM IR representation.
2183///
2184class SrcValueSDNode : public SDNode {
2185 friend class SelectionDAG;
2186
2187 const Value *V;
2188
2189 /// Create a SrcValue for a general value.
2190 explicit SrcValueSDNode(const Value *v)
2191 : SDNode(ISD::SRCVALUE, 0, DebugLoc(), getSDVTList(MVT::Other)), V(v) {}
2192
2193public:
2194 /// Return the contained Value.
2195 const Value *getValue() const { return V; }
2196
2197 static bool classof(const SDNode *N) {
2198 return N->getOpcode() == ISD::SRCVALUE;
2199 }
2200};
2201
2202class MDNodeSDNode : public SDNode {
2203 friend class SelectionDAG;
2204
2205 const MDNode *MD;
2206
2207 explicit MDNodeSDNode(const MDNode *md)
2208 : SDNode(ISD::MDNODE_SDNODE, 0, DebugLoc(), getSDVTList(MVT::Other)), MD(md)
2209 {}
2210
2211public:
2212 const MDNode *getMD() const { return MD; }
2213
2214 static bool classof(const SDNode *N) {
2215 return N->getOpcode() == ISD::MDNODE_SDNODE;
2216 }
2217};
2218
2219class RegisterSDNode : public SDNode {
2220 friend class SelectionDAG;
2221
2222 Register Reg;
2223
2225 : SDNode(ISD::Register, 0, DebugLoc(), VTs), Reg(reg) {}
2226
2227public:
2228 Register getReg() const { return Reg; }
2229
2230 static bool classof(const SDNode *N) {
2231 return N->getOpcode() == ISD::Register;
2232 }
2233};
2234
2236 friend class SelectionDAG;
2237
2238 // The memory for RegMask is not owned by the node.
2239 const uint32_t *RegMask;
2240
2241 RegisterMaskSDNode(const uint32_t *mask)
2242 : SDNode(ISD::RegisterMask, 0, DebugLoc(), getSDVTList(MVT::Untyped)),
2243 RegMask(mask) {}
2244
2245public:
2246 const uint32_t *getRegMask() const { return RegMask; }
2247
2248 static bool classof(const SDNode *N) {
2249 return N->getOpcode() == ISD::RegisterMask;
2250 }
2251};
2252
2254 friend class SelectionDAG;
2255
2256 const BlockAddress *BA;
2257 int64_t Offset;
2258 unsigned TargetFlags;
2259
2260 BlockAddressSDNode(unsigned NodeTy, SDVTList VTs, const BlockAddress *ba,
2261 int64_t o, unsigned Flags)
2262 : SDNode(NodeTy, 0, DebugLoc(), VTs), BA(ba), Offset(o),
2263 TargetFlags(Flags) {}
2264
2265public:
2266 const BlockAddress *getBlockAddress() const { return BA; }
2267 int64_t getOffset() const { return Offset; }
2268 unsigned getTargetFlags() const { return TargetFlags; }
2269
2270 static bool classof(const SDNode *N) {
2271 return N->getOpcode() == ISD::BlockAddress ||
2272 N->getOpcode() == ISD::TargetBlockAddress;
2273 }
2274};
2275
2276class LabelSDNode : public SDNode {
2277 friend class SelectionDAG;
2278
2279 MCSymbol *Label;
2280
2281 LabelSDNode(unsigned Opcode, unsigned Order, const DebugLoc &dl, MCSymbol *L)
2282 : SDNode(Opcode, Order, dl, getSDVTList(MVT::Other)), Label(L) {
2283 assert(LabelSDNode::classof(this) && "not a label opcode");
2284 }
2285
2286public:
2287 MCSymbol *getLabel() const { return Label; }
2288
2289 static bool classof(const SDNode *N) {
2290 return N->getOpcode() == ISD::EH_LABEL ||
2291 N->getOpcode() == ISD::ANNOTATION_LABEL;
2292 }
2293};
2294
2296 friend class SelectionDAG;
2297
2298 const char *Symbol;
2299 unsigned TargetFlags;
2300
2301 ExternalSymbolSDNode(bool isTarget, const char *Sym, unsigned TF,
2302 SDVTList VTs)
2303 : SDNode(isTarget ? ISD::TargetExternalSymbol : ISD::ExternalSymbol, 0,
2304 DebugLoc(), VTs),
2305 Symbol(Sym), TargetFlags(TF) {}
2306
2307public:
2308 const char *getSymbol() const { return Symbol; }
2309 unsigned getTargetFlags() const { return TargetFlags; }
2310
2311 static bool classof(const SDNode *N) {
2312 return N->getOpcode() == ISD::ExternalSymbol ||
2313 N->getOpcode() == ISD::TargetExternalSymbol;
2314 }
2315};
2316
2317class MCSymbolSDNode : public SDNode {
2318 friend class SelectionDAG;
2319
2320 MCSymbol *Symbol;
2321
2322 MCSymbolSDNode(MCSymbol *Symbol, SDVTList VTs)
2323 : SDNode(ISD::MCSymbol, 0, DebugLoc(), VTs), Symbol(Symbol) {}
2324
2325public:
2326 MCSymbol *getMCSymbol() const { return Symbol; }
2327
2328 static bool classof(const SDNode *N) {
2329 return N->getOpcode() == ISD::MCSymbol;
2330 }
2331};
2332
2333class CondCodeSDNode : public SDNode {
2334 friend class SelectionDAG;
2335
2336 ISD::CondCode Condition;
2337
2339 : SDNode(ISD::CONDCODE, 0, DebugLoc(), getSDVTList(MVT::Other)),
2340 Condition(Cond) {}
2341
2342public:
2343 ISD::CondCode get() const { return Condition; }
2344
2345 static bool classof(const SDNode *N) {
2346 return N->getOpcode() == ISD::CONDCODE;
2347 }
2348};
2349
2350/// This class is used to represent EVT's, which are used
2351/// to parameterize some operations.
2352class VTSDNode : public SDNode {
2353 friend class SelectionDAG;
2354
2355 EVT ValueType;
2356
2357 explicit VTSDNode(EVT VT)
2358 : SDNode(ISD::VALUETYPE, 0, DebugLoc(), getSDVTList(MVT::Other)),
2359 ValueType(VT) {}
2360
2361public:
2362 EVT getVT() const { return ValueType; }
2363
2364 static bool classof(const SDNode *N) {
2365 return N->getOpcode() == ISD::VALUETYPE;
2366 }
2367};
2368
2369/// Base class for LoadSDNode and StoreSDNode
2370class LSBaseSDNode : public MemSDNode {
2371public:
2372 LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl,
2373 SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT,
2375 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
2376 LSBaseSDNodeBits.AddressingMode = AM;
2377 assert(getAddressingMode() == AM && "Value truncated");
2378 }
2379
2380 const SDValue &getOffset() const {
2381 return getOperand(getOpcode() == ISD::LOAD ? 2 : 3);
2382 }
2383
2384 /// Return the addressing mode for this load or store:
2385 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2387 return static_cast<ISD::MemIndexedMode>(LSBaseSDNodeBits.AddressingMode);
2388 }
2389
2390 /// Return true if this is a pre/post inc/dec load/store.
2391 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2392
2393 /// Return true if this is NOT a pre/post inc/dec load/store.
2394 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2395
2396 static bool classof(const SDNode *N) {
2397 return N->getOpcode() == ISD::LOAD ||
2398 N->getOpcode() == ISD::STORE;
2399 }
2400};
2401
2402/// This class is used to represent ISD::LOAD nodes.
2403class LoadSDNode : public LSBaseSDNode {
2404 friend class SelectionDAG;
2405
2406 LoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2409 : LSBaseSDNode(ISD::LOAD, Order, dl, VTs, AM, MemVT, MMO) {
2410 LoadSDNodeBits.ExtTy = ETy;
2411 assert(readMem() && "Load MachineMemOperand is not a load!");
2412 assert(!writeMem() && "Load MachineMemOperand is a store!");
2413 }
2414
2415public:
2416 /// Return whether this is a plain node,
2417 /// or one of the varieties of value-extending loads.
2419 return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy);
2420 }
2421
2422 const SDValue &getBasePtr() const { return getOperand(1); }
2423 const SDValue &getOffset() const { return getOperand(2); }
2424
2425 static bool classof(const SDNode *N) {
2426 return N->getOpcode() == ISD::LOAD;
2427 }
2428};
2429
2430/// This class is used to represent ISD::STORE nodes.
2432 friend class SelectionDAG;
2433
2434 StoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2435 ISD::MemIndexedMode AM, bool isTrunc, EVT MemVT,
2437 : LSBaseSDNode(ISD::STORE, Order, dl, VTs, AM, MemVT, MMO) {
2438 StoreSDNodeBits.IsTruncating = isTrunc;
2439 assert(!readMem() && "Store MachineMemOperand is a load!");
2440 assert(writeMem() && "Store MachineMemOperand is not a store!");
2441 }
2442
2443public:
2444 /// Return true if the op does a truncation before store.
2445 /// For integers this is the same as doing a TRUNCATE and storing the result.
2446 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2447 bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2448 void setTruncatingStore(bool Truncating) {
2449 StoreSDNodeBits.IsTruncating = Truncating;
2450 }
2451
2452 const SDValue &getValue() const { return getOperand(1); }
2453 const SDValue &getBasePtr() const { return getOperand(2); }
2454 const SDValue &getOffset() const { return getOperand(3); }
2455
2456 static bool classof(const SDNode *N) {
2457 return N->getOpcode() == ISD::STORE;
2458 }
2459};
2460
2461/// This base class is used to represent VP_LOAD, VP_STORE,
2462/// EXPERIMENTAL_VP_STRIDED_LOAD and EXPERIMENTAL_VP_STRIDED_STORE nodes
2464public:
2465 friend class SelectionDAG;
2466
2467 VPBaseLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order,
2468 const DebugLoc &DL, SDVTList VTs,
2469 ISD::MemIndexedMode AM, EVT MemVT,
2471 : MemSDNode(NodeTy, Order, DL, VTs, MemVT, MMO) {
2472 LSBaseSDNodeBits.AddressingMode = AM;
2473 assert(getAddressingMode() == AM && "Value truncated");
2474 }
2475
2476 // VPStridedStoreSDNode (Chain, Data, Ptr, Offset, Stride, Mask, EVL)
2477 // VPStoreSDNode (Chain, Data, Ptr, Offset, Mask, EVL)
2478 // VPStridedLoadSDNode (Chain, Ptr, Offset, Stride, Mask, EVL)
2479 // VPLoadSDNode (Chain, Ptr, Offset, Mask, EVL)
2480 // Mask is a vector of i1 elements;
2481 // the type of EVL is TLI.getVPExplicitVectorLengthTy().
2482 const SDValue &getOffset() const {
2483 return getOperand((getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD ||
2484 getOpcode() == ISD::VP_LOAD)
2485 ? 2
2486 : 3);
2487 }
2488 const SDValue &getBasePtr() const {
2489 return getOperand((getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD ||
2490 getOpcode() == ISD::VP_LOAD)
2491 ? 1
2492 : 2);
2493 }
2494 const SDValue &getMask() const {
2495 switch (getOpcode()) {
2496 default:
2497 llvm_unreachable("Invalid opcode");
2498 case ISD::VP_LOAD:
2499 return getOperand(3);
2500 case ISD::VP_STORE:
2501 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2502 return getOperand(4);
2503 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2504 return getOperand(5);
2505 }
2506 }
2507 const SDValue &getVectorLength() const {
2508 switch (getOpcode()) {
2509 default:
2510 llvm_unreachable("Invalid opcode");
2511 case ISD::VP_LOAD:
2512 return getOperand(4);
2513 case ISD::VP_STORE:
2514 case ISD::EXPERIMENTAL_VP_STRIDED_LOAD:
2515 return getOperand(5);
2516 case ISD::EXPERIMENTAL_VP_STRIDED_STORE:
2517 return getOperand(6);
2518 }
2519 }
2520
2521 /// Return the addressing mode for this load or store:
2522 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2524 return static_cast<ISD::MemIndexedMode>(LSBaseSDNodeBits.AddressingMode);
2525 }
2526
2527 /// Return true if this is a pre/post inc/dec load/store.
2528 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2529
2530 /// Return true if this is NOT a pre/post inc/dec load/store.
2531 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2532
2533 static bool classof(const SDNode *N) {
2534 return N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD ||
2535 N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE ||
2536 N->getOpcode() == ISD::VP_LOAD || N->getOpcode() == ISD::VP_STORE;
2537 }
2538};
2539
2540/// This class is used to represent a VP_LOAD node
2542public:
2543 friend class SelectionDAG;
2544
2545 VPLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2546 ISD::MemIndexedMode AM, ISD::LoadExtType ETy, bool isExpanding,
2547 EVT MemVT, MachineMemOperand *MMO)
2548 : VPBaseLoadStoreSDNode(ISD::VP_LOAD, Order, dl, VTs, AM, MemVT, MMO) {
2549 LoadSDNodeBits.ExtTy = ETy;
2550 LoadSDNodeBits.IsExpanding = isExpanding;
2551 }
2552
2554 return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy);
2555 }
2556
2557 const SDValue &getBasePtr() const { return getOperand(1); }
2558 const SDValue &getOffset() const { return getOperand(2); }
2559 const SDValue &getMask() const { return getOperand(3); }
2560 const SDValue &getVectorLength() const { return getOperand(4); }
2561
2562 static bool classof(const SDNode *N) {
2563 return N->getOpcode() == ISD::VP_LOAD;
2564 }
2565 bool isExpandingLoad() const { return LoadSDNodeBits.IsExpanding; }
2566};
2567
2568/// This class is used to represent an EXPERIMENTAL_VP_STRIDED_LOAD node.
2570public:
2571 friend class SelectionDAG;
2572
2573 VPStridedLoadSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs,
2575 bool IsExpanding, EVT MemVT, MachineMemOperand *MMO)
2576 : VPBaseLoadStoreSDNode(ISD::EXPERIMENTAL_VP_STRIDED_LOAD, Order, DL, VTs,
2577 AM, MemVT, MMO) {
2578 LoadSDNodeBits.ExtTy = ETy;
2579 LoadSDNodeBits.IsExpanding = IsExpanding;
2580 }
2581
2583 return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy);
2584 }
2585
2586 const SDValue &getBasePtr() const { return getOperand(1); }
2587 const SDValue &getOffset() const { return getOperand(2); }
2588 const SDValue &getStride() const { return getOperand(3); }
2589 const SDValue &getMask() const { return getOperand(4); }
2590 const SDValue &getVectorLength() const { return getOperand(5); }
2591
2592 static bool classof(const SDNode *N) {
2593 return N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_LOAD;
2594 }
2595 bool isExpandingLoad() const { return LoadSDNodeBits.IsExpanding; }
2596};
2597
2598/// This class is used to represent a VP_STORE node
2600public:
2601 friend class SelectionDAG;
2602
2603 VPStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2604 ISD::MemIndexedMode AM, bool isTrunc, bool isCompressing,
2605 EVT MemVT, MachineMemOperand *MMO)
2606 : VPBaseLoadStoreSDNode(ISD::VP_STORE, Order, dl, VTs, AM, MemVT, MMO) {
2607 StoreSDNodeBits.IsTruncating = isTrunc;
2608 StoreSDNodeBits.IsCompressing = isCompressing;
2609 }
2610
2611 /// Return true if this is a truncating store.
2612 /// For integers this is the same as doing a TRUNCATE and storing the result.
2613 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2614 bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2615
2616 /// Returns true if the op does a compression to the vector before storing.
2617 /// The node contiguously stores the active elements (integers or floats)
2618 /// in src (those with their respective bit set in writemask k) to unaligned
2619 /// memory at base_addr.
2620 bool isCompressingStore() const { return StoreSDNodeBits.IsCompressing; }
2621
2622 const SDValue &getValue() const { return getOperand(1); }
2623 const SDValue &getBasePtr() const { return getOperand(2); }
2624 const SDValue &getOffset() const { return getOperand(3); }
2625 const SDValue &getMask() const { return getOperand(4); }
2626 const SDValue &getVectorLength() const { return getOperand(5); }
2627
2628 static bool classof(const SDNode *N) {
2629 return N->getOpcode() == ISD::VP_STORE;
2630 }
2631};
2632
2633/// This class is used to represent an EXPERIMENTAL_VP_STRIDED_STORE node.
2635public:
2636 friend class SelectionDAG;
2637
2638 VPStridedStoreSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs,
2639 ISD::MemIndexedMode AM, bool IsTrunc, bool IsCompressing,
2640 EVT MemVT, MachineMemOperand *MMO)
2641 : VPBaseLoadStoreSDNode(ISD::EXPERIMENTAL_VP_STRIDED_STORE, Order, DL,
2642 VTs, AM, MemVT, MMO) {
2643 StoreSDNodeBits.IsTruncating = IsTrunc;
2644 StoreSDNodeBits.IsCompressing = IsCompressing;
2645 }
2646
2647 /// Return true if this is a truncating store.
2648 /// For integers this is the same as doing a TRUNCATE and storing the result.
2649 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2650 bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2651
2652 /// Returns true if the op does a compression to the vector before storing.
2653 /// The node contiguously stores the active elements (integers or floats)
2654 /// in src (those with their respective bit set in writemask k) to unaligned
2655 /// memory at base_addr.
2656 bool isCompressingStore() const { return StoreSDNodeBits.IsCompressing; }
2657
2658 const SDValue &getValue() const { return getOperand(1); }
2659 const SDValue &getBasePtr() const { return getOperand(2); }
2660 const SDValue &getOffset() const { return getOperand(3); }
2661 const SDValue &getStride() const { return getOperand(4); }
2662 const SDValue &getMask() const { return getOperand(5); }
2663 const SDValue &getVectorLength() const { return getOperand(6); }
2664
2665 static bool classof(const SDNode *N) {
2666 return N->getOpcode() == ISD::EXPERIMENTAL_VP_STRIDED_STORE;
2667 }
2668};
2669
2670/// This base class is used to represent MLOAD and MSTORE nodes
2672public:
2673 friend class SelectionDAG;
2674
2675 MaskedLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order,
2676 const DebugLoc &dl, SDVTList VTs,
2677 ISD::MemIndexedMode AM, EVT MemVT,
2679 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
2680 LSBaseSDNodeBits.AddressingMode = AM;
2681 assert(getAddressingMode() == AM && "Value truncated");
2682 }
2683
2684 // MaskedLoadSDNode (Chain, ptr, offset, mask, passthru)
2685 // MaskedStoreSDNode (Chain, data, ptr, offset, mask)
2686 // Mask is a vector of i1 elements
2687 const SDValue &getOffset() const {
2688 return getOperand(getOpcode() == ISD::MLOAD ? 2 : 3);
2689 }
2690 const SDValue &getMask() const {
2691 return getOperand(getOpcode() == ISD::MLOAD ? 3 : 4);
2692 }
2693
2694 /// Return the addressing mode for this load or store:
2695 /// unindexed, pre-inc, pre-dec, post-inc, or post-dec.
2697 return static_cast<ISD::MemIndexedMode>(LSBaseSDNodeBits.AddressingMode);
2698 }
2699
2700 /// Return true if this is a pre/post inc/dec load/store.
2701 bool isIndexed() const { return getAddressingMode() != ISD::UNINDEXED; }
2702
2703 /// Return true if this is NOT a pre/post inc/dec load/store.
2704 bool isUnindexed() const { return getAddressingMode() == ISD::UNINDEXED; }
2705
2706 static bool classof(const SDNode *N) {
2707 return N->getOpcode() == ISD::MLOAD ||
2708 N->getOpcode() == ISD::MSTORE;
2709 }
2710};
2711
2712/// This class is used to represent an MLOAD node
2714public:
2715 friend class SelectionDAG;
2716
2717 MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2719 bool IsExpanding, EVT MemVT, MachineMemOperand *MMO)
2720 : MaskedLoadStoreSDNode(ISD::MLOAD, Order, dl, VTs, AM, MemVT, MMO) {
2721 LoadSDNodeBits.ExtTy = ETy;
2722 LoadSDNodeBits.IsExpanding = IsExpanding;
2723 }
2724
2726 return static_cast<ISD::LoadExtType>(LoadSDNodeBits.ExtTy);
2727 }
2728
2729 const SDValue &getBasePtr() const { return getOperand(1); }
2730 const SDValue &getOffset() const { return getOperand(2); }
2731 const SDValue &getMask() const { return getOperand(3); }
2732 const SDValue &getPassThru() const { return getOperand(4); }
2733
2734 static bool classof(const SDNode *N) {
2735 return N->getOpcode() == ISD::MLOAD;
2736 }
2737
2738 bool isExpandingLoad() const { return LoadSDNodeBits.IsExpanding; }
2739};
2740
2741/// This class is used to represent an MSTORE node
2743public:
2744 friend class SelectionDAG;
2745
2746 MaskedStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2747 ISD::MemIndexedMode AM, bool isTrunc, bool isCompressing,
2748 EVT MemVT, MachineMemOperand *MMO)
2749 : MaskedLoadStoreSDNode(ISD::MSTORE, Order, dl, VTs, AM, MemVT, MMO) {
2750 StoreSDNodeBits.IsTruncating = isTrunc;
2751 StoreSDNodeBits.IsCompressing = isCompressing;
2752 }
2753
2754 /// Return true if the op does a truncation before store.
2755 /// For integers this is the same as doing a TRUNCATE and storing the result.
2756 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2757 bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2758
2759 /// Returns true if the op does a compression to the vector before storing.
2760 /// The node contiguously stores the active elements (integers or floats)
2761 /// in src (those with their respective bit set in writemask k) to unaligned
2762 /// memory at base_addr.
2763 bool isCompressingStore() const { return StoreSDNodeBits.IsCompressing; }
2764
2765 const SDValue &getValue() const { return getOperand(1); }
2766 const SDValue &getBasePtr() const { return getOperand(2); }
2767 const SDValue &getOffset() const { return getOperand(3); }
2768 const SDValue &getMask() const { return getOperand(4); }
2769
2770 static bool classof(const SDNode *N) {
2771 return N->getOpcode() == ISD::MSTORE;
2772 }
2773};
2774
2775/// This is a base class used to represent
2776/// VP_GATHER and VP_SCATTER nodes
2777///
2779public:
2780 friend class SelectionDAG;
2781
2782 VPGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order,
2783 const DebugLoc &dl, SDVTList VTs, EVT MemVT,
2785 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
2786 LSBaseSDNodeBits.AddressingMode = IndexType;
2787 assert(getIndexType() == IndexType && "Value truncated");
2788 }
2789
2790 /// How is Index applied to BasePtr when computing addresses.
2792 return static_cast<ISD::MemIndexType>(LSBaseSDNodeBits.AddressingMode);
2793 }
2794 bool isIndexScaled() const {
2795 return !cast<ConstantSDNode>(getScale())->isOne();
2796 }
2797 bool isIndexSigned() const { return isIndexTypeSigned(getIndexType()); }
2798
2799 // In the both nodes address is Op1, mask is Op2:
2800 // VPGatherSDNode (Chain, base, index, scale, mask, vlen)
2801 // VPScatterSDNode (Chain, value, base, index, scale, mask, vlen)
2802 // Mask is a vector of i1 elements
2803 const SDValue &getBasePtr() const {
2804 return getOperand((getOpcode() == ISD::VP_GATHER) ? 1 : 2);
2805 }
2806 const SDValue &getIndex() const {
2807 return getOperand((getOpcode() == ISD::VP_GATHER) ? 2 : 3);
2808 }
2809 const SDValue &getScale() const {
2810 return getOperand((getOpcode() == ISD::VP_GATHER) ? 3 : 4);
2811 }
2812 const SDValue &getMask() const {
2813 return getOperand((getOpcode() == ISD::VP_GATHER) ? 4 : 5);
2814 }
2815 const SDValue &getVectorLength() const {
2816 return getOperand((getOpcode() == ISD::VP_GATHER) ? 5 : 6);
2817 }
2818
2819 static bool classof(const SDNode *N) {
2820 return N->getOpcode() == ISD::VP_GATHER ||
2821 N->getOpcode() == ISD::VP_SCATTER;
2822 }
2823};
2824
2825/// This class is used to represent an VP_GATHER node
2826///
2828public:
2829 friend class SelectionDAG;
2830
2831 VPGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT,
2833 : VPGatherScatterSDNode(ISD::VP_GATHER, Order, dl, VTs, MemVT, MMO,
2834 IndexType) {}
2835
2836 static bool classof(const SDNode *N) {
2837 return N->getOpcode() == ISD::VP_GATHER;
2838 }
2839};
2840
2841/// This class is used to represent an VP_SCATTER node
2842///
2844public:
2845 friend class SelectionDAG;
2846
2847 VPScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT,
2849 : VPGatherScatterSDNode(ISD::VP_SCATTER, Order, dl, VTs, MemVT, MMO,
2850 IndexType) {}
2851
2852 const SDValue &getValue() const { return getOperand(1); }
2853
2854 static bool classof(const SDNode *N) {
2855 return N->getOpcode() == ISD::VP_SCATTER;
2856 }
2857};
2858
2859/// This is a base class used to represent
2860/// MGATHER and MSCATTER nodes
2861///
2863public:
2864 friend class SelectionDAG;
2865
2867 const DebugLoc &dl, SDVTList VTs, EVT MemVT,
2869 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
2870 LSBaseSDNodeBits.AddressingMode = IndexType;
2871 assert(getIndexType() == IndexType && "Value truncated");
2872 }
2873
2874 /// How is Index applied to BasePtr when computing addresses.
2876 return static_cast<ISD::MemIndexType>(LSBaseSDNodeBits.AddressingMode);
2877 }
2878 bool isIndexScaled() const {
2879 return !cast<ConstantSDNode>(getScale())->isOne();
2880 }
2881 bool isIndexSigned() const { return isIndexTypeSigned(getIndexType()); }
2882
2883 // In the both nodes address is Op1, mask is Op2:
2884 // MaskedGatherSDNode (Chain, passthru, mask, base, index, scale)
2885 // MaskedScatterSDNode (Chain, value, mask, base, index, scale)
2886 // Mask is a vector of i1 elements
2887 const SDValue &getBasePtr() const { return getOperand(3); }
2888 const SDValue &getIndex() const { return getOperand(4); }
2889 const SDValue &getMask() const { return getOperand(2); }
2890 const SDValue &getScale() const { return getOperand(5); }
2891
2892 static bool classof(const SDNode *N) {
2893 return N->getOpcode() == ISD::MGATHER ||
2894 N->getOpcode() == ISD::MSCATTER;
2895 }
2896};
2897
2898/// This class is used to represent an MGATHER node
2899///
2901public:
2902 friend class SelectionDAG;
2903
2904 MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2905 EVT MemVT, MachineMemOperand *MMO,
2906 ISD::MemIndexType IndexType, ISD::LoadExtType ETy)
2907 : MaskedGatherScatterSDNode(ISD::MGATHER, Order, dl, VTs, MemVT, MMO,
2908 IndexType) {
2909 LoadSDNodeBits.ExtTy = ETy;
2910 }
2911
2912 const SDValue &getPassThru() const { return getOperand(1); }
2913
2915 return ISD::LoadExtType(LoadSDNodeBits.ExtTy);
2916 }
2917
2918 static bool classof(const SDNode *N) {
2919 return N->getOpcode() == ISD::MGATHER;
2920 }
2921};
2922
2923/// This class is used to represent an MSCATTER node
2924///
2926public:
2927 friend class SelectionDAG;
2928
2929 MaskedScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs,
2930 EVT MemVT, MachineMemOperand *MMO,
2931 ISD::MemIndexType IndexType, bool IsTrunc)
2932 : MaskedGatherScatterSDNode(ISD::MSCATTER, Order, dl, VTs, MemVT, MMO,
2933 IndexType) {
2934 StoreSDNodeBits.IsTruncating = IsTrunc;
2935 }
2936
2937 /// Return true if the op does a truncation before store.
2938 /// For integers this is the same as doing a TRUNCATE and storing the result.
2939 /// For floats, it is the same as doing an FP_ROUND and storing the result.
2940 bool isTruncatingStore() const { return StoreSDNodeBits.IsTruncating; }
2941
2942 const SDValue &getValue() const { return getOperand(1); }
2943
2944 static bool classof(const SDNode *N) {
2945 return N->getOpcode() == ISD::MSCATTER;
2946 }
2947};
2948
2950public:
2951 friend class SelectionDAG;
2952
2953 FPStateAccessSDNode(unsigned NodeTy, unsigned Order, const DebugLoc &dl,
2954 SDVTList VTs, EVT MemVT, MachineMemOperand *MMO)
2955 : MemSDNode(NodeTy, Order, dl, VTs, MemVT, MMO) {
2956 assert((NodeTy == ISD::GET_FPENV_MEM || NodeTy == ISD::SET_FPENV_MEM) &&
2957 "Expected FP state access node");
2958 }
2959
2960 static bool classof(const SDNode *N) {
2961 return N->getOpcode() == ISD::GET_FPENV_MEM ||
2962 N->getOpcode() == ISD::SET_FPENV_MEM;
2963 }
2964};
2965
2966/// An SDNode that represents everything that will be needed
2967/// to construct a MachineInstr. These nodes are created during the
2968/// instruction selection proper phase.
2969///
2970/// Note that the only supported way to set the `memoperands` is by calling the
2971/// `SelectionDAG::setNodeMemRefs` function as the memory management happens
2972/// inside the DAG rather than in the node.
2973class MachineSDNode : public SDNode {
2974private:
2975 friend class SelectionDAG;
2976
2977 MachineSDNode(unsigned Opc, unsigned Order, const DebugLoc &DL, SDVTList VTs)
2978 : SDNode(Opc, Order, DL, VTs) {}
2979
2980 // We use a pointer union between a single `MachineMemOperand` pointer and
2981 // a pointer to an array of `MachineMemOperand` pointers. This is null when
2982 // the number of these is zero, the single pointer variant used when the
2983 // number is one, and the array is used for larger numbers.
2984 //
2985 // The array is allocated via the `SelectionDAG`'s allocator and so will
2986 // always live until the DAG is cleaned up and doesn't require ownership here.
2987 //
2988 // We can't use something simpler like `TinyPtrVector` here because `SDNode`
2989 // subclasses aren't managed in a conforming C++ manner. See the comments on
2990 // `SelectionDAG::MorphNodeTo` which details what all goes on, but the
2991 // constraint here is that these don't manage memory with their constructor or
2992 // destructor and can be initialized to a good state even if they start off
2993 // uninitialized.
2995
2996 // Note that this could be folded into the above `MemRefs` member if doing so
2997 // is advantageous at some point. We don't need to store this in most cases.
2998 // However, at the moment this doesn't appear to make the allocation any
2999 // smaller and makes the code somewhat simpler to read.
3000 int NumMemRefs = 0;
3001
3002public:
3004
3006 // Special case the common cases.
3007 if (NumMemRefs == 0)
3008 return {};
3009 if (NumMemRefs == 1)
3010 return ArrayRef(MemRefs.getAddrOfPtr1(), 1);
3011
3012 // Otherwise we have an actual array.
3013 return ArrayRef(cast<MachineMemOperand **>(MemRefs), NumMemRefs);
3014 }
3015 mmo_iterator memoperands_begin() const { return memoperands().begin(); }
3016 mmo_iterator memoperands_end() const { return memoperands().end(); }
3017 bool memoperands_empty() const { return memoperands().empty(); }
3018
3019 /// Clear out the memory reference descriptor list.
3021 MemRefs = nullptr;
3022 NumMemRefs = 0;
3023 }
3024
3025 static bool classof(const SDNode *N) {
3026 return N->isMachineOpcode();
3027 }
3028};
3029
3030/// An SDNode that records if a register contains a value that is guaranteed to
3031/// be aligned accordingly.
3033 Align Alignment;
3034
3035public:
3036 AssertAlignSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs, Align A)
3037 : SDNode(ISD::AssertAlign, Order, DL, VTs), Alignment(A) {}
3038
3039 Align getAlign() const { return Alignment; }
3040
3041 static bool classof(const SDNode *N) {
3042 return N->getOpcode() == ISD::AssertAlign;
3043 }
3044};
3045
3047 const SDNode *Node;
3048 unsigned Operand;
3049
3050 SDNodeIterator(const SDNode *N, unsigned Op) : Node(N), Operand(Op) {}
3051
3052public:
3053 using iterator_category = std::forward_iterator_tag;
3055 using difference_type = std::ptrdiff_t;
3058
3059 bool operator==(const SDNodeIterator& x) const {
3060 return Operand == x.Operand;
3061 }
3062 bool operator!=(const SDNodeIterator& x) const { return !operator==(x); }
3063
3065 return Node->getOperand(Operand).getNode();
3066 }
3067 pointer operator->() const { return operator*(); }
3068
3069 SDNodeIterator& operator++() { // Preincrement
3070 ++Operand;
3071 return *this;
3072 }
3073 SDNodeIterator operator++(int) { // Postincrement
3074 SDNodeIterator tmp = *this; ++*this; return tmp;
3075 }
3077 assert(Node == Other.Node &&
3078 "Cannot compare iterators of two different nodes!");
3079 return Operand - Other.Operand;
3080 }
3081
3082 static SDNodeIterator begin(const SDNode *N) { return SDNodeIterator(N, 0); }
3083 static SDNodeIterator end (const SDNode *N) {
3084 return SDNodeIterator(N, N->getNumOperands());
3085 }
3086
3087 unsigned getOperand() const { return Operand; }
3088 const SDNode *getNode() const { return Node; }
3089};
3090
3091template <> struct GraphTraits<SDNode*> {
3092 using NodeRef = SDNode *;
3094
3095 static NodeRef getEntryNode(SDNode *N) { return N; }
3096
3098 return SDNodeIterator::begin(N);
3099 }
3100
3102 return SDNodeIterator::end(N);
3103 }
3104};
3105
3106/// A representation of the largest SDNode, for use in sizeof().
3107///
3108/// This needs to be a union because the largest node differs on 32 bit systems
3109/// with 4 and 8 byte pointer alignment, respectively.
3114
3115/// The SDNode class with the greatest alignment requirement.
3117
3118namespace ISD {
3119
3120 /// Returns true if the specified node is a non-extending and unindexed load.
3121 inline bool isNormalLoad(const SDNode *N) {
3122 auto *Ld = dyn_cast<LoadSDNode>(N);
3123 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD &&
3124 Ld->getAddressingMode() == ISD::UNINDEXED;
3125 }
3126
3127 /// Returns true if the specified node is a non-extending load.
3128 inline bool isNON_EXTLoad(const SDNode *N) {
3129 auto *Ld = dyn_cast<LoadSDNode>(N);
3130 return Ld && Ld->getExtensionType() == ISD::NON_EXTLOAD;
3131 }
3132
3133 /// Returns true if the specified node is a EXTLOAD.
3134 inline bool isEXTLoad(const SDNode *N) {
3135 auto *Ld = dyn_cast<LoadSDNode>(N);
3136 return Ld && Ld->getExtensionType() == ISD::EXTLOAD;
3137 }
3138
3139 /// Returns true if the specified node is a SEXTLOAD.
3140 inline bool isSEXTLoad(const SDNode *N) {
3141 auto *Ld = dyn_cast<LoadSDNode>(N);
3142 return Ld && Ld->getExtensionType() == ISD::SEXTLOAD;
3143 }
3144
3145 /// Returns true if the specified node is a ZEXTLOAD.
3146 inline bool isZEXTLoad(const SDNode *N) {
3147 auto *Ld = dyn_cast<LoadSDNode>(N);
3148 return Ld && Ld->getExtensionType() == ISD::ZEXTLOAD;
3149 }
3150
3151 /// Returns true if the specified node is an unindexed load.
3152 inline bool isUNINDEXEDLoad(const SDNode *N) {
3153 auto *Ld = dyn_cast<LoadSDNode>(N);
3154 return Ld && Ld->getAddressingMode() == ISD::UNINDEXED;
3155 }
3156
3157 /// Returns true if the specified node is a non-truncating
3158 /// and unindexed store.
3159 inline bool isNormalStore(const SDNode *N) {
3160 auto *St = dyn_cast<StoreSDNode>(N);
3161 return St && !St->isTruncatingStore() &&
3162 St->getAddressingMode() == ISD::UNINDEXED;
3163 }
3164
3165 /// Returns true if the specified node is an unindexed store.
3166 inline bool isUNINDEXEDStore(const SDNode *N) {
3167 auto *St = dyn_cast<StoreSDNode>(N);
3168 return St && St->getAddressingMode() == ISD::UNINDEXED;
3169 }
3170
3171 /// Attempt to match a unary predicate against a scalar/splat constant or
3172 /// every element of a constant BUILD_VECTOR.
3173 /// If AllowUndef is true, then UNDEF elements will pass nullptr to Match.
3174 template <typename ConstNodeType>
3176 std::function<bool(ConstNodeType *)> Match,
3177 bool AllowUndefs = false);
3178
3179 /// Hook for matching ConstantSDNode predicate
3181 std::function<bool(ConstantSDNode *)> Match,
3182 bool AllowUndefs = false) {
3183 return matchUnaryPredicateImpl<ConstantSDNode>(Op, Match, AllowUndefs);
3184 }
3185
3186 /// Hook for matching ConstantFPSDNode predicate
3187 inline bool
3189 std::function<bool(ConstantFPSDNode *)> Match,
3190 bool AllowUndefs = false) {
3191 return matchUnaryPredicateImpl<ConstantFPSDNode>(Op, Match, AllowUndefs);
3192 }
3193
3194 /// Attempt to match a binary predicate against a pair of scalar/splat
3195 /// constants or every element of a pair of constant BUILD_VECTORs.
3196 /// If AllowUndef is true, then UNDEF elements will pass nullptr to Match.
3197 /// If AllowTypeMismatch is true then RetType + ArgTypes don't need to match.
3200 std::function<bool(ConstantSDNode *, ConstantSDNode *)> Match,
3201 bool AllowUndefs = false, bool AllowTypeMismatch = false);
3202
3203 /// Returns true if the specified value is the overflow result from one
3204 /// of the overflow intrinsic nodes.
3206 unsigned Opc = Op.getOpcode();
3207 return (Op.getResNo() == 1 &&
3208 (Opc == ISD::SADDO || Opc == ISD::UADDO || Opc == ISD::SSUBO ||
3209 Opc == ISD::USUBO || Opc == ISD::SMULO || Opc == ISD::UMULO));
3210 }
3211
3212} // end namespace ISD
3213
3214} // end namespace llvm
3215
3216#endif // LLVM_CODEGEN_SELECTIONDAGNODES_H
aarch64 promote const
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
AMDGPU Kernel Attributes
This file declares a class to represent arbitrary precision floating point values and provide a varie...
Atomic ordering constants.
This file implements the BitVector class.
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
RelocType Type
Definition: COFFYAML.cpp:391
static std::optional< bool > isBigEndian(const SmallDenseMap< int64_t, int64_t, 8 > &MemOffset2Idx, int64_t LowestIdx)
Given a map from byte offsets in memory to indices in a load/store, determine if that map corresponds...
This file contains the declarations for the subclasses of Constant, which represent the different fla...
Returns the sub type a function will return at a given Idx Should correspond to the result type of an ExtractValue instruction executed with just that one unsigned Idx
uint32_t Index
uint64_t Size
uint64_t Offset
Definition: ELF_riscv.cpp:478
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.
This file defines the little GraphTraits<X> template class that should be specialized by classes that...
#define op(i)
#define I(x, y, z)
Definition: MD5.cpp:58
#define G(x, y, z)
Definition: MD5.cpp:56
Load MIR Sample Profile
unsigned Reg
This file contains the declarations for metadata subclasses.
const SmallVectorImpl< MachineOperand > & Cond
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
raw_pwrite_stream & OS
#define END_TWO_BYTE_PACK()
#define BEGIN_TWO_BYTE_PACK()
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Value * RHS
Value * LHS
DEMANGLE_DUMP_METHOD void dump() const
Class for arbitrary precision integers.
Definition: APInt.h:76
unsigned getSrcAddressSpace() const
AddrSpaceCastSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, unsigned SrcAS, unsigned DestAS)
unsigned getDestAddressSpace() const
static bool classof(const SDNode *N)
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition: ArrayRef.h:41
An SDNode that records if a register contains a value that is guaranteed to be aligned accordingly.
static bool classof(const SDNode *N)
AssertAlignSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs, Align A)
This is an SDNode representing atomic operations.
void setExtensionType(ISD::LoadExtType ETy)
static bool classof(const SDNode *N)
const SDValue & getBasePtr() const
ISD::LoadExtType getExtensionType() const
AtomicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTL, EVT MemVT, MachineMemOperand *MMO)
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
bool isCompareAndSwap() const
Returns true if this SDNode represents cmpxchg atomic operation, false otherwise.
const SDValue & getVal() const
MachineBasicBlock * getBasicBlock() const
static bool classof(const SDNode *N)
LLVM Basic Block Representation.
Definition: BasicBlock.h:60
static bool classof(const SDNode *N)
unsigned getTargetFlags() const
const BlockAddress * getBlockAddress() const
The address of a basic block.
Definition: Constants.h:889
A "pseudo-class" with methods for operating on BUILD_VECTORs.
bool getConstantRawBits(bool IsLittleEndian, unsigned DstEltSizeInBits, SmallVectorImpl< APInt > &RawBitElements, BitVector &UndefElements) const
Extract the raw bit data from a build vector of Undef, Constant or ConstantFP node elements.
static void recastRawBits(bool IsLittleEndian, unsigned DstEltSizeInBits, SmallVectorImpl< APInt > &DstBitElements, ArrayRef< APInt > SrcBitElements, BitVector &DstUndefElements, const BitVector &SrcUndefElements)
Recast bit data SrcBitElements to DstEltSizeInBits wide elements.
bool getRepeatedSequence(const APInt &DemandedElts, SmallVectorImpl< SDValue > &Sequence, BitVector *UndefElements=nullptr) const
Find the shortest repeating sequence of values in the build vector.
ConstantFPSDNode * getConstantFPSplatNode(const APInt &DemandedElts, BitVector *UndefElements=nullptr) const
Returns the demanded splatted constant FP or null if this is not a constant FP splat.
std::optional< std::pair< APInt, APInt > > isConstantSequence() const
If this BuildVector is constant and represents the numerical series "<a, a+n, a+2n,...
SDValue getSplatValue(const APInt &DemandedElts, BitVector *UndefElements=nullptr) const
Returns the demanded splatted value or a null value if this is not a splat.
bool isConstantSplat(APInt &SplatValue, APInt &SplatUndef, unsigned &SplatBitSize, bool &HasAnyUndefs, unsigned MinSplatBits=0, bool isBigEndian=false) const
Check if this is a constant splat, and if so, find the smallest element size that splats the vector.
ConstantSDNode * getConstantSplatNode(const APInt &DemandedElts, BitVector *UndefElements=nullptr) const
Returns the demanded splatted constant or null if this is not a constant splat.
int32_t getConstantFPSplatPow2ToLog2Int(BitVector *UndefElements, uint32_t BitWidth) const
If this is a constant FP splat and the splatted constant FP is an exact power or 2,...
static bool classof(const SDNode *N)
ISD::CondCode get() const
static bool classof(const SDNode *N)
static bool isValueValidForType(EVT VT, const APFloat &Val)
const APFloat & getValueAPF() const
bool isNaN() const
Return true if the value is a NaN.
const ConstantFP * getConstantFPValue() const
bool isExactlyValue(double V) const
We don't rely on operator== working on double values, as it returns true for things that are clearly ...
bool isNegative() const
Return true if the value is negative.
bool isInfinity() const
Return true if the value is an infinity.
static bool classof(const SDNode *N)
bool isZero() const
Return true if the value is positive or negative zero.
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:268
This is the shared class of boolean and integer constants.
Definition: Constants.h:80
static bool classof(const SDNode *N)
MachineConstantPoolValue * getMachineCPVal() const
bool isMachineConstantPoolEntry() const
MachineConstantPoolValue * MachineCPVal
const Constant * getConstVal() const
unsigned getTargetFlags() const
MaybeAlign getMaybeAlignValue() const
uint64_t getLimitedValue(uint64_t Limit=UINT64_MAX)
const ConstantInt * getConstantIntValue() const
uint64_t getZExtValue() const
const APInt & getAPIntValue() const
int64_t getSExtValue() const
static bool classof(const SDNode *N)
This is an important base class in LLVM.
Definition: Constant.h:41
This class represents an Operation in the Expression.
A debug info location.
Definition: DebugLoc.h:33
bool hasTrivialDestructor() const
Check whether this has a trivial destructor.
Definition: DebugLoc.h:69
const char * getSymbol() const
static bool classof(const SDNode *N)
Utility class for floating point operations which can have information about relaxed accuracy require...
Definition: Operator.h:201
bool hasAllowReassoc() const
Test if this operation may be simplified with reassociative transforms.
Definition: Operator.h:283
bool hasNoNaNs() const
Test if this operation's arguments and results are assumed not-NaN.
Definition: Operator.h:288
bool hasAllowReciprocal() const
Test if this operation can use reciprocal multiply instead of division.
Definition: Operator.h:303
bool hasNoSignedZeros() const
Test if this operation can ignore the sign of zero.
Definition: Operator.h:298
bool hasAllowContract() const
Test if this operation can be floating-point contracted (FMA).
Definition: Operator.h:308
bool hasNoInfs() const
Test if this operation's arguments and results are assumed not-infinite.
Definition: Operator.h:293
bool hasApproxFunc() const
Test if this operation allows approximations of math library functions or intrinsics.
Definition: Operator.h:314
static bool classof(const SDNode *N)
FPStateAccessSDNode(unsigned NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO)
Node - This class is used to maintain the singly linked bucket list in a folding set.
Definition: FoldingSet.h:138
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:320
static bool classof(const SDNode *N)
unsigned getAddressSpace() const
static bool classof(const SDNode *N)
const GlobalValue * getGlobal() const
This class is used to form a handle around another node that is persistent and is updated across invo...
const SDValue & getValue() const
static bool classof(const SDNode *N)
unsigned getTargetFlags() const
Base class for LoadSDNode and StoreSDNode.
LSBaseSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT, MachineMemOperand *MMO)
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc,...
const SDValue & getOffset() const
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
static bool classof(const SDNode *N)
MCSymbol * getLabel() const
static bool classof(const SDNode *N)
This SDNode is used for LIFETIME_START/LIFETIME_END values, which indicate the offet and size that ar...
int64_t getFrameIndex() const
static bool classof(const SDNode *N)
int64_t getOffset() const
This class is used to represent ISD::LOAD nodes.
const SDValue & getBasePtr() const
const SDValue & getOffset() const
ISD::LoadExtType getExtensionType() const
Return whether this is a plain node, or one of the varieties of value-extending loads.
static bool classof(const SDNode *N)
MCSymbol * getMCSymbol() const
static bool classof(const SDNode *N)
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:40
static bool classof(const SDNode *N)
const MDNode * getMD() const
Metadata node.
Definition: Metadata.h:1067
Machine Value Type.
Abstract base class for all machine specific constantpool value subclasses.
A description of a memory reference used in the backend.
AtomicOrdering getFailureOrdering() const
For cmpxchg atomic operations, return the atomic ordering requirements when store does not occur.
bool isUnordered() const
Returns true if this memory operation doesn't have any ordering constraints other than normal aliasin...
const MDNode * getRanges() const
Return the range tag for the memory reference.
bool isAtomic() const
Returns true if this operation has an atomic ordering requirement of unordered or higher,...
void refineAlignment(const MachineMemOperand *MMO)
Update this MachineMemOperand to reflect the alignment of MMO, if it has a greater alignment.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
AtomicOrdering getMergedOrdering() const
Return a single atomic ordering that is at least as strong as both the success and failure orderings ...
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
const MachinePointerInfo & getPointerInfo() const
Align getAlign() const
Return the minimum known alignment in bytes of the actual memory reference.
AAMDNodes getAAInfo() const
Return the AA tags for the memory reference.
Align getBaseAlign() const
Return the minimum known alignment in bytes of the base address, without the offset.
int64_t getOffset() const
For normal values, this is a byte offset added to the base address.
An SDNode that represents everything that will be needed to construct a MachineInstr.
ArrayRef< MachineMemOperand * > memoperands() const
bool memoperands_empty() const
void clearMemRefs()
Clear out the memory reference descriptor list.
mmo_iterator memoperands_begin() const
static bool classof(const SDNode *N)
mmo_iterator memoperands_end() const
This class is used to represent an MGATHER node.
static bool classof(const SDNode *N)
MaskedGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType, ISD::LoadExtType ETy)
const SDValue & getPassThru() const
ISD::LoadExtType getExtensionType() const
This is a base class used to represent MGATHER and MSCATTER nodes.
const SDValue & getIndex() const
const SDValue & getScale() const
static bool classof(const SDNode *N)
MaskedGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
const SDValue & getBasePtr() const
const SDValue & getMask() const
ISD::MemIndexType getIndexType() const
How is Index applied to BasePtr when computing addresses.
This class is used to represent an MLOAD node.
MaskedLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, ISD::LoadExtType ETy, bool IsExpanding, EVT MemVT, MachineMemOperand *MMO)
const SDValue & getBasePtr() const
ISD::LoadExtType getExtensionType() const
const SDValue & getMask() const
const SDValue & getPassThru() const
static bool classof(const SDNode *N)
const SDValue & getOffset() const
This base class is used to represent MLOAD and MSTORE nodes.
const SDValue & getMask() const
MaskedLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT, MachineMemOperand *MMO)
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
static bool classof(const SDNode *N)
const SDValue & getOffset() const
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc,...
This class is used to represent an MSCATTER node.
MaskedScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType, bool IsTrunc)
const SDValue & getValue() const
static bool classof(const SDNode *N)
bool isTruncatingStore() const
Return true if the op does a truncation before store.
This class is used to represent an MSTORE node.
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
MaskedStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, bool isCompressing, EVT MemVT, MachineMemOperand *MMO)
const SDValue & getOffset() const
const SDValue & getBasePtr() const
const SDValue & getMask() const
const SDValue & getValue() const
bool isTruncatingStore() const
Return true if the op does a truncation before store.
static bool classof(const SDNode *N)
This SDNode is used for target intrinsics that touch memory and need an associated MachineMemOperand.
MemIntrinsicSDNode(unsigned Opc, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemoryVT, MachineMemOperand *MMO)
static bool classof(const SDNode *N)
This is an abstract virtual class for memory operations.
MachineMemOperand * MMO
Memory reference information.
unsigned getAddressSpace() const
Return the address space for the associated pointer.
const MDNode * getRanges() const
Returns the Ranges that describes the dereference.
Align getAlign() const
bool isVolatile() const
AAMDNodes getAAInfo() const
Returns the AA info that describes the dereference.
SyncScope::ID getSyncScopeID() const
Returns the synchronization scope ID for this memory operation.
Align getOriginalAlign() const
Returns alignment and volatility of the memory access.
int64_t getSrcValueOffset() const
bool readMem() const
bool isSimple() const
Returns true if the memory operation is neither atomic or volatile.
AtomicOrdering getSuccessOrdering() const
Return the atomic ordering requirements for this memory operation.
MachineMemOperand * getMemOperand() const
Return a MachineMemOperand object describing the memory reference performed by operation.
const SDValue & getBasePtr() const
void refineAlignment(const MachineMemOperand *NewMMO)
Update this MemSDNode's MachineMemOperand information to reflect the alignment of NewMMO,...
const MachinePointerInfo & getPointerInfo() const
AtomicOrdering getMergedOrdering() const
Return a single atomic ordering that is at least as strong as both the success and failure orderings ...
const SDValue & getChain() const
bool isNonTemporal() const
bool isInvariant() const
bool writeMem() const
bool isDereferenceable() const
bool isUnordered() const
Returns true if the memory operation doesn't imply any ordering constraints on surrounding memory ope...
bool isAtomic() const
Return true if the memory operation ordering is Unordered or higher.
static bool classof(const SDNode *N)
unsigned getRawSubclassData() const
Return the SubclassData value, without HasDebugValue.
EVT getMemoryVT() const
Return the type of the in-memory value.
MutableArrayRef - Represent a mutable reference to an array (0 or more elements consecutively in memo...
Definition: ArrayRef.h:307
First const * getAddrOfPtr1() const
If the union is set to the first pointer type get an address pointing to it.
Definition: PointerUnion.h:168
This SDNode is used for PSEUDO_PROBE values, which are the function guid and the index of the basic b...
static bool classof(const SDNode *N)
uint32_t getAttributes() const
const uint32_t * getRegMask() const
static bool classof(const SDNode *N)
static bool classof(const SDNode *N)
Register getReg() const
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
const DebugLoc & getDebugLoc() const
unsigned getIROrder() const
SDLoc(const SDValue V)
SDLoc()=default
SDLoc(const SDNode *N)
SDLoc(const Instruction *I, int Order)
pointer operator->() const
static SDNodeIterator end(const SDNode *N)
size_t operator-(SDNodeIterator Other) const
SDNodeIterator operator++(int)
std::ptrdiff_t difference_type
std::forward_iterator_tag iterator_category
unsigned getOperand() const
pointer operator*() const
SDNodeIterator & operator++()
bool operator==(const SDNodeIterator &x) const
const SDNode * getNode() const
static SDNodeIterator begin(const SDNode *N)
bool operator!=(const SDNodeIterator &x) const
This class provides iterator support for SDUse operands that use a specific SDNode.
bool operator!=(const use_iterator &x) const
use_iterator & operator=(const use_iterator &)=default
unsigned getOperandNo() const
Retrieve the operand # of this use in its user.
std::forward_iterator_tag iterator_category
bool operator==(const use_iterator &x) const
SDNode * operator*() const
Retrieve a pointer to the current user node.
bool atEnd() const
Return true if this iterator is at the end of uses list.
use_iterator(const use_iterator &I)=default
Represents one node in the SelectionDAG.
void setDebugLoc(DebugLoc dl)
Set source location info.
uint32_t getCFIType() const
static SDVTList getSDVTList(EVT VT)
void setIROrder(unsigned Order)
Set the node ordering.
bool isStrictFPOpcode()
Test if this node is a strict floating point pseudo-op.
ArrayRef< SDUse > ops() const
char RawSDNodeBits[sizeof(uint16_t)]
const APInt & getAsAPIntVal() const
Helper method returns the APInt value of a ConstantSDNode.
bool isMachineOpcode() const
Test if this node has a post-isel opcode, directly corresponding to a MachineInstr opcode.
void dumprFull(const SelectionDAG *G=nullptr) const
printrFull to dbgs().
int getNodeId() const
Return the unique node id.
void dump() const
Dump this node, for debugging.
iterator_range< value_iterator > values() const
iterator_range< use_iterator > uses() const
unsigned getOpcode() const
Return the SelectionDAG opcode value for this node.
SDNode * getGluedUser() const
If this node has a glue value with a user, return the user (there is at most one).
bool isDivergent() const
bool hasOneUse() const
Return true if there is exactly one use of this node.
bool isOnlyUserOf(const SDNode *N) const
Return true if this node is the only use of N.
static const char * getIndexedModeName(ISD::MemIndexedMode AM)
iterator_range< value_op_iterator > op_values() const
unsigned getIROrder() const
Return the node ordering.
LoadSDNodeBitfields LoadSDNodeBits
static constexpr size_t getMaxNumOperands()
Return the maximum number of operands that a SDNode can hold.
value_iterator value_end() const
void setHasDebugValue(bool b)
LSBaseSDNodeBitfields LSBaseSDNodeBits
iterator_range< use_iterator > uses()
MemSDNodeBitfields MemSDNodeBits
bool getHasDebugValue() const
void dumpr() const
Dump (recursively) this node and its use-def subgraph.
SDNodeFlags getFlags() const
void setNodeId(int Id)
Set unique node id.
std::string getOperationName(const SelectionDAG *G=nullptr) const
Return the opcode of this operation for printing.
void printrFull(raw_ostream &O, const SelectionDAG *G=nullptr) const
Print a SelectionDAG node and all children down to the leaves.
size_t use_size() const
Return the number of uses of this node.
void intersectFlagsWith(const SDNodeFlags Flags)
Clear any flags in this node that aren't also set in Flags.
void printr(raw_ostream &OS, const SelectionDAG *G=nullptr) const
StoreSDNodeBitfields StoreSDNodeBits
TypeSize getValueSizeInBits(unsigned ResNo) const
Returns MVT::getSizeInBits(getValueType(ResNo)).
MVT getSimpleValueType(unsigned ResNo) const
Return the type of a specified result as a simple type.
static bool hasPredecessorHelper(const SDNode *N, SmallPtrSetImpl< const SDNode * > &Visited, SmallVectorImpl< const SDNode * > &Worklist, unsigned int MaxSteps=0, bool TopologicalPrune=false)
Returns true if N is a predecessor of any node in Worklist.
uint64_t getAsZExtVal() const
Helper method returns the zero-extended integer value of a ConstantSDNode.
bool use_empty() const
Return true if there are no uses of this node.
unsigned getNumValues() const
Return the number of values defined/returned by this operator.
unsigned getNumOperands() const
Return the number of values used by this operation.
unsigned getMachineOpcode() const
This may only be called if isMachineOpcode returns true.
SDVTList getVTList() const
const SDValue & getOperand(unsigned Num) const
bool isMemIntrinsic() const
Test if this node is a memory intrinsic (with valid pointer information).
uint64_t getConstantOperandVal(unsigned Num) const
Helper method returns the integer value of a ConstantSDNode operand.
static bool areOnlyUsersOf(ArrayRef< const SDNode * > Nodes, const SDNode *N)
Return true if all the users of N are contained in Nodes.
bool isTargetStrictFPOpcode() const
Test if this node has a target-specific opcode that may raise FP exceptions (in the <target>ISD names...
use_iterator use_begin() const
Provide iteration support to walk over all uses of an SDNode.
bool isOperandOf(const SDNode *N) const
Return true if this node is an operand of N.
void print(raw_ostream &OS, const SelectionDAG *G=nullptr) const
const DebugLoc & getDebugLoc() const
Return the source location info.
void printrWithDepth(raw_ostream &O, const SelectionDAG *G=nullptr, unsigned depth=100) const
Print a SelectionDAG node and children up to depth "depth." The given SelectionDAG allows target-spec...
const APInt & getConstantOperandAPInt(unsigned Num) const
Helper method returns the APInt of a ConstantSDNode operand.
uint16_t PersistentId
Unique and persistent id per SDNode in the DAG.
void dumprWithDepth(const SelectionDAG *G=nullptr, unsigned depth=100) const
printrWithDepth to dbgs().
bool isPredecessorOf(const SDNode *N) const
Return true if this node is a predecessor of N.
bool hasPredecessor(const SDNode *N) const
Return true if N is a predecessor of this node.
void addUse(SDUse &U)
This method should only be used by the SDUse class.
bool hasAnyUseOfValue(unsigned Value) const
Return true if there are any use of the indicated value.
EVT getValueType(unsigned ResNo) const
Return the type of a specified result.
void print_details(raw_ostream &OS, const SelectionDAG *G) const
bool isTargetMemoryOpcode() const
Test if this node has a target-specific memory-referencing opcode (in the <target>ISD namespace and g...
void setCFIType(uint32_t Type)
bool isUndef() const
Return true if the type of the node type undefined.
void print_types(raw_ostream &OS, const SelectionDAG *G) const
bool hasNUsesOfValue(unsigned NUses, unsigned Value) const
Return true if there are exactly NUSES uses of the indicated value.
bool isVPOpcode() const
Test if this node is a vector predication operation.
void setFlags(SDNodeFlags NewFlags)
SDNode * getGluedNode() const
If this node has a glue operand, return the node to which the glue operand points.
bool isTargetOpcode() const
Test if this node has a target-specific opcode (in the <target>ISD namespace).
op_iterator op_end() const
ConstantSDNodeBitfields ConstantSDNodeBits
value_iterator value_begin() const
op_iterator op_begin() const
static use_iterator use_end()
void DropOperands()
Release the operands and set this node to have zero operands.
SDNode(unsigned Opc, unsigned Order, DebugLoc dl, SDVTList VTs)
Create an SDNode.
SDNodeBitfields SDNodeBits
Represents a use of a SDNode.
const SDNode * getUser() const
SDUse & operator=(const SDUse &)=delete
EVT getValueType() const
Convenience function for get().getValueType().
const SDValue & get() const
If implicit conversion to SDValue doesn't work, the get() method returns the SDValue.
SDUse * getNext() const
Get the next SDUse in the use list.
SDNode * getNode() const
Convenience function for get().getNode().
bool operator!=(const SDValue &V) const
Convenience function for get().operator!=.
SDUse()=default
SDUse(const SDUse &U)=delete
unsigned getResNo() const
Convenience function for get().getResNo().
bool operator==(const SDValue &V) const
Convenience function for get().operator==.
bool operator<(const SDValue &V) const
Convenience function for get().operator<.
SDNode * getUser()
This returns the SDNode that contains this Use.
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation.
bool isUndef() const
SDNode * getNode() const
get the SDNode which holds the desired result
bool hasOneUse() const
Return true if there is exactly one node using value ResNo of Node.
bool isOperandOf(const SDNode *N) const
Return true if this node is an operand of N.
SDValue()=default
bool isTargetMemoryOpcode() const
bool reachesChainWithoutSideEffects(SDValue Dest, unsigned Depth=2) const
Return true if this operand (which must be a chain) reaches the specified operand without crossing an...
bool operator!=(const SDValue &O) const
SDValue getValue(unsigned R) const
void dump() const
EVT getValueType() const
Return the ValueType of the referenced return value.
bool isTargetOpcode() const
bool isMachineOpcode() const
TypeSize getValueSizeInBits() const
Returns the size of the value in bits.
const DebugLoc & getDebugLoc() const
SDNode * operator->() const
bool operator==(const SDValue &O) const
const SDValue & getOperand(unsigned i) const
bool use_empty() const
Return true if there are no nodes using value ResNo of Node.
bool operator<(const SDValue &O) const
const APInt & getConstantOperandAPInt(unsigned i) const
uint64_t getScalarValueSizeInBits() const
unsigned getResNo() const
get the index which selects a specific result in the SDNode
uint64_t getConstantOperandVal(unsigned i) const
MVT getSimpleValueType() const
Return the simple ValueType of the referenced return value.
void setNode(SDNode *N)
set the SDNode
unsigned getMachineOpcode() const
unsigned getOpcode() const
void dumpr() const
unsigned getNumOperands() const
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:225
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
static bool isSplatMask(const int *Mask, EVT VT)
int getMaskElt(unsigned Idx) const
ShuffleVectorSDNode(SDVTList VTs, unsigned Order, const DebugLoc &dl, const int *M)
ArrayRef< int > getMask() const
static void commuteMask(MutableArrayRef< int > Mask)
Change values in a shuffle permute mask assuming the two vector operands have swapped position.
static bool classof(const SDNode *N)
size_type size() const
Definition: SmallPtrSet.h:94
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:321
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
Definition: SmallPtrSet.h:360
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
Definition: SmallPtrSet.h:342
bool empty() const
Definition: SmallVector.h:94
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: SmallVector.h:586
void append(ItTy in_start, ItTy in_end)
Add the specified range to the end of the SmallVector.
Definition: SmallVector.h:696
void push_back(const T &Elt)
Definition: SmallVector.h:426
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1209
An SDNode that holds an arbitrary LLVM IR Value.
const Value * getValue() const
Return the contained Value.
static bool classof(const SDNode *N)
This class is used to represent ISD::STORE nodes.
const SDValue & getBasePtr() const
const SDValue & getOffset() const
const SDValue & getValue() const
bool isTruncatingStore() const
Return true if the op does a truncation before store.
void setTruncatingStore(bool Truncating)
static bool classof(const SDNode *N)
Completely target-dependent object reference.
TargetIndexSDNode(int Idx, SDVTList VTs, int64_t Ofs, unsigned TF)
static bool classof(const SDNode *N)
unsigned getTargetFlags() const
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:45
This base class is used to represent VP_LOAD, VP_STORE, EXPERIMENTAL_VP_STRIDED_LOAD and EXPERIMENTAL...
const SDValue & getMask() const
static bool classof(const SDNode *N)
bool isIndexed() const
Return true if this is a pre/post inc/dec load/store.
VPBaseLoadStoreSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &DL, SDVTList VTs, ISD::MemIndexedMode AM, EVT MemVT, MachineMemOperand *MMO)
const SDValue & getOffset() const
ISD::MemIndexedMode getAddressingMode() const
Return the addressing mode for this load or store: unindexed, pre-inc, pre-dec, post-inc,...
const SDValue & getVectorLength() const
bool isUnindexed() const
Return true if this is NOT a pre/post inc/dec load/store.
const SDValue & getBasePtr() const
This class is used to represent an VP_GATHER node.
VPGatherSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
static bool classof(const SDNode *N)
This is a base class used to represent VP_GATHER and VP_SCATTER nodes.
const SDValue & getScale() const
ISD::MemIndexType getIndexType() const
How is Index applied to BasePtr when computing addresses.
const SDValue & getVectorLength() const
const SDValue & getIndex() const
VPGatherScatterSDNode(ISD::NodeType NodeTy, unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
const SDValue & getBasePtr() const
static bool classof(const SDNode *N)
const SDValue & getMask() const
This class is used to represent a VP_LOAD node.
const SDValue & getOffset() const
const SDValue & getVectorLength() const
ISD::LoadExtType getExtensionType() const
const SDValue & getMask() const
VPLoadSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, ISD::LoadExtType ETy, bool isExpanding, EVT MemVT, MachineMemOperand *MMO)
const SDValue & getBasePtr() const
static bool classof(const SDNode *N)
bool isExpandingLoad() const
This class is used to represent an VP_SCATTER node.
static bool classof(const SDNode *N)
VPScatterSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
const SDValue & getValue() const
This class is used to represent a VP_STORE node.
const SDValue & getMask() const
VPStoreSDNode(unsigned Order, const DebugLoc &dl, SDVTList VTs, ISD::MemIndexedMode AM, bool isTrunc, bool isCompressing, EVT MemVT, MachineMemOperand *MMO)
static bool classof(const SDNode *N)
const SDValue & getVectorLength() const
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
const SDValue & getOffset() const
bool isTruncatingStore() const
Return true if this is a truncating store.
const SDValue & getBasePtr() const
const SDValue & getValue() const
This class is used to represent an EXPERIMENTAL_VP_STRIDED_LOAD node.
const SDValue & getMask() const
ISD::LoadExtType getExtensionType() const
const SDValue & getStride() const
const SDValue & getOffset() const
const SDValue & getVectorLength() const
static bool classof(const SDNode *N)
const SDValue & getBasePtr() const
VPStridedLoadSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs, ISD::MemIndexedMode AM, ISD::LoadExtType ETy, bool IsExpanding, EVT MemVT, MachineMemOperand *MMO)
This class is used to represent an EXPERIMENTAL_VP_STRIDED_STORE node.
const SDValue & getBasePtr() const
const SDValue & getMask() const
const SDValue & getValue() const
bool isTruncatingStore() const
Return true if this is a truncating store.
VPStridedStoreSDNode(unsigned Order, const DebugLoc &DL, SDVTList VTs, ISD::MemIndexedMode AM, bool IsTrunc, bool IsCompressing, EVT MemVT, MachineMemOperand *MMO)
const SDValue & getOffset() const
const SDValue & getVectorLength() const
static bool classof(const SDNode *N)
const SDValue & getStride() const
bool isCompressingStore() const
Returns true if the op does a compression to the vector before storing.
This class is used to represent EVT's, which are used to parameterize some operations.
static bool classof(const SDNode *N)
LLVM Value Representation.
Definition: Value.h:74
CRTP base class for adapting an iterator to a different type.
Definition: iterator.h:237
A range adaptor for a pair of iterators.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
This file defines the ilist_node class template, which is a convenient base class for creating classe...
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define UINT64_MAX
Definition: DataTypes.h:77
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
bool isConstantSplatVectorAllOnes(const SDNode *N, bool BuildVectorOnly=false)
Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are ~0 ...
bool isNON_EXTLoad(const SDNode *N)
Returns true if the specified node is a non-extending load.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:40
@ TargetConstantPool
Definition: ISDOpcodes.h:168
@ MDNODE_SDNODE
MDNODE_SDNODE - This is a node that holdes an MDNode*, which is used to reference metadata in the IR.
Definition: ISDOpcodes.h:1177
@ ATOMIC_LOAD_FMAX
Definition: ISDOpcodes.h:1282
@ ATOMIC_LOAD_NAND
Definition: ISDOpcodes.h:1275
@ TargetBlockAddress
Definition: ISDOpcodes.h:170
@ ConstantFP
Definition: ISDOpcodes.h:77
@ ATOMIC_LOAD_MAX
Definition: ISDOpcodes.h:1277
@ ATOMIC_STORE
OUTCHAIN = ATOMIC_STORE(INCHAIN, ptr, val) This corresponds to "store atomic" instruction.
Definition: ISDOpcodes.h:1247
@ ATOMIC_LOAD_UMIN
Definition: ISDOpcodes.h:1278
@ LOAD
LOAD and STORE have token chains as their first operand, then the same operands as an LLVM load/store...
Definition: ISDOpcodes.h:1037
@ INTRINSIC_VOID
OUTCHAIN = INTRINSIC_VOID(INCHAIN, INTRINSICID, arg1, arg2, ...) This node represents a target intrin...
Definition: ISDOpcodes.h:199
@ GlobalAddress
Definition: ISDOpcodes.h:78
@ ATOMIC_CMP_SWAP_WITH_SUCCESS
Val, Success, OUTCHAIN = ATOMIC_CMP_SWAP_WITH_SUCCESS(INCHAIN, ptr, cmp, swap) N.b.
Definition: ISDOpcodes.h:1260
@ ATOMIC_LOAD_OR
Definition: ISDOpcodes.h:1273
@ ATOMIC_LOAD_XOR
Definition: ISDOpcodes.h:1274
@ BUILTIN_OP_END
BUILTIN_OP_END - This must be the last enum value in this list.
Definition: ISDOpcodes.h:1406
@ ATOMIC_LOAD_FADD
Definition: ISDOpcodes.h:1280
@ GlobalTLSAddress
Definition: ISDOpcodes.h:79
@ SRCVALUE
SRCVALUE - This is a node type that holds a Value* that is used to make reference to a value in the L...
Definition: ISDOpcodes.h:1173
@ FrameIndex
Definition: ISDOpcodes.h:80
@ EH_LABEL
EH_LABEL - Represents a label in mid basic block used to track locations needed for debug and excepti...
Definition: ISDOpcodes.h:1108
@ ANNOTATION_LABEL
ANNOTATION_LABEL - Represents a mid basic block label used by annotations.
Definition: ISDOpcodes.h:1114
@ TargetExternalSymbol
Definition: ISDOpcodes.h:169
@ TargetJumpTable
Definition: ISDOpcodes.h:167
@ TargetIndex
TargetIndex - Like a constant pool entry, but with completely target-dependent semantics.
Definition: ISDOpcodes.h:177
@ PREFETCH
PREFETCH - This corresponds to a prefetch intrinsic.
Definition: ISDOpcodes.h:1227
@ ATOMIC_LOAD_FSUB
Definition: ISDOpcodes.h:1281
@ SSUBO
Same for subtraction.
Definition: ISDOpcodes.h:327
@ ATOMIC_LOAD_MIN
Definition: ISDOpcodes.h:1276
@ ATOMIC_LOAD
Val, OUTCHAIN = ATOMIC_LOAD(INCHAIN, ptr) This corresponds to "load atomic" instruction.
Definition: ISDOpcodes.h:1243
@ UNDEF
UNDEF - An undefined node.
Definition: ISDOpcodes.h:211
@ RegisterMask
Definition: ISDOpcodes.h:75
@ AssertAlign
AssertAlign - These nodes record if a register contains a value that has a known alignment and the tr...
Definition: ISDOpcodes.h:68
@ ATOMIC_LOAD_FMIN
Definition: ISDOpcodes.h:1283
@ BasicBlock
Various leaf nodes.
Definition: ISDOpcodes.h:71
@ SADDO
RESULT, BOOL = [SU]ADDO(LHS, RHS) - Overflow-aware nodes for addition.
Definition: ISDOpcodes.h:323
@ TargetGlobalAddress
TargetGlobalAddress - Like GlobalAddress, but the DAG does no folding or anything else with this node...
Definition: ISDOpcodes.h:164
@ STRICT_FP_TO_FP16
Definition: ISDOpcodes.h:916
@ STRICT_FP16_TO_FP
Definition: ISDOpcodes.h:915
@ ATOMIC_LOAD_CLR
Definition: ISDOpcodes.h:1272
@ VECTOR_SHUFFLE
VECTOR_SHUFFLE(VEC1, VEC2) - Returns a vector, of the same type as VEC1/VEC2.
Definition: ISDOpcodes.h:600
@ ATOMIC_LOAD_AND
Definition: ISDOpcodes.h:1271
@ TargetConstantFP
Definition: ISDOpcodes.h:159
@ ATOMIC_CMP_SWAP
Val, OUTCHAIN = ATOMIC_CMP_SWAP(INCHAIN, ptr, cmp, swap) For double-word atomic operations: ValLo,...
Definition: ISDOpcodes.h:1254
@ ATOMIC_LOAD_UMAX
Definition: ISDOpcodes.h:1279
@ SMULO
Same for multiplication.
Definition: ISDOpcodes.h:331
@ TargetFrameIndex
Definition: ISDOpcodes.h:166
@ ConstantPool
Definition: ISDOpcodes.h:82
@ LIFETIME_START
This corresponds to the llvm.lifetime.
Definition: ISDOpcodes.h:1310
@ STRICT_BF16_TO_FP
Definition: ISDOpcodes.h:924
@ ATOMIC_LOAD_UDEC_WRAP
Definition: ISDOpcodes.h:1285
@ ATOMIC_LOAD_ADD
Definition: ISDOpcodes.h:1269
@ ATOMIC_LOAD_SUB
Definition: ISDOpcodes.h:1270
@ TargetConstant
TargetConstant* - Like Constant*, but the DAG does not do any folding, simplification,...
Definition: ISDOpcodes.h:158
@ GET_FPENV_MEM
Gets the current floating-point environment.
Definition: ISDOpcodes.h:1013
@ PSEUDO_PROBE
Pseudo probe for AutoFDO, as a place holder in a basic block to improve the sample counts quality.
Definition: ISDOpcodes.h:1330
@ STRICT_FP_TO_BF16
Definition: ISDOpcodes.h:925
@ TokenFactor
TokenFactor - This node takes multiple tokens as input and produces a single token result.
Definition: ISDOpcodes.h:52
@ ATOMIC_SWAP
Val, OUTCHAIN = ATOMIC_SWAP(INCHAIN, ptr, amt) Val, OUTCHAIN = ATOMIC_LOAD_[OpName](INCHAIN,...
Definition: ISDOpcodes.h:1268
@ ExternalSymbol
Definition: ISDOpcodes.h:83
@ ADDRSPACECAST
ADDRSPACECAST - This operator converts between pointers of different address spaces.
Definition: ISDOpcodes.h:907
@ BlockAddress
Definition: ISDOpcodes.h:84
@ ATOMIC_LOAD_UINC_WRAP
Definition: ISDOpcodes.h:1284
@ SET_FPENV_MEM
Sets the current floating point environment.
Definition: ISDOpcodes.h:1018
@ INTRINSIC_W_CHAIN
RESULT,OUTCHAIN = INTRINSIC_W_CHAIN(INCHAIN, INTRINSICID, arg1, ...) This node represents a target in...
Definition: ISDOpcodes.h:192
@ TargetGlobalTLSAddress
Definition: ISDOpcodes.h:165
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
Definition: ISDOpcodes.h:515
bool isOverflowIntrOpRes(SDValue Op)
Returns true if the specified value is the overflow result from one of the overflow intrinsic nodes.
bool isBuildVectorOfConstantSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantSDNode or undef.
bool isNormalStore(const SDNode *N)
Returns true if the specified node is a non-truncating and unindexed store.
bool matchUnaryPredicate(SDValue Op, std::function< bool(ConstantSDNode *)> Match, bool AllowUndefs=false)
Hook for matching ConstantSDNode predicate.
bool isZEXTLoad(const SDNode *N)
Returns true if the specified node is a ZEXTLOAD.
bool matchUnaryFpPredicate(SDValue Op, std::function< bool(ConstantFPSDNode *)> Match, bool AllowUndefs=false)
Hook for matching ConstantFPSDNode predicate.
static const int FIRST_TARGET_MEMORY_OPCODE
FIRST_TARGET_MEMORY_OPCODE - Target-specific pre-isel operations which do not reference a specific me...
Definition: ISDOpcodes.h:1418
bool isConstantSplatVectorAllZeros(const SDNode *N, bool BuildVectorOnly=false)
Return true if the specified node is a BUILD_VECTOR or SPLAT_VECTOR where all of the elements are 0 o...
bool isVectorShrinkable(const SDNode *N, unsigned NewEltSize, bool Signed)
Returns true if the specified node is a vector where all elements can be truncated to the specified e...
bool matchUnaryPredicateImpl(SDValue Op, std::function< bool(ConstNodeType *)> Match, bool AllowUndefs=false)
Attempt to match a unary predicate against a scalar/splat constant or every element of a constant BUI...
bool isUNINDEXEDLoad(const SDNode *N)
Returns true if the specified node is an unindexed load.
bool isEXTLoad(const SDNode *N)
Returns true if the specified node is a EXTLOAD.
bool allOperandsUndef(const SDNode *N)
Return true if the node has at least one operand and all operands of the specified node are ISD::UNDE...
bool isFreezeUndef(const SDNode *N)
Return true if the specified node is FREEZE(UNDEF).
MemIndexType
MemIndexType enum - This enum defines how to interpret MGATHER/SCATTER's index parameter when calcula...
Definition: ISDOpcodes.h:1491
bool isBuildVectorAllZeros(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are 0 or undef.
bool isConstantSplatVector(const SDNode *N, APInt &SplatValue)
Node predicates.
bool matchBinaryPredicate(SDValue LHS, SDValue RHS, std::function< bool(ConstantSDNode *, ConstantSDNode *)> Match, bool AllowUndefs=false, bool AllowTypeMismatch=false)
Attempt to match a binary predicate against a pair of scalar/splat constants or every element of a pa...
bool isUNINDEXEDStore(const SDNode *N)
Returns true if the specified node is an unindexed store.
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:1478
bool isBuildVectorOfConstantFPSDNodes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR node of all ConstantFPSDNode or undef.
static const int FIRST_TARGET_STRICTFP_OPCODE
FIRST_TARGET_STRICTFP_OPCODE - Target-specific pre-isel operations which cannot raise FP exceptions s...
Definition: ISDOpcodes.h:1412
bool isSEXTLoad(const SDNode *N)
Returns true if the specified node is a SEXTLOAD.
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out,...
Definition: ISDOpcodes.h:1529
bool isBuildVectorAllOnes(const SDNode *N)
Return true if the specified node is a BUILD_VECTOR where all of the elements are ~0 or undef.
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Definition: ISDOpcodes.h:1509
bool isVPOpcode(unsigned Opcode)
Whether this is a vector-predicated Opcode.
bool isNormalLoad(const SDNode *N)
Returns true if the specified node is a non-extending and unindexed load.
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
GCNRegPressure max(const GCNRegPressure &P1, const GCNRegPressure &P2)
SDValue peekThroughExtractSubvectors(SDValue V)
Return the non-extracted vector source operand of V if it exists.
bool isNullConstant(SDValue V)
Returns true if V is a constant integer zero.
bool isAllOnesOrAllOnesSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowUndefs=false)
Return true if the value is a constant -1 integer or a splatted vector of a constant -1 integer (with...
Definition: Utils.cpp:1525
SDValue getBitwiseNotOperand(SDValue V, SDValue Mask, bool AllowUndefs)
If V is a bitwise not, returns the inverted operand.
SDValue peekThroughBitcasts(SDValue V)
Return the non-bitcasted source operand of V if it exists.
bool isIntOrFPConstant(SDValue V)
Return true if V is either a integer or FP constant.
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
bool isNullOrNullSplat(const MachineInstr &MI, const MachineRegisterInfo &MRI, bool AllowUndefs=false)
Return true if the value is a constant 0 integer or a splatted vector of a constant 0 integer (with n...
Definition: Utils.cpp:1507
bool isMinSignedConstant(SDValue V)
Returns true if V is a constant min signed integer value.
ConstantFPSDNode * isConstOrConstSplatFP(SDValue N, bool AllowUndefs=false)
Returns the SDNode if it is a constant splat BuildVector or constant float.
bool isBitwiseNot(SDValue V, bool AllowUndefs=false)
Returns true if V is a bitwise not operation.
void checkForCycles(const SelectionDAG *DAG, bool force=false)
SDValue peekThroughTruncates(SDValue V)
Return the non-truncated source operand of V if it exists.
bool hasSingleElement(ContainerTy &&C)
Returns true if the given container only contains a single element.
Definition: STLExtras.h:322
SDValue peekThroughOneUseBitcasts(SDValue V)
Return the non-bitcasted and one-use source operand of V if it exists.
bool isOneOrOneSplat(SDValue V, bool AllowUndefs=false)
Return true if the value is a constant 1 integer or a splatted vector of a constant 1 integer (with n...
AtomicOrdering
Atomic ordering for LLVM's memory model.
@ Other
Any other memory.
ConstantSDNode * isConstOrConstSplat(SDValue N, bool AllowUndefs=false, bool AllowTruncation=false)
Returns the SDNode if it is a constant splat BuildVector or constant int.
constexpr unsigned BitWidth
Definition: BitmaskEnum.h:191
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:1849
bool isOneConstant(SDValue V)
Returns true if V is a constant integer one.
bool isNullFPConstant(SDValue V)
Returns true if V is an FP constant with a value of positive zero.
bool isNeutralConstant(unsigned Opc, SDNodeFlags Flags, SDValue V, unsigned OperandNo)
Returns true if V is a neutral element of Opc with Flags.
bool isAllOnesConstant(SDValue V)
Returns true if V is an integer constant with all bits set.
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
A suitably aligned and sized character array member which can hold elements of any type.
Definition: AlignOf.h:27
static unsigned getHashValue(const SDValue &Val)
static bool isEqual(const SDValue &LHS, const SDValue &RHS)
An information struct used to provide DenseMap with the various necessary components for a given valu...
Definition: DenseMapInfo.h:50
Extended Value Type.
Definition: ValueTypes.h:34
TypeSize getSizeInBits() const
Return the size of the specified value type in bits.
Definition: ValueTypes.h:358
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:306
uint64_t getFixedSizeInBits() const
Return the size of the specified fixed width value type in bits.
Definition: ValueTypes.h:366
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition: ValueTypes.h:313
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:326
static ChildIteratorType child_begin(NodeRef N)
static ChildIteratorType child_end(NodeRef N)
static NodeRef getEntryNode(SDNode *N)
This class contains a discriminated union of information about pointers in memory operands,...
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
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.
void copyFMF(const FPMathOperator &FPMO)
Propagate the fast-math-flags from an IR FPMathOperator.
bool hasNoInfs() const
void setNoFPExcept(bool b)
void setDisjoint(bool b)
void setAllowContract(bool b)
void setNoSignedZeros(bool b)
bool hasNoFPExcept() const
void setNoNaNs(bool b)
bool hasNoUnsignedWrap() const
void setAllowReassociation(bool b)
bool hasNoNaNs() const
void setUnpredictable(bool b)
void setNoInfs(bool b)
void setAllowReciprocal(bool b)
bool hasAllowContract() const
bool hasNoSignedZeros() const
bool hasDisjoint() const
void intersectWith(const SDNodeFlags Flags)
Clear any flags in this flag set that aren't also set in Flags.
bool hasApproximateFuncs() const
bool hasUnpredictable() const
void setApproximateFuncs(bool b)
bool hasNoSignedWrap() const
void setNonNeg(bool b)
bool hasAllowReciprocal() const
bool hasNonNeg() const
SDNodeFlags()
Default constructor turns off all optimization flags.
bool hasAllowReassociation() const
void setNoUnsignedWrap(bool b)
void setNoSignedWrap(bool b)
Iterator for directly iterating over the operand SDValue's.
const SDValue & operator*() const
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
unsigned int NumVTs
static SimpleType getSimplifiedValue(SDUse &Val)
static SimpleType getSimplifiedValue(SDValue &Val)
static SimpleType getSimplifiedValue(const SDValue &Val)
Define a template that can be specialized by smart pointers to reflect the fact that they are automat...
Definition: Casting.h:34