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 { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 25 | namespace arm { |
| 26 | |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 27 | static constexpr size_t kArmWordSize = 4; |
| 28 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 29 | class LocationsBuilderARM : public HGraphVisitor { |
| 30 | public: |
| 31 | explicit LocationsBuilderARM(HGraph* graph) : HGraphVisitor(graph) { } |
| 32 | |
| 33 | #define DECLARE_VISIT_INSTRUCTION(name) \ |
| 34 | virtual void Visit##name(H##name* instr); |
| 35 | |
| 36 | FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 37 | |
| 38 | #undef DECLARE_VISIT_INSTRUCTION |
| 39 | |
| 40 | private: |
| 41 | DISALLOW_COPY_AND_ASSIGN(LocationsBuilderARM); |
| 42 | }; |
| 43 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 44 | class CodeGeneratorARM; |
| 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 | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 48 | InstructionCodeGeneratorARM(HGraph* graph, CodeGeneratorARM* codegen); |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 49 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 50 | #define DECLARE_VISIT_INSTRUCTION(name) \ |
| 51 | virtual void Visit##name(H##name* instr); |
| 52 | |
| 53 | FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 54 | |
| 55 | #undef DECLARE_VISIT_INSTRUCTION |
| 56 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 57 | ArmAssembler* GetAssembler() const { return assembler_; } |
Nicolas Geoffray | 8ccc3f5 | 2014-03-19 10:34:11 +0000 | [diff] [blame] | 58 | void LoadCurrentMethod(Register reg); |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 59 | |
| 60 | private: |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 61 | ArmAssembler* const assembler_; |
| 62 | CodeGeneratorARM* const codegen_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 63 | |
| 64 | DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorARM); |
| 65 | }; |
| 66 | |
| 67 | class CodeGeneratorARM : public CodeGenerator { |
| 68 | public: |
| 69 | explicit CodeGeneratorARM(HGraph* graph) |
| 70 | : CodeGenerator(graph), |
| 71 | location_builder_(graph), |
| 72 | instruction_visitor_(graph, this) { } |
| 73 | virtual ~CodeGeneratorARM() { } |
| 74 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 75 | virtual void GenerateFrameEntry() OVERRIDE; |
| 76 | virtual void GenerateFrameExit() OVERRIDE; |
| 77 | virtual void Bind(Label* label) OVERRIDE; |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 78 | virtual void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE; |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 79 | |
Nicolas Geoffray | 707c809 | 2014-04-04 10:50:14 +0100 | [diff] [blame] | 80 | virtual size_t GetWordSize() const OVERRIDE { |
| 81 | return kArmWordSize; |
| 82 | } |
| 83 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 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 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 92 | virtual ArmAssembler* GetAssembler() OVERRIDE { |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 93 | return &assembler_; |
| 94 | } |
| 95 | |
Nicolas Geoffray | 4a34a42 | 2014-04-03 10:38:37 +0100 | [diff] [blame] | 96 | int32_t GetStackSlot(HLocal* local) const; |
| 97 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 98 | private: |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 99 | LocationsBuilderARM location_builder_; |
Nicolas Geoffray | 787c307 | 2014-03-17 10:20:19 +0000 | [diff] [blame] | 100 | InstructionCodeGeneratorARM instruction_visitor_; |
| 101 | ArmAssembler assembler_; |
| 102 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 103 | DISALLOW_COPY_AND_ASSIGN(CodeGeneratorARM); |
| 104 | }; |
| 105 | |
| 106 | } // namespace arm |
| 107 | } // namespace art |
| 108 | |
| 109 | #endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_H_ |