LLVM  5.0.0
Solution.h
Go to the documentation of this file.
1 //===- Solution.h - PBQP Solution -------------------------------*- 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 // PBQP Solution class.
11 //
12 //===----------------------------------------------------------------------===//
13 
14 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
15 #define LLVM_CODEGEN_PBQP_SOLUTION_H
16 
18 #include <cassert>
19 #include <map>
20 
21 namespace llvm {
22 namespace PBQP {
23 
24  /// \brief Represents a solution to a PBQP problem.
25  ///
26  /// To get the selection for each node in the problem use the getSelection method.
27  class Solution {
28  private:
29  using SelectionsMap = std::map<GraphBase::NodeId, unsigned>;
30  SelectionsMap selections;
31 
32  unsigned r0Reductions = 0;
33  unsigned r1Reductions = 0;
34  unsigned r2Reductions = 0;
35  unsigned rNReductions = 0;
36 
37  public:
38  /// \brief Initialise an empty solution.
39  Solution() = default;
40 
41  /// \brief Set the selection for a given node.
42  /// @param nodeId Node id.
43  /// @param selection Selection for nodeId.
44  void setSelection(GraphBase::NodeId nodeId, unsigned selection) {
45  selections[nodeId] = selection;
46  }
47 
48  /// \brief Get a node's selection.
49  /// @param nodeId Node id.
50  /// @return The selection for nodeId;
51  unsigned getSelection(GraphBase::NodeId nodeId) const {
52  SelectionsMap::const_iterator sItr = selections.find(nodeId);
53  assert(sItr != selections.end() && "No selection for node.");
54  return sItr->second;
55  }
56  };
57 
58 } // end namespace PBQP
59 } // end namespace llvm
60 
61 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H
Represents a solution to a PBQP problem.
Definition: Solution.h:27
unsigned getSelection(GraphBase::NodeId nodeId) const
Get a node's selection.
Definition: Solution.h:51
Solution()=default
Initialise an empty solution.
void setSelection(GraphBase::NodeId nodeId, unsigned selection)
Set the selection for a given node.
Definition: Solution.h:44
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())