Coverage Report

Created: 2019-07-24 05:18

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