| OLD | NEW |
| 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 #ifndef COURGETTE_ASSEMBLY_PROGRAM_H_ | 5 #ifndef COURGETTE_ASSEMBLY_PROGRAM_H_ |
| 6 #define COURGETTE_ASSEMBLY_PROGRAM_H_ | 6 #define COURGETTE_ASSEMBLY_PROGRAM_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 // Generates an ELF style relocation table for ARM. | 80 // Generates an ELF style relocation table for ARM. |
| 81 CheckBool EmitElfARMRelocationInstruction() WARN_UNUSED_RESULT; | 81 CheckBool EmitElfARMRelocationInstruction() WARN_UNUSED_RESULT; |
| 82 | 82 |
| 83 // Following instruction will be assembled at address 'rva'. | 83 // Following instruction will be assembled at address 'rva'. |
| 84 CheckBool EmitOriginInstruction(RVA rva) WARN_UNUSED_RESULT; | 84 CheckBool EmitOriginInstruction(RVA rva) WARN_UNUSED_RESULT; |
| 85 | 85 |
| 86 // Generates a single byte of data or machine instruction. | 86 // Generates a single byte of data or machine instruction. |
| 87 CheckBool EmitByteInstruction(uint8 byte) WARN_UNUSED_RESULT; | 87 CheckBool EmitByteInstruction(uint8 byte) WARN_UNUSED_RESULT; |
| 88 | 88 |
| 89 // Generates multiple bytes of data or machine instructions. | 89 // Generates multiple bytes of data or machine instructions. |
| 90 CheckBool EmitBytesInstruction(const uint8* value, uint32 len) | 90 CheckBool EmitBytesInstruction(const uint8* value, size_t len) |
| 91 WARN_UNUSED_RESULT; | 91 WARN_UNUSED_RESULT; |
| 92 | 92 |
| 93 // Generates 4-byte relative reference to address of 'label'. | 93 // Generates 4-byte relative reference to address of 'label'. |
| 94 CheckBool EmitRel32(Label* label) WARN_UNUSED_RESULT; | 94 CheckBool EmitRel32(Label* label) WARN_UNUSED_RESULT; |
| 95 | 95 |
| 96 // Generates 4-byte relative reference to address of 'label' for | 96 // Generates 4-byte relative reference to address of 'label' for |
| 97 // ARM. | 97 // ARM. |
| 98 CheckBool EmitRel32ARM(uint16 op, Label* label, const uint8* arm_op, | 98 CheckBool EmitRel32ARM(uint16 op, Label* label, const uint8* arm_op, |
| 99 uint16 op_size) WARN_UNUSED_RESULT; | 99 uint16 op_size) WARN_UNUSED_RESULT; |
| 100 | 100 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 122 // otherwise returns NULL. | 122 // otherwise returns NULL. |
| 123 Label* InstructionAbs32Label(const Instruction* instruction) const; | 123 Label* InstructionAbs32Label(const Instruction* instruction) const; |
| 124 | 124 |
| 125 // Returns the label if the instruction contains and rel32 offset, | 125 // Returns the label if the instruction contains and rel32 offset, |
| 126 // otherwise returns NULL. | 126 // otherwise returns NULL. |
| 127 Label* InstructionRel32Label(const Instruction* instruction) const; | 127 Label* InstructionRel32Label(const Instruction* instruction) const; |
| 128 | 128 |
| 129 // Trim underused labels | 129 // Trim underused labels |
| 130 CheckBool TrimLabels(); | 130 CheckBool TrimLabels(); |
| 131 | 131 |
| 132 void PrintLabelCounts(RVAToLabel* labels); | |
| 133 void CountRel32ARM(); | |
| 134 | |
| 135 private: | 132 private: |
| 136 ExecutableType kind_; | 133 ExecutableType kind_; |
| 137 | 134 |
| 138 CheckBool Emit(Instruction* instruction) WARN_UNUSED_RESULT; | 135 CheckBool Emit(Instruction* instruction) WARN_UNUSED_RESULT; |
| 139 | 136 |
| 140 static const int kLabelLowerLimit; | 137 static const int kLabelLowerLimit; |
| 141 | 138 |
| 142 // Looks up a label or creates a new one. Might return NULL. | 139 // Looks up a label or creates a new one. Might return NULL. |
| 143 Label* FindLabel(RVA rva, RVAToLabel* labels); | 140 Label* FindLabel(RVA rva, RVAToLabel* labels); |
| 144 | 141 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 159 // We have separate label spaces for addresses referenced by rel32 labels and | 156 // We have separate label spaces for addresses referenced by rel32 labels and |
| 160 // abs32 labels. This is somewhat arbitrary. | 157 // abs32 labels. This is somewhat arbitrary. |
| 161 RVAToLabel rel32_labels_; | 158 RVAToLabel rel32_labels_; |
| 162 RVAToLabel abs32_labels_; | 159 RVAToLabel abs32_labels_; |
| 163 | 160 |
| 164 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); | 161 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); |
| 165 }; | 162 }; |
| 166 | 163 |
| 167 } // namespace courgette | 164 } // namespace courgette |
| 168 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_ | 165 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_ |
| OLD | NEW |