Coverage Report

Created: 2018-11-12 17:33

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