summaryrefslogtreecommitdiff
path: root/src/compiler_llvm/ir_builder.cc
diff options
context:
space:
mode:
author Logan Chien <loganchien@google.com> 2012-01-13 15:42:36 +0800
committer Shih-wei Liao <sliao@google.com> 2012-02-16 02:12:13 -0800
commit42e0e1594f9b6c20f62469832bdd0b8b2d06df41 (patch)
treecd8dcd6827366be1129c6d085bf341345750f50a /src/compiler_llvm/ir_builder.cc
parentd6ececa9628126dc92a7d9ca24dd6709149d2073 (diff)
Add art runtime support declaration.
Change-Id: I909ac29ef4ffbcbe93c7809e2d396ed4672f5892
Diffstat (limited to 'src/compiler_llvm/ir_builder.cc')
-rw-r--r--src/compiler_llvm/ir_builder.cc41
1 files changed, 39 insertions, 2 deletions
diff --git a/src/compiler_llvm/ir_builder.cc b/src/compiler_llvm/ir_builder.cc
index 24fac1a46d..b2c795b9c4 100644
--- a/src/compiler_llvm/ir_builder.cc
+++ b/src/compiler_llvm/ir_builder.cc
@@ -15,6 +15,7 @@
*/
#include "ir_builder.h"
+#include "runtime_support_func.h"
#include <llvm/Module.h>
@@ -30,9 +31,45 @@ IRBuilder::IRBuilder(llvm::LLVMContext& context, llvm::Module& module)
: LLVMIRBuilder(context) {
// Get java object type from module
- llvm::Type* jobject_struct_type =
- llvm::StructType::create(context, "JavaObject");
+ llvm::Type* jobject_struct_type = module.getTypeByName("JavaObject");
+ CHECK_NE(jobject_struct_type, static_cast<llvm::Type*>(NULL));
jobject_type_ = jobject_struct_type->getPointerTo();
+
+ // Load the runtime support function declaration from module
+ InitRuntimeSupportFuncDecl(module);
+}
+
+
+//----------------------------------------------------------------------------
+// Runtime Helper Function
+//----------------------------------------------------------------------------
+
+void IRBuilder::InitRuntimeSupportFuncDecl(llvm::Module& module) {
+ using namespace runtime_support;
+
+#define GET_RUNTIME_SUPPORT_FUNC_DECL(ID, NAME) \
+ do { \
+ llvm::Function* fn = module.getFunction(NAME); \
+ DCHECK_NE(fn, (void*)NULL) << "Function not found: " << NAME; \
+ runtime_support_func_decls_[ID] = fn; \
+ } while (0);
+
+#include "runtime_support_func_list.h"
+ RUNTIME_SUPPORT_FUNC_LIST(GET_RUNTIME_SUPPORT_FUNC_DECL)
+#undef RUNTIME_SUPPORT_FUNC_LIST
+#undef GET_RUNTIME_SUPPORT_FUNC_DECL
+}
+
+
+llvm::Function* IRBuilder::GetRuntime(runtime_support::RuntimeId rt) const {
+ using namespace runtime_support;
+
+ if (rt >= 0 && rt < MAX_ID){
+ return runtime_support_func_decls_[rt];
+ } else {
+ LOG(ERROR) << "Unknown runtime function id: " << rt;
+ return NULL;
+ }
}