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