Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(601)

Side by Side Diff: courgette/adjustment_method.cc

Issue 2793153003: [Courgette] Refactor: Store Label Annotation in AssemblyProgram for patch generation. (Closed)
Patch Set: Rename *_label_annotation to *_label_annotations. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | courgette/adjustment_method_2.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <algorithm> 10 #include <algorithm>
11 #include <list> 11 #include <list>
12 #include <map> 12 #include <map>
13 #include <set> 13 #include <set>
14 #include <string> 14 #include <string>
15 #include <vector> 15 #include <vector>
16 16
17 #include "base/bind.h"
18 #include "base/logging.h" 17 #include "base/logging.h"
19 #include "base/macros.h" 18 #include "base/macros.h"
20 #include "base/strings/string_number_conversions.h" 19 #include "base/strings/string_number_conversions.h"
21 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
22 #include "courgette/assembly_program.h" 21 #include "courgette/assembly_program.h"
23 #include "courgette/courgette.h" 22 #include "courgette/courgette.h"
24 #include "courgette/encoded_program.h" 23 #include "courgette/encoded_program.h"
25 24
26 namespace courgette { 25 namespace courgette {
27 26
(...skipping 560 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 CollectTraces(prog_, &prog_abs32_, &prog_rel32_, false); 587 CollectTraces(prog_, &prog_abs32_, &prog_rel32_, false);
589 Solve(model_abs32_, prog_abs32_); 588 Solve(model_abs32_, prog_abs32_);
590 Solve(model_rel32_, prog_rel32_); 589 Solve(model_rel32_, prog_rel32_);
591 prog_->AssignRemainingIndexes(); 590 prog_->AssignRemainingIndexes();
592 return true; 591 return true;
593 } 592 }
594 593
595 private: 594 private:
596 void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32, 595 void CollectTraces(const AssemblyProgram* program, Trace* abs32, Trace* rel32,
597 bool is_model) { 596 bool is_model) {
598 AssemblyProgram::LabelHandler abs32_handler = 597 for (Label* label : program->abs32_label_annotations())
599 base::Bind(&GraphAdjuster::ReferenceLabel, base::Unretained(this), 598 ReferenceLabel(abs32, is_model, label);
600 abs32, is_model); 599 for (Label* label : program->rel32_label_annotations())
601 AssemblyProgram::LabelHandler rel32_handler = 600 ReferenceLabel(rel32, is_model, label);
602 base::Bind(&GraphAdjuster::ReferenceLabel, base::Unretained(this),
603 rel32, is_model);
604
605 program->HandleInstructionLabels({{ABS32, abs32_handler},
606 {REL32, rel32_handler},
607 {REL32ARM, rel32_handler}});
608 601
609 // TODO(sra): we could simply append all the labels in index order to 602 // TODO(sra): we could simply append all the labels in index order to
610 // incorporate some costing for entropy (bigger deltas) that will be 603 // incorporate some costing for entropy (bigger deltas) that will be
611 // introduced into the label address table by non-monotonic ordering. This 604 // introduced into the label address table by non-monotonic ordering. This
612 // would have some knock-on effects to parts of the algorithm that work on 605 // would have some knock-on effects to parts of the algorithm that work on
613 // single-occurrence labels. 606 // single-occurrence labels.
614 } 607 }
615 608
616 void Solve(const Trace& model, const Trace& problem) { 609 void Solve(const Trace& model, const Trace& problem) {
617 LinkLabelInfos(model); 610 LinkLabelInfos(model);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
689 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod(); 682 AdjustmentMethod* method = AdjustmentMethod::MakeProductionAdjustmentMethod();
690 bool ok = method->Adjust(model, program); 683 bool ok = method->Adjust(model, program);
691 method->Destroy(); 684 method->Destroy();
692 if (ok) 685 if (ok)
693 return C_OK; 686 return C_OK;
694 else 687 else
695 return C_ADJUSTMENT_FAILED; 688 return C_ADJUSTMENT_FAILED;
696 } 689 }
697 690
698 } // namespace courgette 691 } // namespace courgette
OLDNEW
« no previous file with comments | « no previous file | courgette/adjustment_method_2.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698