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

Unified Diff: courgette/assembly_program.h

Issue 2457133002: [Courgette] Refactor: Add AssemblyProgram::DispatchInstructionLabels() to hide InstructionVector us… (Closed)
Patch Set: Rename 'Dispatch' to 'Handle'. Created 4 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « courgette/adjustment_method_2.cc ('k') | courgette/assembly_program.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: courgette/assembly_program.h
diff --git a/courgette/assembly_program.h b/courgette/assembly_program.h
index 96d6dafe35676795909bfac8bc9cf8a30571fb96..50ab30a6f6cac90685c496cbb96a8244bf30aae1 100644
--- a/courgette/assembly_program.h
+++ b/courgette/assembly_program.h
@@ -13,6 +13,7 @@
#include <set>
#include <vector>
+#include "base/bind.h"
#include "base/macros.h"
#include "base/memory/free_deleter.h"
#include "courgette/courgette.h"
@@ -79,6 +80,9 @@ typedef NoThrowBuffer<Instruction*> InstructionVector;
//
class AssemblyProgram {
public:
+ using LabelHandler = base::Callback<void(Label*)>;
+ using LabelHandlerMap = std::map<OP, LabelHandler>;
+
explicit AssemblyProgram(ExecutableType kind);
~AssemblyProgram();
@@ -142,22 +146,11 @@ class AssemblyProgram {
std::unique_ptr<EncodedProgram> Encode() const;
- // Accessor for instruction list.
- const InstructionVector& instructions() const {
- return instructions_;
- }
-
- // Returns the label if the instruction contains an absolute 32-bit address,
- // otherwise returns NULL.
- Label* InstructionAbs32Label(const Instruction* instruction) const;
-
- // Returns the label if the instruction contains an absolute 64-bit address,
- // otherwise returns NULL.
- Label* InstructionAbs64Label(const Instruction* instruction) const;
-
- // Returns the label if the instruction contains a rel32 offset,
- // otherwise returns NULL.
- Label* InstructionRel32Label(const Instruction* instruction) const;
+ // For each |instruction| in |instructions_|, looks up its opcode from
+ // |handler_map| for a handler. If a handler exists, invoke it by passing the
+ // |instruction|'s label. We assume that |handler_map| has correct keys, i.e.,
+ // opcodes for an instruction that have label.
+ void HandleInstructionLabels(const LabelHandlerMap& handler_map) const;
private:
using ScopedInstruction =
« no previous file with comments | « courgette/adjustment_method_2.cc ('k') | courgette/assembly_program.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698