| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "courgette/adjustment_method.h" | 5 #include "courgette/adjustment_method.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <list> | 8 #include <list> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 } | 212 } |
| 213 }; | 213 }; |
| 214 | 214 |
| 215 typedef std::set<Node*, OrderNodeByWeightDecreasing> NodeQueue; | 215 typedef std::set<Node*, OrderNodeByWeightDecreasing> NodeQueue; |
| 216 | 216 |
| 217 class AssignmentProblem { | 217 class AssignmentProblem { |
| 218 public: | 218 public: |
| 219 AssignmentProblem(const Trace& model, | 219 AssignmentProblem(const Trace& model, |
| 220 const Trace& problem) | 220 const Trace& problem) |
| 221 : m_trace_(model), | 221 : m_trace_(model), |
| 222 p_trace_(problem) { | 222 p_trace_(problem), |
| 223 m_root_(NULL), |
| 224 p_root_(NULL) { |
| 223 } | 225 } |
| 224 | 226 |
| 225 ~AssignmentProblem() { | 227 ~AssignmentProblem() { |
| 226 for (size_t i = 0; i < all_nodes_.size(); ++i) | 228 for (size_t i = 0; i < all_nodes_.size(); ++i) |
| 227 delete all_nodes_[i]; | 229 delete all_nodes_[i]; |
| 228 } | 230 } |
| 229 | 231 |
| 230 bool Solve() { | 232 bool Solve() { |
| 231 m_root_ = MakeRootNode(m_trace_); | 233 m_root_ = MakeRootNode(m_trace_); |
| 232 p_root_ = MakeRootNode(p_trace_); | 234 p_root_ = MakeRootNode(p_trace_); |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 572 NodeQueue worklist_; | 574 NodeQueue worklist_; |
| 573 NodeQueue unsolved_; | 575 NodeQueue unsolved_; |
| 574 | 576 |
| 575 std::vector<Node*> all_nodes_; | 577 std::vector<Node*> all_nodes_; |
| 576 | 578 |
| 577 DISALLOW_COPY_AND_ASSIGN(AssignmentProblem); | 579 DISALLOW_COPY_AND_ASSIGN(AssignmentProblem); |
| 578 }; | 580 }; |
| 579 | 581 |
| 580 class GraphAdjuster : public AdjustmentMethod { | 582 class GraphAdjuster : public AdjustmentMethod { |
| 581 public: | 583 public: |
| 582 GraphAdjuster() {} | 584 GraphAdjuster() |
| 585 : prog_(NULL), |
| 586 model_(NULL), |
| 587 debug_label_index_gen_(0) {} |
| 583 ~GraphAdjuster() {} | 588 ~GraphAdjuster() {} |
| 584 | 589 |
| 585 bool Adjust(const AssemblyProgram& model, AssemblyProgram* program) { | 590 bool Adjust(const AssemblyProgram& model, AssemblyProgram* program) { |
| 586 LOG(INFO) << "GraphAdjuster::Adjust"; | 591 LOG(INFO) << "GraphAdjuster::Adjust"; |
| 587 prog_ = program; | 592 prog_ = program; |
| 588 model_ = &model; | 593 model_ = &model; |
| 589 debug_label_index_gen_ = 0; | 594 debug_label_index_gen_ = 0; |
| 590 return Finish(); | 595 return Finish(); |
| 591 } | 596 } |
| 592 | 597 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); | 699 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); |
| 695 bool ok = method->Adjust(model, program); | 700 bool ok = method->Adjust(model, program); |
| 696 method->Destroy(); | 701 method->Destroy(); |
| 697 if (ok) | 702 if (ok) |
| 698 return C_OK; | 703 return C_OK; |
| 699 else | 704 else |
| 700 return C_ADJUSTMENT_FAILED; | 705 return C_ADJUSTMENT_FAILED; |
| 701 } | 706 } |
| 702 | 707 |
| 703 } // namespace courgette | 708 } // namespace courgette |
| OLD | NEW |