Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 1 | /* |
| 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 Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 19 | #include "lir_function.h" |
| 20 | #include "lir_pass_manager.h" |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 21 | #include "target_lir_emitter.h" |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 22 | #include "target_lir_opcodes.h" |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 23 | #include "target_registry.h" |
| 24 | |
| 25 | #include "compiled_method.h" |
| 26 | #include "compiler.h" |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 27 | #include "oat_compilation_unit.h" |
| 28 | #include "utils.h" |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 29 | |
| 30 | #include <UniquePtr.h> |
| 31 | |
| 32 | namespace art { |
| 33 | namespace greenland { |
| 34 | |
| 35 | TargetCodeGenMachine* 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 Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 46 | CompiledMethod* 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 Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 55 | return NULL; |
| 56 | } |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 57 | |
| 58 | lir_func.Dump(); |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 59 | |
| 60 | // 0x90 is the NOP in x86 |
| 61 | std::vector<uint8_t> code(10, 0x90); |
| 62 | |
Shih-wei Liao | 21d28f5 | 2012-06-12 05:55:00 -0700 | [diff] [blame^] | 63 | return new CompiledMethod(compiler.GetInstructionSet(), code, |
Shih-wei Liao | e94d9b2 | 2012-05-22 09:01:24 -0700 | [diff] [blame] | 64 | /* frame_size_in_bytes */0, |
| 65 | /* core_spill_mask */0, |
| 66 | /* fp_spill_mask */0); |
| 67 | } |
| 68 | |
| 69 | } // namespace greenland |
| 70 | } // namespace art |