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"
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 SelectionDAG;
77 class SelectionDAGTargetInfo;
78 class TargetLibraryInfo;
79 class TargetLowering;
80 class TargetMachine;
81 class TargetSubtargetInfo;
82 class Value;
83 
84 class SDVTListNode : public FoldingSetNode {
85  friend struct FoldingSetTrait<SDVTListNode>;
86 
87  /// A reference to an Interned FoldingSetNodeID for this node.
88  /// The Allocator in SelectionDAG holds the data.
89  /// SDVTList contains all types which are frequently accessed in SelectionDAG.
90  /// The size of this list is not expected to be big so it won't introduce
91  /// a memory penalty.
92  FoldingSetNodeIDRef FastID;
93  const EVT *VTs;
94  unsigned int NumVTs;
95  /// The hash value for SDVTList is fixed, so cache it to avoid
96  /// hash calculation.
97  unsigned HashValue;
98 
99 public:
100  SDVTListNode(const FoldingSetNodeIDRef ID, const EVT *VT, unsigned int Num) :
101  FastID(ID), VTs(VT), NumVTs(Num) {
102  HashValue = ID.ComputeHash();
103  }
104 
106  SDVTList result = {VTs, NumVTs};
107  return result;
108  }
109 };
110 
111 /// Specialize FoldingSetTrait for SDVTListNode
112 /// to avoid computing temp FoldingSetNodeID and hash value.
113 template<> struct FoldingSetTrait<SDVTListNode> : DefaultFoldingSetTrait<SDVTListNode> {
114  static void Profile(const SDVTListNode &X, FoldingSetNodeID& ID) {
115  ID = X.FastID;
116  }
117 
118  static bool Equals(const SDVTListNode &X, const FoldingSetNodeID &ID,
119  unsigned IDHash, FoldingSetNodeID &TempID) {
120  if (X.HashValue != IDHash)
121  return false;
122  return ID == X.FastID;
123  }
124 
125  static unsigned ComputeHash(const SDVTListNode &X, FoldingSetNodeID &TempID) {
126  return X.HashValue;
127  }
128 };
129 
130 template <> struct ilist_alloc_traits<SDNode> {
131  static void deleteNode(SDNode *) {
132  llvm_unreachable("ilist_traits<SDNode> shouldn't see a deleteNode call!");
133  }
134 };
135 
136 /// Keeps track of dbg_value information through SDISel. We do
137 /// not build SDNodes for these so as not to perturb the generated code;
138 /// instead the info is kept off to the side in this structure. Each SDNode may
139 /// have one or more associated dbg_value entries. This information is kept in
140 /// DbgValMap.
141 /// Byval parameters are handled separately because they don't use alloca's,
142 /// which busts the normal mechanism. There is good reason for handling all
143 /// parameters separately: they may not have code generated for them, they
144 /// should always go at the beginning of the function regardless of other code
145 /// motion, and debug info for them is potentially useful even if the parameter
146 /// is unused. Right now only byval parameters are handled separately.
147 class SDDbgInfo {
148  BumpPtrAllocator Alloc;
150  SmallVector<SDDbgValue*, 32> ByvalParmDbgValues;
152  DbgValMapType DbgValMap;
153 
154 public:
155  SDDbgInfo() = default;
156  SDDbgInfo(const SDDbgInfo &) = delete;
157  SDDbgInfo &operator=(const SDDbgInfo &) = delete;
158 
159  void add(SDDbgValue *V, const SDNode *Node, bool isParameter) {
160  if (isParameter) {
161  ByvalParmDbgValues.push_back(V);
162  } else DbgValues.push_back(V);
163  if (Node)
164  DbgValMap[Node].push_back(V);
165  }
166 
167  /// \brief Invalidate all DbgValues attached to the node and remove
168  /// it from the Node-to-DbgValues map.
169  void erase(const SDNode *Node);
170 
171  void clear() {
172  DbgValMap.clear();
173  DbgValues.clear();
174  ByvalParmDbgValues.clear();
175  Alloc.Reset();
176  }
177 
178  BumpPtrAllocator &getAlloc() { return Alloc; }
179 
180  bool empty() const {
181  return DbgValues.empty() && ByvalParmDbgValues.empty();
182  }
183 
185  DbgValMapType::iterator I = DbgValMap.find(Node);
186  if (I != DbgValMap.end())
187  return I->second;
188  return ArrayRef<SDDbgValue*>();
189  }
190 
192 
193  DbgIterator DbgBegin() { return DbgValues.begin(); }
194  DbgIterator DbgEnd() { return DbgValues.end(); }
195  DbgIterator ByvalParmDbgBegin() { return ByvalParmDbgValues.begin(); }
196  DbgIterator ByvalParmDbgEnd() { return ByvalParmDbgValues.end(); }
197 };
198 
199 void checkForCycles(const SelectionDAG *DAG, bool force = false);
200 
201 /// This is used to represent a portion of an LLVM function in a low-level
202 /// Data Dependence DAG representation suitable for instruction selection.
203 /// This DAG is constructed as the first step of instruction selection in order
204 /// to allow implementation of machine specific optimizations
205 /// and code simplifications.
206 ///
207 /// The representation used by the SelectionDAG is a target-independent
208 /// representation, which has some similarities to the GCC RTL representation,
209 /// but is significantly more simple, powerful, and is a graph form instead of a
210 /// linear form.
211 ///
213  const TargetMachine &TM;
214  const SelectionDAGTargetInfo *TSI = nullptr;
215  const TargetLowering *TLI = nullptr;
216  const TargetLibraryInfo *LibInfo = nullptr;
217  MachineFunction *MF;
218  Pass *SDAGISelPass = nullptr;
220  CodeGenOpt::Level OptLevel;
221 
222  DivergenceAnalysis * DA = nullptr;
223  FunctionLoweringInfo * FLI = nullptr;
224 
225  /// The function-level optimization remark emitter. Used to emit remarks
226  /// whenever manipulating the DAG.
228 
229  /// The starting token.
230  SDNode EntryNode;
231 
232  /// The root of the entire DAG.
233  SDValue Root;
234 
235  /// A linked list of nodes in the current DAG.
236  ilist<SDNode> AllNodes;
237 
238  /// The AllocatorType for allocating SDNodes. We use
239  /// pool allocation with recycling.
241  sizeof(LargestSDNode),
242  alignof(MostAlignedSDNode)>;
243 
244  /// Pool allocation for nodes.
245  NodeAllocatorType NodeAllocator;
246 
247  /// This structure is used to memoize nodes, automatically performing
248  /// CSE with existing nodes when a duplicate is requested.
249  FoldingSet<SDNode> CSEMap;
250 
251  /// Pool allocation for machine-opcode SDNode operands.
252  BumpPtrAllocator OperandAllocator;
253  ArrayRecycler<SDUse> OperandRecycler;
254 
255  /// Pool allocation for misc. objects that are created once per SelectionDAG.
256  BumpPtrAllocator Allocator;
257 
258  /// Tracks dbg_value information through SDISel.
259  SDDbgInfo *DbgInfo;
260 
261  uint16_t NextPersistentId = 0;
262 
263 public:
264  /// Clients of various APIs that cause global effects on
265  /// the DAG can optionally implement this interface. This allows the clients
266  /// to handle the various sorts of updates that happen.
267  ///
268  /// A DAGUpdateListener automatically registers itself with DAG when it is
269  /// constructed, and removes itself when destroyed in RAII fashion.
273 
275  : Next(D.UpdateListeners), DAG(D) {
276  DAG.UpdateListeners = this;
277  }
278 
279  virtual ~DAGUpdateListener() {
280  assert(DAG.UpdateListeners == this &&
281  "DAGUpdateListeners must be destroyed in LIFO order");
282  DAG.UpdateListeners = Next;
283  }
284 
285  /// The node N that was deleted and, if E is not null, an
286  /// equivalent node E that replaced it.
287  virtual void NodeDeleted(SDNode *N, SDNode *E);
288 
289  /// The node N that was updated.
290  virtual void NodeUpdated(SDNode *N);
291  };
292 
294  std::function<void(SDNode *, SDNode *)> Callback;
295 
297  std::function<void(SDNode *, SDNode *)> Callback)
298  : DAGUpdateListener(DAG), Callback(std::move(Callback)) {}
299 
300  void NodeDeleted(SDNode *N, SDNode *E) override { Callback(N, E); }
301  };
302 
303  /// When true, additional steps are taken to
304  /// ensure that getConstant() and similar functions return DAG nodes that
305  /// have legal types. This is important after type legalization since
306  /// any illegally typed nodes generated after this point will not experience
307  /// type legalization.
308  bool NewNodesMustHaveLegalTypes = false;
309 
310 private:
311  /// DAGUpdateListener is a friend so it can manipulate the listener stack.
312  friend struct DAGUpdateListener;
313 
314  /// Linked list of registered DAGUpdateListener instances.
315  /// This stack is maintained by DAGUpdateListener RAII.
316  DAGUpdateListener *UpdateListeners = nullptr;
317 
318  /// Implementation of setSubgraphColor.
319  /// Return whether we had to truncate the search.
320  bool setSubgraphColorHelper(SDNode *N, const char *Color,
321  DenseSet<SDNode *> &visited,
322  int level, bool &printed);
323 
324  template <typename SDNodeT, typename... ArgTypes>
325  SDNodeT *newSDNode(ArgTypes &&... Args) {
326  return new (NodeAllocator.template Allocate<SDNodeT>())
327  SDNodeT(std::forward<ArgTypes>(Args)...);
328  }
329 
330  /// Build a synthetic SDNodeT with the given args and extract its subclass
331  /// data as an integer (e.g. for use in a folding set).
332  ///
333  /// The args to this function are the same as the args to SDNodeT's
334  /// constructor, except the second arg (assumed to be a const DebugLoc&) is
335  /// omitted.
336  template <typename SDNodeT, typename... ArgTypes>
337  static uint16_t getSyntheticNodeSubclassData(unsigned IROrder,
338  ArgTypes &&... Args) {
339  // The compiler can reduce this expression to a constant iff we pass an
340  // empty DebugLoc. Thankfully, the debug location doesn't have any bearing
341  // on the subclass data.
342  return SDNodeT(IROrder, DebugLoc(), std::forward<ArgTypes>(Args)...)
343  .getRawSubclassData();
344  }
345 
346  template <typename SDNodeTy>
347  static uint16_t getSyntheticNodeSubclassData(unsigned Opc, unsigned Order,
348  SDVTList VTs, EVT MemoryVT,
349  MachineMemOperand *MMO) {
350  return SDNodeTy(Opc, Order, DebugLoc(), VTs, MemoryVT, MMO)
351  .getRawSubclassData();
352  }
353 
354  void createOperands(SDNode *Node, ArrayRef<SDValue> Vals);
355 
356  void removeOperands(SDNode *Node) {
357  if (!Node->OperandList)
358  return;
359  OperandRecycler.deallocate(
360  ArrayRecycler<SDUse>::Capacity::get(Node->NumOperands),
361  Node->OperandList);
362  Node->NumOperands = 0;
363  Node->OperandList = nullptr;
364  }
365  void CreateTopologicalOrder(std::vector<SDNode*>& Order);
366 public:
367  explicit SelectionDAG(const TargetMachine &TM, CodeGenOpt::Level);
368  SelectionDAG(const SelectionDAG &) = delete;
369  SelectionDAG &operator=(const SelectionDAG &) = delete;
370  ~SelectionDAG();
371 
372  /// Prepare this SelectionDAG to process code in the given MachineFunction.
373  void init(MachineFunction &NewMF, OptimizationRemarkEmitter &NewORE,
374  Pass *PassPtr, const TargetLibraryInfo *LibraryInfo,
375  DivergenceAnalysis * DA);
376 
378  FLI = FuncInfo;
379  }
380 
381  /// Clear state and free memory necessary to make this
382  /// SelectionDAG ready to process a new block.
383  void clear();
384 
385  MachineFunction &getMachineFunction() const { return *MF; }
386  const Pass *getPass() const { return SDAGISelPass; }
387 
388  const DataLayout &getDataLayout() const { return MF->getDataLayout(); }
389  const TargetMachine &getTarget() const { return TM; }
390  const TargetSubtargetInfo &getSubtarget() const { return MF->getSubtarget(); }
391  const TargetLowering &getTargetLoweringInfo() const { return *TLI; }
392  const TargetLibraryInfo &getLibInfo() const { return *LibInfo; }
393  const SelectionDAGTargetInfo &getSelectionDAGInfo() const { return *TSI; }
394  LLVMContext *getContext() const {return Context; }
395  OptimizationRemarkEmitter &getORE() const { return *ORE; }
396 
397  /// Pop up a GraphViz/gv window with the DAG rendered using 'dot'.
398  void viewGraph(const std::string &Title);
399  void viewGraph();
400 
401 #ifndef NDEBUG
402  std::map<const SDNode *, std::string> NodeGraphAttrs;
403 #endif
404 
405  /// Clear all previously defined node graph attributes.
406  /// Intended to be used from a debugging tool (eg. gdb).
407  void clearGraphAttrs();
408 
409  /// Set graph attributes for a node. (eg. "color=red".)
410  void setGraphAttrs(const SDNode *N, const char *Attrs);
411 
412  /// Get graph attributes for a node. (eg. "color=red".)
413  /// Used from getNodeAttributes.
414  const std::string getGraphAttrs(const SDNode *N) const;
415 
416  /// Convenience for setting node color attribute.
417  void setGraphColor(const SDNode *N, const char *Color);
418 
419  /// Convenience for setting subgraph color attribute.
420  void setSubgraphColor(SDNode *N, const char *Color);
421 
423 
424  allnodes_const_iterator allnodes_begin() const { return AllNodes.begin(); }
425  allnodes_const_iterator allnodes_end() const { return AllNodes.end(); }
426 
428 
429  allnodes_iterator allnodes_begin() { return AllNodes.begin(); }
430  allnodes_iterator allnodes_end() { return AllNodes.end(); }
431 
433  return AllNodes.size();
434  }
435 
437  return make_range(allnodes_begin(), allnodes_end());
438  }
440  return make_range(allnodes_begin(), allnodes_end());
441  }
442 
443  /// Return the root tag of the SelectionDAG.
444  const SDValue &getRoot() const { return Root; }
445 
446  /// Return the token chain corresponding to the entry of the function.
448  return SDValue(const_cast<SDNode *>(&EntryNode), 0);
449  }
450 
451  /// Set the current root tag of the SelectionDAG.
452  ///
454  assert((!N.getNode() || N.getValueType() == MVT::Other) &&
455  "DAG root value is not a chain!");
456  if (N.getNode())
457  checkForCycles(N.getNode(), this);
458  Root = N;
459  if (N.getNode())
460  checkForCycles(this);
461  return Root;
462  }
463 
464  void VerifyDAGDiverence();
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  // Propagates the change in divergence to users
1132  void updateDivergence(SDNode * N);
1133 
1134  /// These are used for target selectors to *mutate* the
1135  /// specified node to have the specified return type, Target opcode, and
1136  /// operands. Note that target opcodes are stored as
1137  /// ~TargetOpcode in the node opcode field. The resultant node is returned.
1138  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT);
1139  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT, SDValue Op1);
1140  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
1141  SDValue Op1, SDValue Op2);
1142  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
1143  SDValue Op1, SDValue Op2, SDValue Op3);
1144  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT,
1145  ArrayRef<SDValue> Ops);
1146  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1, EVT VT2);
1147  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
1148  EVT VT2, ArrayRef<SDValue> Ops);
1149  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
1150  EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1151  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
1152  EVT VT2, SDValue Op1);
1153  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, EVT VT1,
1154  EVT VT2, SDValue Op1, SDValue Op2);
1155  SDNode *SelectNodeTo(SDNode *N, unsigned TargetOpc, SDVTList VTs,
1156  ArrayRef<SDValue> Ops);
1157 
1158  /// This *mutates* the specified node to have the specified
1159  /// return type, opcode, and operands.
1160  SDNode *MorphNodeTo(SDNode *N, unsigned Opc, SDVTList VTs,
1161  ArrayRef<SDValue> Ops);
1162 
1163  /// Mutate the specified strict FP node to its non-strict equivalent,
1164  /// unlinking the node from its chain and dropping the metadata arguments.
1165  /// The node must be a strict FP node.
1166  SDNode *mutateStrictFPToFP(SDNode *Node);
1167 
1168  /// These are used for target selectors to create a new node
1169  /// with specified return type(s), MachineInstr opcode, and operands.
1170  ///
1171  /// Note that getMachineNode returns the resultant node. If there is already
1172  /// a node of the specified opcode and operands, it returns that node instead
1173  /// of the current one.
1174  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT);
1175  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1176  SDValue Op1);
1177  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1178  SDValue Op1, SDValue Op2);
1179  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1180  SDValue Op1, SDValue Op2, SDValue Op3);
1181  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT,
1182  ArrayRef<SDValue> Ops);
1183  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1184  EVT VT2, SDValue Op1, SDValue Op2);
1185  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1186  EVT VT2, SDValue Op1, SDValue Op2, SDValue Op3);
1187  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1188  EVT VT2, ArrayRef<SDValue> Ops);
1189  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1190  EVT VT2, EVT VT3, SDValue Op1, SDValue Op2);
1191  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1192  EVT VT2, EVT VT3, SDValue Op1, SDValue Op2,
1193  SDValue Op3);
1194  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, EVT VT1,
1195  EVT VT2, EVT VT3, ArrayRef<SDValue> Ops);
1196  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl,
1197  ArrayRef<EVT> ResultTys, ArrayRef<SDValue> Ops);
1198  MachineSDNode *getMachineNode(unsigned Opcode, const SDLoc &dl, SDVTList VTs,
1199  ArrayRef<SDValue> Ops);
1200 
1201  /// A convenience function for creating TargetInstrInfo::EXTRACT_SUBREG nodes.
1202  SDValue getTargetExtractSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1203  SDValue Operand);
1204 
1205  /// A convenience function for creating TargetInstrInfo::INSERT_SUBREG nodes.
1206  SDValue getTargetInsertSubreg(int SRIdx, const SDLoc &DL, EVT VT,
1207  SDValue Operand, SDValue Subreg);
1208 
1209  /// Get the specified node if it's already available, or else return NULL.
1210  SDNode *getNodeIfExists(unsigned Opcode, SDVTList VTs, ArrayRef<SDValue> Ops,
1211  const SDNodeFlags Flags = SDNodeFlags());
1212 
1213  /// Creates a SDDbgValue node.
1214  SDDbgValue *getDbgValue(DIVariable *Var, DIExpression *Expr, SDNode *N,
1215  unsigned R, bool IsIndirect, const DebugLoc &DL,
1216  unsigned O);
1217 
1218  /// Creates a constant SDDbgValue node.
1219  SDDbgValue *getConstantDbgValue(DIVariable *Var, DIExpression *Expr,
1220  const Value *C, const DebugLoc &DL,
1221  unsigned O);
1222 
1223  /// Creates a FrameIndex SDDbgValue node.
1224  SDDbgValue *getFrameIndexDbgValue(DIVariable *Var, DIExpression *Expr,
1225  unsigned FI, const DebugLoc &DL,
1226  unsigned O);
1227 
1228  /// Transfer debug values from one node to another, while optionally
1229  /// generating fragment expressions for split-up values. If \p InvalidateDbg
1230  /// is set, debug values are invalidated after they are transferred.
1231  void transferDbgValues(SDValue From, SDValue To, unsigned OffsetInBits = 0,
1232  unsigned SizeInBits = 0, bool InvalidateDbg = true);
1233 
1234  /// Remove the specified node from the system. If any of its
1235  /// operands then becomes dead, remove them as well. Inform UpdateListener
1236  /// for each node deleted.
1237  void RemoveDeadNode(SDNode *N);
1238 
1239  /// This method deletes the unreachable nodes in the
1240  /// given list, and any nodes that become unreachable as a result.
1241  void RemoveDeadNodes(SmallVectorImpl<SDNode *> &DeadNodes);
1242 
1243  /// Modify anything using 'From' to use 'To' instead.
1244  /// This can cause recursive merging of nodes in the DAG. Use the first
1245  /// version if 'From' is known to have a single result, use the second
1246  /// if you have two nodes with identical results (or if 'To' has a superset
1247  /// of the results of 'From'), use the third otherwise.
1248  ///
1249  /// These methods all take an optional UpdateListener, which (if not null) is
1250  /// informed about nodes that are deleted and modified due to recursive
1251  /// changes in the dag.
1252  ///
1253  /// These functions only replace all existing uses. It's possible that as
1254  /// these replacements are being performed, CSE may cause the From node
1255  /// to be given new uses. These new uses of From are left in place, and
1256  /// not automatically transferred to To.
1257  ///
1258  void ReplaceAllUsesWith(SDValue From, SDValue Op);
1259  void ReplaceAllUsesWith(SDNode *From, SDNode *To);
1260  void ReplaceAllUsesWith(SDNode *From, const SDValue *To);
1261 
1262  /// Replace any uses of From with To, leaving
1263  /// uses of other values produced by From.getNode() alone.
1264  void ReplaceAllUsesOfValueWith(SDValue From, SDValue To);
1265 
1266  /// Like ReplaceAllUsesOfValueWith, but for multiple values at once.
1267  /// This correctly handles the case where
1268  /// there is an overlap between the From values and the To values.
1269  void ReplaceAllUsesOfValuesWith(const SDValue *From, const SDValue *To,
1270  unsigned Num);
1271 
1272  /// If an existing load has uses of its chain, create a token factor node with
1273  /// that chain and the new memory node's chain and update users of the old
1274  /// chain to the token factor. This ensures that the new memory node will have
1275  /// the same relative memory dependency position as the old load. Returns the
1276  /// new merged load chain.
1277  SDValue makeEquivalentMemoryOrdering(LoadSDNode *Old, SDValue New);
1278 
1279  /// Topological-sort the AllNodes list and a
1280  /// assign a unique node id for each node in the DAG based on their
1281  /// topological order. Returns the number of nodes.
1282  unsigned AssignTopologicalOrder();
1283 
1284  /// Move node N in the AllNodes list to be immediately
1285  /// before the given iterator Position. This may be used to update the
1286  /// topological ordering when the list of nodes is modified.
1287  void RepositionNode(allnodes_iterator Position, SDNode *N) {
1288  AllNodes.insert(Position, AllNodes.remove(N));
1289  }
1290 
1291  /// Returns an APFloat semantics tag appropriate for the given type. If VT is
1292  /// a vector type, the element semantics are returned.
1294  switch (VT.getScalarType().getSimpleVT().SimpleTy) {
1295  default: llvm_unreachable("Unknown FP format");
1296  case MVT::f16: return APFloat::IEEEhalf();
1297  case MVT::f32: return APFloat::IEEEsingle();
1298  case MVT::f64: return APFloat::IEEEdouble();
1299  case MVT::f80: return APFloat::x87DoubleExtended();
1300  case MVT::f128: return APFloat::IEEEquad();
1301  case MVT::ppcf128: return APFloat::PPCDoubleDouble();
1302  }
1303  }
1304 
1305  /// Add a dbg_value SDNode. If SD is non-null that means the
1306  /// value is produced by SD.
1307  void AddDbgValue(SDDbgValue *DB, SDNode *SD, bool isParameter);
1308 
1309  /// Get the debug values which reference the given SDNode.
1311  return DbgInfo->getSDDbgValues(SD);
1312  }
1313 
1314 public:
1315  /// Return true if there are any SDDbgValue nodes associated
1316  /// with this SelectionDAG.
1317  bool hasDebugValues() const { return !DbgInfo->empty(); }
1318 
1319  SDDbgInfo::DbgIterator DbgBegin() { return DbgInfo->DbgBegin(); }
1320  SDDbgInfo::DbgIterator DbgEnd() { return DbgInfo->DbgEnd(); }
1321 
1323  return DbgInfo->ByvalParmDbgBegin();
1324  }
1325 
1327  return DbgInfo->ByvalParmDbgEnd();
1328  }
1329 
1330  /// To be invoked on an SDNode that is slated to be erased. This
1331  /// function mirrors \c llvm::salvageDebugInfo.
1332  void salvageDebugInfo(SDNode &N);
1333 
1334  void dump() const;
1335 
1336  /// Create a stack temporary, suitable for holding the specified value type.
1337  /// If minAlign is specified, the slot size will have at least that alignment.
1338  SDValue CreateStackTemporary(EVT VT, unsigned minAlign = 1);
1339 
1340  /// Create a stack temporary suitable for holding either of the specified
1341  /// value types.
1342  SDValue CreateStackTemporary(EVT VT1, EVT VT2);
1343 
1344  SDValue FoldSymbolOffset(unsigned Opcode, EVT VT,
1345  const GlobalAddressSDNode *GA,
1346  const SDNode *N2);
1347 
1348  SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1349  SDNode *Cst1, SDNode *Cst2);
1350 
1351  SDValue FoldConstantArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1352  const ConstantSDNode *Cst1,
1353  const ConstantSDNode *Cst2);
1354 
1355  SDValue FoldConstantVectorArithmetic(unsigned Opcode, const SDLoc &DL, EVT VT,
1356  ArrayRef<SDValue> Ops,
1357  const SDNodeFlags Flags = SDNodeFlags());
1358 
1359  /// Constant fold a setcc to true or false.
1360  SDValue FoldSetCC(EVT VT, SDValue N1, SDValue N2, ISD::CondCode Cond,
1361  const SDLoc &dl);
1362 
1363  /// See if the specified operand can be simplified with the knowledge that only
1364  /// the bits specified by Mask are used. If so, return the simpler operand,
1365  /// otherwise return a null SDValue.
1366  ///
1367  /// (This exists alongside SimplifyDemandedBits because GetDemandedBits can
1368  /// simplify nodes with multiple uses more aggressively.)
1369  SDValue GetDemandedBits(SDValue V, const APInt &Mask);
1370 
1371  /// Return true if the sign bit of Op is known to be zero.
1372  /// We use this predicate to simplify operations downstream.
1373  bool SignBitIsZero(SDValue Op, unsigned Depth = 0) const;
1374 
1375  /// Return true if 'Op & Mask' is known to be zero. We
1376  /// use this predicate to simplify operations downstream. Op and Mask are
1377  /// known to be the same type.
1378  bool MaskedValueIsZero(SDValue Op, const APInt &Mask, unsigned Depth = 0)
1379  const;
1380 
1381  /// Determine which bits of Op are known to be either zero or one and return
1382  /// them in Known. For vectors, the known bits are those that are shared by
1383  /// every vector element.
1384  /// Targets can implement the computeKnownBitsForTargetNode method in the
1385  /// TargetLowering class to allow target nodes to be understood.
1386  void computeKnownBits(SDValue Op, KnownBits &Known, unsigned Depth = 0) const;
1387 
1388  /// Determine which bits of Op are known to be either zero or one and return
1389  /// them in Known. The DemandedElts argument allows us to only collect the
1390  /// known bits that are shared by the requested vector elements.
1391  /// Targets can implement the computeKnownBitsForTargetNode method in the
1392  /// TargetLowering class to allow target nodes to be understood.
1393  void computeKnownBits(SDValue Op, KnownBits &Known, const APInt &DemandedElts,
1394  unsigned Depth = 0) const;
1395 
1396  /// Used to represent the possible overflow behavior of an operation.
1397  /// Never: the operation cannot overflow.
1398  /// Always: the operation will always overflow.
1399  /// Sometime: the operation may or may not overflow.
1404  };
1405 
1406  /// Determine if the result of the addition of 2 node can overflow.
1407  OverflowKind computeOverflowKind(SDValue N0, SDValue N1) const;
1408 
1409  /// Test if the given value is known to have exactly one bit set. This differs
1410  /// from computeKnownBits in that it doesn't necessarily determine which bit
1411  /// is set.
1412  bool isKnownToBeAPowerOfTwo(SDValue Val) const;
1413 
1414  /// Return the number of times the sign bit of the register is replicated into
1415  /// the other bits. We know that at least 1 bit is always equal to the sign
1416  /// bit (itself), but other cases can give us information. For example,
1417  /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
1418  /// to each other, so we return 3. Targets can implement the
1419  /// ComputeNumSignBitsForTarget method in the TargetLowering class to allow
1420  /// target nodes to be understood.
1421  unsigned ComputeNumSignBits(SDValue Op, unsigned Depth = 0) const;
1422 
1423  /// Return the number of times the sign bit of the register is replicated into
1424  /// the other bits. We know that at least 1 bit is always equal to the sign
1425  /// bit (itself), but other cases can give us information. For example,
1426  /// immediately after an "SRA X, 2", we know that the top 3 bits are all equal
1427  /// to each other, so we return 3. The DemandedElts argument allows
1428  /// us to only collect the minimum sign bits of the requested vector elements.
1429  /// Targets can implement the ComputeNumSignBitsForTarget method in the
1430  /// TargetLowering class to allow target nodes to be understood.
1431  unsigned ComputeNumSignBits(SDValue Op, const APInt &DemandedElts,
1432  unsigned Depth = 0) const;
1433 
1434  /// Return true if the specified operand is an ISD::ADD with a ConstantSDNode
1435  /// on the right-hand side, or if it is an ISD::OR with a ConstantSDNode that
1436  /// is guaranteed to have the same semantics as an ADD. This handles the
1437  /// equivalence:
1438  /// X|Cst == X+Cst iff X&Cst = 0.
1439  bool isBaseWithConstantOffset(SDValue Op) const;
1440 
1441  /// Test whether the given SDValue is known to never be NaN.
1442  bool isKnownNeverNaN(SDValue Op) const;
1443 
1444  /// Test whether the given SDValue is known to never be positive or negative
1445  /// zero.
1446  bool isKnownNeverZero(SDValue Op) const;
1447 
1448  /// Test whether two SDValues are known to compare equal. This
1449  /// is true if they are the same value, or if one is negative zero and the
1450  /// other positive zero.
1451  bool isEqualTo(SDValue A, SDValue B) const;
1452 
1453  /// Return true if A and B have no common bits set. As an example, this can
1454  /// allow an 'add' to be transformed into an 'or'.
1455  bool haveNoCommonBitsSet(SDValue A, SDValue B) const;
1456 
1457  /// Utility function used by legalize and lowering to
1458  /// "unroll" a vector operation by splitting out the scalars and operating
1459  /// on each element individually. If the ResNE is 0, fully unroll the vector
1460  /// op. If ResNE is less than the width of the vector op, unroll up to ResNE.
1461  /// If the ResNE is greater than the width of the vector op, unroll the
1462  /// vector op and fill the end of the resulting vector with UNDEFS.
1463  SDValue UnrollVectorOp(SDNode *N, unsigned ResNE = 0);
1464 
1465  /// Return true if loads are next to each other and can be
1466  /// merged. Check that both are nonvolatile and if LD is loading
1467  /// 'Bytes' bytes from a location that is 'Dist' units away from the
1468  /// location that the 'Base' load is loading from.
1469  bool areNonVolatileConsecutiveLoads(LoadSDNode *LD, LoadSDNode *Base,
1470  unsigned Bytes, int Dist) const;
1471 
1472  /// Infer alignment of a load / store address. Return 0 if
1473  /// it cannot be inferred.
1474  unsigned InferPtrAlignment(SDValue Ptr) const;
1475 
1476  /// Compute the VTs needed for the low/hi parts of a type
1477  /// which is split (or expanded) into two not necessarily identical pieces.
1478  std::pair<EVT, EVT> GetSplitDestVTs(const EVT &VT) const;
1479 
1480  /// Split the vector with EXTRACT_SUBVECTOR using the provides
1481  /// VTs and return the low/high part.
1482  std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL,
1483  const EVT &LoVT, const EVT &HiVT);
1484 
1485  /// Split the vector with EXTRACT_SUBVECTOR and return the low/high part.
1486  std::pair<SDValue, SDValue> SplitVector(const SDValue &N, const SDLoc &DL) {
1487  EVT LoVT, HiVT;
1488  std::tie(LoVT, HiVT) = GetSplitDestVTs(N.getValueType());
1489  return SplitVector(N, DL, LoVT, HiVT);
1490  }
1491 
1492  /// Split the node's operand with EXTRACT_SUBVECTOR and
1493  /// return the low/high part.
1494  std::pair<SDValue, SDValue> SplitVectorOperand(const SDNode *N, unsigned OpNo)
1495  {
1496  return SplitVector(N->getOperand(OpNo), SDLoc(N));
1497  }
1498 
1499  /// Append the extracted elements from Start to Count out of the vector Op
1500  /// in Args. If Count is 0, all of the elements will be extracted.
1501  void ExtractVectorElements(SDValue Op, SmallVectorImpl<SDValue> &Args,
1502  unsigned Start = 0, unsigned Count = 0);
1503 
1504  /// Compute the default alignment value for the given type.
1505  unsigned getEVTAlignment(EVT MemoryVT) const;
1506 
1507  /// Test whether the given value is a constant int or similar node.
1508  SDNode *isConstantIntBuildVectorOrConstantInt(SDValue N);
1509 
1510  /// Test whether the given value is a constant FP or similar node.
1512 
1513  /// \returns true if \p N is any kind of constant or build_vector of
1514  /// constants, int or float. If a vector, it may not necessarily be a splat.
1516  return isConstantIntBuildVectorOrConstantInt(N) ||
1518  }
1519 
1520 private:
1521  void InsertNode(SDNode *N);
1522  bool RemoveNodeFromCSEMaps(SDNode *N);
1523  void AddModifiedNodeToCSEMaps(SDNode *N);
1524  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op, void *&InsertPos);
1525  SDNode *FindModifiedNodeSlot(SDNode *N, SDValue Op1, SDValue Op2,
1526  void *&InsertPos);
1527  SDNode *FindModifiedNodeSlot(SDNode *N, ArrayRef<SDValue> Ops,
1528  void *&InsertPos);
1529  SDNode *UpdateSDLocOnMergeSDNode(SDNode *N, const SDLoc &loc);
1530 
1531  void DeleteNodeNotInCSEMaps(SDNode *N);
1532  void DeallocateNode(SDNode *N);
1533 
1534  void allnodes_clear();
1535 
1536  /// Look up the node specified by ID in CSEMap. If it exists, return it. If
1537  /// not, return the insertion token that will make insertion faster. This
1538  /// overload is for nodes other than Constant or ConstantFP, use the other one
1539  /// for those.
1540  SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, void *&InsertPos);
1541 
1542  /// Look up the node specified by ID in CSEMap. If it exists, return it. If
1543  /// not, return the insertion token that will make insertion faster. Performs
1544  /// additional processing for constant nodes.
1545  SDNode *FindNodeOrInsertPos(const FoldingSetNodeID &ID, const SDLoc &DL,
1546  void *&InsertPos);
1547 
1548  /// List of non-single value types.
1549  FoldingSet<SDVTListNode> VTListMap;
1550 
1551  /// Maps to auto-CSE operations.
1552  std::vector<CondCodeSDNode*> CondCodeNodes;
1553 
1554  std::vector<SDNode*> ValueTypeNodes;
1555  std::map<EVT, SDNode*, EVT::compareRawBits> ExtendedValueTypeNodes;
1556  StringMap<SDNode*> ExternalSymbols;
1557 
1558  std::map<std::pair<std::string, unsigned char>,SDNode*> TargetExternalSymbols;
1560 };
1561 
1562 template <> struct GraphTraits<SelectionDAG*> : public GraphTraits<SDNode*> {
1564 
1566  return nodes_iterator(G->allnodes_begin());
1567  }
1568 
1570  return nodes_iterator(G->allnodes_end());
1571  }
1572 };
1573 
1574 template <class TargetMemSDNode>
1576  ArrayRef<SDValue> Ops,
1577  const SDLoc &dl, EVT MemVT,
1578  MachineMemOperand *MMO) {
1579  /// Compose node ID and try to find an existing node.
1581  unsigned Opcode =
1582  TargetMemSDNode(dl.getIROrder(), DebugLoc(), VTs, MemVT, MMO).getOpcode();
1583  ID.AddInteger(Opcode);
1584  ID.AddPointer(VTs.VTs);
1585  for (auto& Op : Ops) {
1586  ID.AddPointer(Op.getNode());
1587  ID.AddInteger(Op.getResNo());
1588  }
1589  ID.AddInteger(MemVT.getRawBits());
1590  ID.AddInteger(MMO->getPointerInfo().getAddrSpace());
1591  ID.AddInteger(getSyntheticNodeSubclassData<TargetMemSDNode>(
1592  dl.getIROrder(), VTs, MemVT, MMO));
1593 
1594  void *IP = nullptr;
1595  if (SDNode *E = FindNodeOrInsertPos(ID, dl, IP)) {
1596  cast<TargetMemSDNode>(E)->refineAlignment(MMO);
1597  return SDValue(E, 0);
1598  }
1599 
1600  /// Existing node was not found. Create a new one.
1601  auto *N = newSDNode<TargetMemSDNode>(dl.getIROrder(), dl.getDebugLoc(), VTs,
1602  MemVT, MMO);
1603  createOperands(N, Ops);
1604  CSEMap.InsertNode(N, IP);
1605  InsertNode(N);
1606  return SDValue(N, 0);
1607 }
1608 
1609 } // end namespace llvm
1610 
1611 #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:392
LLVMContext & Context
Keeps track of dbg_value information through SDISel.
Definition: SelectionDAG.h:147
SDValue getSetCC(const SDLoc &DL, EVT VT, SDValue LHS, SDValue RHS, ISD::CondCode Cond)
Helper function to make it easier to build SetCC&#39;s if you just have an ISD::CondCode instead of an SD...
Definition: SelectionDAG.h: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)
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:196
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:270
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:118
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:193
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:453
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:826
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:682
void AddInteger(signed I)
Definition: FoldingSet.cpp:61
SmallVectorImpl< SDDbgValue * >::iterator DbgIterator
Definition: SelectionDAG.h:191
SDValue getEntryNode() const
Return the token chain corresponding to the entry of the function.
Definition: SelectionDAG.h:447
const DataLayout & getDataLayout() const
Definition: SelectionDAG.h:388
void setFunctionLoweringInfo(FunctionLoweringInfo *FuncInfo)
Definition: SelectionDAG.h:377
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:436
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:385
DAGUpdateListener *const Next
Definition: SelectionDAG.h:271
SDValue getTargetFrameIndex(int FI, EVT VT)
Definition: SelectionDAG.h:613
const TargetMachine & getTarget() const
Definition: SelectionDAG.h:389
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:1505
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:919
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:430
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:429
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:296
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:393
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
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:894
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:180
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:178
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:386
ArrayRef< SDDbgValue * > getSDDbgValues(const SDNode *Node)
Definition: SelectionDAG.h:184
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:439
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:391
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:432
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:212
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:194
allnodes_const_iterator allnodes_begin() const
Definition: SelectionDAG.h:424
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:294
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:211
Flags
Flags values. These may be or&#39;d together.
AlignedCharArrayUnion< AtomicSDNode, TargetIndexSDNode, BlockAddressSDNode, GlobalAddressSDNode > LargestSDNode
A representation of the largest SDNode, for use in sizeof().
The memory access reads data.
TargetSubtargetInfo - Generic base class for all target subtargets.
bool isConstantValueOfAnyType(SDValue N)
SDValue getTargetConstant(const APInt &Val, const SDLoc &DL, EVT VT, bool isOpaque=false)
Definition: SelectionDAG.h:565
std::map< const SDNode *, std::string > NodeGraphAttrs
Definition: SelectionDAG.h:402
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:425
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:100
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:125
#define I(x, y, z)
Definition: MD5.cpp:58
#define N
const TargetSubtargetInfo & getSubtarget() const
Definition: SelectionDAG.h:390
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: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:444
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:105
std::underlying_type< E >::type Mask()
Get a bitmask with 1s in all places up to the high-order bit of E&#39;s largest value.
Definition: BitmaskEnum.h:81
DefaultFoldingSetTrait - This class provides default implementations for FoldingSetTrait implementati...
Definition: FoldingSet.h:221
OptimizationRemarkEmitter & getORE() const
Definition: SelectionDAG.h:395
static void deleteNode(SDNode *)
Definition: SelectionDAG.h:131
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:159
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:195
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:114
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:300
LLVMContext * getContext() const
Definition: SelectionDAG.h:394
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:874
This class is used to represent ISD::LOAD nodes.