Coverage Report

Created: 2019-02-20 00:17

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