Coverage Report

Created: 2019-02-20 00:17

/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
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
// See https://llvm.org/LICENSE.txt for license information.
5
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
//
7
//===----------------------------------------------------------------------===//
8
//
9
// PBQP Solution class.
10
//
11
//===----------------------------------------------------------------------===//
12
13
#ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
14
#define LLVM_CODEGEN_PBQP_SOLUTION_H
15
16
#include "llvm/CodeGen/PBQP/Graph.h"
17
#include <cassert>
18
#include <map>
19
20
namespace llvm {
21
namespace PBQP {
22
23
  /// Represents a solution to a PBQP problem.
24
  ///
25
  /// To get the selection for each node in the problem use the getSelection method.
26
0
  class Solution {
27
  private:
28
    using SelectionsMap = std::map<GraphBase::NodeId, unsigned>;
29
    SelectionsMap selections;
30
31
  public:
32
    /// Initialise an empty solution.
33
16
    Solution() = default;
34
35
    /// Set the selection for a given node.
36
    /// @param nodeId Node id.
37
    /// @param selection Selection for nodeId.
38
153
    void setSelection(GraphBase::NodeId nodeId, unsigned selection) {
39
153
      selections[nodeId] = selection;
40
153
    }
41
42
    /// Get a node's selection.
43
    /// @param nodeId Node id.
44
    /// @return The selection for nodeId;
45
714
    unsigned getSelection(GraphBase::NodeId nodeId) const {
46
714
      SelectionsMap::const_iterator sItr = selections.find(nodeId);
47
714
      assert(sItr != selections.end() && "No selection for node.");
48
714
      return sItr->second;
49
714
    }
50
  };
51
52
} // end namespace PBQP
53
} // end namespace llvm
54
55
#endif // LLVM_CODEGEN_PBQP_SOLUTION_H