diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-17 10:20:19 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-03-18 11:20:20 +0000 |
commit | 787c3076635cf117eb646c5a89a9014b2072fb44 (patch) | |
tree | 3c9c6c6d56e3900cf2255a5d1ade008ec6a40681 /compiler/optimizing/code_generator.h | |
parent | b9d50a9829b795932eac4cc50a99b4ce80b0ecb4 (diff) | |
download | art-787c3076635cf117eb646c5a89a9014b2072fb44.zip art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.gz art-787c3076635cf117eb646c5a89a9014b2072fb44.tar.bz2 |
Plug new optimizing compiler in compilation pipeline.
Also rename accessors to ART's conventions.
Change-Id: I344807055b98aa4b27215704ec362191464acecc
Diffstat (limited to 'compiler/optimizing/code_generator.h')
-rw-r--r-- | compiler/optimizing/code_generator.h | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index c406378..e95bb21 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -79,7 +79,7 @@ class Location : public ValueObject { class LocationSummary : public ArenaObject { public: explicit LocationSummary(HInstruction* instruction) - : inputs(instruction->block()->graph()->arena(), instruction->InputCount()) { + : inputs(instruction->GetBlock()->GetGraph()->GetArena(), instruction->InputCount()) { inputs.SetSize(instruction->InputCount()); for (int i = 0; i < instruction->InputCount(); i++) { inputs.Put(i, Location()); @@ -107,51 +107,54 @@ class LocationSummary : public ArenaObject { DISALLOW_COPY_AND_ASSIGN(LocationSummary); }; -class CodeGenerator : public HGraphVisitor { +class CodeGenerator : public ArenaObject { public: // Compiles the graph to executable instructions. Returns whether the compilation // succeeded. - static bool CompileGraph(HGraph* graph, InstructionSet instruction_set, CodeAllocator* allocator); - - Assembler* assembler() const { return assembler_; } - - // Visit functions for instruction classes. -#define DECLARE_VISIT_INSTRUCTION(name) \ - virtual void Visit##name(H##name* instr) = 0; - - FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) - -#undef DECLARE_VISIT_INSTRUCTION + void Compile(CodeAllocator* allocator); + static CodeGenerator* Create(ArenaAllocator* allocator, + HGraph* graph, + InstructionSet instruction_set); - protected: - CodeGenerator(Assembler* assembler, HGraph* graph) - : HGraphVisitor(graph), - frame_size_(0), - assembler_(assembler), - block_labels_(graph->arena(), 0) { - block_labels_.SetSize(graph->blocks()->Size()); - } + HGraph* GetGraph() const { return graph_; } Label* GetLabelOf(HBasicBlock* block) const; bool GoesToNextBlock(HBasicBlock* current, HBasicBlock* next) const; - // Frame size required for this method. - uint32_t frame_size_; - virtual void GenerateFrameEntry() = 0; virtual void GenerateFrameExit() = 0; virtual void Bind(Label* label) = 0; virtual void Move(HInstruction* instruction, Location location) = 0; virtual void Push(HInstruction* instruction, Location location) = 0; virtual HGraphVisitor* GetLocationBuilder() = 0; + virtual HGraphVisitor* GetInstructionVisitor() = 0; + virtual Assembler* GetAssembler() = 0; + + uint32_t GetFrameSize() const { return frame_size_; } + void SetFrameSize(uint32_t size) { frame_size_ = size; } + + void BuildMappingTable(std::vector<uint8_t>* vector) const { } + void BuildVMapTable(std::vector<uint8_t>* vector) const { } + void BuildNativeGCMap(std::vector<uint8_t>* vector) const { } + + protected: + explicit CodeGenerator(HGraph* graph) + : frame_size_(0), + graph_(graph), + block_labels_(graph->GetArena(), 0) { + block_labels_.SetSize(graph->GetBlocks()->Size()); + } + ~CodeGenerator() { } private: void InitLocations(HInstruction* instruction); - void Compile(CodeAllocator* allocator); void CompileBlock(HBasicBlock* block); void CompileEntryBlock(); - Assembler* const assembler_; + // Frame size required for this method. + uint32_t frame_size_; + + HGraph* const graph_; // Labels for each block that will be compiled. GrowableArray<Label> block_labels_; |