1 //===-- Solution.h ------- PBQP Solution ------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 // PBQP Solution class.
12 //===----------------------------------------------------------------------===//
14 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
15 #define LLVM_CODEGEN_PBQP_SOLUTION_H
24 /// \brief Represents a solution to a PBQP problem.
26 /// To get the selection for each node in the problem use the getSelection method.
29 typedef std::map<Graph::NodeItr, unsigned, NodeItrComparator> SelectionsMap;
30 SelectionsMap selections;
34 /// \brief Number of nodes for which selections have been made.
35 /// @return Number of nodes for which selections have been made.
36 unsigned numNodes() const { return selections.size(); }
38 /// \brief Set the selection for a given node.
39 /// @param nItr Node iterator.
40 /// @param selection Selection for nItr.
41 void setSelection(Graph::NodeItr nItr, unsigned selection) {
42 selections[nItr] = selection;
45 /// \brief Get a node's selection.
46 /// @param nItr Node iterator.
47 /// @return The selection for nItr;
48 unsigned getSelection(Graph::NodeItr nItr) const {
49 SelectionsMap::const_iterator sItr = selections.find(nItr);
50 assert(sItr != selections.end() && "No selection for node.");
58 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H