blob: dd146b8378a010bcb0498d89563928b2ba5b1b66 [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_X86_H_
18#define ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_
19
20#include "code_generator.h"
21#include "nodes.h"
22
23namespace art {
24
25class Assembler;
26class Label;
27
28namespace x86 {
29
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000030class LocationsBuilderX86 : public HGraphVisitor {
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000031 public:
Nicolas Geoffraybab4ed72014-03-11 17:53:17 +000032 explicit LocationsBuilderX86(HGraph* graph) : HGraphVisitor(graph) { }
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000033
Nicolas Geoffrayd4dd2552014-02-28 10:23:58 +000034#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 Geoffraybab4ed72014-03-11 17:53:17 +000042 DISALLOW_COPY_AND_ASSIGN(LocationsBuilderX86);
43};
44
45class 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 Geoffrayd4dd2552014-02-28 10:23:58 +000070
71 DISALLOW_COPY_AND_ASSIGN(CodeGeneratorX86);
72};
73
74} // namespace x86
75} // namespace art
76
77#endif // ART_COMPILER_OPTIMIZING_CODE_GENERATOR_X86_H_