blob: 52d6b2e641697da7c46beb320f4ecb9f59220c56 [file] [log] [blame]
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +00001/*
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 Geoffray787c3072014-03-17 10:20:19 +000022#include "utils/arm/assembler_arm.h"
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000023
24namespace art {
25
26class Assembler;
27class Label;
28
29namespace arm {
30
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000031class 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 Geoffray4a34a422014-04-03 10:38:37 +010046class CodeGeneratorARM;
47
Nicolas Geoffray787c3072014-03-17 10:20:19 +000048class InstructionCodeGeneratorARM : public HGraphVisitor {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000049 public:
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010050 InstructionCodeGeneratorARM(HGraph* graph, CodeGeneratorARM* codegen);
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000051
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000052#define DECLARE_VISIT_INSTRUCTION(name) \
53 virtual void Visit##name(H##name* instr);
54
55 FOR_EACH_INSTRUCTION(DECLARE_VISIT_INSTRUCTION)
56
57#undef DECLARE_VISIT_INSTRUCTION
58
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010059 ArmAssembler* GetAssembler() const { return assembler_; }
Nicolas Geoffray8ccc3f52014-03-19 10:34:11 +000060 void LoadCurrentMethod(Register reg);
Nicolas Geoffray787c3072014-03-17 10:20:19 +000061
62 private:
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010063 ArmAssembler* const assembler_;
64 CodeGeneratorARM* const codegen_;
Nicolas Geoffray787c3072014-03-17 10:20:19 +000065
66 DISALLOW_COPY_AND_ASSIGN(InstructionCodeGeneratorARM);
67};
68
69class 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 Geoffraybab4ed72014-03-11 17:53:17 +000077 virtual void GenerateFrameEntry() OVERRIDE;
78 virtual void GenerateFrameExit() OVERRIDE;
79 virtual void Bind(Label* label) OVERRIDE;
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010080 virtual void Move(HInstruction* instruction, Location location, HInstruction* move_for) OVERRIDE;
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000081
82 virtual HGraphVisitor* GetLocationBuilder() OVERRIDE {
83 return &location_builder_;
84 }
85
Nicolas Geoffray787c3072014-03-17 10:20:19 +000086 virtual HGraphVisitor* GetInstructionVisitor() OVERRIDE {
87 return &instruction_visitor_;
88 }
89
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010090 virtual ArmAssembler* GetAssembler() OVERRIDE {
Nicolas Geoffray787c3072014-03-17 10:20:19 +000091 return &assembler_;
92 }
93
Nicolas Geoffray4a34a422014-04-03 10:38:37 +010094 int32_t GetStackSlot(HLocal* local) const;
95
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000096 private:
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000097 LocationsBuilderARM location_builder_;
Nicolas Geoffray787c3072014-03-17 10:20:19 +000098 InstructionCodeGeneratorARM instruction_visitor_;
99 ArmAssembler assembler_;
100
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +0000101 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorARM);
102};
103
104} // namespace arm
105} // namespace art
106
107#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_ARM_H_