LLVM 24.0.0git
SelectionDAG.h
Go to the documentation of this file.
1//===- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ----------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8//
9// This file declares the SelectionDAG class, and transitively defines the
10// SDNode class and subclasses.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef LLVM_CODEGEN_SELECTIONDAG_H
15#define LLVM_CODEGEN_SELECTIONDAG_H
16
17#include "llvm/ADT/ArrayRef.h"
18#include "llvm/ADT/DenseMap.h"
19#include "llvm/ADT/DenseSet.h"
20#include "llvm/ADT/FoldingSet.h"
22#include "llvm/ADT/StringMap.h"
23#include "llvm/ADT/ilist.h"
24#include "llvm/ADT/iterator.h"
35#include "llvm/IR/DebugLoc.h"
36#include "llvm/IR/Metadata.h"
43#include "llvm/Support/FPFold.h"
47#include <cassert>
48#include <cstdint>
49#include <functional>
50#include <map>
51#include <set>
52#include <string>
53#include <tuple>
54#include <utility>
55#include <vector>
56
57namespace llvm {
58
59class DIExpression;
60class DILabel;
61class DIVariable;
62class Function;
63class Pass;
64class Type;
65template <class GraphType> struct GraphTraits;
66template <typename T, unsigned int N> class SmallSetVector;
67template <typename T, typename Enable> struct FoldingSetTrait;
68class BatchAAResults;
69class BlockAddress;
71class Constant;
72class ConstantFP;
73class ConstantInt;
74class DataLayout;
75struct fltSemantics;
77class FunctionVarLocs;
78class GlobalValue;
79struct KnownBits;
80class LLVMContext;
83class MCSymbol;
85class SDDbgValue;
86class SDDbgOperand;
87class SDDbgLabel;
88class SelectionDAG;
89struct SelectionDAGOptions;
92class TargetLowering;
93class TargetMachine;
95class Value;
96
97template <typename T> class GenericSSAContext;
99template <typename T> class GenericUniformityInfo;
101
102/// The key SelectionDAG uniques SDNodes by. \p Tail carries the opcode
103/// specific data, which most opcodes do not have, still serialized; a lookup
104/// site appends it through the FoldingSetNodeID-shaped forwarders below.
105struct SDNodeKey {
106 unsigned Opcode;
107 const EVT *VTs;
110 /// Backs \p Ops when the key is built from a node; empty otherwise. No
111 /// inline capacity: only that one path pays for the storage.
113
115 : Opcode(Opcode), VTs(VTList.VTs), Ops(Ops) {}
116 LLVM_ABI explicit SDNodeKey(const SDNode &N);
117
118 SDNodeKey(const SDNodeKey &) = delete;
119 SDNodeKey &operator=(const SDNodeKey &) = delete;
120
121 // Forward to FoldingSetNodeID's own overload set, so a lookup site resolves
122 // the same way it did when profiling into one.
123 template <typename T> void AddInteger(T I) { Tail.AddInteger(I); }
124 void AddBoolean(bool B) { Tail.AddBoolean(B); }
125 void AddPointer(const void *P) { Tail.AddPointer(P); }
126};
127
130
131 static KeyTy getKey(const SDNode &N) { return SDNodeKey(N); }
132
133 static unsigned getHashValue(const KeyTy &Key) {
134 unsigned H = detail::combineHashValue(
136 for (const SDValue &Op : Key.Ops)
138 for (unsigned Word : Key.Tail.getRef())
140 return H;
141 }
142
143 LLVM_ABI static bool isEqual(const KeyTy &Key, const SDNode &N);
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 LibcallLoweringInfo *Libcalls = nullptr;
235 const SelectionDAGOptions *DAGOpts = nullptr;
236
237 const FunctionVarLocs *FnVarLocs = nullptr;
238 MachineFunction *MF;
239 MachineFunctionAnalysisManager *MFAM = nullptr;
240 LLVMContext *Context;
241 CodeGenOptLevel OptLevel;
242
243 UniformityInfo *UA = nullptr;
244 FunctionLoweringInfo * FLI = nullptr;
245
246 ProfileSummaryInfo *PSI = nullptr;
247 BlockFrequencyInfo *BFI = nullptr;
248
249 /// Uniquing of VT lists. Each key aliases the EVT array that the returned
250 /// SDVTList points at, allocated from \p Allocator.
251 struct VTListInfo {
252 static unsigned getHashValue(ArrayRef<EVT> VTs) {
253 unsigned H = VTs.size();
254 for (EVT VT : VTs)
256 H, DenseMapInfo<intptr_t>::getHashValue(VT.getRawBits()));
257 return H;
258 }
260 return LHS == RHS;
261 }
262 };
263 DenseSet<ArrayRef<EVT>, VTListInfo> VTLists;
264
265 /// Pool allocation for misc. objects that are created once per SelectionDAG.
266 BumpPtrAllocator Allocator;
267
268 /// The starting token.
269 SDNode EntryNode;
270
271 /// The root of the entire DAG.
272 SDValue Root;
273
274 /// A linked list of nodes in the current DAG.
275 ilist<SDNode> AllNodes;
276
277 /// The AllocatorType for allocating SDNodes. We use
278 /// pool allocation with recycling.
279 using NodeAllocatorType = RecyclingAllocator<BumpPtrAllocator, SDNode,
280 sizeof(LargestSDNode),
281 alignof(MostAlignedSDNode)>;
282
283 /// Pool allocation for nodes.
284 NodeAllocatorType NodeAllocator;
285
286 /// This structure is used to memoize nodes, automatically performing
287 /// CSE with existing nodes when a duplicate is requested.
289
290 /// Pool allocation for machine-opcode SDNode operands.
291 BumpPtrAllocator OperandAllocator;
292 ArrayRecycler<SDUse> OperandRecycler;
293
294 /// Tracks dbg_value and dbg_label information through SDISel.
295 SDDbgInfo *DbgInfo;
296
297 using CallSiteInfo = MachineFunction::CallSiteInfo;
298 using CalledGlobalInfo = MachineFunction::CalledGlobalInfo;
299
300 struct NodeExtraInfo {
301 CallSiteInfo CSInfo;
302 MDNode *HeapAllocSite = nullptr;
303 MDNode *PCSections = nullptr;
304 MDNode *MMRA = nullptr;
305 CalledGlobalInfo CalledGlobal{};
306 bool NoMerge = false;
307 };
308 /// Out-of-line extra information for SDNodes.
310
311 /// PersistentId counter to be used when inserting the next
312 /// SDNode to this SelectionDAG. We do not place that under
313 /// `#if LLVM_ENABLE_ABI_BREAKING_CHECKS` intentionally because
314 /// it adds unneeded complexity without noticeable
315 /// benefits (see discussion with @thakis in D120714).
316 uint16_t NextPersistentId = 0;
317
318public:
319 /// Clients of various APIs that cause global effects on
320 /// the DAG can optionally implement this interface. This allows the clients
321 /// to handle the various sorts of updates that happen.
322 ///
323 /// A DAGUpdateListener automatically registers itself with DAG when it is
324 /// constructed, and removes itself when destroyed in RAII fashion.
328
330 : Next(D.UpdateListeners), DAG(D) {
331 DAG.UpdateListeners = this;
332 }
333
335 assert(DAG.UpdateListeners == this &&
336 "DAGUpdateListeners must be destroyed in LIFO order");
337 DAG.UpdateListeners = Next;
338 }
339
340 /// The node N that was deleted and, if E is not null, an
341 /// equivalent node E that replaced it.
342 virtual void NodeDeleted(SDNode *N, SDNode *E);
343
344 /// The node N that was updated.
345 virtual void NodeUpdated(SDNode *N);
346
347 /// The node N that was inserted.
348 virtual void NodeInserted(SDNode *N);
349 };
350
352 std::function<void(SDNode *, SDNode *)> Callback;
353
357
358 void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); }
359
360 private:
361 virtual void anchor();
362 };
363
365 std::function<void(SDNode *)> Callback;
366
370
371 void NodeInserted(SDNode *N) override { Callback(N); }
372
373 private:
374 virtual void anchor();
375 };
376
377 /// Help to insert SDNodeFlags automatically in transforming. Use
378 /// RAII to save and resume flags in current scope.
380 SelectionDAG &DAG;
381 SDNodeFlags Flags;
382 FlagInserter *LastInserter;
383
384 public:
386 : DAG(SDAG), Flags(Flags),
387 LastInserter(SDAG.getFlagInserter()) {
388 SDAG.setFlagInserter(this);
389 }
392
393 FlagInserter(const FlagInserter &) = delete;
395 ~FlagInserter() { DAG.setFlagInserter(LastInserter); }
396
397 SDNodeFlags getFlags() const { return Flags; }
398 };
399
400 /// When true, additional steps are taken to
401 /// ensure that getConstant() and similar functions return DAG nodes that
402 /// have legal types. This is important after type legalization since
403 /// any illegally typed nodes generated after this point will not experience
404 /// type legalization.
406
407private:
408 /// DAGUpdateListener is a friend so it can manipulate the listener stack.
409 friend struct DAGUpdateListener;
410
411 /// Linked list of registered DAGUpdateListener instances.
412 /// This stack is maintained by DAGUpdateListener RAII.
413 DAGUpdateListener *UpdateListeners = nullptr;
414
415 /// Implementation of setSubgraphColor.
416 /// Return whether we had to truncate the search.
417 bool setSubgraphColorHelper(SDNode *N, const char *Color,
418 DenseSet<SDNode *> &visited,
419 int level, bool &printed);
420
421 template <typename SDNodeT, typename... ArgTypes>
422 SDNodeT *newSDNode(ArgTypes &&... Args) {
423 return new (NodeAllocator.template Allocate<SDNodeT>())
424 SDNodeT(std::forward<ArgTypes>(Args)...);
425 }
426
427 /// Build a synthetic SDNodeT with the given args and extract its subclass
428 /// data as an integer (e.g. for use in a folding set).
429 ///
430 /// The args to this function are the same as the args to SDNodeT's
431 /// constructor, except the second arg (assumed to be a const DebugLoc&) is
432 /// omitted.
433 template <typename SDNodeT, typename... ArgTypes>
434 static uint16_t getSyntheticNodeSubclassData(unsigned IROrder,
435 ArgTypes &&... Args) {
436 // The compiler can reduce this expression to a constant iff we pass an
437 // empty DebugLoc. Thankfully, the debug location doesn't have any bearing
438 // on the subclass data.
439 return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...)
440 .getRawSubclassData();
441 }
442
443 template <typename SDNodeTy>
444 static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order,
445 SDVTList VTs, EVT MemoryVT,
446 MachineMemOperand *MMO) {
447 return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO)
448 .getRawSubclassData();
449 }
450
451 template <typename SDNodeTy>
452 static uint16_t getSyntheticNodeSubclassData(
453 unsigned Opc, unsigned Order, SDVTList VTs, EVT MemoryVT,
454 PointerUnion<MachineMemOperand *, MachineMemOperand **> MemRefs) {
455 return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MemRefs)
456 .getRawSubclassData();
457 }
458
459 void createOperands(SDNode *Node, ArrayRef<SDValue> Vals);
460
461 void removeOperands(SDNode *Node) {
462 if (!Node->OperandList)
463 return;
464 OperandRecycler.deallocate(
466 Node->OperandList);
467 Node->NumOperands = 0;
468 Node->OperandList = nullptr;
469 }
470 void CreateTopologicalOrder(std::vector<SDNode*>& Order);
471
472public:
473 // Maximum depth for recursive analysis such as computeKnownBits, etc.
474 static constexpr unsigned MaxRecursionDepth = 6;
475
477 SelectionDAG(const SelectionDAG &) = delete;
480
481 /// Prepare this SelectionDAG to process code in the given MachineFunction.
482 LLVM_ABI void init(MachineFunction &NewMF,
483 const TargetLibraryInfo *LibraryInfo,
484 const LibcallLoweringInfo *LibcallsInfo,
486 BlockFrequencyInfo *BFIin,
487 FunctionVarLocs const *FnVarLocs);
488
490 const TargetLibraryInfo *LibraryInfo,
491 const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA,
493 FunctionVarLocs const *FnVarLocs) {
494 init(NewMF, LibraryInfo, LibcallsInfo, UA, PSIin, BFIin, FnVarLocs);
495 MFAM = &AM;
496 }
497
499 FLI = FuncInfo;
500 }
501
502 /// Clear state and free memory necessary to make this
503 /// SelectionDAG ready to process a new block.
504 LLVM_ABI void clear();
505
506 MachineFunction &getMachineFunction() const { return *MF; }
508
509 LLVM_ABI bool hasSwiftErrorArg() const;
510
511 // Returns the maximum steps for SDNode->hasPredecessor() like searches.
512 LLVM_ABI unsigned getHasPredecessorMaxSteps() const;
513
514 CodeGenOptLevel getOptLevel() const { return OptLevel; }
515 const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
516 const TargetMachine &getTarget() const { return TM; }
517 const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
518 template <typename STC> const STC &getSubtarget() const {
519 return MF->getSubtarget<STC>();
520 }
521 const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
522 const TargetLibraryInfo &getLibInfo() const { return *LibInfo; }
523
524 const LibcallLoweringInfo &getLibcalls() const { return *Libcalls; }
525
526 const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; }
527 const UniformityInfo *getUniformityInfo() const { return UA; }
528 /// Returns the result of the AssignmentTrackingAnalysis pass if it's
529 /// available, otherwise return nullptr.
530 const FunctionVarLocs *getFunctionVarLocs() const { return FnVarLocs; }
531 LLVMContext *getContext() const { return Context; }
532 const SelectionDAGOptions &getSelectionDAGOptions() const { return *DAGOpts; }
533 ProfileSummaryInfo *getPSI() const { return PSI; }
534 BlockFrequencyInfo *getBFI() const { return BFI; }
535
536 FlagInserter *getFlagInserter() { return Inserter; }
537 void setFlagInserter(FlagInserter *FI) { Inserter = FI; }
538
539 /// Just dump dot graph to a user-provided path and title.
540 /// This doesn't open the dot viewer program and
541 /// helps visualization when outside debugging session.
542 /// FileName expects absolute path. If provided
543 /// without any path separators then the file
544 /// will be created in the current directory.
545 /// Error will be emitted if the path is insane.
546#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
547 LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title);
548#endif
549
550 /// Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
551 LLVM_ABI void viewGraph(const std::string &Title);
552 LLVM_ABI void viewGraph();
553
554#if LLVM_ENABLE_ABI_BREAKING_CHECKS
555 std::map<const SDNode *, std::string> NodeGraphAttrs;
556#endif
557
558 /// Clear all previously defined node graph attributes.
559 /// Intended to be used from a debugging tool (eg. gdb).
561
562 /// Set graph attributes for a node. (eg. "color=red".)
563 LLVM_ABI void setGraphAttrs(const SDNode *N, const char *Attrs);
564
565 /// Get graph attributes for a node. (eg. "color=red".)
566 /// Used from getNodeAttributes.
567 LLVM_ABI std::string getGraphAttrs(const SDNode *N) const;
568
569 /// Convenience for setting node color attribute.
570 LLVM_ABI void setGraphColor(const SDNode *N, const char *Color);
571
572 /// Convenience for setting subgraph color attribute.
573 LLVM_ABI void setSubgraphColor(SDNode *N, const char *Color);
574
576
577 allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
578 allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
579
581
582 allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
583 allnodes_iterator allnodes_end() { return AllNodes.end(); }
584
586 return AllNodes.size();
587 }
588
595
596 /// Return the root tag of the SelectionDAG.
597 const SDValue &getRoot() const { return Root; }
598
599 /// Return the token chain corresponding to the entry of the function.
601 return SDValue(const_cast<SDNode *>(&EntryNode), 0);
602 }
603
604 /// Set the current root tag of the SelectionDAG.
605 ///
607 assert((!N.getNode() || N.getValueType() == MVT::Other) &&
608 "DAG root value is not a chain!");
609 if (N.getNode())
610 checkForCycles(N.getNode(), this);
611 Root = N;
612 if (N.getNode())
613 checkForCycles(this);
614 return Root;
615 }
616
617#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
618 void VerifyDAGDivergence();
619#endif
620
621 /// This iterates over the nodes in the SelectionDAG, folding
622 /// certain types of nodes together, or eliminating superfluous nodes. The
623 /// Level argument controls whether Combine is allowed to produce nodes and
624 /// types that are illegal on the target.
625 LLVM_ABI void Combine(CombineLevel Level, BatchAAResults *BatchAA,
626 CodeGenOptLevel OptLevel);
627
628 /// This transforms the SelectionDAG into a SelectionDAG that
629 /// only uses types natively supported by the target.
630 /// Returns "true" if it made any changes.
631 ///
632 /// Note that this is an involved process that may invalidate pointers into
633 /// the graph.
634 LLVM_ABI bool LegalizeTypes();
635
636 /// This transforms the SelectionDAG into a SelectionDAG that is
637 /// compatible with the target instruction selector, as indicated by the
638 /// TargetLowering object.
639 ///
640 /// Note that this is an involved process that may invalidate pointers into
641 /// the graph.
642 LLVM_ABI void Legalize();
643
644 /// Transforms a SelectionDAG node and any operands to it into a node
645 /// that is compatible with the target instruction selector, as indicated by
646 /// the TargetLowering object.
647 ///
648 /// \returns true if \c N is a valid, legal node after calling this.
649 ///
650 /// This essentially runs a single recursive walk of the \c Legalize process
651 /// over the given node (and its operands). This can be used to incrementally
652 /// legalize the DAG. All of the nodes which are directly replaced,
653 /// potentially including N, are added to the output parameter \c
654 /// UpdatedNodes so that the delta to the DAG can be understood by the
655 /// caller.
656 ///
657 /// When this returns false, N has been legalized in a way that make the
658 /// pointer passed in no longer valid. It may have even been deleted from the
659 /// DAG, and so it shouldn't be used further. When this returns true, the
660 /// N passed in is a legal node, and can be immediately processed as such.
661 /// This may still have done some work on the DAG, and will still populate
662 /// UpdatedNodes with any new nodes replacing those originally in the DAG.
664 SmallSetVector<SDNode *, 16> &UpdatedNodes);
665
666 /// This transforms the SelectionDAG into a SelectionDAG
667 /// that only uses vector math operations supported by the target. This is
668 /// necessary as a separate step from Legalize because unrolling a vector
669 /// operation can introduce illegal types, which requires running
670 /// LegalizeTypes again.
671 ///
672 /// This returns true if it made any changes; in that case, LegalizeTypes
673 /// is called again before Legalize.
674 ///
675 /// Note that this is an involved process that may invalidate pointers into
676 /// the graph.
678
679 /// This method deletes all unreachable nodes in the SelectionDAG.
681
682 /// Remove the specified node from the system. This node must
683 /// have no referrers.
685
686 /// Return an SDVTList that represents the list of values specified.
689 LLVM_ABI SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
690 LLVM_ABI SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
692
693 //===--------------------------------------------------------------------===//
694 // Node creation methods.
695
696 /// Create a ConstantSDNode wrapping a constant value.
697 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
698 ///
699 /// If only legal types can be produced, this does the necessary
700 /// transformations (e.g., if the vector element type is illegal).
701 /// @{
703 bool isTarget = false, bool isOpaque = false);
704 LLVM_ABI SDValue getConstant(const APInt &Val, const SDLoc &DL, EVT VT,
705 bool isTarget = false, bool isOpaque = false);
706
707 LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT,
708 bool isTarget = false,
709 bool isOpaque = false);
710
712 bool IsTarget = false,
713 bool IsOpaque = false);
714
715 LLVM_ABI SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
716 bool isTarget = false, bool isOpaque = false);
718 bool isTarget = false);
720 const SDLoc &DL);
722 const SDLoc &DL);
724 bool isTarget = false);
725
727 bool isOpaque = false) {
728 return getConstant(Val, DL, VT, true, isOpaque);
729 }
730 SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT,
731 bool isOpaque = false) {
732 return getConstant(Val, DL, VT, true, isOpaque);
733 }
735 bool isOpaque = false) {
736 return getConstant(Val, DL, VT, true, isOpaque);
737 }
738 SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT,
739 bool isOpaque = false) {
740 return getSignedConstant(Val, DL, VT, true, isOpaque);
741 }
742
743 /// Create a true or false constant of type \p VT using the target's
744 /// BooleanContent for type \p OpVT.
745 LLVM_ABI SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT);
746 /// @}
747
748 /// Create a ConstantFPSDNode wrapping a constant value.
749 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
750 ///
751 /// If only legal types can be produced, this does the necessary
752 /// transformations (e.g., if the vector element type is illegal).
753 /// The forms that take a double should only be used for simple constants
754 /// that can be exactly represented in VT. No checks are made.
755 /// @{
756 LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT,
757 bool isTarget = false);
758 LLVM_ABI SDValue getConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT,
759 bool isTarget = false);
760 /// Return the folded constant, or an empty SDValue if folding failed.
761 LLVM_ABI SDValue getConstFP(std::optional<FPFoldResult> Result,
762 const SDLoc &DL, EVT VT, bool isTarget = false);
764 bool isTarget = false);
765 SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT) {
766 return getConstantFP(Val, DL, VT, true);
767 }
768 SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT) {
769 return getConstantFP(Val, DL, VT, true);
770 }
772 return getConstantFP(Val, DL, VT, true);
773 }
774 /// @}
775
777 EVT VT, int64_t offset = 0,
778 bool isTargetGA = false,
779 unsigned TargetFlags = 0);
781 int64_t offset = 0, unsigned TargetFlags = 0) {
782 return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags);
783 }
785 LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
787 return getFrameIndex(FI, VT, true);
788 }
789 LLVM_ABI SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
790 unsigned TargetFlags = 0);
791 SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags = 0) {
792 return getJumpTable(JTI, VT, true, TargetFlags);
793 }
795 const SDLoc &DL);
797 MaybeAlign Align = std::nullopt,
798 int Offs = 0, bool isT = false,
799 unsigned TargetFlags = 0);
801 MaybeAlign Align = std::nullopt, int Offset = 0,
802 unsigned TargetFlags = 0) {
803 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
804 }
806 MaybeAlign Align = std::nullopt,
807 int Offs = 0, bool isT = false,
808 unsigned TargetFlags = 0);
810 MaybeAlign Align = std::nullopt, int Offset = 0,
811 unsigned TargetFlags = 0) {
812 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
813 }
814 // When generating a branch to a BB, we don't in general know enough
815 // to provide debug info for the BB at that time, so keep this one around.
817 LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT);
818 LLVM_ABI SDValue getExternalSymbol(RTLIB::LibcallImpl LCImpl, EVT VT);
819 LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
820 unsigned TargetFlags = 0);
821 LLVM_ABI SDValue getTargetExternalSymbol(RTLIB::LibcallImpl LCImpl, EVT VT,
822 unsigned TargetFlags = 0);
823
825
829 LLVM_ABI SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label);
830 LLVM_ABI SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root,
831 MCSymbol *Label);
833 int64_t Offset = 0, bool isTarget = false,
834 unsigned TargetFlags = 0);
836 int64_t Offset = 0, unsigned TargetFlags = 0) {
837 return getBlockAddress(BA, VT, Offset, true, TargetFlags);
838 }
839
841 SDValue N) {
842 return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
843 getRegister(Reg, N.getValueType()), N);
844 }
845
846 // This version of the getCopyToReg method takes an extra operand, which
847 // indicates that there is potentially an incoming glue value (if Glue is not
848 // null) and that there should be a glue result.
850 SDValue Glue) {
851 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
852 SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
853 return getNode(ISD::CopyToReg, dl, VTs,
854 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
855 }
856
857 // Similar to last getCopyToReg() except parameter Reg is a SDValue
859 SDValue Glue) {
860 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
861 SDValue Ops[] = { Chain, Reg, N, Glue };
862 return getNode(ISD::CopyToReg, dl, VTs,
863 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
864 }
865
867 SDVTList VTs = getVTList(VT, MVT::Other);
868 SDValue Ops[] = { Chain, getRegister(Reg, VT) };
869 return getNode(ISD::CopyFromReg, dl, VTs, Ops);
870 }
871
872 // This version of the getCopyFromReg method takes an extra operand, which
873 // indicates that there is potentially an incoming glue value (if Glue is not
874 // null) and that there should be a glue result.
876 SDValue Glue) {
877 SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
878 SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
879 return getNode(ISD::CopyFromReg, dl, VTs,
880 ArrayRef(Ops, Glue.getNode() ? 3 : 2));
881 }
882
884
885 /// Return an ISD::VECTOR_SHUFFLE node. The number of elements in VT,
886 /// which must be a vector type, must match the number of mask elements
887 /// NumElts. An integer mask element equal to -1 is treated as undefined.
889 SDValue N2, ArrayRef<int> Mask);
890
891 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
892 /// which must be a vector type, must match the number of operands in Ops.
893 /// The operands must have the same type as (or, for integers, a type wider
894 /// than) VT's element type.
895 ///
896 /// If the vector elements are all POISON or UNDEF, return a ISD::POISON or
897 /// ISD::UNDEF node instead.
899 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
900 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
901 }
902
903 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
904 /// which must be a vector type, must match the number of operands in Ops.
905 /// The operands must have the same type as (or, for integers, a type wider
906 /// than) VT's element type.
907 ///
908 /// If the vector elements are all POISON or UNDEF, return a ISD::POISON or
909 /// ISD::UNDEF node instead.
911 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
912 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
913 }
914
915 /// Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all
916 /// elements. VT must be a vector type. Op's type must be the same as (or,
917 /// for integers, a type wider than) VT's element type.
919 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
920 if (Op.isUndef()) {
921 assert((VT.getVectorElementType() == Op.getValueType() ||
922 (VT.isInteger() &&
923 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
924 "A splatted value must have a width equal or (for integers) "
925 "greater than the vector element type!");
926 return getNode(ISD::UNDEF, SDLoc(), VT);
927 }
928
930 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
931 }
932
933 // Return a splat ISD::SPLAT_VECTOR node, consisting of Op splatted to all
934 // elements.
936 if (Op.isUndef()) {
937 assert((VT.getVectorElementType() == Op.getValueType() ||
938 (VT.isInteger() &&
939 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
940 "A splatted value must have a width equal or (for integers) "
941 "greater than the vector element type!");
942 return getNode(ISD::UNDEF, SDLoc(), VT);
943 }
944 return getNode(ISD::SPLAT_VECTOR, DL, VT, Op);
945 }
946
947 /// Returns a node representing a splat of one value into all lanes
948 /// of the provided vector type. This is a utility which returns
949 /// either a BUILD_VECTOR or SPLAT_VECTOR depending on the
950 /// scalability of the desired vector type.
952 assert(VT.isVector() && "Can't splat to non-vector type");
953 return VT.isScalableVector() ?
955 }
956
957 /// Returns a vector of type ResVT whose elements contain the linear sequence
958 /// <0, Step, Step * 2, Step * 3, ...>
960 const APInt &StepVal);
961
962 /// Returns a vector of type ResVT whose elements contain the linear sequence
963 /// <0, 1, 2, 3, ...>
964 LLVM_ABI SDValue getStepVector(const SDLoc &DL, EVT ResVT);
965
966 /// Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to
967 /// the shuffle node in input but with swapped operands.
968 ///
969 /// Example: shuffle A, B, <0,5,2,7> -> shuffle B, A, <4,1,6,3>
971
972 /// Extract element at \p Idx from \p Vec. See EXTRACT_VECTOR_ELT
973 /// description for result type handling.
975 unsigned Idx) {
976 return getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, Vec,
978 }
979
980 /// Insert \p Elt into \p Vec at offset \p Idx. See INSERT_VECTOR_ELT
981 /// description for element type handling.
983 unsigned Idx) {
984 return getNode(ISD::INSERT_VECTOR_ELT, DL, Vec.getValueType(), Vec, Elt,
986 }
987
988 /// Insert \p SubVec at the \p Idx element of \p Vec.
990 unsigned Idx) {
991 return getNode(ISD::INSERT_SUBVECTOR, DL, Vec.getValueType(), Vec, SubVec,
993 }
994
995 /// Return the \p VT typed sub-vector of \p Vec at \p Idx
997 unsigned Idx) {
998 return getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Vec,
1000 }
1001
1002 /// Convert Op, which must be of float type, to the
1003 /// float type VT, by either extending or rounding (by truncation).
1005
1006 /// Convert Op, which must be a STRICT operation of float type, to the
1007 /// float type VT, by either extending or rounding (by truncation).
1008 LLVM_ABI std::pair<SDValue, SDValue>
1010
1011 /// Convert *_EXTEND_VECTOR_INREG to *_EXTEND opcode.
1012 static unsigned getOpcode_EXTEND(unsigned Opcode) {
1013 switch (Opcode) {
1014 case ISD::ANY_EXTEND:
1016 return ISD::ANY_EXTEND;
1017 case ISD::ZERO_EXTEND:
1019 return ISD::ZERO_EXTEND;
1020 case ISD::SIGN_EXTEND:
1022 return ISD::SIGN_EXTEND;
1023 }
1024 llvm_unreachable("Unknown opcode");
1025 }
1026
1027 /// Convert *_EXTEND to *_EXTEND_VECTOR_INREG opcode.
1028 static unsigned getOpcode_EXTEND_VECTOR_INREG(unsigned Opcode) {
1029 switch (Opcode) {
1030 case ISD::ANY_EXTEND:
1033 case ISD::ZERO_EXTEND:
1036 case ISD::SIGN_EXTEND:
1039 }
1040 llvm_unreachable("Unknown opcode");
1041 }
1042
1043 /// Convert Op, which must be of integer type, to the
1044 /// integer type VT, by either any-extending or truncating it.
1046
1047 /// Convert Op, which must be of integer type, to the
1048 /// integer type VT, by either sign-extending or truncating it.
1050
1051 /// Convert Op, which must be of integer type, to the
1052 /// integer type VT, by either zero-extending or truncating it.
1054
1055 /// Convert Op, which must be of integer type, to the
1056 /// integer type VT, by either any/sign/zero-extending (depending on IsAny /
1057 /// IsSigned) or truncating it.
1059 EVT VT, unsigned Opcode) {
1060 switch(Opcode) {
1061 case ISD::ANY_EXTEND:
1062 return getAnyExtOrTrunc(Op, DL, VT);
1063 case ISD::ZERO_EXTEND:
1064 return getZExtOrTrunc(Op, DL, VT);
1065 case ISD::SIGN_EXTEND:
1066 return getSExtOrTrunc(Op, DL, VT);
1067 }
1068 llvm_unreachable("Unsupported opcode");
1069 }
1070
1071 /// Convert Op, which must be of integer type, to the
1072 /// integer type VT, by either sign/zero-extending (depending on IsSigned) or
1073 /// truncating it.
1074 SDValue getExtOrTrunc(bool IsSigned, SDValue Op, const SDLoc &DL, EVT VT) {
1075 return IsSigned ? getSExtOrTrunc(Op, DL, VT) : getZExtOrTrunc(Op, DL, VT);
1076 }
1077
1078 /// Convert Op, which must be of integer type, to the
1079 /// integer type VT, by first bitcasting (from potential vector) to
1080 /// corresponding scalar type then either any-extending or truncating it.
1082 EVT VT);
1083
1084 /// Return the expression required to zero extend the Op
1085 /// value assuming it was the smaller SrcTy value.
1087
1088 /// Convert Op, which must be of integer type, to the integer type VT, by
1089 /// either truncating it or performing either zero or sign extension as
1090 /// appropriate extension for the pointer's semantics.
1092
1093 /// Return the expression required to extend the Op as a pointer value
1094 /// assuming it was the smaller SrcTy value. This may be either a zero extend
1095 /// or a sign extend.
1097
1098 /// Convert Op, which must be of integer type, to the integer type VT,
1099 /// by using an extension appropriate for the target's
1100 /// BooleanContent for type OpVT or truncating it.
1102 EVT OpVT);
1103
1104 /// Create negative operation as (SUB 0, Val).
1105 LLVM_ABI SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT);
1106
1107 /// Create a bitwise NOT operation as (XOR Val, -1).
1108 LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT);
1109
1110 /// Create a logical NOT operation as (XOR Val, BooleanOne).
1111 LLVM_ABI SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT);
1112
1113 /// Returns sum of the base pointer and offset.
1114 /// Unlike getObjectPtrOffset this does not set NoUnsignedWrap and InBounds by
1115 /// default.
1118 const SDNodeFlags Flags = SDNodeFlags());
1121 const SDNodeFlags Flags = SDNodeFlags());
1122
1123 /// Create an add instruction with appropriate flags when used for
1124 /// addressing some offset of an object. i.e. if a load is split into multiple
1125 /// components, create an add nuw (or ptradd nuw inbounds) from the base
1126 /// pointer to the offset.
1131
1133 // The object itself can't wrap around the address space, so it shouldn't be
1134 // possible for the adds of the offsets to the split parts to overflow.
1135 return getMemBasePlusOffset(
1137 }
1138
1139 /// Return a new CALLSEQ_START node, that starts new call frame, in which
1140 /// InSize bytes are set up inside CALLSEQ_START..CALLSEQ_END sequence and
1141 /// OutSize specifies part of the frame set up prior to the sequence.
1143 const SDLoc &DL) {
1144 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
1145 SDValue Ops[] = { Chain,
1146 getIntPtrConstant(InSize, DL, true),
1147 getIntPtrConstant(OutSize, DL, true) };
1148 return getNode(ISD::CALLSEQ_START, DL, VTs, Ops);
1149 }
1150
1151 /// Return a new CALLSEQ_END node, which always must have a
1152 /// glue result (to ensure it's not CSE'd).
1153 /// CALLSEQ_END does not have a useful SDLoc.
1155 SDValue InGlue, const SDLoc &DL) {
1156 SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue);
1158 Ops.push_back(Chain);
1159 Ops.push_back(Op1);
1160 Ops.push_back(Op2);
1161 if (InGlue.getNode())
1162 Ops.push_back(InGlue);
1163 return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops);
1164 }
1165
1167 SDValue Glue, const SDLoc &DL) {
1168 return getCALLSEQ_END(
1169 Chain, getIntPtrConstant(Size1, DL, /*isTarget=*/true),
1170 getIntPtrConstant(Size2, DL, /*isTarget=*/true), Glue, DL);
1171 }
1172
1173 /// Return true if the result of this operation is always undefined.
1174 LLVM_ABI bool isUndef(unsigned Opcode, ArrayRef<SDValue> Ops);
1175
1176 /// Return an UNDEF node. UNDEF does not have a useful SDLoc.
1178 return getNode(ISD::UNDEF, SDLoc(), VT);
1179 }
1180
1181 /// Return a POISON node. POISON does not have a useful SDLoc.
1183
1184 /// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
1185 LLVM_ABI SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm);
1186
1188
1190
1191 /// Return a vector with the first 'Len' lanes set to true and remaining lanes
1192 /// set to false. The mask's ValueType is the same as when comparing vectors
1193 /// of type VT.
1195 ElementCount Len);
1196
1197 /// Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
1201
1202 /// Gets or creates the specified node.
1203 ///
1204 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1206 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1207 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1208 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL,
1210 const SDNodeFlags Flags);
1211 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1212 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1213
1214 // Use flags from current flag inserter.
1215 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1217 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL,
1219 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1221 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1222 SDValue Operand);
1223 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1224 SDValue N2);
1225 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1226 SDValue N2, SDValue N3);
1227
1228 // Specialize based on number of operands.
1229 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT);
1230 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1231 SDValue Operand, const SDNodeFlags Flags);
1232 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1233 SDValue N2, const SDNodeFlags Flags);
1234 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1235 SDValue N2, SDValue N3, const SDNodeFlags Flags);
1236 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1237 SDValue N2, SDValue N3, SDValue N4);
1238 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1239 SDValue N2, SDValue N3, SDValue N4,
1240 const SDNodeFlags Flags);
1241 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1242 SDValue N2, SDValue N3, SDValue N4, SDValue N5);
1243 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1244 SDValue N2, SDValue N3, SDValue N4, SDValue N5,
1245 const SDNodeFlags Flags);
1246
1247 // Specialize again based on number of operands for nodes with a VTList
1248 // rather than a single VT.
1249 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList);
1250 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1251 SDValue N);
1252 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1253 SDValue N1, SDValue N2);
1254 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1255 SDValue N1, SDValue N2, SDValue N3);
1256 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1257 SDValue N1, SDValue N2, SDValue N3, SDValue N4);
1258 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1259 SDValue N1, SDValue N2, SDValue N3, SDValue N4,
1260 SDValue N5);
1261
1262 /// Compute a TokenFactor to force all the incoming stack arguments to be
1263 /// loaded from the stack. This is used in tail call lowering to protect
1264 /// stack arguments from being clobbered.
1266
1267 /// Lower a memccpy operation into a target library call and return the
1268 /// resulting chain and call result as SelectionDAG SDValues.
1269 LLVM_ABI std::pair<SDValue, SDValue>
1270 getMemccpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
1271 SDValue C, SDValue Size, const CallInst *CI);
1272
1273 /// Lower a memcmp operation into a target library call and return the
1274 /// resulting chain and call result as SelectionDAG SDValues.
1275 LLVM_ABI std::pair<SDValue, SDValue> getMemcmp(SDValue Chain, const SDLoc &dl,
1276 SDValue Dst, SDValue Src,
1277 SDValue Size,
1278 const CallInst *CI);
1279
1280 /// Lower a strcmp operation into a target library call and return the
1281 /// resulting chain and call result as SelectionDAG SDValues.
1282 LLVM_ABI std::pair<SDValue, SDValue> getStrcmp(SDValue Chain, const SDLoc &dl,
1283 SDValue S0, SDValue S1,
1284 const CallInst *CI);
1285
1286 /// Lower a strcpy operation into a target library call and return the
1287 /// resulting chain and call result as SelectionDAG SDValues.
1288 LLVM_ABI std::pair<SDValue, SDValue> getStrcpy(SDValue Chain, const SDLoc &dl,
1289 SDValue Dst, SDValue Src,
1290 const CallInst *CI);
1291
1292 /// Lower a strlen operation into a target library call and return the
1293 /// resulting chain and call result as SelectionDAG SDValues.
1294 LLVM_ABI std::pair<SDValue, SDValue>
1295 getStrlen(SDValue Chain, const SDLoc &dl, SDValue Src, const CallInst *CI);
1296
1297 /// Lower a strstr operation into a target library call and return the
1298 /// resulting chain and call result as SelectionDAG SDValues.
1299 LLVM_ABI std::pair<SDValue, SDValue> getStrstr(SDValue Chain, const SDLoc &dl,
1300 SDValue S0, SDValue S1,
1301 const CallInst *CI);
1302
1303 /* \p CI if not null is the memset call being lowered.
1304 * \p OverrideTailCall is an optional parameter that can be used to override
1305 * the tail call optimization decision. */
1307 SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size,
1308 Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline,
1309 const CallInst *CI, std::optional<bool> OverrideTailCall,
1310 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo,
1311 const AAMDNodes &AAInfo = AAMDNodes(), BatchAAResults *BatchAA = nullptr);
1312
1313 /* \p CI if not null is the memset call being lowered.
1314 * \p OverrideTailCall is an optional parameter that can be used to override
1315 * the tail call optimization decision. */
1316 LLVM_ABI SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
1317 SDValue Src, SDValue Size, Align DstAlign,
1318 Align SrcAlign, bool isVol, const CallInst *CI,
1319 std::optional<bool> OverrideTailCall,
1320 MachinePointerInfo DstPtrInfo,
1321 MachinePointerInfo SrcPtrInfo,
1322 const AAMDNodes &AAInfo = AAMDNodes(),
1323 BatchAAResults *BatchAA = nullptr);
1324
1325 LLVM_ABI SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
1326 SDValue Src, SDValue Size, Align Alignment,
1327 bool isVol, bool AlwaysInline, const CallInst *CI,
1328 MachinePointerInfo DstPtrInfo,
1329 const AAMDNodes &AAInfo = AAMDNodes());
1330
1331 LLVM_ABI SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst,
1332 SDValue Src, SDValue Size, Type *SizeTy,
1333 unsigned ElemSz, bool isTailCall,
1334 MachinePointerInfo DstPtrInfo,
1335 MachinePointerInfo SrcPtrInfo);
1336
1337 LLVM_ABI SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
1338 SDValue Src, SDValue Size, Type *SizeTy,
1339 unsigned ElemSz, bool isTailCall,
1340 MachinePointerInfo DstPtrInfo,
1341 MachinePointerInfo SrcPtrInfo);
1342
1343 LLVM_ABI SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
1344 SDValue Value, SDValue Size, Type *SizeTy,
1345 unsigned ElemSz, bool isTailCall,
1346 MachinePointerInfo DstPtrInfo);
1347
1348 /// Helper function to make it easier to build SetCC's if you just have an
1349 /// ISD::CondCode instead of an SDValue.
1351 ISD::CondCode Cond, SDValue Chain = SDValue(),
1352 bool IsSignaling = false, SDNodeFlags Flags = {}) {
1353 assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() &&
1354 "Vector/scalar operand type mismatch for setcc");
1355 assert(LHS.getValueType().isVector() == VT.isVector() &&
1356 "Vector/scalar result type mismatch for setcc");
1358 "Cannot create a setCC of an invalid node.");
1359 if (Chain)
1360 return getNode(IsSignaling ? ISD::STRICT_FSETCCS : ISD::STRICT_FSETCC, DL,
1361 {VT, MVT::Other}, {Chain, LHS, RHS, getCondCode(Cond)},
1362 Flags);
1363 return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond), Flags);
1364 }
1365
1366 /// Helper function to make it easier to build Select's if you just have
1367 /// operands and don't want to check for vector.
1369 SDValue RHS, SDNodeFlags Flags = SDNodeFlags()) {
1370 assert(LHS.getValueType() == VT && RHS.getValueType() == VT &&
1371 "Cannot use select on differing types");
1372 auto Opcode = Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT;
1373 return getNode(Opcode, DL, VT, Cond, LHS, RHS, Flags);
1374 }
1375
1376 /// Helper function to make it easier to build SelectCC's if you just have an
1377 /// ISD::CondCode instead of an SDValue.
1380 SDNodeFlags Flags = SDNodeFlags()) {
1381 return getNode(ISD::SELECT_CC, DL, True.getValueType(), LHS, RHS, True,
1382 False, getCondCode(Cond), Flags);
1383 }
1384
1385 /// Try to simplify a select/vselect into 1 of its operands or a constant.
1387
1388 /// Try to simplify a shift into 1 of its operands or a constant.
1390
1391 /// Try to simplify a floating-point binary operation into 1 of its operands
1392 /// or a constant.
1393 LLVM_ABI SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y,
1394 SDNodeFlags Flags);
1395
1396 /// VAArg produces a result and token chain, and takes a pointer
1397 /// and a source value as input.
1398 LLVM_ABI SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1399 SDValue SV, unsigned Align);
1400
1401 /// Gets a node for an atomic cmpxchg op. There are two
1402 /// valid Opcodes. ISD::ATOMIC_CMO_SWAP produces the value loaded and a
1403 /// chain result. ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS produces the value loaded,
1404 /// a success flag (initially i1), and a chain.
1405 LLVM_ABI SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1406 SDVTList VTs, SDValue Chain, SDValue Ptr,
1407 SDValue Cmp, SDValue Swp,
1408 MachineMemOperand *MMO);
1409
1410 /// Gets a node for an atomic op, produces result (if relevant)
1411 /// and chain and takes 2 operands.
1412 LLVM_ABI SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1413 SDValue Chain, SDValue Ptr, SDValue Val,
1414 MachineMemOperand *MMO);
1415
1416 /// Gets a node for an atomic op, produces result and chain and takes N
1417 /// operands.
1418 LLVM_ABI SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1420 MachineMemOperand *MMO,
1422
1424 EVT MemVT, EVT VT, SDValue Chain, SDValue Ptr,
1425 MachineMemOperand *MMO);
1426
1427 /// Creates a MemIntrinsicNode that may produce a
1428 /// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
1429 /// INTRINSIC_W_CHAIN, or a target-specific memory-referencing opcode
1430 // (see `SelectionDAGTargetInfo::isTargetMemoryOpcode`).
1432 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1433 EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment,
1437 const AAMDNodes &AAInfo = AAMDNodes());
1438
1440 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1441 EVT MemVT, MachinePointerInfo PtrInfo,
1442 MaybeAlign Alignment = std::nullopt,
1446 const AAMDNodes &AAInfo = AAMDNodes()) {
1447 // Ensure that codegen never sees alignment 0
1448 return getMemIntrinsicNode(Opcode, dl, VTList, Ops, MemVT, PtrInfo,
1449 Alignment.value_or(getEVTAlign(MemVT)), Flags,
1450 Size, AAInfo);
1451 }
1452
1453 LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl,
1455 EVT MemVT, MachineMemOperand *MMO);
1456
1457 /// getMemIntrinsicNode - Creates a MemIntrinsicNode with multiple MMOs.
1458 LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl,
1460 EVT MemVT,
1462
1463 /// Creates a LifetimeSDNode that starts (`IsStart==true`) or ends
1464 /// (`IsStart==false`) the lifetime of the `FrameIndex`.
1465 LLVM_ABI SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain,
1466 int FrameIndex);
1467
1468 /// Creates a PseudoProbeSDNode with function GUID `Guid` and
1469 /// the index of the block `Index` it is probing, as well as the attributes
1470 /// `attr` of the probe.
1472 uint64_t Guid, uint64_t Index,
1473 uint32_t Attr);
1474
1475 /// Create a MERGE_VALUES node from the given operands.
1477
1478 /// Return poison values for each of \p ResultTypes, substituting \p Chain
1479 /// for any result of type MVT::Other, merged into a single MERGE_VALUES
1480 /// node. Used to salvage a chain when an operation cannot be lowered due
1481 /// to an error, and the program will be discarded.
1483 const SDLoc &dl);
1484
1485 /// Loads are not normal binary operators: their result type is not
1486 /// determined by their operands, and they produce a value AND a token chain.
1487 ///
1488 /// This function will set the MOLoad flag on MMOFlags, but you can set it if
1489 /// you want. The MOStore flag must not be set.
1491 getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1492 MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(),
1494 const MMOMetadata &Metadata = MMOMetadata());
1495 LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1496 MachineMemOperand *MMO);
1498 getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1499 SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT,
1500 MaybeAlign Alignment = MaybeAlign(),
1502 const MMOMetadata &Metadata = MMOMetadata());
1503 LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1504 SDValue Chain, SDValue Ptr, EVT MemVT,
1505 MachineMemOperand *MMO);
1506 LLVM_ABI SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl,
1511 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1512 MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment,
1514 const MMOMetadata &Metadata = MMOMetadata());
1515 inline SDValue
1517 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1518 MachinePointerInfo PtrInfo, EVT MemVT,
1519 MaybeAlign Alignment = MaybeAlign(),
1521 const MMOMetadata &Metadata = MMOMetadata()) {
1522 // Ensures that codegen never sees a None Alignment.
1523 return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT,
1524 Alignment.value_or(getEVTAlign(MemVT)), MMOFlags, Metadata);
1525 }
1527 EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1528 SDValue Offset, EVT MemVT, MachineMemOperand *MMO);
1529
1530 /// Helper function to build ISD::STORE nodes.
1531 ///
1532 /// This function will set the MOStore flag on MMOFlags, but you can set it if
1533 /// you want. The MOLoad and MOInvariant flags must not be set.
1534
1536 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1537 MachinePointerInfo PtrInfo, Align Alignment,
1539 const MMOMetadata &Metadata = MMOMetadata());
1540 inline SDValue
1541 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1542 MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(),
1544 const MMOMetadata &Metadata = MMOMetadata()) {
1545 return getStore(Chain, dl, Val, Ptr, PtrInfo,
1546 Alignment.value_or(getEVTAlign(Val.getValueType())),
1547 MMOFlags, Metadata);
1548 }
1549 LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1550 SDValue Ptr, MachineMemOperand *MMO);
1552 SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset,
1553 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1555 const MMOMetadata &Metadata = MMOMetadata());
1557 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1558 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1560 const MMOMetadata &Metadata = MMOMetadata());
1561 LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1562 SDValue Ptr, SDValue Offset, EVT SVT,
1563 MachineMemOperand *MMO);
1564
1565 inline SDValue
1566 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1567 MachinePointerInfo PtrInfo, EVT SVT,
1568 MaybeAlign Alignment = MaybeAlign(),
1570 const MMOMetadata &Metadata = MMOMetadata()) {
1571 return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT,
1572 Alignment.value_or(getEVTAlign(SVT)), MMOFlags,
1573 Metadata);
1574 }
1575 LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1576 SDValue Ptr, EVT SVT, MachineMemOperand *MMO);
1577 LLVM_ABI SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl,
1580 LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1581 SDValue Ptr, SDValue Offset, EVT SVT,
1583 bool IsTruncating = false);
1584
1586 EVT VT, const SDLoc &dl, SDValue Chain,
1587 SDValue Ptr, SDValue Offset, SDValue Mask,
1588 SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT,
1589 Align Alignment, MachineMemOperand::Flags MMOFlags,
1590 const AAMDNodes &AAInfo,
1591 const MDNode *Ranges = nullptr,
1592 bool IsExpanding = false);
1593 inline SDValue
1595 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1596 SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT,
1597 MaybeAlign Alignment = MaybeAlign(),
1599 const AAMDNodes &AAInfo = AAMDNodes(),
1600 const MDNode *Ranges = nullptr, bool IsExpanding = false) {
1601 // Ensures that codegen never sees a None Alignment.
1602 return getLoadVP(AM, ExtType, VT, dl, Chain, Ptr, Offset, Mask, EVL,
1603 PtrInfo, MemVT, Alignment.value_or(getEVTAlign(MemVT)),
1604 MMOFlags, AAInfo, Ranges, IsExpanding);
1605 }
1607 EVT VT, const SDLoc &dl, SDValue Chain,
1608 SDValue Ptr, SDValue Offset, SDValue Mask,
1609 SDValue EVL, EVT MemVT, MachineMemOperand *MMO,
1610 bool IsExpanding = false);
1611 LLVM_ABI SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain,
1612 SDValue Ptr, SDValue Mask, SDValue EVL,
1613 MachinePointerInfo PtrInfo, MaybeAlign Alignment,
1614 MachineMemOperand::Flags MMOFlags,
1615 const AAMDNodes &AAInfo,
1616 const MDNode *Ranges = nullptr,
1617 bool IsExpanding = false);
1618 LLVM_ABI SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain,
1619 SDValue Ptr, SDValue Mask, SDValue EVL,
1620 MachineMemOperand *MMO, bool IsExpanding = false);
1622 ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1623 SDValue Ptr, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo,
1624 EVT MemVT, MaybeAlign Alignment, MachineMemOperand::Flags MMOFlags,
1625 const AAMDNodes &AAInfo, bool IsExpanding = false);
1627 EVT VT, SDValue Chain, SDValue Ptr,
1628 SDValue Mask, SDValue EVL, EVT MemVT,
1629 MachineMemOperand *MMO,
1630 bool IsExpanding = false);
1631 LLVM_ABI SDValue getStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1632 SDValue Ptr, SDValue Offset, SDValue Mask,
1633 SDValue EVL, EVT MemVT, MachineMemOperand *MMO,
1634 ISD::MemIndexedMode AM, bool IsTruncating = false,
1635 bool IsCompressing = false);
1636 LLVM_ABI SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1637 SDValue Ptr, SDValue Mask, SDValue EVL,
1638 MachinePointerInfo PtrInfo, EVT SVT,
1639 Align Alignment,
1640 MachineMemOperand::Flags MMOFlags,
1641 const AAMDNodes &AAInfo,
1642 bool IsCompressing = false);
1643 LLVM_ABI SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1644 SDValue Ptr, SDValue Mask, SDValue EVL,
1645 EVT SVT, MachineMemOperand *MMO,
1646 bool IsCompressing = false);
1647
1649 ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &DL,
1650 SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Stride, SDValue Mask,
1651 SDValue EVL, EVT MemVT, MachineMemOperand *MMO, bool IsExpanding = false);
1653 SDValue Ptr, SDValue Stride, SDValue Mask,
1654 SDValue EVL, MachineMemOperand *MMO,
1655 bool IsExpanding = false);
1657 const SDLoc &DL, EVT VT, SDValue Chain,
1658 SDValue Ptr, SDValue Stride,
1659 SDValue Mask, SDValue EVL, EVT MemVT,
1660 MachineMemOperand *MMO,
1661 bool IsExpanding = false);
1663 SDValue Val, SDValue Ptr, SDValue Offset,
1664 SDValue Stride, SDValue Mask, SDValue EVL,
1665 EVT MemVT, MachineMemOperand *MMO,
1667 bool IsTruncating = false,
1668 bool IsCompressing = false);
1669
1670 LLVM_ABI SDValue getGatherVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1672 ISD::MemIndexType IndexType);
1673 LLVM_ABI SDValue getScatterVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1675 ISD::MemIndexType IndexType);
1676
1677 LLVM_ABI SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain,
1679 SDValue Src0, EVT MemVT,
1681 ISD::LoadExtType, bool IsExpanding = false);
1685 LLVM_ABI SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1687 EVT MemVT, MachineMemOperand *MMO,
1689 bool IsTruncating = false,
1690 bool IsCompressing = false);
1691 LLVM_ABI SDValue getIndexedMaskedStore(SDValue OrigStore, const SDLoc &dl,
1694 LLVM_ABI SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1696 MachineMemOperand *MMO,
1697 ISD::MemIndexType IndexType,
1698 ISD::LoadExtType ExtTy);
1699 LLVM_ABI SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1701 MachineMemOperand *MMO,
1702 ISD::MemIndexType IndexType,
1703 bool IsTruncating = false);
1704 LLVM_ABI SDValue getMaskedHistogram(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1706 MachineMemOperand *MMO,
1707 ISD::MemIndexType IndexType);
1708 LLVM_ABI SDValue getLoadFFVP(EVT VT, const SDLoc &DL, SDValue Chain,
1709 SDValue Ptr, SDValue Mask, SDValue EVL,
1710 MachineMemOperand *MMO);
1711
1712 LLVM_ABI SDValue getGetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr,
1713 EVT MemVT, MachineMemOperand *MMO);
1714 LLVM_ABI SDValue getSetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr,
1715 EVT MemVT, MachineMemOperand *MMO);
1716
1717 /// Construct a node to track a Value* through the backend.
1719
1720 /// Return an MDNodeSDNode which holds an MDNode.
1721 LLVM_ABI SDValue getMDNode(const MDNode *MD);
1722
1723 /// Return a bitcast using the SDLoc of the value operand, and casting to the
1724 /// provided type. Use getNode to set a custom SDLoc.
1726
1727 /// Return an AddrSpaceCastSDNode.
1728 LLVM_ABI SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr,
1729 unsigned SrcAS, unsigned DestAS,
1730 const SDNodeFlags Flags = SDNodeFlags());
1731
1732 /// Return a freeze using the SDLoc of the value operand.
1734
1735 /// Return a freeze of V if any of the demanded elts may be undef or poison.
1736 /// \p Kind can be used to selectively freeze poison and/or undef bits only.
1738 getFreeze(SDValue V, const APInt &DemandedElts,
1740
1741 /// Return an AssertAlignSDNode.
1743
1744 /// Swap N1 and N2 if Opcode is a commutative binary opcode
1745 /// and the canonical form expects the opposite order.
1746 LLVM_ABI void canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1,
1747 SDValue &N2) const;
1748
1749 /// Return the specified value casted to
1750 /// the target's desired shift amount type.
1752
1753 /// Expand the specified \c ISD::VAARG node as the Legalize pass would.
1755
1756 /// Expand the specified \c ISD::VACOPY node as the Legalize pass would.
1758
1759 /// Return a GlobalAddress of the function from the current module with
1760 /// name matching the given ExternalSymbol. Additionally can provide the
1761 /// matched function.
1762 /// Panic if the function doesn't exist.
1764 SDValue Op, Function **TargetFunction = nullptr);
1765
1766 /// *Mutate* the specified node in-place to have the
1767 /// specified operands. If the resultant node already exists in the DAG,
1768 /// this does not modify the specified node, instead it returns the node that
1769 /// already exists. If the resultant node does not exist in the DAG, the
1770 /// input node is returned. As a degenerate case, if you specify the same
1771 /// input operands as the node already has, the input node is returned.
1775 SDValue Op3);
1777 SDValue Op3, SDValue Op4);
1779 SDValue Op3, SDValue Op4, SDValue Op5);
1781
1782 /// Creates a new TokenFactor containing \p Vals. If \p Vals contains 64k
1783 /// values or more, move values into new TokenFactors in 64k-1 blocks, until
1784 /// the final TokenFactor has less than 64k operands.
1787
1788 /// *Mutate* the specified machine node's memory references to the provided
1789 /// list.
1792
1793 // Calculate divergence of node \p N based on its operands.
1795
1796 // Propagates the change in divergence to users
1798
1799 /// These are used for target selectors to *mutate* the
1800 /// specified node to have the specified return type, Target opcode, and
1801 /// operands. Note that target opcodes are stored as
1802 /// ~TargetOpcode in the node opcode field. The resultant node is returned.
1803 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT);
1804 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1805 SDValue Op1);
1806 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1807 SDValue Op1, SDValue Op2);
1808 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1809 SDValue Op1, SDValue Op2, SDValue Op3);
1810 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1812 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1813 EVT VT2);
1814 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1816 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1817 EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1818 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1819 EVT VT2, SDValue Op1, SDValue Op2);
1820 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, SDVTList VTs,
1822
1823 /// This *mutates* the specified node to have the specified
1824 /// return type, opcode, and operands.
1825 LLVM_ABI SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
1827
1828 /// Mutate the specified strict FP node to its non-strict equivalent,
1829 /// unlinking the node from its chain and dropping the metadata arguments.
1830 /// The node must be a strict FP node.
1832
1833 /// These are used for target selectors to create a new node
1834 /// with specified return type(s), MachineInstr opcode, and operands.
1835 ///
1836 /// Note that getMachineNode returns the resultant node. If there is already
1837 /// a node of the specified opcode and operands, it returns that node instead
1838 /// of the current one.
1839 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1840 EVT VT);
1841 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1842 EVT VT, SDValue Op1);
1843 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1844 EVT VT, SDValue Op1, SDValue Op2);
1845 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1846 EVT VT, SDValue Op1, SDValue Op2,
1847 SDValue Op3);
1848 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1850 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1851 EVT VT1, EVT VT2, SDValue Op1,
1852 SDValue Op2);
1853 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1854 EVT VT1, EVT VT2, SDValue Op1,
1855 SDValue Op2, SDValue Op3);
1856 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1857 EVT VT1, EVT VT2,
1859 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1860 EVT VT1, EVT VT2, EVT VT3, SDValue Op1,
1861 SDValue Op2);
1862 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1863 EVT VT1, EVT VT2, EVT VT3, SDValue Op1,
1864 SDValue Op2, SDValue Op3);
1865 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1866 EVT VT1, EVT VT2, EVT VT3,
1868 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1869 ArrayRef<EVT> ResultTys,
1871 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1873
1874 /// A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
1875 LLVM_ABI SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1876 SDValue Operand);
1877
1878 /// A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
1879 LLVM_ABI SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1880 SDValue Operand, SDValue Subreg);
1881
1882 /// Get the specified node if it's already available, or else return NULL.
1883 LLVM_ABI SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1885 const SDNodeFlags Flags,
1886 bool AllowCommute = false);
1887 LLVM_ABI SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1889 bool AllowCommute = false);
1890
1891 /// Check if a node exists without modifying its flags.
1892 LLVM_ABI bool doesNodeExist(unsigned Opcode, SDVTList VTList,
1894
1895 /// Creates a SDDbgValue node.
1897 SDNode *N, unsigned R, bool IsIndirect,
1898 const DebugLoc &DL, unsigned O);
1899
1900 /// Creates a constant SDDbgValue node.
1902 const Value *C, const DebugLoc &DL,
1903 unsigned O);
1904
1905 /// Creates a FrameIndex SDDbgValue node.
1907 DIExpression *Expr, unsigned FI,
1908 bool IsIndirect,
1909 const DebugLoc &DL, unsigned O);
1910
1911 /// Creates a FrameIndex SDDbgValue node.
1913 DIExpression *Expr, unsigned FI,
1914 ArrayRef<SDNode *> Dependencies,
1915 bool IsIndirect,
1916 const DebugLoc &DL, unsigned O);
1917
1918 /// Creates a VReg SDDbgValue node.
1920 Register VReg, bool IsIndirect,
1921 const DebugLoc &DL, unsigned O);
1922
1923 /// Creates a SDDbgValue node from a list of locations.
1926 ArrayRef<SDNode *> Dependencies,
1927 bool IsIndirect, const DebugLoc &DL,
1928 unsigned O, bool IsVariadic);
1929
1930 /// Creates a SDDbgLabel node.
1932 unsigned O);
1933
1934 /// Transfer debug values from one node to another, while optionally
1935 /// generating fragment expressions for split-up values. If \p InvalidateDbg
1936 /// is set, debug values are invalidated after they are transferred.
1938 unsigned OffsetInBits = 0,
1939 unsigned SizeInBits = 0,
1940 bool InvalidateDbg = true);
1941
1942 /// Remove the specified node from the system. If any of its
1943 /// operands then becomes dead, remove them as well. Inform UpdateListener
1944 /// for each node deleted.
1946
1947 /// This method deletes the unreachable nodes in the
1948 /// given list, and any nodes that become unreachable as a result.
1950
1951 /// Modify anything using 'From' to use 'To' instead.
1952 /// This can cause recursive merging of nodes in the DAG. Use the first
1953 /// version if 'From' is known to have a single result, use the second
1954 /// if you have two nodes with identical results (or if 'To' has a superset
1955 /// of the results of 'From'), use the third otherwise.
1956 ///
1957 /// These methods all take an optional UpdateListener, which (if not null) is
1958 /// informed about nodes that are deleted and modified due to recursive
1959 /// changes in the dag.
1960 ///
1961 /// These functions only replace all existing uses. It's possible that as
1962 /// these replacements are being performed, CSE may cause the From node
1963 /// to be given new uses. These new uses of From are left in place, and
1964 /// not automatically transferred to To.
1965 ///
1967 LLVM_ABI void ReplaceAllUsesWith(SDNode *From, SDNode *To);
1968 LLVM_ABI void ReplaceAllUsesWith(SDNode *From, const SDValue *To);
1969
1970 /// Replace any uses of From with To, leaving
1971 /// uses of other values produced by From.getNode() alone.
1973
1974 /// Like ReplaceAllUsesOfValueWith, but for multiple values at once.
1975 /// This correctly handles the case where
1976 /// there is an overlap between the From values and the To values.
1978 const SDValue *To, unsigned Num);
1979
1980 /// If an existing load has uses of its chain, create a token factor node with
1981 /// that chain and the new memory node's chain and update users of the old
1982 /// chain to the token factor. This ensures that the new memory node will have
1983 /// the same relative memory dependency position as the old load. Returns the
1984 /// new merged load chain.
1986 SDValue NewMemOpChain);
1987
1988 /// If an existing load has uses of its chain, create a token factor node with
1989 /// that chain and the new memory node's chain and update users of the old
1990 /// chain to the token factor. This ensures that the new memory node will have
1991 /// the same relative memory dependency position as the old load. Returns the
1992 /// new merged load chain.
1994 SDValue NewMemOp);
1995
1996 /// Get all the nodes in their topological order without modifying any states.
1998 SmallVectorImpl<const SDNode *> &SortedNodes) const;
1999
2000 /// Topological-sort the AllNodes list and a
2001 /// assign a unique node id for each node in the DAG based on their
2002 /// topological order. Returns the number of nodes.
2004
2005 /// Move node N in the AllNodes list to be immediately
2006 /// before the given iterator Position. This may be used to update the
2007 /// topological ordering when the list of nodes is modified.
2009 AllNodes.insert(Position, AllNodes.remove(N));
2010 }
2011
2012 /// Add a dbg_value SDNode. If SD is non-null that means the
2013 /// value is produced by SD.
2014 LLVM_ABI void AddDbgValue(SDDbgValue *DB, bool isParameter);
2015
2016 /// Add a dbg_label SDNode.
2018
2019 /// Get the debug values which reference the given SDNode.
2021 return DbgInfo->getSDDbgValues(SD);
2022 }
2023
2024public:
2025 /// Return true if there are any SDDbgValue nodes associated
2026 /// with this SelectionDAG.
2027 bool hasDebugValues() const { return !DbgInfo->empty(); }
2028
2029 SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); }
2030 SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); }
2031
2033 return DbgInfo->ByvalParmDbgBegin();
2034 }
2036 return DbgInfo->ByvalParmDbgEnd();
2037 }
2038
2040 return DbgInfo->DbgLabelBegin();
2041 }
2043 return DbgInfo->DbgLabelEnd();
2044 }
2045
2046 /// To be invoked on an SDNode that is slated to be erased. This
2047 /// function mirrors \c llvm::salvageDebugInfo.
2049
2050 /// Dump the textual format of this DAG. Nodes are not sorted.
2051 /// Note that we overload it instead of using default value so that it is
2052 /// convenient to be called from debuggers.
2053 LLVM_ABI void dump() const;
2054
2055 /// Dump the textual format of this DAG. Print nodes in sorted orders if \p
2056 /// Sorted is true.
2057 LLVM_ABI void dump(bool Sorted) const;
2058
2059 /// In most cases this function returns the ABI alignment for a given type,
2060 /// except for illegal vector types where the alignment exceeds that of the
2061 /// stack. In such cases we attempt to break the vector down to a legal type
2062 /// and return the ABI alignment for that instead.
2063 LLVM_ABI Align getReducedAlign(EVT VT, bool UseABI);
2064
2065 /// Create a stack temporary based on the size in bytes and the alignment
2067
2068 /// Create a stack temporary, suitable for holding the specified value type.
2069 /// If minAlign is specified, the slot size will have at least that alignment.
2070 LLVM_ABI SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
2071
2072 /// Create a stack temporary suitable for holding either of the specified
2073 /// value types.
2075
2076 /// Emit a store/load combination to the stack. This stores
2077 /// SrcOp to a stack slot of type SlotVT, truncating it if needed. It then
2078 /// does a load from the stack slot to DestVT, extending it if needed. The
2079 /// resultant code need not be legal.
2081 const SDLoc &DL, SDValue Chain);
2082
2083 LLVM_ABI SDValue FoldSymbolOffset(unsigned Opcode, EVT VT,
2084 const GlobalAddressSDNode *GA,
2085 const SDNode *N2);
2086
2087 LLVM_ABI SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
2089 SDNodeFlags Flags = SDNodeFlags());
2090
2091 /// Constant fold a node with multiple results, returning a MERGE_VALUES of
2092 /// the folded results on success.
2093 LLVM_ABI SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
2094 SDVTList VTList,
2096 SDNodeFlags Flags = SDNodeFlags());
2097
2098 /// Fold floating-point operations when all operands are constants and/or
2099 /// undefined.
2100 LLVM_ABI SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT,
2102
2103 /// Fold BUILD_VECTOR of constants/undefs to the destination type
2104 /// BUILD_VECTOR of constants/undefs elements.
2106 const SDLoc &DL, EVT DstEltVT);
2107
2108 /// Constant fold a setcc to true or false.
2110 const SDLoc &dl, SDNodeFlags Flags = {});
2111
2112 /// Return true if the sign bit of Op is known to be zero.
2113 /// We use this predicate to simplify operations downstream.
2114 LLVM_ABI bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
2115
2116 /// Return true if the sign bit of Op is known to be zero, for a
2117 /// floating-point value.
2118 LLVM_ABI bool SignBitIsZeroFP(SDValue Op, unsigned Depth = 0) const;
2119
2120 /// Return true if 'Op & Mask' is known to be zero. We
2121 /// use this predicate to simplify operations downstream. Op and Mask are
2122 /// known to be the same type.
2123 LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
2124 unsigned Depth = 0) const;
2125
2126 /// Return true if 'Op & Mask' is known to be zero in DemandedElts. We
2127 /// use this predicate to simplify operations downstream. Op and Mask are
2128 /// known to be the same type.
2129 LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
2130 const APInt &DemandedElts,
2131 unsigned Depth = 0) const;
2132
2133 /// Return true if 'Op' is known to be zero in DemandedElts. We
2134 /// use this predicate to simplify operations downstream.
2135 LLVM_ABI bool MaskedVectorIsZero(SDValue Op, const APInt &DemandedElts,
2136 unsigned Depth = 0) const;
2137
2138 /// Return true if '(Op & Mask) == Mask'.
2139 /// Op and Mask are known to be the same type.
2140 LLVM_ABI bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask,
2141 unsigned Depth = 0) const;
2142
2143 /// For each demanded element of a vector, see if it is known to be zero.
2145 const APInt &DemandedElts,
2146 unsigned Depth = 0) const;
2147
2148 /// Determine which bits of Op are known to be either zero or one and return
2149 /// them in Known. For vectors, the known bits are those that are shared by
2150 /// every vector element.
2151 /// Targets can implement the computeKnownBitsForTargetNode method in the
2152 /// TargetLowering class to allow target nodes to be understood.
2153 LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth = 0) const;
2154
2155 /// Determine which bits of Op are known to be either zero or one and return
2156 /// them in Known. The DemandedElts argument allows us to only collect the
2157 /// known bits that are shared by the requested vector elements.
2158 /// Targets can implement the computeKnownBitsForTargetNode method in the
2159 /// TargetLowering class to allow target nodes to be understood.
2160 LLVM_ABI KnownBits computeKnownBits(SDValue Op, const APInt &DemandedElts,
2161 unsigned Depth = 0) const;
2162
2163 /// Determine the possible constant range of an integer or vector of integers.
2164 LLVM_ABI ConstantRange computeConstantRange(SDValue Op, bool ForSigned,
2165 unsigned Depth = 0) const;
2166
2167 /// Determine the possible constant range of an integer or vector of integers.
2168 /// The DemandedElts argument allows us to only collect the known ranges that
2169 /// are shared by the requested vector elements.
2171 const APInt &DemandedElts,
2172 bool ForSigned,
2173 unsigned Depth = 0) const;
2174
2175 /// Combine constant ranges from computeConstantRange() and
2176 /// computeKnownBits().
2178 SDValue Op, bool ForSigned, unsigned Depth = 0) const;
2179
2180 /// Combine constant ranges from computeConstantRange() and
2181 /// computeKnownBits(). The DemandedElts argument allows us to only collect
2182 /// the known ranges that are shared by the requested vector elements.
2184 SDValue Op, const APInt &DemandedElts, bool ForSigned,
2185 unsigned Depth = 0) const;
2186
2187 /// Used to represent the possible overflow behavior of an operation.
2188 /// Never: the operation cannot overflow.
2189 /// Always: the operation will always overflow.
2190 /// Sometime: the operation may or may not overflow.
2196
2197 /// Determine if the result of the signed addition of 2 nodes can overflow.
2199 SDValue N1) const;
2200
2201 /// Determine if the result of the unsigned addition of 2 nodes can overflow.
2203 SDValue N1) const;
2204
2205 /// Determine if the result of the addition of 2 nodes can overflow.
2207 SDValue N1) const {
2208 return IsSigned ? computeOverflowForSignedAdd(N0, N1)
2210 }
2211
2212 /// Determine if the result of the addition of 2 nodes can never overflow.
2213 bool willNotOverflowAdd(bool IsSigned, SDValue N0, SDValue N1) const {
2214 return computeOverflowForAdd(IsSigned, N0, N1) == OFK_Never;
2215 }
2216
2217 /// Determine if the result of the signed sub of 2 nodes can overflow.
2219 SDValue N1) const;
2220
2221 /// Determine if the result of the unsigned sub of 2 nodes can overflow.
2223 SDValue N1) const;
2224
2225 /// Determine if the result of the sub of 2 nodes can overflow.
2227 SDValue N1) const {
2228 return IsSigned ? computeOverflowForSignedSub(N0, N1)
2230 }
2231
2232 /// Determine if the result of the sub of 2 nodes can never overflow.
2233 bool willNotOverflowSub(bool IsSigned, SDValue N0, SDValue N1) const {
2234 return computeOverflowForSub(IsSigned, N0, N1) == OFK_Never;
2235 }
2236
2237 /// Determine if the result of the signed mul of 2 nodes can overflow.
2239 SDValue N1) const;
2240
2241 /// Determine if the result of the unsigned mul of 2 nodes can overflow.
2243 SDValue N1) const;
2244
2245 /// Determine if the result of the mul of 2 nodes can overflow.
2247 SDValue N1) const {
2248 return IsSigned ? computeOverflowForSignedMul(N0, N1)
2250 }
2251
2252 /// Determine if the result of the mul of 2 nodes can never overflow.
2253 bool willNotOverflowMul(bool IsSigned, SDValue N0, SDValue N1) const {
2254 return computeOverflowForMul(IsSigned, N0, N1) == OFK_Never;
2255 }
2256
2257 /// Returns true if \p V is an identity element of Opc with Flags.
2258 /// When OperandNo is 0, it checks that V is a left identity. Otherwise, it
2259 /// checks that V is a right identity.
2260 LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V,
2261 unsigned OperandNo, unsigned Depth = 0) const;
2262
2263 /// Returns true if the demanded vector elements of \p V is an identity
2264 /// element of Opc with Flags. When OperandNo is 0, it checks that V is a left
2265 /// identity. Otherwise, it checks that V is a right identity.
2266 LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V,
2267 const APInt &DemandedElts, unsigned OperandNo,
2268 unsigned Depth = 0) const;
2269
2270 /// Test if the given value is known to have exactly one bit set. This differs
2271 /// from computeKnownBits in that it doesn't necessarily determine which bit
2272 /// is set. If 'OrZero' is set, then return true if the given value is either
2273 /// a power of two or zero.
2274 LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, bool OrZero = false,
2275 unsigned Depth = 0) const;
2276
2277 /// Test if the given value is known to have exactly one bit set. This differs
2278 /// from computeKnownBits in that it doesn't necessarily determine which bit
2279 /// is set. The DemandedElts argument allows us to only collect the minimum
2280 /// sign bits of the requested vector elements. If 'OrZero' is set, then
2281 /// return true if the given value is either a power of two or zero.
2282 LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, const APInt &DemandedElts,
2283 bool OrZero = false,
2284 unsigned Depth = 0) const;
2285
2286 /// Test if the given _fp_ value is known to be an integer power-of-2, either
2287 /// positive or negative.
2288 LLVM_ABI bool isKnownToBeAPowerOfTwoFP(SDValue Val, unsigned Depth = 0) const;
2289
2290 /// Return the number of times the sign bit of the register is replicated into
2291 /// the other bits. We know that at least 1 bit is always equal to the sign
2292 /// bit (itself), but other cases can give us information. For example,
2293 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2294 /// to each other, so we return 3. Targets can implement the
2295 /// ComputeNumSignBitsForTarget method in the TargetLowering class to allow
2296 /// target nodes to be understood.
2297 LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
2298
2299 /// Return the number of times the sign bit of the register is replicated into
2300 /// the other bits. We know that at least 1 bit is always equal to the sign
2301 /// bit (itself), but other cases can give us information. For example,
2302 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2303 /// to each other, so we return 3. The DemandedElts argument allows
2304 /// us to only collect the minimum sign bits of the requested vector elements.
2305 /// Targets can implement the ComputeNumSignBitsForTarget method in the
2306 /// TargetLowering class to allow target nodes to be understood.
2307 LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
2308 unsigned Depth = 0) const;
2309
2310 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2311 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2312 /// Similar to the APInt::getSignificantBits function.
2313 /// Helper wrapper to ComputeNumSignBits.
2315 unsigned Depth = 0) const;
2316
2317 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2318 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2319 /// Similar to the APInt::getSignificantBits function.
2320 /// Helper wrapper to ComputeNumSignBits.
2322 const APInt &DemandedElts,
2323 unsigned Depth = 0) const;
2324
2325 /// Return true if this function can prove that \p Op is never poison
2326 /// and, \p Kind can be used to track poison and/or undef bits.
2329 unsigned Depth = 0) const;
2330
2331 /// Return true if this function can prove that \p Op is never poison
2332 /// and, \p Kind can be used to track poison and/or undef bits. The
2333 /// DemandedElts argument limits the check to the requested vector elements.
2335 SDValue Op, const APInt &DemandedElts,
2337 unsigned Depth = 0) const;
2338
2339 /// Return true if this function can prove that \p Op is never poison.
2344
2345 /// Return true if this function can prove that \p Op is never poison. The
2346 /// DemandedElts argument limits the check to the requested vector elements.
2347 bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts,
2348 unsigned Depth = 0) const {
2349 return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts,
2351 }
2352
2353 /// Return true if Op can create undef or poison from non-undef & non-poison
2354 /// operands. The DemandedElts argument limits the check to the requested
2355 /// vector elements.
2356 ///
2357 /// \p ConsiderFlags controls whether poison producing flags on the
2358 /// instruction are considered. This can be used to see if the instruction
2359 /// could still introduce undef or poison even without poison generating flags
2360 /// which might be on the instruction. (i.e. could the result of
2361 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2362 LLVM_ABI bool
2363 canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
2365 bool ConsiderFlags = true, unsigned Depth = 0) const;
2366
2367 /// Return true if Op can create undef or poison from non-undef & non-poison
2368 /// operands.
2369 ///
2370 /// \p ConsiderFlags controls whether poison producing flags on the
2371 /// instruction are considered. This can be used to see if the instruction
2372 /// could still introduce undef or poison even without poison generating flags
2373 /// which might be on the instruction. (i.e. could the result of
2374 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2375 LLVM_ABI bool
2378 bool ConsiderFlags = true, unsigned Depth = 0) const;
2379
2380 /// Return true if the specified operand is an ISD::OR or ISD::XOR node
2381 /// that can be treated as an ISD::ADD node.
2382 /// or(x,y) == add(x,y) iff haveNoCommonBitsSet(x,y)
2383 /// xor(x,y) == add(x,y) iff isMinSignedConstant(y) && !NoWrap
2384 /// If \p NoWrap is true, this will not match ISD::XOR.
2385 LLVM_ABI bool isADDLike(SDValue Op, bool NoWrap = false) const;
2386
2387 /// Return true if the specified operand is an ISD::ADD with a ConstantSDNode
2388 /// on the right-hand side, or if it is an ISD::OR with a ConstantSDNode that
2389 /// is guaranteed to have the same semantics as an ADD. This handles the
2390 /// equivalence:
2391 /// X|Cst == X+Cst iff X&Cst = 0.
2393
2394 /// Determine floating-point class information about \p Op. For vectors, the
2395 /// known FP classes are those shared by every demanded vector element.
2396 /// \p InterestedClasses is a hint for which FP classes we care about;
2397 /// the implementation may bail out early if it can determine that
2398 /// none of the interested classes are possible.
2400 FPClassTest InterestedClasses,
2401 unsigned Depth = 0) const;
2402
2403 /// Determine floating-point class information about \p Op. The
2404 /// DemandedElts argument allows us to only collect the known FP classes
2405 /// that are shared by the requested vector elements.
2406 /// \p InterestedClasses is a hint for which FP classes we care about.
2408 const APInt &DemandedElts,
2409 FPClassTest InterestedClasses,
2410 unsigned Depth = 0) const;
2411
2412 /// Test whether the given SDValue (or all elements of it, if it is a
2413 /// vector) is known to never be NaN in \p DemandedElts. If \p SNaN is true,
2414 /// returns if \p Op is known to never be a signaling NaN (it may still be a
2415 /// qNaN).
2416 LLVM_ABI bool isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
2417 bool SNaN = false, unsigned Depth = 0) const;
2418
2419 /// Test whether the given SDValue (or all elements of it, if it is a
2420 /// vector) is known to never be NaN. If \p SNaN is true, returns if \p Op is
2421 /// known to never be a signaling NaN (it may still be a qNaN).
2422 LLVM_ABI bool isKnownNeverNaN(SDValue Op, bool SNaN = false,
2423 unsigned Depth = 0) const;
2424
2425 /// \returns true if \p Op is known to never be a signaling NaN in \p
2426 /// DemandedElts.
2427 bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts,
2428 unsigned Depth = 0) const {
2429 return isKnownNeverNaN(Op, DemandedElts, true, Depth);
2430 }
2431
2432 /// \returns true if \p Op is known to never be a signaling NaN.
2433 bool isKnownNeverSNaN(SDValue Op, unsigned Depth = 0) const {
2434 return isKnownNeverNaN(Op, true, Depth);
2435 }
2436
2437 /// Test whether the given floating point SDValue (or all elements of it, if
2438 /// it is a vector) is known to never be interpretable as zero in \p
2439 /// DemandedElts.
2440 LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, const APInt &DemandedElts,
2441 unsigned Depth = 0) const;
2442
2443 /// Test whether the given floating point SDValue (or all elements of it, if
2444 /// it is a vector) is known to never be interpretable as zero.
2445 LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, unsigned Depth = 0) const;
2446
2447 /// Test whether the given SDValue is known to contain non-zero value(s).
2448 LLVM_ABI bool isKnownNeverZero(SDValue Op, unsigned Depth = 0) const;
2449
2450 /// Test whether the given SDValue is known to contain non-zero value(s).
2451 /// The DemandedElts argument limits the check to the requested vector
2452 /// elements.
2453 LLVM_ABI bool isKnownNeverZero(SDValue Op, const APInt &DemandedElts,
2454 unsigned Depth = 0) const;
2455
2456 /// Test whether the given float value is known to be positive. +0.0, +inf and
2457 /// +nan are considered positive, -0.0, -inf and -nan are not.
2459
2460 /// Check if the user of \p Use produces the same result regardless of the
2461 /// sign of a zero in the used float operand.
2462 LLVM_ABI bool canIgnoreSignBitOfZero(const SDUse &Use) const;
2463
2464 /// Check if all uses of \p Op (limited to checking two for compile-time
2465 /// performance) are insensitive to signed zeros. An nsz flag on \p Op does
2466 /// not necessarily permit this.
2468
2469 /// Test whether two SDValues are known to compare equal. This
2470 /// is true if they are the same value, or if one is negative zero and the
2471 /// other positive zero.
2472 LLVM_ABI bool isEqualTo(SDValue A, SDValue B) const;
2473
2474 /// Return true if A and B have no common bits set. As an example, this can
2475 /// allow an 'add' to be transformed into an 'or'.
2477
2478 /// Test whether \p V has a splatted value for all the demanded elements.
2479 ///
2480 /// On success \p UndefElts will indicate the elements that have UNDEF
2481 /// values instead of the splat value, this is only guaranteed to be correct
2482 /// for \p DemandedElts.
2483 ///
2484 /// NOTE: The function will return true for a demanded splat of UNDEF values.
2485 LLVM_ABI bool isSplatValue(SDValue V, const APInt &DemandedElts,
2486 APInt &UndefElts, unsigned Depth = 0) const;
2487
2488 /// Test whether \p V has a splatted value.
2489 LLVM_ABI bool isSplatValue(SDValue V, bool AllowUndefs = false) const;
2490
2491 /// If V is a splatted value, return the source vector and its splat index.
2492 LLVM_ABI SDValue getSplatSourceVector(SDValue V, int &SplatIndex);
2493
2494 /// If V is a splat vector, return its scalar source operand by extracting
2495 /// that element from the source vector. If LegalTypes is true, this method
2496 /// may only return a legally-typed splat value. If it cannot legalize the
2497 /// splatted value it will return SDValue().
2498 LLVM_ABI SDValue getSplatValue(SDValue V, bool LegalTypes = false);
2499
2500 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2501 /// element bit-width of the shift node, return the valid constant range.
2502 LLVM_ABI std::optional<ConstantRange>
2503 getValidShiftAmountRange(SDValue V, const APInt &DemandedElts,
2504 unsigned Depth) const;
2505
2506 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2507 /// that is less than the element bit-width of the shift node, return it.
2508 LLVM_ABI std::optional<unsigned>
2509 getValidShiftAmount(SDValue V, const APInt &DemandedElts,
2510 unsigned Depth = 0) const;
2511
2512 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2513 /// that is less than the element bit-width of the shift node, return it.
2514 LLVM_ABI std::optional<unsigned>
2515 getValidShiftAmount(SDValue V, unsigned Depth = 0) const;
2516
2517 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2518 /// element bit-width of the shift node, return the minimum possible value.
2519 LLVM_ABI std::optional<unsigned>
2520 getValidMinimumShiftAmount(SDValue V, const APInt &DemandedElts,
2521 unsigned Depth = 0) const;
2522
2523 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2524 /// element bit-width of the shift node, return the minimum possible value.
2525 LLVM_ABI std::optional<unsigned>
2526 getValidMinimumShiftAmount(SDValue V, unsigned Depth = 0) const;
2527
2528 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2529 /// element bit-width of the shift node, return the maximum possible value.
2530 LLVM_ABI std::optional<unsigned>
2531 getValidMaximumShiftAmount(SDValue V, const APInt &DemandedElts,
2532 unsigned Depth = 0) const;
2533
2534 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2535 /// element bit-width of the shift node, return the maximum possible value.
2536 LLVM_ABI std::optional<unsigned>
2537 getValidMaximumShiftAmount(SDValue V, unsigned Depth = 0) const;
2538
2539 /// Match a binop + shuffle pyramid that represents a horizontal reduction
2540 /// over the elements of a vector starting from the EXTRACT_VECTOR_ELT node /p
2541 /// Extract. The reduction must use one of the opcodes listed in /p
2542 /// CandidateBinOps and on success /p BinOp will contain the matching opcode.
2543 /// Returns the vector that is being reduced on, or SDValue() if a reduction
2544 /// was not matched. If \p AllowPartials is set then in the case of a
2545 /// reduction pattern that only matches the first few stages, the extracted
2546 /// subvector of the start of the reduction is returned.
2548 ArrayRef<ISD::NodeType> CandidateBinOps,
2549 bool AllowPartials = false);
2550
2551 /// Utility function used by legalize and lowering to
2552 /// "unroll" a vector operation by splitting out the scalars and operating
2553 /// on each element individually. If the ResNE is 0, fully unroll the vector
2554 /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
2555 /// If the ResNE is greater than the width of the vector op, unroll the
2556 /// vector op and fill the end of the resulting vector with UNDEFS.
2557 LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
2558
2559 /// Like UnrollVectorOp(), but for the [US](ADD|SUB|MUL)O family of opcodes.
2560 /// This is a separate function because those opcodes have two results.
2561 LLVM_ABI std::pair<SDValue, SDValue>
2562 UnrollVectorOverflowOp(SDNode *N, unsigned ResNE = 0);
2563
2564 /// Return true if loads are next to each other and can be
2565 /// merged. Check that both are nonvolatile and if LD is loading
2566 /// 'Bytes' bytes from a location that is 'Dist' units away from the
2567 /// location that the 'Base' load is loading from.
2569 TypeSize Bytes, int Dist) const;
2571 unsigned Bytes, int Dist) const {
2573 Dist);
2574 }
2575
2576 /// Return true if stores are next to each other and can be merged. Check that
2577 /// both are nonvolatile and if \p ST is storing \p Bytes bytes to a location
2578 /// that is \p Dist units away from the location that \p Base is storing to.
2581 TypeSize Bytes, int Dist) const;
2583 unsigned Bytes, int Dist) const {
2585 Dist);
2586 }
2587
2588 /// Infer alignment of a load / store address. Return std::nullopt if it
2589 /// cannot be inferred.
2591
2592 /// Split the scalar node with EXTRACT_ELEMENT using the provided VTs and
2593 /// return the low/high part.
2594 LLVM_ABI std::pair<SDValue, SDValue> SplitScalar(const SDValue &N,
2595 const SDLoc &DL,
2596 const EVT &LoVT,
2597 const EVT &HiVT);
2598
2599 /// Compute the VTs needed for the low/hi parts of a type
2600 /// which is split (or expanded) into two not necessarily identical pieces.
2601 LLVM_ABI std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const;
2602
2603 /// Compute the VTs needed for the low/hi parts of a type, dependent on an
2604 /// enveloping VT that has been split into two identical pieces. Sets the
2605 /// HisIsEmpty flag when hi type has zero storage size.
2606 LLVM_ABI std::pair<EVT, EVT> GetDependentSplitDestVTs(const EVT &VT,
2607 const EVT &EnvVT,
2608 bool *HiIsEmpty) const;
2609
2610 /// Split the vector with EXTRACT_SUBVECTOR using the provided
2611 /// VTs and return the low/high part.
2612 LLVM_ABI std::pair<SDValue, SDValue> SplitVector(const SDValue &N,
2613 const SDLoc &DL,
2614 const EVT &LoVT,
2615 const EVT &HiVT);
2616
2617 /// Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
2618 std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
2619 EVT LoVT, HiVT;
2620 std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
2621 return SplitVector(N, DL, LoVT, HiVT);
2622 }
2623
2624 /// Split the explicit vector length parameter of a VP operation.
2625 LLVM_ABI std::pair<SDValue, SDValue> SplitEVL(SDValue N, EVT VecVT,
2626 const SDLoc &DL);
2627
2628 /// Split the node's operand with EXTRACT_SUBVECTOR and
2629 /// return the low/high part.
2630 std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
2631 {
2632 return SplitVector(N->getOperand(OpNo), SDLoc(N));
2633 }
2634
2635 /// Widen the vector up to the next power of two using INSERT_SUBVECTOR.
2636 LLVM_ABI SDValue WidenVector(const SDValue &N, const SDLoc &DL);
2637
2638 /// Append the extracted elements from Start to Count out of the vector Op in
2639 /// Args. If Count is 0, all of the elements will be extracted. The extracted
2640 /// elements will have type EVT if it is provided, and otherwise their type
2641 /// will be Op's element type.
2644 unsigned Start = 0, unsigned Count = 0,
2645 EVT EltVT = EVT());
2646
2647 /// Compute the default alignment value for the given type.
2648 LLVM_ABI Align getEVTAlign(EVT MemoryVT) const;
2649
2650 /// Test whether the given value is a constant int or similar node.
2651 LLVM_ABI bool
2653 bool AllowOpaques = true) const;
2654
2655 /// Test whether the given value is a constant FP or similar node.
2657
2658 /// \returns true if \p N is any kind of constant or build_vector of
2659 /// constants, int or float. If a vector, it may not necessarily be a splat.
2664
2665 /// Check if a value \op N is a constant using the target's BooleanContent for
2666 /// its type.
2667 LLVM_ABI std::optional<bool> isBoolConstant(SDValue N) const;
2668
2669 /// Set CallSiteInfo to be associated with Node.
2670 void addCallSiteInfo(const SDNode *Node, CallSiteInfo &&CallInfo) {
2671 SDEI[Node].CSInfo = std::move(CallInfo);
2672 }
2673 /// Return CallSiteInfo associated with Node, or a default if none exists.
2674 CallSiteInfo getCallSiteInfo(const SDNode *Node) {
2675 auto I = SDEI.find(Node);
2676 return I != SDEI.end() ? std::move(I->second).CSInfo : CallSiteInfo();
2677 }
2678 /// Set HeapAllocSite to be associated with Node.
2680 SDEI[Node].HeapAllocSite = MD;
2681 }
2682 /// Return HeapAllocSite associated with Node, or nullptr if none exists.
2684 auto I = SDEI.find(Node);
2685 return I != SDEI.end() ? I->second.HeapAllocSite : nullptr;
2686 }
2687 /// Set PCSections to be associated with Node.
2688 void addPCSections(const SDNode *Node, MDNode *MD) {
2689 SDEI[Node].PCSections = MD;
2690 }
2691 /// Set MMRAMetadata to be associated with Node.
2692 void addMMRAMetadata(const SDNode *Node, MDNode *MMRA) {
2693 SDEI[Node].MMRA = MMRA;
2694 }
2695 /// Return PCSections associated with Node, or nullptr if none exists.
2697 auto It = SDEI.find(Node);
2698 return It != SDEI.end() ? It->second.PCSections : nullptr;
2699 }
2700 /// Return the MMRA MDNode associated with Node, or nullptr if none
2701 /// exists.
2703 auto It = SDEI.find(Node);
2704 return It != SDEI.end() ? It->second.MMRA : nullptr;
2705 }
2706 /// Set CalledGlobal to be associated with Node.
2707 void addCalledGlobal(const SDNode *Node, const GlobalValue *GV,
2708 unsigned OpFlags) {
2709 SDEI[Node].CalledGlobal = {GV, OpFlags};
2710 }
2711 /// Return CalledGlobal associated with Node, or a nullopt if none exists.
2712 std::optional<CalledGlobalInfo> getCalledGlobal(const SDNode *Node) {
2713 auto I = SDEI.find(Node);
2714 return I != SDEI.end()
2715 ? std::make_optional(std::move(I->second).CalledGlobal)
2716 : std::nullopt;
2717 }
2718 /// Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
2719 void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) {
2720 if (NoMerge)
2721 SDEI[Node].NoMerge = NoMerge;
2722 }
2723 /// Return NoMerge info associated with Node.
2724 bool getNoMergeSiteInfo(const SDNode *Node) const {
2725 auto I = SDEI.find(Node);
2726 return I != SDEI.end() ? I->second.NoMerge : false;
2727 }
2728
2729 /// Copy extra info associated with one node to another.
2730 LLVM_ABI void copyExtraInfo(SDNode *From, SDNode *To);
2731
2732 /// Return the current function's default denormal handling kind for the given
2733 /// floating point type.
2735 return MF->getDenormalMode(VT.getFltSemantics());
2736 }
2737
2738 LLVM_ABI bool shouldOptForSize() const;
2739
2740 LLVM_ABI const BasicBlock *getBasicBlock() const;
2741
2742 /// Get the (commutative) identity element for the given opcode, if it exists.
2743 LLVM_ABI SDValue getIdentityElement(unsigned Opcode, const SDLoc &DL, EVT VT,
2744 SDNodeFlags Flags);
2745
2746 /// Get an expression that implements a partial multiply-subtract reduction.
2747 /// In practice this means that parts of the expression are negated, e.g.
2748 ///
2749 /// partial_reduce_fmls acc, lhs, rhs
2750 /// <=> partial_reduce_fmla acc, lhs, -rhs
2751 ///
2752 /// partial_reduce_umls acc, lhs, rhs
2753 /// <=> -partial_reduce_umla -acc, lhs, rhs
2755 SDValue Acc, SDValue LHS, SDValue RHS);
2756
2757 /// Some opcodes may create immediate undefined behavior when used with some
2758 /// values (integer division-by-zero for example). Therefore, these operations
2759 /// are not generally safe to move around or change.
2760 bool isSafeToSpeculativelyExecute(unsigned Opcode) const {
2761 switch (Opcode) {
2762 case ISD::SDIV:
2763 case ISD::SREM:
2764 case ISD::SDIVREM:
2765 case ISD::UDIV:
2766 case ISD::UREM:
2767 case ISD::UDIVREM:
2768 return false;
2769 default:
2770 return true;
2771 }
2772 }
2773
2774 /// Check if the provided node is save to speculatively executed given its
2775 /// current arguments. So, while `udiv` the opcode is not safe to
2776 /// speculatively execute, a given `udiv` node may be if the denominator is
2777 /// known nonzero.
2779 switch (N->getOpcode()) {
2780 case ISD::UDIV:
2781 return isKnownNeverZero(N->getOperand(1));
2782 default:
2783 return isSafeToSpeculativelyExecute(N->getOpcode());
2784 }
2785 }
2786
2787 LLVM_ABI SDValue makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
2788 SDValue InChain, SDNode *Node);
2789
2790 /// Returns the maximum runtime number of elements in VT if known, or 0
2791 /// otherwise.
2792 LLVM_ABI unsigned getMaxRuntimeNumElements(EVT VT) const;
2793
2794 /// Returns a vector constructed from the scalar values in order. The number
2795 /// of scalars must match the maximum runtime length of VT, but only the first
2796 /// actual runtime length scalars are included in the result.
2798 ArrayRef<SDValue> Scalars);
2799
2800private:
2801#ifndef NDEBUG
2802 void verifyNode(SDNode *N) const;
2803#endif
2804 void InsertNode(SDNode *N);
2805 bool RemoveNodeFromCSEMaps(SDNode *N);
2806 void AddModifiedNodeToCSEMaps(SDNode *N);
2807 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op,
2808 FoldingSetInsertToken &InsertToken);
2809 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
2810 FoldingSetInsertToken &InsertToken);
2811 SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops,
2812 FoldingSetInsertToken &InsertToken);
2813 SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc);
2814
2815 void DeleteNodeNotInCSEMaps(SDNode *N);
2816 void DeallocateNode(SDNode *N);
2817
2818 void allnodes_clear();
2819
2820 /// Look up the node specified by ID in CSEMap. If it exists, return it and
2821 /// clear \p InsertToken; otherwise return null and set \p InsertToken for a
2822 /// subsequent insert. This overload is for nodes other than Constant or
2823 /// ConstantFP, use the other one for those.
2824 SDNode *lookupNode(const SDNodeKey &Key, FoldingSetInsertToken &InsertToken);
2825
2826 /// Look up the node specified by ID in CSEMap. If it exists, return it and
2827 /// clear \p InsertToken; otherwise return null and set \p InsertToken for a
2828 /// subsequent insert. Performs additional processing for constant nodes.
2829 SDNode *lookupNode(const SDNodeKey &Key, const SDLoc &DL,
2830 FoldingSetInsertToken &InsertToken);
2831
2832 /// Maps to auto-CSE operations.
2833 std::vector<CondCodeSDNode*> CondCodeNodes;
2834
2835 std::vector<SDNode*> ValueTypeNodes;
2836 std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
2837 StringMap<SDNode*> ExternalSymbols;
2838
2839 std::map<std::pair<std::string, unsigned>, SDNode *> TargetExternalSymbols;
2841
2842 FlagInserter *Inserter = nullptr;
2843};
2844
2845template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
2847
2849 return nodes_iterator(G->allnodes_begin());
2850 }
2851
2853 return nodes_iterator(G->allnodes_end());
2854 }
2855};
2856
2857} // end namespace llvm
2858
2859#endif // LLVM_CODEGEN_SELECTIONDAG_H
return SDValue()
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
uint64_t uint64_t
constexpr LLT S1
AMDGPU Uniform Intrinsic Combine
MachineBasicBlock & MBB
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
This file defines the BumpPtrAllocator interface.
#define X(NUM, ENUM, NAME)
Definition ELF.h:665
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:211
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:702
@ CallSiteInfo
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file provides fallible floating-point folding operations with explicit rounding and denormal mod...
This file defines a hash set that can be used to remove duplication of nodes in a graph.
const AbstractManglingParser< Derived, Alloc >::OperatorInfo AbstractManglingParser< Derived, Alloc >::Ops[]
#define I(x, y, z)
Definition MD5.cpp:57
#define G(x, y, z)
Definition MD5.cpp:55
#define H(x, y, z)
Definition MD5.cpp:56
Register Reg
This file contains the declarations for metadata subclasses.
#define T
#define P(N)
SmallVector< MachineOperand, 4 > Cond
This file defines the SmallVector class.
static TableGen::Emitter::Opt Y("gen-skeleton-entry", EmitSkeleton, "Generate example skeleton entry")
static void removeOperands(MachineInstr &MI, unsigned i)
This file contains the UndefPoisonKind enum and helper functions.
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.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
size_t size() const
Get the array size.
Definition ArrayRef.h:141
LLVM Basic Block Representation.
Definition BasicBlock.h:62
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:1088
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:420
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:44
DWARF expression.
Base class for variables.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
Implements a dense probed hash-table based set.
Definition DenseSet.h:283
Insertion token: a failed lookup fills it in, the matching insert consumes it.
Definition FoldingSet.h:284
This class is used to gather all the unique data bits of a node.
Definition FoldingSet.h:162
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:76
Tracks which library functions to use for a particular subtarget or function.
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:1087
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.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Root of the metadata hierarchy.
Definition Metadata.h:65
Pass interface - Implemented by all 'passes'.
Definition Pass.h:97
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:20
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.
Represents a use of a SDNode.
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...
LLVM_ABI SDValue getElementCount(const SDLoc &DL, EVT VT, ElementCount EC)
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 getShiftAmountOperand(EVT LHSTy, SDValue Op)
Return the specified value casted to the target's desired shift amount type.
LLVM_ABI std::pair< SDValue, SDValue > getMemccpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue C, SDValue Size, const CallInst *CI)
Lower a memccpy operation into a target library call and return the resulting chain and call result a...
LLVM_ABI SDValue emitStackConvert(SDValue SrcOp, EVT SlotVT, EVT DestVT, const SDLoc &DL, SDValue Chain)
Emit a store/load combination to the stack.
LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
Test whether the given floating point SDValue (or all elements of it, if it is a vector) is known to ...
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)
LLVM_ABI unsigned getHasPredecessorMaxSteps() const
bool isKnownNeverSNaN(SDValue Op, unsigned Depth=0) const
LLVM_ABI SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond, const SDLoc &dl, SDNodeFlags Flags={})
Constant fold a setcc to true or false.
bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts, unsigned Depth=0) const
LLVM_ABI SDValue makeStateFunctionCall(unsigned LibFunc, SDValue Ptr, SDValue InChain, SDNode *Node)
Helper used to make a call to a library function that has one argument of pointer type.
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)
LLVM_ABI ConstantRange computeConstantRange(SDValue Op, bool ForSigned, unsigned Depth=0) const
Determine the possible constant range of an integer or vector of integers.
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.
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 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 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 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 const BasicBlock * getBasicBlock() const
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 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.
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)
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.
SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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.
LLVM_ABI bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, TypeSize Bytes, int Dist) const
Return true if loads are next to each other and can be merged.
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
LLVM_ABI SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm)
Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
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.
LLVM_ABI bool haveNoCommonBitsSet(SDValue A, SDValue B) const
Return true if A and B have no common bits set.
LLVM_ABI SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS, const SDNodeFlags Flags=SDNodeFlags())
Return an AddrSpaceCastSDNode.
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 std::pair< SDValue, SDValue > getStrcmp(SDValue Chain, const SDLoc &dl, SDValue S0, SDValue S1, const CallInst *CI)
Lower a strcmp operation into a target library call and return the resulting chain and call result as...
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 bool canIgnoreSignBitOfZero(const SDUse &Use) const
Check if the user of Use produces the same result regardless of the sign of a zero in the used float ...
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
void init(MachineFunction &NewMF, MachineFunctionAnalysisManager &AM, const TargetLibraryInfo *LibraryInfo, const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs)
LLVM_ABI bool SignBitIsZeroFP(SDValue Op, unsigned Depth=0) const
Return true if the sign bit of Op is known to be zero, for a floating-point value.
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.
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,...
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond, SDValue Chain=SDValue(), bool IsSignaling=false, SDNodeFlags Flags={})
Helper function to make it easier to build SetCC's if you just have an ISD::CondCode instead of an SD...
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 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 bool hasSwiftErrorArg() const
LLVM_ABI SDValue buildVectorFromUnrolledParts(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Scalars)
Returns a vector constructed from the scalar values in order.
LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT)
Create a bitwise NOT operation as (XOR Val, -1).
const STC & getSubtarget() const
LLVM_ABI SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline, const CallInst *CI, std::optional< bool > OverrideTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo, const AAMDNodes &AAInfo=AAMDNodes(), BatchAAResults *BatchAA=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 unsigned getMaxRuntimeNumElements(EVT VT) const
Returns the maximum runtime number of elements in VT if known, or 0 otherwise.
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 getIdentityElement(unsigned Opcode, const SDLoc &DL, EVT VT, SDNodeFlags Flags)
Get the (commutative) identity element for the given opcode, if it exists.
SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, EVT SVT, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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)
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 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachinePointerInfo PtrInfo, EVT SVT, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
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.
LLVM_ABI std::pair< SDValue, SDValue > getStrcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, const CallInst *CI)
Lower a strcpy operation into a target library call and return the resulting chain and call result as...
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
LLVM_ABI SDValue getConstFP(std::optional< FPFoldResult > Result, const SDLoc &DL, EVT VT, bool isTarget=false)
Return the folded constant, or an empty SDValue if folding failed.
allnodes_iterator allnodes_begin()
LLVM_ABI SDValue getPartialReduceMLS(unsigned Opc, const SDLoc &DL, SDValue Acc, SDValue LHS, SDValue RHS)
Get an expression that implements a partial multiply-subtract reduction.
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 SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, MachinePointerInfo PtrInfo, Align Alignment, MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Helper function to build ISD::STORE nodes.
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.
LLVM_ABI bool areNonVolatileConsecutiveStores(StoreSDNode *ST, StoreSDNode *Base, TypeSize Bytes, int Dist) const
Return true if stores are next to each other and can be merged.
LLVM_ABI ConstantRange computeConstantRangeIncludingKnownBits(SDValue Op, bool ForSigned, unsigned Depth=0) const
Combine constant ranges from computeConstantRange() and computeKnownBits().
void addHeapAllocSite(const SDNode *Node, MDNode *MD)
Set HeapAllocSite to be associated with Node.
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
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.
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 getLoadFFVP(EVT VT, const SDLoc &DL, SDValue Chain, SDValue Ptr, SDValue Mask, SDValue EVL, MachineMemOperand *MMO)
LLVM_ABI SDValue getTypeSize(const SDLoc &DL, EVT VT, TypeSize TS)
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 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 MMOMetadata &Metadata=MMOMetadata())
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 getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
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.
LLVM_ABI void dump() const
Dump the textual format of this DAG.
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
allnodes_iterator allnodes_end()
SDDbgInfo::DbgLabelIterator DbgLabelBegin() const
LLVM_ABI bool canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts, UndefPoisonKind Kind=UndefPoisonKind::UndefOrPoison, bool ConsiderFlags=true, unsigned Depth=0) const
Return true if Op can create undef or poison from non-undef & non-poison operands.
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.
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 SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr, MachinePointerInfo PtrInfo, MaybeAlign Alignment=MaybeAlign(), MachineMemOperand::Flags MMOFlags=MachineMemOperand::MONone, const MMOMetadata &Metadata=MMOMetadata())
Loads are not normal binary operators: their result type is not determined by their operands,...
LLVM_ABI KnownFPClass computeKnownFPClass(SDValue Op, FPClassTest InterestedClasses, unsigned Depth=0) const
Determine floating-point class information about Op.
LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V, unsigned OperandNo, unsigned Depth=0) const
Returns true if V is an identity element of Opc with Flags.
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 bool isGuaranteedNotToBeUndefOrPoison(SDValue Op, UndefPoisonKind Kind=UndefPoisonKind::UndefOrPoison, unsigned Depth=0) const
Return true if this function can prove that Op is never poison and, Kind can be used to track poison ...
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 getMaskFromElementCount(const SDLoc &DL, EVT VT, ElementCount Len)
Return a vector with the first 'Len' lanes set to true and remaining lanes set to false.
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.
const LibcallLoweringInfo & getLibcalls() const
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.
bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
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 DstAlign, Align SrcAlign, 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 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 std::pair< SDValue, SDValue > getStrstr(SDValue Chain, const SDLoc &dl, SDValue S0, SDValue S1, const CallInst *CI)
Lower a strstr operation into a target library call and return the resulting chain and call result as...
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 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 getErrorMergeValues(ArrayRef< EVT > ResultTypes, SDValue Chain, const SDLoc &dl)
Return poison values for each of ResultTypes, substituting Chain for any result of type MVT::Other,...
LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget=false)
LLVM_ABI bool canIgnoreSignBitOfZeroResult(SDValue Op) const
Check if all uses of Op (limited to checking two for compile-time performance) are insensitive to sig...
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...
bool areNonVolatileConsecutiveStores(StoreSDNode *ST, StoreSDNode *Base, unsigned Bytes, int Dist) const
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...
const SelectionDAGOptions & getSelectionDAGOptions() const
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 void init(MachineFunction &NewMF, const TargetLibraryInfo *LibraryInfo, const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, FunctionVarLocs const *FnVarLocs)
Prepare this SelectionDAG to process code in the given MachineFunction.
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.
LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, bool OrZero=false, unsigned Depth=0) const
Test if the given value is known to have exactly one bit set.
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 SDValue getDeactivationSymbol(const GlobalValue *GV)
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.
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 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.
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 MMOMetadata &Metadata=MMOMetadata())
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:346
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.
This class is used to represent ISD::STORE nodes.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:129
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
static constexpr TypeSize getFixed(ScalarTy ExactSize)
Definition TypeSize.h:352
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
A uniquing set that compares nodes against a typed key rather than a serialized FoldingSetNodeID.
Definition FoldingSet.h:696
A Use represents the edge between a Value definition and its users.
Definition Use.h:35
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.
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition ISDOpcodes.h:43
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
Definition ISDOpcodes.h:851
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
Definition ISDOpcodes.h:516
@ POISON
POISON - A poison node.
Definition ISDOpcodes.h:238
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
Definition ISDOpcodes.h:605
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition ISDOpcodes.h:885
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
Definition ISDOpcodes.h:942
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
Definition ISDOpcodes.h:282
@ SIGN_EXTEND
Conversion operators.
Definition ISDOpcodes.h:876
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
Definition ISDOpcodes.h:828
@ UNDEF
UNDEF - An undefined node.
Definition ISDOpcodes.h:235
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
Definition ISDOpcodes.h:688
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
Definition ISDOpcodes.h:232
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
Definition ISDOpcodes.h:619
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
Definition ISDOpcodes.h:581
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
Definition ISDOpcodes.h:226
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition ISDOpcodes.h:882
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
Definition ISDOpcodes.h:843
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
Definition ISDOpcodes.h:931
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
Definition ISDOpcodes.h:105
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Definition ISDOpcodes.h:837
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
Definition ISDOpcodes.h:570
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Definition ISDOpcodes.h:953
@ CALLSEQ_START
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence,...
@ BUILD_VECTOR
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a fixed-width vector with the specified,...
Definition ISDOpcodes.h:561
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).
unsigned combineHashValue(unsigned a, unsigned b)
Simplistic combination of 32-bit hash values into 32-bit hash values.
NodeAddr< NodeBase * > Node
Definition RDFGraph.h:381
This is an optimization pass for GlobalISel generic memory operations.
GenericUniformityInfo< SSAContext > UniformityInfo
@ Offset
Definition DWP.cpp:577
bool isEqual(const GCNRPTracker::LiveRegSet &S1, const GCNRPTracker::LiveRegSet &S2)
GenericSSAContext< Function > SSAContext
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
iplist< T, Options... > ilist
Definition ilist.h:344
LLVM_ABI void checkForCycles(const SelectionDAG *DAG, bool force=false)
FPClassTest
Floating-point class tests, supported by 'is_fpclass' intrinsic.
AlignedCharArrayUnion< AtomicSDNode, TargetIndexSDNode, BlockAddressSDNode, GlobalAddressSDNode, PseudoProbeSDNode > LargestSDNode
A representation of the largest SDNode, for use in sizeof().
GlobalAddressSDNode MostAlignedSDNode
The SDNode class with the greatest alignment requirement.
CodeGenOptLevel
Code generation optimization level.
Definition CodeGen.h:280
LLVM_ATTRIBUTE_VISIBILITY_DEFAULT AnalysisKey InnerAnalysisManagerProxy< AnalysisManagerT, IRUnitT, ExtraArgTs... >::Key
CombineLevel
Definition DAGCombine.h:15
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Count
Definition InstrProf.h:145
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:1933
UndefPoisonKind
Enumeration to track whether we are interested in Undef, Poison, or both.
Definition UndefPoison.h:20
BumpPtrAllocatorImpl<> BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition Allocator.h:391
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:879
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:775
This struct is a compact representation of a valid (non-zero power of two) alignment.
Definition Alignment.h:39
Represent subnormal handling kind for floating point instruction inputs and outputs.
An information struct used to provide DenseMap with the various necessary components for a given valu...
Extended Value Type.
Definition ValueTypes.h:35
bool isVector() const
Return true if this is a vector value type.
Definition ValueTypes.h:191
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition ValueTypes.h:202
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition ValueTypes.h:366
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:374
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Definition ValueTypes.h:346
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition ValueTypes.h:175
This trait class is used to define behavior of how to "profile" (in the FoldingSet parlance) an objec...
Definition FoldingSet.h:255
static nodes_iterator nodes_begin(SelectionDAG *G)
static nodes_iterator nodes_end(SelectionDAG *G)
pointer_iterator< SelectionDAG::allnodes_iterator > nodes_iterator
LLVM IR metadata carried by a MachineMemOperand.
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:111
These are IR-level optimization flags that may be propagated to SDNodes.
static unsigned getHashValue(const KeyTy &Key)
static KeyTy getKey(const SDNode &N)
static LLVM_ABI bool isEqual(const KeyTy &Key, const SDNode &N)
The key SelectionDAG uniques SDNodes by.
void AddPointer(const void *P)
SmallVector< SDValue, 0 > OpStorage
Backs Ops when the key is built from a node; empty otherwise.
void AddInteger(T I)
const EVT * VTs
void AddBoolean(bool B)
ArrayRef< SDValue > Ops
FoldingSetNodeID Tail
SDNodeKey & operator=(const SDNodeKey &)=delete
SDNodeKey(const SDNodeKey &)=delete
SDNodeKey(unsigned Opcode, SDVTList VTList, ArrayRef< SDValue > Ops)
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