Chromium Code Reviews| 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 = |