LLVM  3.7.0
RegAllocPBQP.h
Go to the documentation of this file.
1 //===-- RegAllocPBQP.h ------------------------------------------*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 //
10 // This file defines the PBQPBuilder interface, for classes which build PBQP
11 // instances to represent register allocation problems, and the RegAllocPBQP
12 // interface.
13 //
14 //===----------------------------------------------------------------------===//
15 
16 #ifndef LLVM_CODEGEN_REGALLOCPBQP_H
17 #define LLVM_CODEGEN_REGALLOCPBQP_H
18 
24 
25 namespace llvm {
26 
27 class raw_ostream;
28 
29 namespace PBQP {
30 namespace RegAlloc {
31 
32 /// @brief Spill option index.
33 inline unsigned getSpillOptionIdx() { return 0; }
34 
35 /// \brief Metadata to speed allocatability test.
36 ///
37 /// Keeps track of the number of infinities in each row and column.
39 private:
41  void operator=(const MatrixMetadata&);
42 public:
44  : WorstRow(0), WorstCol(0),
45  UnsafeRows(new bool[M.getRows() - 1]()),
46  UnsafeCols(new bool[M.getCols() - 1]()) {
47 
48  unsigned* ColCounts = new unsigned[M.getCols() - 1]();
49 
50  for (unsigned i = 1; i < M.getRows(); ++i) {
51  unsigned RowCount = 0;
52  for (unsigned j = 1; j < M.getCols(); ++j) {
53  if (M[i][j] == std::numeric_limits<PBQPNum>::infinity()) {
54  ++RowCount;
55  ++ColCounts[j - 1];
56  UnsafeRows[i - 1] = true;
57  UnsafeCols[j - 1] = true;
58  }
59  }
60  WorstRow = std::max(WorstRow, RowCount);
61  }
62  unsigned WorstColCountForCurRow =
63  *std::max_element(ColCounts, ColCounts + M.getCols() - 1);
64  WorstCol = std::max(WorstCol, WorstColCountForCurRow);
65  delete[] ColCounts;
66  }
67 
68  unsigned getWorstRow() const { return WorstRow; }
69  unsigned getWorstCol() const { return WorstCol; }
70  const bool* getUnsafeRows() const { return UnsafeRows.get(); }
71  const bool* getUnsafeCols() const { return UnsafeCols.get(); }
72 
73 private:
74  unsigned WorstRow, WorstCol;
75  std::unique_ptr<bool[]> UnsafeRows;
76  std::unique_ptr<bool[]> UnsafeCols;
77 };
78 
79 /// \brief Holds a vector of the allowed physical regs for a vreg.
81  friend hash_code hash_value(const AllowedRegVector &);
82 public:
83 
84  AllowedRegVector() : NumOpts(0), Opts(nullptr) {}
85 
86  AllowedRegVector(const std::vector<unsigned> &OptVec)
87  : NumOpts(OptVec.size()), Opts(new unsigned[NumOpts]) {
88  std::copy(OptVec.begin(), OptVec.end(), Opts.get());
89  }
90 
92  : NumOpts(Other.NumOpts), Opts(new unsigned[NumOpts]) {
93  std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get());
94  }
95 
97  : NumOpts(std::move(Other.NumOpts)), Opts(std::move(Other.Opts)) {}
98 
100  NumOpts = Other.NumOpts;
101  Opts.reset(new unsigned[NumOpts]);
102  std::copy(Other.Opts.get(), Other.Opts.get() + NumOpts, Opts.get());
103  return *this;
104  }
105 
107  NumOpts = std::move(Other.NumOpts);
108  Opts = std::move(Other.Opts);
109  return *this;
110  }
111 
112  unsigned size() const { return NumOpts; }
113  unsigned operator[](size_t I) const { return Opts[I]; }
114 
115  bool operator==(const AllowedRegVector &Other) const {
116  if (NumOpts != Other.NumOpts)
117  return false;
118  return std::equal(Opts.get(), Opts.get() + NumOpts, Other.Opts.get());
119  }
120 
121  bool operator!=(const AllowedRegVector &Other) const {
122  return !(*this == Other);
123  }
124 
125 private:
126  unsigned NumOpts;
127  std::unique_ptr<unsigned[]> Opts;
128 };
129 
130 inline hash_code hash_value(const AllowedRegVector &OptRegs) {
131  unsigned *OStart = OptRegs.Opts.get();
132  unsigned *OEnd = OptRegs.Opts.get() + OptRegs.NumOpts;
133  return hash_combine(OptRegs.NumOpts,
134  hash_combine_range(OStart, OEnd));
135 }
136 
137 /// \brief Holds graph-level metadata relevent to PBQP RA problems.
139 private:
141 public:
142 
144 
148  : MF(MF), LIS(LIS), MBFI(MBFI) {}
149 
153 
154  void setNodeIdForVReg(unsigned VReg, GraphBase::NodeId NId) {
155  VRegToNodeId[VReg] = NId;
156  }
157 
158  GraphBase::NodeId getNodeIdForVReg(unsigned VReg) const {
159  auto VRegItr = VRegToNodeId.find(VReg);
160  if (VRegItr == VRegToNodeId.end())
161  return GraphBase::invalidNodeId();
162  return VRegItr->second;
163  }
164 
165  void eraseNodeIdForVReg(unsigned VReg) {
166  VRegToNodeId.erase(VReg);
167  }
168 
170  return AllowedRegVecs.getValue(std::move(Allowed));
171  }
172 
173 private:
175  AllowedRegVecPool AllowedRegVecs;
176 };
177 
178 /// \brief Holds solver state and other metadata relevant to each PBQP RA node.
180 public:
182 
183  // The node's reduction state. The order in this enum is important,
184  // as it is assumed nodes can only progress up (i.e. towards being
185  // optimally reducible) when reducing the graph.
186  typedef enum {
191  } ReductionState;
192 
194  : RS(Unprocessed), NumOpts(0), DeniedOpts(0), OptUnsafeEdges(nullptr),
195  VReg(0)
196 #ifndef NDEBUG
197  , everConservativelyAllocatable(false)
198 #endif
199  {}
200 
201  // FIXME: Re-implementing default behavior to work around MSVC. Remove once
202  // MSVC synthesizes move constructors properly.
204  : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
205  OptUnsafeEdges(new unsigned[NumOpts]), VReg(Other.VReg),
206  AllowedRegs(Other.AllowedRegs)
207 #ifndef NDEBUG
208  , everConservativelyAllocatable(Other.everConservativelyAllocatable)
209 #endif
210  {
211  if (NumOpts > 0) {
212  std::copy(&Other.OptUnsafeEdges[0], &Other.OptUnsafeEdges[NumOpts],
213  &OptUnsafeEdges[0]);
214  }
215  }
216 
217  // FIXME: Re-implementing default behavior to work around MSVC. Remove once
218  // MSVC synthesizes move constructors properly.
220  : RS(Other.RS), NumOpts(Other.NumOpts), DeniedOpts(Other.DeniedOpts),
221  OptUnsafeEdges(std::move(Other.OptUnsafeEdges)), VReg(Other.VReg),
222  AllowedRegs(std::move(Other.AllowedRegs))
223 #ifndef NDEBUG
224  , everConservativelyAllocatable(Other.everConservativelyAllocatable)
225 #endif
226  {}
227 
228  // FIXME: Re-implementing default behavior to work around MSVC. Remove once
229  // MSVC synthesizes move constructors properly.
231  RS = Other.RS;
232  NumOpts = Other.NumOpts;
233  DeniedOpts = Other.DeniedOpts;
234  OptUnsafeEdges.reset(new unsigned[NumOpts]);
235  std::copy(Other.OptUnsafeEdges.get(), Other.OptUnsafeEdges.get() + NumOpts,
236  OptUnsafeEdges.get());
237  VReg = Other.VReg;
238  AllowedRegs = Other.AllowedRegs;
239 #ifndef NDEBUG
240  everConservativelyAllocatable = Other.everConservativelyAllocatable;
241 #endif
242  return *this;
243  }
244 
245  // FIXME: Re-implementing default behavior to work around MSVC. Remove once
246  // MSVC synthesizes move constructors properly.
248  RS = Other.RS;
249  NumOpts = Other.NumOpts;
250  DeniedOpts = Other.DeniedOpts;
251  OptUnsafeEdges = std::move(Other.OptUnsafeEdges);
252  VReg = Other.VReg;
253  AllowedRegs = std::move(Other.AllowedRegs);
254 #ifndef NDEBUG
255  everConservativelyAllocatable = Other.everConservativelyAllocatable;
256 #endif
257  return *this;
258  }
259 
260  void setVReg(unsigned VReg) { this->VReg = VReg; }
261  unsigned getVReg() const { return VReg; }
262 
264  this->AllowedRegs = std::move(AllowedRegs);
265  }
266  const AllowedRegVector& getAllowedRegs() const { return *AllowedRegs; }
267 
268  void setup(const Vector& Costs) {
269  NumOpts = Costs.getLength() - 1;
270  OptUnsafeEdges = std::unique_ptr<unsigned[]>(new unsigned[NumOpts]());
271  }
272 
273  ReductionState getReductionState() const { return RS; }
275  assert(RS >= this->RS && "A node's reduction state can not be downgraded");
276  this->RS = RS;
277 
278 #ifndef NDEBUG
279  // Remember this state to assert later that a non-infinite register
280  // option was available.
281  if (RS == ConservativelyAllocatable)
282  everConservativelyAllocatable = true;
283 #endif
284  }
285 
286 
287  void handleAddEdge(const MatrixMetadata& MD, bool Transpose) {
288  DeniedOpts += Transpose ? MD.getWorstRow() : MD.getWorstCol();
289  const bool* UnsafeOpts =
290  Transpose ? MD.getUnsafeCols() : MD.getUnsafeRows();
291  for (unsigned i = 0; i < NumOpts; ++i)
292  OptUnsafeEdges[i] += UnsafeOpts[i];
293  }
294 
295  void handleRemoveEdge(const MatrixMetadata& MD, bool Transpose) {
296  DeniedOpts -= Transpose ? MD.getWorstRow() : MD.getWorstCol();
297  const bool* UnsafeOpts =
298  Transpose ? MD.getUnsafeCols() : MD.getUnsafeRows();
299  for (unsigned i = 0; i < NumOpts; ++i)
300  OptUnsafeEdges[i] -= UnsafeOpts[i];
301  }
302 
304  return (DeniedOpts < NumOpts) ||
305  (std::find(&OptUnsafeEdges[0], &OptUnsafeEdges[NumOpts], 0) !=
306  &OptUnsafeEdges[NumOpts]);
307  }
308 
309 #ifndef NDEBUG
311  return everConservativelyAllocatable;
312  }
313 #endif
314 
315 private:
316  ReductionState RS;
317  unsigned NumOpts;
318  unsigned DeniedOpts;
319  std::unique_ptr<unsigned[]> OptUnsafeEdges;
320  unsigned VReg;
322 
323 #ifndef NDEBUG
324  bool everConservativelyAllocatable;
325 #endif
326 };
327 
329 private:
331 public:
335  typedef RAMatrix Matrix;
337 
340 
342  struct EdgeMetadata { };
344 
346 
347  RegAllocSolverImpl(Graph &G) : G(G) {}
348 
350  G.setSolver(*this);
351  Solution S;
352  setup();
353  S = backpropagate(G, reduce());
354  G.unsetSolver();
355  return S;
356  }
357 
358  void handleAddNode(NodeId NId) {
359  assert(G.getNodeCosts(NId).getLength() > 1 &&
360  "PBQP Graph should not contain single or zero-option nodes");
361  G.getNodeMetadata(NId).setup(G.getNodeCosts(NId));
362  }
364  void handleSetNodeCosts(NodeId NId, const Vector& newCosts) {}
365 
366  void handleAddEdge(EdgeId EId) {
367  handleReconnectEdge(EId, G.getEdgeNode1Id(EId));
368  handleReconnectEdge(EId, G.getEdgeNode2Id(EId));
369  }
370 
374  }
375 
377  NodeMetadata& NMd = G.getNodeMetadata(NId);
378  const MatrixMetadata& MMd = G.getEdgeCosts(EId).getMetadata();
379  NMd.handleRemoveEdge(MMd, NId == G.getEdgeNode2Id(EId));
380  promote(NId, NMd);
381  }
382 
384  NodeMetadata& NMd = G.getNodeMetadata(NId);
385  const MatrixMetadata& MMd = G.getEdgeCosts(EId).getMetadata();
386  NMd.handleAddEdge(MMd, NId == G.getEdgeNode2Id(EId));
387  }
388 
389  void handleUpdateCosts(EdgeId EId, const Matrix& NewCosts) {
390  NodeId N1Id = G.getEdgeNode1Id(EId);
391  NodeId N2Id = G.getEdgeNode2Id(EId);
392  NodeMetadata& N1Md = G.getNodeMetadata(N1Id);
393  NodeMetadata& N2Md = G.getNodeMetadata(N2Id);
394  bool Transpose = N1Id != G.getEdgeNode1Id(EId);
395 
396  // Metadata are computed incrementally. First, update them
397  // by removing the old cost.
398  const MatrixMetadata& OldMMd = G.getEdgeCosts(EId).getMetadata();
399  N1Md.handleRemoveEdge(OldMMd, Transpose);
400  N2Md.handleRemoveEdge(OldMMd, !Transpose);
401 
402  // And update now the metadata with the new cost.
403  const MatrixMetadata& MMd = NewCosts.getMetadata();
404  N1Md.handleAddEdge(MMd, Transpose);
405  N2Md.handleAddEdge(MMd, !Transpose);
406 
407  // As the metadata may have changed with the update, the nodes may have
408  // become ConservativelyAllocatable or OptimallyReducible.
409  promote(N1Id, N1Md);
410  promote(N2Id, N2Md);
411  }
412 
413 private:
414 
415  void promote(NodeId NId, NodeMetadata& NMd) {
416  if (G.getNodeDegree(NId) == 3) {
417  // This node is becoming optimally reducible.
418  moveToOptimallyReducibleNodes(NId);
419  } else if (NMd.getReductionState() ==
422  // This node just became conservatively allocatable.
423  moveToConservativelyAllocatableNodes(NId);
424  }
425  }
426 
427  void removeFromCurrentSet(NodeId NId) {
428  switch (G.getNodeMetadata(NId).getReductionState()) {
429  case NodeMetadata::Unprocessed: break;
431  assert(OptimallyReducibleNodes.find(NId) !=
432  OptimallyReducibleNodes.end() &&
433  "Node not in optimally reducible set.");
434  OptimallyReducibleNodes.erase(NId);
435  break;
437  assert(ConservativelyAllocatableNodes.find(NId) !=
438  ConservativelyAllocatableNodes.end() &&
439  "Node not in conservatively allocatable set.");
440  ConservativelyAllocatableNodes.erase(NId);
441  break;
443  assert(NotProvablyAllocatableNodes.find(NId) !=
444  NotProvablyAllocatableNodes.end() &&
445  "Node not in not-provably-allocatable set.");
446  NotProvablyAllocatableNodes.erase(NId);
447  break;
448  }
449  }
450 
451  void moveToOptimallyReducibleNodes(NodeId NId) {
452  removeFromCurrentSet(NId);
453  OptimallyReducibleNodes.insert(NId);
456  }
457 
458  void moveToConservativelyAllocatableNodes(NodeId NId) {
459  removeFromCurrentSet(NId);
460  ConservativelyAllocatableNodes.insert(NId);
463  }
464 
465  void moveToNotProvablyAllocatableNodes(NodeId NId) {
466  removeFromCurrentSet(NId);
467  NotProvablyAllocatableNodes.insert(NId);
470  }
471 
472  void setup() {
473  // Set up worklists.
474  for (auto NId : G.nodeIds()) {
475  if (G.getNodeDegree(NId) < 3)
476  moveToOptimallyReducibleNodes(NId);
478  moveToConservativelyAllocatableNodes(NId);
479  else
480  moveToNotProvablyAllocatableNodes(NId);
481  }
482  }
483 
484  // Compute a reduction order for the graph by iteratively applying PBQP
485  // reduction rules. Locally optimal rules are applied whenever possible (R0,
486  // R1, R2). If no locally-optimal rules apply then any conservatively
487  // allocatable node is reduced. Finally, if no conservatively allocatable
488  // node exists then the node with the lowest spill-cost:degree ratio is
489  // selected.
490  std::vector<GraphBase::NodeId> reduce() {
491  assert(!G.empty() && "Cannot reduce empty graph.");
492 
493  typedef GraphBase::NodeId NodeId;
494  std::vector<NodeId> NodeStack;
495 
496  // Consume worklists.
497  while (true) {
498  if (!OptimallyReducibleNodes.empty()) {
499  NodeSet::iterator NItr = OptimallyReducibleNodes.begin();
500  NodeId NId = *NItr;
501  OptimallyReducibleNodes.erase(NItr);
502  NodeStack.push_back(NId);
503  switch (G.getNodeDegree(NId)) {
504  case 0:
505  break;
506  case 1:
507  applyR1(G, NId);
508  break;
509  case 2:
510  applyR2(G, NId);
511  break;
512  default: llvm_unreachable("Not an optimally reducible node.");
513  }
514  } else if (!ConservativelyAllocatableNodes.empty()) {
515  // Conservatively allocatable nodes will never spill. For now just
516  // take the first node in the set and push it on the stack. When we
517  // start optimizing more heavily for register preferencing, it may
518  // would be better to push nodes with lower 'expected' or worst-case
519  // register costs first (since early nodes are the most
520  // constrained).
521  NodeSet::iterator NItr = ConservativelyAllocatableNodes.begin();
522  NodeId NId = *NItr;
523  ConservativelyAllocatableNodes.erase(NItr);
524  NodeStack.push_back(NId);
526 
527  } else if (!NotProvablyAllocatableNodes.empty()) {
528  NodeSet::iterator NItr =
529  std::min_element(NotProvablyAllocatableNodes.begin(),
530  NotProvablyAllocatableNodes.end(),
531  SpillCostComparator(G));
532  NodeId NId = *NItr;
533  NotProvablyAllocatableNodes.erase(NItr);
534  NodeStack.push_back(NId);
536  } else
537  break;
538  }
539 
540  return NodeStack;
541  }
542 
543  class SpillCostComparator {
544  public:
545  SpillCostComparator(const Graph& G) : G(G) {}
546  bool operator()(NodeId N1Id, NodeId N2Id) {
547  PBQPNum N1SC = G.getNodeCosts(N1Id)[0];
548  PBQPNum N2SC = G.getNodeCosts(N2Id)[0];
549  if (N1SC == N2SC)
550  return G.getNodeDegree(N1Id) < G.getNodeDegree(N2Id);
551  return N1SC < N2SC;
552  }
553  private:
554  const Graph& G;
555  };
556 
557  Graph& G;
558  typedef std::set<NodeId> NodeSet;
559  NodeSet OptimallyReducibleNodes;
560  NodeSet ConservativelyAllocatableNodes;
561  NodeSet NotProvablyAllocatableNodes;
562 };
563 
564 class PBQPRAGraph : public PBQP::Graph<RegAllocSolverImpl> {
565 private:
567 public:
569 
570  /// @brief Dump this graph to dbgs().
571  void dump() const;
572 
573  /// @brief Dump this graph to an output stream.
574  /// @param OS Output stream to print on.
575  void dump(raw_ostream &OS) const;
576 
577  /// @brief Print a representation of this graph in DOT format.
578  /// @param OS Output stream to print on.
579  void printDot(raw_ostream &OS) const;
580 };
581 
583  if (G.empty())
584  return Solution();
585  RegAllocSolverImpl RegAllocSolver(G);
586  return RegAllocSolver.solve();
587 }
588 
589 } // namespace RegAlloc
590 } // namespace PBQP
591 
592 /// @brief Create a PBQP register allocator instance.
593 FunctionPass *
594 createPBQPRegisterAllocator(char *customPassID = nullptr);
595 
596 } // namespace llvm
597 
598 #endif /* LLVM_CODEGEN_REGALLOCPBQP_H */
PBQP::Graph< RegAllocSolverImpl > Graph
Definition: RegAllocPBQP.h:345
unsigned getCols() const
Return the number of cols in this matrix.
Definition: Math.h:231
Represents a solution to a PBQP problem.
Definition: Solution.h:27
NodeId getEdgeNode1Id(EdgeId EId) const
Get the first node connected to this edge.
Definition: Graph.h:552
RegAlloc::AllowedRegVector AllowedRegVector
Definition: RegAllocPBQP.h:181
void setAllowedRegs(GraphMetadata::AllowedRegVecRef AllowedRegs)
Definition: RegAllocPBQP.h:263
Holds a vector of the allowed physical regs for a vreg.
Definition: RegAllocPBQP.h:80
NodeMetadata & operator=(const NodeMetadata &Other)
Definition: RegAllocPBQP.h:230
void handleSetNodeCosts(NodeId NId, const Vector &newCosts)
Definition: RegAllocPBQP.h:364
bool operator!=(const AllowedRegVector &Other) const
Definition: RegAllocPBQP.h:121
static NodeId invalidNodeId()
Returns a value representing an invalid (non-existent) node.
Definition: Graph.h:35
NodeId getEdgeNode2Id(EdgeId EId) const
Get the second node connected to this edge.
Definition: Graph.h:559
PoolRef getValue(ValueKeyT ValueKey)
Definition: CostAllocator.h:96
void eraseNodeIdForVReg(unsigned VReg)
Definition: RegAllocPBQP.h:165
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
NodeMetadata(const NodeMetadata &Other)
Definition: RegAllocPBQP.h:203
MachineBlockFrequencyInfo & MBFI
Definition: RegAllocPBQP.h:152
RegAllocSolverImpl::GraphMetadata GraphMetadata
Definition: Graph.h:61
NodeMetadata(NodeMetadata &&Other)
Definition: RegAllocPBQP.h:219
void setup(const Vector &Costs)
Definition: RegAllocPBQP.h:268
const Vector & getNodeCosts(NodeId NId) const
Get a node's cost vector.
Definition: Graph.h:495
void setReductionState(ReductionState RS)
Definition: RegAllocPBQP.h:274
GraphBase::NodeId getNodeIdForVReg(unsigned VReg) const
Definition: RegAllocPBQP.h:158
FunctionPass * createPBQPRegisterAllocator(char *customPassID=nullptr)
Create a PBQP register allocator instance.
const AllowedRegVector & getAllowedRegs() const
Definition: RegAllocPBQP.h:266
NodeMetadata & getNodeMetadata(NodeId NId)
Definition: Graph.h:499
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Definition: ErrorHandling.h:98
const bool * getUnsafeCols() const
Definition: RegAllocPBQP.h:71
AllowedRegVector(const AllowedRegVector &Other)
Definition: RegAllocPBQP.h:91
friend hash_code hash_value(const AllowedRegVector &)
Definition: RegAllocPBQP.h:130
bool operator==(const AllowedRegVector &Other) const
Definition: RegAllocPBQP.h:115
#define false
Definition: ConvertUTF.c:65
ELFYAML::ELF_STO Other
Definition: ELFYAML.cpp:591
#define G(x, y, z)
Definition: MD5.cpp:52
void printDot(raw_ostream &OS) const
Print a representation of this graph in DOT format.
void setNodeIdForVReg(unsigned VReg, GraphBase::NodeId NId)
Definition: RegAllocPBQP.h:154
void applyR1(GraphT &G, typename GraphT::NodeId NId)
Reduce a node of degree one.
void handleDisconnectEdge(EdgeId EId, NodeId NId)
Definition: RegAllocPBQP.h:376
NodeEntry::AdjEdgeList::size_type getNodeDegree(NodeId NId) const
Definition: Graph.h:507
AllowedRegVecRef getAllowedRegs(AllowedRegVector Allowed)
Definition: RegAllocPBQP.h:169
NodeIdSet nodeIds() const
Definition: Graph.h:456
PBQP Matrix class.
Definition: Math.h:163
PBQPRAGraph(GraphMetadata Metadata)
Definition: RegAllocPBQP.h:568
void handleAddEdge(const MatrixMetadata &MD, bool Transpose)
Definition: RegAllocPBQP.h:287
AllowedRegVector(const std::vector< unsigned > &OptVec)
Definition: RegAllocPBQP.h:86
PBQP Vector class.
Definition: Math.h:24
void setSolver(SolverT &S)
Lock this graph to the given solver instance in preparation for running the solver.
Definition: Graph.h:363
AllowedRegVecPool::PoolRef AllowedRegVecRef
Definition: RegAllocPBQP.h:143
unsigned getLength() const
Return the length of the vector.
Definition: Math.h:95
GraphMetadata(MachineFunction &MF, LiveIntervals &LIS, MachineBlockFrequencyInfo &MBFI)
Definition: RegAllocPBQP.h:145
static cl::opt< RegisterRegAlloc::FunctionPassCtor, false, RegisterPassParser< RegisterRegAlloc > > RegAlloc("regalloc", cl::init(&useDefaultRegisterAllocator), cl::desc("Register allocator to use"))
-regalloc=... command line option.
void handleRemoveEdge(const MatrixMetadata &MD, bool Transpose)
Definition: RegAllocPBQP.h:295
const Metadata & getMetadata() const
Definition: Math.h:416
Holds solver state and other metadata relevant to each PBQP RA node.
Definition: RegAllocPBQP.h:179
float PBQPNum
Definition: Math.h:21
AllowedRegVector(AllowedRegVector &&Other)
Definition: RegAllocPBQP.h:96
void unsetSolver()
Release from solver instance.
Definition: Graph.h:373
Metadata to speed allocatability test.
Definition: RegAllocPBQP.h:38
unsigned operator[](size_t I) const
Definition: RegAllocPBQP.h:113
Solution backpropagate(GraphT &G, StackT stack)
const Matrix & getEdgeCosts(EdgeId EId) const
Get an edge's cost matrix.
Definition: Graph.h:537
std::shared_ptr< const AllowedRegVector > PoolRef
Definition: CostAllocator.h:31
AllowedRegVector & operator=(const AllowedRegVector &Other)
Definition: RegAllocPBQP.h:99
bool empty() const
Returns true if the graph is empty.
Definition: Graph.h:454
RegAlloc::GraphMetadata GraphMetadata
Definition: RegAllocPBQP.h:343
void handleUpdateCosts(EdgeId EId, const Matrix &NewCosts)
Definition: RegAllocPBQP.h:389
hash_code hash_combine(const Ts &...args)
Combine values into a single hash_code.
Definition: Hashing.h:603
ReductionState getReductionState() const
Definition: RegAllocPBQP.h:273
hash_code hash_combine_range(InputIteratorT first, InputIteratorT last)
Compute a hash_code for a sequence of values.
Definition: Hashing.h:481
#define NDEBUG
Definition: regutils.h:48
An opaque object representing a hash code.
Definition: Hashing.h:73
void disconnectAllNeighborsFromNode(NodeId NId)
Convenience method to disconnect all neighbours from the given node.
Definition: Graph.h:642
unsigned getRows() const
Return the number of rows in this matrix.
Definition: Math.h:225
void handleReconnectEdge(EdgeId EId, NodeId NId)
Definition: RegAllocPBQP.h:383
#define I(x, y, z)
Definition: MD5.cpp:54
hash_code hash_value(const AllowedRegVector &OptRegs)
Definition: RegAllocPBQP.h:130
AllowedRegVector & operator=(AllowedRegVector &&Other)
Definition: RegAllocPBQP.h:106
Solution solve(PBQPRAGraph &G)
Definition: RegAllocPBQP.h:582
unsigned getSpillOptionIdx()
Spill option index.
Definition: RegAllocPBQP.h:33
void applyR2(GraphT &G, typename GraphT::NodeId NId)
const bool * getUnsafeRows() const
Definition: RegAllocPBQP.h:70
NodeMetadata & operator=(NodeMetadata &&Other)
Definition: RegAllocPBQP.h:247
unsigned NodeId
Definition: Graph.h:31
This class implements an extremely fast bulk output stream that can only output to a stream...
Definition: raw_ostream.h:38
void dump() const
Dump this graph to dbgs().
PBQP::PoolCostAllocator< Vector, Matrix > CostAllocator
Definition: RegAllocPBQP.h:336
Holds graph-level metadata relevent to PBQP RA problems.
Definition: RegAllocPBQP.h:138
Root of the metadata hierarchy.
Definition: Metadata.h:45