Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #ifndef ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_H_ |
| 19 | |
| 20 | #include "code_generator.h" |
| 21 | #include "nodes.h" |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 22 | #include "utils/arm/assembler_arm.h" |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 23 | |
| 24 | namespace art { |
| 25 | |
| 26 | class Assembler; |
| 27 | class Label; |
| 28 | |
| 29 | namespace arm { |
| 30 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 31 | class LocationsBuilderARM : public HGraphVisitor { |
| 32 | public: |
| 33 | explicit LocationsBuilderARM(HGraph* graph) : HGraphVisitor(graph) { } |
| 34 | |
| 35 | #define DECLARE_VISIT_INSTRUCTION(name) \ |
| 36 | virtual void Visit##name(H##name* instr); |
| 37 | |
| 38 | FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 39 | |
| 40 | #undef DECLARE_VISIT_INSTRUCTION |
| 41 | |
| 42 | private: |
| 43 | DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARM); |
| 44 | }; |
| 45 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 46 | class InstructionCodeGeneratorARM : public HGraphVisitor { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 47 | public: |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 48 | explicit InstructionCodeGeneratorARM(HGraph* graph, CodeGenerator* codegen) |
| 49 | : HGraphVisitor(graph), |
| 50 | assembler_(codegen->GetAssembler()), |
| 51 | codegen_(codegen) { } |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 52 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 53 | #define DECLARE_VISIT_INSTRUCTION(name) \ |
| 54 | virtual void Visit##name(H##name* instr); |
| 55 | |
| 56 | FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 57 | |
| 58 | #undef DECLARE_VISIT_INSTRUCTION |
| 59 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 60 | Assembler* GetAssembler() const { return assembler_; } |
| 61 | |
| 62 | private: |
| 63 | Assembler* const assembler_; |
| 64 | CodeGenerator* const codegen_; |
| 65 | |
| 66 | DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorARM); |
| 67 | }; |
| 68 | |
| 69 | class CodeGeneratorARM : public CodeGenerator { |
| 70 | public: |
| 71 | explicit CodeGeneratorARM(HGraph* graph) |
| 72 | : CodeGenerator(graph), |
| 73 | location_builder_(graph), |
| 74 | instruction_visitor_(graph, this) { } |
| 75 | virtual ~CodeGeneratorARM() { } |
| 76 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 77 | protected: |
| 78 | virtual void GenerateFrameEntry() OVERRIDE; |
| 79 | virtual void GenerateFrameExit() OVERRIDE; |
| 80 | virtual void Bind(Label* label) OVERRIDE; |
| 81 | virtual void Move(HInstruction* instruction, Location location) OVERRIDE; |
| 82 | virtual void Push(HInstruction* instruction, Location location) OVERRIDE; |
| 83 | |
| 84 | virtual HGraphVisitor* GetLocationBuilder() OVERRIDE { |
| 85 | return &location_builder_; |
| 86 | } |
| 87 | |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 88 | virtual HGraphVisitor* GetInstructionVisitor() OVERRIDE { |
| 89 | return &instruction_visitor_; |
| 90 | } |
| 91 | |
| 92 | virtual Assembler* GetAssembler() OVERRIDE { |
| 93 | return &assembler_; |
| 94 | } |
| 95 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 96 | private: |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 97 | LocationsBuilderARM location_builder_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 98 | InstructionCodeGeneratorARM instruction_visitor_; |
| 99 | ArmAssembler assembler_; |
| 100 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 101 | |
| 102 | DISALLOW_COPY_AND_ASSIGN(CodeGeneratorARM); |
| 103 | }; |
| 104 | |
| 105 | } // namespace arm |
| 106 | } // namespace art |
| 107 | |
| 108 | #endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_H_ |