| 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 <stddef.h> | 8 #include <stddef.h> |
| 9 #include <stdint.h> | 9 #include <stdint.h> |
| 10 | 10 |
| 11 #include <map> | 11 #include <map> |
| 12 #include <set> | 12 #include <set> |
| 13 #include <vector> | 13 #include <vector> |
| 14 | 14 |
| 15 #include "base/macros.h" | 15 #include "base/macros.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "courgette/disassembler.h" | 17 #include "courgette/courgette.h" |
| 18 #include "courgette/image_utils.h" | 18 #include "courgette/image_utils.h" |
| 19 #include "courgette/label_manager.h" | 19 #include "courgette/label_manager.h" |
| 20 #include "courgette/memory_allocator.h" | 20 #include "courgette/memory_allocator.h" |
| 21 | 21 |
| 22 namespace courgette { | 22 namespace courgette { |
| 23 | 23 |
| 24 class EncodedProgram; | 24 class EncodedProgram; |
| 25 | 25 |
| 26 // Opcodes of simple assembly language | 26 // Opcodes of simple assembly language |
| 27 enum OP { | 27 enum OP { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 125 // Looks up a label or creates a new one. Might return NULL. | 125 // Looks up a label or creates a new one. Might return NULL. |
| 126 Label* FindOrMakeAbs32Label(RVA rva); | 126 Label* FindOrMakeAbs32Label(RVA rva); |
| 127 | 127 |
| 128 // Looks up a label or creates a new one. Might return NULL. | 128 // Looks up a label or creates a new one. Might return NULL. |
| 129 Label* FindOrMakeRel32Label(RVA rva); | 129 Label* FindOrMakeRel32Label(RVA rva); |
| 130 | 130 |
| 131 void DefaultAssignIndexes(); | 131 void DefaultAssignIndexes(); |
| 132 void UnassignIndexes(); | 132 void UnassignIndexes(); |
| 133 void AssignRemainingIndexes(); | 133 void AssignRemainingIndexes(); |
| 134 | 134 |
| 135 EncodedProgram* Encode() const; | 135 scoped_ptr<EncodedProgram> Encode() const; |
| 136 | 136 |
| 137 // Accessor for instruction list. | 137 // Accessor for instruction list. |
| 138 const InstructionVector& instructions() const { | 138 const InstructionVector& instructions() const { |
| 139 return instructions_; | 139 return instructions_; |
| 140 } | 140 } |
| 141 | 141 |
| 142 // Returns the label if the instruction contains an absolute 32-bit address, | 142 // Returns the label if the instruction contains an absolute 32-bit address, |
| 143 // otherwise returns NULL. | 143 // otherwise returns NULL. |
| 144 Label* InstructionAbs32Label(const Instruction* instruction) const; | 144 Label* InstructionAbs32Label(const Instruction* instruction) const; |
| 145 | 145 |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 184 | 184 |
| 185 // These are lookup maps to find the label associated with a given address. | 185 // These are lookup maps to find the label associated with a given address. |
| 186 // We have separate label spaces for addresses referenced by rel32 labels and | 186 // We have separate label spaces for addresses referenced by rel32 labels and |
| 187 // abs32 labels. This is somewhat arbitrary. | 187 // abs32 labels. This is somewhat arbitrary. |
| 188 RVAToLabel rel32_labels_; | 188 RVAToLabel rel32_labels_; |
| 189 RVAToLabel abs32_labels_; | 189 RVAToLabel abs32_labels_; |
| 190 | 190 |
| 191 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); | 191 DISALLOW_COPY_AND_ASSIGN(AssemblyProgram); |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 // Converts |program| into encoded form, returning it as |*output|. |
| 195 // Returns C_OK if succeeded, otherwise returns an error status and sets |
| 196 // |*output| to null. |
| 197 Status Encode(const AssemblyProgram& program, |
| 198 scoped_ptr<EncodedProgram>* output); |
| 199 |
| 194 } // namespace courgette | 200 } // namespace courgette |
| 201 |
| 195 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_ | 202 #endif // COURGETTE_ASSEMBLY_PROGRAM_H_ |
| OLD | NEW |