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"
46#include <cassert>
47#include <cstdint>
48#include <functional>
49#include <map>
50#include <set>
51#include <string>
52#include <tuple>
53#include <utility>
54#include <vector>
55
56namespace llvm {
57
58class DIExpression;
59class DILabel;
60class DIVariable;
61class Function;
62class Pass;
63class Type;
64template <class GraphType> struct GraphTraits;
65template <typename T, unsigned int N> class SmallSetVector;
66template <typename T, typename Enable> struct FoldingSetTrait;
67class BatchAAResults;
68class BlockAddress;
70class Constant;
71class ConstantFP;
72class ConstantInt;
73class DataLayout;
74struct fltSemantics;
76class FunctionVarLocs;
77class GlobalValue;
78struct KnownBits;
79class LLVMContext;
83class MCSymbol;
86class SDDbgValue;
87class SDDbgOperand;
88class SDDbgLabel;
89class SelectionDAG;
92class TargetLowering;
93class TargetMachine;
95class Value;
96
97template <typename T> class GenericSSAContext;
99template <typename T> class GenericUniformityInfo;
101
102template <> struct ilist_alloc_traits<SDNode> {
103 static void deleteNode(SDNode *) {
104 llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!");
105 }
106};
107
108/// Keeps track of dbg_value information through SDISel. We do
109/// not build SDNodes for these so as not to perturb the generated code;
110/// instead the info is kept off to the side in this structure. Each SDNode may
111/// have one or more associated dbg_value entries. This information is kept in
112/// DbgValMap.
113/// Byval parameters are handled separately because they don't use alloca's,
114/// which busts the normal mechanism. There is good reason for handling all
115/// parameters separately: they may not have code generated for them, they
116/// should always go at the beginning of the function regardless of other code
117/// motion, and debug info for them is potentially useful even if the parameter
118/// is unused. Right now only byval parameters are handled separately.
120 BumpPtrAllocator Alloc;
122 SmallVector<SDDbgValue*, 32> ByvalParmDbgValues;
125 DbgValMapType DbgValMap;
126
127public:
128 SDDbgInfo() = default;
129 SDDbgInfo(const SDDbgInfo &) = delete;
130 SDDbgInfo &operator=(const SDDbgInfo &) = delete;
131
132 LLVM_ABI void add(SDDbgValue *V, bool isParameter);
133
134 void add(SDDbgLabel *L) { DbgLabels.push_back(L); }
135
136 /// Invalidate all DbgValues attached to the node and remove
137 /// it from the Node-to-DbgValues map.
138 LLVM_ABI void erase(const SDNode *Node);
139
140 void clear() {
141 DbgValMap.clear();
142 DbgValues.clear();
143 ByvalParmDbgValues.clear();
144 DbgLabels.clear();
145 Alloc.Reset();
146 }
147
148 BumpPtrAllocator &getAlloc() { return Alloc; }
149
150 bool empty() const {
151 return DbgValues.empty() && ByvalParmDbgValues.empty() && DbgLabels.empty();
152 }
153
155 auto I = DbgValMap.find(Node);
156 if (I != DbgValMap.end())
157 return I->second;
158 return ArrayRef<SDDbgValue*>();
159 }
160
163
164 DbgIterator DbgBegin() { return DbgValues.begin(); }
165 DbgIterator DbgEnd() { return DbgValues.end(); }
166 DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
167 DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
168 DbgLabelIterator DbgLabelBegin() { return DbgLabels.begin(); }
169 DbgLabelIterator DbgLabelEnd() { return DbgLabels.end(); }
170};
171
172LLVM_ABI void checkForCycles(const SelectionDAG *DAG, bool force = false);
173
174/// This is used to represent a portion of an LLVM function in a low-level
175/// Data Dependence DAG representation suitable for instruction selection.
176/// This DAG is constructed as the first step of instruction selection in order
177/// to allow implementation of machine specific optimizations
178/// and code simplifications.
179///
180/// The representation used by the SelectionDAG is a target-independent
181/// representation, which has some similarities to the GCC RTL representation,
182/// but is significantly more simple, powerful, and is a graph form instead of a
183/// linear form.
184///
186 const TargetMachine &TM;
187 const SelectionDAGTargetInfo *TSI = nullptr;
188 const TargetLowering *TLI = nullptr;
189 const TargetLibraryInfo *LibInfo = nullptr;
190 const RTLIB::RuntimeLibcallsInfo *RuntimeLibcallInfo = nullptr;
191 const LibcallLoweringInfo *Libcalls = nullptr;
192
193 const FunctionVarLocs *FnVarLocs = nullptr;
194 MachineFunction *MF;
195 MachineFunctionAnalysisManager *MFAM = nullptr;
196 Pass *SDAGISelPass = nullptr;
197 LLVMContext *Context;
198 CodeGenOptLevel OptLevel;
199
200 UniformityInfo *UA = nullptr;
201 FunctionLoweringInfo * FLI = nullptr;
202
203 /// The function-level optimization remark emitter. Used to emit remarks
204 /// whenever manipulating the DAG.
206
207 ProfileSummaryInfo *PSI = nullptr;
208 BlockFrequencyInfo *BFI = nullptr;
209 MachineModuleInfo *MMI = nullptr;
210
211 /// Extended EVTs used for single value VTLists.
212 std::set<EVT, EVT::compareRawBits> EVTs;
213
214 /// Uniquing of VT lists. Each key aliases the EVT array that the returned
215 /// SDVTList points at, allocated from \p Allocator.
216 struct VTListInfo {
217 static unsigned getHashValue(ArrayRef<EVT> VTs) {
218 unsigned H = VTs.size();
219 for (EVT VT : VTs)
221 H, DenseMapInfo<intptr_t>::getHashValue(VT.getRawBits()));
222 return H;
223 }
225 return LHS == RHS;
226 }
227 };
228 DenseSet<ArrayRef<EVT>, VTListInfo> VTLists;
229
230 /// Pool allocation for misc. objects that are created once per SelectionDAG.
231 BumpPtrAllocator Allocator;
232
233 /// The starting token.
234 SDNode EntryNode;
235
236 /// The root of the entire DAG.
237 SDValue Root;
238
239 /// A linked list of nodes in the current DAG.
240 ilist<SDNode> AllNodes;
241
242 /// The AllocatorType for allocating SDNodes. We use
243 /// pool allocation with recycling.
244 using NodeAllocatorType = RecyclingAllocator<BumpPtrAllocator, SDNode,
245 sizeof(LargestSDNode),
246 alignof(MostAlignedSDNode)>;
247
248 /// Pool allocation for nodes.
249 NodeAllocatorType NodeAllocator;
250
251 /// This structure is used to memoize nodes, automatically performing
252 /// CSE with existing nodes when a duplicate is requested.
253 FoldingSet<SDNode> CSEMap;
254
255 /// Pool allocation for machine-opcode SDNode operands.
256 BumpPtrAllocator OperandAllocator;
257 ArrayRecycler<SDUse> OperandRecycler;
258
259 /// Tracks dbg_value and dbg_label information through SDISel.
260 SDDbgInfo *DbgInfo;
261
262 using CallSiteInfo = MachineFunction::CallSiteInfo;
263 using CalledGlobalInfo = MachineFunction::CalledGlobalInfo;
264
265 struct NodeExtraInfo {
266 CallSiteInfo CSInfo;
267 MDNode *HeapAllocSite = nullptr;
268 MDNode *PCSections = nullptr;
269 MDNode *MMRA = nullptr;
270 CalledGlobalInfo CalledGlobal{};
271 bool NoMerge = false;
272 };
273 /// Out-of-line extra information for SDNodes.
275
276 /// PersistentId counter to be used when inserting the next
277 /// SDNode to this SelectionDAG. We do not place that under
278 /// `#if LLVM_ENABLE_ABI_BREAKING_CHECKS` intentionally because
279 /// it adds unneeded complexity without noticeable
280 /// benefits (see discussion with @thakis in D120714).
281 uint16_t NextPersistentId = 0;
282
283public:
284 /// Clients of various APIs that cause global effects on
285 /// the DAG can optionally implement this interface. This allows the clients
286 /// to handle the various sorts of updates that happen.
287 ///
288 /// A DAGUpdateListener automatically registers itself with DAG when it is
289 /// constructed, and removes itself when destroyed in RAII fashion.
293
295 : Next(D.UpdateListeners), DAG(D) {
296 DAG.UpdateListeners = this;
297 }
298
300 assert(DAG.UpdateListeners == this &&
301 "DAGUpdateListeners must be destroyed in LIFO order");
302 DAG.UpdateListeners = Next;
303 }
304
305 /// The node N that was deleted and, if E is not null, an
306 /// equivalent node E that replaced it.
307 virtual void NodeDeleted(SDNode *N, SDNode *E);
308
309 /// The node N that was updated.
310 virtual void NodeUpdated(SDNode *N);
311
312 /// The node N that was inserted.
313 virtual void NodeInserted(SDNode *N);
314 };
315
317 std::function<void(SDNode *, SDNode *)> Callback;
318
322
323 void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); }
324
325 private:
326 virtual void anchor();
327 };
328
330 std::function<void(SDNode *)> Callback;
331
335
336 void NodeInserted(SDNode *N) override { Callback(N); }
337
338 private:
339 virtual void anchor();
340 };
341
342 /// Help to insert SDNodeFlags automatically in transforming. Use
343 /// RAII to save and resume flags in current scope.
345 SelectionDAG &DAG;
346 SDNodeFlags Flags;
347 FlagInserter *LastInserter;
348
349 public:
351 : DAG(SDAG), Flags(Flags),
352 LastInserter(SDAG.getFlagInserter()) {
353 SDAG.setFlagInserter(this);
354 }
357
358 FlagInserter(const FlagInserter &) = delete;
360 ~FlagInserter() { DAG.setFlagInserter(LastInserter); }
361
362 SDNodeFlags getFlags() const { return Flags; }
363 };
364
365 /// When true, additional steps are taken to
366 /// ensure that getConstant() and similar functions return DAG nodes that
367 /// have legal types. This is important after type legalization since
368 /// any illegally typed nodes generated after this point will not experience
369 /// type legalization.
371
372private:
373 /// DAGUpdateListener is a friend so it can manipulate the listener stack.
374 friend struct DAGUpdateListener;
375
376 /// Linked list of registered DAGUpdateListener instances.
377 /// This stack is maintained by DAGUpdateListener RAII.
378 DAGUpdateListener *UpdateListeners = nullptr;
379
380 /// Implementation of setSubgraphColor.
381 /// Return whether we had to truncate the search.
382 bool setSubgraphColorHelper(SDNode *N, const char *Color,
383 DenseSet<SDNode *> &visited,
384 int level, bool &printed);
385
386 template <typename SDNodeT, typename... ArgTypes>
387 SDNodeT *newSDNode(ArgTypes &&... Args) {
388 return new (NodeAllocator.template Allocate<SDNodeT>())
389 SDNodeT(std::forward<ArgTypes>(Args)...);
390 }
391
392 /// Build a synthetic SDNodeT with the given args and extract its subclass
393 /// data as an integer (e.g. for use in a folding set).
394 ///
395 /// The args to this function are the same as the args to SDNodeT's
396 /// constructor, except the second arg (assumed to be a const DebugLoc&) is
397 /// omitted.
398 template <typename SDNodeT, typename... ArgTypes>
399 static uint16_t getSyntheticNodeSubclassData(unsigned IROrder,
400 ArgTypes &&... Args) {
401 // The compiler can reduce this expression to a constant iff we pass an
402 // empty DebugLoc. Thankfully, the debug location doesn't have any bearing
403 // on the subclass data.
404 return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...)
405 .getRawSubclassData();
406 }
407
408 template <typename SDNodeTy>
409 static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order,
410 SDVTList VTs, EVT MemoryVT,
411 MachineMemOperand *MMO) {
412 return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO)
413 .getRawSubclassData();
414 }
415
416 template <typename SDNodeTy>
417 static uint16_t getSyntheticNodeSubclassData(
418 unsigned Opc, unsigned Order, SDVTList VTs, EVT MemoryVT,
419 PointerUnion<MachineMemOperand *, MachineMemOperand **> MemRefs) {
420 return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MemRefs)
421 .getRawSubclassData();
422 }
423
424 void createOperands(SDNode *Node, ArrayRef<SDValue> Vals);
425
426 void removeOperands(SDNode *Node) {
427 if (!Node->OperandList)
428 return;
429 OperandRecycler.deallocate(
431 Node->OperandList);
432 Node->NumOperands = 0;
433 Node->OperandList = nullptr;
434 }
435 void CreateTopologicalOrder(std::vector<SDNode*>& Order);
436
437public:
438 // Maximum depth for recursive analysis such as computeKnownBits, etc.
439 static constexpr unsigned MaxRecursionDepth = 6;
440
441 // Returns the maximum steps for SDNode->hasPredecessor() like searches.
442 LLVM_ABI static unsigned getHasPredecessorMaxSteps();
443
445 SelectionDAG(const SelectionDAG &) = delete;
448
449 /// Prepare this SelectionDAG to process code in the given MachineFunction.
451 Pass *PassPtr, const TargetLibraryInfo *LibraryInfo,
452 const LibcallLoweringInfo *LibcallsInfo,
455 FunctionVarLocs const *FnVarLocs);
456
459 const TargetLibraryInfo *LibraryInfo,
460 const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA,
462 MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs) {
463 init(NewMF, NewORE, nullptr, LibraryInfo, LibcallsInfo, UA, PSIin, BFIin,
464 MMI, FnVarLocs);
465 MFAM = &AM;
466 }
467
469 FLI = FuncInfo;
470 }
471
472 /// Clear state and free memory necessary to make this
473 /// SelectionDAG ready to process a new block.
474 LLVM_ABI void clear();
475
476 MachineFunction &getMachineFunction() const { return *MF; }
477 const Pass *getPass() const { return SDAGISelPass; }
479
480 bool hasSwiftErrorArg() const;
481
482 CodeGenOptLevel getOptLevel() const { return OptLevel; }
483 const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
484 const TargetMachine &getTarget() const { return TM; }
485 const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
486 template <typename STC> const STC &getSubtarget() const {
487 return MF->getSubtarget<STC>();
488 }
489 const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
490 const TargetLibraryInfo &getLibInfo() const { return *LibInfo; }
491
492 const LibcallLoweringInfo &getLibcalls() const { return *Libcalls; }
493
495 return *RuntimeLibcallInfo;
496 }
497
498 const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; }
499 const UniformityInfo *getUniformityInfo() const { return UA; }
500 /// Returns the result of the AssignmentTrackingAnalysis pass if it's
501 /// available, otherwise return nullptr.
502 const FunctionVarLocs *getFunctionVarLocs() const { return FnVarLocs; }
503 LLVMContext *getContext() const { return Context; }
504 OptimizationRemarkEmitter &getORE() const { return *ORE; }
505 ProfileSummaryInfo *getPSI() const { return PSI; }
506 BlockFrequencyInfo *getBFI() const { return BFI; }
507 MachineModuleInfo *getMMI() const { return MMI; }
508
509 FlagInserter *getFlagInserter() { return Inserter; }
510 void setFlagInserter(FlagInserter *FI) { Inserter = FI; }
511
512 /// Just dump dot graph to a user-provided path and title.
513 /// This doesn't open the dot viewer program and
514 /// helps visualization when outside debugging session.
515 /// FileName expects absolute path. If provided
516 /// without any path separators then the file
517 /// will be created in the current directory.
518 /// Error will be emitted if the path is insane.
519#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
520 LLVM_DUMP_METHOD void dumpDotGraph(const Twine &FileName, const Twine &Title);
521#endif
522
523 /// Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
524 LLVM_ABI void viewGraph(const std::string &Title);
525 LLVM_ABI void viewGraph();
526
527#if LLVM_ENABLE_ABI_BREAKING_CHECKS
528 std::map<const SDNode *, std::string> NodeGraphAttrs;
529#endif
530
531 /// Clear all previously defined node graph attributes.
532 /// Intended to be used from a debugging tool (eg. gdb).
534
535 /// Set graph attributes for a node. (eg. "color=red".)
536 LLVM_ABI void setGraphAttrs(const SDNode *N, const char *Attrs);
537
538 /// Get graph attributes for a node. (eg. "color=red".)
539 /// Used from getNodeAttributes.
540 LLVM_ABI std::string getGraphAttrs(const SDNode *N) const;
541
542 /// Convenience for setting node color attribute.
543 LLVM_ABI void setGraphColor(const SDNode *N, const char *Color);
544
545 /// Convenience for setting subgraph color attribute.
546 LLVM_ABI void setSubgraphColor(SDNode *N, const char *Color);
547
549
550 allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
551 allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
552
554
555 allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
556 allnodes_iterator allnodes_end() { return AllNodes.end(); }
557
559 return AllNodes.size();
560 }
561
568
569 /// Return the root tag of the SelectionDAG.
570 const SDValue &getRoot() const { return Root; }
571
572 /// Return the token chain corresponding to the entry of the function.
574 return SDValue(const_cast<SDNode *>(&EntryNode), 0);
575 }
576
577 /// Set the current root tag of the SelectionDAG.
578 ///
580 assert((!N.getNode() || N.getValueType() == MVT::Other) &&
581 "DAG root value is not a chain!");
582 if (N.getNode())
583 checkForCycles(N.getNode(), this);
584 Root = N;
585 if (N.getNode())
586 checkForCycles(this);
587 return Root;
588 }
589
590#if !defined(NDEBUG) && LLVM_ENABLE_ABI_BREAKING_CHECKS
591 void VerifyDAGDivergence();
592#endif
593
594 /// This iterates over the nodes in the SelectionDAG, folding
595 /// certain types of nodes together, or eliminating superfluous nodes. The
596 /// Level argument controls whether Combine is allowed to produce nodes and
597 /// types that are illegal on the target.
598 LLVM_ABI void Combine(CombineLevel Level, BatchAAResults *BatchAA,
599 CodeGenOptLevel OptLevel);
600
601 /// This transforms the SelectionDAG into a SelectionDAG that
602 /// only uses types natively supported by the target.
603 /// Returns "true" if it made any changes.
604 ///
605 /// Note that this is an involved process that may invalidate pointers into
606 /// the graph.
607 LLVM_ABI bool LegalizeTypes();
608
609 /// This transforms the SelectionDAG into a SelectionDAG that is
610 /// compatible with the target instruction selector, as indicated by the
611 /// TargetLowering object.
612 ///
613 /// Note that this is an involved process that may invalidate pointers into
614 /// the graph.
615 LLVM_ABI void Legalize();
616
617 /// Transforms a SelectionDAG node and any operands to it into a node
618 /// that is compatible with the target instruction selector, as indicated by
619 /// the TargetLowering object.
620 ///
621 /// \returns true if \c N is a valid, legal node after calling this.
622 ///
623 /// This essentially runs a single recursive walk of the \c Legalize process
624 /// over the given node (and its operands). This can be used to incrementally
625 /// legalize the DAG. All of the nodes which are directly replaced,
626 /// potentially including N, are added to the output parameter \c
627 /// UpdatedNodes so that the delta to the DAG can be understood by the
628 /// caller.
629 ///
630 /// When this returns false, N has been legalized in a way that make the
631 /// pointer passed in no longer valid. It may have even been deleted from the
632 /// DAG, and so it shouldn't be used further. When this returns true, the
633 /// N passed in is a legal node, and can be immediately processed as such.
634 /// This may still have done some work on the DAG, and will still populate
635 /// UpdatedNodes with any new nodes replacing those originally in the DAG.
637 SmallSetVector<SDNode *, 16> &UpdatedNodes);
638
639 /// This transforms the SelectionDAG into a SelectionDAG
640 /// that only uses vector math operations supported by the target. This is
641 /// necessary as a separate step from Legalize because unrolling a vector
642 /// operation can introduce illegal types, which requires running
643 /// LegalizeTypes again.
644 ///
645 /// This returns true if it made any changes; in that case, LegalizeTypes
646 /// is called again before Legalize.
647 ///
648 /// Note that this is an involved process that may invalidate pointers into
649 /// the graph.
651
652 /// This method deletes all unreachable nodes in the SelectionDAG.
654
655 /// Remove the specified node from the system. This node must
656 /// have no referrers.
658
659 /// Return an SDVTList that represents the list of values specified.
662 LLVM_ABI SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
663 LLVM_ABI SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
665
666 //===--------------------------------------------------------------------===//
667 // Node creation methods.
668
669 /// Create a ConstantSDNode wrapping a constant value.
670 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
671 ///
672 /// If only legal types can be produced, this does the necessary
673 /// transformations (e.g., if the vector element type is illegal).
674 /// @{
676 bool isTarget = false, bool isOpaque = false);
677 LLVM_ABI SDValue getConstant(const APInt &Val, const SDLoc &DL, EVT VT,
678 bool isTarget = false, bool isOpaque = false);
679
680 LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT,
681 bool isTarget = false,
682 bool isOpaque = false);
683
685 bool IsTarget = false,
686 bool IsOpaque = false);
687
688 LLVM_ABI SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
689 bool isTarget = false, bool isOpaque = false);
691 bool isTarget = false);
693 const SDLoc &DL);
695 const SDLoc &DL);
697 bool isTarget = false);
698
700 bool isOpaque = false) {
701 return getConstant(Val, DL, VT, true, isOpaque);
702 }
703 SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT,
704 bool isOpaque = false) {
705 return getConstant(Val, DL, VT, true, isOpaque);
706 }
708 bool isOpaque = false) {
709 return getConstant(Val, DL, VT, true, isOpaque);
710 }
711 SDValue getSignedTargetConstant(int64_t Val, const SDLoc &DL, EVT VT,
712 bool isOpaque = false) {
713 return getSignedConstant(Val, DL, VT, true, isOpaque);
714 }
715
716 /// Create a true or false constant of type \p VT using the target's
717 /// BooleanContent for type \p OpVT.
718 LLVM_ABI SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT);
719 /// @}
720
721 /// Create a ConstantFPSDNode wrapping a constant value.
722 /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
723 ///
724 /// If only legal types can be produced, this does the necessary
725 /// transformations (e.g., if the vector element type is illegal).
726 /// The forms that take a double should only be used for simple constants
727 /// that can be exactly represented in VT. No checks are made.
728 /// @{
729 LLVM_ABI SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT,
730 bool isTarget = false);
731 LLVM_ABI SDValue getConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT,
732 bool isTarget = false);
733 LLVM_ABI SDValue getConstantFP(const ConstantFP &V, const SDLoc &DL, EVT VT,
734 bool isTarget = false);
735 SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT) {
736 return getConstantFP(Val, DL, VT, true);
737 }
738 SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT) {
739 return getConstantFP(Val, DL, VT, true);
740 }
742 return getConstantFP(Val, DL, VT, true);
743 }
744 /// @}
745
747 EVT VT, int64_t offset = 0,
748 bool isTargetGA = false,
749 unsigned TargetFlags = 0);
751 int64_t offset = 0, unsigned TargetFlags = 0) {
752 return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags);
753 }
755 LLVM_ABI SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
757 return getFrameIndex(FI, VT, true);
758 }
759 LLVM_ABI SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
760 unsigned TargetFlags = 0);
761 SDValue getTargetJumpTable(int JTI, EVT VT, unsigned TargetFlags = 0) {
762 return getJumpTable(JTI, VT, true, TargetFlags);
763 }
765 const SDLoc &DL);
767 MaybeAlign Align = std::nullopt,
768 int Offs = 0, bool isT = false,
769 unsigned TargetFlags = 0);
771 MaybeAlign Align = std::nullopt, int Offset = 0,
772 unsigned TargetFlags = 0) {
773 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
774 }
776 MaybeAlign Align = std::nullopt,
777 int Offs = 0, bool isT = false,
778 unsigned TargetFlags = 0);
780 MaybeAlign Align = std::nullopt, int Offset = 0,
781 unsigned TargetFlags = 0) {
782 return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
783 }
784 // When generating a branch to a BB, we don't in general know enough
785 // to provide debug info for the BB at that time, so keep this one around.
787 LLVM_ABI SDValue getExternalSymbol(const char *Sym, EVT VT);
788 LLVM_ABI SDValue getExternalSymbol(RTLIB::LibcallImpl LCImpl, EVT VT);
789 LLVM_ABI SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
790 unsigned TargetFlags = 0);
791 LLVM_ABI SDValue getTargetExternalSymbol(RTLIB::LibcallImpl LCImpl, EVT VT,
792 unsigned TargetFlags = 0);
793
795
799 LLVM_ABI SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label);
800 LLVM_ABI SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root,
801 MCSymbol *Label);
803 int64_t Offset = 0, bool isTarget = false,
804 unsigned TargetFlags = 0);
806 int64_t Offset = 0, unsigned TargetFlags = 0) {
807 return getBlockAddress(BA, VT, Offset, true, TargetFlags);
808 }
809
811 SDValue N) {
812 return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
813 getRegister(Reg, N.getValueType()), N);
814 }
815
816 // This version of the getCopyToReg method takes an extra operand, which
817 // indicates that there is potentially an incoming glue value (if Glue is not
818 // null) and that there should be a glue result.
820 SDValue Glue) {
821 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
822 SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
823 return getNode(ISD::CopyToReg, dl, VTs,
824 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
825 }
826
827 // Similar to last getCopyToReg() except parameter Reg is a SDValue
829 SDValue Glue) {
830 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
831 SDValue Ops[] = { Chain, Reg, N, Glue };
832 return getNode(ISD::CopyToReg, dl, VTs,
833 ArrayRef(Ops, Glue.getNode() ? 4 : 3));
834 }
835
837 SDVTList VTs = getVTList(VT, MVT::Other);
838 SDValue Ops[] = { Chain, getRegister(Reg, VT) };
839 return getNode(ISD::CopyFromReg, dl, VTs, Ops);
840 }
841
842 // This version of the getCopyFromReg method takes an extra operand, which
843 // indicates that there is potentially an incoming glue value (if Glue is not
844 // null) and that there should be a glue result.
846 SDValue Glue) {
847 SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
848 SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
849 return getNode(ISD::CopyFromReg, dl, VTs,
850 ArrayRef(Ops, Glue.getNode() ? 3 : 2));
851 }
852
854
855 /// Return an ISD::VECTOR_SHUFFLE node. The number of elements in VT,
856 /// which must be a vector type, must match the number of mask elements
857 /// NumElts. An integer mask element equal to -1 is treated as undefined.
859 SDValue N2, ArrayRef<int> Mask);
860
861 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
862 /// which must be a vector type, must match the number of operands in Ops.
863 /// The operands must have the same type as (or, for integers, a type wider
864 /// than) VT's element type.
866 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
867 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
868 }
869
870 /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
871 /// which must be a vector type, must match the number of operands in Ops.
872 /// The operands must have the same type as (or, for integers, a type wider
873 /// than) VT's element type.
875 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
876 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
877 }
878
879 /// Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all
880 /// elements. VT must be a vector type. Op's type must be the same as (or,
881 /// for integers, a type wider than) VT's element type.
883 // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
884 if (Op.isUndef()) {
885 assert((VT.getVectorElementType() == Op.getValueType() ||
886 (VT.isInteger() &&
887 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
888 "A splatted value must have a width equal or (for integers) "
889 "greater than the vector element type!");
890 return getNode(ISD::UNDEF, SDLoc(), VT);
891 }
892
894 return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
895 }
896
897 // Return a splat ISD::SPLAT_VECTOR node, consisting of Op splatted to all
898 // elements.
900 if (Op.isUndef()) {
901 assert((VT.getVectorElementType() == Op.getValueType() ||
902 (VT.isInteger() &&
903 VT.getVectorElementType().bitsLE(Op.getValueType()))) &&
904 "A splatted value must have a width equal or (for integers) "
905 "greater than the vector element type!");
906 return getNode(ISD::UNDEF, SDLoc(), VT);
907 }
908 return getNode(ISD::SPLAT_VECTOR, DL, VT, Op);
909 }
910
911 /// Returns a node representing a splat of one value into all lanes
912 /// of the provided vector type. This is a utility which returns
913 /// either a BUILD_VECTOR or SPLAT_VECTOR depending on the
914 /// scalability of the desired vector type.
916 assert(VT.isVector() && "Can't splat to non-vector type");
917 return VT.isScalableVector() ?
919 }
920
921 /// Returns a vector of type ResVT whose elements contain the linear sequence
922 /// <0, Step, Step * 2, Step * 3, ...>
924 const APInt &StepVal);
925
926 /// Returns a vector of type ResVT whose elements contain the linear sequence
927 /// <0, 1, 2, 3, ...>
928 LLVM_ABI SDValue getStepVector(const SDLoc &DL, EVT ResVT);
929
930 /// Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to
931 /// the shuffle node in input but with swapped operands.
932 ///
933 /// Example: shuffle A, B, <0,5,2,7> -> shuffle B, A, <4,1,6,3>
935
936 /// Extract element at \p Idx from \p Vec. See EXTRACT_VECTOR_ELT
937 /// description for result type handling.
939 unsigned Idx) {
940 return getNode(ISD::EXTRACT_VECTOR_ELT, DL, VT, Vec,
942 }
943
944 /// Insert \p Elt into \p Vec at offset \p Idx. See INSERT_VECTOR_ELT
945 /// description for element type handling.
947 unsigned Idx) {
948 return getNode(ISD::INSERT_VECTOR_ELT, DL, Vec.getValueType(), Vec, Elt,
950 }
951
952 /// Insert \p SubVec at the \p Idx element of \p Vec.
954 unsigned Idx) {
955 return getNode(ISD::INSERT_SUBVECTOR, DL, Vec.getValueType(), Vec, SubVec,
957 }
958
959 /// Return the \p VT typed sub-vector of \p Vec at \p Idx
961 unsigned Idx) {
962 return getNode(ISD::EXTRACT_SUBVECTOR, DL, VT, Vec,
964 }
965
966 /// Convert Op, which must be of float type, to the
967 /// float type VT, by either extending or rounding (by truncation).
969
970 /// Convert Op, which must be a STRICT operation of float type, to the
971 /// float type VT, by either extending or rounding (by truncation).
972 LLVM_ABI std::pair<SDValue, SDValue>
974
975 /// Convert *_EXTEND_VECTOR_INREG to *_EXTEND opcode.
976 static unsigned getOpcode_EXTEND(unsigned Opcode) {
977 switch (Opcode) {
978 case ISD::ANY_EXTEND:
980 return ISD::ANY_EXTEND;
981 case ISD::ZERO_EXTEND:
983 return ISD::ZERO_EXTEND;
984 case ISD::SIGN_EXTEND:
986 return ISD::SIGN_EXTEND;
987 }
988 llvm_unreachable("Unknown opcode");
989 }
990
991 /// Convert *_EXTEND to *_EXTEND_VECTOR_INREG opcode.
992 static unsigned getOpcode_EXTEND_VECTOR_INREG(unsigned Opcode) {
993 switch (Opcode) {
994 case ISD::ANY_EXTEND:
997 case ISD::ZERO_EXTEND:
1000 case ISD::SIGN_EXTEND:
1003 }
1004 llvm_unreachable("Unknown opcode");
1005 }
1006
1007 /// Convert Op, which must be of integer type, to the
1008 /// integer type VT, by either any-extending or truncating it.
1010
1011 /// Convert Op, which must be of integer type, to the
1012 /// integer type VT, by either sign-extending or truncating it.
1014
1015 /// Convert Op, which must be of integer type, to the
1016 /// integer type VT, by either zero-extending or truncating it.
1018
1019 /// Convert Op, which must be of integer type, to the
1020 /// integer type VT, by either any/sign/zero-extending (depending on IsAny /
1021 /// IsSigned) or truncating it.
1023 EVT VT, unsigned Opcode) {
1024 switch(Opcode) {
1025 case ISD::ANY_EXTEND:
1026 return getAnyExtOrTrunc(Op, DL, VT);
1027 case ISD::ZERO_EXTEND:
1028 return getZExtOrTrunc(Op, DL, VT);
1029 case ISD::SIGN_EXTEND:
1030 return getSExtOrTrunc(Op, DL, VT);
1031 }
1032 llvm_unreachable("Unsupported opcode");
1033 }
1034
1035 /// Convert Op, which must be of integer type, to the
1036 /// integer type VT, by either sign/zero-extending (depending on IsSigned) or
1037 /// truncating it.
1038 SDValue getExtOrTrunc(bool IsSigned, SDValue Op, const SDLoc &DL, EVT VT) {
1039 return IsSigned ? getSExtOrTrunc(Op, DL, VT) : getZExtOrTrunc(Op, DL, VT);
1040 }
1041
1042 /// Convert Op, which must be of integer type, to the
1043 /// integer type VT, by first bitcasting (from potential vector) to
1044 /// corresponding scalar type then either any-extending or truncating it.
1046 EVT VT);
1047
1048 /// Convert Op, which must be of integer type, to the
1049 /// integer type VT, by first bitcasting (from potential vector) to
1050 /// corresponding scalar type then either sign-extending or truncating it.
1052
1053 /// Convert Op, which must be of integer type, to the
1054 /// integer type VT, by first bitcasting (from potential vector) to
1055 /// corresponding scalar type then either zero-extending or truncating it.
1057
1058 /// Return the expression required to zero extend the Op
1059 /// value assuming it was the smaller SrcTy value.
1061
1062 /// Convert Op, which must be of integer type, to the integer type VT, by
1063 /// either truncating it or performing either zero or sign extension as
1064 /// appropriate extension for the pointer's semantics.
1066
1067 /// Return the expression required to extend the Op as a pointer value
1068 /// assuming it was the smaller SrcTy value. This may be either a zero extend
1069 /// or a sign extend.
1071
1072 /// Convert Op, which must be of integer type, to the integer type VT,
1073 /// by using an extension appropriate for the target's
1074 /// BooleanContent for type OpVT or truncating it.
1076 EVT OpVT);
1077
1078 /// Create negative operation as (SUB 0, Val).
1079 LLVM_ABI SDValue getNegative(SDValue Val, const SDLoc &DL, EVT VT);
1080
1081 /// Create a bitwise NOT operation as (XOR Val, -1).
1082 LLVM_ABI SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT);
1083
1084 /// Create a logical NOT operation as (XOR Val, BooleanOne).
1085 LLVM_ABI SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT);
1086
1087 /// Returns sum of the base pointer and offset.
1088 /// Unlike getObjectPtrOffset this does not set NoUnsignedWrap and InBounds by
1089 /// default.
1092 const SDNodeFlags Flags = SDNodeFlags());
1095 const SDNodeFlags Flags = SDNodeFlags());
1096
1097 /// Create an add instruction with appropriate flags when used for
1098 /// addressing some offset of an object. i.e. if a load is split into multiple
1099 /// components, create an add nuw (or ptradd nuw inbounds) from the base
1100 /// pointer to the offset.
1105
1107 // The object itself can't wrap around the address space, so it shouldn't be
1108 // possible for the adds of the offsets to the split parts to overflow.
1109 return getMemBasePlusOffset(
1111 }
1112
1113 /// Return a new CALLSEQ_START node, that starts new call frame, in which
1114 /// InSize bytes are set up inside CALLSEQ_START..CALLSEQ_END sequence and
1115 /// OutSize specifies part of the frame set up prior to the sequence.
1117 const SDLoc &DL) {
1118 SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
1119 SDValue Ops[] = { Chain,
1120 getIntPtrConstant(InSize, DL, true),
1121 getIntPtrConstant(OutSize, DL, true) };
1122 return getNode(ISD::CALLSEQ_START, DL, VTs, Ops);
1123 }
1124
1125 /// Return a new CALLSEQ_END node, which always must have a
1126 /// glue result (to ensure it's not CSE'd).
1127 /// CALLSEQ_END does not have a useful SDLoc.
1129 SDValue InGlue, const SDLoc &DL) {
1130 SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue);
1132 Ops.push_back(Chain);
1133 Ops.push_back(Op1);
1134 Ops.push_back(Op2);
1135 if (InGlue.getNode())
1136 Ops.push_back(InGlue);
1137 return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops);
1138 }
1139
1141 SDValue Glue, const SDLoc &DL) {
1142 return getCALLSEQ_END(
1143 Chain, getIntPtrConstant(Size1, DL, /*isTarget=*/true),
1144 getIntPtrConstant(Size2, DL, /*isTarget=*/true), Glue, DL);
1145 }
1146
1147 /// Return true if the result of this operation is always undefined.
1148 LLVM_ABI bool isUndef(unsigned Opcode, ArrayRef<SDValue> Ops);
1149
1150 /// Return an UNDEF node. UNDEF does not have a useful SDLoc.
1152 return getNode(ISD::UNDEF, SDLoc(), VT);
1153 }
1154
1155 /// Return a POISON node. POISON does not have a useful SDLoc.
1157
1158 /// Return a node that represents the runtime scaling 'MulImm * RuntimeVL'.
1159 LLVM_ABI SDValue getVScale(const SDLoc &DL, EVT VT, APInt MulImm);
1160
1162
1164
1165 /// Return a vector with the first 'Len' lanes set to true and remaining lanes
1166 /// set to false. The mask's ValueType is the same as when comparing vectors
1167 /// of type VT.
1169 ElementCount Len);
1170
1171 /// Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
1175
1176 /// Gets or creates the specified node.
1177 ///
1178 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1180 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1181 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1182 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL,
1184 const SDNodeFlags Flags);
1185 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1186 ArrayRef<SDValue> Ops, const SDNodeFlags Flags);
1187
1188 // Use flags from current flag inserter.
1189 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1191 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL,
1193 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1195 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1196 SDValue Operand);
1197 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1198 SDValue N2);
1199 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1200 SDValue N2, SDValue N3);
1201
1202 // Specialize based on number of operands.
1203 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT);
1204 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
1205 SDValue Operand, const SDNodeFlags Flags);
1206 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1207 SDValue N2, const SDNodeFlags Flags);
1208 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1209 SDValue N2, SDValue N3, const SDNodeFlags Flags);
1210 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1211 SDValue N2, SDValue N3, SDValue N4);
1212 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1213 SDValue N2, SDValue N3, SDValue N4,
1214 const SDNodeFlags Flags);
1215 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1216 SDValue N2, SDValue N3, SDValue N4, SDValue N5);
1217 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
1218 SDValue N2, SDValue N3, SDValue N4, SDValue N5,
1219 const SDNodeFlags Flags);
1220
1221 // Specialize again based on number of operands for nodes with a VTList
1222 // rather than a single VT.
1223 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList);
1224 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1225 SDValue N);
1226 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1227 SDValue N1, SDValue N2);
1228 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1229 SDValue N1, SDValue N2, SDValue N3);
1230 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1231 SDValue N1, SDValue N2, SDValue N3, SDValue N4);
1232 LLVM_ABI SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
1233 SDValue N1, SDValue N2, SDValue N3, SDValue N4,
1234 SDValue N5);
1235
1236 /// Compute a TokenFactor to force all the incoming stack arguments to be
1237 /// loaded from the stack. This is used in tail call lowering to protect
1238 /// stack arguments from being clobbered.
1240
1241 /// Lower a memccpy operation into a target library call and return the
1242 /// resulting chain and call result as SelectionDAG SDValues.
1243 LLVM_ABI std::pair<SDValue, SDValue>
1244 getMemccpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
1245 SDValue C, SDValue Size, const CallInst *CI);
1246
1247 /// Lower a memcmp operation into a target library call and return the
1248 /// resulting chain and call result as SelectionDAG SDValues.
1249 LLVM_ABI std::pair<SDValue, SDValue> getMemcmp(SDValue Chain, const SDLoc &dl,
1250 SDValue Dst, SDValue Src,
1251 SDValue Size,
1252 const CallInst *CI);
1253
1254 /// Lower a strcmp operation into a target library call and return the
1255 /// resulting chain and call result as SelectionDAG SDValues.
1256 LLVM_ABI std::pair<SDValue, SDValue> getStrcmp(SDValue Chain, const SDLoc &dl,
1257 SDValue S0, SDValue S1,
1258 const CallInst *CI);
1259
1260 /// Lower a strcpy operation into a target library call and return the
1261 /// resulting chain and call result as SelectionDAG SDValues.
1262 LLVM_ABI std::pair<SDValue, SDValue> getStrcpy(SDValue Chain, const SDLoc &dl,
1263 SDValue Dst, SDValue Src,
1264 const CallInst *CI);
1265
1266 /// Lower a strlen operation into a target library call and return the
1267 /// resulting chain and call result as SelectionDAG SDValues.
1268 LLVM_ABI std::pair<SDValue, SDValue>
1269 getStrlen(SDValue Chain, const SDLoc &dl, SDValue Src, const CallInst *CI);
1270
1271 /// Lower a strstr operation into a target library call and return the
1272 /// resulting chain and call result as SelectionDAG SDValues.
1273 LLVM_ABI std::pair<SDValue, SDValue> getStrstr(SDValue Chain, const SDLoc &dl,
1274 SDValue S0, SDValue S1,
1275 const CallInst *CI);
1276
1277 /* \p CI if not null is the memset call being lowered.
1278 * \p OverrideTailCall is an optional parameter that can be used to override
1279 * the tail call optimization decision. */
1281 SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size,
1282 Align DstAlign, Align SrcAlign, bool isVol, bool AlwaysInline,
1283 const CallInst *CI, std::optional<bool> OverrideTailCall,
1284 MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo,
1285 const AAMDNodes &AAInfo = AAMDNodes(), BatchAAResults *BatchAA = nullptr);
1286
1287 /* \p CI if not null is the memset call being lowered.
1288 * \p OverrideTailCall is an optional parameter that can be used to override
1289 * the tail call optimization decision. */
1290 LLVM_ABI SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
1291 SDValue Src, SDValue Size, Align DstAlign,
1292 Align SrcAlign, bool isVol, const CallInst *CI,
1293 std::optional<bool> OverrideTailCall,
1294 MachinePointerInfo DstPtrInfo,
1295 MachinePointerInfo SrcPtrInfo,
1296 const AAMDNodes &AAInfo = AAMDNodes(),
1297 BatchAAResults *BatchAA = nullptr);
1298
1299 LLVM_ABI SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
1300 SDValue Src, SDValue Size, Align Alignment,
1301 bool isVol, bool AlwaysInline, const CallInst *CI,
1302 MachinePointerInfo DstPtrInfo,
1303 const AAMDNodes &AAInfo = AAMDNodes());
1304
1305 LLVM_ABI SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst,
1306 SDValue Src, SDValue Size, Type *SizeTy,
1307 unsigned ElemSz, bool isTailCall,
1308 MachinePointerInfo DstPtrInfo,
1309 MachinePointerInfo SrcPtrInfo);
1310
1311 LLVM_ABI SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
1312 SDValue Src, SDValue Size, Type *SizeTy,
1313 unsigned ElemSz, bool isTailCall,
1314 MachinePointerInfo DstPtrInfo,
1315 MachinePointerInfo SrcPtrInfo);
1316
1317 LLVM_ABI SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
1318 SDValue Value, SDValue Size, Type *SizeTy,
1319 unsigned ElemSz, bool isTailCall,
1320 MachinePointerInfo DstPtrInfo);
1321
1322 /// Helper function to make it easier to build SetCC's if you just have an
1323 /// ISD::CondCode instead of an SDValue.
1325 ISD::CondCode Cond, SDValue Chain = SDValue(),
1326 bool IsSignaling = false, SDNodeFlags Flags = {}) {
1327 assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() &&
1328 "Vector/scalar operand type mismatch for setcc");
1329 assert(LHS.getValueType().isVector() == VT.isVector() &&
1330 "Vector/scalar result type mismatch for setcc");
1332 "Cannot create a setCC of an invalid node.");
1333 if (Chain)
1334 return getNode(IsSignaling ? ISD::STRICT_FSETCCS : ISD::STRICT_FSETCC, DL,
1335 {VT, MVT::Other}, {Chain, LHS, RHS, getCondCode(Cond)},
1336 Flags);
1337 return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond), Flags);
1338 }
1339
1340 /// Helper function to make it easier to build Select's if you just have
1341 /// operands and don't want to check for vector.
1343 SDValue RHS, SDNodeFlags Flags = SDNodeFlags()) {
1344 assert(LHS.getValueType() == VT && RHS.getValueType() == VT &&
1345 "Cannot use select on differing types");
1346 auto Opcode = Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT;
1347 return getNode(Opcode, DL, VT, Cond, LHS, RHS, Flags);
1348 }
1349
1350 /// Helper function to make it easier to build SelectCC's if you just have an
1351 /// ISD::CondCode instead of an SDValue.
1353 SDValue False, ISD::CondCode Cond,
1354 SDNodeFlags Flags = SDNodeFlags()) {
1355 return getNode(ISD::SELECT_CC, DL, True.getValueType(), LHS, RHS, True,
1356 False, getCondCode(Cond), Flags);
1357 }
1358
1359 /// Try to simplify a select/vselect into 1 of its operands or a constant.
1361
1362 /// Try to simplify a shift into 1 of its operands or a constant.
1364
1365 /// Try to simplify a floating-point binary operation into 1 of its operands
1366 /// or a constant.
1367 LLVM_ABI SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y,
1368 SDNodeFlags Flags);
1369
1370 /// VAArg produces a result and token chain, and takes a pointer
1371 /// and a source value as input.
1372 LLVM_ABI SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1373 SDValue SV, unsigned Align);
1374
1375 /// Gets a node for an atomic cmpxchg op. There are two
1376 /// valid Opcodes. ISD::ATOMIC_CMO_SWAP produces the value loaded and a
1377 /// chain result. ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS produces the value loaded,
1378 /// a success flag (initially i1), and a chain.
1379 LLVM_ABI SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1380 SDVTList VTs, SDValue Chain, SDValue Ptr,
1381 SDValue Cmp, SDValue Swp,
1382 MachineMemOperand *MMO);
1383
1384 /// Gets a node for an atomic op, produces result (if relevant)
1385 /// and chain and takes 2 operands.
1386 LLVM_ABI SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1387 SDValue Chain, SDValue Ptr, SDValue Val,
1388 MachineMemOperand *MMO);
1389
1390 /// Gets a node for an atomic op, produces result and chain and takes N
1391 /// operands.
1392 LLVM_ABI SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1394 MachineMemOperand *MMO,
1396
1398 EVT MemVT, EVT VT, SDValue Chain, SDValue Ptr,
1399 MachineMemOperand *MMO);
1400
1401 /// Creates a MemIntrinsicNode that may produce a
1402 /// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
1403 /// INTRINSIC_W_CHAIN, or a target-specific memory-referencing opcode
1404 // (see `SelectionDAGTargetInfo::isTargetMemoryOpcode`).
1406 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1407 EVT MemVT, MachinePointerInfo PtrInfo, Align Alignment,
1411 const AAMDNodes &AAInfo = AAMDNodes());
1412
1414 unsigned Opcode, const SDLoc &dl, SDVTList VTList, ArrayRef<SDValue> Ops,
1415 EVT MemVT, MachinePointerInfo PtrInfo,
1416 MaybeAlign Alignment = std::nullopt,
1420 const AAMDNodes &AAInfo = AAMDNodes()) {
1421 // Ensure that codegen never sees alignment 0
1422 return getMemIntrinsicNode(Opcode, dl, VTList, Ops, MemVT, PtrInfo,
1423 Alignment.value_or(getEVTAlign(MemVT)), Flags,
1424 Size, AAInfo);
1425 }
1426
1427 LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl,
1429 EVT MemVT, MachineMemOperand *MMO);
1430
1431 /// getMemIntrinsicNode - Creates a MemIntrinsicNode with multiple MMOs.
1432 LLVM_ABI SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl,
1434 EVT MemVT,
1436
1437 /// Creates a LifetimeSDNode that starts (`IsStart==true`) or ends
1438 /// (`IsStart==false`) the lifetime of the `FrameIndex`.
1439 LLVM_ABI SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain,
1440 int FrameIndex);
1441
1442 /// Creates a PseudoProbeSDNode with function GUID `Guid` and
1443 /// the index of the block `Index` it is probing, as well as the attributes
1444 /// `attr` of the probe.
1446 uint64_t Guid, uint64_t Index,
1447 uint32_t Attr);
1448
1449 /// Create a MERGE_VALUES node from the given operands.
1451
1452 /// Return poison values for each of \p ResultTypes, substituting \p Chain
1453 /// for any result of type MVT::Other, merged into a single MERGE_VALUES
1454 /// node. Used to salvage a chain when an operation cannot be lowered due
1455 /// to an error, and the program will be discarded.
1457 const SDLoc &dl);
1458
1459 /// Loads are not normal binary operators: their result type is not
1460 /// determined by their operands, and they produce a value AND a token chain.
1461 ///
1462 /// This function will set the MOLoad flag on MMOFlags, but you can set it if
1463 /// you want. The MOStore flag must not be set.
1465 getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1466 MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(),
1468 const MMOMetadata &Metadata = MMOMetadata());
1469 LLVM_ABI SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1470 MachineMemOperand *MMO);
1472 getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1473 SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT,
1474 MaybeAlign Alignment = MaybeAlign(),
1476 const MMOMetadata &Metadata = MMOMetadata());
1477 LLVM_ABI SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1478 SDValue Chain, SDValue Ptr, EVT MemVT,
1479 MachineMemOperand *MMO);
1480 LLVM_ABI SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl,
1485 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1486 MachinePointerInfo PtrInfo, EVT MemVT, Align Alignment,
1488 const MMOMetadata &Metadata = MMOMetadata());
1489 inline SDValue
1491 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1492 MachinePointerInfo PtrInfo, EVT MemVT,
1493 MaybeAlign Alignment = MaybeAlign(),
1495 const MMOMetadata &Metadata = MMOMetadata()) {
1496 // Ensures that codegen never sees a None Alignment.
1497 return getLoad(AM, ExtType, VT, dl, Chain, Ptr, Offset, PtrInfo, MemVT,
1498 Alignment.value_or(getEVTAlign(MemVT)), MMOFlags, Metadata);
1499 }
1501 EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1502 SDValue Offset, EVT MemVT, MachineMemOperand *MMO);
1503
1504 /// Helper function to build ISD::STORE nodes.
1505 ///
1506 /// This function will set the MOStore flag on MMOFlags, but you can set it if
1507 /// you want. The MOLoad and MOInvariant flags must not be set.
1508
1510 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1511 MachinePointerInfo PtrInfo, Align Alignment,
1513 const MMOMetadata &Metadata = MMOMetadata());
1514 inline SDValue
1515 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1516 MachinePointerInfo PtrInfo, MaybeAlign Alignment = MaybeAlign(),
1518 const MMOMetadata &Metadata = MMOMetadata()) {
1519 return getStore(Chain, dl, Val, Ptr, PtrInfo,
1520 Alignment.value_or(getEVTAlign(Val.getValueType())),
1521 MMOFlags, Metadata);
1522 }
1523 LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1524 SDValue Ptr, MachineMemOperand *MMO);
1526 SDValue Ptr, SDValue Offset,
1527 MachineMemOperand *MMO);
1529 SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset,
1530 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1532 const MMOMetadata &Metadata = MMOMetadata());
1534 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1535 MachinePointerInfo PtrInfo, EVT SVT, Align Alignment,
1537 const MMOMetadata &Metadata = MMOMetadata());
1538 LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1539 SDValue Ptr, SDValue Offset, EVT SVT,
1540 MachineMemOperand *MMO);
1541
1542 inline SDValue
1543 getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1544 MachinePointerInfo PtrInfo, EVT SVT,
1545 MaybeAlign Alignment = MaybeAlign(),
1547 const MMOMetadata &Metadata = MMOMetadata()) {
1548 return getTruncStore(Chain, dl, Val, Ptr, PtrInfo, SVT,
1549 Alignment.value_or(getEVTAlign(SVT)), MMOFlags,
1550 Metadata);
1551 }
1552 LLVM_ABI SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1553 SDValue Ptr, EVT SVT, MachineMemOperand *MMO);
1554 LLVM_ABI SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl,
1557 LLVM_ABI SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1558 SDValue Ptr, SDValue Offset, EVT SVT,
1560 bool IsTruncating = false);
1561
1563 EVT VT, const SDLoc &dl, SDValue Chain,
1564 SDValue Ptr, SDValue Offset, SDValue Mask,
1565 SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT,
1566 Align Alignment, MachineMemOperand::Flags MMOFlags,
1567 const AAMDNodes &AAInfo,
1568 const MDNode *Ranges = nullptr,
1569 bool IsExpanding = false);
1570 inline SDValue
1572 const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1573 SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo, EVT MemVT,
1574 MaybeAlign Alignment = MaybeAlign(),
1576 const AAMDNodes &AAInfo = AAMDNodes(),
1577 const MDNode *Ranges = nullptr, bool IsExpanding = false) {
1578 // Ensures that codegen never sees a None Alignment.
1579 return getLoadVP(AM, ExtType, VT, dl, Chain, Ptr, Offset, Mask, EVL,
1580 PtrInfo, MemVT, Alignment.value_or(getEVTAlign(MemVT)),
1581 MMOFlags, AAInfo, Ranges, IsExpanding);
1582 }
1584 EVT VT, const SDLoc &dl, SDValue Chain,
1585 SDValue Ptr, SDValue Offset, SDValue Mask,
1586 SDValue EVL, EVT MemVT, MachineMemOperand *MMO,
1587 bool IsExpanding = false);
1588 LLVM_ABI SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain,
1589 SDValue Ptr, SDValue Mask, SDValue EVL,
1590 MachinePointerInfo PtrInfo, MaybeAlign Alignment,
1591 MachineMemOperand::Flags MMOFlags,
1592 const AAMDNodes &AAInfo,
1593 const MDNode *Ranges = nullptr,
1594 bool IsExpanding = false);
1595 LLVM_ABI SDValue getLoadVP(EVT VT, const SDLoc &dl, SDValue Chain,
1596 SDValue Ptr, SDValue Mask, SDValue EVL,
1597 MachineMemOperand *MMO, bool IsExpanding = false);
1599 ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1600 SDValue Ptr, SDValue Mask, SDValue EVL, MachinePointerInfo PtrInfo,
1601 EVT MemVT, MaybeAlign Alignment, MachineMemOperand::Flags MMOFlags,
1602 const AAMDNodes &AAInfo, bool IsExpanding = false);
1604 EVT VT, SDValue Chain, SDValue Ptr,
1605 SDValue Mask, SDValue EVL, EVT MemVT,
1606 MachineMemOperand *MMO,
1607 bool IsExpanding = false);
1608 LLVM_ABI SDValue getIndexedLoadVP(SDValue OrigLoad, const SDLoc &dl,
1611 LLVM_ABI SDValue getStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1612 SDValue Ptr, SDValue Offset, SDValue Mask,
1613 SDValue EVL, EVT MemVT, MachineMemOperand *MMO,
1614 ISD::MemIndexedMode AM, bool IsTruncating = false,
1615 bool IsCompressing = false);
1616 LLVM_ABI SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1617 SDValue Ptr, SDValue Mask, SDValue EVL,
1618 MachinePointerInfo PtrInfo, EVT SVT,
1619 Align Alignment,
1620 MachineMemOperand::Flags MMOFlags,
1621 const AAMDNodes &AAInfo,
1622 bool IsCompressing = false);
1623 LLVM_ABI SDValue getTruncStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val,
1624 SDValue Ptr, SDValue Mask, SDValue EVL,
1625 EVT SVT, MachineMemOperand *MMO,
1626 bool IsCompressing = false);
1627 LLVM_ABI SDValue getIndexedStoreVP(SDValue OrigStore, const SDLoc &dl,
1630
1632 ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &DL,
1633 SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Stride, SDValue Mask,
1634 SDValue EVL, EVT MemVT, MachineMemOperand *MMO, bool IsExpanding = false);
1636 SDValue Ptr, SDValue Stride, SDValue Mask,
1637 SDValue EVL, MachineMemOperand *MMO,
1638 bool IsExpanding = false);
1640 const SDLoc &DL, EVT VT, SDValue Chain,
1641 SDValue Ptr, SDValue Stride,
1642 SDValue Mask, SDValue EVL, EVT MemVT,
1643 MachineMemOperand *MMO,
1644 bool IsExpanding = false);
1646 SDValue Val, SDValue Ptr, SDValue Offset,
1647 SDValue Stride, SDValue Mask, SDValue EVL,
1648 EVT MemVT, MachineMemOperand *MMO,
1650 bool IsTruncating = false,
1651 bool IsCompressing = false);
1653 SDValue Val, SDValue Ptr,
1654 SDValue Stride, SDValue Mask,
1655 SDValue EVL, EVT SVT,
1656 MachineMemOperand *MMO,
1657 bool IsCompressing = false);
1658
1659 LLVM_ABI SDValue getGatherVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1661 ISD::MemIndexType IndexType);
1662 LLVM_ABI SDValue getScatterVP(SDVTList VTs, EVT VT, const SDLoc &dl,
1664 ISD::MemIndexType IndexType);
1665
1666 LLVM_ABI SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain,
1668 SDValue Src0, EVT MemVT,
1670 ISD::LoadExtType, bool IsExpanding = false);
1674 LLVM_ABI SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1676 EVT MemVT, MachineMemOperand *MMO,
1678 bool IsTruncating = false,
1679 bool IsCompressing = false);
1680 LLVM_ABI SDValue getIndexedMaskedStore(SDValue OrigStore, const SDLoc &dl,
1683 LLVM_ABI SDValue getMaskedGather(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1685 MachineMemOperand *MMO,
1686 ISD::MemIndexType IndexType,
1687 ISD::LoadExtType ExtTy);
1688 LLVM_ABI SDValue getMaskedScatter(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1690 MachineMemOperand *MMO,
1691 ISD::MemIndexType IndexType,
1692 bool IsTruncating = false);
1693 LLVM_ABI SDValue getMaskedHistogram(SDVTList VTs, EVT MemVT, const SDLoc &dl,
1695 MachineMemOperand *MMO,
1696 ISD::MemIndexType IndexType);
1697 LLVM_ABI SDValue getLoadFFVP(EVT VT, const SDLoc &DL, SDValue Chain,
1698 SDValue Ptr, SDValue Mask, SDValue EVL,
1699 MachineMemOperand *MMO);
1700
1701 LLVM_ABI SDValue getGetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr,
1702 EVT MemVT, MachineMemOperand *MMO);
1703 LLVM_ABI SDValue getSetFPEnv(SDValue Chain, const SDLoc &dl, SDValue Ptr,
1704 EVT MemVT, MachineMemOperand *MMO);
1705
1706 /// Construct a node to track a Value* through the backend.
1708
1709 /// Return an MDNodeSDNode which holds an MDNode.
1710 LLVM_ABI SDValue getMDNode(const MDNode *MD);
1711
1712 /// Return a bitcast using the SDLoc of the value operand, and casting to the
1713 /// provided type. Use getNode to set a custom SDLoc.
1715
1716 /// Return an AddrSpaceCastSDNode.
1717 LLVM_ABI SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr,
1718 unsigned SrcAS, unsigned DestAS);
1719
1720 /// Return a freeze using the SDLoc of the value operand.
1722
1723 /// Return a freeze of V if any of the demanded elts may be undef or poison.
1724 /// \p Kind can be used to selectively freeze poison and/or undef bits only.
1726 getFreeze(SDValue V, const APInt &DemandedElts,
1728
1729 /// Return an AssertAlignSDNode.
1731
1732 /// Swap N1 and N2 if Opcode is a commutative binary opcode
1733 /// and the canonical form expects the opposite order.
1734 LLVM_ABI void canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1,
1735 SDValue &N2) const;
1736
1737 /// Return the specified value casted to
1738 /// the target's desired shift amount type.
1740
1741 /// Expand the specified \c ISD::VAARG node as the Legalize pass would.
1743
1744 /// Expand the specified \c ISD::VACOPY node as the Legalize pass would.
1746
1747 /// Return a GlobalAddress of the function from the current module with
1748 /// name matching the given ExternalSymbol. Additionally can provide the
1749 /// matched function.
1750 /// Panic if the function doesn't exist.
1752 SDValue Op, Function **TargetFunction = nullptr);
1753
1754 /// *Mutate* the specified node in-place to have the
1755 /// specified operands. If the resultant node already exists in the DAG,
1756 /// this does not modify the specified node, instead it returns the node that
1757 /// already exists. If the resultant node does not exist in the DAG, the
1758 /// input node is returned. As a degenerate case, if you specify the same
1759 /// input operands as the node already has, the input node is returned.
1763 SDValue Op3);
1765 SDValue Op3, SDValue Op4);
1767 SDValue Op3, SDValue Op4, SDValue Op5);
1769
1770 /// Creates a new TokenFactor containing \p Vals. If \p Vals contains 64k
1771 /// values or more, move values into new TokenFactors in 64k-1 blocks, until
1772 /// the final TokenFactor has less than 64k operands.
1775
1776 /// *Mutate* the specified machine node's memory references to the provided
1777 /// list.
1780
1781 // Calculate divergence of node \p N based on its operands.
1783
1784 // Propagates the change in divergence to users
1786
1787 /// These are used for target selectors to *mutate* the
1788 /// specified node to have the specified return type, Target opcode, and
1789 /// operands. Note that target opcodes are stored as
1790 /// ~TargetOpcode in the node opcode field. The resultant node is returned.
1791 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT);
1792 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1793 SDValue Op1);
1794 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1795 SDValue Op1, SDValue Op2);
1796 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1797 SDValue Op1, SDValue Op2, SDValue Op3);
1798 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1800 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1801 EVT VT2);
1802 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1804 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1805 EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1806 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1807 EVT VT2, SDValue Op1, SDValue Op2);
1808 LLVM_ABI SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, SDVTList VTs,
1810
1811 /// This *mutates* the specified node to have the specified
1812 /// return type, opcode, and operands.
1813 LLVM_ABI SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
1815
1816 /// Mutate the specified strict FP node to its non-strict equivalent,
1817 /// unlinking the node from its chain and dropping the metadata arguments.
1818 /// The node must be a strict FP node.
1820
1821 /// These are used for target selectors to create a new node
1822 /// with specified return type(s), MachineInstr opcode, and operands.
1823 ///
1824 /// Note that getMachineNode returns the resultant node. If there is already
1825 /// a node of the specified opcode and operands, it returns that node instead
1826 /// of the current one.
1827 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1828 EVT VT);
1829 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1830 EVT VT, SDValue Op1);
1831 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1832 EVT VT, SDValue Op1, SDValue Op2);
1833 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1834 EVT VT, SDValue Op1, SDValue Op2,
1835 SDValue Op3);
1836 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1838 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1839 EVT VT1, EVT VT2, SDValue Op1,
1840 SDValue Op2);
1841 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1842 EVT VT1, EVT VT2, SDValue Op1,
1843 SDValue Op2, SDValue Op3);
1844 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1845 EVT VT1, EVT VT2,
1847 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1848 EVT VT1, EVT VT2, EVT VT3, SDValue Op1,
1849 SDValue Op2);
1850 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1851 EVT VT1, EVT VT2, EVT VT3, SDValue Op1,
1852 SDValue Op2, SDValue Op3);
1853 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1854 EVT VT1, EVT VT2, EVT VT3,
1856 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1857 ArrayRef<EVT> ResultTys,
1859 LLVM_ABI MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1861
1862 /// A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
1863 LLVM_ABI SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1864 SDValue Operand);
1865
1866 /// A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
1867 LLVM_ABI SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1868 SDValue Operand, SDValue Subreg);
1869
1870 /// Get the specified node if it's already available, or else return NULL.
1871 LLVM_ABI SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1873 const SDNodeFlags Flags,
1874 bool AllowCommute = false);
1875 LLVM_ABI SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList,
1877 bool AllowCommute = false);
1878
1879 /// Check if a node exists without modifying its flags.
1880 LLVM_ABI bool doesNodeExist(unsigned Opcode, SDVTList VTList,
1882
1883 /// Creates a SDDbgValue node.
1885 SDNode *N, unsigned R, bool IsIndirect,
1886 const DebugLoc &DL, unsigned O);
1887
1888 /// Creates a constant SDDbgValue node.
1890 const Value *C, const DebugLoc &DL,
1891 unsigned O);
1892
1893 /// Creates a FrameIndex SDDbgValue node.
1895 DIExpression *Expr, unsigned FI,
1896 bool IsIndirect,
1897 const DebugLoc &DL, unsigned O);
1898
1899 /// Creates a FrameIndex SDDbgValue node.
1901 DIExpression *Expr, unsigned FI,
1902 ArrayRef<SDNode *> Dependencies,
1903 bool IsIndirect,
1904 const DebugLoc &DL, unsigned O);
1905
1906 /// Creates a VReg SDDbgValue node.
1908 Register VReg, bool IsIndirect,
1909 const DebugLoc &DL, unsigned O);
1910
1911 /// Creates a SDDbgValue node from a list of locations.
1914 ArrayRef<SDNode *> Dependencies,
1915 bool IsIndirect, const DebugLoc &DL,
1916 unsigned O, bool IsVariadic);
1917
1918 /// Creates a SDDbgLabel node.
1920 unsigned O);
1921
1922 /// Transfer debug values from one node to another, while optionally
1923 /// generating fragment expressions for split-up values. If \p InvalidateDbg
1924 /// is set, debug values are invalidated after they are transferred.
1926 unsigned OffsetInBits = 0,
1927 unsigned SizeInBits = 0,
1928 bool InvalidateDbg = true);
1929
1930 /// Remove the specified node from the system. If any of its
1931 /// operands then becomes dead, remove them as well. Inform UpdateListener
1932 /// for each node deleted.
1934
1935 /// This method deletes the unreachable nodes in the
1936 /// given list, and any nodes that become unreachable as a result.
1938
1939 /// Modify anything using 'From' to use 'To' instead.
1940 /// This can cause recursive merging of nodes in the DAG. Use the first
1941 /// version if 'From' is known to have a single result, use the second
1942 /// if you have two nodes with identical results (or if 'To' has a superset
1943 /// of the results of 'From'), use the third otherwise.
1944 ///
1945 /// These methods all take an optional UpdateListener, which (if not null) is
1946 /// informed about nodes that are deleted and modified due to recursive
1947 /// changes in the dag.
1948 ///
1949 /// These functions only replace all existing uses. It's possible that as
1950 /// these replacements are being performed, CSE may cause the From node
1951 /// to be given new uses. These new uses of From are left in place, and
1952 /// not automatically transferred to To.
1953 ///
1955 LLVM_ABI void ReplaceAllUsesWith(SDNode *From, SDNode *To);
1956 LLVM_ABI void ReplaceAllUsesWith(SDNode *From, const SDValue *To);
1957
1958 /// Replace any uses of From with To, leaving
1959 /// uses of other values produced by From.getNode() alone.
1961
1962 /// Like ReplaceAllUsesOfValueWith, but for multiple values at once.
1963 /// This correctly handles the case where
1964 /// there is an overlap between the From values and the To values.
1966 const SDValue *To, unsigned Num);
1967
1968 /// If an existing load has uses of its chain, create a token factor node with
1969 /// that chain and the new memory node's chain and update users of the old
1970 /// chain to the token factor. This ensures that the new memory node will have
1971 /// the same relative memory dependency position as the old load. Returns the
1972 /// new merged load chain.
1974 SDValue NewMemOpChain);
1975
1976 /// If an existing load has uses of its chain, create a token factor node with
1977 /// that chain and the new memory node's chain and update users of the old
1978 /// chain to the token factor. This ensures that the new memory node will have
1979 /// the same relative memory dependency position as the old load. Returns the
1980 /// new merged load chain.
1982 SDValue NewMemOp);
1983
1984 /// Get all the nodes in their topological order without modifying any states.
1986 SmallVectorImpl<const SDNode *> &SortedNodes) const;
1987
1988 /// Topological-sort the AllNodes list and a
1989 /// assign a unique node id for each node in the DAG based on their
1990 /// topological order. Returns the number of nodes.
1992
1993 /// Move node N in the AllNodes list to be immediately
1994 /// before the given iterator Position. This may be used to update the
1995 /// topological ordering when the list of nodes is modified.
1997 AllNodes.insert(Position, AllNodes.remove(N));
1998 }
1999
2000 /// Add a dbg_value SDNode. If SD is non-null that means the
2001 /// value is produced by SD.
2002 LLVM_ABI void AddDbgValue(SDDbgValue *DB, bool isParameter);
2003
2004 /// Add a dbg_label SDNode.
2006
2007 /// Get the debug values which reference the given SDNode.
2009 return DbgInfo->getSDDbgValues(SD);
2010 }
2011
2012public:
2013 /// Return true if there are any SDDbgValue nodes associated
2014 /// with this SelectionDAG.
2015 bool hasDebugValues() const { return !DbgInfo->empty(); }
2016
2017 SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); }
2018 SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); }
2019
2021 return DbgInfo->ByvalParmDbgBegin();
2022 }
2024 return DbgInfo->ByvalParmDbgEnd();
2025 }
2026
2028 return DbgInfo->DbgLabelBegin();
2029 }
2031 return DbgInfo->DbgLabelEnd();
2032 }
2033
2034 /// To be invoked on an SDNode that is slated to be erased. This
2035 /// function mirrors \c llvm::salvageDebugInfo.
2037
2038 /// Dump the textual format of this DAG. Nodes are not sorted.
2039 /// Note that we overload it instead of using default value so that it is
2040 /// convenient to be called from debuggers.
2041 LLVM_ABI void dump() const;
2042
2043 /// Dump the textual format of this DAG. Print nodes in sorted orders if \p
2044 /// Sorted is true.
2045 LLVM_ABI void dump(bool Sorted) const;
2046
2047 /// In most cases this function returns the ABI alignment for a given type,
2048 /// except for illegal vector types where the alignment exceeds that of the
2049 /// stack. In such cases we attempt to break the vector down to a legal type
2050 /// and return the ABI alignment for that instead.
2051 LLVM_ABI Align getReducedAlign(EVT VT, bool UseABI);
2052
2053 /// Create a stack temporary based on the size in bytes and the alignment
2055
2056 /// Create a stack temporary, suitable for holding the specified value type.
2057 /// If minAlign is specified, the slot size will have at least that alignment.
2058 LLVM_ABI SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
2059
2060 /// Create a stack temporary suitable for holding either of the specified
2061 /// value types.
2063
2064 LLVM_ABI SDValue FoldSymbolOffset(unsigned Opcode, EVT VT,
2065 const GlobalAddressSDNode *GA,
2066 const SDNode *N2);
2067
2068 LLVM_ABI SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL,
2070 SDNodeFlags Flags = SDNodeFlags());
2071
2072 /// Fold floating-point operations when all operands are constants and/or
2073 /// undefined.
2074 LLVM_ABI SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT,
2076
2077 /// Fold BUILD_VECTOR of constants/undefs to the destination type
2078 /// BUILD_VECTOR of constants/undefs elements.
2080 const SDLoc &DL, EVT DstEltVT);
2081
2082 /// Constant fold a setcc to true or false.
2084 const SDLoc &dl, SDNodeFlags Flags = {});
2085
2086 /// Return true if the sign bit of Op is known to be zero.
2087 /// We use this predicate to simplify operations downstream.
2088 LLVM_ABI bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
2089
2090 /// Return true if the sign bit of Op is known to be zero, for a
2091 /// floating-point value.
2092 LLVM_ABI bool SignBitIsZeroFP(SDValue Op, unsigned Depth = 0) const;
2093
2094 /// Return true if 'Op & Mask' is known to be zero. We
2095 /// use this predicate to simplify operations downstream. Op and Mask are
2096 /// known to be the same type.
2097 LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
2098 unsigned Depth = 0) const;
2099
2100 /// Return true if 'Op & Mask' is known to be zero in DemandedElts. We
2101 /// use this predicate to simplify operations downstream. Op and Mask are
2102 /// known to be the same type.
2103 LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask,
2104 const APInt &DemandedElts,
2105 unsigned Depth = 0) const;
2106
2107 /// Return true if 'Op' is known to be zero in DemandedElts. We
2108 /// use this predicate to simplify operations downstream.
2109 LLVM_ABI bool MaskedVectorIsZero(SDValue Op, const APInt &DemandedElts,
2110 unsigned Depth = 0) const;
2111
2112 /// Return true if '(Op & Mask) == Mask'.
2113 /// Op and Mask are known to be the same type.
2114 LLVM_ABI bool MaskedValueIsAllOnes(SDValue Op, const APInt &Mask,
2115 unsigned Depth = 0) const;
2116
2117 /// For each demanded element of a vector, see if it is known to be zero.
2119 const APInt &DemandedElts,
2120 unsigned Depth = 0) const;
2121
2122 /// Determine which bits of Op are known to be either zero or one and return
2123 /// them in Known. For vectors, the known bits are those that are shared by
2124 /// every vector element.
2125 /// Targets can implement the computeKnownBitsForTargetNode method in the
2126 /// TargetLowering class to allow target nodes to be understood.
2127 LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth = 0) const;
2128
2129 /// Determine which bits of Op are known to be either zero or one and return
2130 /// them in Known. The DemandedElts argument allows us to only collect the
2131 /// known bits that are shared by the requested vector elements.
2132 /// Targets can implement the computeKnownBitsForTargetNode method in the
2133 /// TargetLowering class to allow target nodes to be understood.
2134 LLVM_ABI KnownBits computeKnownBits(SDValue Op, const APInt &DemandedElts,
2135 unsigned Depth = 0) const;
2136
2137 /// Determine the possible constant range of an integer or vector of integers.
2138 LLVM_ABI ConstantRange computeConstantRange(SDValue Op, bool ForSigned,
2139 unsigned Depth = 0) const;
2140
2141 /// Determine the possible constant range of an integer or vector of integers.
2142 /// The DemandedElts argument allows us to only collect the known ranges that
2143 /// are shared by the requested vector elements.
2145 const APInt &DemandedElts,
2146 bool ForSigned,
2147 unsigned Depth = 0) const;
2148
2149 /// Combine constant ranges from computeConstantRange() and
2150 /// computeKnownBits().
2152 SDValue Op, bool ForSigned, unsigned Depth = 0) const;
2153
2154 /// Combine constant ranges from computeConstantRange() and
2155 /// computeKnownBits(). The DemandedElts argument allows us to only collect
2156 /// the known ranges that are shared by the requested vector elements.
2158 SDValue Op, const APInt &DemandedElts, bool ForSigned,
2159 unsigned Depth = 0) const;
2160
2161 /// Used to represent the possible overflow behavior of an operation.
2162 /// Never: the operation cannot overflow.
2163 /// Always: the operation will always overflow.
2164 /// Sometime: the operation may or may not overflow.
2170
2171 /// Determine if the result of the signed addition of 2 nodes can overflow.
2173 SDValue N1) const;
2174
2175 /// Determine if the result of the unsigned addition of 2 nodes can overflow.
2177 SDValue N1) const;
2178
2179 /// Determine if the result of the addition of 2 nodes can overflow.
2181 SDValue N1) const {
2182 return IsSigned ? computeOverflowForSignedAdd(N0, N1)
2184 }
2185
2186 /// Determine if the result of the addition of 2 nodes can never overflow.
2187 bool willNotOverflowAdd(bool IsSigned, SDValue N0, SDValue N1) const {
2188 return computeOverflowForAdd(IsSigned, N0, N1) == OFK_Never;
2189 }
2190
2191 /// Determine if the result of the signed sub of 2 nodes can overflow.
2193 SDValue N1) const;
2194
2195 /// Determine if the result of the unsigned sub of 2 nodes can overflow.
2197 SDValue N1) const;
2198
2199 /// Determine if the result of the sub of 2 nodes can overflow.
2201 SDValue N1) const {
2202 return IsSigned ? computeOverflowForSignedSub(N0, N1)
2204 }
2205
2206 /// Determine if the result of the sub of 2 nodes can never overflow.
2207 bool willNotOverflowSub(bool IsSigned, SDValue N0, SDValue N1) const {
2208 return computeOverflowForSub(IsSigned, N0, N1) == OFK_Never;
2209 }
2210
2211 /// Determine if the result of the signed mul of 2 nodes can overflow.
2213 SDValue N1) const;
2214
2215 /// Determine if the result of the unsigned mul of 2 nodes can overflow.
2217 SDValue N1) const;
2218
2219 /// Determine if the result of the mul of 2 nodes can overflow.
2221 SDValue N1) const {
2222 return IsSigned ? computeOverflowForSignedMul(N0, N1)
2224 }
2225
2226 /// Determine if the result of the mul of 2 nodes can never overflow.
2227 bool willNotOverflowMul(bool IsSigned, SDValue N0, SDValue N1) const {
2228 return computeOverflowForMul(IsSigned, N0, N1) == OFK_Never;
2229 }
2230
2231 /// Returns true if \p V is an identity element of Opc with Flags.
2232 /// When OperandNo is 0, it checks that V is a left identity. Otherwise, it
2233 /// checks that V is a right identity.
2234 LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V,
2235 unsigned OperandNo, unsigned Depth = 0) const;
2236
2237 /// Returns true if the demanded vector elements of \p V is an identity
2238 /// element of Opc with Flags. When OperandNo is 0, it checks that V is a left
2239 /// identity. Otherwise, it checks that V is a right identity.
2240 LLVM_ABI bool isIdentityElement(unsigned Opc, SDNodeFlags Flags, SDValue V,
2241 const APInt &DemandedElts, unsigned OperandNo,
2242 unsigned Depth = 0) const;
2243
2244 /// Test if the given value is known to have exactly one bit set. This differs
2245 /// from computeKnownBits in that it doesn't necessarily determine which bit
2246 /// is set. If 'OrZero' is set, then return true if the given value is either
2247 /// a power of two or zero.
2248 LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, bool OrZero = false,
2249 unsigned Depth = 0) const;
2250
2251 /// Test if the given value is known to have exactly one bit set. This differs
2252 /// from computeKnownBits in that it doesn't necessarily determine which bit
2253 /// is set. The DemandedElts argument allows us to only collect the minimum
2254 /// sign bits of the requested vector elements. If 'OrZero' is set, then
2255 /// return true if the given value is either a power of two or zero.
2256 LLVM_ABI bool isKnownToBeAPowerOfTwo(SDValue Val, const APInt &DemandedElts,
2257 bool OrZero = false,
2258 unsigned Depth = 0) const;
2259
2260 /// Test if the given _fp_ value is known to be an integer power-of-2, either
2261 /// positive or negative.
2262 LLVM_ABI bool isKnownToBeAPowerOfTwoFP(SDValue Val, unsigned Depth = 0) const;
2263
2264 /// Return the number of times the sign bit of the register is replicated into
2265 /// the other bits. We know that at least 1 bit is always equal to the sign
2266 /// bit (itself), but other cases can give us information. For example,
2267 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2268 /// to each other, so we return 3. Targets can implement the
2269 /// ComputeNumSignBitsForTarget method in the TargetLowering class to allow
2270 /// target nodes to be understood.
2271 LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
2272
2273 /// Return the number of times the sign bit of the register is replicated into
2274 /// the other bits. We know that at least 1 bit is always equal to the sign
2275 /// bit (itself), but other cases can give us information. For example,
2276 /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
2277 /// to each other, so we return 3. The DemandedElts argument allows
2278 /// us to only collect the minimum sign bits of the requested vector elements.
2279 /// Targets can implement the ComputeNumSignBitsForTarget method in the
2280 /// TargetLowering class to allow target nodes to be understood.
2281 LLVM_ABI unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
2282 unsigned Depth = 0) const;
2283
2284 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2285 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2286 /// Similar to the APInt::getSignificantBits function.
2287 /// Helper wrapper to ComputeNumSignBits.
2289 unsigned Depth = 0) const;
2290
2291 /// Get the upper bound on bit size for this Value \p Op as a signed integer.
2292 /// i.e. x == sext(trunc(x to MaxSignedBits) to bitwidth(x)).
2293 /// Similar to the APInt::getSignificantBits function.
2294 /// Helper wrapper to ComputeNumSignBits.
2296 const APInt &DemandedElts,
2297 unsigned Depth = 0) const;
2298
2299 /// Return true if this function can prove that \p Op is never poison
2300 /// and, \p Kind can be used to track poison and/or undef bits.
2303 unsigned Depth = 0) const;
2304
2305 /// Return true if this function can prove that \p Op is never poison
2306 /// and, \p Kind can be used to track poison and/or undef bits. The
2307 /// DemandedElts argument limits the check to the requested vector elements.
2309 SDValue Op, const APInt &DemandedElts,
2311 unsigned Depth = 0) const;
2312
2313 /// Return true if this function can prove that \p Op is never poison.
2318
2319 /// Return true if this function can prove that \p Op is never poison. The
2320 /// DemandedElts argument limits the check to the requested vector elements.
2321 bool isGuaranteedNotToBePoison(SDValue Op, const APInt &DemandedElts,
2322 unsigned Depth = 0) const {
2323 return isGuaranteedNotToBeUndefOrPoison(Op, DemandedElts,
2325 }
2326
2327 /// Return true if Op can create undef or poison from non-undef & non-poison
2328 /// operands. The DemandedElts argument limits the check to the requested
2329 /// vector elements.
2330 ///
2331 /// \p ConsiderFlags controls whether poison producing flags on the
2332 /// instruction are considered. This can be used to see if the instruction
2333 /// could still introduce undef or poison even without poison generating flags
2334 /// which might be on the instruction. (i.e. could the result of
2335 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2336 LLVM_ABI bool
2337 canCreateUndefOrPoison(SDValue Op, const APInt &DemandedElts,
2339 bool ConsiderFlags = true, unsigned Depth = 0) const;
2340
2341 /// Return true if Op can create undef or poison from non-undef & non-poison
2342 /// operands.
2343 ///
2344 /// \p ConsiderFlags controls whether poison producing flags on the
2345 /// instruction are considered. This can be used to see if the instruction
2346 /// could still introduce undef or poison even without poison generating flags
2347 /// which might be on the instruction. (i.e. could the result of
2348 /// Op->dropPoisonGeneratingFlags() still create poison or undef)
2349 LLVM_ABI bool
2352 bool ConsiderFlags = true, unsigned Depth = 0) const;
2353
2354 /// Return true if the specified operand is an ISD::OR or ISD::XOR node
2355 /// that can be treated as an ISD::ADD node.
2356 /// or(x,y) == add(x,y) iff haveNoCommonBitsSet(x,y)
2357 /// xor(x,y) == add(x,y) iff isMinSignedConstant(y) && !NoWrap
2358 /// If \p NoWrap is true, this will not match ISD::XOR.
2359 LLVM_ABI bool isADDLike(SDValue Op, bool NoWrap = false) const;
2360
2361 /// Return true if the specified operand is an ISD::ADD with a ConstantSDNode
2362 /// on the right-hand side, or if it is an ISD::OR with a ConstantSDNode that
2363 /// is guaranteed to have the same semantics as an ADD. This handles the
2364 /// equivalence:
2365 /// X|Cst == X+Cst iff X&Cst = 0.
2367
2368 /// Determine floating-point class information about \p Op. For vectors, the
2369 /// known FP classes are those shared by every demanded vector element.
2370 /// \p InterestedClasses is a hint for which FP classes we care about;
2371 /// the implementation may bail out early if it can determine that
2372 /// none of the interested classes are possible.
2374 FPClassTest InterestedClasses,
2375 unsigned Depth = 0) const;
2376
2377 /// Determine floating-point class information about \p Op. The
2378 /// DemandedElts argument allows us to only collect the known FP classes
2379 /// that are shared by the requested vector elements.
2380 /// \p InterestedClasses is a hint for which FP classes we care about.
2382 const APInt &DemandedElts,
2383 FPClassTest InterestedClasses,
2384 unsigned Depth = 0) const;
2385
2386 /// Test whether the given SDValue (or all elements of it, if it is a
2387 /// vector) is known to never be NaN in \p DemandedElts. If \p SNaN is true,
2388 /// returns if \p Op is known to never be a signaling NaN (it may still be a
2389 /// qNaN).
2390 LLVM_ABI bool isKnownNeverNaN(SDValue Op, const APInt &DemandedElts,
2391 bool SNaN = false, unsigned Depth = 0) const;
2392
2393 /// Test whether the given SDValue (or all elements of it, if it is a
2394 /// vector) is known to never be NaN. If \p SNaN is true, returns if \p Op is
2395 /// known to never be a signaling NaN (it may still be a qNaN).
2396 LLVM_ABI bool isKnownNeverNaN(SDValue Op, bool SNaN = false,
2397 unsigned Depth = 0) const;
2398
2399 /// \returns true if \p Op is known to never be a signaling NaN in \p
2400 /// DemandedElts.
2401 bool isKnownNeverSNaN(SDValue Op, const APInt &DemandedElts,
2402 unsigned Depth = 0) const {
2403 return isKnownNeverNaN(Op, DemandedElts, true, Depth);
2404 }
2405
2406 /// \returns true if \p Op is known to never be a signaling NaN.
2407 bool isKnownNeverSNaN(SDValue Op, unsigned Depth = 0) const {
2408 return isKnownNeverNaN(Op, true, Depth);
2409 }
2410
2411 /// Test whether the given floating point SDValue (or all elements of it, if
2412 /// it is a vector) is known to never be interpretable as zero in \p
2413 /// DemandedElts.
2414 LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, const APInt &DemandedElts,
2415 unsigned Depth = 0) const;
2416
2417 /// Test whether the given floating point SDValue (or all elements of it, if
2418 /// it is a vector) is known to never be interpretable as zero.
2419 LLVM_ABI bool isKnownNeverLogicalZero(SDValue Op, unsigned Depth = 0) const;
2420
2421 /// Test whether the given SDValue is known to contain non-zero value(s).
2422 LLVM_ABI bool isKnownNeverZero(SDValue Op, unsigned Depth = 0) const;
2423
2424 /// Test whether the given SDValue is known to contain non-zero value(s).
2425 /// The DemandedElts argument limits the check to the requested vector
2426 /// elements.
2427 LLVM_ABI bool isKnownNeverZero(SDValue Op, const APInt &DemandedElts,
2428 unsigned Depth = 0) const;
2429
2430 /// Test whether the given float value is known to be positive. +0.0, +inf and
2431 /// +nan are considered positive, -0.0, -inf and -nan are not.
2433
2434 /// Check if a use of a float value is insensitive to signed zeros.
2435 LLVM_ABI bool canIgnoreSignBitOfZero(const SDUse &Use) const;
2436
2437 /// Check if \p Op has no-signed-zeros, or all users (limited to checking two
2438 /// for compile-time performance) are insensitive to signed zeros.
2440
2441 /// Test whether two SDValues are known to compare equal. This
2442 /// is true if they are the same value, or if one is negative zero and the
2443 /// other positive zero.
2444 LLVM_ABI bool isEqualTo(SDValue A, SDValue B) const;
2445
2446 /// Return true if A and B have no common bits set. As an example, this can
2447 /// allow an 'add' to be transformed into an 'or'.
2449
2450 /// Test whether \p V has a splatted value for all the demanded elements.
2451 ///
2452 /// On success \p UndefElts will indicate the elements that have UNDEF
2453 /// values instead of the splat value, this is only guaranteed to be correct
2454 /// for \p DemandedElts.
2455 ///
2456 /// NOTE: The function will return true for a demanded splat of UNDEF values.
2457 LLVM_ABI bool isSplatValue(SDValue V, const APInt &DemandedElts,
2458 APInt &UndefElts, unsigned Depth = 0) const;
2459
2460 /// Test whether \p V has a splatted value.
2461 LLVM_ABI bool isSplatValue(SDValue V, bool AllowUndefs = false) const;
2462
2463 /// If V is a splatted value, return the source vector and its splat index.
2464 LLVM_ABI SDValue getSplatSourceVector(SDValue V, int &SplatIndex);
2465
2466 /// If V is a splat vector, return its scalar source operand by extracting
2467 /// that element from the source vector. If LegalTypes is true, this method
2468 /// may only return a legally-typed splat value. If it cannot legalize the
2469 /// splatted value it will return SDValue().
2470 LLVM_ABI SDValue getSplatValue(SDValue V, bool LegalTypes = false);
2471
2472 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2473 /// element bit-width of the shift node, return the valid constant range.
2474 LLVM_ABI std::optional<ConstantRange>
2475 getValidShiftAmountRange(SDValue V, const APInt &DemandedElts,
2476 unsigned Depth) const;
2477
2478 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2479 /// that is less than the element bit-width of the shift node, return it.
2480 LLVM_ABI std::optional<unsigned>
2481 getValidShiftAmount(SDValue V, const APInt &DemandedElts,
2482 unsigned Depth = 0) const;
2483
2484 /// If a SHL/SRA/SRL node \p V has a uniform shift amount
2485 /// that is less than the element bit-width of the shift node, return it.
2486 LLVM_ABI std::optional<unsigned>
2487 getValidShiftAmount(SDValue V, unsigned Depth = 0) const;
2488
2489 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2490 /// element bit-width of the shift node, return the minimum possible value.
2491 LLVM_ABI std::optional<unsigned>
2492 getValidMinimumShiftAmount(SDValue V, const APInt &DemandedElts,
2493 unsigned Depth = 0) const;
2494
2495 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2496 /// element bit-width of the shift node, return the minimum possible value.
2497 LLVM_ABI std::optional<unsigned>
2498 getValidMinimumShiftAmount(SDValue V, unsigned Depth = 0) const;
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 maximum possible value.
2502 LLVM_ABI std::optional<unsigned>
2503 getValidMaximumShiftAmount(SDValue V, const APInt &DemandedElts,
2504 unsigned Depth = 0) const;
2505
2506 /// If a SHL/SRA/SRL node \p V has shift amounts that are all less than the
2507 /// element bit-width of the shift node, return the maximum possible value.
2508 LLVM_ABI std::optional<unsigned>
2509 getValidMaximumShiftAmount(SDValue V, unsigned Depth = 0) const;
2510
2511 /// Match a binop + shuffle pyramid that represents a horizontal reduction
2512 /// over the elements of a vector starting from the EXTRACT_VECTOR_ELT node /p
2513 /// Extract. The reduction must use one of the opcodes listed in /p
2514 /// CandidateBinOps and on success /p BinOp will contain the matching opcode.
2515 /// Returns the vector that is being reduced on, or SDValue() if a reduction
2516 /// was not matched. If \p AllowPartials is set then in the case of a
2517 /// reduction pattern that only matches the first few stages, the extracted
2518 /// subvector of the start of the reduction is returned.
2520 ArrayRef<ISD::NodeType> CandidateBinOps,
2521 bool AllowPartials = false);
2522
2523 /// Utility function used by legalize and lowering to
2524 /// "unroll" a vector operation by splitting out the scalars and operating
2525 /// on each element individually. If the ResNE is 0, fully unroll the vector
2526 /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
2527 /// If the ResNE is greater than the width of the vector op, unroll the
2528 /// vector op and fill the end of the resulting vector with UNDEFS.
2529 LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
2530
2531 /// Like UnrollVectorOp(), but for the [US](ADD|SUB|MUL)O family of opcodes.
2532 /// This is a separate function because those opcodes have two results.
2533 LLVM_ABI std::pair<SDValue, SDValue>
2534 UnrollVectorOverflowOp(SDNode *N, unsigned ResNE = 0);
2535
2536 /// Return true if loads are next to each other and can be
2537 /// merged. Check that both are nonvolatile and if LD is loading
2538 /// 'Bytes' bytes from a location that is 'Dist' units away from the
2539 /// location that the 'Base' load is loading from.
2541 unsigned Bytes, int Dist) const;
2542
2543 /// Infer alignment of a load / store address. Return std::nullopt if it
2544 /// cannot be inferred.
2546
2547 /// Split the scalar node with EXTRACT_ELEMENT using the provided VTs and
2548 /// return the low/high part.
2549 LLVM_ABI std::pair<SDValue, SDValue> SplitScalar(const SDValue &N,
2550 const SDLoc &DL,
2551 const EVT &LoVT,
2552 const EVT &HiVT);
2553
2554 /// Compute the VTs needed for the low/hi parts of a type
2555 /// which is split (or expanded) into two not necessarily identical pieces.
2556 LLVM_ABI std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const;
2557
2558 /// Compute the VTs needed for the low/hi parts of a type, dependent on an
2559 /// enveloping VT that has been split into two identical pieces. Sets the
2560 /// HisIsEmpty flag when hi type has zero storage size.
2561 LLVM_ABI std::pair<EVT, EVT> GetDependentSplitDestVTs(const EVT &VT,
2562 const EVT &EnvVT,
2563 bool *HiIsEmpty) const;
2564
2565 /// Split the vector with EXTRACT_SUBVECTOR using the provided
2566 /// VTs and return the low/high part.
2567 LLVM_ABI std::pair<SDValue, SDValue> SplitVector(const SDValue &N,
2568 const SDLoc &DL,
2569 const EVT &LoVT,
2570 const EVT &HiVT);
2571
2572 /// Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
2573 std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
2574 EVT LoVT, HiVT;
2575 std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
2576 return SplitVector(N, DL, LoVT, HiVT);
2577 }
2578
2579 /// Split the explicit vector length parameter of a VP operation.
2580 LLVM_ABI std::pair<SDValue, SDValue> SplitEVL(SDValue N, EVT VecVT,
2581 const SDLoc &DL);
2582
2583 /// Split the node's operand with EXTRACT_SUBVECTOR and
2584 /// return the low/high part.
2585 std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
2586 {
2587 return SplitVector(N->getOperand(OpNo), SDLoc(N));
2588 }
2589
2590 /// Widen the vector up to the next power of two using INSERT_SUBVECTOR.
2591 LLVM_ABI SDValue WidenVector(const SDValue &N, const SDLoc &DL);
2592
2593 /// Append the extracted elements from Start to Count out of the vector Op in
2594 /// Args. If Count is 0, all of the elements will be extracted. The extracted
2595 /// elements will have type EVT if it is provided, and otherwise their type
2596 /// will be Op's element type.
2599 unsigned Start = 0, unsigned Count = 0,
2600 EVT EltVT = EVT());
2601
2602 /// Compute the default alignment value for the given type.
2603 LLVM_ABI Align getEVTAlign(EVT MemoryVT) const;
2604
2605 /// Test whether the given value is a constant int or similar node.
2606 LLVM_ABI bool
2608 bool AllowOpaques = true) const;
2609
2610 /// Test whether the given value is a constant FP or similar node.
2612
2613 /// \returns true if \p N is any kind of constant or build_vector of
2614 /// constants, int or float. If a vector, it may not necessarily be a splat.
2619
2620 /// Check if a value \op N is a constant using the target's BooleanContent for
2621 /// its type.
2622 LLVM_ABI std::optional<bool> isBoolConstant(SDValue N) const;
2623
2624 /// Set CallSiteInfo to be associated with Node.
2625 void addCallSiteInfo(const SDNode *Node, CallSiteInfo &&CallInfo) {
2626 SDEI[Node].CSInfo = std::move(CallInfo);
2627 }
2628 /// Return CallSiteInfo associated with Node, or a default if none exists.
2629 CallSiteInfo getCallSiteInfo(const SDNode *Node) {
2630 auto I = SDEI.find(Node);
2631 return I != SDEI.end() ? std::move(I->second).CSInfo : CallSiteInfo();
2632 }
2633 /// Set HeapAllocSite to be associated with Node.
2635 SDEI[Node].HeapAllocSite = MD;
2636 }
2637 /// Return HeapAllocSite associated with Node, or nullptr if none exists.
2639 auto I = SDEI.find(Node);
2640 return I != SDEI.end() ? I->second.HeapAllocSite : nullptr;
2641 }
2642 /// Set PCSections to be associated with Node.
2643 void addPCSections(const SDNode *Node, MDNode *MD) {
2644 SDEI[Node].PCSections = MD;
2645 }
2646 /// Set MMRAMetadata to be associated with Node.
2647 void addMMRAMetadata(const SDNode *Node, MDNode *MMRA) {
2648 SDEI[Node].MMRA = MMRA;
2649 }
2650 /// Return PCSections associated with Node, or nullptr if none exists.
2652 auto It = SDEI.find(Node);
2653 return It != SDEI.end() ? It->second.PCSections : nullptr;
2654 }
2655 /// Return the MMRA MDNode associated with Node, or nullptr if none
2656 /// exists.
2658 auto It = SDEI.find(Node);
2659 return It != SDEI.end() ? It->second.MMRA : nullptr;
2660 }
2661 /// Set CalledGlobal to be associated with Node.
2662 void addCalledGlobal(const SDNode *Node, const GlobalValue *GV,
2663 unsigned OpFlags) {
2664 SDEI[Node].CalledGlobal = {GV, OpFlags};
2665 }
2666 /// Return CalledGlobal associated with Node, or a nullopt if none exists.
2667 std::optional<CalledGlobalInfo> getCalledGlobal(const SDNode *Node) {
2668 auto I = SDEI.find(Node);
2669 return I != SDEI.end()
2670 ? std::make_optional(std::move(I->second).CalledGlobal)
2671 : std::nullopt;
2672 }
2673 /// Set NoMergeSiteInfo to be associated with Node if NoMerge is true.
2674 void addNoMergeSiteInfo(const SDNode *Node, bool NoMerge) {
2675 if (NoMerge)
2676 SDEI[Node].NoMerge = NoMerge;
2677 }
2678 /// Return NoMerge info associated with Node.
2679 bool getNoMergeSiteInfo(const SDNode *Node) const {
2680 auto I = SDEI.find(Node);
2681 return I != SDEI.end() ? I->second.NoMerge : false;
2682 }
2683
2684 /// Copy extra info associated with one node to another.
2685 LLVM_ABI void copyExtraInfo(SDNode *From, SDNode *To);
2686
2687 /// Return the current function's default denormal handling kind for the given
2688 /// floating point type.
2690 return MF->getDenormalMode(VT.getFltSemantics());
2691 }
2692
2693 LLVM_ABI bool shouldOptForSize() const;
2694
2695 /// Get the (commutative) identity element for the given opcode, if it exists.
2696 LLVM_ABI SDValue getIdentityElement(unsigned Opcode, const SDLoc &DL, EVT VT,
2697 SDNodeFlags Flags);
2698
2699 /// Get an expression that implements a partial multiply-subtract reduction.
2700 /// In practice this means that parts of the expression are negated, e.g.
2701 ///
2702 /// partial_reduce_fmls acc, lhs, rhs
2703 /// <=> partial_reduce_fmla acc, lhs, -rhs
2704 ///
2705 /// partial_reduce_umls acc, lhs, rhs
2706 /// <=> -partial_reduce_umla -acc, lhs, rhs
2708 SDValue Acc, SDValue LHS, SDValue RHS);
2709
2710 /// Some opcodes may create immediate undefined behavior when used with some
2711 /// values (integer division-by-zero for example). Therefore, these operations
2712 /// are not generally safe to move around or change.
2713 bool isSafeToSpeculativelyExecute(unsigned Opcode) const {
2714 switch (Opcode) {
2715 case ISD::SDIV:
2716 case ISD::SREM:
2717 case ISD::SDIVREM:
2718 case ISD::UDIV:
2719 case ISD::UREM:
2720 case ISD::UDIVREM:
2721 return false;
2722 default:
2723 return true;
2724 }
2725 }
2726
2727 /// Check if the provided node is save to speculatively executed given its
2728 /// current arguments. So, while `udiv` the opcode is not safe to
2729 /// speculatively execute, a given `udiv` node may be if the denominator is
2730 /// known nonzero.
2732 switch (N->getOpcode()) {
2733 case ISD::UDIV:
2734 return isKnownNeverZero(N->getOperand(1));
2735 default:
2736 return isSafeToSpeculativelyExecute(N->getOpcode());
2737 }
2738 }
2739
2740 LLVM_ABI SDValue makeStateFunctionCall(unsigned LibFunc, SDValue Ptr,
2741 SDValue InChain, const SDLoc &DLoc);
2742
2743private:
2744#ifndef NDEBUG
2745 void verifyNode(SDNode *N) const;
2746#endif
2747 void InsertNode(SDNode *N);
2748 bool RemoveNodeFromCSEMaps(SDNode *N);
2749 void AddModifiedNodeToCSEMaps(SDNode *N);
2750 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
2751 SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
2752 void *&InsertPos);
2753 SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops,
2754 void *&InsertPos);
2755 SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc);
2756
2757 void DeleteNodeNotInCSEMaps(SDNode *N);
2758 void DeallocateNode(SDNode *N);
2759
2760 void allnodes_clear();
2761
2762 /// Look up the node specified by ID in CSEMap. If it exists, return it. If
2763 /// not, return the insertion token that will make insertion faster. This
2764 /// overload is for nodes other than Constant or ConstantFP, use the other one
2765 /// for those.
2766 SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos);
2767
2768 /// Look up the node specified by ID in CSEMap. If it exists, return it. If
2769 /// not, return the insertion token that will make insertion faster. Performs
2770 /// additional processing for constant nodes.
2771 SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, const SDLoc &DL,
2772 void *&InsertPos);
2773
2774 /// Maps to auto-CSE operations.
2775 std::vector<CondCodeSDNode*> CondCodeNodes;
2776
2777 std::vector<SDNode*> ValueTypeNodes;
2778 std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
2779 StringMap<SDNode*> ExternalSymbols;
2780
2781 std::map<std::pair<std::string, unsigned>, SDNode *> TargetExternalSymbols;
2783
2784 FlagInserter *Inserter = nullptr;
2785};
2786
2787template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
2789
2791 return nodes_iterator(G->allnodes_begin());
2792 }
2793
2795 return nodes_iterator(G->allnodes_end());
2796 }
2797};
2798
2799} // end namespace llvm
2800
2801#endif // LLVM_CODEGEN_SELECTIONDAG_H
return SDValue()
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
This file defines the StringMap class.
unsigned 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:857
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:215
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
Definition Compiler.h:678
@ CallSiteInfo
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This file defines a hash set that can be used to remove duplication of nodes in a graph.
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.
const SmallVectorImpl< MachineOperand > & 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
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:43
DWARF expression.
Base class for variables.
A parsed version of the target data layout string in and methods for querying it.
Definition DataLayout.h:64
A debug info location.
Definition DebugLoc.h:126
Implements a dense probed hash-table based set.
Definition DenseSet.h:281
This class is used to gather all the unique data bits of a node.
Definition FoldingSet.h:211
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
Data structure describing the variable locations in a function.
This is an important class for using LLVM in a threaded context.
Definition LLVMContext.h:68
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:1069
Abstract base class for all machine specific constantpool value subclasses.
A description of a memory reference used in the backend.
Flags
Flags values. These may be or'd together.
@ MOLoad
The memory access reads data.
@ MOStore
The memory access writes data.
This class contains meta information specific to a module.
An SDNode that represents everything that will be needed to construct a MachineInstr.
Root of the metadata hierarchy.
Definition Metadata.h:64
The optimization diagnostic interface.
Pass interface - Implemented by all 'passes'.
Definition Pass.h:99
Analysis providing profile information.
RecyclingAllocator - This class wraps an Allocator, adding the functionality of recycling deleted obj...
Wrapper class representing virtual and physical registers.
Definition Register.h: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 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)
const RTLIB::RuntimeLibcallsInfo & getRuntimeLibcallInfo() const
bool isKnownNeverSNaN(SDValue Op, unsigned Depth=0) const
LLVM_ABI SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS, unsigned DestAS)
Return an AddrSpaceCastSDNode.
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 std::optional< bool > isBoolConstant(SDValue N) const
Check if a value \op N is a constant using the target's BooleanContent for its type.
LLVM_ABI SDValue getStackArgumentTokenFactor(SDValue Chain)
Compute a TokenFactor to force all the incoming stack arguments to be loaded from the stack.
const TargetSubtargetInfo & getSubtarget() const
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N)
const Pass * getPass() const
LLVM_ABI 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.
OptimizationRemarkEmitter & getORE() const
BlockFrequencyInfo * getBFI() const
LLVM_ABI SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL)
LLVM_ABI void updateDivergence(SDNode *N)
LLVM_ABI SDValue getSplatValue(SDValue V, bool LegalTypes=false)
If V is a splat vector, return its scalar source operand by extracting that element from the source v...
LLVM_ABI SDValue 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 void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, Pass *PassPtr, const TargetLibraryInfo *LibraryInfo, const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs)
Prepare this SelectionDAG to process code in the given MachineFunction.
LLVM_ABI SelectionDAG(const TargetMachine &TM, CodeGenOptLevel)
LLVM_ABI SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Align Alignment, bool isVol, bool AlwaysInline, const CallInst *CI, MachinePointerInfo DstPtrInfo, const AAMDNodes &AAInfo=AAMDNodes())
LLVM_ABI SDValue getBitcastedSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by first bitcasting (from potentia...
LLVM_ABI SDValue getConstantPool(const Constant *C, EVT VT, MaybeAlign Align=std::nullopt, int Offs=0, bool isT=false, unsigned TargetFlags=0)
LLVM_ABI SDValue getStridedLoadVP(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT, const SDLoc &DL, SDValue Chain, SDValue Ptr, SDValue Offset, SDValue Stride, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, bool IsExpanding=false)
SDDbgInfo::DbgIterator ByvalParmDbgEnd() const
LLVM_ABI SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDVTList VTs, SDValue Chain, SDValue Ptr, SDValue Cmp, SDValue Swp, MachineMemOperand *MMO)
Gets a node for an atomic cmpxchg op.
MachineModuleInfo * getMMI() const
LLVM_ABI SDValue makeEquivalentMemoryOrdering(SDValue OldChain, SDValue NewMemOpChain)
If an existing load has uses of its chain, create a token factor node with that chain and the new mem...
LLVM_ABI bool isConstantIntBuildVectorOrConstantInt(SDValue N, bool AllowOpaques=true) const
Test whether the given value is a constant int or similar node.
LLVM_ABI void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To, unsigned Num)
Like ReplaceAllUsesOfValueWith, but for multiple values at once.
LLVM_ABI SDValue getJumpTableDebugInfo(int JTI, SDValue Chain, const SDLoc &DL)
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.
void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE, MachineFunctionAnalysisManager &AM, const TargetLibraryInfo *LibraryInfo, const LibcallLoweringInfo *LibcallsInfo, UniformityInfo *UA, ProfileSummaryInfo *PSIin, BlockFrequencyInfo *BFIin, MachineModuleInfo &MMI, FunctionVarLocs const *FnVarLocs)
LLVM_ABI SDValue UnrollVectorOp(SDNode *N, unsigned ResNE=0)
Utility function used by legalize and lowering to "unroll" a vector operation by splitting out the sc...
SDDbgInfo::DbgIterator ByvalParmDbgBegin() const
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.
static LLVM_ABI unsigned getHasPredecessorMaxSteps()
LLVM_ABI bool haveNoCommonBitsSet(SDValue A, SDValue B) const
Return true if A and B have no common bits set.
SDValue getExtractSubvector(const SDLoc &DL, EVT VT, SDValue Vec, unsigned Idx)
Return the VT typed sub-vector of Vec at Idx.
LLVM_ABI bool cannotBeOrderedNegativeFP(SDValue Op) const
Test whether the given float value is known to be positive.
LLVM_ABI SDValue getRegister(Register Reg, EVT VT)
LLVM_ABI bool calculateDivergence(SDNode *N)
LLVM_ABI 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 a use of a float value is insensitive to signed zeros.
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
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.
LLVM_ABI SDValue getBitcastedZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by first bitcasting (from potentia...
SelectionDAG(const SelectionDAG &)=delete
LLVM_ABI SDValue getStepVector(const SDLoc &DL, EVT ResVT, const APInt &StepVal)
Returns a vector of type ResVT whose elements contain the linear sequence <0, Step,...
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.
bool hasSwiftErrorArg() const
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 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
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 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 bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base, unsigned Bytes, int Dist) const
Return true if loads are next to each other and can be merged.
LLVM_ABI SDValue getMaskedHistogram(SDVTList VTs, EVT MemVT, const SDLoc &dl, ArrayRef< SDValue > Ops, MachineMemOperand *MMO, ISD::MemIndexType IndexType)
LLVM_ABI SDDbgLabel * getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O)
Creates a SDDbgLabel node.
SDValue getTargetConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
LLVM_ABI SDValue getStoreVP(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, SDValue Mask, SDValue EVL, EVT MemVT, MachineMemOperand *MMO, ISD::MemIndexedMode AM, bool IsTruncating=false, bool IsCompressing=false)
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL)
Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
LLVM_ABI OverflowKind computeOverflowForUnsignedMul(SDValue N0, SDValue N1) const
Determine if the result of the unsigned mul of 2 nodes can overflow.
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, Register Reg, SDValue N, SDValue Glue)
LLVM_ABI void copyExtraInfo(SDNode *From, SDNode *To)
Copy extra info associated with one node to another.
LLVM_ABI SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
Create a ConstantSDNode wrapping a constant value.
LLVM_ABI void setGraphColor(const SDNode *N, const char *Color)
Convenience for setting node color attribute.
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 getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr, SDValue Offset, MachineMemOperand *MMO)
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 makeStateFunctionCall(unsigned LibFunc, SDValue Ptr, SDValue InChain, const SDLoc &DLoc)
Helper used to make a call to a library function that has one argument of pointer type.
LLVM_ABI SDValue getSignedConstant(int64_t Val, const SDLoc &DL, EVT VT, bool isTarget=false, bool isOpaque=false)
LLVM_ABI SDValue getIndexedLoadVP(SDValue OrigLoad, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
LLVM_ABI SDValue getSrcValue(const Value *v)
Construct a node to track a Value* through the backend.
SDValue getSplatVector(EVT VT, const SDLoc &DL, SDValue Op)
LLVM_ABI SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src, SDValue Size, Type *SizeTy, unsigned ElemSz, bool isTailCall, MachinePointerInfo DstPtrInfo, MachinePointerInfo SrcPtrInfo)
LLVM_ABI OverflowKind computeOverflowForSignedMul(SDValue N0, SDValue N1) const
Determine if the result of the signed mul of 2 nodes can overflow.
LLVM_ABI MaybeAlign InferPtrAlign(SDValue Ptr) const
Infer alignment of a load / store address.
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.
LLVM_ABI SDValue getBasicBlock(MachineBasicBlock *MBB)
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond, SDNodeFlags Flags=SDNodeFlags())
Helper function to make it easier to build SelectCC's if you just have an ISD::CondCode instead of an...
MachineFunctionAnalysisManager * getMFAM()
LLVM_ABI SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign-extending or trunca...
LLVM_ABI SDDbgValue * getVRegDbgValue(DIVariable *Var, DIExpression *Expr, Register VReg, bool IsIndirect, const DebugLoc &DL, unsigned O)
Creates a VReg SDDbgValue node.
LLVM_ABI 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 SDValue getIndexedStoreVP(SDValue OrigStore, const SDLoc &dl, SDValue Base, SDValue Offset, ISD::MemIndexedMode AM)
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.
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 SDValue getTruncStridedStoreVP(SDValue Chain, const SDLoc &DL, SDValue Val, SDValue Ptr, SDValue Stride, SDValue Mask, SDValue EVL, EVT SVT, MachineMemOperand *MMO, bool IsCompressing=false)
const FunctionVarLocs * getFunctionVarLocs() const
Returns the result of the AssignmentTrackingAnalysis pass if it's available, otherwise return nullptr...
LLVM_ABI void canonicalizeCommutativeBinop(unsigned Opcode, SDValue &N1, SDValue &N2) const
Swap N1 and N2 if Opcode is a commutative binary opcode and the canonical form expects the opposite o...
LLVM_ABI KnownBits computeKnownBits(SDValue Op, unsigned Depth=0) const
Determine which bits of Op are known to be either zero or one and return them in Known.
LLVM_ABI SDValue getRegisterMask(const uint32_t *RegMask)
LLVM_ABI SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either zero-extending or trunca...
LLVM_ABI SDValue getCondCode(ISD::CondCode Cond)
void addCallSiteInfo(const SDNode *Node, CallSiteInfo &&CallInfo)
Set CallSiteInfo to be associated with Node.
SDValue getExtOrTrunc(bool IsSigned, SDValue Op, const SDLoc &DL, EVT VT)
Convert Op, which must be of integer type, to the integer type VT, by either sign/zero-extending (dep...
LLVM_ABI bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth=0) const
Return true if 'Op & Mask' is known to be zero.
LLVM_ABI bool isKnownToBeAPowerOfTwoFP(SDValue Val, unsigned Depth=0) const
Test if the given fp value is known to be an integer power-of-2, either positive or negative.
LLVM_ABI OverflowKind computeOverflowForSignedSub(SDValue N0, SDValue N1) const
Determine if the result of the signed sub of 2 nodes can overflow.
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:345
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
typename SuperClass::iterator iterator
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings",...
Definition StringMap.h:128
Provides information about what library functions are available for the current target.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
Primary interface to the complete machine description for the target machine.
TargetSubtargetInfo - Generic base class for all target subtargets.
Twine - A lightweight data structure for efficiently representing the concatenation of temporary valu...
Definition Twine.h:82
The instances of the Type class are immutable: once they are created, they are never changed.
Definition Type.h:46
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:41
@ SETCC
SetCC operator - This evaluates to a true value iff the condition is true.
Definition ISDOpcodes.h:829
@ STRICT_FSETCC
STRICT_FSETCC/STRICT_FSETCCS - Constrained versions of SETCC, used for floating-point operands only.
Definition ISDOpcodes.h:513
@ POISON
POISON - A poison node.
Definition ISDOpcodes.h:236
@ INSERT_SUBVECTOR
INSERT_SUBVECTOR(VECTOR1, VECTOR2, IDX) - Returns a vector with VECTOR2 inserted into VECTOR1.
Definition ISDOpcodes.h:602
@ ANY_EXTEND
ANY_EXTEND - Used for integer types. The high bits are undefined.
Definition ISDOpcodes.h:863
@ SIGN_EXTEND_VECTOR_INREG
SIGN_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register sign-extension of the low ...
Definition ISDOpcodes.h:920
@ SDIVREM
SDIVREM/UDIVREM - Divide two integers and produce both a quotient and remainder result.
Definition ISDOpcodes.h:280
@ SIGN_EXTEND
Conversion operators.
Definition ISDOpcodes.h:854
@ SELECT
Select(COND, TRUEVAL, FALSEVAL).
Definition ISDOpcodes.h:806
@ UNDEF
UNDEF - An undefined node.
Definition ISDOpcodes.h:233
@ SPLAT_VECTOR
SPLAT_VECTOR(VAL) - Returns a vector with the scalar value VAL duplicated in all lanes.
Definition ISDOpcodes.h:674
@ CopyFromReg
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
Definition ISDOpcodes.h:230
@ EXTRACT_SUBVECTOR
EXTRACT_SUBVECTOR(VECTOR, IDX) - Returns a subvector from VECTOR.
Definition ISDOpcodes.h:616
@ EXTRACT_VECTOR_ELT
EXTRACT_VECTOR_ELT(VECTOR, IDX) - Returns a single element from VECTOR identified by the (potentially...
Definition ISDOpcodes.h:578
@ CopyToReg
CopyToReg - This node has three operands: a chain, a register number to set to this value,...
Definition ISDOpcodes.h:224
@ ZERO_EXTEND
ZERO_EXTEND - Used for integer types, zeroing the new bits.
Definition ISDOpcodes.h:860
@ SELECT_CC
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
Definition ISDOpcodes.h:821
@ ANY_EXTEND_VECTOR_INREG
ANY_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register any-extension of the low la...
Definition ISDOpcodes.h:909
@ GLOBAL_OFFSET_TABLE
The address of the GOT.
Definition ISDOpcodes.h:103
@ VSELECT
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Definition ISDOpcodes.h:815
@ INSERT_VECTOR_ELT
INSERT_VECTOR_ELT(VECTOR, VAL, IDX) - Returns VECTOR with the element at IDX replaced with VAL.
Definition ISDOpcodes.h:567
@ ZERO_EXTEND_VECTOR_INREG
ZERO_EXTEND_VECTOR_INREG(Vector) - This operator represents an in-register zero-extension of the low ...
Definition ISDOpcodes.h:931
@ 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:558
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:578
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:149
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:1917
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:390
FoldingSetImpl< T, Trait > FoldingSet
This template class is used to instantiate a specialized implementation of the folding set to the nod...
Definition FoldingSet.h:521
Implement std::hash so that hash_code can be used in STL containers.
Definition BitVector.h:878
#define N
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition Metadata.h:763
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:176
bool isScalableVector() const
Return true if this is a vector type where the runtime length is machine dependent.
Definition ValueTypes.h:187
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition ValueTypes.h:351
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:359
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Definition ValueTypes.h:331
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition ValueTypes.h:160
This trait class is used to define behavior of how to "profile" (in the FoldingSet parlance) an objec...
Definition FoldingSet.h:140
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:106
A simple container for information about the supported runtime calls.
These are IR-level optimization flags that may be propagated to SDNodes.
This represents a list of ValueType's that has been intern'd by a SelectionDAG.
DAGNodeDeletedListener(SelectionDAG &DAG, std::function< void(SDNode *, SDNode *)> Callback)
void NodeDeleted(SDNode *N, SDNode *E) override
The node N that was deleted and, if E is not null, an equivalent node E that replaced it.
std::function< void(SDNode *, SDNode *)> Callback
std::function< void(SDNode *)> Callback
void NodeInserted(SDNode *N) override
The node N that was inserted.
DAGNodeInsertedListener(SelectionDAG &DAG, std::function< void(SDNode *)> Callback)
Clients of various APIs that cause global effects on the DAG can optionally implement this interface.
static void deleteNode(SDNode *)
Use delete by default for iplist and ilist.
Definition ilist.h:41