blob: 9af7eff0691cc7df4e38010478ee09a59bf10d08 [file] [log] [blame]
Brian Carlstrom7940e442013-07-12 13:46:57 -07001#ifdef ART_SEA_IR_MODE
2#include <llvm/Support/Threading.h>
3#include "base/logging.h"
4#include "dex/portable/mir_to_gbc.h"
5#include "driver/compiler_driver.h"
6#include "leb128.h"
7#include "llvm/llvm_compilation_unit.h"
8#include "mirror/object.h"
9#include "runtime.h"
10#include "sea_ir/sea.h"
11
12namespace art {
13
14static CompiledMethod* CompileMethodWithSeaIr(CompilerDriver& compiler,
15 const CompilerBackend compiler_backend,
16 const DexFile::CodeItem* code_item,
17 uint32_t access_flags, InvokeType invoke_type,
18 uint32_t class_def_idx, uint32_t method_idx,
19 jobject class_loader, const DexFile& dex_file
20#if defined(ART_USE_PORTABLE_COMPILER)
21 , llvm::LlvmCompilationUnit* llvm_compilation_unit
22#endif
23) {
24 // NOTE: Instead of keeping the convention from the Dalvik frontend.cc
25 // and silencing the cpplint.py warning, I just corrected the formatting.
26 VLOG(compiler) << "Compiling " << PrettyMethod(method_idx, dex_file) << "...";
27 sea_ir::SeaGraph* sg = sea_ir::SeaGraph::GetCurrentGraph();
28 sg->CompileMethod(code_item, class_def_idx, method_idx, dex_file);
29 sg->DumpSea("/tmp/temp.dot");
30 CHECK(0 && "No SEA compiled function exists yet.");
31 return NULL;
32}
33
34
35CompiledMethod* SeaIrCompileOneMethod(CompilerDriver& compiler,
36 const CompilerBackend backend,
37 const DexFile::CodeItem* code_item,
38 uint32_t access_flags,
39 InvokeType invoke_type,
40 uint32_t class_def_idx,
41 uint32_t method_idx,
42 jobject class_loader,
43 const DexFile& dex_file,
44 llvm::LlvmCompilationUnit* llvm_compilation_unit) {
45 return CompileMethodWithSeaIr(compiler, backend, code_item, access_flags, invoke_type, class_def_idx,
46 method_idx, class_loader, dex_file
47#if defined(ART_USE_PORTABLE_COMPILER)
48 , llvm_compilation_unit
49#endif
50 ); // NOLINT
51}
52
53extern "C" art::CompiledMethod*
54 SeaIrCompileMethod(art::CompilerDriver& compiler,
55 const art::DexFile::CodeItem* code_item,
56 uint32_t access_flags, art::InvokeType invoke_type,
57 uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
58 const art::DexFile& dex_file) {
59 // TODO: check method fingerprint here to determine appropriate backend type. Until then, use build default
60 art::CompilerBackend backend = compiler.GetCompilerBackend();
61 return art::SeaIrCompileOneMethod(compiler, backend, code_item, access_flags, invoke_type,
62 class_def_idx, method_idx, class_loader, dex_file,
63 NULL /* use thread llvm_info */);
64}
65#endif
66
67} // end namespace art