LLVM  4.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 
17 #include "Graph.h"
18 #include "Math.h"
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 
30  typedef std::map<GraphBase::NodeId, unsigned> SelectionsMap;
31  SelectionsMap selections;
32 
33  unsigned r0Reductions, r1Reductions, r2Reductions, rNReductions;
34 
35  public:
36 
37  /// \brief Initialise an empty solution.
39  : r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
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 
59 } // namespace PBQP
60 } // namespace llvm
61 
62 #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()
Initialise an empty solution.
Definition: Solution.h:38
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())