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

Unified Diff: courgette/assembly_program.h

Issue 2457133002: [Courgette] Refactor: Add AssemblyProgram::DispatchInstructionLabels() to hide InstructionVector us… (Closed)
Patch Set: 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..725f7d6a0ca182a88af9f77967d0fb46af6c203e 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 LabelDispatcherMap = std::map<OP, LabelHandler>;
chrisha 2016/10/28 20:39:14 LabelHandlerMap, for consistency?
huangs 2016/10/28 21:48:13 Done.
+
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
+ // |dispatcher| for a handler. If a handler exists, invoke it by passing the
+ // |instruction|'s label. We assume that |dispatcher| has correct keys, i.e.,
+ // opcodes for an instruction that have label.
+ void DispatchInstructionLabels(const LabelDispatcherMap& dispatcher) const;
chrisha 2016/10/28 20:39:14 HandleInstructionLabels? Are we "dispatching" any
huangs 2016/10/28 21:48:13 Done.
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