LLVM  9.0.0svn
SelectionDAG.h
Go to the documentation of this file.
1 //===- llvm/CodeGen/SelectionDAG.h - InstSelection DAG ----------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 // This file declares the SelectionDAG class, and transitively defines the
10 // SDNode class and subclasses.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_SELECTIONDAG_H
15 #define LLVM_CODEGEN_SELECTIONDAG_H
16 
17 #include "llvm/ADT/APFloat.h"
18 #include "llvm/ADT/APInt.h"
19 #include "llvm/ADT/ArrayRef.h"
20 #include "llvm/ADT/DenseMap.h"
21 #include "llvm/ADT/DenseSet.h"
22 #include "llvm/ADT/FoldingSet.h"
23 #include "llvm/ADT/SetVector.h"
24 #include "llvm/ADT/SmallVector.h"
25 #include "llvm/ADT/StringMap.h"
26 #include "llvm/ADT/ilist.h"
27 #include "llvm/ADT/iterator.h"
38 #include "llvm/IR/DebugLoc.h"
39 #include "llvm/IR/Instructions.h"
40 #include "llvm/IR/Metadata.h"
41 #include "llvm/Support/Allocator.h"
44 #include "llvm/Support/Casting.h"
45 #include "llvm/Support/CodeGen.h"
49 #include <algorithm>
50 #include <cassert>
51 #include <cstdint>
52 #include <functional>
53 #include <map>
54 #include <string>
55 #include <tuple>
56 #include <utility>
57 #include <vector>
58 
59 namespace llvm {
60 
61 class BlockAddress;
62 class Constant;
63 class ConstantFP;
64 class ConstantInt;
65 class DataLayout;
66 struct fltSemantics;
67 class GlobalValue;
68 struct KnownBits;
69 class LLVMContext;
70 class MachineBasicBlock;
71 class MachineConstantPoolValue;
72 class MCSymbol;
73 class OptimizationRemarkEmitter;
74 class SDDbgValue;
75 class SDDbgLabel;
76 class SelectionDAG;
77 class SelectionDAGTargetInfo;
78 class TargetLibraryInfo;
79 class TargetLowering;
80 class TargetMachine;
81 class TargetSubtargetInfo;
82 class Value;
83 
84 class SDVTListNode : public FoldingSetNode {
85  friend struct FoldingSetTrait<SDVTListNode>;
86 
87  /// A reference to an Interned FoldingSetNodeID for this node.
88  /// The Allocator in SelectionDAG holds the data.
89  /// SDVTList contains all types which are frequently accessed in SelectionDAG.
90  /// The size of this list is not expected to be big so it won't introduce
91  /// a memory penalty.
92  FoldingSetNodeIDRef FastID;
93  const EVT *VTs;
94  unsigned int NumVTs;
95  /// The hash value for SDVTList is fixed, so cache it to avoid
96  /// hash calculation.
97  unsigned HashValue;
98 
99 public:
100  SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) :
101  FastID(ID), VTs(VT), NumVTs(Num) {
102  HashValue = ID.ComputeHash();
103  }
104 
106  SDVTList result = {VTs, NumVTs};
107  return result;
108  }
109 };
110 
111 /// Specialize FoldingSetTrait for SDVTListNode
112 /// to avoid computing temp FoldingSetNodeID and hash value.
113 template<> struct FoldingSetTrait<SDVTListNode> : DefaultFoldingSetTrait<SDVTListNode> {
114  static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) {
115  ID = X.FastID;
116  }
117 
118  static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID,
119  unsigned IDHash, FoldingSetNodeID &TempID) {
120  if (X.HashValue != IDHash)
121  return false;
122  return ID == X.FastID;
123  }
124 
125  static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) {
126  return X.HashValue;
127  }
128 };
129 
130 template <> struct ilist_alloc_traits<SDNode> {
131  static void deleteNode(SDNode *) {
132  llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!");
133  }
134 };
135 
136 /// Keeps track of dbg_value information through SDISel. We do
137 /// not build SDNodes for these so as not to perturb the generated code;
138 /// instead the info is kept off to the side in this structure. Each SDNode may
139 /// have one or more associated dbg_value entries. This information is kept in
140 /// DbgValMap.
141 /// Byval parameters are handled separately because they don't use alloca's,
142 /// which busts the normal mechanism. There is good reason for handling all
143 /// parameters separately: they may not have code generated for them, they
144 /// should always go at the beginning of the function regardless of other code
145 /// motion, and debug info for them is potentially useful even if the parameter
146 /// is unused. Right now only byval parameters are handled separately.
147 class SDDbgInfo {
148  BumpPtrAllocator Alloc;
150  SmallVector<SDDbgValue*, 32> ByvalParmDbgValues;
151  SmallVector<SDDbgLabel*, 4> DbgLabels;
153  DbgValMapType DbgValMap;
154 
155 public:
156  SDDbgInfo() = default;
157  SDDbgInfo(const SDDbgInfo &) = delete;
158  SDDbgInfo &operator=(const SDDbgInfo &) = delete;
159 
160  void add(SDDbgValue *V, const SDNode *Node, bool isParameter) {
161  if (isParameter) {
162  ByvalParmDbgValues.push_back(V);
163  } else DbgValues.push_back(V);
164  if (Node)
165  DbgValMap[Node].push_back(V);
166  }
167 
168  void add(SDDbgLabel *L) {
169  DbgLabels.push_back(L);
170  }
171 
172  /// Invalidate all DbgValues attached to the node and remove
173  /// it from the Node-to-DbgValues map.
174  void erase(const SDNode *Node);
175 
176  void clear() {
177  DbgValMap.clear();
178  DbgValues.clear();
179  ByvalParmDbgValues.clear();
180  DbgLabels.clear();
181  Alloc.Reset();
182  }
183 
184  BumpPtrAllocator &getAlloc() { return Alloc; }
185 
186  bool empty() const {
187  return DbgValues.empty() && ByvalParmDbgValues.empty() && DbgLabels.empty();
188  }
189 
191  auto I = DbgValMap.find(Node);
192  if (I != DbgValMap.end())
193  return I->second;
194  return ArrayRef<SDDbgValue*>();
195  }
196 
199 
200  DbgIterator DbgBegin() { return DbgValues.begin(); }
201  DbgIterator DbgEnd() { return DbgValues.end(); }
202  DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
203  DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
204  DbgLabelIterator DbgLabelBegin() { return DbgLabels.begin(); }
205  DbgLabelIterator DbgLabelEnd() { return DbgLabels.end(); }
206 };
207 
208 void checkForCycles(const SelectionDAG *DAG, bool force = false);
209 
210 /// This is used to represent a portion of an LLVM function in a low-level
211 /// Data Dependence DAG representation suitable for instruction selection.
212 /// This DAG is constructed as the first step of instruction selection in order
213 /// to allow implementation of machine specific optimizations
214 /// and code simplifications.
215 ///
216 /// The representation used by the SelectionDAG is a target-independent
217 /// representation, which has some similarities to the GCC RTL representation,
218 /// but is significantly more simple, powerful, and is a graph form instead of a
219 /// linear form.
220 ///
222  const TargetMachine &TM;
223  const SelectionDAGTargetInfo *TSI = nullptr;
224  const TargetLowering *TLI = nullptr;
225  const TargetLibraryInfo *LibInfo = nullptr;
226  MachineFunction *MF;
227  Pass *SDAGISelPass = nullptr;
229  CodeGenOpt::Level OptLevel;
230 
231  LegacyDivergenceAnalysis * DA = nullptr;
232  FunctionLoweringInfo * FLI = nullptr;
233 
234  /// The function-level optimization remark emitter. Used to emit remarks
235  /// whenever manipulating the DAG.
237 
238  /// The starting token.
239  SDNode EntryNode;
240 
241  /// The root of the entire DAG.
242  SDValue Root;
243 
244  /// A linked list of nodes in the current DAG.
245  ilist<SDNode> AllNodes;
246 
247  /// The AllocatorType for allocating SDNodes. We use
248  /// pool allocation with recycling.
250  sizeof(LargestSDNode),
251  alignof(MostAlignedSDNode)>;
252 
253  /// Pool allocation for nodes.
254  NodeAllocatorType NodeAllocator;
255 
256  /// This structure is used to memoize nodes, automatically performing
257  /// CSE with existing nodes when a duplicate is requested.
258  FoldingSet<SDNode> CSEMap;
259 
260  /// Pool allocation for machine-opcode SDNode operands.
261  BumpPtrAllocator OperandAllocator;
262  ArrayRecycler<SDUse> OperandRecycler;
263 
264  /// Pool allocation for misc. objects that are created once per SelectionDAG.
265  BumpPtrAllocator Allocator;
266 
267  /// Tracks dbg_value and dbg_label information through SDISel.
268  SDDbgInfo *DbgInfo;
269 
270  uint16_t NextPersistentId = 0;
271 
272 public:
273  /// Clients of various APIs that cause global effects on
274  /// the DAG can optionally implement this interface. This allows the clients
275  /// to handle the various sorts of updates that happen.
276  ///
277  /// A DAGUpdateListener automatically registers itself with DAG when it is
278  /// constructed, and removes itself when destroyed in RAII fashion.
282 
284  : Next(D.UpdateListeners), DAG(D) {
285  DAG.UpdateListeners = this;
286  }
287 
288  virtual ~DAGUpdateListener() {
289  assert(DAG.UpdateListeners == this &&
290  "DAGUpdateListeners must be destroyed in LIFO order");
291  DAG.UpdateListeners = Next;
292  }
293 
294  /// The node N that was deleted and, if E is not null, an
295  /// equivalent node E that replaced it.
296  virtual void NodeDeleted(SDNode *N, SDNode *E);
297 
298  /// The node N that was updated.
299  virtual void NodeUpdated(SDNode *N);
300 
301  /// The node N that was inserted.
302  virtual void NodeInserted(SDNode *N);
303  };
304 
306  std::function<void(SDNode *, SDNode *)> Callback;
307 
309  std::function<void(SDNode *, SDNode *)> Callback)
310  : DAGUpdateListener(DAG), Callback(std::move(Callback)) {}
311 
312  void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); }
313 
314  private:
315  virtual void anchor();
316  };
317 
318  /// When true, additional steps are taken to
319  /// ensure that getConstant() and similar functions return DAG nodes that
320  /// have legal types. This is important after type legalization since
321  /// any illegally typed nodes generated after this point will not experience
322  /// type legalization.
323  bool NewNodesMustHaveLegalTypes = false;
324 
325 private:
326  /// DAGUpdateListener is a friend so it can manipulate the listener stack.
327  friend struct DAGUpdateListener;
328 
329  /// Linked list of registered DAGUpdateListener instances.
330  /// This stack is maintained by DAGUpdateListener RAII.
331  DAGUpdateListener *UpdateListeners = nullptr;
332 
333  /// Implementation of setSubgraphColor.
334  /// Return whether we had to truncate the search.
335  bool setSubgraphColorHelper(SDNode *N, const char *Color,
336  DenseSet<SDNode *> &visited,
337  int level, bool &printed);
338 
339  template <typename SDNodeT, typename... ArgTypes>
340  SDNodeT *newSDNode(ArgTypes &&... Args) {
341  return new (NodeAllocator.template Allocate<SDNodeT>())
342  SDNodeT(std::forward<ArgTypes>(Args)...);
343  }
344 
345  /// Build a synthetic SDNodeT with the given args and extract its subclass
346  /// data as an integer (e.g. for use in a folding set).
347  ///
348  /// The args to this function are the same as the args to SDNodeT's
349  /// constructor, except the second arg (assumed to be a const DebugLoc&) is
350  /// omitted.
351  template <typename SDNodeT, typename... ArgTypes>
352  static uint16_t getSyntheticNodeSubclassData(unsigned IROrder,
353  ArgTypes &&... Args) {
354  // The compiler can reduce this expression to a constant iff we pass an
355  // empty DebugLoc. Thankfully, the debug location doesn't have any bearing
356  // on the subclass data.
357  return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...)
358  .getRawSubclassData();
359  }
360 
361  template <typename SDNodeTy>
362  static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order,
363  SDVTList VTs, EVT MemoryVT,
364  MachineMemOperand *MMO) {
365  return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO)
366  .getRawSubclassData();
367  }
368 
369  void createOperands(SDNode *Node, ArrayRef<SDValue> Vals);
370 
371  void removeOperands(SDNode *Node) {
372  if (!Node->OperandList)
373  return;
374  OperandRecycler.deallocate(
375  ArrayRecycler<SDUse>::Capacity::get(Node->NumOperands),
376  Node->OperandList);
377  Node->NumOperands = 0;
378  Node->OperandList = nullptr;
379  }
380  void CreateTopologicalOrder(std::vector<SDNode*>& Order);
381 public:
382  explicit SelectionDAG(const TargetMachine &TM, CodeGenOpt::Level);
383  SelectionDAG(const SelectionDAG &) = delete;
384  SelectionDAG &operator=(const SelectionDAG &) = delete;
385  ~SelectionDAG();
386 
387  /// Prepare this SelectionDAG to process code in the given MachineFunction.
388  void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
389  Pass *PassPtr, const TargetLibraryInfo *LibraryInfo,
390  LegacyDivergenceAnalysis * Divergence);
391 
393  FLI = FuncInfo;
394  }
395 
396  /// Clear state and free memory necessary to make this
397  /// SelectionDAG ready to process a new block.
398  void clear();
399 
400  MachineFunction &getMachineFunction() const { return *MF; }
401  const Pass *getPass() const { return SDAGISelPass; }
402 
403  const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
404  const TargetMachine &getTarget() const { return TM; }
405  const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
406  const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
407  const TargetLibraryInfo &getLibInfo() const { return *LibInfo; }
408  const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; }
409  LLVMContext *getContext() const {return Context; }
410  OptimizationRemarkEmitter &getORE() const { return *ORE; }
411 
412  /// Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
413  void viewGraph(const std::string &Title);
414  void viewGraph();
415 
416 #ifndef NDEBUG
417  std::map<const SDNode *, std::string> NodeGraphAttrs;
418 #endif
419 
420  /// Clear all previously defined node graph attributes.
421  /// Intended to be used from a debugging tool (eg. gdb).
422  void clearGraphAttrs();
423 
424  /// Set graph attributes for a node. (eg. "color=red".)
425  void setGraphAttrs(const SDNode *N, const char *Attrs);
426 
427  /// Get graph attributes for a node. (eg. "color=red".)
428  /// Used from getNodeAttributes.
429  const std::string getGraphAttrs(const SDNode *N) const;
430 
431  /// Convenience for setting node color attribute.
432  void setGraphColor(const SDNode *N, const char *Color);
433 
434  /// Convenience for setting subgraph color attribute.
435  void setSubgraphColor(SDNode *N, const char *Color);
436 
438 
439  allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
440  allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
441 
443 
444  allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
445  allnodes_iterator allnodes_end() { return AllNodes.end(); }
446 
448  return AllNodes.size();
449  }
450 
452  return make_range(allnodes_begin(), allnodes_end());
453  }
455  return make_range(allnodes_begin(), allnodes_end());
456  }
457 
458  /// Return the root tag of the SelectionDAG.
459  const SDValue &getRoot() const { return Root; }
460 
461  /// Return the token chain corresponding to the entry of the function.
463  return SDValue(const_cast<SDNode *>(&EntryNode), 0);
464  }
465 
466  /// Set the current root tag of the SelectionDAG.
467  ///
469  assert((!N.getNode() || N.getValueType() == MVT::Other) &&
470  "DAG root value is not a chain!");
471  if (N.getNode())
472  checkForCycles(N.getNode(), this);
473  Root = N;
474  if (N.getNode())
475  checkForCycles(this);
476  return Root;
477  }
478 
479 #ifndef NDEBUG
480  void VerifyDAGDiverence();
481 #endif
482 
483  /// This iterates over the nodes in the SelectionDAG, folding
484  /// certain types of nodes together, or eliminating superfluous nodes. The
485  /// Level argument controls whether Combine is allowed to produce nodes and
486  /// types that are illegal on the target.
487  void Combine(CombineLevel Level, AliasAnalysis *AA,
488  CodeGenOpt::Level OptLevel);
489 
490  /// This transforms the SelectionDAG into a SelectionDAG that
491  /// only uses types natively supported by the target.
492  /// Returns "true" if it made any changes.
493  ///
494  /// Note that this is an involved process that may invalidate pointers into
495  /// the graph.
496  bool LegalizeTypes();
497 
498  /// This transforms the SelectionDAG into a SelectionDAG that is
499  /// compatible with the target instruction selector, as indicated by the
500  /// TargetLowering object.
501  ///
502  /// Note that this is an involved process that may invalidate pointers into
503  /// the graph.
504  void Legalize();
505 
506  /// Transforms a SelectionDAG node and any operands to it into a node
507  /// that is compatible with the target instruction selector, as indicated by
508  /// the TargetLowering object.
509  ///
510  /// \returns true if \c N is a valid, legal node after calling this.
511  ///
512  /// This essentially runs a single recursive walk of the \c Legalize process
513  /// over the given node (and its operands). This can be used to incrementally
514  /// legalize the DAG. All of the nodes which are directly replaced,
515  /// potentially including N, are added to the output parameter \c
516  /// UpdatedNodes so that the delta to the DAG can be understood by the
517  /// caller.
518  ///
519  /// When this returns false, N has been legalized in a way that make the
520  /// pointer passed in no longer valid. It may have even been deleted from the
521  /// DAG, and so it shouldn't be used further. When this returns true, the
522  /// N passed in is a legal node, and can be immediately processed as such.
523  /// This may still have done some work on the DAG, and will still populate
524  /// UpdatedNodes with any new nodes replacing those originally in the DAG.
525  bool LegalizeOp(SDNode *N, SmallSetVector<SDNode *, 16> &UpdatedNodes);
526 
527  /// This transforms the SelectionDAG into a SelectionDAG
528  /// that only uses vector math operations supported by the target. This is
529  /// necessary as a separate step from Legalize because unrolling a vector
530  /// operation can introduce illegal types, which requires running
531  /// LegalizeTypes again.
532  ///
533  /// This returns true if it made any changes; in that case, LegalizeTypes
534  /// is called again before Legalize.
535  ///
536  /// Note that this is an involved process that may invalidate pointers into
537  /// the graph.
538  bool LegalizeVectors();
539 
540  /// This method deletes all unreachable nodes in the SelectionDAG.
541  void RemoveDeadNodes();
542 
543  /// Remove the specified node from the system. This node must
544  /// have no referrers.
545  void DeleteNode(SDNode *N);
546 
547  /// Return an SDVTList that represents the list of values specified.
548  SDVTList getVTList(EVT VT);
549  SDVTList getVTList(EVT VT1, EVT VT2);
550  SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3);
551  SDVTList getVTList(EVT VT1, EVT VT2, EVT VT3, EVT VT4);
552  SDVTList getVTList(ArrayRef<EVT> VTs);
553 
554  //===--------------------------------------------------------------------===//
555  // Node creation methods.
556 
557  /// Create a ConstantSDNode wrapping a constant value.
558  /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
559  ///
560  /// If only legal types can be produced, this does the necessary
561  /// transformations (e.g., if the vector element type is illegal).
562  /// @{
563  SDValue getConstant(uint64_t Val, const SDLoc &DL, EVT VT,
564  bool isTarget = false, bool isOpaque = false);
565  SDValue getConstant(const APInt &Val, const SDLoc &DL, EVT VT,
566  bool isTarget = false, bool isOpaque = false);
567 
568  SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget = false,
569  bool IsOpaque = false) {
571  VT, IsTarget, IsOpaque);
572  }
573 
574  SDValue getConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
575  bool isTarget = false, bool isOpaque = false);
576  SDValue getIntPtrConstant(uint64_t Val, const SDLoc &DL,
577  bool isTarget = false);
578  SDValue getShiftAmountConstant(uint64_t Val, EVT VT, const SDLoc &DL,
579  bool LegalTypes = true);
580 
581  SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT,
582  bool isOpaque = false) {
583  return getConstant(Val, DL, VT, true, isOpaque);
584  }
585  SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT,
586  bool isOpaque = false) {
587  return getConstant(Val, DL, VT, true, isOpaque);
588  }
589  SDValue getTargetConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT,
590  bool isOpaque = false) {
591  return getConstant(Val, DL, VT, true, isOpaque);
592  }
593 
594  /// Create a true or false constant of type \p VT using the target's
595  /// BooleanContent for type \p OpVT.
596  SDValue getBoolConstant(bool V, const SDLoc &DL, EVT VT, EVT OpVT);
597  /// @}
598 
599  /// Create a ConstantFPSDNode wrapping a constant value.
600  /// If VT is a vector type, the constant is splatted into a BUILD_VECTOR.
601  ///
602  /// If only legal types can be produced, this does the necessary
603  /// transformations (e.g., if the vector element type is illegal).
604  /// The forms that take a double should only be used for simple constants
605  /// that can be exactly represented in VT. No checks are made.
606  /// @{
607  SDValue getConstantFP(double Val, const SDLoc &DL, EVT VT,
608  bool isTarget = false);
609  SDValue getConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT,
610  bool isTarget = false);
611  SDValue getConstantFP(const ConstantFP &V, const SDLoc &DL, EVT VT,
612  bool isTarget = false);
613  SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT) {
614  return getConstantFP(Val, DL, VT, true);
615  }
616  SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT) {
617  return getConstantFP(Val, DL, VT, true);
618  }
619  SDValue getTargetConstantFP(const ConstantFP &Val, const SDLoc &DL, EVT VT) {
620  return getConstantFP(Val, DL, VT, true);
621  }
622  /// @}
623 
624  SDValue getGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT,
625  int64_t offset = 0, bool isTargetGA = false,
626  unsigned char TargetFlags = 0);
628  int64_t offset = 0,
629  unsigned char TargetFlags = 0) {
630  return getGlobalAddress(GV, DL, VT, offset, true, TargetFlags);
631  }
632  SDValue getFrameIndex(int FI, EVT VT, bool isTarget = false);
634  return getFrameIndex(FI, VT, true);
635  }
636  SDValue getJumpTable(int JTI, EVT VT, bool isTarget = false,
637  unsigned char TargetFlags = 0);
638  SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags = 0) {
639  return getJumpTable(JTI, VT, true, TargetFlags);
640  }
641  SDValue getConstantPool(const Constant *C, EVT VT,
642  unsigned Align = 0, int Offs = 0, bool isT=false,
643  unsigned char TargetFlags = 0);
645  unsigned Align = 0, int Offset = 0,
646  unsigned char TargetFlags = 0) {
647  return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
648  }
649  SDValue getConstantPool(MachineConstantPoolValue *C, EVT VT,
650  unsigned Align = 0, int Offs = 0, bool isT=false,
651  unsigned char TargetFlags = 0);
653  EVT VT, unsigned Align = 0,
654  int Offset = 0, unsigned char TargetFlags=0) {
655  return getConstantPool(C, VT, Align, Offset, true, TargetFlags);
656  }
657  SDValue getTargetIndex(int Index, EVT VT, int64_t Offset = 0,
658  unsigned char TargetFlags = 0);
659  // When generating a branch to a BB, we don't in general know enough
660  // to provide debug info for the BB at that time, so keep this one around.
661  SDValue getBasicBlock(MachineBasicBlock *MBB);
662  SDValue getBasicBlock(MachineBasicBlock *MBB, SDLoc dl);
663  SDValue getExternalSymbol(const char *Sym, EVT VT);
664  SDValue getExternalSymbol(const char *Sym, const SDLoc &dl, EVT VT);
665  SDValue getTargetExternalSymbol(const char *Sym, EVT VT,
666  unsigned char TargetFlags = 0);
667  SDValue getMCSymbol(MCSymbol *Sym, EVT VT);
668 
669  SDValue getValueType(EVT);
670  SDValue getRegister(unsigned Reg, EVT VT);
671  SDValue getRegisterMask(const uint32_t *RegMask);
672  SDValue getEHLabel(const SDLoc &dl, SDValue Root, MCSymbol *Label);
673  SDValue getLabelNode(unsigned Opcode, const SDLoc &dl, SDValue Root,
674  MCSymbol *Label);
675  SDValue getBlockAddress(const BlockAddress *BA, EVT VT,
676  int64_t Offset = 0, bool isTarget = false,
677  unsigned char TargetFlags = 0);
679  int64_t Offset = 0,
680  unsigned char TargetFlags = 0) {
681  return getBlockAddress(BA, VT, Offset, true, TargetFlags);
682  }
683 
684  SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg,
685  SDValue N) {
686  return getNode(ISD::CopyToReg, dl, MVT::Other, Chain,
687  getRegister(Reg, N.getValueType()), N);
688  }
689 
690  // This version of the getCopyToReg method takes an extra operand, which
691  // indicates that there is potentially an incoming glue value (if Glue is not
692  // null) and that there should be a glue result.
693  SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N,
694  SDValue Glue) {
695  SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
696  SDValue Ops[] = { Chain, getRegister(Reg, N.getValueType()), N, Glue };
697  return getNode(ISD::CopyToReg, dl, VTs,
698  makeArrayRef(Ops, Glue.getNode() ? 4 : 3));
699  }
700 
701  // Similar to last getCopyToReg() except parameter Reg is a SDValue
702  SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, SDValue Reg, SDValue N,
703  SDValue Glue) {
704  SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
705  SDValue Ops[] = { Chain, Reg, N, Glue };
706  return getNode(ISD::CopyToReg, dl, VTs,
707  makeArrayRef(Ops, Glue.getNode() ? 4 : 3));
708  }
709 
710  SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT) {
711  SDVTList VTs = getVTList(VT, MVT::Other);
712  SDValue Ops[] = { Chain, getRegister(Reg, VT) };
713  return getNode(ISD::CopyFromReg, dl, VTs, Ops);
714  }
715 
716  // This version of the getCopyFromReg method takes an extra operand, which
717  // indicates that there is potentially an incoming glue value (if Glue is not
718  // null) and that there should be a glue result.
719  SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT,
720  SDValue Glue) {
721  SDVTList VTs = getVTList(VT, MVT::Other, MVT::Glue);
722  SDValue Ops[] = { Chain, getRegister(Reg, VT), Glue };
723  return getNode(ISD::CopyFromReg, dl, VTs,
724  makeArrayRef(Ops, Glue.getNode() ? 3 : 2));
725  }
726 
728 
729  /// Return an ISD::VECTOR_SHUFFLE node. The number of elements in VT,
730  /// which must be a vector type, must match the number of mask elements
731  /// NumElts. An integer mask element equal to -1 is treated as undefined.
732  SDValue getVectorShuffle(EVT VT, const SDLoc &dl, SDValue N1, SDValue N2,
734 
735  /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
736  /// which must be a vector type, must match the number of operands in Ops.
737  /// The operands must have the same type as (or, for integers, a type wider
738  /// than) VT's element type.
740  // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
741  return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
742  }
743 
744  /// Return an ISD::BUILD_VECTOR node. The number of elements in VT,
745  /// which must be a vector type, must match the number of operands in Ops.
746  /// The operands must have the same type as (or, for integers, a type wider
747  /// than) VT's element type.
749  // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
750  return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
751  }
752 
753  /// Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all
754  /// elements. VT must be a vector type. Op's type must be the same as (or,
755  /// for integers, a type wider than) VT's element type.
757  // VerifySDNode (via InsertNode) checks BUILD_VECTOR later.
758  if (Op.getOpcode() == ISD::UNDEF) {
759  assert((VT.getVectorElementType() == Op.getValueType() ||
760  (VT.isInteger() &&
762  "A splatted value must have a width equal or (for integers) "
763  "greater than the vector element type!");
764  return getNode(ISD::UNDEF, SDLoc(), VT);
765  }
766 
768  return getNode(ISD::BUILD_VECTOR, DL, VT, Ops);
769  }
770 
771  /// Returns an ISD::VECTOR_SHUFFLE node semantically equivalent to
772  /// the shuffle node in input but with swapped operands.
773  ///
774  /// Example: shuffle A, B, <0,5,2,7> -> shuffle B, A, <4,1,6,3>
775  SDValue getCommutedVectorShuffle(const ShuffleVectorSDNode &SV);
776 
777  /// Convert Op, which must be of float type, to the
778  /// float type VT, by either extending or rounding (by truncation).
779  SDValue getFPExtendOrRound(SDValue Op, const SDLoc &DL, EVT VT);
780 
781  /// Convert Op, which must be of integer type, to the
782  /// integer type VT, by either any-extending or truncating it.
783  SDValue getAnyExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT);
784 
785  /// Convert Op, which must be of integer type, to the
786  /// integer type VT, by either sign-extending or truncating it.
787  SDValue getSExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT);
788 
789  /// Convert Op, which must be of integer type, to the
790  /// integer type VT, by either zero-extending or truncating it.
791  SDValue getZExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT);
792 
793  /// Return the expression required to zero extend the Op
794  /// value assuming it was the smaller SrcTy value.
795  SDValue getZeroExtendInReg(SDValue Op, const SDLoc &DL, EVT VT);
796 
797  /// Convert Op, which must be of integer type, to the integer type VT, by
798  /// either truncating it or performing either zero or sign extension as
799  /// appropriate extension for the pointer's semantics.
800  SDValue getPtrExtOrTrunc(SDValue Op, const SDLoc &DL, EVT VT);
801 
802  /// Return the expression required to extend the Op as a pointer value
803  /// assuming it was the smaller SrcTy value. This may be either a zero extend
804  /// or a sign extend.
805  SDValue getPtrExtendInReg(SDValue Op, const SDLoc &DL, EVT VT);
806 
807  /// Convert Op, which must be of integer type, to the integer type VT,
808  /// by using an extension appropriate for the target's
809  /// BooleanContent for type OpVT or truncating it.
810  SDValue getBoolExtOrTrunc(SDValue Op, const SDLoc &SL, EVT VT, EVT OpVT);
811 
812  /// Create a bitwise NOT operation as (XOR Val, -1).
813  SDValue getNOT(const SDLoc &DL, SDValue Val, EVT VT);
814 
815  /// Create a logical NOT operation as (XOR Val, BooleanOne).
816  SDValue getLogicalNOT(const SDLoc &DL, SDValue Val, EVT VT);
817 
818  /// Create an add instruction with appropriate flags when used for
819  /// addressing some offset of an object. i.e. if a load is split into multiple
820  /// components, create an add nuw from the base pointer to the offset.
821  SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset) {
822  EVT VT = Op.getValueType();
823  return getObjectPtrOffset(SL, Op, getConstant(Offset, SL, VT));
824  }
825 
827  EVT VT = Op.getValueType();
828 
829  // The object itself can't wrap around the address space, so it shouldn't be
830  // possible for the adds of the offsets to the split parts to overflow.
831  SDNodeFlags Flags;
832  Flags.setNoUnsignedWrap(true);
833  return getNode(ISD::ADD, SL, VT, Op, Offset, Flags);
834  }
835 
836  /// Return a new CALLSEQ_START node, that starts new call frame, in which
837  /// InSize bytes are set up inside CALLSEQ_START..CALLSEQ_END sequence and
838  /// OutSize specifies part of the frame set up prior to the sequence.
839  SDValue getCALLSEQ_START(SDValue Chain, uint64_t InSize, uint64_t OutSize,
840  const SDLoc &DL) {
841  SDVTList VTs = getVTList(MVT::Other, MVT::Glue);
842  SDValue Ops[] = { Chain,
843  getIntPtrConstant(InSize, DL, true),
844  getIntPtrConstant(OutSize, DL, true) };
845  return getNode(ISD::CALLSEQ_START, DL, VTs, Ops);
846  }
847 
848  /// Return a new CALLSEQ_END node, which always must have a
849  /// glue result (to ensure it's not CSE'd).
850  /// CALLSEQ_END does not have a useful SDLoc.
852  SDValue InGlue, const SDLoc &DL) {
853  SDVTList NodeTys = getVTList(MVT::Other, MVT::Glue);
855  Ops.push_back(Chain);
856  Ops.push_back(Op1);
857  Ops.push_back(Op2);
858  if (InGlue.getNode())
859  Ops.push_back(InGlue);
860  return getNode(ISD::CALLSEQ_END, DL, NodeTys, Ops);
861  }
862 
863  /// Return true if the result of this operation is always undefined.
864  bool isUndef(unsigned Opcode, ArrayRef<SDValue> Ops);
865 
866  /// Return an UNDEF node. UNDEF does not have a useful SDLoc.
868  return getNode(ISD::UNDEF, SDLoc(), VT);
869  }
870 
871  /// Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
873  return getNode(ISD::GLOBAL_OFFSET_TABLE, SDLoc(), VT);
874  }
875 
876  /// Gets or creates the specified node.
877  ///
878  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
879  ArrayRef<SDUse> Ops);
880  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT,
881  ArrayRef<SDValue> Ops, const SDNodeFlags Flags = SDNodeFlags());
882  SDValue getNode(unsigned Opcode, const SDLoc &DL, ArrayRef<EVT> ResultTys,
883  ArrayRef<SDValue> Ops);
884  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList,
885  ArrayRef<SDValue> Ops);
886 
887  // Specialize based on number of operands.
888  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT);
889  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue Operand,
890  const SDNodeFlags Flags = SDNodeFlags());
891  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
892  SDValue N2, const SDNodeFlags Flags = SDNodeFlags());
893  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
894  SDValue N2, SDValue N3,
895  const SDNodeFlags Flags = SDNodeFlags());
896  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
897  SDValue N2, SDValue N3, SDValue N4);
898  SDValue getNode(unsigned Opcode, const SDLoc &DL, EVT VT, SDValue N1,
899  SDValue N2, SDValue N3, SDValue N4, SDValue N5);
900 
901  // Specialize again based on number of operands for nodes with a VTList
902  // rather than a single VT.
903  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList);
904  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N);
905  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
906  SDValue N2);
907  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
908  SDValue N2, SDValue N3);
909  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
910  SDValue N2, SDValue N3, SDValue N4);
911  SDValue getNode(unsigned Opcode, const SDLoc &DL, SDVTList VTList, SDValue N1,
912  SDValue N2, SDValue N3, SDValue N4, SDValue N5);
913 
914  /// Compute a TokenFactor to force all the incoming stack arguments to be
915  /// loaded from the stack. This is used in tail call lowering to protect
916  /// stack arguments from being clobbered.
917  SDValue getStackArgumentTokenFactor(SDValue Chain);
918 
919  SDValue getMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
920  SDValue Size, unsigned Align, bool isVol, bool AlwaysInline,
921  bool isTailCall, MachinePointerInfo DstPtrInfo,
922  MachinePointerInfo SrcPtrInfo);
923 
924  SDValue getMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
925  SDValue Size, unsigned Align, bool isVol, bool isTailCall,
926  MachinePointerInfo DstPtrInfo,
927  MachinePointerInfo SrcPtrInfo);
928 
929  SDValue getMemset(SDValue Chain, const SDLoc &dl, SDValue Dst, SDValue Src,
930  SDValue Size, unsigned Align, bool isVol, bool isTailCall,
931  MachinePointerInfo DstPtrInfo);
932 
933  SDValue getAtomicMemcpy(SDValue Chain, const SDLoc &dl, SDValue Dst,
934  unsigned DstAlign, SDValue Src, unsigned SrcAlign,
935  SDValue Size, Type *SizeTy, unsigned ElemSz,
936  bool isTailCall, MachinePointerInfo DstPtrInfo,
937  MachinePointerInfo SrcPtrInfo);
938 
939  SDValue getAtomicMemmove(SDValue Chain, const SDLoc &dl, SDValue Dst,
940  unsigned DstAlign, SDValue Src, unsigned SrcAlign,
941  SDValue Size, Type *SizeTy, unsigned ElemSz,
942  bool isTailCall, MachinePointerInfo DstPtrInfo,
943  MachinePointerInfo SrcPtrInfo);
944 
945  SDValue getAtomicMemset(SDValue Chain, const SDLoc &dl, SDValue Dst,
946  unsigned DstAlign, SDValue Value, SDValue Size,
947  Type *SizeTy, unsigned ElemSz, bool isTailCall,
948  MachinePointerInfo DstPtrInfo);
949 
950  /// Helper function to make it easier to build SetCC's if you just have an
951  /// ISD::CondCode instead of an SDValue.
952  SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS,
953  ISD::CondCode Cond) {
954  assert(LHS.getValueType().isVector() == RHS.getValueType().isVector() &&
955  "Cannot compare scalars to vectors");
956  assert(LHS.getValueType().isVector() == VT.isVector() &&
957  "Cannot compare scalars to vectors");
958  assert(Cond != ISD::SETCC_INVALID &&
959  "Cannot create a setCC of an invalid node.");
960  return getNode(ISD::SETCC, DL, VT, LHS, RHS, getCondCode(Cond));
961  }
962 
963  /// Helper function to make it easier to build Select's if you just have
964  /// operands and don't want to check for vector.
965  SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS,
966  SDValue RHS) {
967  assert(LHS.getValueType() == RHS.getValueType() &&
968  "Cannot use select on differing types");
969  assert(VT.isVector() == LHS.getValueType().isVector() &&
970  "Cannot mix vectors and scalars");
971  auto Opcode = Cond.getValueType().isVector() ? ISD::VSELECT : ISD::SELECT;
972  return getNode(Opcode, DL, VT, Cond, LHS, RHS);
973  }
974 
975  /// Helper function to make it easier to build SelectCC's if you just have an
976  /// ISD::CondCode instead of an SDValue.
977  SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True,
978  SDValue False, ISD::CondCode Cond) {
979  return getNode(ISD::SELECT_CC, DL, True.getValueType(), LHS, RHS, True,
980  False, getCondCode(Cond));
981  }
982 
983  /// Try to simplify a select/vselect into 1 of its operands or a constant.
984  SDValue simplifySelect(SDValue Cond, SDValue TVal, SDValue FVal);
985 
986  /// Try to simplify a shift into 1 of its operands or a constant.
987  SDValue simplifyShift(SDValue X, SDValue Y);
988 
989  /// Try to simplify a floating-point binary operation into 1 of its operands
990  /// or a constant.
991  SDValue simplifyFPBinop(unsigned Opcode, SDValue X, SDValue Y);
992 
993  /// VAArg produces a result and token chain, and takes a pointer
994  /// and a source value as input.
995  SDValue getVAArg(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
996  SDValue SV, unsigned Align);
997 
998  /// Gets a node for an atomic cmpxchg op. There are two
999  /// valid Opcodes. ISD::ATOMIC_CMO_SWAP produces the value loaded and a
1000  /// chain result. ISD::ATOMIC_CMP_SWAP_WITH_SUCCESS produces the value loaded,
1001  /// a success flag (initially i1), and a chain.
1002  SDValue getAtomicCmpSwap(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1003  SDVTList VTs, SDValue Chain, SDValue Ptr,
1004  SDValue Cmp, SDValue Swp, MachineMemOperand *MMO);
1005 
1006  /// Gets a node for an atomic op, produces result (if relevant)
1007  /// and chain and takes 2 operands.
1008  SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, SDValue Chain,
1009  SDValue Ptr, SDValue Val, MachineMemOperand *MMO);
1010 
1011  /// Gets a node for an atomic op, produces result and chain and
1012  /// takes 1 operand.
1013  SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT, EVT VT,
1014  SDValue Chain, SDValue Ptr, MachineMemOperand *MMO);
1015 
1016  /// Gets a node for an atomic op, produces result and chain and takes N
1017  /// operands.
1018  SDValue getAtomic(unsigned Opcode, const SDLoc &dl, EVT MemVT,
1019  SDVTList VTList, ArrayRef<SDValue> Ops,
1020  MachineMemOperand *MMO);
1021 
1022  /// Creates a MemIntrinsicNode that may produce a
1023  /// result and takes a list of operands. Opcode may be INTRINSIC_VOID,
1024  /// INTRINSIC_W_CHAIN, or a target-specific opcode with a value not
1025  /// less than FIRST_TARGET_MEMORY_OPCODE.
1026  SDValue getMemIntrinsicNode(
1027  unsigned Opcode, const SDLoc &dl, SDVTList VTList,
1028  ArrayRef<SDValue> Ops, EVT MemVT,
1029  MachinePointerInfo PtrInfo,
1030  unsigned Align = 0,
1033  unsigned Size = 0);
1034 
1035  SDValue getMemIntrinsicNode(unsigned Opcode, const SDLoc &dl, SDVTList VTList,
1036  ArrayRef<SDValue> Ops, EVT MemVT,
1037  MachineMemOperand *MMO);
1038 
1039  /// Creates a LifetimeSDNode that starts (`IsStart==true`) or ends
1040  /// (`IsStart==false`) the lifetime of the portion of `FrameIndex` between
1041  /// offsets `Offset` and `Offset + Size`.
1042  SDValue getLifetimeNode(bool IsStart, const SDLoc &dl, SDValue Chain,
1043  int FrameIndex, int64_t Size, int64_t Offset = -1);
1044 
1045  /// Create a MERGE_VALUES node from the given operands.
1046  SDValue getMergeValues(ArrayRef<SDValue> Ops, const SDLoc &dl);
1047 
1048  /// Loads are not normal binary operators: their result type is not
1049  /// determined by their operands, and they produce a value AND a token chain.
1050  ///
1051  /// This function will set the MOLoad flag on MMOFlags, but you can set it if
1052  /// you want. The MOStore flag must not be set.
1053  SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1054  MachinePointerInfo PtrInfo, unsigned Alignment = 0,
1056  const AAMDNodes &AAInfo = AAMDNodes(),
1057  const MDNode *Ranges = nullptr);
1058  SDValue getLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1059  MachineMemOperand *MMO);
1060  SDValue
1061  getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT, SDValue Chain,
1062  SDValue Ptr, MachinePointerInfo PtrInfo, EVT MemVT,
1063  unsigned Alignment = 0,
1065  const AAMDNodes &AAInfo = AAMDNodes());
1066  SDValue getExtLoad(ISD::LoadExtType ExtType, const SDLoc &dl, EVT VT,
1067  SDValue Chain, SDValue Ptr, EVT MemVT,
1068  MachineMemOperand *MMO);
1069  SDValue getIndexedLoad(SDValue OrigLoad, const SDLoc &dl, SDValue Base,
1071  SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT,
1072  const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1073  MachinePointerInfo PtrInfo, EVT MemVT, unsigned Alignment = 0,
1075  const AAMDNodes &AAInfo = AAMDNodes(),
1076  const MDNode *Ranges = nullptr);
1077  SDValue getLoad(ISD::MemIndexedMode AM, ISD::LoadExtType ExtType, EVT VT,
1078  const SDLoc &dl, SDValue Chain, SDValue Ptr, SDValue Offset,
1079  EVT MemVT, MachineMemOperand *MMO);
1080 
1081  /// Helper function to build ISD::STORE nodes.
1082  ///
1083  /// This function will set the MOStore flag on MMOFlags, but you can set it if
1084  /// you want. The MOLoad and MOInvariant flags must not be set.
1085  SDValue
1086  getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1087  MachinePointerInfo PtrInfo, unsigned Alignment = 0,
1089  const AAMDNodes &AAInfo = AAMDNodes());
1090  SDValue getStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1091  MachineMemOperand *MMO);
1092  SDValue
1093  getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val, SDValue Ptr,
1094  MachinePointerInfo PtrInfo, EVT SVT, unsigned Alignment = 0,
1096  const AAMDNodes &AAInfo = AAMDNodes());
1097  SDValue getTruncStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1098  SDValue Ptr, EVT SVT, MachineMemOperand *MMO);
1099  SDValue getIndexedStore(SDValue OrigStore, const SDLoc &dl, SDValue Base,
1100  SDValue Offset, ISD::MemIndexedMode AM);
1101 
1102  /// Returns sum of the base pointer and offset.
1103  SDValue getMemBasePlusOffset(SDValue Base, unsigned Offset, const SDLoc &DL);
1104 
1105  SDValue getMaskedLoad(EVT VT, const SDLoc &dl, SDValue Chain, SDValue Ptr,
1106  SDValue Mask, SDValue Src0, EVT MemVT,
1108  bool IsExpanding = false);
1109  SDValue getMaskedStore(SDValue Chain, const SDLoc &dl, SDValue Val,
1110  SDValue Ptr, SDValue Mask, EVT MemVT,
1111  MachineMemOperand *MMO, bool IsTruncating = false,
1112  bool IsCompressing = false);
1113  SDValue getMaskedGather(SDVTList VTs, EVT VT, const SDLoc &dl,
1115  SDValue getMaskedScatter(SDVTList VTs, EVT VT, const SDLoc &dl,
1117 
1118  /// Return (create a new or find existing) a target-specific node.
1119  /// TargetMemSDNode should be derived class from MemSDNode.
1120  template <class TargetMemSDNode>
1121  SDValue getTargetMemSDNode(SDVTList VTs, ArrayRef<SDValue> Ops,
1122  const SDLoc &dl, EVT MemVT,
1123  MachineMemOperand *MMO);
1124 
1125  /// Construct a node to track a Value* through the backend.
1126  SDValue getSrcValue(const Value *v);
1127 
1128  /// Return an MDNodeSDNode which holds an MDNode.
1129  SDValue getMDNode(const MDNode *MD);
1130 
1131  /// Return a bitcast using the SDLoc of the value operand, and casting to the
1132  /// provided type. Use getNode to set a custom SDLoc.
1133  SDValue getBitcast(EVT VT, SDValue V);
1134 
1135  /// Return an AddrSpaceCastSDNode.
1136  SDValue getAddrSpaceCast(const SDLoc &dl, EVT VT, SDValue Ptr, unsigned SrcAS,
1137  unsigned DestAS);
1138 
1139  /// Return the specified value casted to
1140  /// the target's desired shift amount type.
1141  SDValue getShiftAmountOperand(EVT LHSTy, SDValue Op);
1142 
1143  /// Expand the specified \c ISD::VAARG node as the Legalize pass would.
1144  SDValue expandVAArg(SDNode *Node);
1145 
1146  /// Expand the specified \c ISD::VACOPY node as the Legalize pass would.
1147  SDValue expandVACopy(SDNode *Node);
1148 
1149  /// Returs an GlobalAddress of the function from the current module with
1150  /// name matching the given ExternalSymbol. Additionally can provide the
1151  /// matched function.
1152  /// Panics the function doesn't exists.
1153  SDValue getSymbolFunctionGlobalAddress(SDValue Op,
1154  Function **TargetFunction = nullptr);
1155 
1156  /// *Mutate* the specified node in-place to have the
1157  /// specified operands. If the resultant node already exists in the DAG,
1158  /// this does not modify the specified node, instead it returns the node that
1159  /// already exists. If the resultant node does not exist in the DAG, the
1160  /// input node is returned. As a degenerate case, if you specify the same
1161  /// input operands as the node already has, the input node is returned.
1162  SDNode *UpdateNodeOperands(SDNode *N, SDValue Op);
1163  SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2);
1164  SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1165  SDValue Op3);
1166  SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1167  SDValue Op3, SDValue Op4);
1168  SDNode *UpdateNodeOperands(SDNode *N, SDValue Op1, SDValue Op2,
1169  SDValue Op3, SDValue Op4, SDValue Op5);
1170  SDNode *UpdateNodeOperands(SDNode *N, ArrayRef<SDValue> Ops);
1171 
1172  /// Creates a new TokenFactor containing \p Vals. If \p Vals contains 64k
1173  /// values or more, move values into new TokenFactors in 64k-1 blocks, until
1174  /// the final TokenFactor has less than 64k operands.
1175  SDValue getTokenFactor(const SDLoc &DL, SmallVectorImpl<SDValue> &Vals);
1176 
1177  /// *Mutate* the specified machine node's memory references to the provided
1178  /// list.
1179  void setNodeMemRefs(MachineSDNode *N,
1180  ArrayRef<MachineMemOperand *> NewMemRefs);
1181 
1182  // Propagates the change in divergence to users
1183  void updateDivergence(SDNode * N);
1184 
1185  /// These are used for target selectors to *mutate* the
1186  /// specified node to have the specified return type, Target opcode, and
1187  /// operands. Note that target opcodes are stored as
1188  /// ~TargetOpcode in the node opcode field. The resultant node is returned.
1189  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT);
1190  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT, SDValue Op1);
1191  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1192  SDValue Op1, SDValue Op2);
1193  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1194  SDValue Op1, SDValue Op2, SDValue Op3);
1195  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT,
1196  ArrayRef<SDValue> Ops);
1197  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1, EVT VT2);
1198  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1199  EVT VT2, ArrayRef<SDValue> Ops);
1200  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1201  EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1202  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
1203  EVT VT2, SDValue Op1);
1204  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, EVT VT1,
1205  EVT VT2, SDValue Op1, SDValue Op2);
1206  SDNode *SelectNodeTo(SDNode *N, unsigned MachineOpc, SDVTList VTs,
1207  ArrayRef<SDValue> Ops);
1208 
1209  /// This *mutates* the specified node to have the specified
1210  /// return type, opcode, and operands.
1211  SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
1212  ArrayRef<SDValue> Ops);
1213 
1214  /// Mutate the specified strict FP node to its non-strict equivalent,
1215  /// unlinking the node from its chain and dropping the metadata arguments.
1216  /// The node must be a strict FP node.
1217  SDNode *mutateStrictFPToFP(SDNode *Node);
1218 
1219  /// These are used for target selectors to create a new node
1220  /// with specified return type(s), MachineInstr opcode, and operands.
1221  ///
1222  /// Note that getMachineNode returns the resultant node. If there is already
1223  /// a node of the specified opcode and operands, it returns that node instead
1224  /// of the current one.
1225  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT);
1226  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1227  SDValue Op1);
1228  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1229  SDValue Op1, SDValue Op2);
1230  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1231  SDValue Op1, SDValue Op2, SDValue Op3);
1232  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1233  ArrayRef<SDValue> Ops);
1234  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1235  EVT VT2, SDValue Op1, SDValue Op2);
1236  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1237  EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
1238  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1239  EVT VT2, ArrayRef<SDValue> Ops);
1240  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1241  EVT VT2, EVT VT3, SDValue Op1, SDValue Op2);
1242  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1243  EVT VT2, EVT VT3, SDValue Op1, SDValue Op2,
1244  SDValue Op3);
1245  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1246  EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1247  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1248  ArrayRef<EVT> ResultTys, ArrayRef<SDValue> Ops);
1249  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, SDVTList VTs,
1250  ArrayRef<SDValue> Ops);
1251 
1252  /// A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
1253  SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1254  SDValue Operand);
1255 
1256  /// A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
1257  SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1258  SDValue Operand, SDValue Subreg);
1259 
1260  /// Get the specified node if it's already available, or else return NULL.
1261  SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTList, ArrayRef<SDValue> Ops,
1262  const SDNodeFlags Flags = SDNodeFlags());
1263 
1264  /// Creates a SDDbgValue node.
1265  SDDbgValue *getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N,
1266  unsigned R, bool IsIndirect, const DebugLoc &DL,
1267  unsigned O);
1268 
1269  /// Creates a constant SDDbgValue node.
1270  SDDbgValue *getConstantDbgValue(DIVariable *Var, DIExpression *Expr,
1271  const Value *C, const DebugLoc &DL,
1272  unsigned O);
1273 
1274  /// Creates a FrameIndex SDDbgValue node.
1275  SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr,
1276  unsigned FI, bool IsIndirect,
1277  const DebugLoc &DL, unsigned O);
1278 
1279  /// Creates a VReg SDDbgValue node.
1280  SDDbgValue *getVRegDbgValue(DIVariable *Var, DIExpression *Expr,
1281  unsigned VReg, bool IsIndirect,
1282  const DebugLoc &DL, unsigned O);
1283 
1284  /// Creates a SDDbgLabel node.
1285  SDDbgLabel *getDbgLabel(DILabel *Label, const DebugLoc &DL, unsigned O);
1286 
1287  /// Transfer debug values from one node to another, while optionally
1288  /// generating fragment expressions for split-up values. If \p InvalidateDbg
1289  /// is set, debug values are invalidated after they are transferred.
1290  void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0,
1291  unsigned SizeInBits = 0, bool InvalidateDbg = true);
1292 
1293  /// Remove the specified node from the system. If any of its
1294  /// operands then becomes dead, remove them as well. Inform UpdateListener
1295  /// for each node deleted.
1296  void RemoveDeadNode(SDNode *N);
1297 
1298  /// This method deletes the unreachable nodes in the
1299  /// given list, and any nodes that become unreachable as a result.
1300  void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes);
1301 
1302  /// Modify anything using 'From' to use 'To' instead.
1303  /// This can cause recursive merging of nodes in the DAG. Use the first
1304  /// version if 'From' is known to have a single result, use the second
1305  /// if you have two nodes with identical results (or if 'To' has a superset
1306  /// of the results of 'From'), use the third otherwise.
1307  ///
1308  /// These methods all take an optional UpdateListener, which (if not null) is
1309  /// informed about nodes that are deleted and modified due to recursive
1310  /// changes in the dag.
1311  ///
1312  /// These functions only replace all existing uses. It's possible that as
1313  /// these replacements are being performed, CSE may cause the From node
1314  /// to be given new uses. These new uses of From are left in place, and
1315  /// not automatically transferred to To.
1316  ///
1317  void ReplaceAllUsesWith(SDValue From, SDValue To);
1318  void ReplaceAllUsesWith(SDNode *From, SDNode *To);
1319  void ReplaceAllUsesWith(SDNode *From, const SDValue *To);
1320 
1321  /// Replace any uses of From with To, leaving
1322  /// uses of other values produced by From.getNode() alone.
1323  void ReplaceAllUsesOfValueWith(SDValue From, SDValue To);
1324 
1325  /// Like ReplaceAllUsesOfValueWith, but for multiple values at once.
1326  /// This correctly handles the case where
1327  /// there is an overlap between the From values and the To values.
1328  void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To,
1329  unsigned Num);
1330 
1331  /// If an existing load has uses of its chain, create a token factor node with
1332  /// that chain and the new memory node's chain and update users of the old
1333  /// chain to the token factor. This ensures that the new memory node will have
1334  /// the same relative memory dependency position as the old load. Returns the
1335  /// new merged load chain.
1336  SDValue makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New);
1337 
1338  /// Topological-sort the AllNodes list and a
1339  /// assign a unique node id for each node in the DAG based on their
1340  /// topological order. Returns the number of nodes.
1341  unsigned AssignTopologicalOrder();
1342 
1343  /// Move node N in the AllNodes list to be immediately
1344  /// before the given iterator Position. This may be used to update the
1345  /// topological ordering when the list of nodes is modified.
1347  AllNodes.insert(Position, AllNodes.remove(N));
1348  }
1349 
1350  /// Returns an APFloat semantics tag appropriate for the given type. If VT is
1351  /// a vector type, the element semantics are returned.
1353  switch (VT.getScalarType().getSimpleVT().SimpleTy) {
1354  default: llvm_unreachable("Unknown FP format");
1355  case MVT::f16: return APFloat::IEEEhalf();
1356  case MVT::f32: return APFloat::IEEEsingle();
1357  case MVT::f64: return APFloat::IEEEdouble();
1358  case MVT::f80: return APFloat::x87DoubleExtended();
1359  case MVT::f128: return APFloat::IEEEquad();
1360  case MVT::ppcf128: return APFloat::PPCDoubleDouble();
1361  }
1362  }
1363 
1364  /// Add a dbg_value SDNode. If SD is non-null that means the
1365  /// value is produced by SD.
1366  void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter);
1367 
1368  /// Add a dbg_label SDNode.
1369  void AddDbgLabel(SDDbgLabel *DB);
1370 
1371  /// Get the debug values which reference the given SDNode.
1372  ArrayRef<SDDbgValue*> GetDbgValues(const SDNode* SD) const {
1373  return DbgInfo->getSDDbgValues(SD);
1374  }
1375 
1376 public:
1377  /// Return true if there are any SDDbgValue nodes associated
1378  /// with this SelectionDAG.
1379  bool hasDebugValues() const { return !DbgInfo->empty(); }
1380 
1381  SDDbgInfo::DbgIterator DbgBegin() const { return DbgInfo->DbgBegin(); }
1382  SDDbgInfo::DbgIterator DbgEnd() const { return DbgInfo->DbgEnd(); }
1383 
1385  return DbgInfo->ByvalParmDbgBegin();
1386  }
1388  return DbgInfo->ByvalParmDbgEnd();
1389  }
1390 
1392  return DbgInfo->DbgLabelBegin();
1393  }
1395  return DbgInfo->DbgLabelEnd();
1396  }
1397 
1398  /// To be invoked on an SDNode that is slated to be erased. This
1399  /// function mirrors \c llvm::salvageDebugInfo.
1400  void salvageDebugInfo(SDNode &N);
1401 
1402  void dump() const;
1403 
1404  /// Create a stack temporary, suitable for holding the specified value type.
1405  /// If minAlign is specified, the slot size will have at least that alignment.
1406  SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
1407 
1408  /// Create a stack temporary suitable for holding either of the specified
1409  /// value types.
1410  SDValue CreateStackTemporary(EVT VT1, EVT VT2);
1411 
1412  SDValue FoldSymbolOffset(unsigned Opcode, EVT VT,
1413  const GlobalAddressSDNode *GA,
1414  const SDNode *N2);
1415 
1416  SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1417  SDNode *N1, SDNode *N2);
1418 
1419  SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1420  const ConstantSDNode *C1,
1421  const ConstantSDNode *C2);
1422 
1423  SDValue FoldConstantVectorArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1424  ArrayRef<SDValue> Ops,
1425  const SDNodeFlags Flags = SDNodeFlags());
1426 
1427  /// Fold floating-point operations with 2 operands when both operands are
1428  /// constants and/or undefined.
1429  SDValue foldConstantFPMath(unsigned Opcode, const SDLoc &DL, EVT VT,
1430  SDValue N1, SDValue N2);
1431 
1432  /// Constant fold a setcc to true or false.
1433  SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond,
1434  const SDLoc &dl);
1435 
1436  /// See if the specified operand can be simplified with the knowledge that only
1437  /// the bits specified by Mask are used. If so, return the simpler operand,
1438  /// otherwise return a null SDValue.
1439  ///
1440  /// (This exists alongside SimplifyDemandedBits because GetDemandedBits can
1441  /// simplify nodes with multiple uses more aggressively.)
1442  SDValue GetDemandedBits(SDValue V, const APInt &Mask);
1443 
1444  /// Return true if the sign bit of Op is known to be zero.
1445  /// We use this predicate to simplify operations downstream.
1446  bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
1447 
1448  /// Return true if 'Op & Mask' is known to be zero. We
1449  /// use this predicate to simplify operations downstream. Op and Mask are
1450  /// known to be the same type.
1451  bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0)
1452  const;
1453 
1454  /// Determine which bits of Op are known to be either zero or one and return
1455  /// them in Known. For vectors, the known bits are those that are shared by
1456  /// every vector element.
1457  /// Targets can implement the computeKnownBitsForTargetNode method in the
1458  /// TargetLowering class to allow target nodes to be understood.
1459  KnownBits computeKnownBits(SDValue Op, unsigned Depth = 0) const;
1460 
1461  /// Determine which bits of Op are known to be either zero or one and return
1462  /// them in Known. The DemandedElts argument allows us to only collect the
1463  /// known bits that are shared by the requested vector elements.
1464  /// Targets can implement the computeKnownBitsForTargetNode method in the
1465  /// TargetLowering class to allow target nodes to be understood.
1466  KnownBits computeKnownBits(SDValue Op, const APInt &DemandedElts,
1467  unsigned Depth = 0) const;
1468 
1469  /// Used to represent the possible overflow behavior of an operation.
1470  /// Never: the operation cannot overflow.
1471  /// Always: the operation will always overflow.
1472  /// Sometime: the operation may or may not overflow.
1477  };
1478 
1479  /// Determine if the result of the addition of 2 node can overflow.
1480  OverflowKind computeOverflowKind(SDValue N0, SDValue N1) const;
1481 
1482  /// Test if the given value is known to have exactly one bit set. This differs
1483  /// from computeKnownBits in that it doesn't necessarily determine which bit
1484  /// is set.
1485  bool isKnownToBeAPowerOfTwo(SDValue Val) const;
1486 
1487  /// Return the number of times the sign bit of the register is replicated into
1488  /// the other bits. We know that at least 1 bit is always equal to the sign
1489  /// bit (itself), but other cases can give us information. For example,
1490  /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
1491  /// to each other, so we return 3. Targets can implement the
1492  /// ComputeNumSignBitsForTarget method in the TargetLowering class to allow
1493  /// target nodes to be understood.
1494  unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
1495 
1496  /// Return the number of times the sign bit of the register is replicated into
1497  /// the other bits. We know that at least 1 bit is always equal to the sign
1498  /// bit (itself), but other cases can give us information. For example,
1499  /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
1500  /// to each other, so we return 3. The DemandedElts argument allows
1501  /// us to only collect the minimum sign bits of the requested vector elements.
1502  /// Targets can implement the ComputeNumSignBitsForTarget method in the
1503  /// TargetLowering class to allow target nodes to be understood.
1504  unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
1505  unsigned Depth = 0) const;
1506 
1507  /// Return true if the specified operand is an ISD::ADD with a ConstantSDNode
1508  /// on the right-hand side, or if it is an ISD::OR with a ConstantSDNode that
1509  /// is guaranteed to have the same semantics as an ADD. This handles the
1510  /// equivalence:
1511  /// X|Cst == X+Cst iff X&Cst = 0.
1512  bool isBaseWithConstantOffset(SDValue Op) const;
1513 
1514  /// Test whether the given SDValue is known to never be NaN. If \p SNaN is
1515  /// true, returns if \p Op is known to never be a signaling NaN (it may still
1516  /// be a qNaN).
1517  bool isKnownNeverNaN(SDValue Op, bool SNaN = false, unsigned Depth = 0) const;
1518 
1519  /// \returns true if \p Op is known to never be a signaling NaN.
1520  bool isKnownNeverSNaN(SDValue Op, unsigned Depth = 0) const {
1521  return isKnownNeverNaN(Op, true, Depth);
1522  }
1523 
1524  /// Test whether the given floating point SDValue is known to never be
1525  /// positive or negative zero.
1526  bool isKnownNeverZeroFloat(SDValue Op) const;
1527 
1528  /// Test whether the given SDValue is known to contain non-zero value(s).
1529  bool isKnownNeverZero(SDValue Op) const;
1530 
1531  /// Test whether two SDValues are known to compare equal. This
1532  /// is true if they are the same value, or if one is negative zero and the
1533  /// other positive zero.
1534  bool isEqualTo(SDValue A, SDValue B) const;
1535 
1536  /// Return true if A and B have no common bits set. As an example, this can
1537  /// allow an 'add' to be transformed into an 'or'.
1538  bool haveNoCommonBitsSet(SDValue A, SDValue B) const;
1539 
1540  /// Test whether \p V has a splatted value for all the demanded elements.
1541  ///
1542  /// On success \p UndefElts will indicate the elements that have UNDEF
1543  /// values instead of the splat value, this is only guaranteed to be correct
1544  /// for \p DemandedElts.
1545  ///
1546  /// NOTE: The function will return true for a demanded splat of UNDEF values.
1547  bool isSplatValue(SDValue V, const APInt &DemandedElts, APInt &UndefElts);
1548 
1549  /// Test whether \p V has a splatted value.
1550  bool isSplatValue(SDValue V, bool AllowUndefs = false);
1551 
1552  /// If V is a splatted value, return the source vector and its splat index.
1553  SDValue getSplatSourceVector(SDValue V, int &SplatIndex);
1554 
1555  /// If V is a splat vector, return its scalar source operand by extracting
1556  /// that element from the source vector.
1558 
1559  /// Match a binop + shuffle pyramid that represents a horizontal reduction
1560  /// over the elements of a vector starting from the EXTRACT_VECTOR_ELT node /p
1561  /// Extract. The reduction must use one of the opcodes listed in /p
1562  /// CandidateBinOps and on success /p BinOp will contain the matching opcode.
1563  /// Returns the vector that is being reduced on, or SDValue() if a reduction
1564  /// was not matched.
1565  SDValue matchBinOpReduction(SDNode *Extract, ISD::NodeType &BinOp,
1566  ArrayRef<ISD::NodeType> CandidateBinOps);
1567 
1568  /// Utility function used by legalize and lowering to
1569  /// "unroll" a vector operation by splitting out the scalars and operating
1570  /// on each element individually. If the ResNE is 0, fully unroll the vector
1571  /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
1572  /// If the ResNE is greater than the width of the vector op, unroll the
1573  /// vector op and fill the end of the resulting vector with UNDEFS.
1574  SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
1575 
1576  /// Like UnrollVectorOp(), but for the [US](ADD|SUB|MUL)O family of opcodes.
1577  /// This is a separate function because those opcodes have two results.
1578  std::pair<SDValue, SDValue> UnrollVectorOverflowOp(SDNode *N,
1579  unsigned ResNE = 0);
1580 
1581  /// Return true if loads are next to each other and can be
1582  /// merged. Check that both are nonvolatile and if LD is loading
1583  /// 'Bytes' bytes from a location that is 'Dist' units away from the
1584  /// location that the 'Base' load is loading from.
1585  bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base,
1586  unsigned Bytes, int Dist) const;
1587 
1588  /// Infer alignment of a load / store address. Return 0 if
1589  /// it cannot be inferred.
1590  unsigned InferPtrAlignment(SDValue Ptr) const;
1591 
1592  /// Compute the VTs needed for the low/hi parts of a type
1593  /// which is split (or expanded) into two not necessarily identical pieces.
1594  std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const;
1595 
1596  /// Split the vector with EXTRACT_SUBVECTOR using the provides
1597  /// VTs and return the low/high part.
1598  std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL,
1599  const EVT &LoVT, const EVT &HiVT);
1600 
1601  /// Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
1602  std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
1603  EVT LoVT, HiVT;
1604  std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
1605  return SplitVector(N, DL, LoVT, HiVT);
1606  }
1607 
1608  /// Split the node's operand with EXTRACT_SUBVECTOR and
1609  /// return the low/high part.
1610  std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
1611  {
1612  return SplitVector(N->getOperand(OpNo), SDLoc(N));
1613  }
1614 
1615  /// Widen the vector up to the next power of two using INSERT_SUBVECTOR.
1616  SDValue WidenVector(const SDValue &N, const SDLoc &DL);
1617 
1618  /// Append the extracted elements from Start to Count out of the vector Op
1619  /// in Args. If Count is 0, all of the elements will be extracted.
1620  void ExtractVectorElements(SDValue Op, SmallVectorImpl<SDValue> &Args,
1621  unsigned Start = 0, unsigned Count = 0);
1622 
1623  /// Compute the default alignment value for the given type.
1624  unsigned getEVTAlignment(EVT MemoryVT) const;
1625 
1626  /// Test whether the given value is a constant int or similar node.
1627  SDNode *isConstantIntBuildVectorOrConstantInt(SDValue N);
1628 
1629  /// Test whether the given value is a constant FP or similar node.
1631 
1632  /// \returns true if \p N is any kind of constant or build_vector of
1633  /// constants, int or float. If a vector, it may not necessarily be a splat.
1635  return isConstantIntBuildVectorOrConstantInt(N) ||
1637  }
1638 
1639 private:
1640  void InsertNode(SDNode *N);
1641  bool RemoveNodeFromCSEMaps(SDNode *N);
1642  void AddModifiedNodeToCSEMaps(SDNode *N);
1643  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
1644  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
1645  void *&InsertPos);
1646  SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops,
1647  void *&InsertPos);
1648  SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc);
1649 
1650  void DeleteNodeNotInCSEMaps(SDNode *N);
1651  void DeallocateNode(SDNode *N);
1652 
1653  void allnodes_clear();
1654 
1655  /// Look up the node specified by ID in CSEMap. If it exists, return it. If
1656  /// not, return the insertion token that will make insertion faster. This
1657  /// overload is for nodes other than Constant or ConstantFP, use the other one
1658  /// for those.
1659  SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos);
1660 
1661  /// Look up the node specified by ID in CSEMap. If it exists, return it. If
1662  /// not, return the insertion token that will make insertion faster. Performs
1663  /// additional processing for constant nodes.
1664  SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, const SDLoc &DL,
1665  void *&InsertPos);
1666 
1667  /// List of non-single value types.
1668  FoldingSet<SDVTListNode> VTListMap;
1669 
1670  /// Maps to auto-CSE operations.
1671  std::vector<CondCodeSDNode*> CondCodeNodes;
1672 
1673  std::vector<SDNode*> ValueTypeNodes;
1674  std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
1675  StringMap<SDNode*> ExternalSymbols;
1676 
1677  std::map<std::pair<std::string, unsigned char>,SDNode*> TargetExternalSymbols;
1679 };
1680 
1681 template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
1683 
1685  return nodes_iterator(G->allnodes_begin());
1686  }
1687 
1689  return nodes_iterator(G->allnodes_end());
1690  }
1691 };
1692 
1693 template <class TargetMemSDNode>
1695  ArrayRef<SDValue> Ops,
1696  const SDLoc &dl, EVT MemVT,
1697  MachineMemOperand *MMO) {
1698  /// Compose node ID and try to find an existing node.
1700  unsigned Opcode =
1701  TargetMemSDNode(dl.getIROrder(), DebugLoc(), VTs, MemVT, MMO).getOpcode();
1702  ID.AddInteger(Opcode);
1703  ID.AddPointer(VTs.VTs);
1704  for (auto& Op : Ops) {
1705  ID.AddPointer(Op.getNode());
1706  ID.AddInteger(Op.getResNo());
1707  }
1708  ID.AddInteger(MemVT.getRawBits());
1709  ID.AddInteger(MMO->getPointerInfo().getAddrSpace());
1710  ID.AddInteger(getSyntheticNodeSubclassData<TargetMemSDNode>(
1711  dl.getIROrder(), VTs, MemVT, MMO));
1712 
1713  void *IP = nullptr;
1714  if (SDNode *E = FindNodeOrInsertPos(ID, dl, IP)) {
1715  cast<TargetMemSDNode>(E)->refineAlignment(MMO);
1716  return SDValue(E, 0);
1717  }
1718 
1719  /// Existing node was not found. Create a new one.
1720  auto *N = newSDNode<TargetMemSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs,
1721  MemVT, MMO);
1722  createOperands(N, Ops);
1723  CSEMap.InsertNode(N, IP);
1724  InsertNode(N);
1725  return SDValue(N, 0);
1726 }
1727 
1728 } // end namespace llvm
1729 
1730 #endif // LLVM_CODEGEN_SELECTIONDAG_H
Pass interface - Implemented by all &#39;passes&#39;.
Definition: Pass.h:80
uint64_t CallInst * C
static const fltSemantics & IEEEquad() LLVM_READNONE
Definition: APFloat.cpp:125
void computeKnownBits(const Value *V, KnownBits &Known, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, OptimizationRemarkEmitter *ORE=nullptr, bool UseInstrInfo=true)
Determine which bits of V are known to be either zero or one and return them in the KnownZero/KnownOn...
void AddPointer(const void *Ptr)
Add* - Add various data types to Bit data.
Definition: FoldingSet.cpp:51
void add(SDDbgLabel *L)
Definition: SelectionDAG.h:168
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:110
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
EVT getValueType() const
Return the ValueType of the referenced return value.
OverflowKind
Used to represent the possible overflow behavior of an operation.
static MSP430CC::CondCodes getCondCode(unsigned Cond)
static GCMetadataPrinterRegistry::Add< ErlangGCPrinter > X("erlang", "erlang-compatible garbage collector")
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT, SDValue Glue)
Definition: SelectionDAG.h:719
static APInt getAllOnesValue(unsigned numBits)
Get the all-ones value.
Definition: APInt.h:561
const TargetLibraryInfo & getLibInfo() const
Definition: SelectionDAG.h:407
LLVMContext & Context
Keeps track of dbg_value information through SDISel.
Definition: SelectionDAG.h:147
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC&#39;s if you just have an ISD::CondCode instead of an SD...
Definition: SelectionDAG.h:952
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&#39;s not CSE&#39;d)...
Definition: SelectionDAG.h:851
Atomic ordering constants.
This class represents lattice values for constants.
Definition: AllocatorList.h:23
static void removeOperands(MachineInstr &MI, unsigned i)
EVT getScalarType() const
If this is a vector type, return the element type, otherwise return this.
Definition: ValueTypes.h:259
MCSymbol - Instances of this class represent a symbol name in the MC file, and MCSymbols are created ...
Definition: MCSymbol.h:41
DbgIterator ByvalParmDbgEnd()
Definition: SelectionDAG.h:203
const Value * getSplatValue(const Value *V)
Get splat value if the input is a splat vector or return nullptr.
Implements a dense probed hash-table based set.
Definition: DenseSet.h:249
This provides a very simple, boring adaptor for a begin and end iterator into a range type...
Clients of various APIs that cause global effects on the DAG can optionally implement this interface...
Definition: SelectionDAG.h:279
unsigned Reg
This file contains the declarations for metadata subclasses.
MVT getSimpleVT() const
Return the SimpleValueType held in the specified simple EVT.
Definition: ValueTypes.h:252
ArrayRef< SDDbgValue * > getSDDbgValues(const SDNode *Node) const
Definition: SelectionDAG.h:190
static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID, unsigned IDHash, FoldingSetNodeID &TempID)
Definition: SelectionDAG.h:118
bool salvageDebugInfo(Instruction &I)
Assuming the instruction I is going to be deleted, attempt to salvage debug users of I by writing the...
Definition: Local.cpp:1624
static const fltSemantics & EVTToAPFloatSemantics(EVT VT)
Returns an APFloat semantics tag appropriate for the given type.
Recycle small arrays allocated from a BumpPtrAllocator.
Definition: ArrayRecycler.h:28
SDValue getTargetConstantFP(const ConstantFP &Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:619
A debug info location.
Definition: DebugLoc.h:33
Metadata node.
Definition: Metadata.h:863
bool isInteger() const
Return true if this is an integer or a vector integer type.
Definition: ValueTypes.h:140
SDValue getSelect(const SDLoc &DL, EVT VT, SDValue Cond, SDValue LHS, SDValue RHS)
Helper function to make it easier to build Select&#39;s if you just have operands and don&#39;t want to check...
Definition: SelectionDAG.h:965
DbgIterator DbgBegin()
Definition: SelectionDAG.h:200
SDDbgInfo::DbgLabelIterator DbgLabelBegin() const
SDNode * getNode() const
get the SDNode which holds the desired result
const SDValue & setRoot(SDValue N)
Set the current root tag of the SelectionDAG.
Definition: SelectionDAG.h:468
SmallVectorImpl< SDDbgLabel * >::iterator DbgLabelIterator
Definition: SelectionDAG.h:198
The address of the GOT.
Definition: ISDOpcodes.h:65
Select with condition operator - This selects between a true value and a false value (ops #2 and #3) ...
Definition: ISDOpcodes.h:459
NodeType
ISD::NodeType enum - This enum defines the target-independent operators for a SelectionDAG.
Definition: ISDOpcodes.h:38
This file defines the MallocAllocator and BumpPtrAllocator interfaces.
This SDNode is used to implement the code generator support for the llvm IR shufflevector instruction...
unsigned getAddrSpace() const
Return the LLVM IR address space number that this pointer points into.
static GCMetadataPrinterRegistry::Add< OcamlGCMetadataPrinter > Y("ocaml", "ocaml 3.10-compatible collector")
The address of a basic block.
Definition: Constants.h:839
A description of a memory reference used in the backend.
Definition: BitVector.h:937
bool isKnownToBeAPowerOfTwo(const Value *V, const DataLayout &DL, bool OrZero=false, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if the given value is known to have exactly one bit set when defined. ...
SDDbgInfo::DbgIterator DbgEnd() const
SDValue getTargetConstantFP(const APFloat &Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:616
void Reset()
Deallocate all but the current slab and reset the current pointer to the beginning of it...
Definition: Allocator.h:194
ArrayRef< T > makeArrayRef(const T &OneElt)
Construct an ArrayRef from a single element.
Definition: ArrayRef.h:450
static Optional< unsigned > getOpcode(ArrayRef< VPValue *> Values)
Returns the opcode of Values or ~0 if they do not all agree.
Definition: VPlanSLP.cpp:196
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
Definition: APFloat.h:41
CopyToReg - This node has three operands: a chain, a register number to set to this value...
Definition: ISDOpcodes.h:169
SimpleValueType SimpleTy
bool MaskedValueIsZero(const Value *V, const APInt &Mask, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if &#39;V & Mask&#39; is known to be zero.
CALLSEQ_START/CALLSEQ_END - These operators mark the beginning and end of a call sequence, and carry arbitrary information that target might want to know.
Definition: ISDOpcodes.h:744
void AddInteger(signed I)
Definition: FoldingSet.cpp:60
SmallVectorImpl< SDDbgValue * >::iterator DbgIterator
Definition: SelectionDAG.h:197
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
Definition: SelectionDAG.h:462
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:403
void setFunctionLoweringInfo(FunctionLoweringInfo *FuncInfo)
Definition: SelectionDAG.h:392
SDValue getTargetConstant(const ConstantInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:589
Position
Position to insert a new instruction relative to an existing instruction.
This class defines information used to lower LLVM code to legal SelectionDAG operators that the targe...
This file implements a class to represent arbitrary precision integral constant values and operations...
This represents a list of ValueType&#39;s that has been intern&#39;d by a SelectionDAG.
iterator_range< allnodes_iterator > allnodes()
Definition: SelectionDAG.h:451
static int64_t getConstant(const MachineInstr *MI)
void InsertNode(T *N, void *InsertPos)
InsertNode - Insert the specified node into the folding set, knowing that it is not already in the fo...
Definition: FoldingSet.h:451
unsigned getScalarSizeInBits() const
Definition: ValueTypes.h:297
void checkForCycles(const SelectionDAG *DAG, bool force=false)
MachineFunction & getMachineFunction() const
Definition: SelectionDAG.h:400
DAGUpdateListener *const Next
Definition: SelectionDAG.h:280
SDValue getTargetFrameIndex(int FI, EVT VT)
Definition: SelectionDAG.h:633
const TargetMachine & getTarget() const
Definition: SelectionDAG.h:404
Select with a vector condition (op #0) and two vector operands (ops #1 and #2), returning a vector re...
Definition: ISDOpcodes.h:453
Simple integer binary arithmetic operators.
Definition: ISDOpcodes.h:200
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory)...
Definition: APInt.h:32
SDValue getUNDEF(EVT VT)
Return an UNDEF node. UNDEF does not have a useful SDLoc.
Definition: SelectionDAG.h:867
CondCode
ISD::CondCode enum - These are ordered carefully to make the bitfields below work out...
Definition: ISDOpcodes.h:995
static const fltSemantics & IEEEdouble() LLVM_READNONE
Definition: APFloat.cpp:122
SDValue getTargetConstant(uint64_t Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:581
allnodes_iterator allnodes_end()
Definition: SelectionDAG.h:445
SDValue getSplatBuildVector(EVT VT, const SDLoc &DL, SDValue Op)
Return a splat ISD::BUILD_VECTOR node, consisting of Op splatted to all elements. ...
Definition: SelectionDAG.h:756
constexpr char Attrs[]
Key for Kernel::Metadata::mAttrs.
SDDbgInfo::DbgIterator DbgBegin() const
allnodes_iterator allnodes_begin()
Definition: SelectionDAG.h:444
SDValue getTargetConstantFP(double Val, const SDLoc &DL, EVT VT)
Definition: SelectionDAG.h:613
static SDValue WidenVector(SDValue V64Reg, SelectionDAG &DAG)
WidenVector - Given a value in the V64 register class, produce the equivalent value in the V128 regis...
const DataLayout & getDataLayout() const
Return the DataLayout attached to the Module associated to this MF.
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDUse > Ops)
Return an ISD::BUILD_VECTOR node.
Definition: SelectionDAG.h:748
UNDEF - An undefined node.
Definition: ISDOpcodes.h:177
BUILD_VECTOR(ELT0, ELT1, ELT2, ELT3,...) - Return a vector with the specified, possibly variable...
Definition: ISDOpcodes.h:351
iterator find(const_arg_type_t< KeyT > Val)
Definition: DenseMap.h:176
unsigned ComputeHash() const
ComputeHash - Compute a strong hash value for this FoldingSetNodeIDRef, used to lookup the node in th...
Definition: FoldingSet.cpp:29
FoldingSetNodeID - This class is used to gather all the unique data bits of a node.
Definition: FoldingSet.h:305
BumpPtrAllocatorImpl BumpPtrAllocator
The standard BumpPtrAllocator which just uses the default template parameters.
Definition: Allocator.h:434
Use delete by default for iplist and ilist.
Definition: ilist.h:40
unsigned ComputeNumSignBits(const Value *Op, const DataLayout &DL, unsigned Depth=0, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return the number of times the sign bit of the register is replicated into the other bits...
DAGNodeDeletedListener(SelectionDAG &DAG, std::function< void(SDNode *, SDNode *)> Callback)
Definition: SelectionDAG.h:308
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:432
FoldingSetTrait - This trait class is used to define behavior of how to "profile" (in the FoldingSet ...
Definition: FoldingSet.h:249
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
void dump(const SparseBitVector< ElementSize > &LHS, raw_ostream &out)
static nodes_iterator nodes_begin(SelectionDAG *G)
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:45
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
const SelectionDAGTargetInfo & getSelectionDAGInfo() const
Definition: SelectionDAG.h:408
This is an important class for using LLVM in a threaded context.
Definition: LLVMContext.h:64
Allocate memory in an ever growing pool, as if by bump-pointer.
Definition: Allocator.h:140
unsigned getVectorNumElements() const
Given a vector type, return the number of elements it contains.
Definition: ValueTypes.h:272
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This is an important base class in LLVM.
Definition: Constant.h:41
bool hasDebugValues() const
Return true if there are any SDDbgValue nodes associated with this SelectionDAG.
const SDValue & getOperand(unsigned Num) const
LoadExtType
LoadExtType enum - This enum defines the three variants of LOADEXT (load with extension).
Definition: ISDOpcodes.h:970
bool bitsLE(EVT VT) const
Return true if this has no more bits than VT.
Definition: ValueTypes.h:246
DbgLabelIterator DbgLabelEnd()
Definition: SelectionDAG.h:205
bool empty() const
Definition: SelectionDAG.h:186
bool isKnownNeverSNaN(SDValue Op, unsigned Depth=0) const
ConstantFP - Floating Point Values [float, double].
Definition: Constants.h:263
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 ...
Definition: SelectionDAG.h:839
std::pair< SDValue, SDValue > SplitVectorOperand(const SDNode *N, unsigned OpNo)
Split the node&#39;s operand with EXTRACT_SUBVECTOR and return the low/high part.
CombineLevel
Definition: DAGCombine.h:15
This file declares a class to represent arbitrary precision floating point values and provide a varie...
BumpPtrAllocator & getAlloc()
Definition: SelectionDAG.h:184
void RepositionNode(allnodes_iterator Position, SDNode *N)
Move node N in the AllNodes list to be immediately before the given iterator Position.
SDDbgInfo::DbgIterator ByvalParmDbgEnd() const
Base class for variables.
static const fltSemantics & x87DoubleExtended() LLVM_READNONE
Definition: APFloat.cpp:128
std::pair< SDValue, SDValue > SplitVector(const SDValue &N, const SDLoc &DL)
Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
Targets can subclass this to parameterize the SelectionDAG lowering and instruction selection process...
const Pass * getPass() const
Definition: SelectionDAG.h:401
Extended Value Type.
Definition: ValueTypes.h:33
Abstract base class for all machine specific constantpool value subclasses.
SDValue getTargetConstantPool(MachineConstantPoolValue *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
Definition: SelectionDAG.h:652
SDValue getAllOnesConstant(const SDLoc &DL, EVT VT, bool IsTarget=false, bool IsOpaque=false)
Definition: SelectionDAG.h:568
static Constant * simplifyFPBinop(Value *Op0, Value *Op1)
iterator_range< allnodes_const_iterator > allnodes() const
Definition: SelectionDAG.h:454
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N, SDValue Glue)
Definition: SelectionDAG.h:693
An intrusive list with ownership and callbacks specified/controlled by ilist_traits, only with API safe for polymorphic types.
Definition: ilist.h:388
This class contains a discriminated union of information about pointers in memory operands...
FoldingSet - This template class is used to instantiate a specialized implementation of the folding s...
Definition: FoldingSet.h:473
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
The memory access writes data.
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, SDValue Offset)
Definition: SelectionDAG.h:826
iterator_range< T > make_range(T x, T y)
Convenience function for iterating over sub-ranges.
SDValue getTargetConstantPool(const Constant *C, EVT VT, unsigned Align=0, int Offset=0, unsigned char TargetFlags=0)
Definition: SelectionDAG.h:644
SDValue getTargetJumpTable(int JTI, EVT VT, unsigned char TargetFlags=0)
Definition: SelectionDAG.h:638
static bool isUndef(ArrayRef< int > Mask)
static const fltSemantics & IEEEsingle() LLVM_READNONE
Definition: APFloat.cpp:119
Basic Register Allocator
const TargetLowering & getTargetLoweringInfo() const
Definition: SelectionDAG.h:406
A SetVector that performs no allocations if smaller than a certain size.
Definition: SetVector.h:297
Iterator for intrusive lists based on ilist_node.
void setNoUnsignedWrap(bool b)
This is the shared class of boolean and integer constants.
Definition: Constants.h:83
Color
A "color", which is either even or odd.
BlockVerifier::State From
static const fltSemantics & IEEEhalf() LLVM_READNONE
Definition: APFloat.cpp:116
ilist< SDNode >::size_type allnodes_size() const
Definition: SelectionDAG.h:447
EVT getVectorElementType() const
Given a vector type, return the type of each element.
Definition: ValueTypes.h:264
static nodes_iterator nodes_end(SelectionDAG *G)
This is used to represent a portion of an LLVM function in a low-level Data Dependence DAG representa...
Definition: SelectionDAG.h:221
SDValue getTargetMemSDNode(SDVTList VTs, ArrayRef< SDValue > Ops, const SDLoc &dl, EVT MemVT, MachineMemOperand *MMO)
Return (create a new or find existing) a target-specific node.
This is a &#39;vector&#39; (really, a variable-sized array), optimized for the case when the array is small...
Definition: SmallVector.h:841
SDValue getBuildVector(EVT VT, const SDLoc &DL, ArrayRef< SDValue > Ops)
Return an ISD::BUILD_VECTOR node.
Definition: SelectionDAG.h:739
Provides information about what library functions are available for the current target.
const DebugLoc & getDebugLoc() const
const DataFlowGraph & G
Definition: RDFGraph.cpp:202
An SDNode that represents everything that will be needed to construct a MachineInstr.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
Definition: Metadata.h:643
Wrapper class for IR location info (IR ordering and DebugLoc) to be passed into SDNode creation funct...
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
Represents one node in the SelectionDAG.
DbgIterator DbgEnd()
Definition: SelectionDAG.h:201
allnodes_const_iterator allnodes_begin() const
Definition: SelectionDAG.h:439
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, unsigned Reg, SDValue N)
Definition: SelectionDAG.h:684
DWARF expression.
A range adaptor for a pair of iterators.
StringMap - This is an unconventional map that is specialized for handling keys that are "strings"...
Definition: StringMap.h:219
Class for arbitrary precision integers.
Definition: APInt.h:69
std::function< void(SDNode *, SDNode *)> Callback
Definition: SelectionDAG.h:306
Select(COND, TRUEVAL, FALSEVAL).
Definition: ISDOpcodes.h:444
typename SuperClass::iterator iterator
Definition: SmallVector.h:319
SDDbgInfo::DbgLabelIterator DbgLabelEnd() const
static void clear(coro::Shape &Shape)
Definition: Coroutines.cpp:211
Flags
Flags values. These may be or&#39;d together.
AlignedCharArrayUnion< AtomicSDNode, TargetIndexSDNode, BlockAddressSDNode, GlobalAddressSDNode > LargestSDNode
A representation of the largest SDNode, for use in sizeof().
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
bool isConstantValueOfAnyType(SDValue N)
SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:585
std::map< const SDNode *, std::string > NodeGraphAttrs
Definition: SelectionDAG.h:417
static const fltSemantics & PPCDoubleDouble() LLVM_READNONE
Definition: APFloat.cpp:134
These are IR-level optimization flags that may be propagated to SDNodes.
allnodes_const_iterator allnodes_end() const
Definition: SelectionDAG.h:440
SDValue getTargetBlockAddress(const BlockAddress *BA, EVT VT, int64_t Offset=0, unsigned char TargetFlags=0)
Definition: SelectionDAG.h:678
SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num)
Definition: SelectionDAG.h:100
const MachinePointerInfo & getPointerInfo() const
bool isVector() const
Return true if this is a vector value type.
Definition: ValueTypes.h:150
FoldingSetNodeIDRef - This class describes a reference to an interned FoldingSetNodeID, which can be a useful to store node id data rather than using plain FoldingSetNodeIDs, since the 32-element SmallVector is often much larger than necessary, and the possibility of heap allocation means it requires a non-trivial destructor call.
Definition: FoldingSet.h:277
Holds the information from a dbg_label node through SDISel.
SDValue getCopyFromReg(SDValue Chain, const SDLoc &dl, unsigned Reg, EVT VT)
Definition: SelectionDAG.h:710
Node - This class is used to maintain the singly linked bucket list in a folding set.
Definition: FoldingSet.h:135
LLVM_NODISCARD bool empty() const
Definition: SmallVector.h:55
static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID)
Definition: SelectionDAG.h:125
#define I(x, y, z)
Definition: MD5.cpp:58
bool haveNoCommonBitsSet(const Value *LHS, const Value *RHS, const DataLayout &DL, AssumptionCache *AC=nullptr, const Instruction *CxtI=nullptr, const DominatorTree *DT=nullptr, bool UseInstrInfo=true)
Return true if LHS and RHS have no common bits set.
#define N
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:405
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
FunctionLoweringInfo - This contains information that is global to a function that is used when lower...
iterator end()
Definition: DenseMap.h:108
SDDbgInfo::DbgIterator ByvalParmDbgBegin() const
uint32_t Size
Definition: Profile.cpp:46
unsigned getOpcode() const
bool isKnownNeverNaN(const Value *V, const TargetLibraryInfo *TLI, unsigned Depth=0)
Return true if the floating-point scalar value is not a NaN or if the floating-point vector value has...
SDValue getCopyToReg(SDValue Chain, const SDLoc &dl, SDValue Reg, SDValue N, SDValue Glue)
Definition: SelectionDAG.h:702
CopyFromReg - This node indicates that the input value is a virtual or physical register that is defi...
Definition: ISDOpcodes.h:174
const SDValue & getRoot() const
Return the root tag of the SelectionDAG.
Definition: SelectionDAG.h:459
SDValue getGLOBAL_OFFSET_TABLE(EVT VT)
Return a GLOBAL_OFFSET_TABLE node. This does not have a useful SDLoc.
Definition: SelectionDAG.h:872
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
LLVM Value Representation.
Definition: Value.h:72
SDValue getSelectCC(const SDLoc &DL, SDValue LHS, SDValue RHS, SDValue True, SDValue False, ISD::CondCode Cond)
Helper function to make it easier to build SelectCC&#39;s if you just have an ISD::CondCode instead of an...
Definition: SelectionDAG.h:977
SDVTList getSDVTList()
Definition: SelectionDAG.h:105
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:80
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
Definition: FoldingSet.h:220
OptimizationRemarkEmitter & getORE() const
Definition: SelectionDAG.h:410
static void deleteNode(SDNode *)
Definition: SelectionDAG.h:131
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:65
void add(SDDbgValue *V, const SDNode *Node, bool isParameter)
Definition: SelectionDAG.h:160
void deallocate(Capacity Cap, T *Ptr)
Deallocate an array with the specified Capacity.
print Print MemDeps of function
ArrayRef< SDDbgValue * > GetDbgValues(const SDNode *SD) const
Get the debug values which reference the given SDNode.
SetCC operator - This evaluates to a true value iff the condition is true.
Definition: ISDOpcodes.h:467
static SDNode * isConstantFPBuildVectorOrConstantFP(SDValue N)
DbgIterator ByvalParmDbgBegin()
Definition: SelectionDAG.h:202
SDValue getObjectPtrOffset(const SDLoc &SL, SDValue Op, int64_t Offset)
Create an add instruction with appropriate flags when used for addressing some offset of an object...
Definition: SelectionDAG.h:821
Unlike LLVM values, Selection DAG nodes may return multiple values as the result of a computation...
Holds the information from a dbg_value node through SDISel.
static void Profile(const SDVTListNode &X, FoldingSetNodeID &ID)
Definition: SelectionDAG.h:114
DbgLabelIterator DbgLabelBegin()
Definition: SelectionDAG.h:204
The optimization diagnostic interface.
void NodeDeleted(SDNode *N, SDNode *E) override
The node N that was deleted and, if E is not null, an equivalent node E that replaced it...
Definition: SelectionDAG.h:312
LLVMContext * getContext() const
Definition: SelectionDAG.h:409
constexpr char Args[]
Key for Kernel::Metadata::mArgs.
unsigned getIROrder() const
SDValue getTargetGlobalAddress(const GlobalValue *GV, const SDLoc &DL, EVT VT, int64_t offset=0, unsigned char TargetFlags=0)
Definition: SelectionDAG.h:627
MemIndexedMode
MemIndexedMode enum - This enum defines the load / store indexed addressing modes.
Definition: ISDOpcodes.h:950
This class is used to represent ISD::LOAD nodes.