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_X86_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ |
| 19 | |
| 20 | #include "code_generator.h" |
| 21 | #include "nodes.h" |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | class Assembler; |
| 26 | class Label; |
| 27 | |
| 28 | namespace x86 { |
| 29 | |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 30 | class LocationsBuilderX86 : public HGraphVisitor { |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 31 | public: |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 32 | explicit LocationsBuilderX86(HGraph* graph) : HGraphVisitor(graph) { } |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 33 | |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 34 | #define DECLARE_VISIT_INSTRUCTION(name) \ |
| 35 | virtual void Visit##name(H##name* instr); |
| 36 | |
| 37 | FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION) |
| 38 | |
| 39 | #undef DECLARE_VISIT_INSTRUCTION |
| 40 | |
| 41 | private: |
Nicolas Geoffray | bab4ed7 | 2014-03-11 17:53:17 +0000 | [diff] [blame] | 42 | DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86); |
| 43 | }; |
| 44 | |
| 45 | class CodeGeneratorX86 : public CodeGenerator { |
| 46 | public: |
| 47 | CodeGeneratorX86(Assembler* assembler, HGraph* graph) |
| 48 | : CodeGenerator(assembler, graph), location_builder_(graph) { } |
| 49 | |
| 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 | |
| 57 | protected: |
| 58 | virtual void GenerateFrameEntry() OVERRIDE; |
| 59 | virtual void GenerateFrameExit() OVERRIDE; |
| 60 | virtual void Bind(Label* label) OVERRIDE; |
| 61 | virtual void Move(HInstruction* instruction, Location location) OVERRIDE; |
| 62 | virtual void Push(HInstruction* instruction, Location location) OVERRIDE; |
| 63 | |
| 64 | virtual HGraphVisitor* GetLocationBuilder() OVERRIDE { |
| 65 | return &location_builder_; |
| 66 | } |
| 67 | |
| 68 | private: |
| 69 | LocationsBuilderX86 location_builder_; |
Nicolas Geoffray | d4dd255 | 2014-02-28 10:23:58 +0000 | [diff] [blame] | 70 | |
| 71 | DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86); |
| 72 | }; |
| 73 | |
| 74 | } // namespace x86 |
| 75 | } // namespace art |
| 76 | |
| 77 | #endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_ |