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