blob: 3c65a68248826d958479aaf0451573ae5ded1da9 [file] [log] [blame]
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -07001/*
2 * Copyright (C) 2012 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#include "target_codegen_machine.h"
18
Shih-wei Liao21d28f52012-06-12 05:55:00 -070019#include "lir_function.h"
20#include "lir_pass_manager.h"
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070021#include "target_lir_emitter.h"
Shih-wei Liao21d28f52012-06-12 05:55:00 -070022#include "target_lir_opcodes.h"
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070023#include "target_registry.h"
24
25#include "compiled_method.h"
26#include "compiler.h"
Shih-wei Liao21d28f52012-06-12 05:55:00 -070027#include "oat_compilation_unit.h"
28#include "utils.h"
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070029
30#include <UniquePtr.h>
31
32namespace art {
33namespace greenland {
34
35TargetCodeGenMachine* TargetCodeGenMachine::Create(InstructionSet insn_set) {
36 TargetRegistry::TargetCodeGenMachineCtorTy ctor =
37 TargetRegistry::GetTargetCodeGenMachineCtor(insn_set);
38
39 if (ctor == NULL) {
40 return NULL;
41 }
42
43 return (*ctor)();
44}
45
Shih-wei Liao21d28f52012-06-12 05:55:00 -070046CompiledMethod* TargetCodeGenMachine::Run(const Compiler& compiler,
47 const GBCFunction& gbc_func) {
48 LIRPassManager lir_pm;
49
50 lir_pm.Add(CreateLIREmitter());
51
52 LIRFunction lir_func(*this, gbc_func);
53
54 if (!lir_pm.Run(lir_func)) {
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070055 return NULL;
56 }
Shih-wei Liao21d28f52012-06-12 05:55:00 -070057
58 lir_func.Dump();
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070059
60 // 0x90 is the NOP in x86
61 std::vector<uint8_t> code(10, 0x90);
62
Shih-wei Liao21d28f52012-06-12 05:55:00 -070063 return new CompiledMethod(compiler.GetInstructionSet(), code,
Shih-wei Liaoe94d9b22012-05-22 09:01:24 -070064 /* frame_size_in_bytes */0,
65 /* core_spill_mask */0,
66 /* fp_spill_mask */0);
67}
68
69} // namespace greenland
70} // namespace art