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