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