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