Coverage Report

Created: 2018-09-23 16:00

/Users/buildslave/jenkins/workspace/clang-stage2-coverage-R/llvm/include/llvm/CodeGen/PBQP/Solution.h
Line
Count
Source (jump to first uncovered line)
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 "llvm/CodeGen/PBQP/Graph.h"
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
0
  class Solution {
28
  private:
29
    using SelectionsMap = std::map<GraphBase::NodeId, unsigned>;
30
    SelectionsMap selections;
31
32
  public:
33
    /// Initialise an empty solution.
34
16
    Solution() = default;
35
36
    /// Set the selection for a given node.
37
    /// @param nodeId Node id.
38
    /// @param selection Selection for nodeId.
39
153
    void setSelection(GraphBase::NodeId nodeId, unsigned selection) {
40
153
      selections[nodeId] = selection;
41
153
    }
42
43
    /// Get a node's selection.
44
    /// @param nodeId Node id.
45
    /// @return The selection for nodeId;
46
714
    unsigned getSelection(GraphBase::NodeId nodeId) const {
47
714
      SelectionsMap::const_iterator sItr = selections.find(nodeId);
48
714
      assert(sItr != selections.end() && "No selection for node.");
49
714
      return sItr->second;
50
714
    }
51
  };
52
53
} // end namespace PBQP
54
} // end namespace llvm
55
56
#endif // LLVM_CODEGEN_PBQP_SOLUTION_H