LLVM  8.0.1
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  /// 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  public:
33  /// Initialise an empty solution.
34  Solution() = default;
35 
36  /// Set the selection for a given node.
37  /// @param nodeId Node id.
38  /// @param selection Selection for nodeId.
39  void setSelection(GraphBase::NodeId nodeId, unsigned selection) {
40  selections[nodeId] = selection;
41  }
42 
43  /// Get a node's selection.
44  /// @param nodeId Node id.
45  /// @return The selection for nodeId;
46  unsigned getSelection(GraphBase::NodeId nodeId) const {
47  SelectionsMap::const_iterator sItr = selections.find(nodeId);
48  assert(sItr != selections.end() && "No selection for node.");
49  return sItr->second;
50  }
51  };
52 
53 } // end namespace PBQP
54 } // end namespace llvm
55 
56 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H
Represents a solution to a PBQP problem.
Definition: Solution.h:27
This class represents lattice values for constants.
Definition: AllocatorList.h:24
Solution()=default
Initialise an empty solution.
void setSelection(GraphBase::NodeId nodeId, unsigned selection)
Set the selection for a given node.
Definition: Solution.h:39
unsigned getSelection(GraphBase::NodeId nodeId) const
Get a node&#39;s selection.
Definition: Solution.h:46
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())