Index: courgette/assembly_program.h |
diff --git a/courgette/assembly_program.h b/courgette/assembly_program.h |
index 2d157dd480d6cd65149f46139a588c1a39b551f1..96d6dafe35676795909bfac8bc9cf8a30571fb96 100644 |
--- a/courgette/assembly_program.h |
+++ b/courgette/assembly_program.h |
@@ -123,16 +123,23 @@ class AssemblyProgram { |
// Generates 8-byte absolute reference to address of 'label'. |
CheckBool EmitAbs64(Label* label) WARN_UNUSED_RESULT; |
- // Looks up a label or creates a new one. Might return NULL. |
- Label* FindOrMakeAbs32Label(RVA rva); |
+ // Traverses RVAs in |abs32_visitor| and |rel32_visitor| to precompute Labels. |
+ void PrecomputeLabels(RvaVisitor* abs32_visitor, RvaVisitor* rel32_visitor); |
- // Looks up a label or creates a new one. Might return NULL. |
- Label* FindOrMakeRel32Label(RVA rva); |
+ // Removes underused Labels. Thresholds used (0 = no trimming) is |
+ // architecture-dependent. |
+ void TrimLabels(); |
- void DefaultAssignIndexes(); |
void UnassignIndexes(); |
+ void DefaultAssignIndexes(); |
void AssignRemainingIndexes(); |
+ // Looks up abs32 label. Returns null if none found. |
+ Label* FindAbs32Label(RVA rva); |
+ |
+ // Looks up rel32 label. Returns null if none found. |
+ Label* FindRel32Label(RVA rva); |
+ |
std::unique_ptr<EncodedProgram> Encode() const; |
// Accessor for instruction list. |
@@ -152,10 +159,6 @@ class AssemblyProgram { |
// otherwise returns NULL. |
Label* InstructionRel32Label(const Instruction* instruction) const; |
- // Removes underused Labels. Thresholds used (may be 0, i.e., no trimming) is |
- // dependent on architecture. Returns true on success, and false otherwise. |
- CheckBool TrimLabels(); |
- |
private: |
using ScopedInstruction = |
std::unique_ptr<Instruction, UncheckedDeleter<Instruction>>; |
@@ -183,11 +186,10 @@ class AssemblyProgram { |
InstructionVector instructions_; // All the instructions in program. |
- // These are lookup maps to find the label associated with a given address. |
- // We have separate label spaces for addresses referenced by rel32 labels and |
- // abs32 labels. This is somewhat arbitrary. |
- RVAToLabel rel32_labels_; |
- RVAToLabel abs32_labels_; |
+ // Storage and lookup of Labels associated with target addresses. We use |
+ // separate abs32 and rel32 labels. |
+ LabelManager abs32_label_manager_; |
+ LabelManager rel32_label_manager_; |
DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); |
}; |