Indentation.
[llvm/avr.git] / lib / CodeGen / PBQP / Solution.h
blobc91e2fa560a08df36e3138b08bc04ff179494a60
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 // Annotated PBQP Graph class. This class is used internally by the PBQP solver
11 // to cache information to speed up reduction.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_CODEGEN_PBQP_SOLUTION_H
16 #define LLVM_CODEGEN_PBQP_SOLUTION_H
18 #include "PBQPMath.h"
20 namespace PBQP {
22 class Solution {
24 friend class SolverImplementation;
26 private:
28 std::vector<unsigned> selections;
29 PBQPNum solutionCost;
30 bool provedOptimal;
31 unsigned r0Reductions, r1Reductions,
32 r2Reductions, rNReductions;
34 public:
36 Solution() :
37 solutionCost(0.0), provedOptimal(false),
38 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
40 Solution(unsigned length, bool assumeOptimal) :
41 selections(length), solutionCost(0.0), provedOptimal(assumeOptimal),
42 r0Reductions(0), r1Reductions(0), r2Reductions(0), rNReductions(0) {}
44 void setProvedOptimal(bool provedOptimal) {
45 this->provedOptimal = provedOptimal;
48 void setSelection(unsigned nodeID, unsigned selection) {
49 selections[nodeID] = selection;
52 void setSolutionCost(PBQPNum solutionCost) {
53 this->solutionCost = solutionCost;
56 void incR0Reductions() { ++r0Reductions; }
57 void incR1Reductions() { ++r1Reductions; }
58 void incR2Reductions() { ++r2Reductions; }
59 void incRNReductions() { ++rNReductions; }
61 unsigned numNodes() const { return selections.size(); }
63 unsigned getSelection(unsigned nodeID) const {
64 return selections[nodeID];
67 PBQPNum getCost() const { return solutionCost; }
69 bool isProvedOptimal() const { return provedOptimal; }
71 unsigned getR0Reductions() const { return r0Reductions; }
72 unsigned getR1Reductions() const { return r1Reductions; }
73 unsigned getR2Reductions() const { return r2Reductions; }
74 unsigned getRNReductions() const { return rNReductions; }
76 bool operator==(const Solution &other) const {
77 return (selections == other.selections);
80 bool operator!=(const Solution &other) const {
81 return !(*this == other);
88 #endif // LLVM_CODEGEN_PBQP_SOLUTION_H