Move compiler_llvm to art::llvm.

Also move the invoke stubs (soon to be removed) under compiler.
Start moving LLVM code under compiler. Will move GBC expander to dex/portable
once it is disentangled from other builds (moving toward solving Bug: 8195425).

Change-Id: I8829f9db6ade9ac8e32bd16198b90f83619769f1
diff --git a/src/compiler/dex/compiler_ir.h b/src/compiler/dex/compiler_ir.h
index 76e838c..4ab98a6 100644
--- a/src/compiler/dex/compiler_ir.h
+++ b/src/compiler/dex/compiler_ir.h
@@ -23,8 +23,8 @@
 #include "compiler/driver/dex_compilation_unit.h"
 #include "compiler_utility.h"
 #include "safe_map.h"
-#include "compiler_llvm/ir_builder.h"
-#include "compiler_llvm/intrinsic_helper.h"
+#include "compiler/llvm/ir_builder.h"
+#include "compiler/llvm/intrinsic_helper.h"
 #include "llvm/Module.h"
 #include "compiler_enums.h"
 
@@ -508,21 +508,21 @@
   Checkstats* checkstats;
   bool gen_bitcode;
   LLVMInfo* llvm_info;
-  llvm::LLVMContext* context;
-  llvm::Module* module;
-  llvm::Function* func;
-  compiler_llvm::IntrinsicHelper* intrinsic_helper;
-  compiler_llvm::IRBuilder* irb;
-  llvm::BasicBlock* placeholder_bb;
-  llvm::BasicBlock* entry_bb;
-  llvm::BasicBlock* entryTarget_bb;
+  ::llvm::LLVMContext* context;
+  ::llvm::Module* module;
+  ::llvm::Function* func;
+  art::llvm::IntrinsicHelper* intrinsic_helper;
+  art::llvm::IRBuilder* irb;
+  ::llvm::BasicBlock* placeholder_bb;
+  ::llvm::BasicBlock* entry_bb;
+  ::llvm::BasicBlock* entryTarget_bb;
   std::string bitcode_filename;
   GrowableList llvm_values;
   int32_t temp_name;
-  SafeMap<llvm::BasicBlock*, LIR*> block_to_label_map; // llvm bb -> LIR label.
-  SafeMap<int32_t, llvm::BasicBlock*> id_to_block_map; // block id -> llvm bb.
-  SafeMap<llvm::Value*, RegLocation> loc_map; // llvm Value to loc rec.
-  std::set<llvm::BasicBlock*> llvm_blocks;
+  SafeMap< ::llvm::BasicBlock*, LIR*> block_to_label_map; // llvm bb -> LIR label.
+  SafeMap<int32_t, ::llvm::BasicBlock*> id_to_block_map; // block id -> llvm bb.
+  SafeMap< ::llvm::Value*, RegLocation> loc_map; // llvm Value to loc rec.
+  std::set< ::llvm::BasicBlock*> llvm_blocks;
 #ifndef NDEBUG
   /*
    * Sanity checking for the register temp tracking.  The same ssa
diff --git a/src/compiler/dex/frontend.cc b/src/compiler/dex/frontend.cc
index 510e08a..482804c 100644
--- a/src/compiler/dex/frontend.cc
+++ b/src/compiler/dex/frontend.cc
@@ -32,13 +32,13 @@
   pthread_once_t llvm_multi_init = PTHREAD_ONCE_INIT;
 #endif
   void InitializeLLVMForQuick() {
-    llvm::llvm_start_multithreaded();
+    ::llvm::llvm_start_multithreaded();
   }
 }
 
 namespace art {
-namespace compiler_llvm {
-llvm::Module* makeLLVMModuleContents(llvm::Module* module);
+namespace llvm {
+::llvm::Module* makeLLVMModuleContents(::llvm::Module* module);
 }
 
 LLVMInfo::LLVMInfo() {
@@ -46,12 +46,12 @@
   pthread_once(&llvm_multi_init, InitializeLLVMForQuick);
 #endif
   // Create context, module, intrinsic helper & ir builder
-  llvm_context_.reset(new llvm::LLVMContext());
-  llvm_module_ = new llvm::Module("art", *llvm_context_);
-  llvm::StructType::create(*llvm_context_, "JavaObject");
-  compiler_llvm::makeLLVMModuleContents(llvm_module_);
-  intrinsic_helper_.reset( new compiler_llvm::IntrinsicHelper(*llvm_context_, *llvm_module_));
-  ir_builder_.reset(new compiler_llvm::IRBuilder(*llvm_context_, *llvm_module_, *intrinsic_helper_));
+  llvm_context_.reset(new ::llvm::LLVMContext());
+  llvm_module_ = new ::llvm::Module("art", *llvm_context_);
+  ::llvm::StructType::create(*llvm_context_, "JavaObject");
+  art::llvm::makeLLVMModuleContents(llvm_module_);
+  intrinsic_helper_.reset( new art::llvm::IntrinsicHelper(*llvm_context_, *llvm_module_));
+  ir_builder_.reset(new art::llvm::IRBuilder(*llvm_context_, *llvm_module_, *intrinsic_helper_));
 }
 
 LLVMInfo::~LLVMInfo() {
diff --git a/src/compiler/dex/frontend.h b/src/compiler/dex/frontend.h
index 4e65d12..4c906be 100644
--- a/src/compiler/dex/frontend.h
+++ b/src/compiler/dex/frontend.h
@@ -26,7 +26,7 @@
 }
 
 namespace art {
-namespace compiler_llvm {
+namespace llvm {
   class IntrinsicHelper;
   class IRBuilder;
 }
@@ -110,27 +110,27 @@
     LLVMInfo();
     ~LLVMInfo();
 
-    llvm::LLVMContext* GetLLVMContext() {
+    ::llvm::LLVMContext* GetLLVMContext() {
       return llvm_context_.get();
     }
 
-    llvm::Module* GetLLVMModule() {
+    ::llvm::Module* GetLLVMModule() {
       return llvm_module_;
     }
 
-    art::compiler_llvm::IntrinsicHelper* GetIntrinsicHelper() {
+    art::llvm::IntrinsicHelper* GetIntrinsicHelper() {
       return intrinsic_helper_.get();
     }
 
-    art::compiler_llvm::IRBuilder* GetIRBuilder() {
+    art::llvm::IRBuilder* GetIRBuilder() {
       return ir_builder_.get();
     }
 
   private:
-    UniquePtr<llvm::LLVMContext> llvm_context_;
-    llvm::Module* llvm_module_; // Managed by context_.
-    UniquePtr<art::compiler_llvm::IntrinsicHelper> intrinsic_helper_;
-    UniquePtr<art::compiler_llvm::IRBuilder> ir_builder_;
+    UniquePtr< ::llvm::LLVMContext> llvm_context_;
+    ::llvm::Module* llvm_module_; // Managed by context_.
+    UniquePtr<art::llvm::IntrinsicHelper> intrinsic_helper_;
+    UniquePtr<art::llvm::IRBuilder> ir_builder_;
 };
 
 struct CompilationUnit;
diff --git a/src/compiler/dex/portable/mir_to_gbc.cc b/src/compiler/dex/portable/mir_to_gbc.cc
index 18a87c3..8319b4d 100644
--- a/src/compiler/dex/portable/mir_to_gbc.cc
+++ b/src/compiler/dex/portable/mir_to_gbc.cc
@@ -40,34 +40,33 @@
 static const char kCatchBlock = 'C';
 
 namespace art {
-static RegLocation GetLoc(CompilationUnit* cu, llvm::Value* val);
+static RegLocation GetLoc(CompilationUnit* cu, ::llvm::Value* val);
 
-static llvm::BasicBlock* GetLLVMBlock(CompilationUnit* cu, int id)
+static ::llvm::BasicBlock* GetLLVMBlock(CompilationUnit* cu, int id)
 {
   return cu->id_to_block_map.Get(id);
 }
 
-static llvm::Value* GetLLVMValue(CompilationUnit* cu, int s_reg)
+static ::llvm::Value* GetLLVMValue(CompilationUnit* cu, int s_reg)
 {
-  return reinterpret_cast<llvm::Value*>(GrowableListGetElement(&cu->llvm_values, s_reg));
+  return reinterpret_cast< ::llvm::Value*>(GrowableListGetElement(&cu->llvm_values, s_reg));
 }
 
-static void SetVregOnValue(CompilationUnit* cu, llvm::Value* val, int s_reg)
+static void SetVregOnValue(CompilationUnit* cu, ::llvm::Value* val, int s_reg)
 {
   // Set vreg for debugging
-  compiler_llvm::IntrinsicHelper::IntrinsicId id =
-      compiler_llvm::IntrinsicHelper::SetVReg;
-  llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  art::llvm::IntrinsicHelper::IntrinsicId id = art::llvm::IntrinsicHelper::SetVReg;
+  ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
   int v_reg = SRegToVReg(cu, s_reg);
-  llvm::Value* table_slot = cu->irb->getInt32(v_reg);
-  llvm::Value* args[] = { table_slot, val };
+  ::llvm::Value* table_slot = cu->irb->getInt32(v_reg);
+  ::llvm::Value* args[] = { table_slot, val };
   cu->irb->CreateCall(func, args);
 }
 
 // Replace the placeholder value with the real definition
-static void DefineValueOnly(CompilationUnit* cu, llvm::Value* val, int s_reg)
+static void DefineValueOnly(CompilationUnit* cu, ::llvm::Value* val, int s_reg)
 {
-  llvm::Value* placeholder = GetLLVMValue(cu, s_reg);
+  ::llvm::Value* placeholder = GetLLVMValue(cu, s_reg);
   if (placeholder == NULL) {
     // This can happen on instruction rewrite on verification failure
     LOG(WARNING) << "Null placeholder";
@@ -76,21 +75,21 @@
   placeholder->replaceAllUsesWith(val);
   val->takeName(placeholder);
   cu->llvm_values.elem_list[s_reg] = reinterpret_cast<uintptr_t>(val);
-  llvm::Instruction* inst = llvm::dyn_cast<llvm::Instruction>(placeholder);
+  ::llvm::Instruction* inst = ::llvm::dyn_cast< ::llvm::Instruction>(placeholder);
   DCHECK(inst != NULL);
   inst->eraseFromParent();
 
 }
 
-static void DefineValue(CompilationUnit* cu, llvm::Value* val, int s_reg)
+static void DefineValue(CompilationUnit* cu, ::llvm::Value* val, int s_reg)
 {
   DefineValueOnly(cu, val, s_reg);
   SetVregOnValue(cu, val, s_reg);
 }
 
-static llvm::Type* LlvmTypeFromLocRec(CompilationUnit* cu, RegLocation loc)
+static ::llvm::Type* LlvmTypeFromLocRec(CompilationUnit* cu, RegLocation loc)
 {
-  llvm::Type* res = NULL;
+  ::llvm::Type* res = NULL;
   if (loc.wide) {
     if (loc.fp)
         res = cu->irb->getDoubleTy();
@@ -110,12 +109,12 @@
 }
 
 /* Create an in-memory RegLocation from an llvm Value. */
-static void CreateLocFromValue(CompilationUnit* cu, llvm::Value* val)
+static void CreateLocFromValue(CompilationUnit* cu, ::llvm::Value* val)
 {
   // NOTE: llvm takes shortcuts with c_str() - get to std::string firstt
   std::string s(val->getName().str());
   const char* val_name = s.c_str();
-  SafeMap<llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
+  SafeMap< ::llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
   DCHECK(it == cu->loc_map.end()) << " - already defined: " << val_name;
   int base_sreg = INVALID_SREG;
   int subscript = -1;
@@ -129,7 +128,7 @@
   // TODO: redo during C++'ification
   RegLocation loc =  {kLocDalvikFrame, 0, 0, 0, 0, 0, 0, 0, 0, INVALID_REG,
                       INVALID_REG, INVALID_SREG, INVALID_SREG};
-  llvm::Type* ty = val->getType();
+  ::llvm::Type* ty = val->getType();
   loc.wide = ((ty == cu->irb->getInt64Ty()) ||
               (ty == cu->irb->getDoubleTy()));
   loc.defined = true;
@@ -214,7 +213,7 @@
   return GET_ELEM_N(cu->ssa_strings, char*, ssa_reg);
 }
 
-llvm::BasicBlock* FindCaseTarget(CompilationUnit* cu, uint32_t vaddr)
+::llvm::BasicBlock* FindCaseTarget(CompilationUnit* cu, uint32_t vaddr)
 {
   BasicBlock* bb = FindBlock(cu, vaddr);
   DCHECK(bb != NULL);
@@ -228,19 +227,19 @@
       reinterpret_cast<const Instruction::PackedSwitchPayload*>(
       cu->insns + cu->current_dalvik_offset + table_offset);
 
-  llvm::Value* value = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* value = GetLLVMValue(cu, rl_src.orig_sreg);
 
-  llvm::SwitchInst* sw =
+  ::llvm::SwitchInst* sw =
     cu->irb->CreateSwitch(value, GetLLVMBlock(cu, bb->fall_through->id),
                              payload->case_count);
 
   for (uint16_t i = 0; i < payload->case_count; ++i) {
-    llvm::BasicBlock* llvm_bb =
+    ::llvm::BasicBlock* llvm_bb =
         FindCaseTarget(cu, cu->current_dalvik_offset + payload->targets[i]);
     sw->addCase(cu->irb->getInt32(payload->first_key + i), llvm_bb);
   }
-  llvm::MDNode* switch_node =
-      llvm::MDNode::get(*cu->context, cu->irb->getInt32(table_offset));
+  ::llvm::MDNode* switch_node =
+      ::llvm::MDNode::get(*cu->context, cu->irb->getInt32(table_offset));
   sw->setMetadata("SwitchTable", switch_node);
   bb->taken = NULL;
   bb->fall_through = NULL;
@@ -256,158 +255,158 @@
   const int32_t* keys = payload->GetKeys();
   const int32_t* targets = payload->GetTargets();
 
-  llvm::Value* value = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* value = GetLLVMValue(cu, rl_src.orig_sreg);
 
-  llvm::SwitchInst* sw =
+  ::llvm::SwitchInst* sw =
     cu->irb->CreateSwitch(value, GetLLVMBlock(cu, bb->fall_through->id),
                              payload->case_count);
 
   for (size_t i = 0; i < payload->case_count; ++i) {
-    llvm::BasicBlock* llvm_bb =
+    ::llvm::BasicBlock* llvm_bb =
         FindCaseTarget(cu, cu->current_dalvik_offset + targets[i]);
     sw->addCase(cu->irb->getInt32(keys[i]), llvm_bb);
   }
-  llvm::MDNode* switch_node =
-      llvm::MDNode::get(*cu->context, cu->irb->getInt32(table_offset));
+  ::llvm::MDNode* switch_node =
+      ::llvm::MDNode::get(*cu->context, cu->irb->getInt32(table_offset));
   sw->setMetadata("SwitchTable", switch_node);
   bb->taken = NULL;
   bb->fall_through = NULL;
 }
 
 static void ConvertSget(CompilationUnit* cu, int32_t field_index,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_dest)
+                        art::llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_dest)
 {
-  llvm::Constant* field_idx = cu->irb->getInt32(field_index);
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res = cu->irb->CreateCall(intr, field_idx);
+  ::llvm::Constant* field_idx = cu->irb->getInt32(field_index);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, field_idx);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertSput(CompilationUnit* cu, int32_t field_index,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_src)
+                        art::llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_src)
 {
-  llvm::SmallVector<llvm::Value*, 2> args;
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(field_index));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(intr, args);
 }
 
 static void ConvertFillArrayData(CompilationUnit* cu, int32_t offset, RegLocation rl_array)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::HLFillArrayData;
-  llvm::SmallVector<llvm::Value*, 2> args;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::HLFillArrayData;
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(offset));
   args.push_back(GetLLVMValue(cu, rl_array.orig_sreg));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(intr, args);
 }
 
-static llvm::Value* EmitConst(CompilationUnit* cu, llvm::ArrayRef<llvm::Value*> src,
+static ::llvm::Value* EmitConst(CompilationUnit* cu, ::llvm::ArrayRef< ::llvm::Value*> src,
                               RegLocation loc)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
   if (loc.wide) {
     if (loc.fp) {
-      id = compiler_llvm::IntrinsicHelper::ConstDouble;
+      id = art::llvm::IntrinsicHelper::ConstDouble;
     } else {
-      id = compiler_llvm::IntrinsicHelper::ConstLong;
+      id = art::llvm::IntrinsicHelper::ConstLong;
     }
   } else {
     if (loc.fp) {
-      id = compiler_llvm::IntrinsicHelper::ConstFloat;
+      id = art::llvm::IntrinsicHelper::ConstFloat;
     } else if (loc.ref) {
-      id = compiler_llvm::IntrinsicHelper::ConstObj;
+      id = art::llvm::IntrinsicHelper::ConstObj;
     } else {
-      id = compiler_llvm::IntrinsicHelper::ConstInt;
+      id = art::llvm::IntrinsicHelper::ConstInt;
     }
   }
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   return cu->irb->CreateCall(intr, src);
 }
 
 static void EmitPopShadowFrame(CompilationUnit* cu)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
-      compiler_llvm::IntrinsicHelper::PopShadowFrame);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
+      art::llvm::IntrinsicHelper::PopShadowFrame);
   cu->irb->CreateCall(intr);
 }
 
-static llvm::Value* EmitCopy(CompilationUnit* cu, llvm::ArrayRef<llvm::Value*> src,
+static ::llvm::Value* EmitCopy(CompilationUnit* cu, ::llvm::ArrayRef< ::llvm::Value*> src,
                              RegLocation loc)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
   if (loc.wide) {
     if (loc.fp) {
-      id = compiler_llvm::IntrinsicHelper::CopyDouble;
+      id = art::llvm::IntrinsicHelper::CopyDouble;
     } else {
-      id = compiler_llvm::IntrinsicHelper::CopyLong;
+      id = art::llvm::IntrinsicHelper::CopyLong;
     }
   } else {
     if (loc.fp) {
-      id = compiler_llvm::IntrinsicHelper::CopyFloat;
+      id = art::llvm::IntrinsicHelper::CopyFloat;
     } else if (loc.ref) {
-      id = compiler_llvm::IntrinsicHelper::CopyObj;
+      id = art::llvm::IntrinsicHelper::CopyObj;
     } else {
-      id = compiler_llvm::IntrinsicHelper::CopyInt;
+      id = art::llvm::IntrinsicHelper::CopyInt;
     }
   }
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   return cu->irb->CreateCall(intr, src);
 }
 
 static void ConvertMoveException(CompilationUnit* cu, RegLocation rl_dest)
 {
-  llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
-      compiler_llvm::IntrinsicHelper::GetException);
-  llvm::Value* res = cu->irb->CreateCall(func);
+  ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
+      art::llvm::IntrinsicHelper::GetException);
+  ::llvm::Value* res = cu->irb->CreateCall(func);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertThrow(CompilationUnit* cu, RegLocation rl_src)
 {
-  llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
-  llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
-      compiler_llvm::IntrinsicHelper::HLThrowException);
+  ::llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
+      art::llvm::IntrinsicHelper::HLThrowException);
   cu->irb->CreateCall(func, src);
 }
 
 static void ConvertMonitorEnterExit(CompilationUnit* cu, int opt_flags,
-                                    compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                                    art::llvm::IntrinsicHelper::IntrinsicId id,
                                     RegLocation rl_src)
 {
-  llvm::SmallVector<llvm::Value*, 2> args;
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
-  llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(func, args);
 }
 
 static void ConvertArrayLength(CompilationUnit* cu, int opt_flags,
                                RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::SmallVector<llvm::Value*, 2> args;
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
-  llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
-      compiler_llvm::IntrinsicHelper::OptArrayLength);
-  llvm::Value* res = cu->irb->CreateCall(func, args);
+  ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(
+      art::llvm::IntrinsicHelper::OptArrayLength);
+  ::llvm::Value* res = cu->irb->CreateCall(func, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void EmitSuspendCheck(CompilationUnit* cu)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id =
-      compiler_llvm::IntrinsicHelper::CheckSuspend;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  art::llvm::IntrinsicHelper::IntrinsicId id =
+      art::llvm::IntrinsicHelper::CheckSuspend;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(intr);
 }
 
-static llvm::Value* ConvertCompare(CompilationUnit* cu, ConditionCode cc,
-                                   llvm::Value* src1, llvm::Value* src2)
+static ::llvm::Value* ConvertCompare(CompilationUnit* cu, ConditionCode cc,
+                                   ::llvm::Value* src1, ::llvm::Value* src2)
 {
-  llvm::Value* res = NULL;
+  ::llvm::Value* res = NULL;
   DCHECK_EQ(src1->getType(), src2->getType());
   switch(cc) {
     case kCondEq: res = cu->irb->CreateICmpEQ(src1, src2); break;
@@ -427,9 +426,9 @@
   if (bb->taken->start_offset <= mir->offset) {
     EmitSuspendCheck(cu);
   }
-  llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
-  llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
-  llvm::Value* cond_value = ConvertCompare(cu, cc, src1, src2);
+  ::llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
+  ::llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
+  ::llvm::Value* cond_value = ConvertCompare(cu, cc, src1, src2);
   cond_value->setName(StringPrintf("t%d", cu->temp_name++));
   cu->irb->CreateCondBr(cond_value, GetLLVMBlock(cu, bb->taken->id),
                            GetLLVMBlock(cu, bb->fall_through->id));
@@ -443,48 +442,48 @@
   if (bb->taken->start_offset <= mir->offset) {
     EmitSuspendCheck(cu);
   }
-  llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
-  llvm::Value* src2;
+  ::llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
+  ::llvm::Value* src2;
   if (rl_src1.ref) {
     src2 = cu->irb->getJNull();
   } else {
     src2 = cu->irb->getInt32(0);
   }
-  llvm::Value* cond_value = ConvertCompare(cu, cc, src1, src2);
+  ::llvm::Value* cond_value = ConvertCompare(cu, cc, src1, src2);
   cu->irb->CreateCondBr(cond_value, GetLLVMBlock(cu, bb->taken->id),
                            GetLLVMBlock(cu, bb->fall_through->id));
   // Don't redo the fallthrough branch in the BB driver
   bb->fall_through = NULL;
 }
 
-static llvm::Value* GenDivModOp(CompilationUnit* cu, bool is_div, bool is_long,
-                                llvm::Value* src1, llvm::Value* src2)
+static ::llvm::Value* GenDivModOp(CompilationUnit* cu, bool is_div, bool is_long,
+                                ::llvm::Value* src1, ::llvm::Value* src2)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
   if (is_long) {
     if (is_div) {
-      id = compiler_llvm::IntrinsicHelper::DivLong;
+      id = art::llvm::IntrinsicHelper::DivLong;
     } else {
-      id = compiler_llvm::IntrinsicHelper::RemLong;
+      id = art::llvm::IntrinsicHelper::RemLong;
     }
   } else {
     if (is_div) {
-      id = compiler_llvm::IntrinsicHelper::DivInt;
+      id = art::llvm::IntrinsicHelper::DivInt;
     } else {
-      id = compiler_llvm::IntrinsicHelper::RemInt;
+      id = art::llvm::IntrinsicHelper::RemInt;
     }
   }
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2>args;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2>args;
   args.push_back(src1);
   args.push_back(src2);
   return cu->irb->CreateCall(intr, args);
 }
 
-static llvm::Value* GenArithOp(CompilationUnit* cu, OpKind op, bool is_long,
-                               llvm::Value* src1, llvm::Value* src2)
+static ::llvm::Value* GenArithOp(CompilationUnit* cu, OpKind op, bool is_long,
+                               ::llvm::Value* src1, ::llvm::Value* src2)
 {
-  llvm::Value* res = NULL;
+  ::llvm::Value* res = NULL;
   switch(op) {
     case kOpAdd: res = cu->irb->CreateAdd(src1, src2); break;
     case kOpSub: res = cu->irb->CreateSub(src1, src2); break;
@@ -507,9 +506,9 @@
 static void ConvertFPArithOp(CompilationUnit* cu, OpKind op, RegLocation rl_dest,
                              RegLocation rl_src1, RegLocation rl_src2)
 {
-  llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
-  llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
-  llvm::Value* res = NULL;
+  ::llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
+  ::llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
+  ::llvm::Value* res = NULL;
   switch(op) {
     case kOpAdd: res = cu->irb->CreateFAdd(src1, src2); break;
     case kOpSub: res = cu->irb->CreateFSub(src1, src2); break;
@@ -522,44 +521,44 @@
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
-static void ConvertShift(CompilationUnit* cu, compiler_llvm::IntrinsicHelper::IntrinsicId id,
+static void ConvertShift(CompilationUnit* cu, art::llvm::IntrinsicHelper::IntrinsicId id,
                          RegLocation rl_dest, RegLocation rl_src1, RegLocation rl_src2)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2>args;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2>args;
   args.push_back(GetLLVMValue(cu, rl_src1.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_src2.orig_sreg));
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
-static void ConvertShiftLit(CompilationUnit* cu, compiler_llvm::IntrinsicHelper::IntrinsicId id,
+static void ConvertShiftLit(CompilationUnit* cu, art::llvm::IntrinsicHelper::IntrinsicId id,
                             RegLocation rl_dest, RegLocation rl_src, int shift_amount)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2>args;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2>args;
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
   args.push_back(cu->irb->getInt32(shift_amount));
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertArithOp(CompilationUnit* cu, OpKind op, RegLocation rl_dest,
                            RegLocation rl_src1, RegLocation rl_src2)
 {
-  llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
-  llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
+  ::llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
+  ::llvm::Value* src2 = GetLLVMValue(cu, rl_src2.orig_sreg);
   DCHECK_EQ(src1->getType(), src2->getType());
-  llvm::Value* res = GenArithOp(cu, op, rl_dest.wide, src1, src2);
+  ::llvm::Value* res = GenArithOp(cu, op, rl_dest.wide, src1, src2);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertArithOpLit(CompilationUnit* cu, OpKind op, RegLocation rl_dest,
                               RegLocation rl_src1, int32_t imm)
 {
-  llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
-  llvm::Value* src2 = cu->irb->getInt32(imm);
-  llvm::Value* res = GenArithOp(cu, op, rl_dest.wide, src1, src2);
+  ::llvm::Value* src1 = GetLLVMValue(cu, rl_src1.orig_sreg);
+  ::llvm::Value* src2 = cu->irb->getInt32(imm);
+  ::llvm::Value* res = GenArithOp(cu, op, rl_dest.wide, src1, src2);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
@@ -573,7 +572,7 @@
 {
   Codegen* cg = cu->cg.get();
   CallInfo* info = cg->NewMemCallInfo(cu, bb, mir, invoke_type, is_range);
-  llvm::SmallVector<llvm::Value*, 10> args;
+  ::llvm::SmallVector< ::llvm::Value*, 10> args;
   // Insert the invoke_type
   args.push_back(cu->irb->getInt32(static_cast<int>(invoke_type)));
   // Insert the method_idx
@@ -582,7 +581,7 @@
   args.push_back(cu->irb->getInt32(info->opt_flags));
   // Now, insert the actual arguments
   for (int i = 0; i < info->num_arg_words;) {
-    llvm::Value* val = GetLLVMValue(cu, info->args[i].orig_sreg);
+    ::llvm::Value* val = GetLLVMValue(cu, info->args[i].orig_sreg);
     args.push_back(val);
     i += info->args[i].wide ? 2 : 1;
   }
@@ -591,48 +590,48 @@
    * be different than shorty.  For example, if a function return value
    * is not used, we'll treat this as a void invoke.
    */
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
   if (is_filled_new_array) {
-    id = compiler_llvm::IntrinsicHelper::HLFilledNewArray;
+    id = art::llvm::IntrinsicHelper::HLFilledNewArray;
   } else if (info->result.location == kLocInvalid) {
-    id = compiler_llvm::IntrinsicHelper::HLInvokeVoid;
+    id = art::llvm::IntrinsicHelper::HLInvokeVoid;
   } else {
     if (info->result.wide) {
       if (info->result.fp) {
-        id = compiler_llvm::IntrinsicHelper::HLInvokeDouble;
+        id = art::llvm::IntrinsicHelper::HLInvokeDouble;
       } else {
-        id = compiler_llvm::IntrinsicHelper::HLInvokeLong;
+        id = art::llvm::IntrinsicHelper::HLInvokeLong;
       }
     } else if (info->result.ref) {
-        id = compiler_llvm::IntrinsicHelper::HLInvokeObj;
+        id = art::llvm::IntrinsicHelper::HLInvokeObj;
     } else if (info->result.fp) {
-        id = compiler_llvm::IntrinsicHelper::HLInvokeFloat;
+        id = art::llvm::IntrinsicHelper::HLInvokeFloat;
     } else {
-        id = compiler_llvm::IntrinsicHelper::HLInvokeInt;
+        id = art::llvm::IntrinsicHelper::HLInvokeInt;
     }
   }
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   if (info->result.location != kLocInvalid) {
     DefineValue(cu, res, info->result.orig_sreg);
   }
 }
 
 static void ConvertConstObject(CompilationUnit* cu, uint32_t idx,
-                               compiler_llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_dest)
+                               art::llvm::IntrinsicHelper::IntrinsicId id, RegLocation rl_dest)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* index = cu->irb->getInt32(idx);
-  llvm::Value* res = cu->irb->CreateCall(intr, index);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* index = cu->irb->getInt32(idx);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, index);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertCheckCast(CompilationUnit* cu, uint32_t type_idx, RegLocation rl_src)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::HLCheckCast;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2> args;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::HLCheckCast;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(type_idx));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
   cu->irb->CreateCall(intr, args);
@@ -640,185 +639,185 @@
 
 static void ConvertNewInstance(CompilationUnit* cu, uint32_t type_idx, RegLocation rl_dest)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::NewInstance;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* index = cu->irb->getInt32(type_idx);
-  llvm::Value* res = cu->irb->CreateCall(intr, index);
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::NewInstance;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* index = cu->irb->getInt32(type_idx);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, index);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertNewArray(CompilationUnit* cu, uint32_t type_idx,
                             RegLocation rl_dest, RegLocation rl_src)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::NewArray;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2> args;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::NewArray;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(type_idx));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertAget(CompilationUnit* cu, int opt_flags,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                        art::llvm::IntrinsicHelper::IntrinsicId id,
                         RegLocation rl_dest, RegLocation rl_array, RegLocation rl_index)
 {
-  llvm::SmallVector<llvm::Value*, 3> args;
+  ::llvm::SmallVector< ::llvm::Value*, 3> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_array.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_index.orig_sreg));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertAput(CompilationUnit* cu, int opt_flags,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                        art::llvm::IntrinsicHelper::IntrinsicId id,
                         RegLocation rl_src, RegLocation rl_array, RegLocation rl_index)
 {
-  llvm::SmallVector<llvm::Value*, 4> args;
+  ::llvm::SmallVector< ::llvm::Value*, 4> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_array.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_index.orig_sreg));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(intr, args);
 }
 
 static void ConvertIget(CompilationUnit* cu, int opt_flags,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                        art::llvm::IntrinsicHelper::IntrinsicId id,
                         RegLocation rl_dest, RegLocation rl_obj, int field_index)
 {
-  llvm::SmallVector<llvm::Value*, 3> args;
+  ::llvm::SmallVector< ::llvm::Value*, 3> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_obj.orig_sreg));
   args.push_back(cu->irb->getInt32(field_index));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertIput(CompilationUnit* cu, int opt_flags,
-                        compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                        art::llvm::IntrinsicHelper::IntrinsicId id,
                         RegLocation rl_src, RegLocation rl_obj, int field_index)
 {
-  llvm::SmallVector<llvm::Value*, 4> args;
+  ::llvm::SmallVector< ::llvm::Value*, 4> args;
   args.push_back(cu->irb->getInt32(opt_flags));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_obj.orig_sreg));
   args.push_back(cu->irb->getInt32(field_index));
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
   cu->irb->CreateCall(intr, args);
 }
 
 static void ConvertInstanceOf(CompilationUnit* cu, uint32_t type_idx,
                               RegLocation rl_dest, RegLocation rl_src)
 {
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::InstanceOf;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2> args;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::InstanceOf;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(cu->irb->getInt32(type_idx));
   args.push_back(GetLLVMValue(cu, rl_src.orig_sreg));
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertIntToLong(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* res = cu->irb->CreateSExt(GetLLVMValue(cu, rl_src.orig_sreg),
+  ::llvm::Value* res = cu->irb->CreateSExt(GetLLVMValue(cu, rl_src.orig_sreg),
                                             cu->irb->getInt64Ty());
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertLongToInt(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
-  llvm::Value* res = cu->irb->CreateTrunc(src, cu->irb->getInt32Ty());
+  ::llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* res = cu->irb->CreateTrunc(src, cu->irb->getInt32Ty());
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertFloatToDouble(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
-  llvm::Value* res = cu->irb->CreateFPExt(src, cu->irb->getDoubleTy());
+  ::llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* res = cu->irb->CreateFPExt(src, cu->irb->getDoubleTy());
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertDoubleToFloat(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
-  llvm::Value* res = cu->irb->CreateFPTrunc(src, cu->irb->getFloatTy());
+  ::llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* res = cu->irb->CreateFPTrunc(src, cu->irb->getFloatTy());
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertWideComparison(CompilationUnit* cu,
-                                  compiler_llvm::IntrinsicHelper::IntrinsicId id,
+                                  art::llvm::IntrinsicHelper::IntrinsicId id,
                                   RegLocation rl_dest, RegLocation rl_src1,
                            RegLocation rl_src2)
 {
   DCHECK_EQ(rl_src1.fp, rl_src2.fp);
   DCHECK_EQ(rl_src1.wide, rl_src2.wide);
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::SmallVector<llvm::Value*, 2> args;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::SmallVector< ::llvm::Value*, 2> args;
   args.push_back(GetLLVMValue(cu, rl_src1.orig_sreg));
   args.push_back(GetLLVMValue(cu, rl_src2.orig_sreg));
-  llvm::Value* res = cu->irb->CreateCall(intr, args);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, args);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertIntNarrowing(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src,
-                                compiler_llvm::IntrinsicHelper::IntrinsicId id)
+                                art::llvm::IntrinsicHelper::IntrinsicId id)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res =
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res =
       cu->irb->CreateCall(intr, GetLLVMValue(cu, rl_src.orig_sreg));
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertNeg(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* res = cu->irb->CreateNeg(GetLLVMValue(cu, rl_src.orig_sreg));
+  ::llvm::Value* res = cu->irb->CreateNeg(GetLLVMValue(cu, rl_src.orig_sreg));
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
-static void ConvertIntToFP(CompilationUnit* cu, llvm::Type* ty, RegLocation rl_dest,
+static void ConvertIntToFP(CompilationUnit* cu, ::llvm::Type* ty, RegLocation rl_dest,
                            RegLocation rl_src)
 {
-  llvm::Value* res =
+  ::llvm::Value* res =
       cu->irb->CreateSIToFP(GetLLVMValue(cu, rl_src.orig_sreg), ty);
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
-static void ConvertFPToInt(CompilationUnit* cu, compiler_llvm::IntrinsicHelper::IntrinsicId id,
+static void ConvertFPToInt(CompilationUnit* cu, art::llvm::IntrinsicHelper::IntrinsicId id,
                            RegLocation rl_dest,
                     RegLocation rl_src)
 {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Value* res = cu->irb->CreateCall(intr, GetLLVMValue(cu, rl_src.orig_sreg));
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Value* res = cu->irb->CreateCall(intr, GetLLVMValue(cu, rl_src.orig_sreg));
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 
 static void ConvertNegFP(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* res =
+  ::llvm::Value* res =
       cu->irb->CreateFNeg(GetLLVMValue(cu, rl_src.orig_sreg));
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void ConvertNot(CompilationUnit* cu, RegLocation rl_dest, RegLocation rl_src)
 {
-  llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
-  llvm::Value* res = cu->irb->CreateXor(src, static_cast<uint64_t>(-1));
+  ::llvm::Value* src = GetLLVMValue(cu, rl_src.orig_sreg);
+  ::llvm::Value* res = cu->irb->CreateXor(src, static_cast<uint64_t>(-1));
   DefineValue(cu, res, rl_dest.orig_sreg);
 }
 
 static void EmitConstructorBarrier(CompilationUnit* cu) {
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
-      compiler_llvm::IntrinsicHelper::ConstructorBarrier);
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
+      art::llvm::IntrinsicHelper::ConstructorBarrier);
   cu->irb->CreateCall(intr);
 }
 
@@ -828,7 +827,7 @@
  * when necessary.
  */
 static bool ConvertMIRNode(CompilationUnit* cu, MIR* mir, BasicBlock* bb,
-                           llvm::BasicBlock* llvm_bb, LIR* label_list)
+                           ::llvm::BasicBlock* llvm_bb, LIR* label_list)
 {
   bool res = false;   // Assume success
   RegLocation rl_src[3];
@@ -905,8 +904,8 @@
          * Insert a dummy intrinsic copy call, which will be recognized
          * by the quick path and removed by the portable path.
          */
-        llvm::Value* src = GetLLVMValue(cu, rl_src[0].orig_sreg);
-        llvm::Value* res = EmitCopy(cu, src, rl_dest);
+        ::llvm::Value* src = GetLLVMValue(cu, rl_src[0].orig_sreg);
+        ::llvm::Value* res = EmitCopy(cu, src, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
@@ -914,8 +913,8 @@
     case Instruction::CONST:
     case Instruction::CONST_4:
     case Instruction::CONST_16: {
-        llvm::Constant* imm_value = cu->irb->getJInt(vB);
-        llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
+        ::llvm::Constant* imm_value = cu->irb->getJInt(vB);
+        ::llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
@@ -924,97 +923,97 @@
     case Instruction::CONST_WIDE_32: {
         // Sign extend to 64 bits
         int64_t imm = static_cast<int32_t>(vB);
-        llvm::Constant* imm_value = cu->irb->getJLong(imm);
-        llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
+        ::llvm::Constant* imm_value = cu->irb->getJLong(imm);
+        ::llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
 
     case Instruction::CONST_HIGH16: {
-        llvm::Constant* imm_value = cu->irb->getJInt(vB << 16);
-        llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
+        ::llvm::Constant* imm_value = cu->irb->getJInt(vB << 16);
+        ::llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
 
     case Instruction::CONST_WIDE: {
-        llvm::Constant* imm_value =
+        ::llvm::Constant* imm_value =
             cu->irb->getJLong(mir->dalvikInsn.vB_wide);
-        llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
+        ::llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
     case Instruction::CONST_WIDE_HIGH16: {
         int64_t imm = static_cast<int64_t>(vB) << 48;
-        llvm::Constant* imm_value = cu->irb->getJLong(imm);
-        llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
+        ::llvm::Constant* imm_value = cu->irb->getJLong(imm);
+        ::llvm::Value* res = EmitConst(cu, imm_value, rl_dest);
         DefineValue(cu, res, rl_dest.orig_sreg);
       }
       break;
 
     case Instruction::SPUT_OBJECT:
-      ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputObject,
+      ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputObject,
                   rl_src[0]);
       break;
     case Instruction::SPUT:
       if (rl_src[0].fp) {
-        ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputFloat,
+        ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputFloat,
                     rl_src[0]);
       } else {
-        ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSput, rl_src[0]);
+        ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSput, rl_src[0]);
       }
       break;
     case Instruction::SPUT_BOOLEAN:
-      ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputBoolean,
+      ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputBoolean,
                   rl_src[0]);
       break;
     case Instruction::SPUT_BYTE:
-      ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputByte, rl_src[0]);
+      ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputByte, rl_src[0]);
       break;
     case Instruction::SPUT_CHAR:
-      ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputChar, rl_src[0]);
+      ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputChar, rl_src[0]);
       break;
     case Instruction::SPUT_SHORT:
-      ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputShort, rl_src[0]);
+      ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputShort, rl_src[0]);
       break;
     case Instruction::SPUT_WIDE:
       if (rl_src[0].fp) {
-        ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputDouble,
+        ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputDouble,
                     rl_src[0]);
       } else {
-        ConvertSput(cu, vB, compiler_llvm::IntrinsicHelper::HLSputWide,
+        ConvertSput(cu, vB, art::llvm::IntrinsicHelper::HLSputWide,
                     rl_src[0]);
       }
       break;
 
     case Instruction::SGET_OBJECT:
-      ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetObject, rl_dest);
+      ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetObject, rl_dest);
       break;
     case Instruction::SGET:
       if (rl_dest.fp) {
-        ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetFloat, rl_dest);
+        ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetFloat, rl_dest);
       } else {
-        ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSget, rl_dest);
+        ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSget, rl_dest);
       }
       break;
     case Instruction::SGET_BOOLEAN:
-      ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetBoolean, rl_dest);
+      ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetBoolean, rl_dest);
       break;
     case Instruction::SGET_BYTE:
-      ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetByte, rl_dest);
+      ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetByte, rl_dest);
       break;
     case Instruction::SGET_CHAR:
-      ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetChar, rl_dest);
+      ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetChar, rl_dest);
       break;
     case Instruction::SGET_SHORT:
-      ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetShort, rl_dest);
+      ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetShort, rl_dest);
       break;
     case Instruction::SGET_WIDE:
       if (rl_dest.fp) {
-        ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetDouble,
+        ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetDouble,
                     rl_dest);
       } else {
-        ConvertSget(cu, vB, compiler_llvm::IntrinsicHelper::HLSgetWide, rl_dest);
+        ConvertSget(cu, vB, art::llvm::IntrinsicHelper::HLSgetWide, rl_dest);
       }
       break;
 
@@ -1143,32 +1142,32 @@
       break;
     case Instruction::SHL_LONG:
     case Instruction::SHL_LONG_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::SHLLong,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::SHLLong,
                     rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::SHL_INT:
     case Instruction::SHL_INT_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::SHLInt,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::SHLInt,
                    rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::SHR_LONG:
     case Instruction::SHR_LONG_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::SHRLong,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::SHRLong,
                    rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::SHR_INT:
     case Instruction::SHR_INT_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::SHRInt,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::SHRInt,
                    rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::USHR_LONG:
     case Instruction::USHR_LONG_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::USHRLong,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::USHRLong,
                    rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::USHR_INT:
     case Instruction::USHR_INT_2ADDR:
-      ConvertShift(cu, compiler_llvm::IntrinsicHelper::USHRInt,
+      ConvertShift(cu, art::llvm::IntrinsicHelper::USHRInt,
                    rl_dest, rl_src[0], rl_src[1]);
       break;
 
@@ -1205,15 +1204,15 @@
       ConvertArithOpLit(cu, kOpXor, rl_dest, rl_src[0], vC);
       break;
     case Instruction::SHL_INT_LIT8:
-      ConvertShiftLit(cu, compiler_llvm::IntrinsicHelper::SHLInt,
+      ConvertShiftLit(cu, art::llvm::IntrinsicHelper::SHLInt,
                       rl_dest, rl_src[0], vC & 0x1f);
       break;
     case Instruction::SHR_INT_LIT8:
-      ConvertShiftLit(cu, compiler_llvm::IntrinsicHelper::SHRInt,
+      ConvertShiftLit(cu, art::llvm::IntrinsicHelper::SHRInt,
                       rl_dest, rl_src[0], vC & 0x1f);
       break;
     case Instruction::USHR_INT_LIT8:
-      ConvertShiftLit(cu, compiler_llvm::IntrinsicHelper::USHRInt,
+      ConvertShiftLit(cu, art::llvm::IntrinsicHelper::USHRInt,
                       rl_dest, rl_src[0], vC & 0x1f);
       break;
 
@@ -1307,12 +1306,12 @@
 
     case Instruction::CONST_STRING:
     case Instruction::CONST_STRING_JUMBO:
-      ConvertConstObject(cu, vB, compiler_llvm::IntrinsicHelper::ConstString,
+      ConvertConstObject(cu, vB, art::llvm::IntrinsicHelper::ConstString,
                          rl_dest);
       break;
 
     case Instruction::CONST_CLASS:
-      ConvertConstObject(cu, vB, compiler_llvm::IntrinsicHelper::ConstClass,
+      ConvertConstObject(cu, vB, art::llvm::IntrinsicHelper::ConstClass,
                          rl_dest);
       break;
 
@@ -1354,13 +1353,13 @@
 
     case Instruction::MONITOR_ENTER:
       ConvertMonitorEnterExit(cu, opt_flags,
-                              compiler_llvm::IntrinsicHelper::MonitorEnter,
+                              art::llvm::IntrinsicHelper::MonitorEnter,
                               rl_src[0]);
       break;
 
     case Instruction::MONITOR_EXIT:
       ConvertMonitorEnterExit(cu, opt_flags,
-                              compiler_llvm::IntrinsicHelper::MonitorExit,
+                              art::llvm::IntrinsicHelper::MonitorExit,
                               rl_src[0]);
       break;
 
@@ -1379,41 +1378,41 @@
     case Instruction::AGET:
       if (rl_dest.fp) {
         ConvertAget(cu, opt_flags,
-                    compiler_llvm::IntrinsicHelper::HLArrayGetFloat,
+                    art::llvm::IntrinsicHelper::HLArrayGetFloat,
                     rl_dest, rl_src[0], rl_src[1]);
       } else {
-        ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGet,
+        ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGet,
                     rl_dest, rl_src[0], rl_src[1]);
       }
       break;
     case Instruction::AGET_OBJECT:
-      ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGetObject,
+      ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGetObject,
                   rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::AGET_BOOLEAN:
       ConvertAget(cu, opt_flags,
-                  compiler_llvm::IntrinsicHelper::HLArrayGetBoolean,
+                  art::llvm::IntrinsicHelper::HLArrayGetBoolean,
                   rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::AGET_BYTE:
-      ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGetByte,
+      ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGetByte,
                   rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::AGET_CHAR:
-      ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGetChar,
+      ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGetChar,
                   rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::AGET_SHORT:
-      ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGetShort,
+      ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGetShort,
                   rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::AGET_WIDE:
       if (rl_dest.fp) {
         ConvertAget(cu, opt_flags,
-                    compiler_llvm::IntrinsicHelper::HLArrayGetDouble,
+                    art::llvm::IntrinsicHelper::HLArrayGetDouble,
                     rl_dest, rl_src[0], rl_src[1]);
       } else {
-        ConvertAget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayGetWide,
+        ConvertAget(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayGetWide,
                     rl_dest, rl_src[0], rl_src[1]);
       }
       break;
@@ -1421,118 +1420,118 @@
     case Instruction::APUT:
       if (rl_src[0].fp) {
         ConvertAput(cu, opt_flags,
-                    compiler_llvm::IntrinsicHelper::HLArrayPutFloat,
+                    art::llvm::IntrinsicHelper::HLArrayPutFloat,
                     rl_src[0], rl_src[1], rl_src[2]);
       } else {
-        ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPut,
+        ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPut,
                     rl_src[0], rl_src[1], rl_src[2]);
       }
       break;
     case Instruction::APUT_OBJECT:
-      ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPutObject,
+      ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPutObject,
                     rl_src[0], rl_src[1], rl_src[2]);
       break;
     case Instruction::APUT_BOOLEAN:
       ConvertAput(cu, opt_flags,
-                  compiler_llvm::IntrinsicHelper::HLArrayPutBoolean,
+                  art::llvm::IntrinsicHelper::HLArrayPutBoolean,
                     rl_src[0], rl_src[1], rl_src[2]);
       break;
     case Instruction::APUT_BYTE:
-      ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPutByte,
+      ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPutByte,
                     rl_src[0], rl_src[1], rl_src[2]);
       break;
     case Instruction::APUT_CHAR:
-      ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPutChar,
+      ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPutChar,
                     rl_src[0], rl_src[1], rl_src[2]);
       break;
     case Instruction::APUT_SHORT:
-      ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPutShort,
+      ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPutShort,
                     rl_src[0], rl_src[1], rl_src[2]);
       break;
     case Instruction::APUT_WIDE:
       if (rl_src[0].fp) {
         ConvertAput(cu, opt_flags,
-                    compiler_llvm::IntrinsicHelper::HLArrayPutDouble,
+                    art::llvm::IntrinsicHelper::HLArrayPutDouble,
                     rl_src[0], rl_src[1], rl_src[2]);
       } else {
-        ConvertAput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLArrayPutWide,
+        ConvertAput(cu, opt_flags, art::llvm::IntrinsicHelper::HLArrayPutWide,
                     rl_src[0], rl_src[1], rl_src[2]);
       }
       break;
 
     case Instruction::IGET:
       if (rl_dest.fp) {
-        ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetFloat,
+        ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetFloat,
                     rl_dest, rl_src[0], vC);
       } else {
-        ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGet,
+        ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGet,
                     rl_dest, rl_src[0], vC);
       }
       break;
     case Instruction::IGET_OBJECT:
-      ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetObject,
+      ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetObject,
                   rl_dest, rl_src[0], vC);
       break;
     case Instruction::IGET_BOOLEAN:
-      ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetBoolean,
+      ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetBoolean,
                   rl_dest, rl_src[0], vC);
       break;
     case Instruction::IGET_BYTE:
-      ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetByte,
+      ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetByte,
                   rl_dest, rl_src[0], vC);
       break;
     case Instruction::IGET_CHAR:
-      ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetChar,
+      ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetChar,
                   rl_dest, rl_src[0], vC);
       break;
     case Instruction::IGET_SHORT:
-      ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetShort,
+      ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetShort,
                   rl_dest, rl_src[0], vC);
       break;
     case Instruction::IGET_WIDE:
       if (rl_dest.fp) {
-        ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetDouble,
+        ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetDouble,
                     rl_dest, rl_src[0], vC);
       } else {
-        ConvertIget(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIGetWide,
+        ConvertIget(cu, opt_flags, art::llvm::IntrinsicHelper::HLIGetWide,
                     rl_dest, rl_src[0], vC);
       }
       break;
     case Instruction::IPUT:
       if (rl_src[0].fp) {
-        ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutFloat,
+        ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutFloat,
                     rl_src[0], rl_src[1], vC);
       } else {
-        ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPut,
+        ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPut,
                     rl_src[0], rl_src[1], vC);
       }
       break;
     case Instruction::IPUT_OBJECT:
-      ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutObject,
+      ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutObject,
                   rl_src[0], rl_src[1], vC);
       break;
     case Instruction::IPUT_BOOLEAN:
-      ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutBoolean,
+      ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutBoolean,
                   rl_src[0], rl_src[1], vC);
       break;
     case Instruction::IPUT_BYTE:
-      ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutByte,
+      ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutByte,
                   rl_src[0], rl_src[1], vC);
       break;
     case Instruction::IPUT_CHAR:
-      ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutChar,
+      ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutChar,
                   rl_src[0], rl_src[1], vC);
       break;
     case Instruction::IPUT_SHORT:
-      ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutShort,
+      ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutShort,
                   rl_src[0], rl_src[1], vC);
       break;
     case Instruction::IPUT_WIDE:
       if (rl_src[0].fp) {
-        ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutDouble,
+        ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutDouble,
                     rl_src[0], rl_src[1], vC);
       } else {
-        ConvertIput(cu, opt_flags, compiler_llvm::IntrinsicHelper::HLIPutWide,
+        ConvertIput(cu, opt_flags, art::llvm::IntrinsicHelper::HLIPutWide,
                     rl_src[0], rl_src[1], vC);
       }
       break;
@@ -1551,15 +1550,15 @@
 
     case Instruction::INT_TO_CHAR:
       ConvertIntNarrowing(cu, rl_dest, rl_src[0],
-                          compiler_llvm::IntrinsicHelper::IntToChar);
+                          art::llvm::IntrinsicHelper::IntToChar);
       break;
     case Instruction::INT_TO_BYTE:
       ConvertIntNarrowing(cu, rl_dest, rl_src[0],
-                          compiler_llvm::IntrinsicHelper::IntToByte);
+                          art::llvm::IntrinsicHelper::IntToByte);
       break;
     case Instruction::INT_TO_SHORT:
       ConvertIntNarrowing(cu, rl_dest, rl_src[0],
-                          compiler_llvm::IntrinsicHelper::IntToShort);
+                          art::llvm::IntrinsicHelper::IntToShort);
       break;
 
     case Instruction::INT_TO_FLOAT:
@@ -1596,39 +1595,39 @@
       break;
 
     case Instruction::FLOAT_TO_INT:
-      ConvertFPToInt(cu, compiler_llvm::IntrinsicHelper::F2I, rl_dest, rl_src[0]);
+      ConvertFPToInt(cu, art::llvm::IntrinsicHelper::F2I, rl_dest, rl_src[0]);
       break;
 
     case Instruction::DOUBLE_TO_INT:
-      ConvertFPToInt(cu, compiler_llvm::IntrinsicHelper::D2I, rl_dest, rl_src[0]);
+      ConvertFPToInt(cu, art::llvm::IntrinsicHelper::D2I, rl_dest, rl_src[0]);
       break;
 
     case Instruction::FLOAT_TO_LONG:
-      ConvertFPToInt(cu, compiler_llvm::IntrinsicHelper::F2L, rl_dest, rl_src[0]);
+      ConvertFPToInt(cu, art::llvm::IntrinsicHelper::F2L, rl_dest, rl_src[0]);
       break;
 
     case Instruction::DOUBLE_TO_LONG:
-      ConvertFPToInt(cu, compiler_llvm::IntrinsicHelper::D2L, rl_dest, rl_src[0]);
+      ConvertFPToInt(cu, art::llvm::IntrinsicHelper::D2L, rl_dest, rl_src[0]);
       break;
 
     case Instruction::CMPL_FLOAT:
-      ConvertWideComparison(cu, compiler_llvm::IntrinsicHelper::CmplFloat,
+      ConvertWideComparison(cu, art::llvm::IntrinsicHelper::CmplFloat,
                             rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::CMPG_FLOAT:
-      ConvertWideComparison(cu, compiler_llvm::IntrinsicHelper::CmpgFloat,
+      ConvertWideComparison(cu, art::llvm::IntrinsicHelper::CmpgFloat,
                             rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::CMPL_DOUBLE:
-      ConvertWideComparison(cu, compiler_llvm::IntrinsicHelper::CmplDouble,
+      ConvertWideComparison(cu, art::llvm::IntrinsicHelper::CmplDouble,
                             rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::CMPG_DOUBLE:
-      ConvertWideComparison(cu, compiler_llvm::IntrinsicHelper::CmpgDouble,
+      ConvertWideComparison(cu, art::llvm::IntrinsicHelper::CmpgDouble,
                             rl_dest, rl_src[0], rl_src[1]);
       break;
     case Instruction::CMP_LONG:
-      ConvertWideComparison(cu, compiler_llvm::IntrinsicHelper::CmpLong,
+      ConvertWideComparison(cu, art::llvm::IntrinsicHelper::CmpLong,
                             rl_dest, rl_src[0], rl_src[1]);
       break;
 
@@ -1650,9 +1649,9 @@
 static void SetDexOffset(CompilationUnit* cu, int32_t offset)
 {
   cu->current_dalvik_offset = offset;
-  llvm::SmallVector<llvm::Value*, 1> array_ref;
+  ::llvm::SmallVector< ::llvm::Value*, 1> array_ref;
   array_ref.push_back(cu->irb->getInt32(offset));
-  llvm::MDNode* node = llvm::MDNode::get(*cu->context, array_ref);
+  ::llvm::MDNode* node = ::llvm::MDNode::get(*cu->context, array_ref);
   cu->irb->SetDexOffset(node);
 }
 
@@ -1661,20 +1660,20 @@
 {
   // We don't want dex offset on this
   cu->irb->SetDexOffset(NULL);
-  compiler_llvm::IntrinsicHelper::IntrinsicId id;
-  id = compiler_llvm::IntrinsicHelper::MethodInfo;
-  llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
-  llvm::Instruction* inst = cu->irb->CreateCall(intr);
-  llvm::SmallVector<llvm::Value*, 2> reg_info;
+  art::llvm::IntrinsicHelper::IntrinsicId id;
+  id = art::llvm::IntrinsicHelper::MethodInfo;
+  ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(id);
+  ::llvm::Instruction* inst = cu->irb->CreateCall(intr);
+  ::llvm::SmallVector< ::llvm::Value*, 2> reg_info;
   reg_info.push_back(cu->irb->getInt32(cu->num_ins));
   reg_info.push_back(cu->irb->getInt32(cu->num_regs));
   reg_info.push_back(cu->irb->getInt32(cu->num_outs));
   reg_info.push_back(cu->irb->getInt32(cu->num_compiler_temps));
   reg_info.push_back(cu->irb->getInt32(cu->num_ssa_regs));
-  llvm::MDNode* reg_info_node = llvm::MDNode::get(*cu->context, reg_info);
+  ::llvm::MDNode* reg_info_node = ::llvm::MDNode::get(*cu->context, reg_info);
   inst->setMetadata("RegInfo", reg_info_node);
   int promo_size = cu->num_dalvik_registers + cu->num_compiler_temps + 1;
-  llvm::SmallVector<llvm::Value*, 50> pmap;
+  ::llvm::SmallVector< ::llvm::Value*, 50> pmap;
   for (int i = 0; i < promo_size; i++) {
     PromotionMap* p = &cu->promotion_map[i];
     int32_t map_data = ((p->first_in_pair & 0xff) << 24) |
@@ -1684,12 +1683,12 @@
                       (p->core_location & 0xf);
     pmap.push_back(cu->irb->getInt32(map_data));
   }
-  llvm::MDNode* map_node = llvm::MDNode::get(*cu->context, pmap);
+  ::llvm::MDNode* map_node = ::llvm::MDNode::get(*cu->context, pmap);
   inst->setMetadata("PromotionMap", map_node);
   SetDexOffset(cu, cu->current_dalvik_offset);
 }
 
-static void HandlePhiNodes(CompilationUnit* cu, BasicBlock* bb, llvm::BasicBlock* llvm_bb)
+static void HandlePhiNodes(CompilationUnit* cu, BasicBlock* bb, ::llvm::BasicBlock* llvm_bb)
 {
   SetDexOffset(cu, bb->start_offset);
   for (MIR* mir = bb->first_mir_insn; mir != NULL; mir = mir->next) {
@@ -1714,9 +1713,9 @@
       continue;  // No Phi node - handled via low word
     }
     int* incoming = reinterpret_cast<int*>(mir->dalvikInsn.vB);
-    llvm::Type* phi_type =
+    ::llvm::Type* phi_type =
         LlvmTypeFromLocRec(cu, rl_dest);
-    llvm::PHINode* phi = cu->irb->CreatePHI(phi_type, mir->ssa_rep->num_uses);
+    ::llvm::PHINode* phi = cu->irb->CreatePHI(phi_type, mir->ssa_rep->num_uses);
     for (int i = 0; i < mir->ssa_rep->num_uses; i++) {
       RegLocation loc;
       // Don't check width here.
@@ -1740,7 +1739,7 @@
 
 /* Extended MIR instructions like PHI */
 static void ConvertExtendedMIR(CompilationUnit* cu, BasicBlock* bb, MIR* mir,
-                               llvm::BasicBlock* llvm_bb)
+                               ::llvm::BasicBlock* llvm_bb)
 {
 
   switch (static_cast<ExtendedMIROpcode>(mir->dalvikInsn.opcode)) {
@@ -1750,7 +1749,7 @@
       if (!rl_dest.high_word) {
         // Only consider low word of pairs.
         DCHECK(GetLLVMValue(cu, rl_dest.orig_sreg) != NULL);
-        llvm::Value* phi = GetLLVMValue(cu, rl_dest.orig_sreg);
+        ::llvm::Value* phi = GetLLVMValue(cu, rl_dest.orig_sreg);
         if (1) SetVregOnValue(cu, phi, rl_dest.orig_sreg);
       }
       break;
@@ -1791,7 +1790,7 @@
 static bool BlockBitcodeConversion(CompilationUnit* cu, BasicBlock* bb)
 {
   if (bb->block_type == kDead) return false;
-  llvm::BasicBlock* llvm_bb = GetLLVMBlock(cu, bb->id);
+  ::llvm::BasicBlock* llvm_bb = GetLLVMBlock(cu, bb->id);
   if (llvm_bb == NULL) {
     CHECK(bb->block_type == kExitBlock);
   } else {
@@ -1813,18 +1812,18 @@
     SetMethodInfo(cu);
 
     { // Allocate shadowframe.
-      compiler_llvm::IntrinsicHelper::IntrinsicId id =
-              compiler_llvm::IntrinsicHelper::AllocaShadowFrame;
-      llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
-      llvm::Value* entries = cu->irb->getInt32(cu->num_dalvik_registers);
+      art::llvm::IntrinsicHelper::IntrinsicId id =
+              art::llvm::IntrinsicHelper::AllocaShadowFrame;
+      ::llvm::Function* func = cu->intrinsic_helper->GetIntrinsicFunction(id);
+      ::llvm::Value* entries = cu->irb->getInt32(cu->num_dalvik_registers);
       cu->irb->CreateCall(func, entries);
     }
 
     { // Store arguments to vregs.
       uint16_t arg_reg = cu->num_regs;
 
-      llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
-      llvm::Function::arg_iterator arg_end(cu->func->arg_end());
+      ::llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
+      ::llvm::Function::arg_iterator arg_end(cu->func->arg_end());
 
       const char* shorty = cu->shorty;
       uint32_t shorty_size = strlen(shorty);
@@ -1886,23 +1885,23 @@
       work_half->meta.original_opcode = work_half->dalvikInsn.opcode;
       work_half->dalvikInsn.opcode = static_cast<Instruction::Code>(kMirOpNop);
       if (bb->successor_block_list.block_list_type == kCatch) {
-        llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
-            compiler_llvm::IntrinsicHelper::CatchTargets);
-        llvm::Value* switch_key =
+        ::llvm::Function* intr = cu->intrinsic_helper->GetIntrinsicFunction(
+            art::llvm::IntrinsicHelper::CatchTargets);
+        ::llvm::Value* switch_key =
             cu->irb->CreateCall(intr, cu->irb->getInt32(mir->offset));
         GrowableListIterator iter;
         GrowableListIteratorInit(&bb->successor_block_list.blocks, &iter);
         // New basic block to use for work half
-        llvm::BasicBlock* work_bb =
-            llvm::BasicBlock::Create(*cu->context, "", cu->func);
-        llvm::SwitchInst* sw =
+        ::llvm::BasicBlock* work_bb =
+            ::llvm::BasicBlock::Create(*cu->context, "", cu->func);
+        ::llvm::SwitchInst* sw =
             cu->irb->CreateSwitch(switch_key, work_bb,
                                      bb->successor_block_list.blocks.num_used);
         while (true) {
           SuccessorBlockInfo *successor_block_info =
               reinterpret_cast<SuccessorBlockInfo*>(GrowableListIteratorNext(&iter));
           if (successor_block_info == NULL) break;
-          llvm::BasicBlock *target =
+          ::llvm::BasicBlock *target =
               GetLLVMBlock(cu, successor_block_info->block->id);
           int type_index = successor_block_info->key;
           sw->addCase(cu->irb->getInt32(type_index), target);
@@ -1959,13 +1958,13 @@
   return shorty_type;
 }
 
-static llvm::FunctionType* GetFunctionType(CompilationUnit* cu) {
+static ::llvm::FunctionType* GetFunctionType(CompilationUnit* cu) {
 
   // Get return type
-  llvm::Type* ret_type = cu->irb->getJType(RemapShorty(cu->shorty[0]));
+  ::llvm::Type* ret_type = cu->irb->getJType(RemapShorty(cu->shorty[0]));
 
   // Get argument type
-  std::vector<llvm::Type*> args_type;
+  std::vector< ::llvm::Type*> args_type;
 
   // method object
   args_type.push_back(cu->irb->getJMethodTy());
@@ -1979,24 +1978,24 @@
     args_type.push_back(cu->irb->getJType(RemapShorty(cu->shorty[i])));
   }
 
-  return llvm::FunctionType::get(ret_type, args_type, false);
+  return ::llvm::FunctionType::get(ret_type, args_type, false);
 }
 
 static bool CreateFunction(CompilationUnit* cu) {
   std::string func_name(PrettyMethod(cu->method_idx, *cu->dex_file,
                                      /* with_signature */ false));
-  llvm::FunctionType* func_type = GetFunctionType(cu);
+  ::llvm::FunctionType* func_type = GetFunctionType(cu);
 
   if (func_type == NULL) {
     return false;
   }
 
-  cu->func = llvm::Function::Create(func_type,
-                                       llvm::Function::ExternalLinkage,
+  cu->func = ::llvm::Function::Create(func_type,
+                                       ::llvm::Function::ExternalLinkage,
                                        func_name, cu->module);
 
-  llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
-  llvm::Function::arg_iterator arg_end(cu->func->arg_end());
+  ::llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
+  ::llvm::Function::arg_iterator arg_end(cu->func->arg_end());
 
   arg_iter->setName("method");
   ++arg_iter;
@@ -2019,14 +2018,14 @@
   } else {
     int offset = bb->start_offset;
     bool entry_block = (bb->block_type == kEntryBlock);
-    llvm::BasicBlock* llvm_bb =
-        llvm::BasicBlock::Create(*cu->context, entry_block ? "entry" :
+    ::llvm::BasicBlock* llvm_bb =
+        ::llvm::BasicBlock::Create(*cu->context, entry_block ? "entry" :
                                  StringPrintf(kLabelFormat, bb->catch_entry ? kCatchBlock :
                                               kNormalBlock, offset, bb->id), cu->func);
     if (entry_block) {
         cu->entry_bb = llvm_bb;
         cu->placeholder_bb =
-            llvm::BasicBlock::Create(*cu->context, "placeholder",
+            ::llvm::BasicBlock::Create(*cu->context, "placeholder",
                                      cu->func);
     }
     cu->id_to_block_map.Put(bb->id, llvm_bb);
@@ -2060,23 +2059,23 @@
    * the definition yet).
    */
   cu->irb->SetInsertPoint(cu->placeholder_bb);
-  llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
+  ::llvm::Function::arg_iterator arg_iter(cu->func->arg_begin());
   arg_iter++;  /* Skip path method */
   for (int i = 0; i < cu->num_ssa_regs; i++) {
-    llvm::Value* val;
+    ::llvm::Value* val;
     RegLocation rl_temp = cu->reg_location[i];
     if ((SRegToVReg(cu, i) < 0) || rl_temp.high_word) {
       InsertGrowableList(cu, &cu->llvm_values, 0);
     } else if ((i < cu->num_regs) ||
                (i >= (cu->num_regs + cu->num_ins))) {
-      llvm::Constant* imm_value = cu->reg_location[i].wide ?
+      ::llvm::Constant* imm_value = cu->reg_location[i].wide ?
          cu->irb->getJLong(0) : cu->irb->getJInt(0);
       val = EmitConst(cu, imm_value, cu->reg_location[i]);
       val->setName(LlvmSSAName(cu, i));
       InsertGrowableList(cu, &cu->llvm_values, reinterpret_cast<uintptr_t>(val));
     } else {
       // Recover previously-created argument values
-      llvm::Value* arg_val = arg_iter++;
+      ::llvm::Value* arg_val = arg_iter++;
       InsertGrowableList(cu, &cu->llvm_values, reinterpret_cast<uintptr_t>(arg_val));
     }
   }
@@ -2097,11 +2096,11 @@
    * If any definitions remain, we link the placeholder block into the
    * CFG.  Otherwise, it is deleted.
    */
-  for (llvm::BasicBlock::iterator it = cu->placeholder_bb->begin(),
+  for (::llvm::BasicBlock::iterator it = cu->placeholder_bb->begin(),
        it_end = cu->placeholder_bb->end(); it != it_end;) {
-    llvm::Instruction* inst = llvm::dyn_cast<llvm::Instruction>(it++);
+    ::llvm::Instruction* inst = ::llvm::dyn_cast< ::llvm::Instruction>(it++);
     DCHECK(inst != NULL);
-    llvm::Value* val = llvm::dyn_cast<llvm::Value>(inst);
+    ::llvm::Value* val = ::llvm::dyn_cast< ::llvm::Value>(inst);
     DCHECK(val != NULL);
     if (val->getNumUses() == 0) {
       inst->eraseFromParent();
@@ -2119,7 +2118,7 @@
   cu->irb->CreateBr(cu->entryTarget_bb);
 
   if (cu->enable_debug & (1 << kDebugVerifyBitcode)) {
-     if (llvm::verifyFunction(*cu->func, llvm::PrintMessageAction)) {
+     if (::llvm::verifyFunction(*cu->func, ::llvm::PrintMessageAction)) {
        LOG(INFO) << "Bitcode verification FAILED for "
                  << PrettyMethod(cu->method_idx, *cu->dex_file)
                  << " of size " << cu->insns_size;
@@ -2140,23 +2139,23 @@
       fname.resize(240);
     }
 
-    llvm::OwningPtr<llvm::tool_output_file> out_file(
-        new llvm::tool_output_file(fname.c_str(), errmsg,
-                                   llvm::raw_fd_ostream::F_Binary));
+    ::llvm::OwningPtr< ::llvm::tool_output_file> out_file(
+        new ::llvm::tool_output_file(fname.c_str(), errmsg,
+                                   ::llvm::raw_fd_ostream::F_Binary));
 
     if (!errmsg.empty()) {
       LOG(ERROR) << "Failed to create bitcode output file: " << errmsg;
     }
 
-    llvm::WriteBitcodeToFile(cu->module, out_file->os());
+    ::llvm::WriteBitcodeToFile(cu->module, out_file->os());
     out_file->keep();
   }
 }
 
-static RegLocation GetLoc(CompilationUnit* cu, llvm::Value* val) {
+static RegLocation GetLoc(CompilationUnit* cu, ::llvm::Value* val) {
   RegLocation res;
   DCHECK(val != NULL);
-  SafeMap<llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
+  SafeMap< ::llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
   if (it == cu->loc_map.end()) {
     std::string val_name = val->getName().str();
     if (val_name.empty()) {
@@ -2169,7 +2168,7 @@
       res.home = true;
       res.s_reg_low = INVALID_SREG;
       res.orig_sreg = INVALID_SREG;
-      llvm::Type* ty = val->getType();
+      ::llvm::Type* ty = val->getType();
       res.wide = ((ty == cu->irb->getInt64Ty()) ||
                   (ty == cu->irb->getDoubleTy()));
       if (res.wide) {
@@ -2266,7 +2265,7 @@
   return res;
 }
 
-static void CvtBinFPOp(CompilationUnit* cu, OpKind op, llvm::Instruction* inst)
+static void CvtBinFPOp(CompilationUnit* cu, OpKind op, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
@@ -2276,8 +2275,8 @@
    * may insert them - in particular for create_neg_fp.  Recognize this case
    * and deal with it.
    */
-  llvm::ConstantFP* op1C = llvm::dyn_cast<llvm::ConstantFP>(inst->getOperand(0));
-  llvm::ConstantFP* op2C = llvm::dyn_cast<llvm::ConstantFP>(inst->getOperand(1));
+  ::llvm::ConstantFP* op1C = ::llvm::dyn_cast< ::llvm::ConstantFP>(inst->getOperand(0));
+  ::llvm::ConstantFP* op2C = ::llvm::dyn_cast< ::llvm::ConstantFP>(inst->getOperand(1));
   DCHECK(op2C == NULL);
   if ((op1C != NULL) && (op == kOpSub)) {
     RegLocation rl_src = GetLoc(cu, inst->getOperand(1));
@@ -2299,7 +2298,7 @@
   }
 }
 
-static void CvtIntNarrowing(CompilationUnit* cu, llvm::Instruction* inst,
+static void CvtIntNarrowing(CompilationUnit* cu, ::llvm::Instruction* inst,
                      Instruction::Code opcode)
 {
   Codegen* cg = cu->cg.get();
@@ -2308,7 +2307,7 @@
   cg->GenIntNarrowing(cu, opcode, rl_dest, rl_src);
 }
 
-static void CvtIntToFP(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtIntToFP(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
@@ -2330,7 +2329,7 @@
   cg->GenConversion(cu, opcode, rl_dest, rl_src);
 }
 
-static void CvtFPToInt(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtFPToInt(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, call_inst);
@@ -2352,7 +2351,7 @@
   cg->GenConversion(cu, opcode, rl_dest, rl_src);
 }
 
-static void CvtFloatToDouble(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtFloatToDouble(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
@@ -2360,7 +2359,7 @@
   cg->GenConversion(cu, Instruction::FLOAT_TO_DOUBLE, rl_dest, rl_src);
 }
 
-static void CvtTrunc(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtTrunc(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
@@ -2370,7 +2369,7 @@
   cg->StoreValue(cu, rl_dest, rl_src);
 }
 
-static void CvtDoubleToFloat(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtDoubleToFloat(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
@@ -2379,7 +2378,7 @@
 }
 
 
-static void CvtIntExt(CompilationUnit* cu, llvm::Instruction* inst, bool is_signed)
+static void CvtIntExt(CompilationUnit* cu, ::llvm::Instruction* inst, bool is_signed)
 {
   Codegen* cg = cu->cg.get();
   // TODO: evaluate src/tgt types and add general support for more than int to long
@@ -2403,13 +2402,13 @@
   cg->StoreValueWide(cu, rl_dest, rl_result);
 }
 
-static void CvtBinOp(CompilationUnit* cu, OpKind op, llvm::Instruction* inst)
+static void CvtBinOp(CompilationUnit* cu, OpKind op, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, inst);
-  llvm::Value* lhs = inst->getOperand(0);
+  ::llvm::Value* lhs = inst->getOperand(0);
   // Special-case RSUB/NEG
-  llvm::ConstantInt* lhs_imm = llvm::dyn_cast<llvm::ConstantInt>(lhs);
+  ::llvm::ConstantInt* lhs_imm = ::llvm::dyn_cast< ::llvm::ConstantInt>(lhs);
   if ((op == kOpSub) && (lhs_imm != NULL)) {
     RegLocation rl_src1 = GetLoc(cu, inst->getOperand(1));
     if (rl_src1.wide) {
@@ -2423,8 +2422,8 @@
   }
   DCHECK(lhs_imm == NULL);
   RegLocation rl_src1 = GetLoc(cu, inst->getOperand(0));
-  llvm::Value* rhs = inst->getOperand(1);
-  llvm::ConstantInt* const_rhs = llvm::dyn_cast<llvm::ConstantInt>(rhs);
+  ::llvm::Value* rhs = inst->getOperand(1);
+  ::llvm::ConstantInt* const_rhs = ::llvm::dyn_cast< ::llvm::ConstantInt>(rhs);
   if (!rl_dest.wide && (const_rhs != NULL)) {
     Instruction::Code dalvik_op = GetDalvikOpcode(op, true, false);
     cg->GenArithOpIntLit(cu, dalvik_op, rl_dest, rl_src1, const_rhs->getSExtValue());
@@ -2448,14 +2447,14 @@
   }
 }
 
-static void CvtShiftOp(CompilationUnit* cu, Instruction::Code opcode, llvm::CallInst* call_inst)
+static void CvtShiftOp(CompilationUnit* cu, Instruction::Code opcode, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
   RegLocation rl_dest = GetLoc(cu, call_inst);
   RegLocation rl_src = GetLoc(cu, call_inst->getArgOperand(0));
-  llvm::Value* rhs = call_inst->getArgOperand(1);
-  if (llvm::ConstantInt* src2 = llvm::dyn_cast<llvm::ConstantInt>(rhs)) {
+  ::llvm::Value* rhs = call_inst->getArgOperand(1);
+  if (::llvm::ConstantInt* src2 = ::llvm::dyn_cast< ::llvm::ConstantInt>(rhs)) {
     DCHECK(!rl_dest.wide);
     cg->GenArithOpIntLit(cu, opcode, rl_dest, rl_src, src2->getSExtValue());
   } else {
@@ -2468,26 +2467,26 @@
   }
 }
 
-static void CvtBr(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtBr(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
-  llvm::BranchInst* br_inst = llvm::dyn_cast<llvm::BranchInst>(inst);
+  ::llvm::BranchInst* br_inst = ::llvm::dyn_cast< ::llvm::BranchInst>(inst);
   DCHECK(br_inst != NULL);
   DCHECK(br_inst->isUnconditional());  // May change - but this is all we use now
-  llvm::BasicBlock* target_bb = br_inst->getSuccessor(0);
+  ::llvm::BasicBlock* target_bb = br_inst->getSuccessor(0);
   cg->OpUnconditionalBranch(cu, cu->block_to_label_map.Get(target_bb));
 }
 
-static void CvtPhi(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtPhi(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   // Nop - these have already been processed
 }
 
-static void CvtRet(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtRet(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
-  llvm::ReturnInst* ret_inst = llvm::dyn_cast<llvm::ReturnInst>(inst);
-  llvm::Value* ret_val = ret_inst->getReturnValue();
+  ::llvm::ReturnInst* ret_inst = ::llvm::dyn_cast< ::llvm::ReturnInst>(inst);
+  ::llvm::Value* ret_val = ret_inst->getReturnValue();
   if (ret_val != NULL) {
     RegLocation rl_src = GetLoc(cu, ret_val);
     if (rl_src.wide) {
@@ -2499,54 +2498,54 @@
   cg->GenExitSequence(cu);
 }
 
-static ConditionCode GetCond(llvm::ICmpInst::Predicate llvm_cond)
+static ConditionCode GetCond(::llvm::ICmpInst::Predicate llvm_cond)
 {
   ConditionCode res = kCondAl;
   switch(llvm_cond) {
-    case llvm::ICmpInst::ICMP_EQ: res = kCondEq; break;
-    case llvm::ICmpInst::ICMP_NE: res = kCondNe; break;
-    case llvm::ICmpInst::ICMP_SLT: res = kCondLt; break;
-    case llvm::ICmpInst::ICMP_SGE: res = kCondGe; break;
-    case llvm::ICmpInst::ICMP_SGT: res = kCondGt; break;
-    case llvm::ICmpInst::ICMP_SLE: res = kCondLe; break;
+    case ::llvm::ICmpInst::ICMP_EQ: res = kCondEq; break;
+    case ::llvm::ICmpInst::ICMP_NE: res = kCondNe; break;
+    case ::llvm::ICmpInst::ICMP_SLT: res = kCondLt; break;
+    case ::llvm::ICmpInst::ICMP_SGE: res = kCondGe; break;
+    case ::llvm::ICmpInst::ICMP_SGT: res = kCondGt; break;
+    case ::llvm::ICmpInst::ICMP_SLE: res = kCondLe; break;
     default: LOG(FATAL) << "Unexpected llvm condition";
   }
   return res;
 }
 
-static void CvtICmp(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtICmp(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   // cg->GenCmpLong(cu, rl_dest, rl_src1, rl_src2)
   UNIMPLEMENTED(FATAL);
 }
 
-static void CvtICmpBr(CompilationUnit* cu, llvm::Instruction* inst,
-               llvm::BranchInst* br_inst)
+static void CvtICmpBr(CompilationUnit* cu, ::llvm::Instruction* inst,
+               ::llvm::BranchInst* br_inst)
 {
   Codegen* cg = cu->cg.get();
   // Get targets
-  llvm::BasicBlock* taken_bb = br_inst->getSuccessor(0);
+  ::llvm::BasicBlock* taken_bb = br_inst->getSuccessor(0);
   LIR* taken = cu->block_to_label_map.Get(taken_bb);
-  llvm::BasicBlock* fallthrough_bb = br_inst->getSuccessor(1);
+  ::llvm::BasicBlock* fallthrough_bb = br_inst->getSuccessor(1);
   LIR* fall_through = cu->block_to_label_map.Get(fallthrough_bb);
   // Get comparison operands
-  llvm::ICmpInst* i_cmp_inst = llvm::dyn_cast<llvm::ICmpInst>(inst);
+  ::llvm::ICmpInst* i_cmp_inst = ::llvm::dyn_cast< ::llvm::ICmpInst>(inst);
   ConditionCode cond = GetCond(i_cmp_inst->getPredicate());
-  llvm::Value* lhs = i_cmp_inst->getOperand(0);
+  ::llvm::Value* lhs = i_cmp_inst->getOperand(0);
   // Not expecting a constant as 1st operand
-  DCHECK(llvm::dyn_cast<llvm::ConstantInt>(lhs) == NULL);
+  DCHECK(::llvm::dyn_cast< ::llvm::ConstantInt>(lhs) == NULL);
   RegLocation rl_src1 = GetLoc(cu, inst->getOperand(0));
   rl_src1 = cg->LoadValue(cu, rl_src1, kCoreReg);
-  llvm::Value* rhs = inst->getOperand(1);
+  ::llvm::Value* rhs = inst->getOperand(1);
   if (cu->instruction_set == kMips) {
     // Compare and branch in one shot
     UNIMPLEMENTED(FATAL);
   }
   //Compare, then branch
   // TODO: handle fused CMP_LONG/IF_xxZ case
-  if (llvm::ConstantInt* src2 = llvm::dyn_cast<llvm::ConstantInt>(rhs)) {
+  if (::llvm::ConstantInt* src2 = ::llvm::dyn_cast< ::llvm::ConstantInt>(rhs)) {
     cg->OpRegImm(cu, kOpCmp, rl_src1.low_reg, src2->getSExtValue());
-  } else if (llvm::dyn_cast<llvm::ConstantPointerNull>(rhs) != NULL) {
+  } else if (::llvm::dyn_cast< ::llvm::ConstantPointerNull>(rhs) != NULL) {
     cg->OpRegImm(cu, kOpCmp, rl_src1.low_reg, 0);
   } else {
     RegLocation rl_src2 = GetLoc(cu, rhs);
@@ -2558,7 +2557,7 @@
   cg->OpUnconditionalBranch(cu, fall_through);
 }
 
-static void CvtCopy(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtCopy(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
@@ -2574,12 +2573,12 @@
 }
 
 // Note: Immediate arg is a ConstantInt regardless of result type
-static void CvtConst(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtConst(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
-  llvm::ConstantInt* src =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* src =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint64_t immval = src->getZExtValue();
   RegLocation rl_dest = GetLoc(cu, call_inst);
   RegLocation rl_result = EvalLoc(cu, rl_dest, kAnyReg, true);
@@ -2596,12 +2595,12 @@
   }
 }
 
-static void CvtConstObject(CompilationUnit* cu, llvm::CallInst* call_inst, bool is_string)
+static void CvtConstObject(CompilationUnit* cu, ::llvm::CallInst* call_inst, bool is_string)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
-  llvm::ConstantInt* idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t index = idx_val->getZExtValue();
   RegLocation rl_dest = GetLoc(cu, call_inst);
   if (is_string) {
@@ -2611,70 +2610,70 @@
   }
 }
 
-static void CvtFillArrayData(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtFillArrayData(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* offset_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* offset_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_src = GetLoc(cu, call_inst->getArgOperand(1));
   cg->GenFillArrayData(cu, offset_val->getSExtValue(), rl_src);
 }
 
-static void CvtNewInstance(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtNewInstance(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
-  llvm::ConstantInt* type_idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t type_idx = type_idx_val->getZExtValue();
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenNewInstance(cu, type_idx, rl_dest);
 }
 
-static void CvtNewArray(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtNewArray(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* type_idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t type_idx = type_idx_val->getZExtValue();
-  llvm::Value* len = call_inst->getArgOperand(1);
+  ::llvm::Value* len = call_inst->getArgOperand(1);
   RegLocation rl_len = GetLoc(cu, len);
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenNewArray(cu, type_idx, rl_dest, rl_len);
 }
 
-static void CvtInstanceOf(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtInstanceOf(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* type_idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t type_idx = type_idx_val->getZExtValue();
-  llvm::Value* src = call_inst->getArgOperand(1);
+  ::llvm::Value* src = call_inst->getArgOperand(1);
   RegLocation rl_src = GetLoc(cu, src);
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenInstanceof(cu, type_idx, rl_dest, rl_src);
 }
 
-static void CvtThrow(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtThrow(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
-  llvm::Value* src = call_inst->getArgOperand(0);
+  ::llvm::Value* src = call_inst->getArgOperand(0);
   RegLocation rl_src = GetLoc(cu, src);
   cg->GenThrow(cu, rl_src);
 }
 
 static void CvtMonitorEnterExit(CompilationUnit* cu, bool is_enter,
-                         llvm::CallInst* call_inst)
+                         ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
-  llvm::Value* src = call_inst->getArgOperand(1);
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::Value* src = call_inst->getArgOperand(1);
   RegLocation rl_src = GetLoc(cu, src);
   if (is_enter) {
     cg->GenMonitorEnter(cu, opt_flags->getZExtValue(), rl_src);
@@ -2683,13 +2682,13 @@
   }
 }
 
-static void CvtArrayLength(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtArrayLength(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
-  llvm::Value* src = call_inst->getArgOperand(1);
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::Value* src = call_inst->getArgOperand(1);
   RegLocation rl_src = GetLoc(cu, src);
   rl_src = cg->LoadValue(cu, rl_src, kCoreReg);
   cg->GenNullCheck(cu, rl_src.s_reg_low, rl_src.low_reg, opt_flags->getZExtValue());
@@ -2700,42 +2699,42 @@
   cg->StoreValue(cu, rl_dest, rl_result);
 }
 
-static void CvtMoveException(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtMoveException(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenMoveException(cu, rl_dest);
 }
 
-static void CvtSget(CompilationUnit* cu, llvm::CallInst* call_inst, bool is_wide, bool is_object)
+static void CvtSget(CompilationUnit* cu, ::llvm::CallInst* call_inst, bool is_wide, bool is_object)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 1U);
-  llvm::ConstantInt* type_idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t type_idx = type_idx_val->getZExtValue();
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenSget(cu, type_idx, rl_dest, is_wide, is_object);
 }
 
-static void CvtSput(CompilationUnit* cu, llvm::CallInst* call_inst, bool is_wide, bool is_object)
+static void CvtSput(CompilationUnit* cu, ::llvm::CallInst* call_inst, bool is_wide, bool is_object)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* type_idx_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   uint32_t type_idx = type_idx_val->getZExtValue();
-  llvm::Value* src = call_inst->getArgOperand(1);
+  ::llvm::Value* src = call_inst->getArgOperand(1);
   RegLocation rl_src = GetLoc(cu, src);
   cg->GenSput(cu, type_idx, rl_src, is_wide, is_object);
 }
 
-static void CvtAget(CompilationUnit* cu, llvm::CallInst* call_inst, OpSize size, int scale)
+static void CvtAget(CompilationUnit* cu, ::llvm::CallInst* call_inst, OpSize size, int scale)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 3U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_array = GetLoc(cu, call_inst->getArgOperand(1));
   RegLocation rl_index = GetLoc(cu, call_inst->getArgOperand(2));
   RegLocation rl_dest = GetLoc(cu, call_inst);
@@ -2743,13 +2742,13 @@
               rl_dest, scale);
 }
 
-static void CvtAput(CompilationUnit* cu, llvm::CallInst* call_inst, OpSize size,
+static void CvtAput(CompilationUnit* cu, ::llvm::CallInst* call_inst, OpSize size,
                     int scale, bool is_object)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 4U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_src = GetLoc(cu, call_inst->getArgOperand(1));
   RegLocation rl_array = GetLoc(cu, call_inst->getArgOperand(2));
   RegLocation rl_index = GetLoc(cu, call_inst->getArgOperand(3));
@@ -2762,58 +2761,58 @@
   }
 }
 
-static void CvtAputObj(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtAputObj(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   CvtAput(cu, call_inst, kWord, 2, true /* is_object */);
 }
 
-static void CvtAputPrimitive(CompilationUnit* cu, llvm::CallInst* call_inst,
+static void CvtAputPrimitive(CompilationUnit* cu, ::llvm::CallInst* call_inst,
                       OpSize size, int scale)
 {
   CvtAput(cu, call_inst, size, scale, false /* is_object */);
 }
 
-static void CvtIget(CompilationUnit* cu, llvm::CallInst* call_inst, OpSize size,
+static void CvtIget(CompilationUnit* cu, ::llvm::CallInst* call_inst, OpSize size,
                     bool is_wide, bool is_obj)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 3U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_obj = GetLoc(cu, call_inst->getArgOperand(1));
-  llvm::ConstantInt* field_idx =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(2));
+  ::llvm::ConstantInt* field_idx =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(2));
   RegLocation rl_dest = GetLoc(cu, call_inst);
   cg->GenIGet(cu, field_idx->getZExtValue(), opt_flags->getZExtValue(),
           size, rl_dest, rl_obj, is_wide, is_obj);
 }
 
-static void CvtIput(CompilationUnit* cu, llvm::CallInst* call_inst, OpSize size,
+static void CvtIput(CompilationUnit* cu, ::llvm::CallInst* call_inst, OpSize size,
                     bool is_wide, bool is_obj)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 4U);
-  llvm::ConstantInt* opt_flags =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* opt_flags =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_src = GetLoc(cu, call_inst->getArgOperand(1));
   RegLocation rl_obj = GetLoc(cu, call_inst->getArgOperand(2));
-  llvm::ConstantInt* field_idx =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(3));
+  ::llvm::ConstantInt* field_idx =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(3));
   cg->GenIPut(cu, field_idx->getZExtValue(), opt_flags->getZExtValue(),
           size, rl_src, rl_obj, is_wide, is_obj);
 }
 
-static void CvtCheckCast(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtCheckCast(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   DCHECK_EQ(call_inst->getNumArgOperands(), 2U);
-  llvm::ConstantInt* type_idx =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* type_idx =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
   RegLocation rl_src = GetLoc(cu, call_inst->getArgOperand(1));
   cg->GenCheckCast(cu, type_idx->getZExtValue(), rl_src);
 }
 
-static void CvtFPCompare(CompilationUnit* cu, llvm::CallInst* call_inst,
+static void CvtFPCompare(CompilationUnit* cu, ::llvm::CallInst* call_inst,
                          Instruction::Code opcode)
 {
   Codegen* cg = cu->cg.get();
@@ -2823,7 +2822,7 @@
   cg->GenCmpFP(cu, opcode, rl_dest, rl_src1, rl_src2);
 }
 
-static void CvtLongCompare(CompilationUnit* cu, llvm::CallInst* call_inst)
+static void CvtLongCompare(CompilationUnit* cu, ::llvm::CallInst* call_inst)
 {
   Codegen* cg = cu->cg.get();
   RegLocation rl_src1 = GetLoc(cu, call_inst->getArgOperand(0));
@@ -2832,16 +2831,16 @@
   cg->GenCmpLong(cu, rl_dest, rl_src1, rl_src2);
 }
 
-static void CvtSwitch(CompilationUnit* cu, llvm::Instruction* inst)
+static void CvtSwitch(CompilationUnit* cu, ::llvm::Instruction* inst)
 {
   Codegen* cg = cu->cg.get();
-  llvm::SwitchInst* sw_inst = llvm::dyn_cast<llvm::SwitchInst>(inst);
+  ::llvm::SwitchInst* sw_inst = ::llvm::dyn_cast< ::llvm::SwitchInst>(inst);
   DCHECK(sw_inst != NULL);
-  llvm::Value* test_val = sw_inst->getCondition();
-  llvm::MDNode* table_offset_node = sw_inst->getMetadata("SwitchTable");
+  ::llvm::Value* test_val = sw_inst->getCondition();
+  ::llvm::MDNode* table_offset_node = sw_inst->getMetadata("SwitchTable");
   DCHECK(table_offset_node != NULL);
-  llvm::ConstantInt* table_offset_value =
-          static_cast<llvm::ConstantInt*>(table_offset_node->getOperand(0));
+  ::llvm::ConstantInt* table_offset_value =
+          static_cast< ::llvm::ConstantInt*>(table_offset_node->getOperand(0));
   int32_t table_offset = table_offset_value->getSExtValue();
   RegLocation rl_src = GetLoc(cu, test_val);
   const uint16_t* table = cu->insns + cu->current_dalvik_offset + table_offset;
@@ -2854,7 +2853,7 @@
   }
 }
 
-static void CvtInvoke(CompilationUnit* cu, llvm::CallInst* call_inst, bool is_void,
+static void CvtInvoke(CompilationUnit* cu, ::llvm::CallInst* call_inst, bool is_void,
                       bool is_filled_new_array)
 {
   Codegen* cg = cu->cg.get();
@@ -2864,12 +2863,12 @@
   } else {
     info->result = GetLoc(cu, call_inst);
   }
-  llvm::ConstantInt* invoke_type_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(0));
-  llvm::ConstantInt* method_index_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(1));
-  llvm::ConstantInt* opt_flags_val =
-      llvm::dyn_cast<llvm::ConstantInt>(call_inst->getArgOperand(2));
+  ::llvm::ConstantInt* invoke_type_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(0));
+  ::llvm::ConstantInt* method_index_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(1));
+  ::llvm::ConstantInt* opt_flags_val =
+      ::llvm::dyn_cast< ::llvm::ConstantInt>(call_inst->getArgOperand(2));
   info->type = static_cast<InvokeType>(invoke_type_val->getZExtValue());
   info->index = method_index_val->getZExtValue();
   info->opt_flags = opt_flags_val->getZExtValue();
@@ -2910,18 +2909,18 @@
 }
 
 /* Look up the RegLocation associated with a Value.  Must already be defined */
-static RegLocation ValToLoc(CompilationUnit* cu, llvm::Value* val)
+static RegLocation ValToLoc(CompilationUnit* cu, ::llvm::Value* val)
 {
-  SafeMap<llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
+  SafeMap< ::llvm::Value*, RegLocation>::iterator it = cu->loc_map.find(val);
   DCHECK(it != cu->loc_map.end()) << "Missing definition";
   return it->second;
 }
 
-static bool BitcodeBlockCodeGen(CompilationUnit* cu, llvm::BasicBlock* bb)
+static bool BitcodeBlockCodeGen(CompilationUnit* cu, ::llvm::BasicBlock* bb)
 {
   Codegen* cg = cu->cg.get();
   while (cu->llvm_blocks.find(bb) == cu->llvm_blocks.end()) {
-    llvm::BasicBlock* next_bb = NULL;
+    ::llvm::BasicBlock* next_bb = NULL;
     cu->llvm_blocks.insert(bb);
     bool is_entry = (bb == &cu->func->getEntryBlock());
     // Define the starting label
@@ -2963,14 +2962,14 @@
     if (is_entry) {
       RegLocation* ArgLocs = static_cast<RegLocation*>
           (NewMem(cu, sizeof(RegLocation) * cu->num_ins, true, kAllocMisc));
-      llvm::Function::arg_iterator it(cu->func->arg_begin());
-      llvm::Function::arg_iterator it_end(cu->func->arg_end());
+      ::llvm::Function::arg_iterator it(cu->func->arg_begin());
+      ::llvm::Function::arg_iterator it_end(cu->func->arg_end());
       // Skip past Method*
       it++;
       for (unsigned i = 0; it != it_end; ++it) {
-        llvm::Value* val = it;
+        ::llvm::Value* val = it;
         ArgLocs[i++] = ValToLoc(cu, val);
-        llvm::Type* ty = val->getType();
+        ::llvm::Type* ty = val->getType();
         if ((ty == cu->irb->getInt64Ty()) || (ty == cu->irb->getDoubleTy())) {
           ArgLocs[i] = ArgLocs[i-1];
           ArgLocs[i].low_reg = ArgLocs[i].high_reg;
@@ -2984,15 +2983,15 @@
     }
 
     // Visit all of the instructions in the block
-    for (llvm::BasicBlock::iterator it = bb->begin(), e = bb->end(); it != e;) {
-      llvm::Instruction* inst = it;
-      llvm::BasicBlock::iterator next_it = ++it;
+    for (::llvm::BasicBlock::iterator it = bb->begin(), e = bb->end(); it != e;) {
+      ::llvm::Instruction* inst = it;
+      ::llvm::BasicBlock::iterator next_it = ++it;
       // Extract the Dalvik offset from the instruction
       uint32_t opcode = inst->getOpcode();
-      llvm::MDNode* dex_offset_node = inst->getMetadata("DexOff");
+      ::llvm::MDNode* dex_offset_node = inst->getMetadata("DexOff");
       if (dex_offset_node != NULL) {
-        llvm::ConstantInt* dex_offset_value =
-            static_cast<llvm::ConstantInt*>(dex_offset_node->getOperand(0));
+        ::llvm::ConstantInt* dex_offset_value =
+            static_cast< ::llvm::ConstantInt*>(dex_offset_node->getOperand(0));
         cu->current_dalvik_offset = dex_offset_value->getZExtValue();
       }
 
@@ -3021,9 +3020,9 @@
 
       switch(opcode) {
 
-        case llvm::Instruction::ICmp: {
-            llvm::Instruction* next_inst = next_it;
-            llvm::BranchInst* br_inst = llvm::dyn_cast<llvm::BranchInst>(next_inst);
+        case ::llvm::Instruction::ICmp: {
+            ::llvm::Instruction* next_inst = next_it;
+            ::llvm::BranchInst* br_inst = ::llvm::dyn_cast< ::llvm::BranchInst>(next_inst);
             if (br_inst != NULL /* and... */) {
               CvtICmpBr(cu, inst, br_inst);
               ++it;
@@ -3033,283 +3032,283 @@
           }
           break;
 
-        case llvm::Instruction::Call: {
-            llvm::CallInst* call_inst = llvm::dyn_cast<llvm::CallInst>(inst);
-            llvm::Function* callee = call_inst->getCalledFunction();
-            compiler_llvm::IntrinsicHelper::IntrinsicId id =
+        case ::llvm::Instruction::Call: {
+            ::llvm::CallInst* call_inst = ::llvm::dyn_cast< ::llvm::CallInst>(inst);
+            ::llvm::Function* callee = call_inst->getCalledFunction();
+            art::llvm::IntrinsicHelper::IntrinsicId id =
                 cu->intrinsic_helper->GetIntrinsicId(callee);
             switch (id) {
-              case compiler_llvm::IntrinsicHelper::AllocaShadowFrame:
-              case compiler_llvm::IntrinsicHelper::PopShadowFrame:
-              case compiler_llvm::IntrinsicHelper::SetVReg:
+              case art::llvm::IntrinsicHelper::AllocaShadowFrame:
+              case art::llvm::IntrinsicHelper::PopShadowFrame:
+              case art::llvm::IntrinsicHelper::SetVReg:
                 // Ignore shadow frame stuff for quick compiler
                 break;
-              case compiler_llvm::IntrinsicHelper::CopyInt:
-              case compiler_llvm::IntrinsicHelper::CopyObj:
-              case compiler_llvm::IntrinsicHelper::CopyFloat:
-              case compiler_llvm::IntrinsicHelper::CopyLong:
-              case compiler_llvm::IntrinsicHelper::CopyDouble:
+              case art::llvm::IntrinsicHelper::CopyInt:
+              case art::llvm::IntrinsicHelper::CopyObj:
+              case art::llvm::IntrinsicHelper::CopyFloat:
+              case art::llvm::IntrinsicHelper::CopyLong:
+              case art::llvm::IntrinsicHelper::CopyDouble:
                 CvtCopy(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::ConstInt:
-              case compiler_llvm::IntrinsicHelper::ConstObj:
-              case compiler_llvm::IntrinsicHelper::ConstLong:
-              case compiler_llvm::IntrinsicHelper::ConstFloat:
-              case compiler_llvm::IntrinsicHelper::ConstDouble:
+              case art::llvm::IntrinsicHelper::ConstInt:
+              case art::llvm::IntrinsicHelper::ConstObj:
+              case art::llvm::IntrinsicHelper::ConstLong:
+              case art::llvm::IntrinsicHelper::ConstFloat:
+              case art::llvm::IntrinsicHelper::ConstDouble:
                 CvtConst(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::DivInt:
-              case compiler_llvm::IntrinsicHelper::DivLong:
+              case art::llvm::IntrinsicHelper::DivInt:
+              case art::llvm::IntrinsicHelper::DivLong:
                 CvtBinOp(cu, kOpDiv, inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::RemInt:
-              case compiler_llvm::IntrinsicHelper::RemLong:
+              case art::llvm::IntrinsicHelper::RemInt:
+              case art::llvm::IntrinsicHelper::RemLong:
                 CvtBinOp(cu, kOpRem, inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::MethodInfo:
+              case art::llvm::IntrinsicHelper::MethodInfo:
                 // Already dealt with - just ignore it here.
                 break;
-              case compiler_llvm::IntrinsicHelper::CheckSuspend:
+              case art::llvm::IntrinsicHelper::CheckSuspend:
                 cg->GenSuspendTest(cu, 0 /* opt_flags already applied */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLInvokeObj:
-              case compiler_llvm::IntrinsicHelper::HLInvokeFloat:
-              case compiler_llvm::IntrinsicHelper::HLInvokeDouble:
-              case compiler_llvm::IntrinsicHelper::HLInvokeLong:
-              case compiler_llvm::IntrinsicHelper::HLInvokeInt:
+              case art::llvm::IntrinsicHelper::HLInvokeObj:
+              case art::llvm::IntrinsicHelper::HLInvokeFloat:
+              case art::llvm::IntrinsicHelper::HLInvokeDouble:
+              case art::llvm::IntrinsicHelper::HLInvokeLong:
+              case art::llvm::IntrinsicHelper::HLInvokeInt:
                 CvtInvoke(cu, call_inst, false /* is_void */, false /* new_array */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLInvokeVoid:
+              case art::llvm::IntrinsicHelper::HLInvokeVoid:
                 CvtInvoke(cu, call_inst, true /* is_void */, false /* new_array */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLFilledNewArray:
+              case art::llvm::IntrinsicHelper::HLFilledNewArray:
                 CvtInvoke(cu, call_inst, false /* is_void */, true /* new_array */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLFillArrayData:
+              case art::llvm::IntrinsicHelper::HLFillArrayData:
                 CvtFillArrayData(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::ConstString:
+              case art::llvm::IntrinsicHelper::ConstString:
                 CvtConstObject(cu, call_inst, true /* is_string */);
                 break;
-              case compiler_llvm::IntrinsicHelper::ConstClass:
+              case art::llvm::IntrinsicHelper::ConstClass:
                 CvtConstObject(cu, call_inst, false /* is_string */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLCheckCast:
+              case art::llvm::IntrinsicHelper::HLCheckCast:
                 CvtCheckCast(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::NewInstance:
+              case art::llvm::IntrinsicHelper::NewInstance:
                 CvtNewInstance(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSgetObject:
+              case art::llvm::IntrinsicHelper::HLSgetObject:
                 CvtSget(cu, call_inst, false /* wide */, true /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSget:
-              case compiler_llvm::IntrinsicHelper::HLSgetFloat:
-              case compiler_llvm::IntrinsicHelper::HLSgetBoolean:
-              case compiler_llvm::IntrinsicHelper::HLSgetByte:
-              case compiler_llvm::IntrinsicHelper::HLSgetChar:
-              case compiler_llvm::IntrinsicHelper::HLSgetShort:
+              case art::llvm::IntrinsicHelper::HLSget:
+              case art::llvm::IntrinsicHelper::HLSgetFloat:
+              case art::llvm::IntrinsicHelper::HLSgetBoolean:
+              case art::llvm::IntrinsicHelper::HLSgetByte:
+              case art::llvm::IntrinsicHelper::HLSgetChar:
+              case art::llvm::IntrinsicHelper::HLSgetShort:
                 CvtSget(cu, call_inst, false /* wide */, false /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSgetWide:
-              case compiler_llvm::IntrinsicHelper::HLSgetDouble:
+              case art::llvm::IntrinsicHelper::HLSgetWide:
+              case art::llvm::IntrinsicHelper::HLSgetDouble:
                 CvtSget(cu, call_inst, true /* wide */, false /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSput:
-              case compiler_llvm::IntrinsicHelper::HLSputFloat:
-              case compiler_llvm::IntrinsicHelper::HLSputBoolean:
-              case compiler_llvm::IntrinsicHelper::HLSputByte:
-              case compiler_llvm::IntrinsicHelper::HLSputChar:
-              case compiler_llvm::IntrinsicHelper::HLSputShort:
+              case art::llvm::IntrinsicHelper::HLSput:
+              case art::llvm::IntrinsicHelper::HLSputFloat:
+              case art::llvm::IntrinsicHelper::HLSputBoolean:
+              case art::llvm::IntrinsicHelper::HLSputByte:
+              case art::llvm::IntrinsicHelper::HLSputChar:
+              case art::llvm::IntrinsicHelper::HLSputShort:
                 CvtSput(cu, call_inst, false /* wide */, false /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSputWide:
-              case compiler_llvm::IntrinsicHelper::HLSputDouble:
+              case art::llvm::IntrinsicHelper::HLSputWide:
+              case art::llvm::IntrinsicHelper::HLSputDouble:
                 CvtSput(cu, call_inst, true /* wide */, false /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLSputObject:
+              case art::llvm::IntrinsicHelper::HLSputObject:
                 CvtSput(cu, call_inst, false /* wide */, true /* Object */);
                 break;
-              case compiler_llvm::IntrinsicHelper::GetException:
+              case art::llvm::IntrinsicHelper::GetException:
                 CvtMoveException(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLThrowException:
+              case art::llvm::IntrinsicHelper::HLThrowException:
                 CvtThrow(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::MonitorEnter:
+              case art::llvm::IntrinsicHelper::MonitorEnter:
                 CvtMonitorEnterExit(cu, true /* is_enter */, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::MonitorExit:
+              case art::llvm::IntrinsicHelper::MonitorExit:
                 CvtMonitorEnterExit(cu, false /* is_enter */, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::OptArrayLength:
+              case art::llvm::IntrinsicHelper::OptArrayLength:
                 CvtArrayLength(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::NewArray:
+              case art::llvm::IntrinsicHelper::NewArray:
                 CvtNewArray(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::InstanceOf:
+              case art::llvm::IntrinsicHelper::InstanceOf:
                 CvtInstanceOf(cu, call_inst);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::HLArrayGet:
-              case compiler_llvm::IntrinsicHelper::HLArrayGetObject:
-              case compiler_llvm::IntrinsicHelper::HLArrayGetFloat:
+              case art::llvm::IntrinsicHelper::HLArrayGet:
+              case art::llvm::IntrinsicHelper::HLArrayGetObject:
+              case art::llvm::IntrinsicHelper::HLArrayGetFloat:
                 CvtAget(cu, call_inst, kWord, 2);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayGetWide:
-              case compiler_llvm::IntrinsicHelper::HLArrayGetDouble:
+              case art::llvm::IntrinsicHelper::HLArrayGetWide:
+              case art::llvm::IntrinsicHelper::HLArrayGetDouble:
                 CvtAget(cu, call_inst, kLong, 3);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayGetBoolean:
+              case art::llvm::IntrinsicHelper::HLArrayGetBoolean:
                 CvtAget(cu, call_inst, kUnsignedByte, 0);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayGetByte:
+              case art::llvm::IntrinsicHelper::HLArrayGetByte:
                 CvtAget(cu, call_inst, kSignedByte, 0);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayGetChar:
+              case art::llvm::IntrinsicHelper::HLArrayGetChar:
                 CvtAget(cu, call_inst, kUnsignedHalf, 1);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayGetShort:
+              case art::llvm::IntrinsicHelper::HLArrayGetShort:
                 CvtAget(cu, call_inst, kSignedHalf, 1);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::HLArrayPut:
-              case compiler_llvm::IntrinsicHelper::HLArrayPutFloat:
+              case art::llvm::IntrinsicHelper::HLArrayPut:
+              case art::llvm::IntrinsicHelper::HLArrayPutFloat:
                 CvtAputPrimitive(cu, call_inst, kWord, 2);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutObject:
+              case art::llvm::IntrinsicHelper::HLArrayPutObject:
                 CvtAputObj(cu, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutWide:
-              case compiler_llvm::IntrinsicHelper::HLArrayPutDouble:
+              case art::llvm::IntrinsicHelper::HLArrayPutWide:
+              case art::llvm::IntrinsicHelper::HLArrayPutDouble:
                 CvtAputPrimitive(cu, call_inst, kLong, 3);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutBoolean:
+              case art::llvm::IntrinsicHelper::HLArrayPutBoolean:
                 CvtAputPrimitive(cu, call_inst, kUnsignedByte, 0);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutByte:
+              case art::llvm::IntrinsicHelper::HLArrayPutByte:
                 CvtAputPrimitive(cu, call_inst, kSignedByte, 0);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutChar:
+              case art::llvm::IntrinsicHelper::HLArrayPutChar:
                 CvtAputPrimitive(cu, call_inst, kUnsignedHalf, 1);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLArrayPutShort:
+              case art::llvm::IntrinsicHelper::HLArrayPutShort:
                 CvtAputPrimitive(cu, call_inst, kSignedHalf, 1);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::HLIGet:
-              case compiler_llvm::IntrinsicHelper::HLIGetFloat:
+              case art::llvm::IntrinsicHelper::HLIGet:
+              case art::llvm::IntrinsicHelper::HLIGetFloat:
                 CvtIget(cu, call_inst, kWord, false /* is_wide */, false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetObject:
+              case art::llvm::IntrinsicHelper::HLIGetObject:
                 CvtIget(cu, call_inst, kWord, false /* is_wide */, true /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetWide:
-              case compiler_llvm::IntrinsicHelper::HLIGetDouble:
+              case art::llvm::IntrinsicHelper::HLIGetWide:
+              case art::llvm::IntrinsicHelper::HLIGetDouble:
                 CvtIget(cu, call_inst, kLong, true /* is_wide */, false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetBoolean:
+              case art::llvm::IntrinsicHelper::HLIGetBoolean:
                 CvtIget(cu, call_inst, kUnsignedByte, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetByte:
+              case art::llvm::IntrinsicHelper::HLIGetByte:
                 CvtIget(cu, call_inst, kSignedByte, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetChar:
+              case art::llvm::IntrinsicHelper::HLIGetChar:
                 CvtIget(cu, call_inst, kUnsignedHalf, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIGetShort:
+              case art::llvm::IntrinsicHelper::HLIGetShort:
                 CvtIget(cu, call_inst, kSignedHalf, false /* is_wide */,
                         false /* obj */);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::HLIPut:
-              case compiler_llvm::IntrinsicHelper::HLIPutFloat:
+              case art::llvm::IntrinsicHelper::HLIPut:
+              case art::llvm::IntrinsicHelper::HLIPutFloat:
                 CvtIput(cu, call_inst, kWord, false /* is_wide */, false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutObject:
+              case art::llvm::IntrinsicHelper::HLIPutObject:
                 CvtIput(cu, call_inst, kWord, false /* is_wide */, true /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutWide:
-              case compiler_llvm::IntrinsicHelper::HLIPutDouble:
+              case art::llvm::IntrinsicHelper::HLIPutWide:
+              case art::llvm::IntrinsicHelper::HLIPutDouble:
                 CvtIput(cu, call_inst, kLong, true /* is_wide */, false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutBoolean:
+              case art::llvm::IntrinsicHelper::HLIPutBoolean:
                 CvtIput(cu, call_inst, kUnsignedByte, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutByte:
+              case art::llvm::IntrinsicHelper::HLIPutByte:
                 CvtIput(cu, call_inst, kSignedByte, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutChar:
+              case art::llvm::IntrinsicHelper::HLIPutChar:
                 CvtIput(cu, call_inst, kUnsignedHalf, false /* is_wide */,
                         false /* obj */);
                 break;
-              case compiler_llvm::IntrinsicHelper::HLIPutShort:
+              case art::llvm::IntrinsicHelper::HLIPutShort:
                 CvtIput(cu, call_inst, kSignedHalf, false /* is_wide */,
                         false /* obj */);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::IntToChar:
+              case art::llvm::IntrinsicHelper::IntToChar:
                 CvtIntNarrowing(cu, call_inst, Instruction::INT_TO_CHAR);
                 break;
-              case compiler_llvm::IntrinsicHelper::IntToShort:
+              case art::llvm::IntrinsicHelper::IntToShort:
                 CvtIntNarrowing(cu, call_inst, Instruction::INT_TO_SHORT);
                 break;
-              case compiler_llvm::IntrinsicHelper::IntToByte:
+              case art::llvm::IntrinsicHelper::IntToByte:
                 CvtIntNarrowing(cu, call_inst, Instruction::INT_TO_BYTE);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::F2I:
-              case compiler_llvm::IntrinsicHelper::D2I:
-              case compiler_llvm::IntrinsicHelper::F2L:
-              case compiler_llvm::IntrinsicHelper::D2L:
+              case art::llvm::IntrinsicHelper::F2I:
+              case art::llvm::IntrinsicHelper::D2I:
+              case art::llvm::IntrinsicHelper::F2L:
+              case art::llvm::IntrinsicHelper::D2L:
                 CvtFPToInt(cu, call_inst);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::CmplFloat:
+              case art::llvm::IntrinsicHelper::CmplFloat:
                 CvtFPCompare(cu, call_inst, Instruction::CMPL_FLOAT);
                 break;
-              case compiler_llvm::IntrinsicHelper::CmpgFloat:
+              case art::llvm::IntrinsicHelper::CmpgFloat:
                 CvtFPCompare(cu, call_inst, Instruction::CMPG_FLOAT);
                 break;
-              case compiler_llvm::IntrinsicHelper::CmplDouble:
+              case art::llvm::IntrinsicHelper::CmplDouble:
                 CvtFPCompare(cu, call_inst, Instruction::CMPL_DOUBLE);
                 break;
-              case compiler_llvm::IntrinsicHelper::CmpgDouble:
+              case art::llvm::IntrinsicHelper::CmpgDouble:
                 CvtFPCompare(cu, call_inst, Instruction::CMPG_DOUBLE);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::CmpLong:
+              case art::llvm::IntrinsicHelper::CmpLong:
                 CvtLongCompare(cu, call_inst);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::SHLLong:
+              case art::llvm::IntrinsicHelper::SHLLong:
                 CvtShiftOp(cu, Instruction::SHL_LONG, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::SHRLong:
+              case art::llvm::IntrinsicHelper::SHRLong:
                 CvtShiftOp(cu, Instruction::SHR_LONG, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::USHRLong:
+              case art::llvm::IntrinsicHelper::USHRLong:
                 CvtShiftOp(cu, Instruction::USHR_LONG, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::SHLInt:
+              case art::llvm::IntrinsicHelper::SHLInt:
                 CvtShiftOp(cu, Instruction::SHL_INT, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::SHRInt:
+              case art::llvm::IntrinsicHelper::SHRInt:
                 CvtShiftOp(cu, Instruction::SHR_INT, call_inst);
                 break;
-              case compiler_llvm::IntrinsicHelper::USHRInt:
+              case art::llvm::IntrinsicHelper::USHRInt:
                 CvtShiftOp(cu, Instruction::USHR_INT, call_inst);
                 break;
 
-              case compiler_llvm::IntrinsicHelper::CatchTargets: {
-                  llvm::SwitchInst* sw_inst =
-                      llvm::dyn_cast<llvm::SwitchInst>(next_it);
+              case art::llvm::IntrinsicHelper::CatchTargets: {
+                  ::llvm::SwitchInst* sw_inst =
+                      ::llvm::dyn_cast< ::llvm::SwitchInst>(next_it);
                   DCHECK(sw_inst != NULL);
                   /*
                    * Discard the edges and the following conditional branch.
@@ -3317,7 +3316,7 @@
                    * "work" portion of the pair.
                    * TODO: awful code layout - rework
                    */
-                   llvm::BasicBlock* target_bb = sw_inst->getDefaultDest();
+                   ::llvm::BasicBlock* target_bb = sw_inst->getDefaultDest();
                    DCHECK(target_bb != NULL);
                    cg->OpUnconditionalBranch(cu, cu->block_to_label_map.Get(target_bb));
                    ++it;
@@ -3325,7 +3324,7 @@
                    next_bb = target_bb;
                 }
                 break;
-              case compiler_llvm::IntrinsicHelper::ConstructorBarrier: {
+              case art::llvm::IntrinsicHelper::ConstructorBarrier: {
                 CvtConstructorBarrier(cu);
                 break;
               }
@@ -3336,69 +3335,69 @@
           }
           break;
 
-        case llvm::Instruction::Br: CvtBr(cu, inst); break;
-        case llvm::Instruction::Add: CvtBinOp(cu, kOpAdd, inst); break;
-        case llvm::Instruction::Sub: CvtBinOp(cu, kOpSub, inst); break;
-        case llvm::Instruction::Mul: CvtBinOp(cu, kOpMul, inst); break;
-        case llvm::Instruction::SDiv: CvtBinOp(cu, kOpDiv, inst); break;
-        case llvm::Instruction::SRem: CvtBinOp(cu, kOpRem, inst); break;
-        case llvm::Instruction::And: CvtBinOp(cu, kOpAnd, inst); break;
-        case llvm::Instruction::Or: CvtBinOp(cu, kOpOr, inst); break;
-        case llvm::Instruction::Xor: CvtBinOp(cu, kOpXor, inst); break;
-        case llvm::Instruction::PHI: CvtPhi(cu, inst); break;
-        case llvm::Instruction::Ret: CvtRet(cu, inst); break;
-        case llvm::Instruction::FAdd: CvtBinFPOp(cu, kOpAdd, inst); break;
-        case llvm::Instruction::FSub: CvtBinFPOp(cu, kOpSub, inst); break;
-        case llvm::Instruction::FMul: CvtBinFPOp(cu, kOpMul, inst); break;
-        case llvm::Instruction::FDiv: CvtBinFPOp(cu, kOpDiv, inst); break;
-        case llvm::Instruction::FRem: CvtBinFPOp(cu, kOpRem, inst); break;
-        case llvm::Instruction::SIToFP: CvtIntToFP(cu, inst); break;
-        case llvm::Instruction::FPTrunc: CvtDoubleToFloat(cu, inst); break;
-        case llvm::Instruction::FPExt: CvtFloatToDouble(cu, inst); break;
-        case llvm::Instruction::Trunc: CvtTrunc(cu, inst); break;
+        case ::llvm::Instruction::Br: CvtBr(cu, inst); break;
+        case ::llvm::Instruction::Add: CvtBinOp(cu, kOpAdd, inst); break;
+        case ::llvm::Instruction::Sub: CvtBinOp(cu, kOpSub, inst); break;
+        case ::llvm::Instruction::Mul: CvtBinOp(cu, kOpMul, inst); break;
+        case ::llvm::Instruction::SDiv: CvtBinOp(cu, kOpDiv, inst); break;
+        case ::llvm::Instruction::SRem: CvtBinOp(cu, kOpRem, inst); break;
+        case ::llvm::Instruction::And: CvtBinOp(cu, kOpAnd, inst); break;
+        case ::llvm::Instruction::Or: CvtBinOp(cu, kOpOr, inst); break;
+        case ::llvm::Instruction::Xor: CvtBinOp(cu, kOpXor, inst); break;
+        case ::llvm::Instruction::PHI: CvtPhi(cu, inst); break;
+        case ::llvm::Instruction::Ret: CvtRet(cu, inst); break;
+        case ::llvm::Instruction::FAdd: CvtBinFPOp(cu, kOpAdd, inst); break;
+        case ::llvm::Instruction::FSub: CvtBinFPOp(cu, kOpSub, inst); break;
+        case ::llvm::Instruction::FMul: CvtBinFPOp(cu, kOpMul, inst); break;
+        case ::llvm::Instruction::FDiv: CvtBinFPOp(cu, kOpDiv, inst); break;
+        case ::llvm::Instruction::FRem: CvtBinFPOp(cu, kOpRem, inst); break;
+        case ::llvm::Instruction::SIToFP: CvtIntToFP(cu, inst); break;
+        case ::llvm::Instruction::FPTrunc: CvtDoubleToFloat(cu, inst); break;
+        case ::llvm::Instruction::FPExt: CvtFloatToDouble(cu, inst); break;
+        case ::llvm::Instruction::Trunc: CvtTrunc(cu, inst); break;
 
-        case llvm::Instruction::ZExt: CvtIntExt(cu, inst, false /* signed */);
+        case ::llvm::Instruction::ZExt: CvtIntExt(cu, inst, false /* signed */);
           break;
-        case llvm::Instruction::SExt: CvtIntExt(cu, inst, true /* signed */);
+        case ::llvm::Instruction::SExt: CvtIntExt(cu, inst, true /* signed */);
           break;
 
-        case llvm::Instruction::Switch: CvtSwitch(cu, inst); break;
+        case ::llvm::Instruction::Switch: CvtSwitch(cu, inst); break;
 
-        case llvm::Instruction::Unreachable:
+        case ::llvm::Instruction::Unreachable:
           break;  // FIXME: can we really ignore these?
 
-        case llvm::Instruction::Shl:
-        case llvm::Instruction::LShr:
-        case llvm::Instruction::AShr:
-        case llvm::Instruction::Invoke:
-        case llvm::Instruction::FPToUI:
-        case llvm::Instruction::FPToSI:
-        case llvm::Instruction::UIToFP:
-        case llvm::Instruction::PtrToInt:
-        case llvm::Instruction::IntToPtr:
-        case llvm::Instruction::FCmp:
-        case llvm::Instruction::URem:
-        case llvm::Instruction::UDiv:
-        case llvm::Instruction::Resume:
-        case llvm::Instruction::Alloca:
-        case llvm::Instruction::GetElementPtr:
-        case llvm::Instruction::Fence:
-        case llvm::Instruction::AtomicCmpXchg:
-        case llvm::Instruction::AtomicRMW:
-        case llvm::Instruction::BitCast:
-        case llvm::Instruction::VAArg:
-        case llvm::Instruction::Select:
-        case llvm::Instruction::UserOp1:
-        case llvm::Instruction::UserOp2:
-        case llvm::Instruction::ExtractElement:
-        case llvm::Instruction::InsertElement:
-        case llvm::Instruction::ShuffleVector:
-        case llvm::Instruction::ExtractValue:
-        case llvm::Instruction::InsertValue:
-        case llvm::Instruction::LandingPad:
-        case llvm::Instruction::IndirectBr:
-        case llvm::Instruction::Load:
-        case llvm::Instruction::Store:
+        case ::llvm::Instruction::Shl:
+        case ::llvm::Instruction::LShr:
+        case ::llvm::Instruction::AShr:
+        case ::llvm::Instruction::Invoke:
+        case ::llvm::Instruction::FPToUI:
+        case ::llvm::Instruction::FPToSI:
+        case ::llvm::Instruction::UIToFP:
+        case ::llvm::Instruction::PtrToInt:
+        case ::llvm::Instruction::IntToPtr:
+        case ::llvm::Instruction::FCmp:
+        case ::llvm::Instruction::URem:
+        case ::llvm::Instruction::UDiv:
+        case ::llvm::Instruction::Resume:
+        case ::llvm::Instruction::Alloca:
+        case ::llvm::Instruction::GetElementPtr:
+        case ::llvm::Instruction::Fence:
+        case ::llvm::Instruction::AtomicCmpXchg:
+        case ::llvm::Instruction::AtomicRMW:
+        case ::llvm::Instruction::BitCast:
+        case ::llvm::Instruction::VAArg:
+        case ::llvm::Instruction::Select:
+        case ::llvm::Instruction::UserOp1:
+        case ::llvm::Instruction::UserOp2:
+        case ::llvm::Instruction::ExtractElement:
+        case ::llvm::Instruction::InsertElement:
+        case ::llvm::Instruction::ShuffleVector:
+        case ::llvm::Instruction::ExtractValue:
+        case ::llvm::Instruction::InsertValue:
+        case ::llvm::Instruction::LandingPad:
+        case ::llvm::Instruction::IndirectBr:
+        case ::llvm::Instruction::Load:
+        case ::llvm::Instruction::Store:
           LOG(FATAL) << "Unexpected llvm opcode: " << opcode; break;
 
         default:
@@ -3435,15 +3434,15 @@
 void MethodBitcode2LIR(CompilationUnit* cu)
 {
   Codegen* cg = cu->cg.get();
-  llvm::Function* func = cu->func;
+  ::llvm::Function* func = cu->func;
   int num_basic_blocks = func->getBasicBlockList().size();
   // Allocate a list for LIR basic block labels
   cu->block_label_list =
     static_cast<LIR*>(NewMem(cu, sizeof(LIR) * num_basic_blocks, true, kAllocLIR));
   LIR* label_list = cu->block_label_list;
   int next_label = 0;
-  for (llvm::Function::iterator i = func->begin(), e = func->end(); i != e; ++i) {
-    cu->block_to_label_map.Put(static_cast<llvm::BasicBlock*>(i),
+  for (::llvm::Function::iterator i = func->begin(), e = func->end(); i != e; ++i) {
+    cu->block_to_label_map.Put(static_cast< ::llvm::BasicBlock*>(i),
                                &label_list[next_label++]);
   }
 
@@ -3471,28 +3470,28 @@
    * be the first instruction we encounter, so we won't have to iterate
    * through everything.
    */
-  for (llvm::inst_iterator i = llvm::inst_begin(func), e = llvm::inst_end(func); i != e; ++i) {
-    llvm::CallInst* call_inst = llvm::dyn_cast<llvm::CallInst>(&*i);
+  for (::llvm::inst_iterator i = ::llvm::inst_begin(func), e = ::llvm::inst_end(func); i != e; ++i) {
+    ::llvm::CallInst* call_inst = ::llvm::dyn_cast< ::llvm::CallInst>(&*i);
     if (call_inst != NULL) {
-      llvm::Function* callee = call_inst->getCalledFunction();
-      compiler_llvm::IntrinsicHelper::IntrinsicId id =
+      ::llvm::Function* callee = call_inst->getCalledFunction();
+      llvm::IntrinsicHelper::IntrinsicId id =
           cu->intrinsic_helper->GetIntrinsicId(callee);
-      if (id == compiler_llvm::IntrinsicHelper::MethodInfo) {
+      if (id == art::llvm::IntrinsicHelper::MethodInfo) {
         if (cu->verbose) {
           LOG(INFO) << "Found MethodInfo";
         }
-        llvm::MDNode* reg_info_node = call_inst->getMetadata("RegInfo");
+        ::llvm::MDNode* reg_info_node = call_inst->getMetadata("RegInfo");
         if (reg_info_node != NULL) {
-          llvm::ConstantInt* num_ins_value =
-            static_cast<llvm::ConstantInt*>(reg_info_node->getOperand(0));
-          llvm::ConstantInt* num_regs_value =
-            static_cast<llvm::ConstantInt*>(reg_info_node->getOperand(1));
-          llvm::ConstantInt* num_outs_value =
-            static_cast<llvm::ConstantInt*>(reg_info_node->getOperand(2));
-          llvm::ConstantInt* num_compiler_temps_value =
-            static_cast<llvm::ConstantInt*>(reg_info_node->getOperand(3));
-          llvm::ConstantInt* num_ssa_regs_value =
-            static_cast<llvm::ConstantInt*>(reg_info_node->getOperand(4));
+          ::llvm::ConstantInt* num_ins_value =
+            static_cast< ::llvm::ConstantInt*>(reg_info_node->getOperand(0));
+          ::llvm::ConstantInt* num_regs_value =
+            static_cast< ::llvm::ConstantInt*>(reg_info_node->getOperand(1));
+          ::llvm::ConstantInt* num_outs_value =
+            static_cast< ::llvm::ConstantInt*>(reg_info_node->getOperand(2));
+          ::llvm::ConstantInt* num_compiler_temps_value =
+            static_cast< ::llvm::ConstantInt*>(reg_info_node->getOperand(3));
+          ::llvm::ConstantInt* num_ssa_regs_value =
+            static_cast< ::llvm::ConstantInt*>(reg_info_node->getOperand(4));
           if (cu->verbose) {
              LOG(INFO) << "RegInfo - Ins:" << num_ins_value->getZExtValue()
                        << ", Regs:" << num_regs_value->getZExtValue()
@@ -3501,15 +3500,15 @@
                        << ", SSARegs:" << num_ssa_regs_value->getZExtValue();
             }
           }
-        llvm::MDNode* pmap_info_node = call_inst->getMetadata("PromotionMap");
+        ::llvm::MDNode* pmap_info_node = call_inst->getMetadata("PromotionMap");
         if (pmap_info_node != NULL) {
           int elems = pmap_info_node->getNumOperands();
           if (cu->verbose) {
             LOG(INFO) << "PMap size: " << elems;
           }
           for (int i = 0; i < elems; i++) {
-            llvm::ConstantInt* raw_map_data =
-                static_cast<llvm::ConstantInt*>(pmap_info_node->getOperand(i));
+            ::llvm::ConstantInt* raw_map_data =
+                static_cast< ::llvm::ConstantInt*>(pmap_info_node->getOperand(i));
             uint32_t map_data = raw_map_data->getZExtValue();
             PromotionMap* p = &cu->promotion_map[i];
             p->first_in_pair = (map_data >> 24) & 0xff;
@@ -3536,23 +3535,23 @@
   cu->frame_size = ComputeFrameSize(cu);
 
   // Create RegLocations for arguments
-  llvm::Function::arg_iterator it(cu->func->arg_begin());
-  llvm::Function::arg_iterator it_end(cu->func->arg_end());
+  ::llvm::Function::arg_iterator it(cu->func->arg_begin());
+  ::llvm::Function::arg_iterator it_end(cu->func->arg_end());
   for (; it != it_end; ++it) {
-    llvm::Value* val = it;
+    ::llvm::Value* val = it;
     CreateLocFromValue(cu, val);
   }
   // Create RegLocations for all non-argument defintions
-  for (llvm::inst_iterator i = llvm::inst_begin(func), e = llvm::inst_end(func); i != e; ++i) {
-    llvm::Value* val = &*i;
+  for (::llvm::inst_iterator i = ::llvm::inst_begin(func), e = ::llvm::inst_end(func); i != e; ++i) {
+    ::llvm::Value* val = &*i;
     if (val->hasName() && (val->getName().str().c_str()[0] == 'v')) {
       CreateLocFromValue(cu, val);
     }
   }
 
   // Walk the blocks, generating code.
-  for (llvm::Function::iterator i = cu->func->begin(), e = cu->func->end(); i != e; ++i) {
-    BitcodeBlockCodeGen(cu, static_cast<llvm::BasicBlock*>(i));
+  for (::llvm::Function::iterator i = cu->func->begin(), e = cu->func->end(); i != e; ++i) {
+    BitcodeBlockCodeGen(cu, static_cast< ::llvm::BasicBlock*>(i));
   }
 
   cg->HandleSuspendLaunchPads(cu);
diff --git a/src/compiler/invoke_stubs/portable/stub_compiler.cc b/src/compiler/invoke_stubs/portable/stub_compiler.cc
new file mode 100644
index 0000000..5c314e6
--- /dev/null
+++ b/src/compiler/invoke_stubs/portable/stub_compiler.cc
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "stub_compiler.h"
+
+#include "base/logging.h"
+#include "compiled_method.h"
+#include "compiler/driver/compiler_driver.h"
+#include "compiler/llvm/compiler_llvm.h"
+#include "compiler/llvm/ir_builder.h"
+#include "compiler/llvm/llvm_compilation_unit.h"
+#include "compiler/llvm/runtime_support_func.h"
+#include "compiler/llvm/utils_llvm.h"
+#include "mirror/abstract_method.h"
+
+#include <llvm/BasicBlock.h>
+#include <llvm/Function.h>
+#include <llvm/GlobalVariable.h>
+#include <llvm/Intrinsics.h>
+
+#include <string>
+#include <string.h>
+
+namespace art {
+namespace llvm {
+
+using namespace runtime_support;
+
+
+StubCompiler::StubCompiler(LlvmCompilationUnit* cunit, const CompilerDriver& driver)
+: cunit_(cunit), driver_(&driver), module_(cunit_->GetModule()),
+  context_(cunit_->GetLLVMContext()), irb_(*cunit_->GetIRBuilder()) {
+}
+
+
+CompiledInvokeStub* StubCompiler::CreateInvokeStub(bool is_static,
+                                                   const char* shorty) {
+  CHECK(shorty != NULL);
+  size_t shorty_size = strlen(shorty);
+
+  // Function name
+  std::string func_name(ElfFuncName(cunit_->GetIndex()));
+
+  // Get argument types
+  ::llvm::Type* arg_types[] = {
+    irb_.getJObjectTy(), // Method object pointer
+    irb_.getJObjectTy(), // "this" object pointer (NULL for static)
+    irb_.getJObjectTy(), // Thread object pointer
+    irb_.getJValueTy()->getPointerTo(),
+    irb_.getJValueTy()->getPointerTo(),
+  };
+
+  // Function type
+  ::llvm::FunctionType* func_type =
+    ::llvm::FunctionType::get(irb_.getVoidTy(), arg_types, false);
+
+  // Create function
+  ::llvm::Function* func =
+    ::llvm::Function::Create(func_type, ::llvm::Function::ExternalLinkage,
+                           func_name, module_);
+
+
+  // Create basic block for the body of this function
+  ::llvm::BasicBlock* block_body =
+    ::llvm::BasicBlock::Create(*context_, "upcall", func);
+
+  irb_.SetInsertPoint(block_body);
+
+  // Actual arguments
+  ::llvm::Function::arg_iterator arg_iter = func->arg_begin();
+
+  ::llvm::Value* method_object_addr = arg_iter++;
+  ::llvm::Value* callee_this_addr = arg_iter++;
+  ::llvm::Value* thread_object_addr = arg_iter++;
+  ::llvm::Value* actual_args_array_addr = arg_iter++;
+  ::llvm::Value* retval_addr = arg_iter++;
+
+  // Setup thread pointer
+  ::llvm::Value* old_thread_register = irb_.Runtime().EmitSetCurrentThread(thread_object_addr);
+
+  // Accurate function type
+  ::llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
+
+  std::vector< ::llvm::Type*> accurate_arg_types;
+
+  accurate_arg_types.push_back(irb_.getJObjectTy()); // method object pointer
+
+  if (!is_static) {
+    accurate_arg_types.push_back(irb_.getJObjectTy());
+  }
+
+  for (size_t i = 1; i < shorty_size; ++i) {
+    accurate_arg_types.push_back(irb_.getJType(shorty[i]));
+  }
+
+  ::llvm::FunctionType* accurate_func_type =
+    ::llvm::FunctionType::get(accurate_ret_type, accurate_arg_types, false);
+
+  // Load actual arguments
+  std::vector< ::llvm::Value*> args;
+
+  args.push_back(method_object_addr);
+
+  if (!is_static) {
+    args.push_back(callee_this_addr);
+  }
+
+  for (size_t i = 1; i < shorty_size; ++i) {
+    char arg_shorty = shorty[i];
+
+    if (arg_shorty == 'Z' || arg_shorty == 'B' || arg_shorty == 'C' ||
+        arg_shorty == 'S' || arg_shorty == 'I' || arg_shorty == 'J' ||
+        arg_shorty == 'F' || arg_shorty == 'D' || arg_shorty == 'L') {
+
+      ::llvm::Type* arg_type =
+        irb_.getJType(shorty[i])->getPointerTo();
+
+      ::llvm::Value* arg_jvalue_addr =
+        irb_.CreateConstGEP1_32(actual_args_array_addr, i - 1);
+
+      ::llvm::Value* arg_addr = irb_.CreateBitCast(arg_jvalue_addr, arg_type);
+
+      args.push_back(irb_.CreateLoad(arg_addr, kTBAAStackTemp));
+
+    } else {
+      LOG(FATAL) << "Unexpected arg shorty for invoke stub: " << shorty[i];
+    }
+  }
+
+  // Invoke managed method now!
+  ::llvm::Value* code_field_offset_value =
+    irb_.getPtrEquivInt(mirror::AbstractMethod::GetCodeOffset().Int32Value());
+
+  ::llvm::Value* code_field_addr =
+    irb_.CreatePtrDisp(method_object_addr, code_field_offset_value,
+                       accurate_func_type->getPointerTo()->getPointerTo());
+
+  ::llvm::Value* code_addr = irb_.CreateLoad(code_field_addr, kTBAARuntimeInfo);
+
+  ::llvm::CallInst* retval = irb_.CreateCall(code_addr, args);
+  for (size_t i = 1; i < shorty_size; ++i) {
+    switch(shorty[i]) {
+      case 'Z':
+      case 'C':
+        retval->addAttribute(i + (is_static ? 1 : 2), ::llvm::Attribute::ZExt);
+        break;
+
+      case 'B':
+      case 'S':
+        retval->addAttribute(i + (is_static ? 1 : 2), ::llvm::Attribute::SExt);
+        break;
+
+      default: break;
+    }
+  }
+
+  // Store the returned value
+  if (shorty[0] != 'V') {
+    ::llvm::Value* ret_addr =
+      irb_.CreateBitCast(retval_addr, accurate_ret_type->getPointerTo());
+
+    irb_.CreateStore(retval, ret_addr, kTBAAStackTemp);
+  }
+
+  // Restore thread register
+  irb_.Runtime().EmitSetCurrentThread(old_thread_register);
+  irb_.CreateRetVoid();
+
+  // Verify the generated function
+  VERIFY_LLVM_FUNCTION(*func);
+
+  cunit_->Materialize();
+
+  return new CompiledInvokeStub(cunit_->GetInstructionSet(),
+                                cunit_->GetCompiledCode());
+}
+
+
+CompiledInvokeStub* StubCompiler::CreateProxyStub(const char* shorty) {
+  CHECK(shorty != NULL);
+  size_t shorty_size = strlen(shorty);
+
+  // Function name
+  std::string func_name(ElfFuncName(cunit_->GetIndex()));
+
+  // Accurate function type
+  ::llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
+
+  std::vector< ::llvm::Type*> accurate_arg_types;
+  accurate_arg_types.push_back(irb_.getJObjectTy()); // method
+  accurate_arg_types.push_back(irb_.getJObjectTy()); // this
+
+  for (size_t i = 1; i < shorty_size; ++i) {
+    accurate_arg_types.push_back(irb_.getJType(shorty[i]));
+  }
+
+  ::llvm::FunctionType* accurate_func_type =
+    ::llvm::FunctionType::get(accurate_ret_type, accurate_arg_types, false);
+
+  // Create function
+  ::llvm::Function* func =
+    ::llvm::Function::Create(accurate_func_type, ::llvm::Function::ExternalLinkage,
+                             func_name, module_);
+  switch(shorty[0]) {
+    case 'Z':
+    case 'C':
+      func->addAttribute(0, ::llvm::Attribute::ZExt);
+      break;
+
+    case 'B':
+    case 'S':
+      func->addAttribute(0, ::llvm::Attribute::SExt);
+      break;
+
+    default: break;
+  }
+
+  // Create basic block for the body of this function
+  ::llvm::BasicBlock* block_body =
+    ::llvm::BasicBlock::Create(*context_, "proxy", func);
+  irb_.SetInsertPoint(block_body);
+
+  // JValue for proxy return
+  ::llvm::AllocaInst* jvalue_temp = irb_.CreateAlloca(irb_.getJValueTy());
+
+  // Load actual arguments
+  ::llvm::Function::arg_iterator arg_iter = func->arg_begin();
+
+  std::vector< ::llvm::Value*> args;
+  args.push_back(arg_iter++); // method
+  args.push_back(arg_iter++); // this
+  args.push_back(irb_.Runtime().EmitGetCurrentThread()); // thread
+
+  for (size_t i = 1; i < shorty_size; ++i) {
+    args.push_back(arg_iter++);
+  }
+
+  if (shorty[0] != 'V') {
+    args.push_back(jvalue_temp);
+  }
+
+  // Call ProxyInvokeHandler
+  // TODO: Partial inline ProxyInvokeHandler, don't use VarArg.
+  irb_.CreateCall(irb_.GetRuntime(ProxyInvokeHandler), args);
+
+  if (shorty[0] != 'V') {
+    ::llvm::Value* result_addr =
+        irb_.CreateBitCast(jvalue_temp, accurate_ret_type->getPointerTo());
+    ::llvm::Value* retval = irb_.CreateLoad(result_addr, kTBAAStackTemp);
+    irb_.CreateRet(retval);
+  } else {
+    irb_.CreateRetVoid();
+  }
+
+  // Verify the generated function
+  VERIFY_LLVM_FUNCTION(*func);
+
+  cunit_->Materialize();
+
+  return new CompiledInvokeStub(cunit_->GetInstructionSet(),
+                                cunit_->GetCompiledCode());
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/invoke_stubs/portable/stub_compiler.h b/src/compiler/invoke_stubs/portable/stub_compiler.h
new file mode 100644
index 0000000..ceb8f58
--- /dev/null
+++ b/src/compiler/invoke_stubs/portable/stub_compiler.h
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_STUB_COMPILER_H_
+#define ART_SRC_COMPILER_LLVM_STUB_COMPILER_H_
+
+#include <stdint.h>
+
+namespace art {
+  class CompiledInvokeStub;
+  class CompiledProxyStub;
+  class CompilerDriver;
+}
+
+namespace llvm {
+  class LLVMContext;
+  class Module;
+}
+
+namespace art {
+namespace llvm {
+
+class LlvmCompilationUnit;
+class CompilerLLVM;
+class IRBuilder;
+
+class StubCompiler {
+ public:
+  StubCompiler(LlvmCompilationUnit* cunit, const CompilerDriver& compiler);
+
+  CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty);
+  CompiledInvokeStub* CreateProxyStub(const char* shorty);
+
+ private:
+  LlvmCompilationUnit* cunit_;
+  const CompilerDriver* const driver_;
+  ::llvm::Module* module_;
+  ::llvm::LLVMContext* context_;
+  IRBuilder& irb_;
+};
+
+
+} // namespace llvm
+} // namespace art
+
+
+#endif // ART_SRC_COMPILER_LLVM_STUB_COMPILER_H_
diff --git a/src/compiler/invoke_stubs/quick/jni_internal_arm.cc b/src/compiler/invoke_stubs/quick/jni_internal_arm.cc
new file mode 100644
index 0000000..1cbe5d9
--- /dev/null
+++ b/src/compiler/invoke_stubs/quick/jni_internal_arm.cc
@@ -0,0 +1,166 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+
+#include <algorithm>
+
+#include "asm_support.h"
+#include "compiled_method.h"
+#include "compiler/driver/compiler_driver.h"
+#include "invoke_arg_array_builder.h"
+#include "jni_internal.h"
+#include "mirror/abstract_method.h"
+#include "oat/utils/arm/assembler_arm.h"
+#include "oat/utils/assembler.h"
+
+namespace art {
+namespace arm {
+
+// Creates a function which invokes a managed method with an array of
+// arguments.
+//
+// At the time of call, the environment looks something like this:
+//
+// R0 = method pointer
+// R1 = receiver pointer or NULL for static methods
+// R2 = (managed) thread pointer
+// R3 = argument array or NULL for no argument methods
+// [SP] = JValue* result or NULL for void returns
+//
+// As the JNI call has already transitioned the thread into the
+// "running" state the remaining responsibilities of this routine are
+// to save the native register value and restore the managed thread
+// register and transfer arguments from the array into register and on
+// the stack, if needed.  On return, the thread register must be
+// shuffled and the return value must be store into the result JValue.
+CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty, uint32_t shorty_len) {
+  UniquePtr<ArmAssembler> assembler(down_cast<ArmAssembler*>(Assembler::Create(kArm)));
+#define __ assembler->
+  size_t num_arg_array_bytes = NumArgArrayBytes(shorty, shorty_len);
+  // Size of frame = spill of R4,R9/LR + Method* + possible receiver + arg array size
+  // Note, space is left in the frame to flush arguments in registers back to out locations.
+  size_t unpadded_frame_size = (4 * kPointerSize) +
+                               (is_static ? 0 : kPointerSize) +
+                               num_arg_array_bytes;
+  size_t frame_size = RoundUp(unpadded_frame_size, kStackAlignment);
+
+  // Spill R4,R9 and LR
+  RegList save = (1 << R9) | (1 << R4);
+  __ PushList(save | (1 << LR));
+
+  // Move the managed thread pointer into R9.
+  __ mov(R9, ShifterOperand(R2));
+
+  // Reset R4 to suspend check interval
+  __ LoadImmediate(R4, SUSPEND_CHECK_INTERVAL);
+
+  // Move frame down for arguments less 3 pushed values above
+  __ AddConstant(SP, -frame_size + (3 * kPointerSize));
+
+  // Can either get 3 or 2 arguments into registers
+  size_t reg_bytes = (is_static ? 3 : 2) * kPointerSize;
+  if (num_arg_array_bytes <= reg_bytes) {
+    reg_bytes = num_arg_array_bytes;
+  }
+
+  // Method* at bottom of frame is null thereby terminating managed stack crawls
+  __ LoadImmediate(IP, 0, AL);
+  __ StoreToOffset(kStoreWord, IP, SP, 0);
+
+  // Copy values onto the stack.
+  size_t src_offset = 0;
+  size_t dst_offset = (is_static ? 1 : 2) * kPointerSize;
+  for (size_t i = 1; i < shorty_len; ++i) {
+    switch (shorty[i]) {
+      case 'D':
+      case 'J':
+        // Move both pointers 64 bits.
+        __ LoadFromOffset(kLoadWord, IP, R3, src_offset);
+        src_offset += kPointerSize;
+        __ StoreToOffset(kStoreWord, IP, SP, dst_offset);
+        dst_offset += kPointerSize;
+
+        __ LoadFromOffset(kLoadWord, IP, R3, src_offset);
+        src_offset += kPointerSize;
+        __ StoreToOffset(kStoreWord, IP, SP, dst_offset);
+        dst_offset += kPointerSize;
+        break;
+      default:
+        // Move the source pointer sizeof(JValue) and the destination pointer 32 bits.
+        __ LoadFromOffset(kLoadWord, IP, R3, src_offset);
+        src_offset += sizeof(JValue);
+        __ StoreToOffset(kStoreWord, IP, SP, dst_offset);
+        dst_offset += kPointerSize;
+        break;
+    }
+  }
+
+  // Move all the register arguments into place.
+  dst_offset = (is_static ? 1 : 2) * kPointerSize;
+  if (is_static) {
+    if (reg_bytes > 0 && num_arg_array_bytes > 0) {
+      __ LoadFromOffset(kLoadWord, R1, SP, dst_offset + 0);
+      if (reg_bytes > 4 && num_arg_array_bytes > 4) {
+        __ LoadFromOffset(kLoadWord, R2, SP, dst_offset + 4);
+        if (reg_bytes > 8 && num_arg_array_bytes > 8) {
+          __ LoadFromOffset(kLoadWord, R3, SP, dst_offset + 8);
+        }
+      }
+    }
+  } else {
+    if (reg_bytes > 0 && num_arg_array_bytes > 0) {
+      __ LoadFromOffset(kLoadWord, R2, SP, dst_offset + 0);
+      if (reg_bytes > 4 && num_arg_array_bytes > 4) {
+        __ LoadFromOffset(kLoadWord, R3, SP, dst_offset + 4);
+      }
+    }
+  }
+
+  // Load the code pointer we are about to call.
+  __ LoadFromOffset(kLoadWord, IP, R0, mirror::AbstractMethod::GetCodeOffset().Int32Value());
+
+  // Do the call.
+  __ blx(IP);
+
+  // If the method returns a value, store it to the result pointer.
+  if (shorty[0] != 'V') {
+    // Load the result JValue pointer of the stub caller's out args.
+    __ LoadFromOffset(kLoadWord, IP, SP, frame_size);
+    StoreOperandType type = (shorty[0] == 'J' || shorty[0] == 'D') ? kStoreWordPair : kStoreWord;
+    __ StoreToOffset(type, R0, IP, 0);
+  }
+
+  // Remove the frame less the spilled R4, R9 and LR
+  __ AddConstant(SP, frame_size - (3 * kPointerSize));
+
+  // Pop R4, R9 and the LR into PC
+  __ PopList(save | (1 << PC));
+  // TODO: store native_entry in the stub table
+  std::vector<uint8_t> code(assembler->CodeSize());
+  MemoryRegion region(&code[0], code.size());
+  assembler->FinalizeInstructions(region);
+  return new CompiledInvokeStub(kArm, code);
+#undef __
+}
+
+}  // namespace arm
+}  // namespace art
+
+extern "C" art::CompiledInvokeStub* ArtCreateArmInvokeStub(art::CompilerDriver& /*compiler*/, bool is_static,
+                                                        const char* shorty, uint32_t shorty_len) {
+  return art::arm::CreateInvokeStub(is_static, shorty, shorty_len);
+}
diff --git a/src/compiler/invoke_stubs/quick/jni_internal_mips.cc b/src/compiler/invoke_stubs/quick/jni_internal_mips.cc
new file mode 100644
index 0000000..133052d
--- /dev/null
+++ b/src/compiler/invoke_stubs/quick/jni_internal_mips.cc
@@ -0,0 +1,177 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdint.h>
+
+#include <algorithm>
+
+#include "asm_support.h"
+#include "compiled_method.h"
+#include "compiler/driver/compiler_driver.h"
+#include "invoke_arg_array_builder.h"
+#include "jni_internal.h"
+#include "mirror/abstract_method.h"
+#include "oat/utils/mips/assembler_mips.h"
+#include "oat/utils/assembler.h"
+
+namespace art {
+namespace mips {
+// Creates a function which invokes a managed method with an array of
+// arguments.
+//
+// At the time of call, the environment looks something like this:
+//
+// A0 = method pointer
+// A1 = receiver pointer or NULL for static methods
+// A2 = (managed) thread pointer
+// A3 = argument array or NULL for no argument methods
+// [SP] = JValue* result or NULL for void returns
+//
+// As the JNI call has already transitioned the thread into the
+// "running" state the remaining responsibilities of this routine are
+// to save the native register value and restore the managed thread
+// register and transfer arguments from the array into register and on
+// the stack, if needed.  On return, the thread register must be
+// shuffled and the return value must be store into the result JValue.
+CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty, uint32_t shorty_len) {
+  UniquePtr<MipsAssembler> assembler(down_cast<MipsAssembler*>(Assembler::Create(kMips)));
+#define __ assembler->
+  size_t num_arg_array_bytes = NumArgArrayBytes(shorty, shorty_len);
+  // Size of frame = spill of R4,R9/LR + Method* + possible receiver + arg array size
+  // Note, space is left in the frame to flush arguments in registers back to out locations.
+  size_t unpadded_frame_size = (4 * kPointerSize) +
+                               (is_static ? 0 : kPointerSize) +
+                               num_arg_array_bytes;
+  size_t frame_size = RoundUp(unpadded_frame_size, kStackAlignment);
+
+  // Setup frame and spill S0 (rSUSPEND), S1 (rSELF), and RA
+  __ AddConstant(SP, SP, -frame_size);
+  __ StoreToOffset(kStoreWord, RA, SP, frame_size - 4);
+  __ StoreToOffset(kStoreWord, S1, SP, frame_size - 8);
+  __ StoreToOffset(kStoreWord, S0, SP, frame_size - 12);
+
+  // Move the managed thread pointer into S1.
+  __ Move(S1, A2);
+
+  // Reset S0 to suspend check interval
+  __ LoadImmediate(S0, SUSPEND_CHECK_INTERVAL);
+
+  // Can either get 3 or 2 arguments into registers
+  size_t reg_bytes = (is_static ? 3 : 2) * kPointerSize;
+  if (num_arg_array_bytes <= reg_bytes) {
+    reg_bytes = num_arg_array_bytes;
+  }
+
+  // Method* at bottom of frame is null thereby terminating managed stack crawls
+  __ StoreToOffset(kStoreWord, ZERO, SP, 0);
+
+  // Copy values onto the stack.
+  size_t src_offset = 0;
+  size_t dst_offset = (is_static ? 1 : 2) * kPointerSize;
+  for (size_t i = 1; i < shorty_len; ++i) {
+    switch (shorty[i]) {
+      case 'D':
+      case 'J':
+        // Move both pointers 64 bits.
+        __ LoadFromOffset(kLoadWord, T9, A3, src_offset);
+        src_offset += kPointerSize;
+        __ StoreToOffset(kStoreWord, T9, SP, dst_offset);
+        dst_offset += kPointerSize;
+
+        __ LoadFromOffset(kLoadWord, T9, A3, src_offset);
+        src_offset += kPointerSize;
+        __ StoreToOffset(kStoreWord, T9, SP, dst_offset);
+        dst_offset += kPointerSize;
+        break;
+      default:
+        // Move the source pointer sizeof(JValue) and the destination pointer 32 bits.
+        __ LoadFromOffset(kLoadWord, T9, A3, src_offset);
+        src_offset += sizeof(JValue);
+        __ StoreToOffset(kStoreWord, T9, SP, dst_offset);
+        dst_offset += kPointerSize;
+        break;
+    }
+  }
+
+  // Move all the register arguments into place.
+  dst_offset = (is_static ? 1 : 2) * kPointerSize;
+  if (is_static) {
+    if (reg_bytes > 0 && num_arg_array_bytes > 0) {
+      __ LoadFromOffset(kLoadWord, A1, SP, dst_offset + 0);
+      if (reg_bytes > 4 && num_arg_array_bytes > 4) {
+        __ LoadFromOffset(kLoadWord, A2, SP, dst_offset + 4);
+        if (reg_bytes > 8 && num_arg_array_bytes > 8) {
+          __ LoadFromOffset(kLoadWord, A3, SP, dst_offset + 8);
+        }
+      }
+    }
+  } else {
+    if (reg_bytes > 0 && num_arg_array_bytes > 0) {
+      __ LoadFromOffset(kLoadWord, A2, SP, dst_offset + 0);
+      if (reg_bytes > 4 && num_arg_array_bytes > 4) {
+        __ LoadFromOffset(kLoadWord, A3, SP, dst_offset + 4);
+      }
+    }
+  }
+
+  // Load the code pointer we are about to call.
+  __ LoadFromOffset(kLoadWord, T9, A0, mirror::AbstractMethod::GetCodeOffset().Int32Value());
+
+  // Do the call.
+  __ Jalr(T9);
+
+  // If the method returns a value, store it to the result pointer.
+  if (shorty[0] != 'V') {
+    // Load the result JValue pointer of the stub caller's out args.
+    __ LoadFromOffset(kLoadWord, T9, SP, frame_size + 16);
+    switch (shorty[0]) {
+      case 'D':
+        __ StoreDToOffset(D0, T9, 0);
+        break;
+      case 'F':
+        __ StoreFToOffset(F0, T9, 0);
+        break;
+      case 'J':
+        __ StoreToOffset(kStoreWord, V0, T9, 0);
+        __ StoreToOffset(kStoreWord, V1, T9, 4);
+        break;
+      default:
+        __ StoreToOffset(kStoreWord, V0, T9, 0);
+    }
+  }
+
+  // Restore frame and spill regs
+  __ LoadFromOffset(kLoadWord, S0, SP, frame_size - 12);
+  __ LoadFromOffset(kLoadWord, S1, SP, frame_size - 8);
+  __ LoadFromOffset(kLoadWord, RA, SP, frame_size - 4);
+  __ AddConstant(SP, SP, frame_size);
+
+  __ Jr(RA);
+
+  // TODO: store native_entry in the stub table
+  std::vector<uint8_t> code(assembler->CodeSize());
+  MemoryRegion region(&code[0], code.size());
+  assembler->FinalizeInstructions(region);
+  return new CompiledInvokeStub(kMips, code);
+#undef __
+}
+}  // namespace mips
+}  // namespace art
+
+extern "C" art::CompiledInvokeStub* ArtCreateMipsInvokeStub(art::CompilerDriver& /*compiler*/, bool is_static,
+                                                        const char* shorty, uint32_t shorty_len) {
+  return art::mips::CreateInvokeStub(is_static, shorty, shorty_len);
+}
diff --git a/src/compiler/invoke_stubs/quick/jni_internal_x86.cc b/src/compiler/invoke_stubs/quick/jni_internal_x86.cc
new file mode 100644
index 0000000..58d0664
--- /dev/null
+++ b/src/compiler/invoke_stubs/quick/jni_internal_x86.cc
@@ -0,0 +1,171 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "compiled_method.h"
+#include "compiler/driver/compiler_driver.h"
+#include "invoke_arg_array_builder.h"
+#include "jni_internal.h"
+#include "mirror/abstract_method.h"
+#include "oat/utils/assembler.h"
+#include "oat/utils/x86/assembler_x86.h"
+
+namespace art {
+namespace x86 {
+
+// Creates a function which invokes a managed method with an array of
+// arguments.
+//
+// Immediately after the call on X86, the environment looks like this:
+//
+// [SP+0 ] = Return address
+// [SP+4 ] = method pointer
+// [SP+8 ] = receiver pointer or NULL for static methods
+// [SP+12] = (managed) thread pointer
+// [SP+16] = argument array or NULL for no argument methods
+// [SP+20] = JValue* result or NULL for void returns
+//
+// As the JNI call has already transitioned the thread into the
+// "running" state the remaining responsibilities of this routine are
+// to save the native registers and set up the managed registers. On
+// return, the return value must be store into the result JValue.
+CompiledInvokeStub* CreateInvokeStub(bool is_static, const char* shorty, uint32_t shorty_len) {
+  UniquePtr<X86Assembler> assembler(down_cast<X86Assembler*>(Assembler::Create(kX86)));
+#define __ assembler->
+  size_t num_arg_array_bytes = NumArgArrayBytes(shorty, shorty_len);
+  // Size of frame = return address + saved EBX + Method* + possible receiver + arg array size
+  // Note, space is left in the frame to flush arguments in registers back to out locations.
+  size_t frame_size = 3 * kPointerSize + (is_static ? 0 : kPointerSize) + num_arg_array_bytes;
+  size_t pad_size = RoundUp(frame_size, kStackAlignment) - frame_size;
+
+  Register rMethod = EAX;
+  __ movl(rMethod,   Address(ESP, 4));     // EAX = method
+  Register rReceiver = ECX;
+  if (!is_static) {
+    __ movl(rReceiver, Address(ESP, 8));   // ECX = receiver
+  }
+  // Save EBX
+  __ pushl(EBX);
+  Register rArgArray = EBX;
+  __ movl(rArgArray, Address(ESP, 20));    // EBX = arg array
+
+  // TODO: optimize the frame set up to avoid excessive SP math
+  // Push padding
+  if (pad_size != 0) {
+    __ subl(ESP, Immediate(pad_size));
+  }
+  // Push/copy arguments.
+  size_t arg_count = (shorty_len - 1);
+  size_t dst_offset = num_arg_array_bytes;
+  size_t src_offset = arg_count * sizeof(JValue);
+  for (size_t i = shorty_len - 1; i > 0; --i) {
+    switch (shorty[i]) {
+      case 'D':
+      case 'J':
+        // Move both pointers 64 bits.
+        dst_offset -= kPointerSize;
+        src_offset -= sizeof(JValue) / 2;
+        __ pushl(Address(rArgArray, src_offset));
+        dst_offset -= kPointerSize;
+        src_offset -= sizeof(JValue) / 2;
+        __ pushl(Address(rArgArray, src_offset));
+        break;
+      default:
+        // Move the source pointer sizeof(JValue) and the destination pointer 32 bits.
+        dst_offset -= kPointerSize;
+        src_offset -= sizeof(JValue);
+        __ pushl(Address(rArgArray, src_offset));
+        break;
+    }
+  }
+
+  // Backing space for receiver.
+  if (!is_static) {
+    __ pushl(Immediate(0));
+  }
+  // Push 0 as NULL Method* thereby terminating managed stack crawls.
+  __ pushl(Immediate(0));
+  if (!is_static) {
+    if (shorty_len > 1) {
+      // Receiver already in ECX, pass remaining 2 args in EDX and EBX.
+      __ movl(EDX, Address(rArgArray, 0));
+      if (shorty[1] == 'D' || shorty[1] == 'J') {
+        __ movl(EBX, Address(rArgArray, sizeof(JValue) / 2));
+      } else if (shorty_len > 2) {
+        __ movl(EBX, Address(rArgArray, sizeof(JValue)));
+      }
+    }
+  } else {
+    if (shorty_len > 1) {
+      // Pass remaining 3 args in ECX, EDX and EBX.
+      __ movl(ECX, Address(rArgArray, 0));
+      if (shorty[1] == 'D' || shorty[1] == 'J') {
+        __ movl(EDX, Address(rArgArray, sizeof(JValue) / 2));
+        if (shorty_len > 2) {
+           __ movl(EBX, Address(rArgArray, sizeof(JValue)));
+        }
+      } else if (shorty_len > 2) {
+        __ movl(EDX, Address(rArgArray, sizeof(JValue)));
+        if (shorty[2] == 'D' || shorty[2] == 'J') {
+          __ movl(EBX, Address(rArgArray, sizeof(JValue) + (sizeof(JValue) / 2)));
+        } else {
+          __ movl(EBX, Address(rArgArray, sizeof(JValue) + sizeof(JValue)));
+        }
+      }
+    }
+  }
+
+  __ call(Address(EAX, mirror::AbstractMethod::GetCodeOffset()));  // Call code off of method
+
+  // Pop arguments up to EBX and the return address.
+  __ addl(ESP, Immediate(frame_size + pad_size - (2 * kPointerSize)));
+  // Restore EBX.
+  __ popl(EBX);
+  char ch = shorty[0];
+  if (ch != 'V') {
+    // Load the result JValue pointer.
+    __ movl(ECX, Address(ESP, 20));
+    switch (ch) {
+      case 'D':
+        __ movsd(Address(ECX, 0), XMM0);
+        break;
+      case 'F':
+        __ movss(Address(ECX, 0), XMM0);
+        break;
+      case 'J':
+        __ movl(Address(ECX, 0), EAX);
+        __ movl(Address(ECX, 4), EDX);
+        break;
+      default:
+        __ movl(Address(ECX, 0), EAX);
+        break;
+    }
+  }
+  __ ret();
+  // TODO: store native_entry in the stub table
+  std::vector<uint8_t> code(assembler->CodeSize());
+  MemoryRegion region(&code[0], code.size());
+  assembler->FinalizeInstructions(region);
+  return new CompiledInvokeStub(kX86, code);
+#undef __
+}
+
+}  // namespace x86
+}  // namespace art
+
+extern "C" art::CompiledInvokeStub* ArtCreateX86InvokeStub(art::CompilerDriver& /*compiler*/, bool is_static,
+                                                        const char* shorty, uint32_t shorty_len) {
+  return art::x86::CreateInvokeStub(is_static, shorty, shorty_len);
+}
diff --git a/src/compiler/jni/portable/jni_compiler.cc b/src/compiler/jni/portable/jni_compiler.cc
index a0f4dc8..1a4ad95 100644
--- a/src/compiler/jni/portable/jni_compiler.cc
+++ b/src/compiler/jni/portable/jni_compiler.cc
@@ -21,11 +21,11 @@
 #include "compiled_method.h"
 #include "compiler/driver/compiler_driver.h"
 #include "compiler/driver/dex_compilation_unit.h"
-#include "compiler_llvm/compiler_llvm.h"
-#include "compiler_llvm/ir_builder.h"
-#include "compiler_llvm/llvm_compilation_unit.h"
-#include "compiler_llvm/runtime_support_func.h"
-#include "compiler_llvm/utils_llvm.h"
+#include "compiler/llvm/compiler_llvm.h"
+#include "compiler/llvm/ir_builder.h"
+#include "compiler/llvm/llvm_compilation_unit.h"
+#include "compiler/llvm/runtime_support_func.h"
+#include "compiler/llvm/utils_llvm.h"
 #include "mirror/abstract_method.h"
 #include "runtime.h"
 #include "stack.h"
@@ -38,7 +38,7 @@
 #include <llvm/Type.h>
 
 namespace art {
-namespace compiler_llvm {
+namespace llvm {
 
 using namespace runtime_support;
 
@@ -62,18 +62,18 @@
   DexFile::MethodId const& method_id =
       dex_file->GetMethodId(dex_compilation_unit_->GetDexMethodIndex());
   char const return_shorty = dex_file->GetMethodShorty(method_id)[0];
-  llvm::Value* this_object_or_class_object;
+  ::llvm::Value* this_object_or_class_object;
 
   CreateFunction();
 
   // Set argument name
-  llvm::Function::arg_iterator arg_begin(func_->arg_begin());
-  llvm::Function::arg_iterator arg_end(func_->arg_end());
-  llvm::Function::arg_iterator arg_iter(arg_begin);
+  ::llvm::Function::arg_iterator arg_begin(func_->arg_begin());
+  ::llvm::Function::arg_iterator arg_end(func_->arg_end());
+  ::llvm::Function::arg_iterator arg_iter(arg_begin);
 
   DCHECK_NE(arg_iter, arg_end);
   arg_iter->setName("method");
-  llvm::Value* method_object_addr = arg_iter++;
+  ::llvm::Value* method_object_addr = arg_iter++;
 
   if (!is_static) {
     // Non-static, the second argument is "this object"
@@ -103,8 +103,8 @@
   }
 
   // Shadow stack
-  llvm::StructType* shadow_frame_type = irb_.getShadowFrameTy(sirt_size);
-  llvm::AllocaInst* shadow_frame_ = irb_.CreateAlloca(shadow_frame_type);
+  ::llvm::StructType* shadow_frame_type = irb_.getShadowFrameTy(sirt_size);
+  ::llvm::AllocaInst* shadow_frame_ = irb_.CreateAlloca(shadow_frame_type);
 
   // Store the dex pc
   irb_.StoreToObjectOffset(shadow_frame_,
@@ -113,18 +113,18 @@
                            kTBAAShadowFrame);
 
   // Push the shadow frame
-  llvm::Value* shadow_frame_upcast = irb_.CreateConstGEP2_32(shadow_frame_, 0, 0);
-  llvm::Value* old_shadow_frame =
+  ::llvm::Value* shadow_frame_upcast = irb_.CreateConstGEP2_32(shadow_frame_, 0, 0);
+  ::llvm::Value* old_shadow_frame =
       irb_.Runtime().EmitPushShadowFrame(shadow_frame_upcast, method_object_addr, sirt_size);
 
   // Get JNIEnv
-  llvm::Value* jni_env_object_addr =
+  ::llvm::Value* jni_env_object_addr =
       irb_.Runtime().EmitLoadFromThreadOffset(Thread::JniEnvOffset().Int32Value(),
                                               irb_.getJObjectTy(),
                                               kTBAARuntimeInfo);
 
   // Get callee code_addr
-  llvm::Value* code_addr =
+  ::llvm::Value* code_addr =
       irb_.LoadFromObjectOffset(method_object_addr,
                                 mirror::AbstractMethod::NativeMethodOffset().Int32Value(),
                                 GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(),
@@ -132,13 +132,13 @@
                                 kTBAARuntimeInfo);
 
   // Load actual parameters
-  std::vector<llvm::Value*> args;
+  std::vector< ::llvm::Value*> args;
 
   // The 1st parameter: JNIEnv*
   args.push_back(jni_env_object_addr);
 
   // Variables for GetElementPtr
-  llvm::Value* gep_index[] = {
+  ::llvm::Value* gep_index[] = {
     irb_.getInt32(0), // No displacement for shadow frame pointer
     irb_.getInt32(1), // SIRT
     NULL,
@@ -148,7 +148,7 @@
 
   // Store the "this object or class object" to SIRT
   gep_index[2] = irb_.getInt32(sirt_member_index++);
-  llvm::Value* sirt_field_addr = irb_.CreateBitCast(irb_.CreateGEP(shadow_frame_, gep_index),
+  ::llvm::Value* sirt_field_addr = irb_.CreateBitCast(irb_.CreateGEP(shadow_frame_, gep_index),
                                                     irb_.getJObjectTy()->getPointerTo());
   irb_.CreateStore(this_object_or_class_object, sirt_field_addr, kTBAAShadowFrame);
   // Push the "this object or class object" to out args
@@ -159,13 +159,13 @@
     if (arg_iter->getType() == irb_.getJObjectTy()) {
       // Store the reference type arguments to SIRT
       gep_index[2] = irb_.getInt32(sirt_member_index++);
-      llvm::Value* sirt_field_addr = irb_.CreateBitCast(irb_.CreateGEP(shadow_frame_, gep_index),
+      ::llvm::Value* sirt_field_addr = irb_.CreateBitCast(irb_.CreateGEP(shadow_frame_, gep_index),
                                                         irb_.getJObjectTy()->getPointerTo());
       irb_.CreateStore(arg_iter, sirt_field_addr, kTBAAShadowFrame);
       // Note null is placed in the SIRT but the jobject passed to the native code must be null
       // (not a pointer into the SIRT as with regular references).
-      llvm::Value* equal_null = irb_.CreateICmpEQ(arg_iter, irb_.getJNull());
-      llvm::Value* arg =
+      ::llvm::Value* equal_null = irb_.CreateICmpEQ(arg_iter, irb_.getJNull());
+      ::llvm::Value* arg =
           irb_.CreateSelect(equal_null,
                             irb_.getJNull(),
                             irb_.CreateBitCast(sirt_field_addr, irb_.getJObjectTy()));
@@ -175,11 +175,11 @@
     }
   }
 
-  llvm::Value* saved_local_ref_cookie;
+  ::llvm::Value* saved_local_ref_cookie;
   { // JniMethodStart
     RuntimeId func_id = is_synchronized ? JniMethodStartSynchronized
                                         : JniMethodStart;
-    llvm::SmallVector<llvm::Value*, 2> args;
+    ::llvm::SmallVector< ::llvm::Value*, 2> args;
     if (is_synchronized) {
       args.push_back(this_object_or_class_object);
     }
@@ -189,7 +189,7 @@
   }
 
   // Call!!!
-  llvm::Value* retval = irb_.CreateCall(code_addr, args);
+  ::llvm::Value* retval = irb_.CreateCall(code_addr, args);
 
   { // JniMethodEnd
     bool is_return_ref = return_shorty == 'L';
@@ -198,7 +198,7 @@
                                          : JniMethodEndWithReference)
                       : (is_synchronized ? JniMethodEndSynchronized
                                          : JniMethodEnd);
-    llvm::SmallVector<llvm::Value*, 4> args;
+    ::llvm::SmallVector< ::llvm::Value*, 4> args;
     if (is_return_ref) {
       args.push_back(retval);
     }
@@ -208,7 +208,7 @@
     }
     args.push_back(irb_.Runtime().EmitGetCurrentThread());
 
-    llvm::Value* decoded_jobject =
+    ::llvm::Value* decoded_jobject =
         irb_.CreateCall(irb_.GetRuntime(func_id), args);
 
     // Return decoded jobject if return reference.
@@ -244,33 +244,33 @@
   const bool is_static = dex_compilation_unit_->IsStatic();
 
   // Get function type
-  llvm::FunctionType* func_type =
+  ::llvm::FunctionType* func_type =
     GetFunctionType(dex_compilation_unit_->GetDexMethodIndex(), is_static, false);
 
   // Create function
-  func_ = llvm::Function::Create(func_type, llvm::Function::ExternalLinkage,
+  func_ = ::llvm::Function::Create(func_type, ::llvm::Function::ExternalLinkage,
                                  func_name, module_);
 
   // Create basic block
-  llvm::BasicBlock* basic_block = llvm::BasicBlock::Create(*context_, "B0", func_);
+  ::llvm::BasicBlock* basic_block = ::llvm::BasicBlock::Create(*context_, "B0", func_);
 
   // Set insert point
   irb_.SetInsertPoint(basic_block);
 }
 
 
-llvm::FunctionType* JniCompiler::GetFunctionType(uint32_t method_idx,
-                                                 bool is_static, bool is_native_function) {
+::llvm::FunctionType* JniCompiler::GetFunctionType(uint32_t method_idx,
+                                                   bool is_static, bool is_native_function) {
   // Get method signature
   uint32_t shorty_size;
   const char* shorty = dex_compilation_unit_->GetShorty(&shorty_size);
   CHECK_GE(shorty_size, 1u);
 
   // Get return type
-  llvm::Type* ret_type = irb_.getJType(shorty[0]);
+  ::llvm::Type* ret_type = irb_.getJType(shorty[0]);
 
   // Get argument type
-  std::vector<llvm::Type*> args_type;
+  std::vector< ::llvm::Type*> args_type;
 
   args_type.push_back(irb_.getJObjectTy()); // method object pointer
 
@@ -284,8 +284,8 @@
     args_type.push_back(irb_.getJType(shorty[i]));
   }
 
-  return llvm::FunctionType::get(ret_type, args_type, false);
+  return ::llvm::FunctionType::get(ret_type, args_type, false);
 }
 
-} // namespace compiler_llvm
+} // namespace llvm
 } // namespace art
diff --git a/src/compiler/jni/portable/jni_compiler.h b/src/compiler/jni/portable/jni_compiler.h
index 3125f0f..3df81a5 100644
--- a/src/compiler/jni/portable/jni_compiler.h
+++ b/src/compiler/jni/portable/jni_compiler.h
@@ -44,7 +44,7 @@
 }  // namespace llvm
 
 namespace art {
-namespace compiler_llvm {
+namespace llvm {
 
 class LlvmCompilationUnit;
 class IRBuilder;
@@ -60,25 +60,25 @@
  private:
   void CreateFunction();
 
-  llvm::FunctionType* GetFunctionType(uint32_t method_idx,
+  ::llvm::FunctionType* GetFunctionType(uint32_t method_idx,
                                       bool is_static, bool is_target_function);
 
  private:
   LlvmCompilationUnit* cunit_;
   const CompilerDriver* const driver_;
 
-  llvm::Module* module_;
-  llvm::LLVMContext* context_;
+  ::llvm::Module* module_;
+  ::llvm::LLVMContext* context_;
   IRBuilder& irb_;
 
   const DexCompilationUnit* const dex_compilation_unit_;
 
-  llvm::Function* func_;
+  ::llvm::Function* func_;
   uint16_t elf_func_idx_;
 };
 
 
-}  // namespace compiler_llvm
+}  // namespace llvm
 }  // namespace art
 
 
diff --git a/src/compiler/llvm/art_module.ll b/src/compiler/llvm/art_module.ll
new file mode 100644
index 0000000..233692c
--- /dev/null
+++ b/src/compiler/llvm/art_module.ll
@@ -0,0 +1,153 @@
+;;
+;; Copyright (C) 2012 The Android Open Source Project
+;;
+;; Licensed under the Apache License, Version 2.0 (the "License");
+;; you may not use this file except in compliance with the License.
+;; You may obtain a copy of the License at
+;;
+;;      http://www.apache.org/licenses/LICENSE-2.0
+;;
+;; Unless required by applicable law or agreed to in writing, software
+;; distributed under the License is distributed on an "AS IS" BASIS,
+;; WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+;; See the License for the specific language governing permissions and
+;; limitations under the License.
+;;
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Type
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+%JavaObject = type opaque
+
+%ShadowFrame = type { i32                  ; Number of VRegs
+                    , %ShadowFrame*        ; Previous frame
+                    , %JavaObject*         ; Method object pointer
+                    , i32                  ; Line number for stack backtrace
+                    ; [0 x i32]            ; VRegs
+                    }
+
+declare void @__art_type_list(%JavaObject*, %ShadowFrame*)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Thread
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare %JavaObject* @art_portable_get_current_thread_from_code()
+declare %JavaObject* @art_portable_set_current_thread_from_code(%JavaObject*)
+
+declare void @art_portable_lock_object_from_code(%JavaObject*, %JavaObject*)
+declare void @art_portable_unlock_object_from_code(%JavaObject*, %JavaObject*)
+
+declare void @art_portable_test_suspend_from_code(%JavaObject*)
+
+declare %ShadowFrame* @art_portable_push_shadow_frame_from_code(%JavaObject*, %ShadowFrame*, %JavaObject*, i32)
+declare void @art_portable_pop_shadow_frame_from_code(%ShadowFrame*)
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Exception
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare %JavaObject* @art_portable_get_and_clear_exception(%JavaObject*)
+declare void @art_portable_throw_div_zero_from_code()
+declare void @art_portable_throw_array_bounds_from_code(i32, i32)
+declare void @art_portable_throw_no_such_method_from_code(i32)
+declare void @art_portable_throw_null_pointer_exception_from_code(i32)
+declare void @art_portable_throw_stack_overflow_from_code()
+declare void @art_portable_throw_exception_from_code(%JavaObject*)
+
+declare i32 @art_portable_find_catch_block_from_code(%JavaObject*, i32)
+
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Object Space
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare %JavaObject* @art_portable_alloc_object_from_code(i32, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_alloc_object_from_code_with_access_check(i32, %JavaObject*, %JavaObject*)
+
+declare %JavaObject* @art_portable_alloc_array_from_code(i32, %JavaObject*, i32, %JavaObject*)
+declare %JavaObject* @art_portable_alloc_array_from_code_with_access_check(i32, %JavaObject*, i32, %JavaObject*)
+declare %JavaObject* @art_portable_check_and_alloc_array_from_code(i32, %JavaObject*, i32, %JavaObject*)
+declare %JavaObject* @art_portable_check_and_alloc_array_from_code_with_access_check(i32, %JavaObject*, i32, %JavaObject*)
+
+declare void @art_portable_find_instance_field_from_code(i32, %JavaObject*)
+declare void @art_portable_find_static_field_from_code(i32, %JavaObject*)
+
+declare %JavaObject* @art_portable_find_static_method_from_code_with_access_check(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_find_direct_method_from_code_with_access_check(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_find_virtual_method_from_code_with_access_check(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_find_super_method_from_code_with_access_check(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_find_interface_method_from_code_with_access_check(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_find_interface_method_from_code(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+
+declare %JavaObject* @art_portable_initialize_static_storage_from_code(i32, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_initialize_type_from_code(i32, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_initialize_type_and_verify_access_from_code(i32, %JavaObject*, %JavaObject*)
+
+declare %JavaObject* @art_portable_resolve_string_from_code(%JavaObject*, i32)
+
+declare i32 @art_portable_set32_static_from_code(i32, %JavaObject*, i32)
+declare i32 @art_portable_set64_static_from_code(i32, %JavaObject*, i64)
+declare i32 @art_portable_set_obj_static_from_code(i32, %JavaObject*, %JavaObject*)
+
+declare i32 @art_portable_get32_static_from_code(i32, %JavaObject*)
+declare i64 @art_portable_get64_static_from_code(i32, %JavaObject*)
+declare %JavaObject* @art_portable_get_obj_static_from_code(i32, %JavaObject*)
+
+declare i32 @art_portable_set32_instance_from_code(i32, %JavaObject*, %JavaObject*, i32)
+declare i32 @art_portable_set64_instance_from_code(i32, %JavaObject*, %JavaObject*, i64)
+declare i32 @art_portable_set_obj_instance_from_code(i32, %JavaObject*, %JavaObject*, %JavaObject*)
+
+declare i32 @art_portable_get32_instance_from_code(i32, %JavaObject*, %JavaObject*)
+declare i64 @art_portable_get64_instance_from_code(i32, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_get_obj_instance_from_code(i32, %JavaObject*, %JavaObject*)
+
+declare %JavaObject* @art_portable_decode_jobject_in_thread(%JavaObject*, %JavaObject*)
+
+declare void @art_portable_fill_array_data_from_code(%JavaObject*, i32, %JavaObject*, i32)
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Type Checking, in the nature of casting
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare i32 @art_portable_is_assignable_from_code(%JavaObject*, %JavaObject*)
+declare void @art_portable_check_cast_from_code(%JavaObject*, %JavaObject*)
+declare void @art_portable_check_put_array_element_from_code(%JavaObject*, %JavaObject*)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Math
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare i64 @art_d2l(double)
+declare i32 @art_d2i(double)
+declare i64 @art_f2l(float)
+declare i32 @art_f2i(float)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; JNI
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare i32 @art_portable_jni_method_start(%JavaObject*)
+declare i32 @art_portable_jni_method_start_synchronized(%JavaObject*, %JavaObject*)
+
+declare void @art_portable_jni_method_end(i32, %JavaObject*)
+declare void @art_portable_jni_method_end_synchronized(i32, %JavaObject*, %JavaObject*)
+declare %JavaObject* @art_portable_jni_method_end_with_reference(%JavaObject*, i32, %JavaObject*)
+declare %JavaObject* @art_portable_jni_method_end_with_reference_synchronized(%JavaObject*, i32, %JavaObject*, %JavaObject*)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+; Temporary runtime support, will be removed in the future
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+
+declare i1 @art_portable_is_exception_pending_from_code()
+
+declare void @art_portable_mark_gc_card_from_code(%JavaObject*, %JavaObject*)
+
+declare void @art_portable_proxy_invoke_handler_from_code(%JavaObject*, ...)
diff --git a/src/compiler/llvm/backend_options.h b/src/compiler/llvm/backend_options.h
new file mode 100644
index 0000000..924a346
--- /dev/null
+++ b/src/compiler/llvm/backend_options.h
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_
+#define ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_
+
+#include <llvm/Support/CommandLine.h>
+
+#define DECLARE_ARM_BACKEND_OPTIONS \
+extern llvm::cl::opt<bool> EnableARMLongCalls; \
+extern llvm::cl::opt<bool> ReserveR9;
+
+#define INITIAL_ARM_BACKEND_OPTIONS \
+EnableARMLongCalls = true; \
+ReserveR9 = true;
+
+#define DECLARE_X86_BACKEND_OPTIONS
+#define INITIAL_X86_BACKEND_OPTIONS
+
+#define DECLARE_Mips_BACKEND_OPTIONS
+#define INITIAL_Mips_BACKEND_OPTIONS
+
+#define LLVM_TARGET(TargetName) DECLARE_##TargetName##_BACKEND_OPTIONS
+#include "llvm/Config/Targets.def"
+
+namespace art {
+namespace llvm {
+
+inline void InitialBackendOptions() {
+#define LLVM_TARGET(TargetName) INITIAL_##TargetName##_BACKEND_OPTIONS
+#include "llvm/Config/Targets.def"
+}
+
+}  // namespace llvm
+}  // namespace art
+
+#endif  // ART_SRC_COMPILER_LLVM_BACKEND_OPTIONS_H_
diff --git a/src/compiler/llvm/backend_types.h b/src/compiler/llvm/backend_types.h
new file mode 100644
index 0000000..09f6de7
--- /dev/null
+++ b/src/compiler/llvm/backend_types.h
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_
+#define ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_
+
+#include "base/logging.h"
+
+
+namespace art {
+namespace llvm {
+
+
+enum JType {
+  kVoid,
+  kBoolean,
+  kByte,
+  kChar,
+  kShort,
+  kInt,
+  kLong,
+  kFloat,
+  kDouble,
+  kObject,
+  MAX_JTYPE
+};
+
+enum RegCategory {
+  kRegUnknown,
+  kRegZero,
+  kRegCat1nr,
+  kRegCat2,
+  kRegObject,
+};
+
+
+enum TBAASpecialType {
+  kTBAARegister,
+  kTBAAStackTemp,
+  kTBAAHeapArray,
+  kTBAAHeapInstance,
+  kTBAAHeapStatic,
+  kTBAAJRuntime,
+  kTBAARuntimeInfo,
+  kTBAAShadowFrame,
+  kTBAAConstJObject,
+  MAX_TBAA_SPECIAL_TYPE
+};
+
+
+enum ExpectCond {
+  kLikely,
+  kUnlikely,
+  MAX_EXPECT
+};
+
+
+inline JType GetJTypeFromShorty(char shorty_jty) {
+  switch (shorty_jty) {
+  case 'V':
+    return kVoid;
+
+  case 'Z':
+    return kBoolean;
+
+  case 'B':
+    return kByte;
+
+  case 'C':
+    return kChar;
+
+  case 'S':
+    return kShort;
+
+  case 'I':
+    return kInt;
+
+  case 'J':
+    return kLong;
+
+  case 'F':
+    return kFloat;
+
+  case 'D':
+    return kDouble;
+
+  case 'L':
+    return kObject;
+
+  default:
+    LOG(FATAL) << "Unknown Dalvik shorty descriptor: " << shorty_jty;
+    return kVoid;
+  }
+}
+
+
+inline RegCategory GetRegCategoryFromJType(JType jty) {
+  switch (jty) {
+  case kVoid:
+    return kRegUnknown;
+
+  case kBoolean:
+  case kByte:
+  case kChar:
+  case kShort:
+  case kInt:
+  case kFloat:
+    return kRegCat1nr;
+
+  case kLong:
+  case kDouble:
+    return kRegCat2;
+
+  case kObject:
+    return kRegObject;
+
+  default:
+    LOG(FATAL) << "Unknown java type: " << jty;
+    return kRegUnknown;
+  }
+}
+
+
+inline RegCategory GetRegCategoryFromShorty(char shorty) {
+  return GetRegCategoryFromJType(GetJTypeFromShorty(shorty));
+}
+
+
+} // namespace llvm
+} // namespace art
+
+
+#endif // ART_SRC_COMPILER_LLVM_BACKEND_TYPES_H_
diff --git a/src/compiler/llvm/compiler_llvm.cc b/src/compiler/llvm/compiler_llvm.cc
new file mode 100644
index 0000000..1c9a494
--- /dev/null
+++ b/src/compiler/llvm/compiler_llvm.cc
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "compiler_llvm.h"
+
+#include "base/stl_util.h"
+#include "backend_options.h"
+#include "class_linker.h"
+#include "compiled_method.h"
+#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
+#include "compiler/invoke_stubs/portable/stub_compiler.h"
+#include "compiler/jni/portable/jni_compiler.h"
+#include "ir_builder.h"
+#include "llvm_compilation_unit.h"
+#include "oat_file.h"
+#include "utils_llvm.h"
+#include "verifier/method_verifier.h"
+
+#include <llvm/LinkAllPasses.h>
+#include <llvm/LinkAllVMCore.h>
+#include <llvm/Support/ManagedStatic.h>
+#include <llvm/Support/TargetSelect.h>
+#include <llvm/Support/Threading.h>
+
+namespace art {
+void CompileOneMethod(CompilerDriver& driver,
+                      const CompilerBackend compilerBackend,
+                      const DexFile::CodeItem* code_item,
+                      uint32_t access_flags, InvokeType invoke_type,
+                      uint32_t class_def_idx, uint32_t method_idx, jobject class_loader,
+                      const DexFile& dex_file,
+                      LLVMInfo* llvm_info);
+}
+
+namespace llvm {
+  extern bool TimePassesIsEnabled;
+}
+
+namespace {
+
+pthread_once_t llvm_initialized = PTHREAD_ONCE_INIT;
+
+void InitializeLLVM() {
+  // Initialize LLVM internal data structure for multithreading
+  llvm::llvm_start_multithreaded();
+
+  // NOTE: Uncomment following line to show the time consumption of LLVM passes
+  //llvm::TimePassesIsEnabled = true;
+
+  // Initialize LLVM target-specific options.
+  art::llvm::InitialBackendOptions();
+
+  // Initialize LLVM target, MC subsystem, asm printer, and asm parser.
+#if defined(ART_TARGET)
+  // Don't initialize all targets on device. Just initialize the device's native target
+  llvm::InitializeNativeTarget();
+  llvm::InitializeNativeTargetAsmPrinter();
+  llvm::InitializeNativeTargetAsmParser();
+#else
+  llvm::InitializeAllTargets();
+  llvm::InitializeAllTargetMCs();
+  llvm::InitializeAllAsmPrinters();
+  llvm::InitializeAllAsmParsers();
+#endif
+
+  // Initialize LLVM optimization passes
+  llvm::PassRegistry &registry = *llvm::PassRegistry::getPassRegistry();
+
+  llvm::initializeCore(registry);
+  llvm::initializeScalarOpts(registry);
+  llvm::initializeIPO(registry);
+  llvm::initializeAnalysis(registry);
+  llvm::initializeIPA(registry);
+  llvm::initializeTransformUtils(registry);
+  llvm::initializeInstCombine(registry);
+  llvm::initializeInstrumentation(registry);
+  llvm::initializeTarget(registry);
+}
+
+// The Guard to Shutdown LLVM
+// llvm::llvm_shutdown_obj llvm_guard;
+// TODO: We are commenting out this line because this will cause SEGV from
+// time to time.
+// Two reasons: (1) the order of the destruction of static objects, or
+//              (2) dlopen/dlclose side-effect on static objects.
+
+} // anonymous namespace
+
+
+namespace art {
+namespace llvm {
+
+
+::llvm::Module* makeLLVMModuleContents(::llvm::Module* module);
+
+
+CompilerLLVM::CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set)
+    : compiler_driver_(driver), insn_set_(insn_set),
+      num_cunits_lock_("compilation unit counter lock"), num_cunits_(0),
+      plt_(insn_set) {
+
+  // Initialize LLVM libraries
+  pthread_once(&llvm_initialized, InitializeLLVM);
+}
+
+
+CompilerLLVM::~CompilerLLVM() {
+}
+
+
+LlvmCompilationUnit* CompilerLLVM::AllocateCompilationUnit() {
+  MutexLock GUARD(Thread::Current(), num_cunits_lock_);
+  LlvmCompilationUnit* cunit = new LlvmCompilationUnit(this, ++num_cunits_);
+  if (!bitcode_filename_.empty()) {
+    cunit->SetBitcodeFileName(StringPrintf("%s-%zu", bitcode_filename_.c_str(), cunit->GetIndex()));
+  }
+  return cunit;
+}
+
+
+CompiledMethod* CompilerLLVM::
+CompileDexMethod(DexCompilationUnit* dex_compilation_unit, InvokeType invoke_type) {
+  UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
+
+  std::string methodName(PrettyMethod(dex_compilation_unit->GetDexMethodIndex(),
+                                      *dex_compilation_unit->GetDexFile()));
+  // TODO: consolidate ArtCompileMethods
+  CompileOneMethod(*compiler_driver_,
+                   kPortable,
+                   dex_compilation_unit->GetCodeItem(),
+                   dex_compilation_unit->GetAccessFlags(),
+                   invoke_type,
+                   dex_compilation_unit->GetClassDefIndex(),
+                   dex_compilation_unit->GetDexMethodIndex(),
+                   dex_compilation_unit->GetClassLoader(),
+                   *dex_compilation_unit->GetDexFile(),
+                   cunit->GetQuickContext()
+  );
+
+  cunit->SetCompiler(compiler_driver_);
+  cunit->SetDexCompilationUnit(dex_compilation_unit);
+
+  cunit->Materialize();
+
+  CompilerDriver::MethodReference mref(dex_compilation_unit->GetDexFile(),
+                                       dex_compilation_unit->GetDexMethodIndex());
+  return new CompiledMethod(compiler_driver_->GetInstructionSet(),
+                            cunit->GetCompiledCode(),
+                            *verifier::MethodVerifier::GetDexGcMap(mref));
+}
+
+
+CompiledMethod* CompilerLLVM::
+CompileNativeMethod(DexCompilationUnit* dex_compilation_unit) {
+  UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
+
+  UniquePtr<JniCompiler> jni_compiler(
+      new JniCompiler(cunit.get(), *compiler_driver_, dex_compilation_unit));
+
+  return jni_compiler->Compile();
+}
+
+
+CompiledInvokeStub* CompilerLLVM::CreateInvokeStub(bool is_static,
+                                                   char const *shorty) {
+  UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
+
+  UniquePtr<StubCompiler> stub_compiler(
+    new StubCompiler(cunit.get(), *compiler_driver_));
+
+  return stub_compiler->CreateInvokeStub(is_static, shorty);
+}
+
+
+CompiledInvokeStub* CompilerLLVM::CreateProxyStub(char const *shorty) {
+  UniquePtr<LlvmCompilationUnit> cunit(AllocateCompilationUnit());
+
+  UniquePtr<StubCompiler> stub_compiler(
+    new StubCompiler(cunit.get(), *compiler_driver_));
+
+  return stub_compiler->CreateProxyStub(shorty);
+}
+
+} // namespace llvm
+} // namespace art
+
+inline static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) {
+  void *compiler_context = driver.GetCompilerContext();
+  CHECK(compiler_context != NULL);
+  return reinterpret_cast<art::llvm::CompilerLLVM*>(compiler_context);
+}
+
+inline static const art::llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) {
+  void *compiler_context = driver.GetCompilerContext();
+  CHECK(compiler_context != NULL);
+  return reinterpret_cast<const art::llvm::CompilerLLVM*>(compiler_context);
+}
+
+extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) {
+  CHECK(driver.GetCompilerContext() == NULL);
+
+  art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(&driver,
+                                                                       driver.GetInstructionSet());
+
+  driver.SetCompilerContext(compiler_llvm);
+}
+
+extern "C" void ArtUnInitCompilerContext(art::CompilerDriver& driver) {
+  delete ContextOf(driver);
+  driver.SetCompilerContext(NULL);
+}
+extern "C" art::CompiledMethod* ArtCompileMethod(art::CompilerDriver& driver,
+                                                 const art::DexFile::CodeItem* code_item,
+                                                 uint32_t access_flags,
+                                                 art::InvokeType invoke_type,
+                                                 uint32_t class_def_idx,
+                                                 uint32_t method_idx,
+                                                 jobject class_loader,
+                                                 const art::DexFile& dex_file) {
+  UNUSED(class_def_idx);  // TODO: this is used with Compiler::RequiresConstructorBarrier.
+  art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
+
+  art::DexCompilationUnit dex_compilation_unit(
+    class_loader, class_linker, dex_file, code_item,
+    class_def_idx, method_idx, access_flags);
+  art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+  art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type);
+  return result;
+}
+
+extern "C" art::CompiledMethod* ArtLLVMJniCompileMethod(art::CompilerDriver& driver,
+                                                        uint32_t access_flags, uint32_t method_idx,
+                                                        const art::DexFile& dex_file) {
+  art::ClassLinker *class_linker = art::Runtime::Current()->GetClassLinker();
+
+  art::DexCompilationUnit dex_compilation_unit(
+    NULL, class_linker, dex_file, NULL,
+    0, method_idx, access_flags);
+
+  art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+  art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&dex_compilation_unit);
+  return result;
+}
+
+extern "C" art::CompiledInvokeStub* ArtCreateLLVMInvokeStub(art::CompilerDriver& driver,
+                                                            bool is_static,
+                                                            const char* shorty,
+                                                            uint32_t shorty_len) {
+  art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+  art::CompiledInvokeStub* result = compiler_llvm->CreateInvokeStub(is_static, shorty);
+  return result;
+}
+
+extern "C" art::CompiledInvokeStub* ArtCreateProxyStub(art::CompilerDriver& driver,
+                                                       const char* shorty,
+                                                       uint32_t shorty_len) {
+  art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+  art::CompiledInvokeStub* result = compiler_llvm->CreateProxyStub(shorty);
+  return result;
+}
+
+extern "C" void compilerLLVMSetBitcodeFileName(art::CompilerDriver& driver,
+                                               std::string const& filename) {
+  ContextOf(driver)->SetBitcodeFileName(filename);
+}
diff --git a/src/compiler/llvm/compiler_llvm.h b/src/compiler/llvm/compiler_llvm.h
new file mode 100644
index 0000000..870a541
--- /dev/null
+++ b/src/compiler/llvm/compiler_llvm.h
@@ -0,0 +1,115 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
+#define ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
+
+#include "base/macros.h"
+#include "compiler/driver/compiler_driver.h"
+#include "dex_file.h"
+#include "instruction_set.h"
+#include "mirror/object.h"
+#include "procedure_linkage_table.h"
+
+#include <UniquePtr.h>
+
+#include <string>
+#include <utility>
+#include <vector>
+
+namespace art {
+  class CompiledInvokeStub;
+  class CompiledMethod;
+  class CompilerDriver;
+  class DexCompilationUnit;
+  namespace mirror {
+    class AbstractMethod;
+    class ClassLoader;
+  }  // namespace mirror
+}  // namespace art
+
+
+namespace llvm {
+  class Function;
+  class LLVMContext;
+  class Module;
+  class PointerType;
+  class StructType;
+  class Type;
+}  // namespace llvm
+
+
+namespace art {
+namespace llvm {
+
+class LlvmCompilationUnit;
+class IRBuilder;
+
+class CompilerLLVM {
+ public:
+  CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set);
+
+  ~CompilerLLVM();
+
+  CompilerDriver* GetCompiler() const {
+    return compiler_driver_;
+  }
+
+  InstructionSet GetInstructionSet() const {
+    return insn_set_;
+  }
+
+  void SetBitcodeFileName(std::string const& filename) {
+    bitcode_filename_ = filename;
+  }
+
+  CompiledMethod* CompileDexMethod(DexCompilationUnit* dex_compilation_unit,
+                                   InvokeType invoke_type);
+
+  CompiledMethod* CompileGBCMethod(DexCompilationUnit* dex_compilation_unit, std::string* func);
+
+  CompiledMethod* CompileNativeMethod(DexCompilationUnit* dex_compilation_unit);
+
+  CompiledInvokeStub* CreateInvokeStub(bool is_static, const char *shorty);
+
+  CompiledInvokeStub* CreateProxyStub(const char *shorty);
+
+  const ProcedureLinkageTable& GetProcedureLinkageTable() const {
+    return plt_;
+  }
+
+ private:
+  LlvmCompilationUnit* AllocateCompilationUnit();
+
+  CompilerDriver* compiler_driver_;
+
+  InstructionSet insn_set_;
+
+  Mutex num_cunits_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
+  size_t num_cunits_ GUARDED_BY(num_cunits_lock_);
+
+  std::string bitcode_filename_;
+
+  ProcedureLinkageTable plt_;
+
+  DISALLOW_COPY_AND_ASSIGN(CompilerLLVM);
+};
+
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_COMPILER_LLVM_H_
diff --git a/src/compiler/llvm/compiler_runtime_func_list.h b/src/compiler/llvm/compiler_runtime_func_list.h
new file mode 100644
index 0000000..ffbae85
--- /dev/null
+++ b/src/compiler/llvm/compiler_runtime_func_list.h
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_COMPILER_RUNTIME_FUNC_LIST_H_
+#define ART_SRC_COMPILER_LLVM_COMPILER_RUNTIME_FUNC_LIST_H_
+
+// NOTE: COMPILER_RUNTIME_FUNC_LIST_* should be sorted!
+
+#define COMPILER_RUNTIME_FUNC_LIST_X86(V) \
+  V(__ashldi3,          long long, long long, int) \
+  V(__ashrdi3,          long long, long long, int) \
+  V(__divdi3,           long long, long long, long long) \
+  V(__fixdfdi,          long long, double) \
+  V(__fixsfdi,          long long, float) \
+  V(__fixtfdi,          long long, long double) \
+  V(__fixtfsi,          int, long double) \
+  V(__fixunsdfdi,       unsigned long long, double) \
+  V(__fixunsdfsi,       unsigned int, double) \
+  V(__fixunssfdi,       unsigned long long, float) \
+  V(__fixunssfsi,       unsigned int, float) \
+  V(__fixunstfdi,       unsigned long long, long double) \
+  V(__fixunstfsi,       unsigned int, long double) \
+  V(__fixunsxfdi,       unsigned long long, long double) \
+  V(__fixunsxfsi,       unsigned int, long double) \
+  V(__fixxfdi,          long long, long double) \
+  V(__floatdidf,        double, long long) \
+  V(__floatdisf,        float, long long) \
+  V(__floatditf,        long double, long long) \
+  V(__floatdixf,        long double, long long) \
+  V(__floatsitf,        long double, int) \
+  V(__floatundidf,      double, unsigned long long) \
+  V(__floatundisf,      float, unsigned long long) \
+  V(__floatunditf,      long double, unsigned long long) \
+  V(__floatundixf,      long double, unsigned long long) \
+  V(__floatunsitf,      long double, int) \
+  V(__lshrdi3,          long long, long long, int) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__muldi3,           long long, long long, long long) \
+  V(__negdi2,           long long, long long) \
+  V(__powidf2,          double, double, int) \
+  V(__powisf2,          float, float, int) \
+  V(__powitf2,          long double, long double, int) \
+  V(__powixf2,          long double, long double, int) \
+  V(__trunctfdf2,       double, long double) \
+  V(__trunctfsf2,       float, long double) \
+  V(__udivdi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(ceil,               double, double) \
+  V(ceilf,              float, float) \
+  V(ceill,              long double, long double) \
+  V(copysign,           double, double, double) \
+  V(copysignf,          float, float, float) \
+  V(copysignl,          long double, long double, long double) \
+  V(cos,                double, double) \
+  V(cosf,               float, float) \
+  V(exp,                double, double) \
+  V(exp2,               double, double) \
+  V(exp2f,              float, float) \
+  V(expf,               float, float) \
+  V(floor,              double, double) \
+  V(floorf,             float, float) \
+  V(floorl,             long double, long double) \
+  V(fma,                double, double, double, double) \
+  V(fmaf,               float, float, float, float) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(log,                double, double) \
+  V(log10,              double, double) \
+  V(log10f,             float, float) \
+  V(logf,               float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t) \
+  V(nearbyint,          double, double) \
+  V(nearbyintf,         float, float) \
+  V(pow,                double, double, double) \
+  V(powf,               float, float, float) \
+  V(rint,               double, double) \
+  V(rintf,              float, float) \
+  V(sin,                double, double) \
+  V(sinf,               float, float) \
+  V(sqrt,               double, double) \
+  V(sqrtf,              float, float) \
+  V(trunc,              double, double) \
+  V(truncf,             float, float) \
+  V(truncl,             long double, long double)
+
+#define COMPILER_RUNTIME_FUNC_LIST_MIPS(V) \
+  V(__ashldi3,          long long, long long, int) \
+  V(__ashrdi3,          long long, long long, int) \
+  V(__divdi3,           long long, long long, long long) \
+  V(__fixdfdi,          long long, double) \
+  V(__fixsfdi,          long long, float) \
+  V(__fixunsdfdi,       unsigned long long, double) \
+  V(__fixunsdfsi,       unsigned int, double) \
+  V(__fixunssfdi,       unsigned long long, float) \
+  V(__fixunssfsi,       unsigned int, float) \
+  V(__floatdidf,        double, long long) \
+  V(__floatdisf,        float, long long) \
+  V(__floatundidf,      double, unsigned long long) \
+  V(__floatundisf,      float, unsigned long long) \
+  V(__lshrdi3,          long long, long long, int) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__muldi3,           long long, long long, long long) \
+  V(__negdi2,           long long, long long) \
+  V(__powidf2,          double, double, int) \
+  V(__powisf2,          float, float, int) \
+  V(__udivdi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(ceil,               double, double) \
+  V(ceilf,              float, float) \
+  V(ceill,              long double, long double) \
+  V(copysign,           double, double, double) \
+  V(copysignf,          float, float, float) \
+  V(copysignl,          long double, long double, long double) \
+  V(cos,                double, double) \
+  V(cosf,               float, float) \
+  V(exp,                double, double) \
+  V(exp2,               double, double) \
+  V(exp2f,              float, float) \
+  V(expf,               float, float) \
+  V(floor,              double, double) \
+  V(floorf,             float, float) \
+  V(floorl,             long double, long double) \
+  V(fma,                double, double, double, double) \
+  V(fmaf,               float, float, float, float) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(log,                double, double) \
+  V(log10,              double, double) \
+  V(log10f,             float, float) \
+  V(logf,               float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t) \
+  V(nearbyint,          double, double) \
+  V(nearbyintf,         float, float) \
+  V(pow,                double, double, double) \
+  V(powf,               float, float, float) \
+  V(rint,               double, double) \
+  V(rintf,              float, float) \
+  V(sin,                double, double) \
+  V(sinf,               float, float) \
+  V(sqrt,               double, double) \
+  V(sqrtf,              float, float) \
+  V(trunc,              double, double) \
+  V(truncf,             float, float) \
+  V(truncl,             long double, long double)
+
+#define COMPILER_RUNTIME_FUNC_LIST_ARM(V) \
+  V(__aeabi_d2f,        float, double) \
+  V(__aeabi_d2iz,       int, double) \
+  V(__aeabi_d2lz,       long long, double) \
+  V(__aeabi_d2uiz,      unsigned, double) \
+  V(__aeabi_d2ulz,      unsigned long long, double) \
+  V(__aeabi_dadd,       double, double, double) \
+  V(__aeabi_dcmpeq,     int, double, double) \
+  V(__aeabi_dcmpge,     int, double, double) \
+  V(__aeabi_dcmpgt,     int, double, double) \
+  V(__aeabi_dcmple,     int, double, double) \
+  V(__aeabi_dcmplt,     int, double, double) \
+  V(__aeabi_dcmpun,     int, double, double) \
+  V(__aeabi_ddiv,       double, double, double) \
+  V(__aeabi_dmul,       double, double, double) \
+  V(__aeabi_dsub,       double, double, double) \
+  V(__aeabi_f2d,        double, float) \
+  V(__aeabi_f2iz,       int, float) \
+  V(__aeabi_f2lz,       long long, float) \
+  V(__aeabi_f2uiz,      unsigned int, float) \
+  V(__aeabi_f2ulz,      unsigned long long, float) \
+  V(__aeabi_fadd,       float, float, float) \
+  V(__aeabi_fcmpeq,     int, float, float) \
+  V(__aeabi_fcmpge,     int, float, float) \
+  V(__aeabi_fcmpgt,     int, float, float) \
+  V(__aeabi_fcmple,     int, float, float) \
+  V(__aeabi_fcmplt,     int, float, float) \
+  V(__aeabi_fcmpun,     int, float, float) \
+  V(__aeabi_fdiv,       float, float, float) \
+  V(__aeabi_fmul,       float, float, float) \
+  V(__aeabi_fsub,       float, float, float) \
+  V(__aeabi_i2d,        double, int) \
+  V(__aeabi_i2f,        float, int) \
+  V(__aeabi_idiv,       int, int, int) \
+  V(__aeabi_l2d,        double, long long) \
+  V(__aeabi_l2f,        float, long long) \
+  V(__aeabi_lasr,       long long, long long, int) \
+  V(__aeabi_ldivmod,    /* value in regs */ void, long long, long long) \
+  V(__aeabi_llsl,       long long, long long, int) \
+  V(__aeabi_llsr,       long long, long long, int) \
+  V(__aeabi_lmul,       long long, long long, long long) \
+  V(__aeabi_memcpy,     void, void *, const void *, size_t) \
+  V(__aeabi_memmove,    void, void *, const void *, size_t) \
+  V(__aeabi_memset,     void, void *, size_t, int) /* different from stdlib */ \
+  V(__aeabi_ui2d,       double, unsigned int) \
+  V(__aeabi_ui2f,       float, unsigned int) \
+  V(__aeabi_uidiv,      unsigned int, unsigned int, unsigned int) \
+  V(__aeabi_ul2d,       double, unsigned long long) \
+  V(__aeabi_ul2f,       float, unsigned long long) \
+  V(__aeabi_uldivmod,   /* value in regs */ void, unsigned long long, unsigned long long) \
+  V(__moddi3,           long long, long long, long long) \
+  V(__modsi3,           int, int, int) \
+  V(__umoddi3,          unsigned long long, unsigned long long, unsigned long long) \
+  V(__umodsi3,          unsigned int, unsigned int, unsigned int) \
+  V(fmod,               double, double, double) \
+  V(fmodf,              float, float, float) \
+  V(memcpy,             void *, void *, const void *, size_t) \
+  V(memmove,            void *, void *, const void *, size_t) \
+  V(memset,             void *, void *, int, size_t)
+
+
+#if defined(__arm__)
+#define COMPILER_RUNTIME_FUNC_LIST_NATIVE(V) COMPILER_RUNTIME_FUNC_LIST_ARM(V)
+#elif defined(__mips__)
+#define COMPILER_RUNTIME_FUNC_LIST_NATIVE(V) COMPILER_RUNTIME_FUNC_LIST_MIPS(V)
+#elif defined(__i386__)
+#define COMPILER_RUNTIME_FUNC_LIST_NATIVE(V) COMPILER_RUNTIME_FUNC_LIST_X86(V)
+#else
+#error "Unknown target platform"
+#endif
+
+#endif // ART_SRC_COMPILER_LLVM_COMPILER_RUNTIME_FUNC_LIST_H_
diff --git a/src/compiler/llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
new file mode 100644
index 0000000..4e1a91d
--- /dev/null
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -0,0 +1,3642 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "compiler/driver/compiler_driver.h"
+#include "compiler/driver/dex_compilation_unit.h"
+#include "intrinsic_helper.h"
+#include "ir_builder.h"
+#include "mirror/abstract_method.h"
+#include "mirror/array.h"
+#include "thread.h"
+#include "utils_llvm.h"
+#include "verifier/method_verifier.h"
+
+#include "compiler/dex/compiler_ir.h"
+#include "compiler/dex/quick/codegen.h"
+using art::kMIRIgnoreNullCheck;
+using art::kMIRIgnoreRangeCheck;
+
+#include <llvm/ADT/STLExtras.h>
+#include <llvm/Intrinsics.h>
+#include <llvm/Metadata.h>
+#include <llvm/Pass.h>
+#include <llvm/Support/CFG.h>
+#include <llvm/Support/InstIterator.h>
+
+#include <vector>
+#include <map>
+#include <utility>
+
+using namespace art::llvm;
+
+using art::llvm::IntrinsicHelper;
+
+namespace art {
+extern char RemapShorty(char shortyType);
+};
+
+namespace {
+
+class GBCExpanderPass : public llvm::FunctionPass {
+ private:
+  const IntrinsicHelper& intrinsic_helper_;
+  IRBuilder& irb_;
+
+  llvm::LLVMContext& context_;
+  RuntimeSupportBuilder& rtb_;
+
+ private:
+  llvm::AllocaInst* shadow_frame_;
+  llvm::Value* old_shadow_frame_;
+
+ private:
+  art::CompilerDriver* const driver_;
+
+  const art::DexCompilationUnit* const dex_compilation_unit_;
+
+  llvm::Function* func_;
+
+  std::vector<llvm::BasicBlock*> basic_blocks_;
+
+  std::vector<llvm::BasicBlock*> basic_block_landing_pads_;
+  llvm::BasicBlock* current_bb_;
+  std::map<llvm::BasicBlock*, std::vector<std::pair<llvm::BasicBlock*, llvm::BasicBlock*> > >
+      landing_pad_phi_mapping_;
+  llvm::BasicBlock* basic_block_unwind_;
+
+  bool changed_;
+
+ private:
+  //----------------------------------------------------------------------------
+  // Constant for GBC expansion
+  //----------------------------------------------------------------------------
+  enum IntegerShiftKind {
+    kIntegerSHL,
+    kIntegerSHR,
+    kIntegerUSHR,
+  };
+
+ private:
+  //----------------------------------------------------------------------------
+  // Helper function for GBC expansion
+  //----------------------------------------------------------------------------
+
+  llvm::Value* ExpandToRuntime(runtime_support::RuntimeId rt,
+                               llvm::CallInst& inst);
+
+  uint64_t LV2UInt(llvm::Value* lv) {
+    return llvm::cast<llvm::ConstantInt>(lv)->getZExtValue();
+  }
+
+  int64_t LV2SInt(llvm::Value* lv) {
+    return llvm::cast<llvm::ConstantInt>(lv)->getSExtValue();
+  }
+
+ private:
+  // TODO: Almost all Emit* are directly copy-n-paste from MethodCompiler.
+  // Refactor these utility functions from MethodCompiler to avoid forking.
+
+  void EmitStackOverflowCheck(llvm::Instruction* first_non_alloca);
+
+  void RewriteFunction();
+
+  void RewriteBasicBlock(llvm::BasicBlock* original_block);
+
+  void UpdatePhiInstruction(llvm::BasicBlock* old_basic_block,
+                            llvm::BasicBlock* new_basic_block);
+
+
+  // Sign or zero extend category 1 types < 32bits in size to 32bits.
+  llvm::Value* SignOrZeroExtendCat1Types(llvm::Value* value, JType jty);
+
+  // Truncate category 1 types from 32bits to the given JType size.
+  llvm::Value* TruncateCat1Types(llvm::Value* value, JType jty);
+
+  //----------------------------------------------------------------------------
+  // Dex cache code generation helper function
+  //----------------------------------------------------------------------------
+  llvm::Value* EmitLoadDexCacheAddr(art::MemberOffset dex_cache_offset);
+
+  llvm::Value* EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx);
+
+  llvm::Value* EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx);
+
+  llvm::Value* EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx);
+
+  llvm::Value* EmitLoadDexCacheStringFieldAddr(uint32_t string_idx);
+
+  //----------------------------------------------------------------------------
+  // Code generation helper function
+  //----------------------------------------------------------------------------
+  llvm::Value* EmitLoadMethodObjectAddr();
+
+  llvm::Value* EmitLoadArrayLength(llvm::Value* array);
+
+  llvm::Value* EmitLoadSDCalleeMethodObjectAddr(uint32_t callee_method_idx);
+
+  llvm::Value* EmitLoadVirtualCalleeMethodObjectAddr(int vtable_idx,
+                                                     llvm::Value* this_addr);
+
+  llvm::Value* EmitArrayGEP(llvm::Value* array_addr,
+                            llvm::Value* index_value,
+                            JType elem_jty);
+
+ private:
+  //----------------------------------------------------------------------------
+  // Expand Greenland intrinsics
+  //----------------------------------------------------------------------------
+  void Expand_TestSuspend(llvm::CallInst& call_inst);
+
+  void Expand_MarkGCCard(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_LoadStringFromDexCache(llvm::Value* string_idx_value);
+
+  llvm::Value* Expand_LoadTypeFromDexCache(llvm::Value* type_idx_value);
+
+  void Expand_LockObject(llvm::Value* obj);
+
+  void Expand_UnlockObject(llvm::Value* obj);
+
+  llvm::Value* Expand_ArrayGet(llvm::Value* array_addr,
+                               llvm::Value* index_value,
+                               JType elem_jty);
+
+  void Expand_ArrayPut(llvm::Value* new_value,
+                       llvm::Value* array_addr,
+                       llvm::Value* index_value,
+                       JType elem_jty);
+
+  void Expand_FilledNewArray(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_IGetFast(llvm::Value* field_offset_value,
+                               llvm::Value* is_volatile_value,
+                               llvm::Value* object_addr,
+                               JType field_jty);
+
+  void Expand_IPutFast(llvm::Value* field_offset_value,
+                       llvm::Value* is_volatile_value,
+                       llvm::Value* object_addr,
+                       llvm::Value* new_value,
+                       JType field_jty);
+
+  llvm::Value* Expand_SGetFast(llvm::Value* static_storage_addr,
+                               llvm::Value* field_offset_value,
+                               llvm::Value* is_volatile_value,
+                               JType field_jty);
+
+  void Expand_SPutFast(llvm::Value* static_storage_addr,
+                       llvm::Value* field_offset_value,
+                       llvm::Value* is_volatile_value,
+                       llvm::Value* new_value,
+                       JType field_jty);
+
+  llvm::Value* Expand_LoadDeclaringClassSSB(llvm::Value* method_object_addr);
+
+  llvm::Value* Expand_LoadClassSSBFromDexCache(llvm::Value* type_idx_value);
+
+  llvm::Value*
+  Expand_GetSDCalleeMethodObjAddrFast(llvm::Value* callee_method_idx_value);
+
+  llvm::Value*
+  Expand_GetVirtualCalleeMethodObjAddrFast(llvm::Value* vtable_idx_value,
+                                           llvm::Value* this_addr);
+
+  llvm::Value* Expand_Invoke(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_DivRem(llvm::CallInst& call_inst, bool is_div, JType op_jty);
+
+  void Expand_AllocaShadowFrame(llvm::Value* num_vregs_value);
+
+  void Expand_SetVReg(llvm::Value* entry_idx, llvm::Value* obj);
+
+  void Expand_PopShadowFrame();
+
+  void Expand_UpdateDexPC(llvm::Value* dex_pc_value);
+
+  //----------------------------------------------------------------------------
+  // Quick
+  //----------------------------------------------------------------------------
+
+  llvm::Value* Expand_FPCompare(llvm::Value* src1_value,
+                                llvm::Value* src2_value,
+                                bool gt_bias);
+
+  llvm::Value* Expand_LongCompare(llvm::Value* src1_value, llvm::Value* src2_value);
+
+  llvm::Value* EmitCompareResultSelection(llvm::Value* cmp_eq,
+                                          llvm::Value* cmp_lt);
+
+  llvm::Value* EmitLoadConstantClass(uint32_t dex_pc, uint32_t type_idx);
+  llvm::Value* EmitLoadStaticStorage(uint32_t dex_pc, uint32_t type_idx);
+
+  llvm::Value* Expand_HLIGet(llvm::CallInst& call_inst, JType field_jty);
+  void Expand_HLIPut(llvm::CallInst& call_inst, JType field_jty);
+
+  llvm::Value* Expand_HLSget(llvm::CallInst& call_inst, JType field_jty);
+  void Expand_HLSput(llvm::CallInst& call_inst, JType field_jty);
+
+  llvm::Value* Expand_HLArrayGet(llvm::CallInst& call_inst, JType field_jty);
+  void Expand_HLArrayPut(llvm::CallInst& call_inst, JType field_jty);
+
+  llvm::Value* Expand_ConstString(llvm::CallInst& call_inst);
+  llvm::Value* Expand_ConstClass(llvm::CallInst& call_inst);
+
+  void Expand_MonitorEnter(llvm::CallInst& call_inst);
+  void Expand_MonitorExit(llvm::CallInst& call_inst);
+
+  void Expand_HLCheckCast(llvm::CallInst& call_inst);
+  llvm::Value* Expand_InstanceOf(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_NewInstance(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_HLInvoke(llvm::CallInst& call_inst);
+
+  llvm::Value* Expand_OptArrayLength(llvm::CallInst& call_inst);
+  llvm::Value* Expand_NewArray(llvm::CallInst& call_inst);
+  llvm::Value* Expand_HLFilledNewArray(llvm::CallInst& call_inst);
+  void Expand_HLFillArrayData(llvm::CallInst& call_inst);
+
+  llvm::Value* EmitAllocNewArray(uint32_t dex_pc,
+                                 llvm::Value* array_length_value,
+                                 uint32_t type_idx,
+                                 bool is_filled_new_array);
+
+  llvm::Value* EmitCallRuntimeForCalleeMethodObjectAddr(uint32_t callee_method_idx,
+                                                        art::InvokeType invoke_type,
+                                                        llvm::Value* this_addr,
+                                                        uint32_t dex_pc,
+                                                        bool is_fast_path);
+
+  void EmitMarkGCCard(llvm::Value* value, llvm::Value* target_addr);
+
+  void EmitUpdateDexPC(uint32_t dex_pc);
+
+  void EmitGuard_DivZeroException(uint32_t dex_pc,
+                                  llvm::Value* denominator,
+                                  JType op_jty);
+
+  void EmitGuard_NullPointerException(uint32_t dex_pc, llvm::Value* object,
+                                      int opt_flags);
+
+  void EmitGuard_ArrayIndexOutOfBoundsException(uint32_t dex_pc,
+                                                llvm::Value* array,
+                                                llvm::Value* index,
+                                                int opt_flags);
+
+  llvm::FunctionType* GetFunctionType(llvm::Type* ret_type, uint32_t method_idx, bool is_static);
+
+  llvm::BasicBlock* GetBasicBlock(uint32_t dex_pc);
+
+  llvm::BasicBlock* CreateBasicBlockWithDexPC(uint32_t dex_pc,
+                                              const char* postfix);
+
+  int32_t GetTryItemOffset(uint32_t dex_pc);
+
+  llvm::BasicBlock* GetLandingPadBasicBlock(uint32_t dex_pc);
+
+  llvm::BasicBlock* GetUnwindBasicBlock();
+
+  void EmitGuard_ExceptionLandingPad(uint32_t dex_pc);
+
+  void EmitBranchExceptionLandingPad(uint32_t dex_pc);
+
+  //----------------------------------------------------------------------------
+  // Expand Arithmetic Helper Intrinsics
+  //----------------------------------------------------------------------------
+
+  llvm::Value* Expand_IntegerShift(llvm::Value* src1_value,
+                                   llvm::Value* src2_value,
+                                   IntegerShiftKind kind,
+                                   JType op_jty);
+
+ public:
+  static char ID;
+
+  GBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
+                  art::CompilerDriver* compiler, art::DexCompilationUnit* dex_compilation_unit)
+      : llvm::FunctionPass(ID), intrinsic_helper_(intrinsic_helper), irb_(irb),
+        context_(irb.getContext()), rtb_(irb.Runtime()),
+        shadow_frame_(NULL), old_shadow_frame_(NULL),
+        driver_(compiler),
+        dex_compilation_unit_(dex_compilation_unit),
+        func_(NULL), current_bb_(NULL), basic_block_unwind_(NULL), changed_(false) {}
+
+  bool runOnFunction(llvm::Function& func);
+
+ private:
+  void InsertStackOverflowCheck(llvm::Function& func);
+
+  llvm::Value* ExpandIntrinsic(IntrinsicHelper::IntrinsicId intr_id,
+                               llvm::CallInst& call_inst);
+
+};
+
+char GBCExpanderPass::ID = 0;
+
+bool GBCExpanderPass::runOnFunction(llvm::Function& func) {
+  VLOG(compiler) << "GBC expansion on " << func.getName().str();
+
+  // Runtime support or stub
+  if (func.getName().startswith("art_") || func.getName().startswith("Art")) {
+    return false;
+  }
+
+  // Setup rewrite context
+  shadow_frame_ = NULL;
+  old_shadow_frame_ = NULL;
+  func_ = &func;
+  changed_ = false; // Assume unchanged
+
+  basic_blocks_.resize(dex_compilation_unit_->GetCodeItem()->insns_size_in_code_units_);
+  basic_block_landing_pads_.resize(dex_compilation_unit_->GetCodeItem()->tries_size_, NULL);
+  basic_block_unwind_ = NULL;
+  for (llvm::Function::iterator bb_iter = func_->begin(), bb_end = func_->end();
+       bb_iter != bb_end;
+       ++bb_iter) {
+    if (bb_iter->begin()->getMetadata("DexOff") == NULL) {
+      continue;
+    }
+    uint32_t dex_pc = LV2UInt(bb_iter->begin()->getMetadata("DexOff")->getOperand(0));
+    basic_blocks_[dex_pc] = bb_iter;
+  }
+
+  // Insert stack overflow check
+  InsertStackOverflowCheck(func); // TODO: Use intrinsic.
+
+  // Rewrite the intrinsics
+  RewriteFunction();
+
+  VERIFY_LLVM_FUNCTION(func);
+
+  return changed_;
+}
+
+void GBCExpanderPass::RewriteBasicBlock(llvm::BasicBlock* original_block) {
+  llvm::BasicBlock* curr_basic_block = original_block;
+
+  llvm::BasicBlock::iterator inst_iter = original_block->begin();
+  llvm::BasicBlock::iterator inst_end = original_block->end();
+
+  while (inst_iter != inst_end) {
+    llvm::CallInst* call_inst = llvm::dyn_cast<llvm::CallInst>(inst_iter);
+    IntrinsicHelper::IntrinsicId intr_id = IntrinsicHelper::UnknownId;
+
+    if (call_inst) {
+      llvm::Function* callee_func = call_inst->getCalledFunction();
+      intr_id = intrinsic_helper_.GetIntrinsicId(callee_func);
+    }
+
+    if (intr_id == IntrinsicHelper::UnknownId) {
+      // This is not intrinsic call.  Skip this instruction.
+      ++inst_iter;
+      continue;
+    }
+
+    // Rewrite the intrinsic and change the function
+    changed_ = true;
+    irb_.SetInsertPoint(inst_iter);
+
+    // Expand the intrinsic
+    if (llvm::Value* new_value = ExpandIntrinsic(intr_id, *call_inst)) {
+      inst_iter->replaceAllUsesWith(new_value);
+    }
+
+    // Remove the old intrinsic call instruction
+    llvm::BasicBlock::iterator old_inst = inst_iter++;
+    old_inst->eraseFromParent();
+
+    // Splice the instruction to the new basic block
+    llvm::BasicBlock* next_basic_block = irb_.GetInsertBlock();
+    if (next_basic_block != curr_basic_block) {
+      next_basic_block->getInstList().splice(
+          irb_.GetInsertPoint(), curr_basic_block->getInstList(),
+          inst_iter, inst_end);
+      curr_basic_block = next_basic_block;
+      inst_end = curr_basic_block->end();
+    }
+  }
+}
+
+
+void GBCExpanderPass::RewriteFunction() {
+  size_t num_basic_blocks = func_->getBasicBlockList().size();
+  // NOTE: We are not using (bb_iter != bb_end) as the for-loop condition,
+  // because we will create new basic block while expanding the intrinsics.
+  // We only want to iterate through the input basic blocks.
+
+  landing_pad_phi_mapping_.clear();
+
+  for (llvm::Function::iterator bb_iter = func_->begin();
+       num_basic_blocks > 0; ++bb_iter, --num_basic_blocks) {
+    // Set insert point to current basic block.
+    irb_.SetInsertPoint(bb_iter);
+
+    current_bb_ = bb_iter;
+
+    // Rewrite the basic block
+    RewriteBasicBlock(bb_iter);
+
+    // Update the phi-instructions in the successor basic block
+    llvm::BasicBlock* last_block = irb_.GetInsertBlock();
+    if (last_block != bb_iter) {
+      UpdatePhiInstruction(bb_iter, last_block);
+    }
+  }
+
+  typedef std::map<llvm::PHINode*, llvm::PHINode*> HandlerPHIMap;
+  HandlerPHIMap handler_phi;
+  // Iterate every used landing pad basic block
+  for (size_t i = 0, ei = basic_block_landing_pads_.size(); i != ei; ++i) {
+    llvm::BasicBlock* lbb = basic_block_landing_pads_[i];
+    if (lbb == NULL) {
+      continue;
+    }
+
+    llvm::TerminatorInst* term_inst = lbb->getTerminator();
+    std::vector<std::pair<llvm::BasicBlock*, llvm::BasicBlock*> >& rewrite_pair
+        = landing_pad_phi_mapping_[lbb];
+    irb_.SetInsertPoint(lbb->begin());
+
+    // Iterate every succeeding basic block (catch block)
+    for (unsigned succ_iter = 0, succ_end = term_inst->getNumSuccessors();
+         succ_iter != succ_end; ++succ_iter) {
+      llvm::BasicBlock* succ_basic_block = term_inst->getSuccessor(succ_iter);
+
+      // Iterate every phi instructions in the succeeding basic block
+      for (llvm::BasicBlock::iterator
+           inst_iter = succ_basic_block->begin(),
+           inst_end = succ_basic_block->end();
+           inst_iter != inst_end; ++inst_iter) {
+        llvm::PHINode *phi = llvm::dyn_cast<llvm::PHINode>(inst_iter);
+
+        if (!phi) {
+          break; // Meet non-phi instruction.  Done.
+        }
+
+        if (handler_phi[phi] == NULL) {
+          handler_phi[phi] = llvm::PHINode::Create(phi->getType(), 1);
+        }
+
+        // Create new_phi in landing pad
+        llvm::PHINode* new_phi = irb_.CreatePHI(phi->getType(), rewrite_pair.size());
+        // Insert all incoming value into new_phi by rewrite_pair
+        for (size_t j = 0, ej = rewrite_pair.size(); j != ej; ++j) {
+          llvm::BasicBlock* old_bb = rewrite_pair[j].first;
+          llvm::BasicBlock* new_bb = rewrite_pair[j].second;
+          new_phi->addIncoming(phi->getIncomingValueForBlock(old_bb), new_bb);
+        }
+        // Delete all incoming value from phi by rewrite_pair
+        for (size_t j = 0, ej = rewrite_pair.size(); j != ej; ++j) {
+          llvm::BasicBlock* old_bb = rewrite_pair[j].first;
+          int old_bb_idx = phi->getBasicBlockIndex(old_bb);
+          if (old_bb_idx >= 0) {
+            phi->removeIncomingValue(old_bb_idx, false);
+          }
+        }
+        // Insert new_phi into new handler phi
+        handler_phi[phi]->addIncoming(new_phi, lbb);
+      }
+    }
+  }
+
+  // Replace all handler phi
+  // We can't just use the old handler phi, because some exception edges will disappear after we
+  // compute fast-path.
+  for (HandlerPHIMap::iterator it = handler_phi.begin(); it != handler_phi.end(); ++it) {
+    llvm::PHINode* old_phi = it->first;
+    llvm::PHINode* new_phi = it->second;
+    new_phi->insertBefore(old_phi);
+    old_phi->replaceAllUsesWith(new_phi);
+    old_phi->eraseFromParent();
+  }
+}
+
+void GBCExpanderPass::UpdatePhiInstruction(llvm::BasicBlock* old_basic_block,
+                                           llvm::BasicBlock* new_basic_block) {
+  llvm::TerminatorInst* term_inst = new_basic_block->getTerminator();
+
+  if (!term_inst) {
+    return; // No terminating instruction in new_basic_block.  Nothing to do.
+  }
+
+  // Iterate every succeeding basic block
+  for (unsigned succ_iter = 0, succ_end = term_inst->getNumSuccessors();
+       succ_iter != succ_end; ++succ_iter) {
+    llvm::BasicBlock* succ_basic_block = term_inst->getSuccessor(succ_iter);
+
+    // Iterate every phi instructions in the succeeding basic block
+    for (llvm::BasicBlock::iterator
+         inst_iter = succ_basic_block->begin(),
+         inst_end = succ_basic_block->end();
+         inst_iter != inst_end; ++inst_iter) {
+      llvm::PHINode *phi = llvm::dyn_cast<llvm::PHINode>(inst_iter);
+
+      if (!phi) {
+        break; // Meet non-phi instruction.  Done.
+      }
+
+      // Update the incoming block of this phi instruction
+      for (llvm::PHINode::block_iterator
+           ibb_iter = phi->block_begin(), ibb_end = phi->block_end();
+           ibb_iter != ibb_end; ++ibb_iter) {
+        if (*ibb_iter == old_basic_block) {
+          *ibb_iter = new_basic_block;
+        }
+      }
+    }
+  }
+}
+
+llvm::Value* GBCExpanderPass::ExpandToRuntime(runtime_support::RuntimeId rt,
+                                              llvm::CallInst& inst) {
+  // Some GBC intrinsic can directly replace with IBC runtime. "Directly" means
+  // the arguments passed to the GBC intrinsic are as the same as IBC runtime
+  // function, therefore only called function is needed to change.
+  unsigned num_args = inst.getNumArgOperands();
+
+  if (num_args <= 0) {
+    return irb_.CreateCall(irb_.GetRuntime(rt));
+  } else {
+    std::vector<llvm::Value*> args;
+    for (unsigned i = 0; i < num_args; i++) {
+      args.push_back(inst.getArgOperand(i));
+    }
+
+    return irb_.CreateCall(irb_.GetRuntime(rt), args);
+  }
+}
+
+void
+GBCExpanderPass::EmitStackOverflowCheck(llvm::Instruction* first_non_alloca) {
+  llvm::Function* func = first_non_alloca->getParent()->getParent();
+  llvm::Module* module = func->getParent();
+
+  // Call llvm intrinsic function to get frame address.
+  llvm::Function* frameaddress =
+      llvm::Intrinsic::getDeclaration(module, llvm::Intrinsic::frameaddress);
+
+  // The type of llvm::frameaddress is: i8* @llvm.frameaddress(i32)
+  llvm::Value* frame_address = irb_.CreateCall(frameaddress, irb_.getInt32(0));
+
+  // Cast i8* to int
+  frame_address = irb_.CreatePtrToInt(frame_address, irb_.getPtrEquivIntTy());
+
+  // Get thread.stack_end_
+  llvm::Value* stack_end =
+    irb_.Runtime().EmitLoadFromThreadOffset(art::Thread::StackEndOffset().Int32Value(),
+                                            irb_.getPtrEquivIntTy(),
+                                            kTBAARuntimeInfo);
+
+  // Check the frame address < thread.stack_end_ ?
+  llvm::Value* is_stack_overflow = irb_.CreateICmpULT(frame_address, stack_end);
+
+  llvm::BasicBlock* block_exception =
+      llvm::BasicBlock::Create(context_, "stack_overflow", func);
+
+  llvm::BasicBlock* block_continue =
+      llvm::BasicBlock::Create(context_, "stack_overflow_cont", func);
+
+  irb_.CreateCondBr(is_stack_overflow, block_exception, block_continue, kUnlikely);
+
+  // If stack overflow, throw exception.
+  irb_.SetInsertPoint(block_exception);
+  irb_.CreateCall(irb_.GetRuntime(runtime_support::ThrowStackOverflowException));
+
+  // Unwind.
+  llvm::Type* ret_type = func->getReturnType();
+  if (ret_type->isVoidTy()) {
+    irb_.CreateRetVoid();
+  } else {
+    // The return value is ignored when there's an exception. MethodCompiler
+    // returns zero value under the the corresponding return type  in this case.
+    // GBCExpander returns LLVM undef value here for brevity
+    irb_.CreateRet(llvm::UndefValue::get(ret_type));
+  }
+
+  irb_.SetInsertPoint(block_continue);
+}
+
+llvm::Value* GBCExpanderPass::EmitLoadDexCacheAddr(art::MemberOffset offset) {
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  return irb_.LoadFromObjectOffset(method_object_addr,
+                                   offset.Int32Value(),
+                                   irb_.getJObjectTy(),
+                                   kTBAAConstJObject);
+}
+
+llvm::Value*
+GBCExpanderPass::EmitLoadDexCacheStaticStorageFieldAddr(uint32_t type_idx) {
+  llvm::Value* static_storage_dex_cache_addr =
+    EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheInitializedStaticStorageOffset());
+
+  llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
+
+  return EmitArrayGEP(static_storage_dex_cache_addr, type_idx_value, kObject);
+}
+
+llvm::Value*
+GBCExpanderPass::EmitLoadDexCacheResolvedTypeFieldAddr(uint32_t type_idx) {
+  llvm::Value* resolved_type_dex_cache_addr =
+    EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedTypesOffset());
+
+  llvm::Value* type_idx_value = irb_.getPtrEquivInt(type_idx);
+
+  return EmitArrayGEP(resolved_type_dex_cache_addr, type_idx_value, kObject);
+}
+
+llvm::Value* GBCExpanderPass::
+EmitLoadDexCacheResolvedMethodFieldAddr(uint32_t method_idx) {
+  llvm::Value* resolved_method_dex_cache_addr =
+    EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheResolvedMethodsOffset());
+
+  llvm::Value* method_idx_value = irb_.getPtrEquivInt(method_idx);
+
+  return EmitArrayGEP(resolved_method_dex_cache_addr, method_idx_value, kObject);
+}
+
+llvm::Value* GBCExpanderPass::
+EmitLoadDexCacheStringFieldAddr(uint32_t string_idx) {
+  llvm::Value* string_dex_cache_addr =
+    EmitLoadDexCacheAddr(art::mirror::AbstractMethod::DexCacheStringsOffset());
+
+  llvm::Value* string_idx_value = irb_.getPtrEquivInt(string_idx);
+
+  return EmitArrayGEP(string_dex_cache_addr, string_idx_value, kObject);
+}
+
+llvm::Value* GBCExpanderPass::EmitLoadMethodObjectAddr() {
+  llvm::Function* parent_func = irb_.GetInsertBlock()->getParent();
+  return parent_func->arg_begin();
+}
+
+llvm::Value* GBCExpanderPass::EmitLoadArrayLength(llvm::Value* array) {
+  // Load array length
+  return irb_.LoadFromObjectOffset(array,
+                                   art::mirror::Array::LengthOffset().Int32Value(),
+                                   irb_.getJIntTy(),
+                                   kTBAAConstJObject);
+
+}
+
+llvm::Value*
+GBCExpanderPass::EmitLoadSDCalleeMethodObjectAddr(uint32_t callee_method_idx) {
+  llvm::Value* callee_method_object_field_addr =
+    EmitLoadDexCacheResolvedMethodFieldAddr(callee_method_idx);
+
+  return irb_.CreateLoad(callee_method_object_field_addr, kTBAARuntimeInfo);
+}
+
+llvm::Value* GBCExpanderPass::
+EmitLoadVirtualCalleeMethodObjectAddr(int vtable_idx, llvm::Value* this_addr) {
+  // Load class object of *this* pointer
+  llvm::Value* class_object_addr =
+    irb_.LoadFromObjectOffset(this_addr,
+                              art::mirror::Object::ClassOffset().Int32Value(),
+                              irb_.getJObjectTy(),
+                              kTBAAConstJObject);
+
+  // Load vtable address
+  llvm::Value* vtable_addr =
+    irb_.LoadFromObjectOffset(class_object_addr,
+                              art::mirror::Class::VTableOffset().Int32Value(),
+                              irb_.getJObjectTy(),
+                              kTBAAConstJObject);
+
+  // Load callee method object
+  llvm::Value* vtable_idx_value =
+    irb_.getPtrEquivInt(static_cast<uint64_t>(vtable_idx));
+
+  llvm::Value* method_field_addr =
+    EmitArrayGEP(vtable_addr, vtable_idx_value, kObject);
+
+  return irb_.CreateLoad(method_field_addr, kTBAAConstJObject);
+}
+
+// Emit Array GetElementPtr
+llvm::Value* GBCExpanderPass::EmitArrayGEP(llvm::Value* array_addr,
+                                           llvm::Value* index_value,
+                                           JType elem_jty) {
+
+  int data_offset;
+  if (elem_jty == kLong || elem_jty == kDouble ||
+      (elem_jty == kObject && sizeof(uint64_t) == sizeof(art::mirror::Object*))) {
+    data_offset = art::mirror::Array::DataOffset(sizeof(int64_t)).Int32Value();
+  } else {
+    data_offset = art::mirror::Array::DataOffset(sizeof(int32_t)).Int32Value();
+  }
+
+  llvm::Constant* data_offset_value =
+    irb_.getPtrEquivInt(data_offset);
+
+  llvm::Type* elem_type = irb_.getJType(elem_jty);
+
+  llvm::Value* array_data_addr =
+    irb_.CreatePtrDisp(array_addr, data_offset_value,
+                       elem_type->getPointerTo());
+
+  return irb_.CreateGEP(array_data_addr, index_value);
+}
+
+void GBCExpanderPass::Expand_TestSuspend(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+
+  llvm::Value* suspend_count =
+      irb_.Runtime().EmitLoadFromThreadOffset(art::Thread::ThreadFlagsOffset().Int32Value(),
+                                              irb_.getInt16Ty(),
+                                              kTBAARuntimeInfo);
+  llvm::Value* is_suspend = irb_.CreateICmpNE(suspend_count, irb_.getInt16(0));
+
+  llvm::BasicBlock* basic_block_suspend = CreateBasicBlockWithDexPC(dex_pc, "suspend");
+  llvm::BasicBlock* basic_block_cont = CreateBasicBlockWithDexPC(dex_pc, "suspend_cont");
+
+  irb_.CreateCondBr(is_suspend, basic_block_suspend, basic_block_cont, kUnlikely);
+
+  irb_.SetInsertPoint(basic_block_suspend);
+  if (dex_pc != art::DexFile::kDexNoIndex) {
+    EmitUpdateDexPC(dex_pc);
+  }
+  irb_.Runtime().EmitTestSuspend();
+
+  llvm::BasicBlock* basic_block_exception = CreateBasicBlockWithDexPC(dex_pc, "exception");
+  llvm::Value* exception_pending = irb_.Runtime().EmitIsExceptionPending();
+  irb_.CreateCondBr(exception_pending, basic_block_exception, basic_block_cont, kUnlikely);
+
+  irb_.SetInsertPoint(basic_block_exception);
+  llvm::Type* ret_type = call_inst.getParent()->getParent()->getReturnType();
+  if (ret_type->isVoidTy()) {
+    irb_.CreateRetVoid();
+  } else {
+    // The return value is ignored when there's an exception.
+    irb_.CreateRet(llvm::UndefValue::get(ret_type));
+  }
+
+  irb_.SetInsertPoint(basic_block_cont);
+  return;
+}
+
+void GBCExpanderPass::Expand_MarkGCCard(llvm::CallInst& call_inst) {
+  irb_.Runtime().EmitMarkGCCard(call_inst.getArgOperand(0), call_inst.getArgOperand(1));
+  return;
+}
+
+llvm::Value*
+GBCExpanderPass::Expand_LoadStringFromDexCache(llvm::Value* string_idx_value) {
+  uint32_t string_idx =
+    llvm::cast<llvm::ConstantInt>(string_idx_value)->getZExtValue();
+
+  llvm::Value* string_field_addr = EmitLoadDexCacheStringFieldAddr(string_idx);
+
+  return irb_.CreateLoad(string_field_addr, kTBAARuntimeInfo);
+}
+
+llvm::Value*
+GBCExpanderPass::Expand_LoadTypeFromDexCache(llvm::Value* type_idx_value) {
+  uint32_t type_idx =
+    llvm::cast<llvm::ConstantInt>(type_idx_value)->getZExtValue();
+
+  llvm::Value* type_field_addr =
+    EmitLoadDexCacheResolvedTypeFieldAddr(type_idx);
+
+  return irb_.CreateLoad(type_field_addr, kTBAARuntimeInfo);
+}
+
+void GBCExpanderPass::Expand_LockObject(llvm::Value* obj) {
+  rtb_.EmitLockObject(obj);
+  return;
+}
+
+void GBCExpanderPass::Expand_UnlockObject(llvm::Value* obj) {
+  rtb_.EmitUnlockObject(obj);
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_ArrayGet(llvm::Value* array_addr,
+                                              llvm::Value* index_value,
+                                              JType elem_jty) {
+  llvm::Value* array_elem_addr =
+    EmitArrayGEP(array_addr, index_value, elem_jty);
+
+  return irb_.CreateLoad(array_elem_addr, kTBAAHeapArray, elem_jty);
+}
+
+void GBCExpanderPass::Expand_ArrayPut(llvm::Value* new_value,
+                                      llvm::Value* array_addr,
+                                      llvm::Value* index_value,
+                                      JType elem_jty) {
+  llvm::Value* array_elem_addr =
+    EmitArrayGEP(array_addr, index_value, elem_jty);
+
+  irb_.CreateStore(new_value, array_elem_addr, kTBAAHeapArray, elem_jty);
+
+  return;
+}
+
+void GBCExpanderPass::Expand_FilledNewArray(llvm::CallInst& call_inst) {
+  // Most of the codes refer to MethodCompiler::EmitInsn_FilledNewArray
+  llvm::Value* array = call_inst.getArgOperand(0);
+
+  uint32_t element_jty =
+    llvm::cast<llvm::ConstantInt>(call_inst.getArgOperand(1))->getZExtValue();
+
+  DCHECK(call_inst.getNumArgOperands() > 2);
+  unsigned num_elements = (call_inst.getNumArgOperands() - 2);
+
+  bool is_elem_int_ty = (static_cast<JType>(element_jty) == kInt);
+
+  uint32_t alignment;
+  llvm::Constant* elem_size;
+  llvm::PointerType* field_type;
+
+  // NOTE: Currently filled-new-array only supports 'L', '[', and 'I'
+  // as the element, thus we are only checking 2 cases: primitive int and
+  // non-primitive type.
+  if (is_elem_int_ty) {
+    alignment = sizeof(int32_t);
+    elem_size = irb_.getPtrEquivInt(sizeof(int32_t));
+    field_type = irb_.getJIntTy()->getPointerTo();
+  } else {
+    alignment = irb_.getSizeOfPtrEquivInt();
+    elem_size = irb_.getSizeOfPtrEquivIntValue();
+    field_type = irb_.getJObjectTy()->getPointerTo();
+  }
+
+  llvm::Value* data_field_offset =
+    irb_.getPtrEquivInt(art::mirror::Array::DataOffset(alignment).Int32Value());
+
+  llvm::Value* data_field_addr =
+    irb_.CreatePtrDisp(array, data_field_offset, field_type);
+
+  for (unsigned i = 0; i < num_elements; ++i) {
+    // Values to fill the array begin at the 3rd argument
+    llvm::Value* reg_value = call_inst.getArgOperand(2 + i);
+
+    irb_.CreateStore(reg_value, data_field_addr, kTBAAHeapArray);
+
+    data_field_addr =
+      irb_.CreatePtrDisp(data_field_addr, elem_size, field_type);
+  }
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_IGetFast(llvm::Value* field_offset_value,
+                                              llvm::Value* /*is_volatile_value*/,
+                                              llvm::Value* object_addr,
+                                              JType field_jty) {
+  int field_offset =
+    llvm::cast<llvm::ConstantInt>(field_offset_value)->getSExtValue();
+
+  DCHECK_GE(field_offset, 0);
+
+  llvm::PointerType* field_type =
+    irb_.getJType(field_jty)->getPointerTo();
+
+  field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+  llvm::Value* field_addr =
+    irb_.CreatePtrDisp(object_addr, field_offset_value, field_type);
+
+  // TODO: Check is_volatile.  We need to generate atomic load instruction
+  // when is_volatile is true.
+  return irb_.CreateLoad(field_addr, kTBAAHeapInstance, field_jty);
+}
+
+void GBCExpanderPass::Expand_IPutFast(llvm::Value* field_offset_value,
+                                      llvm::Value* /* is_volatile_value */,
+                                      llvm::Value* object_addr,
+                                      llvm::Value* new_value,
+                                      JType field_jty) {
+  int field_offset =
+    llvm::cast<llvm::ConstantInt>(field_offset_value)->getSExtValue();
+
+  DCHECK_GE(field_offset, 0);
+
+  llvm::PointerType* field_type =
+    irb_.getJType(field_jty)->getPointerTo();
+
+  field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+  llvm::Value* field_addr =
+    irb_.CreatePtrDisp(object_addr, field_offset_value, field_type);
+
+  // TODO: Check is_volatile.  We need to generate atomic store instruction
+  // when is_volatile is true.
+  irb_.CreateStore(new_value, field_addr, kTBAAHeapInstance, field_jty);
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_SGetFast(llvm::Value* static_storage_addr,
+                                              llvm::Value* field_offset_value,
+                                              llvm::Value* /*is_volatile_value*/,
+                                              JType field_jty) {
+  int field_offset =
+    llvm::cast<llvm::ConstantInt>(field_offset_value)->getSExtValue();
+
+  DCHECK_GE(field_offset, 0);
+
+  llvm::Value* static_field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+  llvm::Value* static_field_addr =
+    irb_.CreatePtrDisp(static_storage_addr, static_field_offset_value,
+                       irb_.getJType(field_jty)->getPointerTo());
+
+  // TODO: Check is_volatile.  We need to generate atomic store instruction
+  // when is_volatile is true.
+  return irb_.CreateLoad(static_field_addr, kTBAAHeapStatic, field_jty);
+}
+
+void GBCExpanderPass::Expand_SPutFast(llvm::Value* static_storage_addr,
+                                      llvm::Value* field_offset_value,
+                                      llvm::Value* /* is_volatile_value */,
+                                      llvm::Value* new_value,
+                                      JType field_jty) {
+  int field_offset =
+    llvm::cast<llvm::ConstantInt>(field_offset_value)->getSExtValue();
+
+  DCHECK_GE(field_offset, 0);
+
+  llvm::Value* static_field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+  llvm::Value* static_field_addr =
+    irb_.CreatePtrDisp(static_storage_addr, static_field_offset_value,
+                       irb_.getJType(field_jty)->getPointerTo());
+
+  // TODO: Check is_volatile.  We need to generate atomic store instruction
+  // when is_volatile is true.
+  irb_.CreateStore(new_value, static_field_addr, kTBAAHeapStatic, field_jty);
+
+  return;
+}
+
+llvm::Value*
+GBCExpanderPass::Expand_LoadDeclaringClassSSB(llvm::Value* method_object_addr) {
+  return irb_.LoadFromObjectOffset(method_object_addr,
+                                   art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(),
+                                   irb_.getJObjectTy(),
+                                   kTBAAConstJObject);
+}
+
+llvm::Value*
+GBCExpanderPass::Expand_LoadClassSSBFromDexCache(llvm::Value* type_idx_value) {
+  uint32_t type_idx =
+    llvm::cast<llvm::ConstantInt>(type_idx_value)->getZExtValue();
+
+  llvm::Value* storage_field_addr =
+    EmitLoadDexCacheStaticStorageFieldAddr(type_idx);
+
+  return irb_.CreateLoad(storage_field_addr, kTBAARuntimeInfo);
+}
+
+llvm::Value*
+GBCExpanderPass::Expand_GetSDCalleeMethodObjAddrFast(llvm::Value* callee_method_idx_value) {
+  uint32_t callee_method_idx =
+    llvm::cast<llvm::ConstantInt>(callee_method_idx_value)->getZExtValue();
+
+  return EmitLoadSDCalleeMethodObjectAddr(callee_method_idx);
+}
+
+llvm::Value* GBCExpanderPass::Expand_GetVirtualCalleeMethodObjAddrFast(
+    llvm::Value* vtable_idx_value,
+    llvm::Value* this_addr) {
+  int vtable_idx =
+    llvm::cast<llvm::ConstantInt>(vtable_idx_value)->getSExtValue();
+
+  return EmitLoadVirtualCalleeMethodObjectAddr(vtable_idx, this_addr);
+}
+
+llvm::Value* GBCExpanderPass::Expand_Invoke(llvm::CallInst& call_inst) {
+  // Most of the codes refer to MethodCompiler::EmitInsn_Invoke
+  llvm::Value* callee_method_object_addr = call_inst.getArgOperand(0);
+  unsigned num_args = call_inst.getNumArgOperands();
+  llvm::Type* ret_type = call_inst.getType();
+
+  // Determine the function type of the callee method
+  std::vector<llvm::Type*> args_type;
+  std::vector<llvm::Value*> args;
+  for (unsigned i = 0; i < num_args; i++) {
+    args.push_back(call_inst.getArgOperand(i));
+    args_type.push_back(args[i]->getType());
+  }
+
+  llvm::FunctionType* callee_method_type =
+    llvm::FunctionType::get(ret_type, args_type, false);
+
+  llvm::Value* code_addr =
+    irb_.LoadFromObjectOffset(callee_method_object_addr,
+                              art::mirror::AbstractMethod::GetCodeOffset().Int32Value(),
+                              callee_method_type->getPointerTo(),
+                              kTBAARuntimeInfo);
+
+  // Invoke callee
+  llvm::Value* retval = irb_.CreateCall(code_addr, args);
+
+  return retval;
+}
+
+llvm::Value* GBCExpanderPass::Expand_DivRem(llvm::CallInst& call_inst,
+                                            bool is_div, JType op_jty) {
+  llvm::Value* dividend = call_inst.getArgOperand(0);
+  llvm::Value* divisor = call_inst.getArgOperand(1);
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  EmitGuard_DivZeroException(dex_pc, divisor, op_jty);
+  // Most of the codes refer to MethodCompiler::EmitIntDivRemResultComputation
+
+  // Check the special case: MININT / -1 = MININT
+  // That case will cause overflow, which is undefined behavior in llvm.
+  // So we check the divisor is -1 or not, if the divisor is -1, we do
+  // the special path to avoid undefined behavior.
+  llvm::Type* op_type = irb_.getJType(op_jty);
+  llvm::Value* zero = irb_.getJZero(op_jty);
+  llvm::Value* neg_one = llvm::ConstantInt::getSigned(op_type, -1);
+
+  llvm::Function* parent = irb_.GetInsertBlock()->getParent();
+  llvm::BasicBlock* eq_neg_one = llvm::BasicBlock::Create(context_, "", parent);
+  llvm::BasicBlock* ne_neg_one = llvm::BasicBlock::Create(context_, "", parent);
+  llvm::BasicBlock* neg_one_cont =
+    llvm::BasicBlock::Create(context_, "", parent);
+
+  llvm::Value* is_equal_neg_one = irb_.CreateICmpEQ(divisor, neg_one);
+  irb_.CreateCondBr(is_equal_neg_one, eq_neg_one, ne_neg_one, kUnlikely);
+
+  // If divisor == -1
+  irb_.SetInsertPoint(eq_neg_one);
+  llvm::Value* eq_result;
+  if (is_div) {
+    // We can just change from "dividend div -1" to "neg dividend". The sub
+    // don't care the sign/unsigned because of two's complement representation.
+    // And the behavior is what we want:
+    //  -(2^n)        (2^n)-1
+    //  MININT  < k <= MAXINT    ->     mul k -1  =  -k
+    //  MININT == k              ->     mul k -1  =   k
+    //
+    // LLVM use sub to represent 'neg'
+    eq_result = irb_.CreateSub(zero, dividend);
+  } else {
+    // Everything modulo -1 will be 0.
+    eq_result = zero;
+  }
+  irb_.CreateBr(neg_one_cont);
+
+  // If divisor != -1, just do the division.
+  irb_.SetInsertPoint(ne_neg_one);
+  llvm::Value* ne_result;
+  if (is_div) {
+    ne_result = irb_.CreateSDiv(dividend, divisor);
+  } else {
+    ne_result = irb_.CreateSRem(dividend, divisor);
+  }
+  irb_.CreateBr(neg_one_cont);
+
+  irb_.SetInsertPoint(neg_one_cont);
+  llvm::PHINode* result = irb_.CreatePHI(op_type, 2);
+  result->addIncoming(eq_result, eq_neg_one);
+  result->addIncoming(ne_result, ne_neg_one);
+
+  return result;
+}
+
+void GBCExpanderPass::Expand_AllocaShadowFrame(llvm::Value* num_vregs_value) {
+  // Most of the codes refer to MethodCompiler::EmitPrologueAllocShadowFrame and
+  // MethodCompiler::EmitPushShadowFrame
+  uint16_t num_vregs =
+    llvm::cast<llvm::ConstantInt>(num_vregs_value)->getZExtValue();
+
+  llvm::StructType* shadow_frame_type =
+    irb_.getShadowFrameTy(num_vregs);
+
+  // Create allocas at the start of entry block.
+  llvm::IRBuilderBase::InsertPoint irb_ip_original = irb_.saveIP();
+  llvm::BasicBlock* entry_block = &func_->front();
+  irb_.SetInsertPoint(&entry_block->front());
+
+  shadow_frame_ = irb_.CreateAlloca(shadow_frame_type);
+
+  // Alloca a pointer to old shadow frame
+  old_shadow_frame_ =
+    irb_.CreateAlloca(shadow_frame_type->getElementType(0)->getPointerTo());
+
+  irb_.restoreIP(irb_ip_original);
+
+  // Push the shadow frame
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* shadow_frame_upcast =
+    irb_.CreateConstGEP2_32(shadow_frame_, 0, 0);
+
+  llvm::Value* result = rtb_.EmitPushShadowFrame(shadow_frame_upcast,
+                                                 method_object_addr,
+                                                 num_vregs);
+
+  irb_.CreateStore(result, old_shadow_frame_, kTBAARegister);
+
+  return;
+}
+
+void GBCExpanderPass::Expand_SetVReg(llvm::Value* entry_idx,
+                                     llvm::Value* value) {
+  DCHECK(shadow_frame_ != NULL);
+
+  llvm::Value* gep_index[] = {
+    irb_.getInt32(0), // No pointer displacement
+    irb_.getInt32(1), // VRegs
+    entry_idx // Pointer field
+  };
+
+  llvm::Value* vreg_addr = irb_.CreateGEP(shadow_frame_, gep_index);
+
+  irb_.CreateStore(value,
+                   irb_.CreateBitCast(vreg_addr, value->getType()->getPointerTo()),
+                   kTBAAShadowFrame);
+  return;
+}
+
+void GBCExpanderPass::Expand_PopShadowFrame() {
+  if (old_shadow_frame_ == NULL) {
+    return;
+  }
+  rtb_.EmitPopShadowFrame(irb_.CreateLoad(old_shadow_frame_, kTBAARegister));
+  return;
+}
+
+void GBCExpanderPass::Expand_UpdateDexPC(llvm::Value* dex_pc_value) {
+  irb_.StoreToObjectOffset(shadow_frame_,
+                           art::ShadowFrame::DexPCOffset(),
+                           dex_pc_value,
+                           kTBAAShadowFrame);
+  return;
+}
+
+void GBCExpanderPass::InsertStackOverflowCheck(llvm::Function& func) {
+  // All alloca instructions are generated in the first basic block of the
+  // function, and there are no alloca instructions after the first non-alloca
+  // instruction.
+
+  llvm::BasicBlock* first_basic_block = &func.front();
+
+  // Look for first non-alloca instruction
+  llvm::BasicBlock::iterator first_non_alloca = first_basic_block->begin();
+  while (llvm::isa<llvm::AllocaInst>(first_non_alloca)) {
+    ++first_non_alloca;
+  }
+
+  irb_.SetInsertPoint(first_non_alloca);
+
+  // Insert stack overflow check codes before first_non_alloca (i.e., after all
+  // alloca instructions)
+  EmitStackOverflowCheck(&*first_non_alloca);
+
+  irb_.Runtime().EmitTestSuspend();
+
+  llvm::BasicBlock* next_basic_block = irb_.GetInsertBlock();
+  if (next_basic_block != first_basic_block) {
+    // Splice the rest of the instruction to the continuing basic block
+    next_basic_block->getInstList().splice(
+        irb_.GetInsertPoint(), first_basic_block->getInstList(),
+        first_non_alloca, first_basic_block->end());
+
+    // Rewrite the basic block
+    RewriteBasicBlock(next_basic_block);
+
+    // Update the phi-instructions in the successor basic block
+    UpdatePhiInstruction(first_basic_block, irb_.GetInsertBlock());
+  }
+
+  // We have changed the basic block
+  changed_ = true;
+}
+
+// ==== High-level intrinsic expander ==========================================
+
+llvm::Value* GBCExpanderPass::Expand_FPCompare(llvm::Value* src1_value,
+                                               llvm::Value* src2_value,
+                                               bool gt_bias) {
+  llvm::Value* cmp_eq = irb_.CreateFCmpOEQ(src1_value, src2_value);
+  llvm::Value* cmp_lt;
+
+  if (gt_bias) {
+    cmp_lt = irb_.CreateFCmpOLT(src1_value, src2_value);
+  } else {
+    cmp_lt = irb_.CreateFCmpULT(src1_value, src2_value);
+  }
+
+  return EmitCompareResultSelection(cmp_eq, cmp_lt);
+}
+
+llvm::Value* GBCExpanderPass::Expand_LongCompare(llvm::Value* src1_value, llvm::Value* src2_value) {
+  llvm::Value* cmp_eq = irb_.CreateICmpEQ(src1_value, src2_value);
+  llvm::Value* cmp_lt = irb_.CreateICmpSLT(src1_value, src2_value);
+
+  return EmitCompareResultSelection(cmp_eq, cmp_lt);
+}
+
+llvm::Value* GBCExpanderPass::EmitCompareResultSelection(llvm::Value* cmp_eq,
+                                                         llvm::Value* cmp_lt) {
+
+  llvm::Constant* zero = irb_.getJInt(0);
+  llvm::Constant* pos1 = irb_.getJInt(1);
+  llvm::Constant* neg1 = irb_.getJInt(-1);
+
+  llvm::Value* result_lt = irb_.CreateSelect(cmp_lt, neg1, pos1);
+  llvm::Value* result_eq = irb_.CreateSelect(cmp_eq, zero, result_lt);
+
+  return result_eq;
+}
+
+llvm::Value* GBCExpanderPass::Expand_IntegerShift(llvm::Value* src1_value,
+                                                  llvm::Value* src2_value,
+                                                  IntegerShiftKind kind,
+                                                  JType op_jty) {
+  DCHECK(op_jty == kInt || op_jty == kLong);
+
+  // Mask and zero-extend RHS properly
+  if (op_jty == kInt) {
+    src2_value = irb_.CreateAnd(src2_value, 0x1f);
+  } else {
+    llvm::Value* masked_src2_value = irb_.CreateAnd(src2_value, 0x3f);
+    src2_value = irb_.CreateZExt(masked_src2_value, irb_.getJLongTy());
+  }
+
+  // Create integer shift llvm instruction
+  switch (kind) {
+  case kIntegerSHL:
+    return irb_.CreateShl(src1_value, src2_value);
+
+  case kIntegerSHR:
+    return irb_.CreateAShr(src1_value, src2_value);
+
+  case kIntegerUSHR:
+    return irb_.CreateLShr(src1_value, src2_value);
+
+  default:
+    LOG(FATAL) << "Unknown integer shift kind: " << kind;
+    return NULL;
+  }
+}
+
+llvm::Value* GBCExpanderPass::SignOrZeroExtendCat1Types(llvm::Value* value, JType jty) {
+  switch (jty) {
+    case kBoolean:
+    case kChar:
+      return irb_.CreateZExt(value, irb_.getJType(kInt));
+    case kByte:
+    case kShort:
+      return irb_.CreateSExt(value, irb_.getJType(kInt));
+    case kVoid:
+    case kInt:
+    case kLong:
+    case kFloat:
+    case kDouble:
+    case kObject:
+      return value;  // Nothing to do.
+    default:
+      LOG(FATAL) << "Unknown java type: " << jty;
+      return NULL;
+  }
+}
+
+llvm::Value* GBCExpanderPass::TruncateCat1Types(llvm::Value* value, JType jty) {
+  switch (jty) {
+    case kBoolean:
+    case kChar:
+    case kByte:
+    case kShort:
+      return irb_.CreateTrunc(value, irb_.getJType(jty));
+    case kVoid:
+    case kInt:
+    case kLong:
+    case kFloat:
+    case kDouble:
+    case kObject:
+      return value;  // Nothing to do.
+    default:
+      LOG(FATAL) << "Unknown java type: " << jty;
+      return NULL;
+  }
+}
+
+llvm::Value* GBCExpanderPass::Expand_HLArrayGet(llvm::CallInst& call_inst,
+                                                JType elem_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* array_addr = call_inst.getArgOperand(1);
+  llvm::Value* index_value = call_inst.getArgOperand(2);
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, array_addr, opt_flags);
+  EmitGuard_ArrayIndexOutOfBoundsException(dex_pc, array_addr, index_value,
+                                           opt_flags);
+
+  llvm::Value* array_elem_addr = EmitArrayGEP(array_addr, index_value, elem_jty);
+
+  llvm::Value* array_elem_value = irb_.CreateLoad(array_elem_addr, kTBAAHeapArray, elem_jty);
+
+  return SignOrZeroExtendCat1Types(array_elem_value, elem_jty);
+}
+
+
+void GBCExpanderPass::Expand_HLArrayPut(llvm::CallInst& call_inst,
+                                        JType elem_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* new_value = call_inst.getArgOperand(1);
+  llvm::Value* array_addr = call_inst.getArgOperand(2);
+  llvm::Value* index_value = call_inst.getArgOperand(3);
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, array_addr, opt_flags);
+  EmitGuard_ArrayIndexOutOfBoundsException(dex_pc, array_addr, index_value,
+                                           opt_flags);
+
+  new_value = TruncateCat1Types(new_value, elem_jty);
+
+  llvm::Value* array_elem_addr = EmitArrayGEP(array_addr, index_value, elem_jty);
+
+  if (elem_jty == kObject) { // If put an object, check the type, and mark GC card table.
+    llvm::Function* runtime_func = irb_.GetRuntime(runtime_support::CheckPutArrayElement);
+
+    irb_.CreateCall2(runtime_func, new_value, array_addr);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    EmitMarkGCCard(new_value, array_addr);
+  }
+
+  irb_.CreateStore(new_value, array_elem_addr, kTBAAHeapArray, elem_jty);
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_HLIGet(llvm::CallInst& call_inst,
+                                            JType field_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* object_addr = call_inst.getArgOperand(1);
+  uint32_t field_idx = LV2UInt(call_inst.getArgOperand(2));
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, object_addr, opt_flags);
+
+  llvm::Value* field_value;
+
+  int field_offset;
+  bool is_volatile;
+  bool is_fast_path = driver_->ComputeInstanceFieldInfo(
+    field_idx, dex_compilation_unit_, field_offset, is_volatile, false);
+
+  if (!is_fast_path) {
+    llvm::Function* runtime_func;
+
+    if (field_jty == kObject) {
+      runtime_func = irb_.GetRuntime(runtime_support::GetObjectInstance);
+    } else if (field_jty == kLong || field_jty == kDouble) {
+      runtime_func = irb_.GetRuntime(runtime_support::Get64Instance);
+    } else {
+      runtime_func = irb_.GetRuntime(runtime_support::Get32Instance);
+    }
+
+    llvm::ConstantInt* field_idx_value = irb_.getInt32(field_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    EmitUpdateDexPC(dex_pc);
+
+    field_value = irb_.CreateCall3(runtime_func, field_idx_value,
+                                   method_object_addr, object_addr);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    if (field_jty == kFloat || field_jty == kDouble) {
+      field_value = irb_.CreateBitCast(field_value, irb_.getJType(field_jty));
+    }
+  } else {
+    DCHECK_GE(field_offset, 0);
+
+    llvm::PointerType* field_type =
+      irb_.getJType(field_jty)->getPointerTo();
+
+    llvm::ConstantInt* field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+    llvm::Value* field_addr =
+      irb_.CreatePtrDisp(object_addr, field_offset_value, field_type);
+
+    // TODO: Check is_volatile.  We need to generate atomic load instruction
+    // when is_volatile is true.
+    field_value = irb_.CreateLoad(field_addr, kTBAAHeapInstance, field_jty);
+    field_value = SignOrZeroExtendCat1Types(field_value, field_jty);
+  }
+
+  return field_value;
+}
+
+void GBCExpanderPass::Expand_HLIPut(llvm::CallInst& call_inst,
+                                    JType field_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* new_value = call_inst.getArgOperand(1);
+  llvm::Value* object_addr = call_inst.getArgOperand(2);
+  uint32_t field_idx = LV2UInt(call_inst.getArgOperand(3));
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, object_addr, opt_flags);
+
+  int field_offset;
+  bool is_volatile;
+  bool is_fast_path = driver_->ComputeInstanceFieldInfo(
+    field_idx, dex_compilation_unit_, field_offset, is_volatile, true);
+
+  if (!is_fast_path) {
+    llvm::Function* runtime_func;
+
+    if (field_jty == kFloat) {
+      new_value = irb_.CreateBitCast(new_value, irb_.getJType(kInt));
+    } else if (field_jty == kDouble) {
+      new_value = irb_.CreateBitCast(new_value, irb_.getJType(kLong));
+    }
+
+    if (field_jty == kObject) {
+      runtime_func = irb_.GetRuntime(runtime_support::SetObjectInstance);
+    } else if (field_jty == kLong || field_jty == kDouble) {
+      runtime_func = irb_.GetRuntime(runtime_support::Set64Instance);
+    } else {
+      runtime_func = irb_.GetRuntime(runtime_support::Set32Instance);
+    }
+
+    llvm::Value* field_idx_value = irb_.getInt32(field_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    EmitUpdateDexPC(dex_pc);
+
+    irb_.CreateCall4(runtime_func, field_idx_value,
+                     method_object_addr, object_addr, new_value);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+  } else {
+    DCHECK_GE(field_offset, 0);
+
+    llvm::PointerType* field_type =
+      irb_.getJType(field_jty)->getPointerTo();
+
+    llvm::Value* field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+    llvm::Value* field_addr =
+      irb_.CreatePtrDisp(object_addr, field_offset_value, field_type);
+
+    // TODO: Check is_volatile.  We need to generate atomic store instruction
+    // when is_volatile is true.
+    new_value = TruncateCat1Types(new_value, field_jty);
+    irb_.CreateStore(new_value, field_addr, kTBAAHeapInstance, field_jty);
+
+    if (field_jty == kObject) { // If put an object, mark the GC card table.
+      EmitMarkGCCard(new_value, object_addr);
+    }
+  }
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::EmitLoadConstantClass(uint32_t dex_pc,
+                                                    uint32_t type_idx) {
+  if (!driver_->CanAccessTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+                                           *dex_compilation_unit_->GetDexFile(), type_idx)) {
+    llvm::Value* type_idx_value = irb_.getInt32(type_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+    llvm::Function* runtime_func =
+      irb_.GetRuntime(runtime_support::InitializeTypeAndVerifyAccess);
+
+    EmitUpdateDexPC(dex_pc);
+
+    llvm::Value* type_object_addr =
+      irb_.CreateCall3(runtime_func, type_idx_value, method_object_addr, thread_object_addr);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    return type_object_addr;
+
+  } else {
+    // Try to load the class (type) object from the test cache.
+    llvm::Value* type_field_addr =
+      EmitLoadDexCacheResolvedTypeFieldAddr(type_idx);
+
+    llvm::Value* type_object_addr = irb_.CreateLoad(type_field_addr, kTBAARuntimeInfo);
+
+    if (driver_->CanAssumeTypeIsPresentInDexCache(*dex_compilation_unit_->GetDexFile(), type_idx)) {
+      return type_object_addr;
+    }
+
+    llvm::BasicBlock* block_original = irb_.GetInsertBlock();
+
+    // Test whether class (type) object is in the dex cache or not
+    llvm::Value* equal_null =
+      irb_.CreateICmpEQ(type_object_addr, irb_.getJNull());
+
+    llvm::BasicBlock* block_cont =
+      CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+    llvm::BasicBlock* block_load_class =
+      CreateBasicBlockWithDexPC(dex_pc, "load_class");
+
+    irb_.CreateCondBr(equal_null, block_load_class, block_cont, kUnlikely);
+
+    // Failback routine to load the class object
+    irb_.SetInsertPoint(block_load_class);
+
+    llvm::Function* runtime_func = irb_.GetRuntime(runtime_support::InitializeType);
+
+    llvm::Constant* type_idx_value = irb_.getInt32(type_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+    EmitUpdateDexPC(dex_pc);
+
+    llvm::Value* loaded_type_object_addr =
+      irb_.CreateCall3(runtime_func, type_idx_value, method_object_addr, thread_object_addr);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    llvm::BasicBlock* block_after_load_class = irb_.GetInsertBlock();
+
+    irb_.CreateBr(block_cont);
+
+    // Now the class object must be loaded
+    irb_.SetInsertPoint(block_cont);
+
+    llvm::PHINode* phi = irb_.CreatePHI(irb_.getJObjectTy(), 2);
+
+    phi->addIncoming(type_object_addr, block_original);
+    phi->addIncoming(loaded_type_object_addr, block_after_load_class);
+
+    return phi;
+  }
+}
+
+llvm::Value* GBCExpanderPass::EmitLoadStaticStorage(uint32_t dex_pc,
+                                                    uint32_t type_idx) {
+  llvm::BasicBlock* block_load_static =
+    CreateBasicBlockWithDexPC(dex_pc, "load_static");
+
+  llvm::BasicBlock* block_cont = CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+  // Load static storage from dex cache
+  llvm::Value* storage_field_addr =
+    EmitLoadDexCacheStaticStorageFieldAddr(type_idx);
+
+  llvm::Value* storage_object_addr = irb_.CreateLoad(storage_field_addr, kTBAARuntimeInfo);
+
+  llvm::BasicBlock* block_original = irb_.GetInsertBlock();
+
+  // Test: Is the static storage of this class initialized?
+  llvm::Value* equal_null =
+    irb_.CreateICmpEQ(storage_object_addr, irb_.getJNull());
+
+  irb_.CreateCondBr(equal_null, block_load_static, block_cont, kUnlikely);
+
+  // Failback routine to load the class object
+  irb_.SetInsertPoint(block_load_static);
+
+  llvm::Function* runtime_func = irb_.GetRuntime(runtime_support::InitializeStaticStorage);
+
+  llvm::Constant* type_idx_value = irb_.getInt32(type_idx);
+
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+  EmitUpdateDexPC(dex_pc);
+
+  llvm::Value* loaded_storage_object_addr =
+    irb_.CreateCall3(runtime_func, type_idx_value, method_object_addr, thread_object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  llvm::BasicBlock* block_after_load_static = irb_.GetInsertBlock();
+
+  irb_.CreateBr(block_cont);
+
+  // Now the class object must be loaded
+  irb_.SetInsertPoint(block_cont);
+
+  llvm::PHINode* phi = irb_.CreatePHI(irb_.getJObjectTy(), 2);
+
+  phi->addIncoming(storage_object_addr, block_original);
+  phi->addIncoming(loaded_storage_object_addr, block_after_load_static);
+
+  return phi;
+}
+
+llvm::Value* GBCExpanderPass::Expand_HLSget(llvm::CallInst& call_inst,
+                                            JType field_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t field_idx = LV2UInt(call_inst.getArgOperand(0));
+
+  int field_offset;
+  int ssb_index;
+  bool is_referrers_class;
+  bool is_volatile;
+
+  bool is_fast_path = driver_->ComputeStaticFieldInfo(
+    field_idx, dex_compilation_unit_, field_offset, ssb_index,
+    is_referrers_class, is_volatile, false);
+
+  llvm::Value* static_field_value;
+
+  if (!is_fast_path) {
+    llvm::Function* runtime_func;
+
+    if (field_jty == kObject) {
+      runtime_func = irb_.GetRuntime(runtime_support::GetObjectStatic);
+    } else if (field_jty == kLong || field_jty == kDouble) {
+      runtime_func = irb_.GetRuntime(runtime_support::Get64Static);
+    } else {
+      runtime_func = irb_.GetRuntime(runtime_support::Get32Static);
+    }
+
+    llvm::Constant* field_idx_value = irb_.getInt32(field_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    EmitUpdateDexPC(dex_pc);
+
+    static_field_value =
+      irb_.CreateCall2(runtime_func, field_idx_value, method_object_addr);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    if (field_jty == kFloat || field_jty == kDouble) {
+      static_field_value = irb_.CreateBitCast(static_field_value, irb_.getJType(field_jty));
+    }
+  } else {
+    DCHECK_GE(field_offset, 0);
+
+    llvm::Value* static_storage_addr = NULL;
+
+    if (is_referrers_class) {
+      // Fast path, static storage base is this method's class
+      llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+      static_storage_addr =
+        irb_.LoadFromObjectOffset(method_object_addr,
+                                  art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(),
+                                  irb_.getJObjectTy(),
+                                  kTBAAConstJObject);
+    } else {
+      // Medium path, static storage base in a different class which
+      // requires checks that the other class is initialized
+      DCHECK_GE(ssb_index, 0);
+      static_storage_addr = EmitLoadStaticStorage(dex_pc, ssb_index);
+    }
+
+    llvm::Value* static_field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+    llvm::Value* static_field_addr =
+      irb_.CreatePtrDisp(static_storage_addr, static_field_offset_value,
+                         irb_.getJType(field_jty)->getPointerTo());
+
+    // TODO: Check is_volatile.  We need to generate atomic load instruction
+    // when is_volatile is true.
+    static_field_value = irb_.CreateLoad(static_field_addr, kTBAAHeapStatic, field_jty);
+    static_field_value = SignOrZeroExtendCat1Types(static_field_value, field_jty);
+  }
+
+  return static_field_value;
+}
+
+void GBCExpanderPass::Expand_HLSput(llvm::CallInst& call_inst,
+                                    JType field_jty) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t field_idx = LV2UInt(call_inst.getArgOperand(0));
+  llvm::Value* new_value = call_inst.getArgOperand(1);
+
+  if (field_jty == kFloat || field_jty == kDouble) {
+    new_value = irb_.CreateBitCast(new_value, irb_.getJType(field_jty));
+  }
+
+  int field_offset;
+  int ssb_index;
+  bool is_referrers_class;
+  bool is_volatile;
+
+  bool is_fast_path = driver_->ComputeStaticFieldInfo(
+    field_idx, dex_compilation_unit_, field_offset, ssb_index,
+    is_referrers_class, is_volatile, true);
+
+  if (!is_fast_path) {
+    llvm::Function* runtime_func;
+
+    if (field_jty == kObject) {
+      runtime_func = irb_.GetRuntime(runtime_support::SetObjectStatic);
+    } else if (field_jty == kLong || field_jty == kDouble) {
+      runtime_func = irb_.GetRuntime(runtime_support::Set64Static);
+    } else {
+      runtime_func = irb_.GetRuntime(runtime_support::Set32Static);
+    }
+
+    if (field_jty == kFloat) {
+      new_value = irb_.CreateBitCast(new_value, irb_.getJType(kInt));
+    } else if (field_jty == kDouble) {
+      new_value = irb_.CreateBitCast(new_value, irb_.getJType(kLong));
+    }
+
+    llvm::Constant* field_idx_value = irb_.getInt32(field_idx);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    EmitUpdateDexPC(dex_pc);
+
+    irb_.CreateCall3(runtime_func, field_idx_value,
+                     method_object_addr, new_value);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+  } else {
+    DCHECK_GE(field_offset, 0);
+
+    llvm::Value* static_storage_addr = NULL;
+
+    if (is_referrers_class) {
+      // Fast path, static storage base is this method's class
+      llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+      static_storage_addr =
+        irb_.LoadFromObjectOffset(method_object_addr,
+                                  art::mirror::AbstractMethod::DeclaringClassOffset().Int32Value(),
+                                  irb_.getJObjectTy(),
+                                  kTBAAConstJObject);
+    } else {
+      // Medium path, static storage base in a different class which
+      // requires checks that the other class is initialized
+      DCHECK_GE(ssb_index, 0);
+      static_storage_addr = EmitLoadStaticStorage(dex_pc, ssb_index);
+    }
+
+    llvm::Value* static_field_offset_value = irb_.getPtrEquivInt(field_offset);
+
+    llvm::Value* static_field_addr =
+      irb_.CreatePtrDisp(static_storage_addr, static_field_offset_value,
+                         irb_.getJType(field_jty)->getPointerTo());
+
+    // TODO: Check is_volatile.  We need to generate atomic store instruction
+    // when is_volatile is true.
+    new_value = TruncateCat1Types(new_value, field_jty);
+    irb_.CreateStore(new_value, static_field_addr, kTBAAHeapStatic, field_jty);
+
+    if (field_jty == kObject) { // If put an object, mark the GC card table.
+      EmitMarkGCCard(new_value, static_storage_addr);
+    }
+  }
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_ConstString(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t string_idx = LV2UInt(call_inst.getArgOperand(0));
+
+  llvm::Value* string_field_addr = EmitLoadDexCacheStringFieldAddr(string_idx);
+
+  llvm::Value* string_addr = irb_.CreateLoad(string_field_addr, kTBAARuntimeInfo);
+
+  if (!driver_->CanAssumeStringIsPresentInDexCache(*dex_compilation_unit_->GetDexFile(),
+                                                   string_idx)) {
+    llvm::BasicBlock* block_str_exist =
+      CreateBasicBlockWithDexPC(dex_pc, "str_exist");
+
+    llvm::BasicBlock* block_str_resolve =
+      CreateBasicBlockWithDexPC(dex_pc, "str_resolve");
+
+    llvm::BasicBlock* block_cont =
+      CreateBasicBlockWithDexPC(dex_pc, "str_cont");
+
+    // Test: Is the string resolved and in the dex cache?
+    llvm::Value* equal_null = irb_.CreateICmpEQ(string_addr, irb_.getJNull());
+
+    irb_.CreateCondBr(equal_null, block_str_resolve, block_str_exist, kUnlikely);
+
+    // String is resolved, go to next basic block.
+    irb_.SetInsertPoint(block_str_exist);
+    irb_.CreateBr(block_cont);
+
+    // String is not resolved yet, resolve it now.
+    irb_.SetInsertPoint(block_str_resolve);
+
+    llvm::Function* runtime_func = irb_.GetRuntime(runtime_support::ResolveString);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    llvm::Value* string_idx_value = irb_.getInt32(string_idx);
+
+    EmitUpdateDexPC(dex_pc);
+
+    llvm::Value* result = irb_.CreateCall2(runtime_func, method_object_addr,
+                                           string_idx_value);
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+
+    irb_.CreateBr(block_cont);
+
+
+    llvm::BasicBlock* block_pre_cont = irb_.GetInsertBlock();
+
+    irb_.SetInsertPoint(block_cont);
+
+    llvm::PHINode* phi = irb_.CreatePHI(irb_.getJObjectTy(), 2);
+
+    phi->addIncoming(string_addr, block_str_exist);
+    phi->addIncoming(result, block_pre_cont);
+
+    string_addr = phi;
+  }
+
+  return string_addr;
+}
+
+llvm::Value* GBCExpanderPass::Expand_ConstClass(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
+
+  llvm::Value* type_object_addr = EmitLoadConstantClass(dex_pc, type_idx);
+
+  return type_object_addr;
+}
+
+void GBCExpanderPass::Expand_MonitorEnter(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* object_addr = call_inst.getArgOperand(1);
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, object_addr, opt_flags);
+
+  EmitUpdateDexPC(dex_pc);
+
+  irb_.Runtime().EmitLockObject(object_addr);
+
+  return;
+}
+
+void GBCExpanderPass::Expand_MonitorExit(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  llvm::Value* object_addr = call_inst.getArgOperand(1);
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, object_addr, opt_flags);
+
+  EmitUpdateDexPC(dex_pc);
+
+  irb_.Runtime().EmitUnlockObject(object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  return;
+}
+
+void GBCExpanderPass::Expand_HLCheckCast(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
+  llvm::Value* object_addr = call_inst.getArgOperand(1);
+
+  llvm::BasicBlock* block_test_class =
+    CreateBasicBlockWithDexPC(dex_pc, "test_class");
+
+  llvm::BasicBlock* block_test_sub_class =
+    CreateBasicBlockWithDexPC(dex_pc, "test_sub_class");
+
+  llvm::BasicBlock* block_cont =
+    CreateBasicBlockWithDexPC(dex_pc, "checkcast_cont");
+
+  // Test: Is the reference equal to null?  Act as no-op when it is null.
+  llvm::Value* equal_null = irb_.CreateICmpEQ(object_addr, irb_.getJNull());
+
+  irb_.CreateCondBr(equal_null, block_cont, block_test_class, kUnlikely);
+
+  // Test: Is the object instantiated from the given class?
+  irb_.SetInsertPoint(block_test_class);
+  llvm::Value* type_object_addr = EmitLoadConstantClass(dex_pc, type_idx);
+  DCHECK_EQ(art::mirror::Object::ClassOffset().Int32Value(), 0);
+
+  llvm::PointerType* jobject_ptr_ty = irb_.getJObjectTy();
+
+  llvm::Value* object_type_field_addr =
+    irb_.CreateBitCast(object_addr, jobject_ptr_ty->getPointerTo());
+
+  llvm::Value* object_type_object_addr =
+    irb_.CreateLoad(object_type_field_addr, kTBAAConstJObject);
+
+  llvm::Value* equal_class =
+    irb_.CreateICmpEQ(type_object_addr, object_type_object_addr);
+
+  irb_.CreateCondBr(equal_class, block_cont, block_test_sub_class, kLikely);
+
+  // Test: Is the object instantiated from the subclass of the given class?
+  irb_.SetInsertPoint(block_test_sub_class);
+
+  EmitUpdateDexPC(dex_pc);
+
+  irb_.CreateCall2(irb_.GetRuntime(runtime_support::CheckCast),
+                   type_object_addr, object_type_object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  irb_.CreateBr(block_cont);
+
+  irb_.SetInsertPoint(block_cont);
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::Expand_InstanceOf(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
+  llvm::Value* object_addr = call_inst.getArgOperand(1);
+
+  llvm::BasicBlock* block_nullp =
+      CreateBasicBlockWithDexPC(dex_pc, "nullp");
+
+  llvm::BasicBlock* block_test_class =
+      CreateBasicBlockWithDexPC(dex_pc, "test_class");
+
+  llvm::BasicBlock* block_class_equals =
+      CreateBasicBlockWithDexPC(dex_pc, "class_eq");
+
+  llvm::BasicBlock* block_test_sub_class =
+      CreateBasicBlockWithDexPC(dex_pc, "test_sub_class");
+
+  llvm::BasicBlock* block_cont =
+      CreateBasicBlockWithDexPC(dex_pc, "instance_of_cont");
+
+  // Overview of the following code :
+  // We check for null, if so, then false, otherwise check for class == . If so
+  // then true, otherwise do callout slowpath.
+  //
+  // Test: Is the reference equal to null?  Set 0 when it is null.
+  llvm::Value* equal_null = irb_.CreateICmpEQ(object_addr, irb_.getJNull());
+
+  irb_.CreateCondBr(equal_null, block_nullp, block_test_class, kUnlikely);
+
+  irb_.SetInsertPoint(block_nullp);
+  irb_.CreateBr(block_cont);
+
+  // Test: Is the object instantiated from the given class?
+  irb_.SetInsertPoint(block_test_class);
+  llvm::Value* type_object_addr = EmitLoadConstantClass(dex_pc, type_idx);
+  DCHECK_EQ(art::mirror::Object::ClassOffset().Int32Value(), 0);
+
+  llvm::PointerType* jobject_ptr_ty = irb_.getJObjectTy();
+
+  llvm::Value* object_type_field_addr =
+    irb_.CreateBitCast(object_addr, jobject_ptr_ty->getPointerTo());
+
+  llvm::Value* object_type_object_addr =
+    irb_.CreateLoad(object_type_field_addr, kTBAAConstJObject);
+
+  llvm::Value* equal_class =
+    irb_.CreateICmpEQ(type_object_addr, object_type_object_addr);
+
+  irb_.CreateCondBr(equal_class, block_class_equals, block_test_sub_class, kLikely);
+
+  irb_.SetInsertPoint(block_class_equals);
+  irb_.CreateBr(block_cont);
+
+  // Test: Is the object instantiated from the subclass of the given class?
+  irb_.SetInsertPoint(block_test_sub_class);
+  llvm::Value* result =
+    irb_.CreateCall2(irb_.GetRuntime(runtime_support::IsAssignable),
+                     type_object_addr, object_type_object_addr);
+  irb_.CreateBr(block_cont);
+
+  irb_.SetInsertPoint(block_cont);
+
+  llvm::PHINode* phi = irb_.CreatePHI(irb_.getJIntTy(), 3);
+
+  phi->addIncoming(irb_.getJInt(0), block_nullp);
+  phi->addIncoming(irb_.getJInt(1), block_class_equals);
+  phi->addIncoming(result, block_test_sub_class);
+
+  return phi;
+}
+
+llvm::Value* GBCExpanderPass::Expand_NewInstance(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
+
+  llvm::Function* runtime_func;
+  if (driver_->CanAccessInstantiableTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+                                                      *dex_compilation_unit_->GetDexFile(),
+                                                      type_idx)) {
+    runtime_func = irb_.GetRuntime(runtime_support::AllocObject);
+  } else {
+    runtime_func = irb_.GetRuntime(runtime_support::AllocObjectWithAccessCheck);
+  }
+
+  llvm::Constant* type_index_value = irb_.getInt32(type_idx);
+
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+  EmitUpdateDexPC(dex_pc);
+
+  llvm::Value* object_addr =
+    irb_.CreateCall3(runtime_func, type_index_value, method_object_addr, thread_object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  return object_addr;
+}
+
+llvm::Value* GBCExpanderPass::Expand_HLInvoke(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  art::InvokeType invoke_type = static_cast<art::InvokeType>(LV2UInt(call_inst.getArgOperand(0)));
+  bool is_static = (invoke_type == art::kStatic);
+  uint32_t callee_method_idx = LV2UInt(call_inst.getArgOperand(1));
+  int opt_flags = LV2UInt(call_inst.getArgOperand(2));
+
+  // Compute invoke related information for compiler decision
+  int vtable_idx = -1;
+  uintptr_t direct_code = 0;
+  uintptr_t direct_method = 0;
+  bool is_fast_path = driver_->
+    ComputeInvokeInfo(callee_method_idx, dex_compilation_unit_,
+                      invoke_type, vtable_idx, direct_code, direct_method);
+
+  // Load *this* actual parameter
+  llvm::Value* this_addr = NULL;
+
+  if (!is_static) {
+    // Test: Is *this* parameter equal to null?
+    this_addr = call_inst.getArgOperand(3);
+  }
+
+  // Load the method object
+  llvm::Value* callee_method_object_addr = NULL;
+
+  if (!is_fast_path) {
+    callee_method_object_addr =
+      EmitCallRuntimeForCalleeMethodObjectAddr(callee_method_idx, invoke_type,
+                                               this_addr, dex_pc, is_fast_path);
+
+    if (!is_static) {
+      EmitGuard_NullPointerException(dex_pc, this_addr, opt_flags);
+    }
+  } else {
+    if (!is_static) {
+      EmitGuard_NullPointerException(dex_pc, this_addr, opt_flags);
+    }
+
+    switch (invoke_type) {
+    case art::kStatic:
+    case art::kDirect:
+      if (direct_method != 0u &&
+          direct_method != static_cast<uintptr_t>(-1)) {
+        callee_method_object_addr =
+          irb_.CreateIntToPtr(irb_.getPtrEquivInt(direct_method),
+                              irb_.getJObjectTy());
+      } else {
+        callee_method_object_addr =
+          EmitLoadSDCalleeMethodObjectAddr(callee_method_idx);
+      }
+      break;
+
+    case art::kVirtual:
+      DCHECK(vtable_idx != -1);
+      callee_method_object_addr =
+        EmitLoadVirtualCalleeMethodObjectAddr(vtable_idx, this_addr);
+      break;
+
+    case art::kSuper:
+      LOG(FATAL) << "invoke-super should be promoted to invoke-direct in "
+                    "the fast path.";
+      break;
+
+    case art::kInterface:
+      callee_method_object_addr =
+        EmitCallRuntimeForCalleeMethodObjectAddr(callee_method_idx,
+                                                 invoke_type, this_addr,
+                                                 dex_pc, is_fast_path);
+      break;
+    }
+  }
+
+  // Load the actual parameter
+  std::vector<llvm::Value*> args;
+
+  args.push_back(callee_method_object_addr); // method object for callee
+
+  for (uint32_t i = 3; i < call_inst.getNumArgOperands(); ++i) {
+    args.push_back(call_inst.getArgOperand(i));
+  }
+
+  // Generate the load of the Method*. We base the return type on that of the call as method's
+  // returning a value are void calls if the return value is unused.
+  llvm::Value* code_addr;
+  if (direct_code != 0u &&
+      direct_code != static_cast<uintptr_t>(-1)) {
+    code_addr =
+      irb_.CreateIntToPtr(irb_.getPtrEquivInt(direct_code),
+                          GetFunctionType(call_inst.getType(), callee_method_idx, is_static)->getPointerTo());
+  } else {
+    code_addr =
+      irb_.LoadFromObjectOffset(callee_method_object_addr,
+                                art::mirror::AbstractMethod::GetCodeOffset().Int32Value(),
+                                GetFunctionType(call_inst.getType(), callee_method_idx, is_static)->getPointerTo(),
+                                kTBAARuntimeInfo);
+  }
+
+  // Invoke callee
+  EmitUpdateDexPC(dex_pc);
+  llvm::Value* retval = irb_.CreateCall(code_addr, args);
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  return retval;
+}
+
+llvm::Value* GBCExpanderPass::Expand_OptArrayLength(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  // Get the array object address
+  llvm::Value* array_addr = call_inst.getArgOperand(1);
+  int opt_flags = LV2UInt(call_inst.getArgOperand(0));
+
+  EmitGuard_NullPointerException(dex_pc, array_addr, opt_flags);
+
+  // Get the array length and store it to the register
+  return EmitLoadArrayLength(array_addr);
+}
+
+llvm::Value* GBCExpanderPass::Expand_NewArray(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(0));
+  llvm::Value* length = call_inst.getArgOperand(1);
+
+  return EmitAllocNewArray(dex_pc, length, type_idx, false);
+}
+
+llvm::Value* GBCExpanderPass::Expand_HLFilledNewArray(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  uint32_t type_idx = LV2UInt(call_inst.getArgOperand(1));
+  uint32_t length = call_inst.getNumArgOperands() - 3;
+
+  llvm::Value* object_addr =
+    EmitAllocNewArray(dex_pc, irb_.getInt32(length), type_idx, true);
+
+  if (length > 0) {
+    // Check for the element type
+    uint32_t type_desc_len = 0;
+    const char* type_desc =
+        dex_compilation_unit_->GetDexFile()->StringByTypeIdx(type_idx, &type_desc_len);
+
+    DCHECK_GE(type_desc_len, 2u); // should be guaranteed by verifier
+    DCHECK_EQ(type_desc[0], '['); // should be guaranteed by verifier
+    bool is_elem_int_ty = (type_desc[1] == 'I');
+
+    uint32_t alignment;
+    llvm::Constant* elem_size;
+    llvm::PointerType* field_type;
+
+    // NOTE: Currently filled-new-array only supports 'L', '[', and 'I'
+    // as the element, thus we are only checking 2 cases: primitive int and
+    // non-primitive type.
+    if (is_elem_int_ty) {
+      alignment = sizeof(int32_t);
+      elem_size = irb_.getPtrEquivInt(sizeof(int32_t));
+      field_type = irb_.getJIntTy()->getPointerTo();
+    } else {
+      alignment = irb_.getSizeOfPtrEquivInt();
+      elem_size = irb_.getSizeOfPtrEquivIntValue();
+      field_type = irb_.getJObjectTy()->getPointerTo();
+    }
+
+    llvm::Value* data_field_offset =
+      irb_.getPtrEquivInt(art::mirror::Array::DataOffset(alignment).Int32Value());
+
+    llvm::Value* data_field_addr =
+      irb_.CreatePtrDisp(object_addr, data_field_offset, field_type);
+
+    // TODO: Tune this code.  Currently we are generating one instruction for
+    // one element which may be very space consuming.  Maybe changing to use
+    // memcpy may help; however, since we can't guarantee that the alloca of
+    // dalvik register are continuous, we can't perform such optimization yet.
+    for (uint32_t i = 0; i < length; ++i) {
+      llvm::Value* reg_value = call_inst.getArgOperand(i+3);
+
+      irb_.CreateStore(reg_value, data_field_addr, kTBAAHeapArray);
+
+      data_field_addr =
+        irb_.CreatePtrDisp(data_field_addr, elem_size, field_type);
+    }
+  }
+
+  return object_addr;
+}
+
+void GBCExpanderPass::Expand_HLFillArrayData(llvm::CallInst& call_inst) {
+  uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+  int32_t payload_offset = static_cast<int32_t>(dex_pc) +
+                           LV2SInt(call_inst.getArgOperand(0));
+  llvm::Value* array_addr = call_inst.getArgOperand(1);
+
+  const art::Instruction::ArrayDataPayload* payload =
+    reinterpret_cast<const art::Instruction::ArrayDataPayload*>(
+        dex_compilation_unit_->GetCodeItem()->insns_ + payload_offset);
+
+  if (payload->element_count == 0) {
+    // When the number of the elements in the payload is zero, we don't have
+    // to copy any numbers.  However, we should check whether the array object
+    // address is equal to null or not.
+    EmitGuard_NullPointerException(dex_pc, array_addr, 0);
+  } else {
+    // To save the code size, we are going to call the runtime function to
+    // copy the content from DexFile.
+
+    // NOTE: We will check for the NullPointerException in the runtime.
+
+    llvm::Function* runtime_func = irb_.GetRuntime(runtime_support::FillArrayData);
+
+    llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+    EmitUpdateDexPC(dex_pc);
+
+    irb_.CreateCall4(runtime_func,
+                     method_object_addr, irb_.getInt32(dex_pc),
+                     array_addr, irb_.getInt32(payload_offset));
+
+    EmitGuard_ExceptionLandingPad(dex_pc);
+  }
+
+  return;
+}
+
+llvm::Value* GBCExpanderPass::EmitAllocNewArray(uint32_t dex_pc,
+                                                llvm::Value* array_length_value,
+                                                uint32_t type_idx,
+                                                bool is_filled_new_array) {
+  llvm::Function* runtime_func;
+
+  bool skip_access_check =
+    driver_->CanAccessTypeWithoutChecks(dex_compilation_unit_->GetDexMethodIndex(),
+                                        *dex_compilation_unit_->GetDexFile(), type_idx);
+
+
+  if (is_filled_new_array) {
+    runtime_func = skip_access_check ?
+      irb_.GetRuntime(runtime_support::CheckAndAllocArray) :
+      irb_.GetRuntime(runtime_support::CheckAndAllocArrayWithAccessCheck);
+  } else {
+    runtime_func = skip_access_check ?
+      irb_.GetRuntime(runtime_support::AllocArray) :
+      irb_.GetRuntime(runtime_support::AllocArrayWithAccessCheck);
+  }
+
+  llvm::Constant* type_index_value = irb_.getInt32(type_idx);
+
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+  EmitUpdateDexPC(dex_pc);
+
+  llvm::Value* object_addr =
+    irb_.CreateCall4(runtime_func, type_index_value, method_object_addr,
+                     array_length_value, thread_object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  return object_addr;
+}
+
+llvm::Value* GBCExpanderPass::
+EmitCallRuntimeForCalleeMethodObjectAddr(uint32_t callee_method_idx,
+                                         art::InvokeType invoke_type,
+                                         llvm::Value* this_addr,
+                                         uint32_t dex_pc,
+                                         bool is_fast_path) {
+
+  llvm::Function* runtime_func = NULL;
+
+  switch (invoke_type) {
+  case art::kStatic:
+    runtime_func = irb_.GetRuntime(runtime_support::FindStaticMethodWithAccessCheck);
+    break;
+
+  case art::kDirect:
+    runtime_func = irb_.GetRuntime(runtime_support::FindDirectMethodWithAccessCheck);
+    break;
+
+  case art::kVirtual:
+    runtime_func = irb_.GetRuntime(runtime_support::FindVirtualMethodWithAccessCheck);
+    break;
+
+  case art::kSuper:
+    runtime_func = irb_.GetRuntime(runtime_support::FindSuperMethodWithAccessCheck);
+    break;
+
+  case art::kInterface:
+    if (is_fast_path) {
+      runtime_func = irb_.GetRuntime(runtime_support::FindInterfaceMethod);
+    } else {
+      runtime_func = irb_.GetRuntime(runtime_support::FindInterfaceMethodWithAccessCheck);
+    }
+    break;
+  }
+
+  llvm::Value* callee_method_idx_value = irb_.getInt32(callee_method_idx);
+
+  if (this_addr == NULL) {
+    DCHECK_EQ(invoke_type, art::kStatic);
+    this_addr = irb_.getJNull();
+  }
+
+  llvm::Value* caller_method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* thread_object_addr = irb_.Runtime().EmitGetCurrentThread();
+
+  EmitUpdateDexPC(dex_pc);
+
+  llvm::Value* callee_method_object_addr =
+    irb_.CreateCall4(runtime_func,
+                     callee_method_idx_value,
+                     this_addr,
+                     caller_method_object_addr,
+                     thread_object_addr);
+
+  EmitGuard_ExceptionLandingPad(dex_pc);
+
+  return callee_method_object_addr;
+}
+
+void GBCExpanderPass::EmitMarkGCCard(llvm::Value* value, llvm::Value* target_addr) {
+  // Using runtime support, let the target can override by InlineAssembly.
+  irb_.Runtime().EmitMarkGCCard(value, target_addr);
+}
+
+void GBCExpanderPass::EmitUpdateDexPC(uint32_t dex_pc) {
+  if (shadow_frame_ == NULL) {
+    return;
+  }
+  irb_.StoreToObjectOffset(shadow_frame_,
+                           art::ShadowFrame::DexPCOffset(),
+                           irb_.getInt32(dex_pc),
+                           kTBAAShadowFrame);
+}
+
+void GBCExpanderPass::EmitGuard_DivZeroException(uint32_t dex_pc,
+                                                 llvm::Value* denominator,
+                                                 JType op_jty) {
+  DCHECK(op_jty == kInt || op_jty == kLong) << op_jty;
+
+  llvm::Constant* zero = irb_.getJZero(op_jty);
+
+  llvm::Value* equal_zero = irb_.CreateICmpEQ(denominator, zero);
+
+  llvm::BasicBlock* block_exception = CreateBasicBlockWithDexPC(dex_pc, "div0");
+
+  llvm::BasicBlock* block_continue = CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+  irb_.CreateCondBr(equal_zero, block_exception, block_continue, kUnlikely);
+
+  irb_.SetInsertPoint(block_exception);
+  EmitUpdateDexPC(dex_pc);
+  irb_.CreateCall(irb_.GetRuntime(runtime_support::ThrowDivZeroException));
+  EmitBranchExceptionLandingPad(dex_pc);
+
+  irb_.SetInsertPoint(block_continue);
+}
+
+void GBCExpanderPass::EmitGuard_NullPointerException(uint32_t dex_pc,
+                                                     llvm::Value* object,
+                                                     int opt_flags) {
+  bool ignore_null_check = ((opt_flags & MIR_IGNORE_NULL_CHECK) != 0);
+  if (ignore_null_check) {
+    llvm::BasicBlock* lpad = GetLandingPadBasicBlock(dex_pc);
+    if (lpad) {
+      // There is at least one catch: create a "fake" conditional branch to
+      // keep the exception edge to the catch block.
+      landing_pad_phi_mapping_[lpad].push_back(
+          std::make_pair(current_bb_->getUniquePredecessor(),
+                         irb_.GetInsertBlock()));
+
+      llvm::BasicBlock* block_continue =
+          CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+      irb_.CreateCondBr(irb_.getFalse(), lpad, block_continue, kUnlikely);
+
+      irb_.SetInsertPoint(block_continue);
+    }
+  } else {
+    llvm::Value* equal_null = irb_.CreateICmpEQ(object, irb_.getJNull());
+
+    llvm::BasicBlock* block_exception =
+        CreateBasicBlockWithDexPC(dex_pc, "nullp");
+
+    llvm::BasicBlock* block_continue =
+        CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+    irb_.CreateCondBr(equal_null, block_exception, block_continue, kUnlikely);
+
+    irb_.SetInsertPoint(block_exception);
+    EmitUpdateDexPC(dex_pc);
+    irb_.CreateCall(irb_.GetRuntime(runtime_support::ThrowNullPointerException),
+                    irb_.getInt32(dex_pc));
+    EmitBranchExceptionLandingPad(dex_pc);
+
+    irb_.SetInsertPoint(block_continue);
+  }
+}
+
+void
+GBCExpanderPass::EmitGuard_ArrayIndexOutOfBoundsException(uint32_t dex_pc,
+                                                          llvm::Value* array,
+                                                          llvm::Value* index,
+                                                          int opt_flags) {
+  bool ignore_range_check = ((opt_flags & MIR_IGNORE_RANGE_CHECK) != 0);
+  if (ignore_range_check) {
+    llvm::BasicBlock* lpad = GetLandingPadBasicBlock(dex_pc);
+    if (lpad) {
+      // There is at least one catch: create a "fake" conditional branch to
+      // keep the exception edge to the catch block.
+      landing_pad_phi_mapping_[lpad].push_back(
+          std::make_pair(current_bb_->getUniquePredecessor(),
+                         irb_.GetInsertBlock()));
+
+      llvm::BasicBlock* block_continue =
+          CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+      irb_.CreateCondBr(irb_.getFalse(), lpad, block_continue, kUnlikely);
+
+      irb_.SetInsertPoint(block_continue);
+    }
+  } else {
+    llvm::Value* array_len = EmitLoadArrayLength(array);
+
+    llvm::Value* cmp = irb_.CreateICmpUGE(index, array_len);
+
+    llvm::BasicBlock* block_exception =
+        CreateBasicBlockWithDexPC(dex_pc, "overflow");
+
+    llvm::BasicBlock* block_continue =
+        CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+    irb_.CreateCondBr(cmp, block_exception, block_continue, kUnlikely);
+
+    irb_.SetInsertPoint(block_exception);
+
+    EmitUpdateDexPC(dex_pc);
+    irb_.CreateCall2(irb_.GetRuntime(runtime_support::ThrowIndexOutOfBounds), index, array_len);
+    EmitBranchExceptionLandingPad(dex_pc);
+
+    irb_.SetInsertPoint(block_continue);
+  }
+}
+
+llvm::FunctionType* GBCExpanderPass::GetFunctionType(llvm::Type* ret_type, uint32_t method_idx,
+                                                     bool is_static) {
+  // Get method signature
+  art::DexFile::MethodId const& method_id =
+      dex_compilation_unit_->GetDexFile()->GetMethodId(method_idx);
+
+  uint32_t shorty_size;
+  const char* shorty = dex_compilation_unit_->GetDexFile()->GetMethodShorty(method_id, &shorty_size);
+  CHECK_GE(shorty_size, 1u);
+
+  // Get argument type
+  std::vector<llvm::Type*> args_type;
+
+  args_type.push_back(irb_.getJObjectTy()); // method object pointer
+
+  if (!is_static) {
+    args_type.push_back(irb_.getJType('L')); // "this" object pointer
+  }
+
+  for (uint32_t i = 1; i < shorty_size; ++i) {
+    char shorty_type = art::RemapShorty(shorty[i]);
+    args_type.push_back(irb_.getJType(shorty_type));
+  }
+
+  return llvm::FunctionType::get(ret_type, args_type, false);
+}
+
+
+llvm::BasicBlock* GBCExpanderPass::
+CreateBasicBlockWithDexPC(uint32_t dex_pc, const char* postfix) {
+  std::string name;
+
+#if !defined(NDEBUG)
+  art::StringAppendF(&name, "B%04x.%s", dex_pc, postfix);
+#endif
+
+  return llvm::BasicBlock::Create(context_, name, func_);
+}
+
+llvm::BasicBlock* GBCExpanderPass::GetBasicBlock(uint32_t dex_pc) {
+  DCHECK(dex_pc < dex_compilation_unit_->GetCodeItem()->insns_size_in_code_units_);
+  CHECK(basic_blocks_[dex_pc] != NULL);
+  return basic_blocks_[dex_pc];
+}
+
+int32_t GBCExpanderPass::GetTryItemOffset(uint32_t dex_pc) {
+  int32_t min = 0;
+  int32_t max = dex_compilation_unit_->GetCodeItem()->tries_size_ - 1;
+
+  while (min <= max) {
+    int32_t mid = min + (max - min) / 2;
+
+    const art::DexFile::TryItem* ti =
+        art::DexFile::GetTryItems(*dex_compilation_unit_->GetCodeItem(), mid);
+    uint32_t start = ti->start_addr_;
+    uint32_t end = start + ti->insn_count_;
+
+    if (dex_pc < start) {
+      max = mid - 1;
+    } else if (dex_pc >= end) {
+      min = mid + 1;
+    } else {
+      return mid; // found
+    }
+  }
+
+  return -1; // not found
+}
+
+llvm::BasicBlock* GBCExpanderPass::GetLandingPadBasicBlock(uint32_t dex_pc) {
+  // Find the try item for this address in this method
+  int32_t ti_offset = GetTryItemOffset(dex_pc);
+
+  if (ti_offset == -1) {
+    return NULL; // No landing pad is available for this address.
+  }
+
+  // Check for the existing landing pad basic block
+  DCHECK_GT(basic_block_landing_pads_.size(), static_cast<size_t>(ti_offset));
+  llvm::BasicBlock* block_lpad = basic_block_landing_pads_[ti_offset];
+
+  if (block_lpad) {
+    // We have generated landing pad for this try item already.  Return the
+    // same basic block.
+    return block_lpad;
+  }
+
+  // Get try item from code item
+  const art::DexFile::TryItem* ti = art::DexFile::GetTryItems(*dex_compilation_unit_->GetCodeItem(),
+                                                              ti_offset);
+
+  std::string lpadname;
+
+#if !defined(NDEBUG)
+  art::StringAppendF(&lpadname, "lpad%d_%04x_to_%04x", ti_offset, ti->start_addr_, ti->handler_off_);
+#endif
+
+  // Create landing pad basic block
+  block_lpad = llvm::BasicBlock::Create(context_, lpadname, func_);
+
+  // Change IRBuilder insert point
+  llvm::IRBuilderBase::InsertPoint irb_ip_original = irb_.saveIP();
+  irb_.SetInsertPoint(block_lpad);
+
+  // Find catch block with matching type
+  llvm::Value* method_object_addr = EmitLoadMethodObjectAddr();
+
+  llvm::Value* ti_offset_value = irb_.getInt32(ti_offset);
+
+  llvm::Value* catch_handler_index_value =
+    irb_.CreateCall2(irb_.GetRuntime(runtime_support::FindCatchBlock),
+                     method_object_addr, ti_offset_value);
+
+  // Switch instruction (Go to unwind basic block by default)
+  llvm::SwitchInst* sw =
+    irb_.CreateSwitch(catch_handler_index_value, GetUnwindBasicBlock());
+
+  // Cases with matched catch block
+  art::CatchHandlerIterator iter(*dex_compilation_unit_->GetCodeItem(), ti->start_addr_);
+
+  for (uint32_t c = 0; iter.HasNext(); iter.Next(), ++c) {
+    sw->addCase(irb_.getInt32(c), GetBasicBlock(iter.GetHandlerAddress()));
+  }
+
+  // Restore the orignal insert point for IRBuilder
+  irb_.restoreIP(irb_ip_original);
+
+  // Cache this landing pad
+  DCHECK_GT(basic_block_landing_pads_.size(), static_cast<size_t>(ti_offset));
+  basic_block_landing_pads_[ti_offset] = block_lpad;
+
+  return block_lpad;
+}
+
+llvm::BasicBlock* GBCExpanderPass::GetUnwindBasicBlock() {
+  // Check the existing unwinding baisc block block
+  if (basic_block_unwind_ != NULL) {
+    return basic_block_unwind_;
+  }
+
+  // Create new basic block for unwinding
+  basic_block_unwind_ =
+    llvm::BasicBlock::Create(context_, "exception_unwind", func_);
+
+  // Change IRBuilder insert point
+  llvm::IRBuilderBase::InsertPoint irb_ip_original = irb_.saveIP();
+  irb_.SetInsertPoint(basic_block_unwind_);
+
+  // Pop the shadow frame
+  Expand_PopShadowFrame();
+
+  // Emit the code to return default value (zero) for the given return type.
+  char ret_shorty = dex_compilation_unit_->GetShorty()[0];
+  ret_shorty = art::RemapShorty(ret_shorty);
+  if (ret_shorty == 'V') {
+    irb_.CreateRetVoid();
+  } else {
+    irb_.CreateRet(irb_.getJZero(ret_shorty));
+  }
+
+  // Restore the orignal insert point for IRBuilder
+  irb_.restoreIP(irb_ip_original);
+
+  return basic_block_unwind_;
+}
+
+void GBCExpanderPass::EmitBranchExceptionLandingPad(uint32_t dex_pc) {
+  if (llvm::BasicBlock* lpad = GetLandingPadBasicBlock(dex_pc)) {
+    landing_pad_phi_mapping_[lpad].push_back(std::make_pair(current_bb_->getUniquePredecessor(),
+                                                            irb_.GetInsertBlock()));
+    irb_.CreateBr(lpad);
+  } else {
+    irb_.CreateBr(GetUnwindBasicBlock());
+  }
+}
+
+void GBCExpanderPass::EmitGuard_ExceptionLandingPad(uint32_t dex_pc) {
+  llvm::Value* exception_pending = irb_.Runtime().EmitIsExceptionPending();
+
+  llvm::BasicBlock* block_cont = CreateBasicBlockWithDexPC(dex_pc, "cont");
+
+  if (llvm::BasicBlock* lpad = GetLandingPadBasicBlock(dex_pc)) {
+    landing_pad_phi_mapping_[lpad].push_back(std::make_pair(current_bb_->getUniquePredecessor(),
+                                                            irb_.GetInsertBlock()));
+    irb_.CreateCondBr(exception_pending, lpad, block_cont, kUnlikely);
+  } else {
+    irb_.CreateCondBr(exception_pending, GetUnwindBasicBlock(), block_cont, kUnlikely);
+  }
+
+  irb_.SetInsertPoint(block_cont);
+}
+
+llvm::Value*
+GBCExpanderPass::ExpandIntrinsic(IntrinsicHelper::IntrinsicId intr_id,
+                                 llvm::CallInst& call_inst) {
+  switch (intr_id) {
+    //==- Thread -----------------------------------------------------------==//
+    case IntrinsicHelper::GetCurrentThread: {
+      return irb_.Runtime().EmitGetCurrentThread();
+    }
+    case IntrinsicHelper::CheckSuspend: {
+      Expand_TestSuspend(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::TestSuspend: {
+      Expand_TestSuspend(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::MarkGCCard: {
+      Expand_MarkGCCard(call_inst);
+      return NULL;
+    }
+
+    //==- Exception --------------------------------------------------------==//
+    case IntrinsicHelper::ThrowException: {
+      return ExpandToRuntime(runtime_support::ThrowException, call_inst);
+    }
+    case IntrinsicHelper::HLThrowException: {
+      uint32_t dex_pc = LV2UInt(call_inst.getMetadata("DexOff")->getOperand(0));
+
+      EmitUpdateDexPC(dex_pc);
+
+      irb_.CreateCall(irb_.GetRuntime(runtime_support::ThrowException),
+                      call_inst.getArgOperand(0));
+
+      EmitGuard_ExceptionLandingPad(dex_pc);
+      return NULL;
+    }
+    case IntrinsicHelper::GetException: {
+      return irb_.Runtime().EmitGetAndClearException();
+    }
+    case IntrinsicHelper::IsExceptionPending: {
+      return irb_.Runtime().EmitIsExceptionPending();
+    }
+    case IntrinsicHelper::FindCatchBlock: {
+      return ExpandToRuntime(runtime_support::FindCatchBlock, call_inst);
+    }
+    case IntrinsicHelper::ThrowDivZeroException: {
+      return ExpandToRuntime(runtime_support::ThrowDivZeroException, call_inst);
+    }
+    case IntrinsicHelper::ThrowNullPointerException: {
+      return ExpandToRuntime(runtime_support::ThrowNullPointerException, call_inst);
+    }
+    case IntrinsicHelper::ThrowIndexOutOfBounds: {
+      return ExpandToRuntime(runtime_support::ThrowIndexOutOfBounds, call_inst);
+    }
+
+    //==- Const String -----------------------------------------------------==//
+    case IntrinsicHelper::ConstString: {
+      return Expand_ConstString(call_inst);
+    }
+    case IntrinsicHelper::LoadStringFromDexCache: {
+      return Expand_LoadStringFromDexCache(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::ResolveString: {
+      return ExpandToRuntime(runtime_support::ResolveString, call_inst);
+    }
+
+    //==- Const Class ------------------------------------------------------==//
+    case IntrinsicHelper::ConstClass: {
+      return Expand_ConstClass(call_inst);
+    }
+    case IntrinsicHelper::InitializeTypeAndVerifyAccess: {
+      return ExpandToRuntime(runtime_support::InitializeTypeAndVerifyAccess, call_inst);
+    }
+    case IntrinsicHelper::LoadTypeFromDexCache: {
+      return Expand_LoadTypeFromDexCache(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::InitializeType: {
+      return ExpandToRuntime(runtime_support::InitializeType, call_inst);
+    }
+
+    //==- Lock -------------------------------------------------------------==//
+    case IntrinsicHelper::LockObject: {
+      Expand_LockObject(call_inst.getArgOperand(0));
+      return NULL;
+    }
+    case IntrinsicHelper::UnlockObject: {
+      Expand_UnlockObject(call_inst.getArgOperand(0));
+      return NULL;
+    }
+
+    //==- Cast -------------------------------------------------------------==//
+    case IntrinsicHelper::CheckCast: {
+      return ExpandToRuntime(runtime_support::CheckCast, call_inst);
+    }
+    case IntrinsicHelper::HLCheckCast: {
+      Expand_HLCheckCast(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::IsAssignable: {
+      return ExpandToRuntime(runtime_support::IsAssignable, call_inst);
+    }
+
+    //==- Alloc ------------------------------------------------------------==//
+    case IntrinsicHelper::AllocObject: {
+      return ExpandToRuntime(runtime_support::AllocObject, call_inst);
+    }
+    case IntrinsicHelper::AllocObjectWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::AllocObjectWithAccessCheck, call_inst);
+    }
+
+    //==- Instance ---------------------------------------------------------==//
+    case IntrinsicHelper::NewInstance: {
+      return Expand_NewInstance(call_inst);
+    }
+    case IntrinsicHelper::InstanceOf: {
+      return Expand_InstanceOf(call_inst);
+    }
+
+    //==- Array ------------------------------------------------------------==//
+    case IntrinsicHelper::NewArray: {
+      return Expand_NewArray(call_inst);
+    }
+    case IntrinsicHelper::OptArrayLength: {
+      return Expand_OptArrayLength(call_inst);
+    }
+    case IntrinsicHelper::ArrayLength: {
+      return EmitLoadArrayLength(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::AllocArray: {
+      return ExpandToRuntime(runtime_support::AllocArray, call_inst);
+    }
+    case IntrinsicHelper::AllocArrayWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::AllocArrayWithAccessCheck,
+                             call_inst);
+    }
+    case IntrinsicHelper::CheckAndAllocArray: {
+      return ExpandToRuntime(runtime_support::CheckAndAllocArray, call_inst);
+    }
+    case IntrinsicHelper::CheckAndAllocArrayWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::CheckAndAllocArrayWithAccessCheck,
+                             call_inst);
+    }
+    case IntrinsicHelper::ArrayGet: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kInt);
+    }
+    case IntrinsicHelper::ArrayGetWide: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kLong);
+    }
+    case IntrinsicHelper::ArrayGetObject: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kObject);
+    }
+    case IntrinsicHelper::ArrayGetBoolean: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kBoolean);
+    }
+    case IntrinsicHelper::ArrayGetByte: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kByte);
+    }
+    case IntrinsicHelper::ArrayGetChar: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kChar);
+    }
+    case IntrinsicHelper::ArrayGetShort: {
+      return Expand_ArrayGet(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             kShort);
+    }
+    case IntrinsicHelper::ArrayPut: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutWide: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutObject: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kObject);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutBoolean: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutByte: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutChar: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::ArrayPutShort: {
+      Expand_ArrayPut(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      kShort);
+      return NULL;
+    }
+    case IntrinsicHelper::CheckPutArrayElement: {
+      return ExpandToRuntime(runtime_support::CheckPutArrayElement, call_inst);
+    }
+    case IntrinsicHelper::FilledNewArray: {
+      Expand_FilledNewArray(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::FillArrayData: {
+      return ExpandToRuntime(runtime_support::FillArrayData, call_inst);
+    }
+    case IntrinsicHelper::HLFillArrayData: {
+      Expand_HLFillArrayData(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::HLFilledNewArray: {
+      return Expand_HLFilledNewArray(call_inst);
+    }
+
+    //==- Instance Field ---------------------------------------------------==//
+    case IntrinsicHelper::InstanceFieldGet:
+    case IntrinsicHelper::InstanceFieldGetBoolean:
+    case IntrinsicHelper::InstanceFieldGetByte:
+    case IntrinsicHelper::InstanceFieldGetChar:
+    case IntrinsicHelper::InstanceFieldGetShort: {
+      return ExpandToRuntime(runtime_support::Get32Instance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldGetWide: {
+      return ExpandToRuntime(runtime_support::Get64Instance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldGetObject: {
+      return ExpandToRuntime(runtime_support::GetObjectInstance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldGetFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kInt);
+    }
+    case IntrinsicHelper::InstanceFieldGetWideFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kLong);
+    }
+    case IntrinsicHelper::InstanceFieldGetObjectFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kObject);
+    }
+    case IntrinsicHelper::InstanceFieldGetBooleanFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kBoolean);
+    }
+    case IntrinsicHelper::InstanceFieldGetByteFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kByte);
+    }
+    case IntrinsicHelper::InstanceFieldGetCharFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kChar);
+    }
+    case IntrinsicHelper::InstanceFieldGetShortFast: {
+      return Expand_IGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kShort);
+    }
+    case IntrinsicHelper::InstanceFieldPut:
+    case IntrinsicHelper::InstanceFieldPutBoolean:
+    case IntrinsicHelper::InstanceFieldPutByte:
+    case IntrinsicHelper::InstanceFieldPutChar:
+    case IntrinsicHelper::InstanceFieldPutShort: {
+      return ExpandToRuntime(runtime_support::Set32Instance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldPutWide: {
+      return ExpandToRuntime(runtime_support::Set64Instance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldPutObject: {
+      return ExpandToRuntime(runtime_support::SetObjectInstance, call_inst);
+    }
+    case IntrinsicHelper::InstanceFieldPutFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutWideFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutObjectFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kObject);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutBooleanFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutByteFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutCharFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::InstanceFieldPutShortFast: {
+      Expand_IPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kShort);
+      return NULL;
+    }
+
+    //==- Static Field -----------------------------------------------------==//
+    case IntrinsicHelper::StaticFieldGet:
+    case IntrinsicHelper::StaticFieldGetBoolean:
+    case IntrinsicHelper::StaticFieldGetByte:
+    case IntrinsicHelper::StaticFieldGetChar:
+    case IntrinsicHelper::StaticFieldGetShort: {
+      return ExpandToRuntime(runtime_support::Get32Static, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldGetWide: {
+      return ExpandToRuntime(runtime_support::Get64Static, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldGetObject: {
+      return ExpandToRuntime(runtime_support::GetObjectStatic, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldGetFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kInt);
+    }
+    case IntrinsicHelper::StaticFieldGetWideFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kLong);
+    }
+    case IntrinsicHelper::StaticFieldGetObjectFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kObject);
+    }
+    case IntrinsicHelper::StaticFieldGetBooleanFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kBoolean);
+    }
+    case IntrinsicHelper::StaticFieldGetByteFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kByte);
+    }
+    case IntrinsicHelper::StaticFieldGetCharFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kChar);
+    }
+    case IntrinsicHelper::StaticFieldGetShortFast: {
+      return Expand_SGetFast(call_inst.getArgOperand(0),
+                             call_inst.getArgOperand(1),
+                             call_inst.getArgOperand(2),
+                             kShort);
+    }
+    case IntrinsicHelper::StaticFieldPut:
+    case IntrinsicHelper::StaticFieldPutBoolean:
+    case IntrinsicHelper::StaticFieldPutByte:
+    case IntrinsicHelper::StaticFieldPutChar:
+    case IntrinsicHelper::StaticFieldPutShort: {
+      return ExpandToRuntime(runtime_support::Set32Static, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldPutWide: {
+      return ExpandToRuntime(runtime_support::Set64Static, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldPutObject: {
+      return ExpandToRuntime(runtime_support::SetObjectStatic, call_inst);
+    }
+    case IntrinsicHelper::StaticFieldPutFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutWideFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutObjectFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kObject);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutBooleanFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutByteFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutCharFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::StaticFieldPutShortFast: {
+      Expand_SPutFast(call_inst.getArgOperand(0),
+                      call_inst.getArgOperand(1),
+                      call_inst.getArgOperand(2),
+                      call_inst.getArgOperand(3),
+                      kShort);
+      return NULL;
+    }
+    case IntrinsicHelper::LoadDeclaringClassSSB: {
+      return Expand_LoadDeclaringClassSSB(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::LoadClassSSBFromDexCache: {
+      return Expand_LoadClassSSBFromDexCache(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::InitializeAndLoadClassSSB: {
+      return ExpandToRuntime(runtime_support::InitializeStaticStorage, call_inst);
+    }
+
+    //==- High-level Array -------------------------------------------------==//
+    case IntrinsicHelper::HLArrayGet: {
+      return Expand_HLArrayGet(call_inst, kInt);
+    }
+    case IntrinsicHelper::HLArrayGetBoolean: {
+      return Expand_HLArrayGet(call_inst, kBoolean);
+    }
+    case IntrinsicHelper::HLArrayGetByte: {
+      return Expand_HLArrayGet(call_inst, kByte);
+    }
+    case IntrinsicHelper::HLArrayGetChar: {
+      return Expand_HLArrayGet(call_inst, kChar);
+    }
+    case IntrinsicHelper::HLArrayGetShort: {
+      return Expand_HLArrayGet(call_inst, kShort);
+    }
+    case IntrinsicHelper::HLArrayGetFloat: {
+      return Expand_HLArrayGet(call_inst, kFloat);
+    }
+    case IntrinsicHelper::HLArrayGetWide: {
+      return Expand_HLArrayGet(call_inst, kLong);
+    }
+    case IntrinsicHelper::HLArrayGetDouble: {
+      return Expand_HLArrayGet(call_inst, kDouble);
+    }
+    case IntrinsicHelper::HLArrayGetObject: {
+      return Expand_HLArrayGet(call_inst, kObject);
+    }
+    case IntrinsicHelper::HLArrayPut: {
+      Expand_HLArrayPut(call_inst, kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutBoolean: {
+      Expand_HLArrayPut(call_inst, kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutByte: {
+      Expand_HLArrayPut(call_inst, kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutChar: {
+      Expand_HLArrayPut(call_inst, kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutShort: {
+      Expand_HLArrayPut(call_inst, kShort);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutFloat: {
+      Expand_HLArrayPut(call_inst, kFloat);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutWide: {
+      Expand_HLArrayPut(call_inst, kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutDouble: {
+      Expand_HLArrayPut(call_inst, kDouble);
+      return NULL;
+    }
+    case IntrinsicHelper::HLArrayPutObject: {
+      Expand_HLArrayPut(call_inst, kObject);
+      return NULL;
+    }
+
+    //==- High-level Instance ----------------------------------------------==//
+    case IntrinsicHelper::HLIGet: {
+      return Expand_HLIGet(call_inst, kInt);
+    }
+    case IntrinsicHelper::HLIGetBoolean: {
+      return Expand_HLIGet(call_inst, kBoolean);
+    }
+    case IntrinsicHelper::HLIGetByte: {
+      return Expand_HLIGet(call_inst, kByte);
+    }
+    case IntrinsicHelper::HLIGetChar: {
+      return Expand_HLIGet(call_inst, kChar);
+    }
+    case IntrinsicHelper::HLIGetShort: {
+      return Expand_HLIGet(call_inst, kShort);
+    }
+    case IntrinsicHelper::HLIGetFloat: {
+      return Expand_HLIGet(call_inst, kFloat);
+    }
+    case IntrinsicHelper::HLIGetWide: {
+      return Expand_HLIGet(call_inst, kLong);
+    }
+    case IntrinsicHelper::HLIGetDouble: {
+      return Expand_HLIGet(call_inst, kDouble);
+    }
+    case IntrinsicHelper::HLIGetObject: {
+      return Expand_HLIGet(call_inst, kObject);
+    }
+    case IntrinsicHelper::HLIPut: {
+      Expand_HLIPut(call_inst, kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutBoolean: {
+      Expand_HLIPut(call_inst, kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutByte: {
+      Expand_HLIPut(call_inst, kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutChar: {
+      Expand_HLIPut(call_inst, kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutShort: {
+      Expand_HLIPut(call_inst, kShort);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutFloat: {
+      Expand_HLIPut(call_inst, kFloat);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutWide: {
+      Expand_HLIPut(call_inst, kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutDouble: {
+      Expand_HLIPut(call_inst, kDouble);
+      return NULL;
+    }
+    case IntrinsicHelper::HLIPutObject: {
+      Expand_HLIPut(call_inst, kObject);
+      return NULL;
+    }
+
+    //==- High-level Invoke ------------------------------------------------==//
+    case IntrinsicHelper::HLInvokeVoid:
+    case IntrinsicHelper::HLInvokeObj:
+    case IntrinsicHelper::HLInvokeInt:
+    case IntrinsicHelper::HLInvokeFloat:
+    case IntrinsicHelper::HLInvokeLong:
+    case IntrinsicHelper::HLInvokeDouble: {
+      return Expand_HLInvoke(call_inst);
+    }
+
+    //==- Invoke -----------------------------------------------------------==//
+    case IntrinsicHelper::FindStaticMethodWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::FindStaticMethodWithAccessCheck, call_inst);
+    }
+    case IntrinsicHelper::FindDirectMethodWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::FindDirectMethodWithAccessCheck, call_inst);
+    }
+    case IntrinsicHelper::FindVirtualMethodWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::FindVirtualMethodWithAccessCheck, call_inst);
+    }
+    case IntrinsicHelper::FindSuperMethodWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::FindSuperMethodWithAccessCheck, call_inst);
+    }
+    case IntrinsicHelper::FindInterfaceMethodWithAccessCheck: {
+      return ExpandToRuntime(runtime_support::FindInterfaceMethodWithAccessCheck, call_inst);
+    }
+    case IntrinsicHelper::GetSDCalleeMethodObjAddrFast: {
+      return Expand_GetSDCalleeMethodObjAddrFast(call_inst.getArgOperand(0));
+    }
+    case IntrinsicHelper::GetVirtualCalleeMethodObjAddrFast: {
+      return Expand_GetVirtualCalleeMethodObjAddrFast(
+                call_inst.getArgOperand(0), call_inst.getArgOperand(1));
+    }
+    case IntrinsicHelper::GetInterfaceCalleeMethodObjAddrFast: {
+      return ExpandToRuntime(runtime_support::FindInterfaceMethod, call_inst);
+    }
+    case IntrinsicHelper::InvokeRetVoid:
+    case IntrinsicHelper::InvokeRetBoolean:
+    case IntrinsicHelper::InvokeRetByte:
+    case IntrinsicHelper::InvokeRetChar:
+    case IntrinsicHelper::InvokeRetShort:
+    case IntrinsicHelper::InvokeRetInt:
+    case IntrinsicHelper::InvokeRetLong:
+    case IntrinsicHelper::InvokeRetFloat:
+    case IntrinsicHelper::InvokeRetDouble:
+    case IntrinsicHelper::InvokeRetObject: {
+      return Expand_Invoke(call_inst);
+    }
+
+    //==- Math -------------------------------------------------------------==//
+    case IntrinsicHelper::DivInt: {
+      return Expand_DivRem(call_inst, /* is_div */true, kInt);
+    }
+    case IntrinsicHelper::RemInt: {
+      return Expand_DivRem(call_inst, /* is_div */false, kInt);
+    }
+    case IntrinsicHelper::DivLong: {
+      return Expand_DivRem(call_inst, /* is_div */true, kLong);
+    }
+    case IntrinsicHelper::RemLong: {
+      return Expand_DivRem(call_inst, /* is_div */false, kLong);
+    }
+    case IntrinsicHelper::D2L: {
+      return ExpandToRuntime(runtime_support::art_d2l, call_inst);
+    }
+    case IntrinsicHelper::D2I: {
+      return ExpandToRuntime(runtime_support::art_d2i, call_inst);
+    }
+    case IntrinsicHelper::F2L: {
+      return ExpandToRuntime(runtime_support::art_f2l, call_inst);
+    }
+    case IntrinsicHelper::F2I: {
+      return ExpandToRuntime(runtime_support::art_f2i, call_inst);
+    }
+
+    //==- High-level Static ------------------------------------------------==//
+    case IntrinsicHelper::HLSget: {
+      return Expand_HLSget(call_inst, kInt);
+    }
+    case IntrinsicHelper::HLSgetBoolean: {
+      return Expand_HLSget(call_inst, kBoolean);
+    }
+    case IntrinsicHelper::HLSgetByte: {
+      return Expand_HLSget(call_inst, kByte);
+    }
+    case IntrinsicHelper::HLSgetChar: {
+      return Expand_HLSget(call_inst, kChar);
+    }
+    case IntrinsicHelper::HLSgetShort: {
+      return Expand_HLSget(call_inst, kShort);
+    }
+    case IntrinsicHelper::HLSgetFloat: {
+      return Expand_HLSget(call_inst, kFloat);
+    }
+    case IntrinsicHelper::HLSgetWide: {
+      return Expand_HLSget(call_inst, kLong);
+    }
+    case IntrinsicHelper::HLSgetDouble: {
+      return Expand_HLSget(call_inst, kDouble);
+    }
+    case IntrinsicHelper::HLSgetObject: {
+      return Expand_HLSget(call_inst, kObject);
+    }
+    case IntrinsicHelper::HLSput: {
+      Expand_HLSput(call_inst, kInt);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputBoolean: {
+      Expand_HLSput(call_inst, kBoolean);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputByte: {
+      Expand_HLSput(call_inst, kByte);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputChar: {
+      Expand_HLSput(call_inst, kChar);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputShort: {
+      Expand_HLSput(call_inst, kShort);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputFloat: {
+      Expand_HLSput(call_inst, kFloat);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputWide: {
+      Expand_HLSput(call_inst, kLong);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputDouble: {
+      Expand_HLSput(call_inst, kDouble);
+      return NULL;
+    }
+    case IntrinsicHelper::HLSputObject: {
+      Expand_HLSput(call_inst, kObject);
+      return NULL;
+    }
+
+    //==- High-level Monitor -----------------------------------------------==//
+    case IntrinsicHelper::MonitorEnter: {
+      Expand_MonitorEnter(call_inst);
+      return NULL;
+    }
+    case IntrinsicHelper::MonitorExit: {
+      Expand_MonitorExit(call_inst);
+      return NULL;
+    }
+
+    //==- Shadow Frame -----------------------------------------------------==//
+    case IntrinsicHelper::AllocaShadowFrame: {
+      Expand_AllocaShadowFrame(call_inst.getArgOperand(0));
+      return NULL;
+    }
+    case IntrinsicHelper::SetVReg: {
+      Expand_SetVReg(call_inst.getArgOperand(0),
+                     call_inst.getArgOperand(1));
+      return NULL;
+    }
+    case IntrinsicHelper::PopShadowFrame: {
+      Expand_PopShadowFrame();
+      return NULL;
+    }
+    case IntrinsicHelper::UpdateDexPC: {
+      Expand_UpdateDexPC(call_inst.getArgOperand(0));
+      return NULL;
+    }
+
+    //==- Comparison -------------------------------------------------------==//
+    case IntrinsicHelper::CmplFloat:
+    case IntrinsicHelper::CmplDouble: {
+      return Expand_FPCompare(call_inst.getArgOperand(0),
+                              call_inst.getArgOperand(1),
+                              false);
+    }
+    case IntrinsicHelper::CmpgFloat:
+    case IntrinsicHelper::CmpgDouble: {
+      return Expand_FPCompare(call_inst.getArgOperand(0),
+                              call_inst.getArgOperand(1),
+                              true);
+    }
+    case IntrinsicHelper::CmpLong: {
+      return Expand_LongCompare(call_inst.getArgOperand(0),
+                                call_inst.getArgOperand(1));
+    }
+
+    //==- Const ------------------------------------------------------------==//
+    case IntrinsicHelper::ConstInt:
+    case IntrinsicHelper::ConstLong: {
+      return call_inst.getArgOperand(0);
+    }
+    case IntrinsicHelper::ConstFloat: {
+      return irb_.CreateBitCast(call_inst.getArgOperand(0),
+                                irb_.getJFloatTy());
+    }
+    case IntrinsicHelper::ConstDouble: {
+      return irb_.CreateBitCast(call_inst.getArgOperand(0),
+                                irb_.getJDoubleTy());
+    }
+    case IntrinsicHelper::ConstObj: {
+      CHECK(LV2UInt(call_inst.getArgOperand(0)) == 0);
+      return irb_.getJNull();
+    }
+
+    //==- Method Info ------------------------------------------------------==//
+    case IntrinsicHelper::MethodInfo: {
+      // Nothing to be done, because MethodInfo carries optional hints that are
+      // not needed by the portable path.
+      return NULL;
+    }
+
+    //==- Copy -------------------------------------------------------------==//
+    case IntrinsicHelper::CopyInt:
+    case IntrinsicHelper::CopyFloat:
+    case IntrinsicHelper::CopyLong:
+    case IntrinsicHelper::CopyDouble:
+    case IntrinsicHelper::CopyObj: {
+      return call_inst.getArgOperand(0);
+    }
+
+    //==- Shift ------------------------------------------------------------==//
+    case IntrinsicHelper::SHLLong: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerSHL, kLong);
+    }
+    case IntrinsicHelper::SHRLong: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerSHR, kLong);
+    }
+    case IntrinsicHelper::USHRLong: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerUSHR, kLong);
+    }
+    case IntrinsicHelper::SHLInt: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerSHL, kInt);
+    }
+    case IntrinsicHelper::SHRInt: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerSHR, kInt);
+    }
+    case IntrinsicHelper::USHRInt: {
+      return Expand_IntegerShift(call_inst.getArgOperand(0),
+                                 call_inst.getArgOperand(1),
+                                 kIntegerUSHR, kInt);
+    }
+
+    //==- Conversion -------------------------------------------------------==//
+    case IntrinsicHelper::IntToChar: {
+      return irb_.CreateZExt(irb_.CreateTrunc(call_inst.getArgOperand(0), irb_.getJCharTy()),
+                             irb_.getJIntTy());
+    }
+    case IntrinsicHelper::IntToShort: {
+      return irb_.CreateSExt(irb_.CreateTrunc(call_inst.getArgOperand(0), irb_.getJShortTy()),
+                             irb_.getJIntTy());
+    }
+    case IntrinsicHelper::IntToByte: {
+      return irb_.CreateSExt(irb_.CreateTrunc(call_inst.getArgOperand(0), irb_.getJByteTy()),
+                             irb_.getJIntTy());
+    }
+
+    //==- Exception --------------------------------------------------------==//
+    case IntrinsicHelper::CatchTargets: {
+      UpdatePhiInstruction(current_bb_, irb_.GetInsertBlock());
+      llvm::SwitchInst* si = llvm::dyn_cast<llvm::SwitchInst>(call_inst.getNextNode());
+      CHECK(si != NULL);
+      irb_.CreateBr(si->getDefaultDest());
+      si->eraseFromParent();
+      return call_inst.getArgOperand(0);
+    }
+
+    //==- Constructor barrier-----------------------------------------------==//
+    case IntrinsicHelper::ConstructorBarrier: {
+      irb_.CreateMemoryBarrier(art::kStoreStore);
+      return NULL;
+    }
+
+    //==- Unknown Cases ----------------------------------------------------==//
+    case IntrinsicHelper::MaxIntrinsicId:
+    case IntrinsicHelper::UnknownId:
+    //default:
+      // NOTE: "default" is intentionally commented so that C/C++ compiler will
+      // give some warning on unmatched cases.
+      // NOTE: We should not implement these cases.
+      break;
+  }
+  UNIMPLEMENTED(FATAL) << "Unexpected GBC intrinsic: " << static_cast<int>(intr_id);
+  return NULL;
+}
+
+} // anonymous namespace
+
+namespace art {
+namespace llvm {
+
+::llvm::FunctionPass*
+CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
+                      CompilerDriver* driver, DexCompilationUnit* dex_compilation_unit) {
+  return new GBCExpanderPass(intrinsic_helper, irb, driver, dex_compilation_unit);
+}
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/generated/art_module.cc b/src/compiler/llvm/generated/art_module.cc
new file mode 100644
index 0000000..2748cd6
--- /dev/null
+++ b/src/compiler/llvm/generated/art_module.cc
@@ -0,0 +1,1096 @@
+// Generated with ../tools/gen_art_module_cc.sh
+
+
+#pragma GCC diagnostic ignored "-Wframe-larger-than="
+// TODO: Remove this pragma after llc can generate makeLLVMModuleContents()
+// with smaller frame size.
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+#include <vector>
+
+using namespace llvm;
+
+namespace art {
+namespace llvm {
+
+
+// Generated by llvm2cpp - DO NOT MODIFY!
+
+
+Module* makeLLVMModuleContents(Module *mod) {
+
+mod->setModuleIdentifier("art_module.ll");
+
+// Type Definitions
+std::vector<Type*>FuncTy_0_args;
+StructType *StructTy_JavaObject = mod->getTypeByName("JavaObject");
+if (!StructTy_JavaObject) {
+StructTy_JavaObject = StructType::create(mod->getContext(), "JavaObject");
+}
+std::vector<Type*>StructTy_JavaObject_fields;
+if (StructTy_JavaObject->isOpaque()) {
+StructTy_JavaObject->setBody(StructTy_JavaObject_fields, /*isPacked=*/false);
+}
+
+PointerType* PointerTy_1 = PointerType::get(StructTy_JavaObject, 0);
+
+FuncTy_0_args.push_back(PointerTy_1);
+StructType *StructTy_ShadowFrame = mod->getTypeByName("ShadowFrame");
+if (!StructTy_ShadowFrame) {
+StructTy_ShadowFrame = StructType::create(mod->getContext(), "ShadowFrame");
+}
+std::vector<Type*>StructTy_ShadowFrame_fields;
+StructTy_ShadowFrame_fields.push_back(IntegerType::get(mod->getContext(), 32));
+PointerType* PointerTy_2 = PointerType::get(StructTy_ShadowFrame, 0);
+
+StructTy_ShadowFrame_fields.push_back(PointerTy_2);
+StructTy_ShadowFrame_fields.push_back(PointerTy_1);
+StructTy_ShadowFrame_fields.push_back(IntegerType::get(mod->getContext(), 32));
+if (StructTy_ShadowFrame->isOpaque()) {
+StructTy_ShadowFrame->setBody(StructTy_ShadowFrame_fields, /*isPacked=*/false);
+}
+
+
+FuncTy_0_args.push_back(PointerTy_2);
+FunctionType* FuncTy_0 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_0_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_3_args;
+FunctionType* FuncTy_3 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_3_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_4_args;
+FuncTy_4_args.push_back(PointerTy_1);
+FunctionType* FuncTy_4 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_4_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_5_args;
+FuncTy_5_args.push_back(PointerTy_1);
+FuncTy_5_args.push_back(PointerTy_1);
+FunctionType* FuncTy_5 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_5_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_6_args;
+FuncTy_6_args.push_back(PointerTy_1);
+FunctionType* FuncTy_6 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_6_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_7_args;
+FuncTy_7_args.push_back(PointerTy_1);
+FuncTy_7_args.push_back(PointerTy_2);
+FuncTy_7_args.push_back(PointerTy_1);
+FuncTy_7_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_7 = FunctionType::get(
+ /*Result=*/PointerTy_2,
+ /*Params=*/FuncTy_7_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_8_args;
+FuncTy_8_args.push_back(PointerTy_2);
+FunctionType* FuncTy_8 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_8_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_9_args;
+FunctionType* FuncTy_9 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_9_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_10_args;
+FuncTy_10_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_10_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_10 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_10_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_11_args;
+FuncTy_11_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_11 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_11_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_12_args;
+FuncTy_12_args.push_back(PointerTy_1);
+FuncTy_12_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_12 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_12_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_13_args;
+FuncTy_13_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_13_args.push_back(PointerTy_1);
+FuncTy_13_args.push_back(PointerTy_1);
+FunctionType* FuncTy_13 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_13_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_14_args;
+FuncTy_14_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_14_args.push_back(PointerTy_1);
+FuncTy_14_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_14_args.push_back(PointerTy_1);
+FunctionType* FuncTy_14 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_14_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_15_args;
+FuncTy_15_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_15_args.push_back(PointerTy_1);
+FunctionType* FuncTy_15 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_15_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_16_args;
+FuncTy_16_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_16_args.push_back(PointerTy_1);
+FuncTy_16_args.push_back(PointerTy_1);
+FuncTy_16_args.push_back(PointerTy_1);
+FunctionType* FuncTy_16 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_16_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_17_args;
+FuncTy_17_args.push_back(PointerTy_1);
+FuncTy_17_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_17 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_17_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_18_args;
+FuncTy_18_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_18_args.push_back(PointerTy_1);
+FuncTy_18_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_18 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_18_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_19_args;
+FuncTy_19_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_19_args.push_back(PointerTy_1);
+FuncTy_19_args.push_back(IntegerType::get(mod->getContext(), 64));
+FunctionType* FuncTy_19 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_19_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_20_args;
+FuncTy_20_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_20_args.push_back(PointerTy_1);
+FuncTy_20_args.push_back(PointerTy_1);
+FunctionType* FuncTy_20 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_20_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_21_args;
+FuncTy_21_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_21_args.push_back(PointerTy_1);
+FunctionType* FuncTy_21 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_21_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_22_args;
+FuncTy_22_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_22_args.push_back(PointerTy_1);
+FunctionType* FuncTy_22 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Params=*/FuncTy_22_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_23_args;
+FuncTy_23_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_23_args.push_back(PointerTy_1);
+FunctionType* FuncTy_23 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_23_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_24_args;
+FuncTy_24_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_24_args.push_back(PointerTy_1);
+FuncTy_24_args.push_back(PointerTy_1);
+FuncTy_24_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_24 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_24_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_25_args;
+FuncTy_25_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_25_args.push_back(PointerTy_1);
+FuncTy_25_args.push_back(PointerTy_1);
+FuncTy_25_args.push_back(IntegerType::get(mod->getContext(), 64));
+FunctionType* FuncTy_25 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_25_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_26_args;
+FuncTy_26_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_26_args.push_back(PointerTy_1);
+FuncTy_26_args.push_back(PointerTy_1);
+FuncTy_26_args.push_back(PointerTy_1);
+FunctionType* FuncTy_26 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_26_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_27_args;
+FuncTy_27_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_27_args.push_back(PointerTy_1);
+FuncTy_27_args.push_back(PointerTy_1);
+FunctionType* FuncTy_27 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Params=*/FuncTy_27_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_28_args;
+FuncTy_28_args.push_back(PointerTy_1);
+FuncTy_28_args.push_back(PointerTy_1);
+FunctionType* FuncTy_28 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_28_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_29_args;
+FuncTy_29_args.push_back(PointerTy_1);
+FuncTy_29_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_29_args.push_back(PointerTy_1);
+FuncTy_29_args.push_back(IntegerType::get(mod->getContext(), 32));
+FunctionType* FuncTy_29 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_29_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_30_args;
+FuncTy_30_args.push_back(PointerTy_1);
+FuncTy_30_args.push_back(PointerTy_1);
+FunctionType* FuncTy_30 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_30_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_31_args;
+FuncTy_31_args.push_back(Type::getDoubleTy(mod->getContext()));
+FunctionType* FuncTy_31 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Params=*/FuncTy_31_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_32_args;
+FuncTy_32_args.push_back(Type::getDoubleTy(mod->getContext()));
+FunctionType* FuncTy_32 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_32_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_33_args;
+FuncTy_33_args.push_back(Type::getFloatTy(mod->getContext()));
+FunctionType* FuncTy_33 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 64),
+ /*Params=*/FuncTy_33_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_34_args;
+FuncTy_34_args.push_back(Type::getFloatTy(mod->getContext()));
+FunctionType* FuncTy_34 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_34_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_35_args;
+FuncTy_35_args.push_back(PointerTy_1);
+FunctionType* FuncTy_35 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 32),
+ /*Params=*/FuncTy_35_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_36_args;
+FuncTy_36_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_36_args.push_back(PointerTy_1);
+FuncTy_36_args.push_back(PointerTy_1);
+FunctionType* FuncTy_36 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_36_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_37_args;
+FuncTy_37_args.push_back(PointerTy_1);
+FuncTy_37_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_37_args.push_back(PointerTy_1);
+FunctionType* FuncTy_37 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_37_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_38_args;
+FuncTy_38_args.push_back(PointerTy_1);
+FuncTy_38_args.push_back(IntegerType::get(mod->getContext(), 32));
+FuncTy_38_args.push_back(PointerTy_1);
+FuncTy_38_args.push_back(PointerTy_1);
+FunctionType* FuncTy_38 = FunctionType::get(
+ /*Result=*/PointerTy_1,
+ /*Params=*/FuncTy_38_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_39_args;
+FunctionType* FuncTy_39 = FunctionType::get(
+ /*Result=*/IntegerType::get(mod->getContext(), 1),
+ /*Params=*/FuncTy_39_args,
+ /*isVarArg=*/false);
+
+std::vector<Type*>FuncTy_40_args;
+FuncTy_40_args.push_back(PointerTy_1);
+FunctionType* FuncTy_40 = FunctionType::get(
+ /*Result=*/Type::getVoidTy(mod->getContext()),
+ /*Params=*/FuncTy_40_args,
+ /*isVarArg=*/true);
+
+
+// Function Declarations
+
+Function* func___art_type_list = mod->getFunction("__art_type_list");
+if (!func___art_type_list) {
+func___art_type_list = Function::Create(
+ /*Type=*/FuncTy_0,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"__art_type_list", mod); // (external, no body)
+func___art_type_list->setCallingConv(CallingConv::C);
+}
+AttrListPtr func___art_type_list_PAL;
+func___art_type_list->setAttributes(func___art_type_list_PAL);
+
+Function* func_art_portable_get_current_thread_from_code = mod->getFunction("art_portable_get_current_thread_from_code");
+if (!func_art_portable_get_current_thread_from_code) {
+func_art_portable_get_current_thread_from_code = Function::Create(
+ /*Type=*/FuncTy_3,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get_current_thread_from_code", mod); // (external, no body)
+func_art_portable_get_current_thread_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get_current_thread_from_code_PAL;
+func_art_portable_get_current_thread_from_code->setAttributes(func_art_portable_get_current_thread_from_code_PAL);
+
+Function* func_art_portable_set_current_thread_from_code = mod->getFunction("art_portable_set_current_thread_from_code");
+if (!func_art_portable_set_current_thread_from_code) {
+func_art_portable_set_current_thread_from_code = Function::Create(
+ /*Type=*/FuncTy_4,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set_current_thread_from_code", mod); // (external, no body)
+func_art_portable_set_current_thread_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set_current_thread_from_code_PAL;
+func_art_portable_set_current_thread_from_code->setAttributes(func_art_portable_set_current_thread_from_code_PAL);
+
+Function* func_art_portable_lock_object_from_code = mod->getFunction("art_portable_lock_object_from_code");
+if (!func_art_portable_lock_object_from_code) {
+func_art_portable_lock_object_from_code = Function::Create(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_lock_object_from_code", mod); // (external, no body)
+func_art_portable_lock_object_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_lock_object_from_code_PAL;
+func_art_portable_lock_object_from_code->setAttributes(func_art_portable_lock_object_from_code_PAL);
+
+Function* func_art_portable_unlock_object_from_code = mod->getFunction("art_portable_unlock_object_from_code");
+if (!func_art_portable_unlock_object_from_code) {
+func_art_portable_unlock_object_from_code = Function::Create(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_unlock_object_from_code", mod); // (external, no body)
+func_art_portable_unlock_object_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_unlock_object_from_code_PAL;
+func_art_portable_unlock_object_from_code->setAttributes(func_art_portable_unlock_object_from_code_PAL);
+
+Function* func_art_portable_test_suspend_from_code = mod->getFunction("art_portable_test_suspend_from_code");
+if (!func_art_portable_test_suspend_from_code) {
+func_art_portable_test_suspend_from_code = Function::Create(
+ /*Type=*/FuncTy_6,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_test_suspend_from_code", mod); // (external, no body)
+func_art_portable_test_suspend_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_test_suspend_from_code_PAL;
+func_art_portable_test_suspend_from_code->setAttributes(func_art_portable_test_suspend_from_code_PAL);
+
+Function* func_art_portable_push_shadow_frame_from_code = mod->getFunction("art_portable_push_shadow_frame_from_code");
+if (!func_art_portable_push_shadow_frame_from_code) {
+func_art_portable_push_shadow_frame_from_code = Function::Create(
+ /*Type=*/FuncTy_7,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_push_shadow_frame_from_code", mod); // (external, no body)
+func_art_portable_push_shadow_frame_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_push_shadow_frame_from_code_PAL;
+func_art_portable_push_shadow_frame_from_code->setAttributes(func_art_portable_push_shadow_frame_from_code_PAL);
+
+Function* func_art_portable_pop_shadow_frame_from_code = mod->getFunction("art_portable_pop_shadow_frame_from_code");
+if (!func_art_portable_pop_shadow_frame_from_code) {
+func_art_portable_pop_shadow_frame_from_code = Function::Create(
+ /*Type=*/FuncTy_8,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_pop_shadow_frame_from_code", mod); // (external, no body)
+func_art_portable_pop_shadow_frame_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_pop_shadow_frame_from_code_PAL;
+func_art_portable_pop_shadow_frame_from_code->setAttributes(func_art_portable_pop_shadow_frame_from_code_PAL);
+
+Function* func_art_portable_get_and_clear_exception = mod->getFunction("art_portable_get_and_clear_exception");
+if (!func_art_portable_get_and_clear_exception) {
+func_art_portable_get_and_clear_exception = Function::Create(
+ /*Type=*/FuncTy_4,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get_and_clear_exception", mod); // (external, no body)
+func_art_portable_get_and_clear_exception->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get_and_clear_exception_PAL;
+func_art_portable_get_and_clear_exception->setAttributes(func_art_portable_get_and_clear_exception_PAL);
+
+Function* func_art_portable_throw_div_zero_from_code = mod->getFunction("art_portable_throw_div_zero_from_code");
+if (!func_art_portable_throw_div_zero_from_code) {
+func_art_portable_throw_div_zero_from_code = Function::Create(
+ /*Type=*/FuncTy_9,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_div_zero_from_code", mod); // (external, no body)
+func_art_portable_throw_div_zero_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_div_zero_from_code_PAL;
+func_art_portable_throw_div_zero_from_code->setAttributes(func_art_portable_throw_div_zero_from_code_PAL);
+
+Function* func_art_portable_throw_array_bounds_from_code = mod->getFunction("art_portable_throw_array_bounds_from_code");
+if (!func_art_portable_throw_array_bounds_from_code) {
+func_art_portable_throw_array_bounds_from_code = Function::Create(
+ /*Type=*/FuncTy_10,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_array_bounds_from_code", mod); // (external, no body)
+func_art_portable_throw_array_bounds_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_array_bounds_from_code_PAL;
+func_art_portable_throw_array_bounds_from_code->setAttributes(func_art_portable_throw_array_bounds_from_code_PAL);
+
+Function* func_art_portable_throw_no_such_method_from_code = mod->getFunction("art_portable_throw_no_such_method_from_code");
+if (!func_art_portable_throw_no_such_method_from_code) {
+func_art_portable_throw_no_such_method_from_code = Function::Create(
+ /*Type=*/FuncTy_11,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_no_such_method_from_code", mod); // (external, no body)
+func_art_portable_throw_no_such_method_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_no_such_method_from_code_PAL;
+func_art_portable_throw_no_such_method_from_code->setAttributes(func_art_portable_throw_no_such_method_from_code_PAL);
+
+Function* func_art_portable_throw_null_pointer_exception_from_code = mod->getFunction("art_portable_throw_null_pointer_exception_from_code");
+if (!func_art_portable_throw_null_pointer_exception_from_code) {
+func_art_portable_throw_null_pointer_exception_from_code = Function::Create(
+ /*Type=*/FuncTy_11,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_null_pointer_exception_from_code", mod); // (external, no body)
+func_art_portable_throw_null_pointer_exception_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_null_pointer_exception_from_code_PAL;
+func_art_portable_throw_null_pointer_exception_from_code->setAttributes(func_art_portable_throw_null_pointer_exception_from_code_PAL);
+
+Function* func_art_portable_throw_stack_overflow_from_code = mod->getFunction("art_portable_throw_stack_overflow_from_code");
+if (!func_art_portable_throw_stack_overflow_from_code) {
+func_art_portable_throw_stack_overflow_from_code = Function::Create(
+ /*Type=*/FuncTy_9,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_stack_overflow_from_code", mod); // (external, no body)
+func_art_portable_throw_stack_overflow_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_stack_overflow_from_code_PAL;
+func_art_portable_throw_stack_overflow_from_code->setAttributes(func_art_portable_throw_stack_overflow_from_code_PAL);
+
+Function* func_art_portable_throw_exception_from_code = mod->getFunction("art_portable_throw_exception_from_code");
+if (!func_art_portable_throw_exception_from_code) {
+func_art_portable_throw_exception_from_code = Function::Create(
+ /*Type=*/FuncTy_6,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_throw_exception_from_code", mod); // (external, no body)
+func_art_portable_throw_exception_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_throw_exception_from_code_PAL;
+func_art_portable_throw_exception_from_code->setAttributes(func_art_portable_throw_exception_from_code_PAL);
+
+Function* func_art_portable_find_catch_block_from_code = mod->getFunction("art_portable_find_catch_block_from_code");
+if (!func_art_portable_find_catch_block_from_code) {
+func_art_portable_find_catch_block_from_code = Function::Create(
+ /*Type=*/FuncTy_12,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_catch_block_from_code", mod); // (external, no body)
+func_art_portable_find_catch_block_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_catch_block_from_code_PAL;
+func_art_portable_find_catch_block_from_code->setAttributes(func_art_portable_find_catch_block_from_code_PAL);
+
+Function* func_art_portable_alloc_object_from_code = mod->getFunction("art_portable_alloc_object_from_code");
+if (!func_art_portable_alloc_object_from_code) {
+func_art_portable_alloc_object_from_code = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_alloc_object_from_code", mod); // (external, no body)
+func_art_portable_alloc_object_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_alloc_object_from_code_PAL;
+func_art_portable_alloc_object_from_code->setAttributes(func_art_portable_alloc_object_from_code_PAL);
+
+Function* func_art_portable_alloc_object_from_code_with_access_check = mod->getFunction("art_portable_alloc_object_from_code_with_access_check");
+if (!func_art_portable_alloc_object_from_code_with_access_check) {
+func_art_portable_alloc_object_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_alloc_object_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_alloc_object_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_alloc_object_from_code_with_access_check_PAL;
+func_art_portable_alloc_object_from_code_with_access_check->setAttributes(func_art_portable_alloc_object_from_code_with_access_check_PAL);
+
+Function* func_art_portable_alloc_array_from_code = mod->getFunction("art_portable_alloc_array_from_code");
+if (!func_art_portable_alloc_array_from_code) {
+func_art_portable_alloc_array_from_code = Function::Create(
+ /*Type=*/FuncTy_14,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_alloc_array_from_code", mod); // (external, no body)
+func_art_portable_alloc_array_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_alloc_array_from_code_PAL;
+func_art_portable_alloc_array_from_code->setAttributes(func_art_portable_alloc_array_from_code_PAL);
+
+Function* func_art_portable_alloc_array_from_code_with_access_check = mod->getFunction("art_portable_alloc_array_from_code_with_access_check");
+if (!func_art_portable_alloc_array_from_code_with_access_check) {
+func_art_portable_alloc_array_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_14,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_alloc_array_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_alloc_array_from_code_with_access_check_PAL;
+func_art_portable_alloc_array_from_code_with_access_check->setAttributes(func_art_portable_alloc_array_from_code_with_access_check_PAL);
+
+Function* func_art_portable_check_and_alloc_array_from_code = mod->getFunction("art_portable_check_and_alloc_array_from_code");
+if (!func_art_portable_check_and_alloc_array_from_code) {
+func_art_portable_check_and_alloc_array_from_code = Function::Create(
+ /*Type=*/FuncTy_14,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_check_and_alloc_array_from_code", mod); // (external, no body)
+func_art_portable_check_and_alloc_array_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_check_and_alloc_array_from_code_PAL;
+func_art_portable_check_and_alloc_array_from_code->setAttributes(func_art_portable_check_and_alloc_array_from_code_PAL);
+
+Function* func_art_portable_check_and_alloc_array_from_code_with_access_check = mod->getFunction("art_portable_check_and_alloc_array_from_code_with_access_check");
+if (!func_art_portable_check_and_alloc_array_from_code_with_access_check) {
+func_art_portable_check_and_alloc_array_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_14,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_check_and_alloc_array_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_check_and_alloc_array_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_check_and_alloc_array_from_code_with_access_check_PAL;
+func_art_portable_check_and_alloc_array_from_code_with_access_check->setAttributes(func_art_portable_check_and_alloc_array_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_instance_field_from_code = mod->getFunction("art_portable_find_instance_field_from_code");
+if (!func_art_portable_find_instance_field_from_code) {
+func_art_portable_find_instance_field_from_code = Function::Create(
+ /*Type=*/FuncTy_15,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_instance_field_from_code", mod); // (external, no body)
+func_art_portable_find_instance_field_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_instance_field_from_code_PAL;
+func_art_portable_find_instance_field_from_code->setAttributes(func_art_portable_find_instance_field_from_code_PAL);
+
+Function* func_art_portable_find_static_field_from_code = mod->getFunction("art_portable_find_static_field_from_code");
+if (!func_art_portable_find_static_field_from_code) {
+func_art_portable_find_static_field_from_code = Function::Create(
+ /*Type=*/FuncTy_15,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_static_field_from_code", mod); // (external, no body)
+func_art_portable_find_static_field_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_static_field_from_code_PAL;
+func_art_portable_find_static_field_from_code->setAttributes(func_art_portable_find_static_field_from_code_PAL);
+
+Function* func_art_portable_find_static_method_from_code_with_access_check = mod->getFunction("art_portable_find_static_method_from_code_with_access_check");
+if (!func_art_portable_find_static_method_from_code_with_access_check) {
+func_art_portable_find_static_method_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_static_method_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_find_static_method_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_static_method_from_code_with_access_check_PAL;
+func_art_portable_find_static_method_from_code_with_access_check->setAttributes(func_art_portable_find_static_method_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_direct_method_from_code_with_access_check = mod->getFunction("art_portable_find_direct_method_from_code_with_access_check");
+if (!func_art_portable_find_direct_method_from_code_with_access_check) {
+func_art_portable_find_direct_method_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_direct_method_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_find_direct_method_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_direct_method_from_code_with_access_check_PAL;
+func_art_portable_find_direct_method_from_code_with_access_check->setAttributes(func_art_portable_find_direct_method_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_virtual_method_from_code_with_access_check = mod->getFunction("art_portable_find_virtual_method_from_code_with_access_check");
+if (!func_art_portable_find_virtual_method_from_code_with_access_check) {
+func_art_portable_find_virtual_method_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_virtual_method_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_find_virtual_method_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_virtual_method_from_code_with_access_check_PAL;
+func_art_portable_find_virtual_method_from_code_with_access_check->setAttributes(func_art_portable_find_virtual_method_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_super_method_from_code_with_access_check = mod->getFunction("art_portable_find_super_method_from_code_with_access_check");
+if (!func_art_portable_find_super_method_from_code_with_access_check) {
+func_art_portable_find_super_method_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_super_method_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_find_super_method_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_super_method_from_code_with_access_check_PAL;
+func_art_portable_find_super_method_from_code_with_access_check->setAttributes(func_art_portable_find_super_method_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_interface_method_from_code_with_access_check = mod->getFunction("art_portable_find_interface_method_from_code_with_access_check");
+if (!func_art_portable_find_interface_method_from_code_with_access_check) {
+func_art_portable_find_interface_method_from_code_with_access_check = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_interface_method_from_code_with_access_check", mod); // (external, no body)
+func_art_portable_find_interface_method_from_code_with_access_check->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_interface_method_from_code_with_access_check_PAL;
+func_art_portable_find_interface_method_from_code_with_access_check->setAttributes(func_art_portable_find_interface_method_from_code_with_access_check_PAL);
+
+Function* func_art_portable_find_interface_method_from_code = mod->getFunction("art_portable_find_interface_method_from_code");
+if (!func_art_portable_find_interface_method_from_code) {
+func_art_portable_find_interface_method_from_code = Function::Create(
+ /*Type=*/FuncTy_16,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_find_interface_method_from_code", mod); // (external, no body)
+func_art_portable_find_interface_method_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_find_interface_method_from_code_PAL;
+func_art_portable_find_interface_method_from_code->setAttributes(func_art_portable_find_interface_method_from_code_PAL);
+
+Function* func_art_portable_initialize_static_storage_from_code = mod->getFunction("art_portable_initialize_static_storage_from_code");
+if (!func_art_portable_initialize_static_storage_from_code) {
+func_art_portable_initialize_static_storage_from_code = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_initialize_static_storage_from_code", mod); // (external, no body)
+func_art_portable_initialize_static_storage_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_initialize_static_storage_from_code_PAL;
+func_art_portable_initialize_static_storage_from_code->setAttributes(func_art_portable_initialize_static_storage_from_code_PAL);
+
+Function* func_art_portable_initialize_type_from_code = mod->getFunction("art_portable_initialize_type_from_code");
+if (!func_art_portable_initialize_type_from_code) {
+func_art_portable_initialize_type_from_code = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_initialize_type_from_code", mod); // (external, no body)
+func_art_portable_initialize_type_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_initialize_type_from_code_PAL;
+func_art_portable_initialize_type_from_code->setAttributes(func_art_portable_initialize_type_from_code_PAL);
+
+Function* func_art_portable_initialize_type_and_verify_access_from_code = mod->getFunction("art_portable_initialize_type_and_verify_access_from_code");
+if (!func_art_portable_initialize_type_and_verify_access_from_code) {
+func_art_portable_initialize_type_and_verify_access_from_code = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_initialize_type_and_verify_access_from_code", mod); // (external, no body)
+func_art_portable_initialize_type_and_verify_access_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_initialize_type_and_verify_access_from_code_PAL;
+func_art_portable_initialize_type_and_verify_access_from_code->setAttributes(func_art_portable_initialize_type_and_verify_access_from_code_PAL);
+
+Function* func_art_portable_resolve_string_from_code = mod->getFunction("art_portable_resolve_string_from_code");
+if (!func_art_portable_resolve_string_from_code) {
+func_art_portable_resolve_string_from_code = Function::Create(
+ /*Type=*/FuncTy_17,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_resolve_string_from_code", mod); // (external, no body)
+func_art_portable_resolve_string_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_resolve_string_from_code_PAL;
+func_art_portable_resolve_string_from_code->setAttributes(func_art_portable_resolve_string_from_code_PAL);
+
+Function* func_art_portable_set32_static_from_code = mod->getFunction("art_portable_set32_static_from_code");
+if (!func_art_portable_set32_static_from_code) {
+func_art_portable_set32_static_from_code = Function::Create(
+ /*Type=*/FuncTy_18,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set32_static_from_code", mod); // (external, no body)
+func_art_portable_set32_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set32_static_from_code_PAL;
+func_art_portable_set32_static_from_code->setAttributes(func_art_portable_set32_static_from_code_PAL);
+
+Function* func_art_portable_set64_static_from_code = mod->getFunction("art_portable_set64_static_from_code");
+if (!func_art_portable_set64_static_from_code) {
+func_art_portable_set64_static_from_code = Function::Create(
+ /*Type=*/FuncTy_19,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set64_static_from_code", mod); // (external, no body)
+func_art_portable_set64_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set64_static_from_code_PAL;
+func_art_portable_set64_static_from_code->setAttributes(func_art_portable_set64_static_from_code_PAL);
+
+Function* func_art_portable_set_obj_static_from_code = mod->getFunction("art_portable_set_obj_static_from_code");
+if (!func_art_portable_set_obj_static_from_code) {
+func_art_portable_set_obj_static_from_code = Function::Create(
+ /*Type=*/FuncTy_20,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set_obj_static_from_code", mod); // (external, no body)
+func_art_portable_set_obj_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set_obj_static_from_code_PAL;
+func_art_portable_set_obj_static_from_code->setAttributes(func_art_portable_set_obj_static_from_code_PAL);
+
+Function* func_art_portable_get32_static_from_code = mod->getFunction("art_portable_get32_static_from_code");
+if (!func_art_portable_get32_static_from_code) {
+func_art_portable_get32_static_from_code = Function::Create(
+ /*Type=*/FuncTy_21,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get32_static_from_code", mod); // (external, no body)
+func_art_portable_get32_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get32_static_from_code_PAL;
+func_art_portable_get32_static_from_code->setAttributes(func_art_portable_get32_static_from_code_PAL);
+
+Function* func_art_portable_get64_static_from_code = mod->getFunction("art_portable_get64_static_from_code");
+if (!func_art_portable_get64_static_from_code) {
+func_art_portable_get64_static_from_code = Function::Create(
+ /*Type=*/FuncTy_22,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get64_static_from_code", mod); // (external, no body)
+func_art_portable_get64_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get64_static_from_code_PAL;
+func_art_portable_get64_static_from_code->setAttributes(func_art_portable_get64_static_from_code_PAL);
+
+Function* func_art_portable_get_obj_static_from_code = mod->getFunction("art_portable_get_obj_static_from_code");
+if (!func_art_portable_get_obj_static_from_code) {
+func_art_portable_get_obj_static_from_code = Function::Create(
+ /*Type=*/FuncTy_23,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get_obj_static_from_code", mod); // (external, no body)
+func_art_portable_get_obj_static_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get_obj_static_from_code_PAL;
+func_art_portable_get_obj_static_from_code->setAttributes(func_art_portable_get_obj_static_from_code_PAL);
+
+Function* func_art_portable_set32_instance_from_code = mod->getFunction("art_portable_set32_instance_from_code");
+if (!func_art_portable_set32_instance_from_code) {
+func_art_portable_set32_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_24,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set32_instance_from_code", mod); // (external, no body)
+func_art_portable_set32_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set32_instance_from_code_PAL;
+func_art_portable_set32_instance_from_code->setAttributes(func_art_portable_set32_instance_from_code_PAL);
+
+Function* func_art_portable_set64_instance_from_code = mod->getFunction("art_portable_set64_instance_from_code");
+if (!func_art_portable_set64_instance_from_code) {
+func_art_portable_set64_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_25,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set64_instance_from_code", mod); // (external, no body)
+func_art_portable_set64_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set64_instance_from_code_PAL;
+func_art_portable_set64_instance_from_code->setAttributes(func_art_portable_set64_instance_from_code_PAL);
+
+Function* func_art_portable_set_obj_instance_from_code = mod->getFunction("art_portable_set_obj_instance_from_code");
+if (!func_art_portable_set_obj_instance_from_code) {
+func_art_portable_set_obj_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_26,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_set_obj_instance_from_code", mod); // (external, no body)
+func_art_portable_set_obj_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_set_obj_instance_from_code_PAL;
+func_art_portable_set_obj_instance_from_code->setAttributes(func_art_portable_set_obj_instance_from_code_PAL);
+
+Function* func_art_portable_get32_instance_from_code = mod->getFunction("art_portable_get32_instance_from_code");
+if (!func_art_portable_get32_instance_from_code) {
+func_art_portable_get32_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_20,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get32_instance_from_code", mod); // (external, no body)
+func_art_portable_get32_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get32_instance_from_code_PAL;
+func_art_portable_get32_instance_from_code->setAttributes(func_art_portable_get32_instance_from_code_PAL);
+
+Function* func_art_portable_get64_instance_from_code = mod->getFunction("art_portable_get64_instance_from_code");
+if (!func_art_portable_get64_instance_from_code) {
+func_art_portable_get64_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_27,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get64_instance_from_code", mod); // (external, no body)
+func_art_portable_get64_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get64_instance_from_code_PAL;
+func_art_portable_get64_instance_from_code->setAttributes(func_art_portable_get64_instance_from_code_PAL);
+
+Function* func_art_portable_get_obj_instance_from_code = mod->getFunction("art_portable_get_obj_instance_from_code");
+if (!func_art_portable_get_obj_instance_from_code) {
+func_art_portable_get_obj_instance_from_code = Function::Create(
+ /*Type=*/FuncTy_13,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_get_obj_instance_from_code", mod); // (external, no body)
+func_art_portable_get_obj_instance_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_get_obj_instance_from_code_PAL;
+func_art_portable_get_obj_instance_from_code->setAttributes(func_art_portable_get_obj_instance_from_code_PAL);
+
+Function* func_art_portable_decode_jobject_in_thread = mod->getFunction("art_portable_decode_jobject_in_thread");
+if (!func_art_portable_decode_jobject_in_thread) {
+func_art_portable_decode_jobject_in_thread = Function::Create(
+ /*Type=*/FuncTy_28,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_decode_jobject_in_thread", mod); // (external, no body)
+func_art_portable_decode_jobject_in_thread->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_decode_jobject_in_thread_PAL;
+func_art_portable_decode_jobject_in_thread->setAttributes(func_art_portable_decode_jobject_in_thread_PAL);
+
+Function* func_art_portable_fill_array_data_from_code = mod->getFunction("art_portable_fill_array_data_from_code");
+if (!func_art_portable_fill_array_data_from_code) {
+func_art_portable_fill_array_data_from_code = Function::Create(
+ /*Type=*/FuncTy_29,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_fill_array_data_from_code", mod); // (external, no body)
+func_art_portable_fill_array_data_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_fill_array_data_from_code_PAL;
+func_art_portable_fill_array_data_from_code->setAttributes(func_art_portable_fill_array_data_from_code_PAL);
+
+Function* func_art_portable_is_assignable_from_code = mod->getFunction("art_portable_is_assignable_from_code");
+if (!func_art_portable_is_assignable_from_code) {
+func_art_portable_is_assignable_from_code = Function::Create(
+ /*Type=*/FuncTy_30,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_is_assignable_from_code", mod); // (external, no body)
+func_art_portable_is_assignable_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_is_assignable_from_code_PAL;
+func_art_portable_is_assignable_from_code->setAttributes(func_art_portable_is_assignable_from_code_PAL);
+
+Function* func_art_portable_check_cast_from_code = mod->getFunction("art_portable_check_cast_from_code");
+if (!func_art_portable_check_cast_from_code) {
+func_art_portable_check_cast_from_code = Function::Create(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_check_cast_from_code", mod); // (external, no body)
+func_art_portable_check_cast_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_check_cast_from_code_PAL;
+func_art_portable_check_cast_from_code->setAttributes(func_art_portable_check_cast_from_code_PAL);
+
+Function* func_art_portable_check_put_array_element_from_code = mod->getFunction("art_portable_check_put_array_element_from_code");
+if (!func_art_portable_check_put_array_element_from_code) {
+func_art_portable_check_put_array_element_from_code = Function::Create(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_check_put_array_element_from_code", mod); // (external, no body)
+func_art_portable_check_put_array_element_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_check_put_array_element_from_code_PAL;
+func_art_portable_check_put_array_element_from_code->setAttributes(func_art_portable_check_put_array_element_from_code_PAL);
+
+Function* func_art_d2l = mod->getFunction("art_d2l");
+if (!func_art_d2l) {
+func_art_d2l = Function::Create(
+ /*Type=*/FuncTy_31,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_d2l", mod); // (external, no body)
+func_art_d2l->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_d2l_PAL;
+func_art_d2l->setAttributes(func_art_d2l_PAL);
+
+Function* func_art_d2i = mod->getFunction("art_d2i");
+if (!func_art_d2i) {
+func_art_d2i = Function::Create(
+ /*Type=*/FuncTy_32,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_d2i", mod); // (external, no body)
+func_art_d2i->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_d2i_PAL;
+func_art_d2i->setAttributes(func_art_d2i_PAL);
+
+Function* func_art_f2l = mod->getFunction("art_f2l");
+if (!func_art_f2l) {
+func_art_f2l = Function::Create(
+ /*Type=*/FuncTy_33,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_f2l", mod); // (external, no body)
+func_art_f2l->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_f2l_PAL;
+func_art_f2l->setAttributes(func_art_f2l_PAL);
+
+Function* func_art_f2i = mod->getFunction("art_f2i");
+if (!func_art_f2i) {
+func_art_f2i = Function::Create(
+ /*Type=*/FuncTy_34,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_f2i", mod); // (external, no body)
+func_art_f2i->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_f2i_PAL;
+func_art_f2i->setAttributes(func_art_f2i_PAL);
+
+Function* func_art_portable_jni_method_start = mod->getFunction("art_portable_jni_method_start");
+if (!func_art_portable_jni_method_start) {
+func_art_portable_jni_method_start = Function::Create(
+ /*Type=*/FuncTy_35,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_start", mod); // (external, no body)
+func_art_portable_jni_method_start->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_start_PAL;
+func_art_portable_jni_method_start->setAttributes(func_art_portable_jni_method_start_PAL);
+
+Function* func_art_portable_jni_method_start_synchronized = mod->getFunction("art_portable_jni_method_start_synchronized");
+if (!func_art_portable_jni_method_start_synchronized) {
+func_art_portable_jni_method_start_synchronized = Function::Create(
+ /*Type=*/FuncTy_30,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_start_synchronized", mod); // (external, no body)
+func_art_portable_jni_method_start_synchronized->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_start_synchronized_PAL;
+func_art_portable_jni_method_start_synchronized->setAttributes(func_art_portable_jni_method_start_synchronized_PAL);
+
+Function* func_art_portable_jni_method_end = mod->getFunction("art_portable_jni_method_end");
+if (!func_art_portable_jni_method_end) {
+func_art_portable_jni_method_end = Function::Create(
+ /*Type=*/FuncTy_15,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_end", mod); // (external, no body)
+func_art_portable_jni_method_end->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_end_PAL;
+func_art_portable_jni_method_end->setAttributes(func_art_portable_jni_method_end_PAL);
+
+Function* func_art_portable_jni_method_end_synchronized = mod->getFunction("art_portable_jni_method_end_synchronized");
+if (!func_art_portable_jni_method_end_synchronized) {
+func_art_portable_jni_method_end_synchronized = Function::Create(
+ /*Type=*/FuncTy_36,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_end_synchronized", mod); // (external, no body)
+func_art_portable_jni_method_end_synchronized->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_end_synchronized_PAL;
+func_art_portable_jni_method_end_synchronized->setAttributes(func_art_portable_jni_method_end_synchronized_PAL);
+
+Function* func_art_portable_jni_method_end_with_reference = mod->getFunction("art_portable_jni_method_end_with_reference");
+if (!func_art_portable_jni_method_end_with_reference) {
+func_art_portable_jni_method_end_with_reference = Function::Create(
+ /*Type=*/FuncTy_37,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_end_with_reference", mod); // (external, no body)
+func_art_portable_jni_method_end_with_reference->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_end_with_reference_PAL;
+func_art_portable_jni_method_end_with_reference->setAttributes(func_art_portable_jni_method_end_with_reference_PAL);
+
+Function* func_art_portable_jni_method_end_with_reference_synchronized = mod->getFunction("art_portable_jni_method_end_with_reference_synchronized");
+if (!func_art_portable_jni_method_end_with_reference_synchronized) {
+func_art_portable_jni_method_end_with_reference_synchronized = Function::Create(
+ /*Type=*/FuncTy_38,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_jni_method_end_with_reference_synchronized", mod); // (external, no body)
+func_art_portable_jni_method_end_with_reference_synchronized->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_jni_method_end_with_reference_synchronized_PAL;
+func_art_portable_jni_method_end_with_reference_synchronized->setAttributes(func_art_portable_jni_method_end_with_reference_synchronized_PAL);
+
+Function* func_art_portable_is_exception_pending_from_code = mod->getFunction("art_portable_is_exception_pending_from_code");
+if (!func_art_portable_is_exception_pending_from_code) {
+func_art_portable_is_exception_pending_from_code = Function::Create(
+ /*Type=*/FuncTy_39,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_is_exception_pending_from_code", mod); // (external, no body)
+func_art_portable_is_exception_pending_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_is_exception_pending_from_code_PAL;
+func_art_portable_is_exception_pending_from_code->setAttributes(func_art_portable_is_exception_pending_from_code_PAL);
+
+Function* func_art_portable_mark_gc_card_from_code = mod->getFunction("art_portable_mark_gc_card_from_code");
+if (!func_art_portable_mark_gc_card_from_code) {
+func_art_portable_mark_gc_card_from_code = Function::Create(
+ /*Type=*/FuncTy_5,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_mark_gc_card_from_code", mod); // (external, no body)
+func_art_portable_mark_gc_card_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_mark_gc_card_from_code_PAL;
+func_art_portable_mark_gc_card_from_code->setAttributes(func_art_portable_mark_gc_card_from_code_PAL);
+
+Function* func_art_portable_proxy_invoke_handler_from_code = mod->getFunction("art_portable_proxy_invoke_handler_from_code");
+if (!func_art_portable_proxy_invoke_handler_from_code) {
+func_art_portable_proxy_invoke_handler_from_code = Function::Create(
+ /*Type=*/FuncTy_40,
+ /*Linkage=*/GlobalValue::ExternalLinkage,
+ /*Name=*/"art_portable_proxy_invoke_handler_from_code", mod); // (external, no body)
+func_art_portable_proxy_invoke_handler_from_code->setCallingConv(CallingConv::C);
+}
+AttrListPtr func_art_portable_proxy_invoke_handler_from_code_PAL;
+func_art_portable_proxy_invoke_handler_from_code->setAttributes(func_art_portable_proxy_invoke_handler_from_code_PAL);
+
+// Global Variable Declarations
+
+
+// Constant Definitions
+
+// Global Variable Definitions
+
+// Function Definitions
+
+return mod;
+
+}
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/intrinsic_func_list.def b/src/compiler/llvm/intrinsic_func_list.def
new file mode 100644
index 0000000..92537ba
--- /dev/null
+++ b/src/compiler/llvm/intrinsic_func_list.def
@@ -0,0 +1,1803 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// DEF_INTRINSICS_FUNC(ID, NAME, ATTR, RET_TYPE,
+//                     ARG1_TYPE, ARG2_TYPE, ARG3_TYPE, ARG4_TYPE, ARG5_TYPE)
+#ifndef DEF_INTRINSICS_FUNC
+#  error "missing DEF_INTRINSICS_FUNC definition!"
+#endif
+
+#define _EVAL_DEF_INTRINSICS_FUNC(ID, NAME, ATTR, RET_TYPE, ...) \
+    DEF_INTRINSICS_FUNC(ID, NAME, ATTR, RET_TYPE, __VA_ARGS__)
+
+#define _EXPAND_ARG0()                         kNone, kNone, kNone, kNone, kNone
+#define _EXPAND_ARG1(ARG1)                      ARG1, kNone, kNone, kNone, kNone
+#define _EXPAND_ARG2(ARG1, ARG2)                ARG1,  ARG2, kNone, kNone, kNone
+#define _EXPAND_ARG3(ARG1, ARG2, ARG3)          ARG1,  ARG2,  ARG3, kNone, kNone
+#define _EXPAND_ARG4(ARG1, ARG2, ARG3, ARG4)    ARG1,  ARG2,  ARG3,  ARG4, kNone
+#define _EXPAND_ARG5(ARG1, ARG2, ARG3, ARG4, ARG5) \
+                                                ARG1,  ARG2,  ARG3,  ARG4,  ARG5
+
+#define _JTYPE(TYPE, SPACE) _JTYPE_OF_ ## TYPE ## _UNDER_ ## SPACE
+
+// Note: These should be consistent with the type return from
+// IRBuilder::GetJType([type], kArray).
+#define _JTYPE_OF_kInt1Ty_UNDER_kArray        kInt8Ty
+#define _JTYPE_OF_kInt8Ty_UNDER_kArray        kInt8Ty
+#define _JTYPE_OF_kInt16Ty_UNDER_kArray       kInt16Ty
+#define _JTYPE_OF_kInt32Ty_UNDER_kArray       kInt32Ty
+#define _JTYPE_OF_kInt64Ty_UNDER_kArray       kInt64Ty
+#define _JTYPE_OF_kJavaObjectTy_UNDER_kArray  kJavaObjectTy
+
+// Note: These should be consistent with the type return from
+// IRBuilder::GetJType([type], kField).
+#define _JTYPE_OF_kInt1Ty_UNDER_kField        kInt32Ty
+#define _JTYPE_OF_kInt8Ty_UNDER_kField        kInt32Ty
+#define _JTYPE_OF_kInt16Ty_UNDER_kField       kInt32Ty
+#define _JTYPE_OF_kInt32Ty_UNDER_kField       kInt32Ty
+#define _JTYPE_OF_kInt64Ty_UNDER_kField       kInt64Ty
+#define _JTYPE_OF_kJavaObjectTy_UNDER_kField  kJavaObjectTy
+
+//----------------------------------------------------------------------------
+// Thread
+//----------------------------------------------------------------------------
+
+// Thread* art_portable_get_current_thread()
+_EVAL_DEF_INTRINSICS_FUNC(GetCurrentThread,
+                          art_portable_get_current_thread,
+                          kAttrReadNone | kAttrNoThrow,
+                          kJavaThreadTy,
+                          _EXPAND_ARG0())
+
+// void art_portable_test_suspend(Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(TestSuspend,
+                          art_portable_test_suspend,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kJavaThreadTy))
+
+// void art_portable_check_suspend() /* Expands to GetCurrentThread/TestSuspend */
+_EVAL_DEF_INTRINSICS_FUNC(CheckSuspend,
+                          art_portable_check_suspend,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG0())
+
+// void art_portable_mark_gc_card(Object* new_value, Object* object)
+_EVAL_DEF_INTRINSICS_FUNC(MarkGCCard,
+                          art_portable_mark_gc_card,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaObjectTy))
+
+//----------------------------------------------------------------------------
+// Exception
+//----------------------------------------------------------------------------
+
+// Should not expand - introduces the catch targets for a potentially
+// throwing instruction.  The result is a switch key and this
+// instruction will be followed by a switch statement.  The catch
+// targets will be enumerated as cases of the switch, with the fallthrough
+// designating the block containing the potentially throwing instruction.
+// bool art_portable_catch_targets(int dex_pc)
+_EVAL_DEF_INTRINSICS_FUNC(CatchTargets,
+                          art_portable_catch_targets,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// void art_portable_throw_exception(JavaObject* exception)
+_EVAL_DEF_INTRINSICS_FUNC(ThrowException,
+                          art_portable_throw_exception,
+                          kAttrDoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kJavaObjectTy))
+
+// void art_portable_hl_throw_exception(JavaObject* exception)
+_EVAL_DEF_INTRINSICS_FUNC(HLThrowException,
+                          art_portable_hl_throw_exception,
+                          kAttrDoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kJavaObjectTy))
+
+// JavaObject* art_portable_get_current_exception()
+_EVAL_DEF_INTRINSICS_FUNC(GetException,
+                          art_portable_get_current_exception,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG0())
+
+// bool art_portable_is_exception_pending()
+_EVAL_DEF_INTRINSICS_FUNC(IsExceptionPending,
+                          art_portable_is_exception_pending,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt1Ty,
+                          _EXPAND_ARG0())
+
+// int art_portable_find_catch_block(Method* method, int try_item_offset)
+_EVAL_DEF_INTRINSICS_FUNC(FindCatchBlock,
+                          art_portable_find_catch_block,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kInt32ConstantTy))
+
+// void art_portable_throw_div_zero()
+_EVAL_DEF_INTRINSICS_FUNC(ThrowDivZeroException,
+                          art_portable_throw_div_zero,
+                          kAttrDoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG0())
+
+// void art_portable_throw_null_pointer_exception(uint32_t dex_pc)
+_EVAL_DEF_INTRINSICS_FUNC(ThrowNullPointerException,
+                          art_portable_throw_null_pointer_exception,
+                          kAttrDoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// void art_portable_throw_array_bounds(int index, int array_len)
+_EVAL_DEF_INTRINSICS_FUNC(ThrowIndexOutOfBounds,
+                          art_portable_throw_array_bounds,
+                          kAttrDoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+//----------------------------------------------------------------------------
+// ConstString
+//----------------------------------------------------------------------------
+
+// JavaObject* art_portable_const_string(uint32_t string_idx)
+_EVAL_DEF_INTRINSICS_FUNC(ConstString,
+                          art_portable_const_string,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// JavaObject* art_portable_load_string_from_dex_cache(Method* method, uint32_t string_idx)
+_EVAL_DEF_INTRINSICS_FUNC(LoadStringFromDexCache,
+                          art_portable_load_string_from_dex_cache,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// JavaObject* art_portable_resolve_string(Method* method, uint32_t string_idx)
+_EVAL_DEF_INTRINSICS_FUNC(ResolveString,
+                          art_portable_resolve_string,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG2(kJavaMethodTy, kInt32ConstantTy))
+
+//----------------------------------------------------------------------------
+// ConstClass
+//----------------------------------------------------------------------------
+
+// JavaObject* art_portable_const_class(uint32_t type_idx)
+_EVAL_DEF_INTRINSICS_FUNC(ConstClass,
+                          art_portable_const_class,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// JavaObject* art_portable_initialize_type_and_verify_access(uint32_t type_idx,
+//                                                        Method* referrer,
+//                                                        Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(InitializeTypeAndVerifyAccess,
+                          art_portable_initialize_type_and_verify_access,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaThreadTy))
+
+// JavaObject* art_portable_load_type_from_dex_cache(uint32_t type_idx)
+_EVAL_DEF_INTRINSICS_FUNC(LoadTypeFromDexCache,
+                          art_portable_load_type_from_dex_cache,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// JavaObject* art_portable_initialize_type(uint32_t type_idx,
+//                                      Method* referrer,
+//                                      Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(InitializeType,
+                          art_portable_initialize_type,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaThreadTy))
+
+//----------------------------------------------------------------------------
+// Lock
+//----------------------------------------------------------------------------
+
+// void art_portable_lock_object(JavaObject* obj, Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(LockObject,
+                          art_portable_lock_object,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaThreadTy))
+
+// void art_portable_unlock_object(JavaObject* obj, Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(UnlockObject,
+                          art_portable_unlock_object,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaThreadTy))
+
+//----------------------------------------------------------------------------
+// Cast
+//----------------------------------------------------------------------------
+
+// void art_portable_check_cast(JavaObject* dest_type, JavaObject* src_type)
+_EVAL_DEF_INTRINSICS_FUNC(CheckCast,
+                          art_portable_check_cast,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaObjectTy))
+
+// void art_portable_hl_check_cast(uint32_t type_idx, JavaObject* obj)
+_EVAL_DEF_INTRINSICS_FUNC(HLCheckCast,
+                          art_portable_hl_check_cast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaObjectTy))
+
+// int art_portable_is_assignable(JavaObject* dest_type, JavaObject* src_type)
+_EVAL_DEF_INTRINSICS_FUNC(IsAssignable,
+                          art_portable_is_assignable,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaObjectTy))
+
+//----------------------------------------------------------------------------
+// Allocation
+//----------------------------------------------------------------------------
+
+// JavaObject* art_portable_alloc_object(uint32_t type_idx,
+//                                   Method* referrer,
+//                                   Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(AllocObject,
+                          art_portable_alloc_object,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaThreadTy))
+
+// JavaObject* art_portable_alloc_object_with_access_check(uint32_t type_idx,
+//                                                     Method* referrer,
+//                                                     Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(AllocObjectWithAccessCheck,
+                          art_portable_alloc_object_with_access_check,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaThreadTy))
+
+//----------------------------------------------------------------------------
+// Instance
+//----------------------------------------------------------------------------
+
+// JavaObject* art_portable_new_instance(uint32_t type_idx)
+_EVAL_DEF_INTRINSICS_FUNC(NewInstance,
+                          art_portable_new_instance,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// bool art_portable_instance_of(uint32_t type_idx, JavaObject* ref)
+_EVAL_DEF_INTRINSICS_FUNC(InstanceOf,
+                          art_portable_instance_of,
+                          kAttrNone,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty, kJavaObjectTy))
+
+//----------------------------------------------------------------------------
+// Array
+//----------------------------------------------------------------------------
+
+// JavaObject* art_portable_new_array(uint32_t type_idx, uint32_t array_size)
+_EVAL_DEF_INTRINSICS_FUNC(NewArray,
+                          art_portable_new_array,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG2(kInt32ConstantTy, kInt32Ty))
+
+// uint32_t art_portable_opt_array_length(int32_t opt_flags, JavaObject* array)
+_EVAL_DEF_INTRINSICS_FUNC(OptArrayLength,
+                          art_portable_opt_array_length,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty, kJavaObjectTy))
+
+// uint32_t art_portable_array_length(JavaObject* array)
+_EVAL_DEF_INTRINSICS_FUNC(ArrayLength,
+                          art_portable_array_length,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kJavaObjectTy))
+
+// JavaObject* art_portable_alloc_array(uint32_t type_idx,
+//                                  Method* referrer,
+//                                  uint32_t length,
+//                                  Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(AllocArray,
+                          art_portable_alloc_array,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kInt32Ty, kJavaThreadTy))
+
+// JavaObject* art_portable_alloc_array_with_access_check(uint32_t type_idx,
+//                                                    Method* referrer,
+//                                                    uint32_t length,
+//                                                    Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(AllocArrayWithAccessCheck,
+                          art_portable_alloc_array_with_access_check,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kInt32Ty, kJavaThreadTy))
+
+// JavaObject* art_portable_check_and_alloc_array(uint32_t type_idx,
+//                                            Method* referrer,
+//                                            uint32_t length,
+//                                            Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(CheckAndAllocArray,
+                          art_portable_check_and_alloc_array,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kInt32ConstantTy, kJavaThreadTy))
+
+// JavaObject* art_portable_check_and_alloc_array_with_access_check(uint32_t type_idx,
+//                                                              Method* referrer,
+//                                                              uint32_t length,
+//                                                              Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(CheckAndAllocArrayWithAccessCheck,
+                          art_portable_check_and_alloc_array_with_access_check,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kInt32ConstantTy, kJavaThreadTy))
+
+// art_portable_aget_* and art_portable_aput_* never generate exception since the
+// necessary checking on arguments (e.g., array and index) has already done
+// before invocation of these intrinsics.
+//
+// [type] void art_portable_aget_[type](JavaObject* array, uint32_t index)
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGet,
+                          art_portable_aget,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt32Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetWide,
+                          art_portable_aget_wide,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt64Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetObject,
+                          art_portable_aget_object,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kJavaObjectTy, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetBoolean,
+                          art_portable_aget_boolean,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt1Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetByte,
+                          art_portable_aget_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt8Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetChar,
+                          art_portable_aget_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayGetShort,
+                          art_portable_aget_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kArray),
+                          _EXPAND_ARG2(kJavaObjectTy, kInt32Ty))
+
+// void art_portable_aput_[type]([type] value, JavaObject* array, uint32_t index)
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPut,
+                          art_portable_aput,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt32Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutWide,
+                          art_portable_aput_wide,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt64Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutObject,
+                          art_portable_aput_object,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kJavaObjectTy, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutBoolean,
+                          art_portable_aput_boolean,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt1Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutByte,
+                          art_portable_aput_byte,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt8Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutChar,
+                          art_portable_aput_char,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt16Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(ArrayPutShort,
+                          art_portable_aput_short,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(_JTYPE(kInt16Ty, kArray), kJavaObjectTy, kInt32Ty))
+
+// void art_portable_check_put_array_element(JavaObject* value, JavaObject* array)
+_EVAL_DEF_INTRINSICS_FUNC(CheckPutArrayElement,
+                          art_portable_check_put_array_element,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaObjectTy, kJavaObjectTy))
+
+// void art_portable_filled_new_array(Array* array,
+//                                uint32_t elem_jty, ...)
+_EVAL_DEF_INTRINSICS_FUNC(FilledNewArray,
+                          art_portable_filled_new_array,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kVarArgTy))
+
+// void art_portable_fill_array_data(Method* referrer,
+//                               uint32_t dex_pc,
+//                               Array* array,
+//                               uint32_t payload_offset)
+_EVAL_DEF_INTRINSICS_FUNC(FillArrayData,
+                          art_portable_fill_array_data,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaMethodTy, kInt32ConstantTy, kJavaObjectTy, kInt32ConstantTy))
+
+// void art_portable_hl_fill_array_data(int32_t offset, JavaObject* array)
+_EVAL_DEF_INTRINSICS_FUNC(HLFillArrayData,
+                          art_portable_hl_fill_array_data,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaObjectTy))
+
+//----------------------------------------------------------------------------
+// Instance Field
+//----------------------------------------------------------------------------
+
+// [type] art_portable_iget_[type](uint32_t field_idx,
+//                             Method* referrer,
+//                             JavaObject* obj)
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGet,
+                          art_portable_iget,
+                          kAttrNone,
+                          _JTYPE(kInt32Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetWide,
+                          art_portable_iget_wide,
+                          kAttrNone,
+                          _JTYPE(kInt64Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetObject,
+                          art_portable_iget_object,
+                          kAttrNone,
+                          _JTYPE(kJavaObjectTy, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetBoolean,
+                          art_portable_iget_boolean,
+                          kAttrNone,
+                          _JTYPE(kInt1Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetByte,
+                          art_portable_iget_byte,
+                          kAttrNone,
+                          _JTYPE(kInt8Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetChar,
+                          art_portable_iget_char,
+                          kAttrNone,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetShort,
+                          art_portable_iget_short,
+                          kAttrNone,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy))
+
+// [type] art_portable_iget_[type].fast(int field_offset,
+//                                  bool is_volatile,
+//                                  JavaObject* obj)
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetFast,
+                          art_portable_iget.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt32Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetWideFast,
+                          art_portable_iget_wide.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt64Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetObjectFast,
+                          art_portable_iget_object.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kJavaObjectTy, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetBooleanFast,
+                          art_portable_iget_boolean.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt1Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetByteFast,
+                          art_portable_iget_byte.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt8Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetCharFast,
+                          art_portable_iget_char.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldGetShortFast,
+                          art_portable_iget_short.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy))
+
+// void art_portable_iput_[type](uint32_t field_idx,
+//                           Method* referrer,
+//                           JavaObject* obj,
+//                           [type] new_value)
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPut,
+                          art_portable_iput,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt32Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutWide,
+                          art_portable_iput_wide,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt64Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutObject,
+                          art_portable_iput_object,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kJavaObjectTy, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutBoolean,
+                          art_portable_iput_boolean,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt1Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutByte,
+                          art_portable_iput_byte,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt8Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutChar,
+                          art_portable_iput_char,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt16Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutShort,
+                          art_portable_iput_short,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaMethodTy, kJavaObjectTy, _JTYPE(kInt16Ty, kField)))
+
+// void art_portable_iput_[type].fast(int field_offset,
+//                                bool is_volatile,
+//                                JavaObject* obj,
+//                                [type] new_value)
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutFast,
+                          art_portable_iput.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt32Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutWideFast,
+                          art_portable_iput_wide.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt64Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutObjectFast,
+                          art_portable_iput_object.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kJavaObjectTy, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutBooleanFast,
+                          art_portable_iput_boolean.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt1Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutByteFast,
+                          art_portable_iput_byte.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt8Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutCharFast,
+                          art_portable_iput_char.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt16Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(InstanceFieldPutShortFast,
+                          art_portable_iput_short.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kInt1ConstantTy, kJavaObjectTy, _JTYPE(kInt16Ty, kField)))
+
+//----------------------------------------------------------------------------
+// Static Field
+//----------------------------------------------------------------------------
+
+// [type] art_portable_sget_[type](uint32_t field_idx, Method* referrer)
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGet,
+                          art_portable_sget,
+                          kAttrNone,
+                          _JTYPE(kInt32Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetWide,
+                          art_portable_sget_wide,
+                          kAttrNone,
+                          _JTYPE(kInt64Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetObject,
+                          art_portable_sget_object,
+                          kAttrNone,
+                          _JTYPE(kJavaObjectTy, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetBoolean,
+                          art_portable_sget_boolean,
+                          kAttrNone,
+                          _JTYPE(kInt1Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetByte,
+                          art_portable_sget_byte,
+                          kAttrNone,
+                          _JTYPE(kInt8Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetChar,
+                          art_portable_sget_char,
+                          kAttrNone,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetShort,
+                          art_portable_sget_short,
+                          kAttrNone,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaMethodTy))
+
+// [type] art_portable_sget_[type].fast(JavaObject* ssb,
+//                                  int field_offset,
+//                                  bool is_volatile)
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetFast,
+                          art_portable_sget.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt32Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetWideFast,
+                          art_portable_sget_wide.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt64Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetObjectFast,
+                          art_portable_sget_object.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kJavaObjectTy, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetBooleanFast,
+                          art_portable_sget_boolean.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt1Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetByteFast,
+                          art_portable_sget_byte.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt8Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetCharFast,
+                          art_portable_sget_char.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldGetShortFast,
+                          art_portable_sget_short.fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          _JTYPE(kInt16Ty, kField),
+                          _EXPAND_ARG3(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy))
+
+// void art_portable_sput_[type](uint32_t field_idx,
+//                           Method* referrer,
+//                           [type] new_value)
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPut,
+                          art_portable_sput,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt32Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutWide,
+                          art_portable_sput_wide,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt64Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutObject,
+                          art_portable_sput_object,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kJavaObjectTy, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutBoolean,
+                          art_portable_sput_boolean,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt1Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutByte,
+                          art_portable_sput_byte,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt8Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutChar,
+                          art_portable_sput_char,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt16Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutShort,
+                          art_portable_sput_short,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, _JTYPE(kInt16Ty, kField)))
+
+// void art_portable_sput_[type].fast(JavaObject* ssb,
+//                                int field_offset,
+//                                bool is_volatile,
+//                                [type] new_value)
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutFast,
+                          art_portable_sput.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt32Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutWideFast,
+                          art_portable_sput_wide.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt64Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutObjectFast,
+                          art_portable_sput_object.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kJavaObjectTy, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutBooleanFast,
+                          art_portable_sput_boolean.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt1Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutByteFast,
+                          art_portable_sput_byte.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt8Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutCharFast,
+                          art_portable_sput_char.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt16Ty, kField)))
+
+_EVAL_DEF_INTRINSICS_FUNC(StaticFieldPutShortFast,
+                          art_portable_sput_short.fast,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kJavaObjectTy, kInt32ConstantTy, kInt1ConstantTy, _JTYPE(kInt16Ty, kField)))
+
+// JavaObject* art_portable_load_declaring_class_ssb(Method* method)
+// Load the static storage base of the class that given method resides
+_EVAL_DEF_INTRINSICS_FUNC(LoadDeclaringClassSSB,
+                          art_portable_load_declaring_class_ssb,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kJavaMethodTy))
+
+// JavaObject* art_portable_load_class_ssb_from_dex_cache(uint32_t type_idx)
+_EVAL_DEF_INTRINSICS_FUNC(LoadClassSSBFromDexCache,
+                          art_portable_load_class_ssb_from_dex_cache,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// JavaObject* art_portable_init_and_load_class_ssb(uint32_t type_idx,
+//                                              Method* referrer,
+//                                              Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(InitializeAndLoadClassSSB,
+                          art_portable_init_and_load_class_ssb,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32ConstantTy, kJavaMethodTy, kJavaThreadTy))
+
+//----------------------------------------------------------------------------
+// High-level Array get/put
+//
+// Similar to art_portable_aget/aput_xxx, but checks not yet performed.
+// OptFlags contain info describing whether frontend has determined that
+// null check and/or array bounds check may be skipped.
+//
+// [type] void art_portable_hl_aget_[type](int optFlags, JavaObject* array, uint32_t index)
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGet,
+                          art_portable_hl_aget,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetFloat,
+                          art_portable_hl_aget_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kFloatTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetWide,
+                          art_portable_hl_aget_wide,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetDouble,
+                          art_portable_hl_aget_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kDoubleTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetObject,
+                          art_portable_hl_aget_object,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetBoolean,
+                          art_portable_hl_aget_boolean,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetByte,
+                          art_portable_hl_aget_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetChar,
+                          art_portable_hl_aget_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayGetShort,
+                          art_portable_hl_aget_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+// void art_portable_aput_[type](int optFlags, [type] value, JavaObject* array, uint32_t index)
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPut,
+                          art_portable_hl_aput,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutFloat,
+                          art_portable_hl_aput_float,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kFloatTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutWide,
+                          art_portable_hl_aput_wide,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt64Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutDouble,
+                          art_portable_hl_aput_double,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kDoubleTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutObject,
+                          art_portable_hl_aput_object,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kJavaObjectTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutBoolean,
+                          art_portable_hl_aput_boolean,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutByte,
+                          art_portable_hl_aput_byte,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutChar,
+                          art_portable_hl_aput_char,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLArrayPutShort,
+                          art_portable_hl_aput_short,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+//----------------------------------------------------------------------------
+// High-level Instance get/put
+//
+// Similar to art_portable_iget/iput_xxx, but checks not yet performed.
+// OptFlags contain info describing whether frontend has determined that
+// null check may be skipped.
+//
+// [type] void art_portable_hl_iget_[type](int optFlags, JavaObject* obj, uint32_t field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLIGet,
+                          art_portable_hl_iget,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetFloat,
+                          art_portable_hl_iget_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kFloatTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetWide,
+                          art_portable_hl_iget_wide,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetDouble,
+                          art_portable_hl_iget_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kDoubleTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetObject,
+                          art_portable_hl_iget_object,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetBoolean,
+                          art_portable_hl_iget_boolean,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetByte,
+                          art_portable_hl_iget_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetChar,
+                          art_portable_hl_iget_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIGetShort,
+                          art_portable_hl_iget_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG3(kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+// void art_portable_iput_[type](int optFlags, [type] value, JavaObject* obj, uint32_t field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLIPut,
+                          art_portable_hl_iput,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutFloat,
+                          art_portable_hl_iput_float,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kFloatTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutWide,
+                          art_portable_hl_iput_wide,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt64Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutDouble,
+                          art_portable_hl_iput_double,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kDoubleTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutObject,
+                          art_portable_hl_iput_object,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kJavaObjectTy, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutBoolean,
+                          art_portable_hl_iput_boolean,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutByte,
+                          art_portable_hl_iput_byte,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutChar,
+                          art_portable_hl_iput_char,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(HLIPutShort,
+                          art_portable_hl_iput_short,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG4(kInt32Ty, kInt32Ty, kJavaObjectTy, kInt32Ty))
+
+//----------------------------------------------------------------------------
+// High-level Invokes (fast-path determination not yet performed)
+//
+// NOTE: We expect these intrinsics to be temporary.  Once calling conventions are
+//       fully merged, the unified front end will lower down to the
+//       InvokeRetxxx() intrinsics in the next section and these will be
+//       removed.
+//
+// arg0: InvokeType [ignored if FilledNewArray]
+// arg1: method_idx [ignored if FilledNewArray]
+// arg2: optimization_flags (primary to note whether null checking is needed)
+// [arg3..argN]: actual arguments
+//----------------------------------------------------------------------------
+// INVOKE method returns void
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeVoid,
+                          art_portable_hl_invoke.void,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// INVOKE method returns object
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeObj,
+                          art_portable_hl_invoke.obj,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// INVOKE method returns int
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeInt,
+                          art_portable_hl_invoke.i32,
+                          kAttrNone,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// INVOKE method returns float
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeFloat,
+                          art_portable_hl_invoke.f32,
+                          kAttrNone,
+                          kFloatTy,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// INVOKE method returns long
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeLong,
+                          art_portable_hl_invoke.i64,
+                          kAttrNone,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// INVOKE method returns double
+_EVAL_DEF_INTRINSICS_FUNC(HLInvokeDouble,
+                          art_portable_hl_invoke.f64,
+                          kAttrNone,
+                          kDoubleTy,
+                          _EXPAND_ARG1(kVarArgTy))
+
+// FILLED_NEW_ARRAY returns object
+_EVAL_DEF_INTRINSICS_FUNC(HLFilledNewArray,
+                          art_portable_hl_filled_new_array,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kVarArgTy))
+
+//----------------------------------------------------------------------------
+// Invoke
+//----------------------------------------------------------------------------
+
+// Method* art_portable_find_static_method_with_access_check(uint32_t method_idx,
+//                                                       JavaObject* this,
+//                                                       Method* referrer,
+//                                                       Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(FindStaticMethodWithAccessCheck,
+                          art_portable_find_static_method_with_access_check,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// Method* art_portable_find_direct_method_with_access_check(uint32_t method_idx,
+//                                                       JavaObject* this,
+//                                                       Method* referrer,
+//                                                       Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(FindDirectMethodWithAccessCheck,
+                          art_portable_find_direct_method_with_access_check,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// Method* art_portable_find_virtual_method_with_access_check(uint32_t method_idx,
+//                                                        JavaObject* this,
+//                                                        Method* referrer,
+//                                                        Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(FindVirtualMethodWithAccessCheck,
+                          art_portable_find_virtual_method_with_access_check,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// Method* art_portable_find_super_method_with_access_check(uint32_t method_idx,
+//                                                      JavaObject* this,
+//                                                      Method* referrer,
+//                                                      Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(FindSuperMethodWithAccessCheck,
+                          art_portable_find_super_method_with_access_check,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// Method* art_portable_find_interface_method_with_access_check(uint32_t method_idx,
+//                                                          JavaObject* this,
+//                                                          Method* referrer,
+//                                                          Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(FindInterfaceMethodWithAccessCheck,
+                          art_portable_find_interface_method_with_access_check,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// Method* art_portable_get_sd_callee_method_obj_addr(uint32_t method_idx)
+_EVAL_DEF_INTRINSICS_FUNC(GetSDCalleeMethodObjAddrFast,
+                          art_portable_get_sd_callee_method_obj_addr_fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaMethodTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// Method* art_portable_get_virtual_callee_method_obj_addr(uint32_t vtable_idx,
+//                                                     JavaObject* this)
+_EVAL_DEF_INTRINSICS_FUNC(GetVirtualCalleeMethodObjAddrFast,
+                          art_portable_get_virtual_callee_method_obj_addr_fast,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaMethodTy,
+                          _EXPAND_ARG2(kInt32ConstantTy, kJavaObjectTy))
+
+// Method* art_portable_get_interface_callee_method_obj_addr(uint32_t method_idx,
+//                                                       JavaObject* this,
+//                                                       Method* referrer,
+//                                                       Thread* thread)
+_EVAL_DEF_INTRINSICS_FUNC(GetInterfaceCalleeMethodObjAddrFast,
+                          art_portable_get_interface_callee_method_obj_addr_fast,
+                          kAttrNone,
+                          kJavaMethodTy,
+                          _EXPAND_ARG4(kInt32ConstantTy, kJavaObjectTy, kJavaMethodTy, kJavaThreadTy))
+
+// [type] art_portable_invoke.[type](Method* callee, ...)
+// INVOKE method returns void
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetVoid,
+                          art_portable_invoke.void,
+                          kAttrNone,
+                          kVoidTy,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type boolean
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetBoolean,
+                          art_portable_invoke.bool,
+                          kAttrNone,
+                          kInt1Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type byte
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetByte,
+                          art_portable_invoke.byte,
+                          kAttrNone,
+                          kInt8Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type char
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetChar,
+                          art_portable_invoke.char,
+                          kAttrNone,
+                          kInt16Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type short
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetShort,
+                          art_portable_invoke.short,
+                          kAttrNone,
+                          kInt16Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type int
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetInt,
+                          art_portable_invoke.int,
+                          kAttrNone,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type long
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetLong,
+                          art_portable_invoke.long,
+                          kAttrNone,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type float
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetFloat,
+                          art_portable_invoke.float,
+                          kAttrNone,
+                          kFloatTy,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type double
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetDouble,
+                          art_portable_invoke.double,
+                          kAttrNone,
+                          kDoubleTy,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+// INVOKE method returns the value of type "object"
+_EVAL_DEF_INTRINSICS_FUNC(InvokeRetObject,
+                          art_portable_invoke.object,
+                          kAttrNone,
+                          kJavaObjectTy,
+                          _EXPAND_ARG2(kJavaMethodTy, kVarArgTy))
+
+//----------------------------------------------------------------------------
+// Math
+//----------------------------------------------------------------------------
+
+// int art_portable_{div,rem}_int(int a, int b)
+_EVAL_DEF_INTRINSICS_FUNC(DivInt,
+                          art_portable_div_int,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(RemInt,
+                          art_portable_rem_int,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// long art_portable_{div,rem}_long(long a, long b)
+_EVAL_DEF_INTRINSICS_FUNC(DivLong,
+                          art_portable_div_long,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kInt64Ty, kInt64Ty))
+
+_EVAL_DEF_INTRINSICS_FUNC(RemLong,
+                          art_portable_rem_long,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kInt64Ty, kInt64Ty))
+
+// int64_t art_portable_d2l(double f)
+_EVAL_DEF_INTRINSICS_FUNC(D2L,
+                          art_portable_d2l,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kDoubleTy))
+
+// int32_t art_portable_d2l(double f)
+_EVAL_DEF_INTRINSICS_FUNC(D2I,
+                          art_portable_d2i,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kDoubleTy))
+
+// int64_t art_portable_f2l(float f)
+_EVAL_DEF_INTRINSICS_FUNC(F2L,
+                          art_portable_f2l,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kFloatTy))
+
+// int32_t art_portable_f2i(float f)
+_EVAL_DEF_INTRINSICS_FUNC(F2I,
+                          art_portable_f2i,
+                          kAttrReadNone | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kFloatTy))
+
+//----------------------------------------------------------------------------
+// sput intrinsics to assist MIR to Greenland_ir conversion.
+// "HL" versions - will be deprecated when fast/slow path handling done
+// in the common frontend.
+//----------------------------------------------------------------------------
+
+// void sput_hl(int field_idx, int val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSput,
+                          art_portable_hl_sput,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// void sput_hl_object(int field_idx, object* val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputObject,
+                          art_portable_hl_sput_object,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kJavaObjectTy))
+
+// void sput_hl_boolean(int field_idx, kInt1Ty)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputBoolean,
+                          art_portable_hl_sput_boolean,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// void sput_hl_byte(int field_idx, int val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputByte,
+                          art_portable_hl_sput_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// void sput_hl_char(int field_idx, kInt16Ty val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputChar,
+                          art_portable_hl_sput_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// void sput_hl_short(int field_idx, int val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputShort,
+                          art_portable_hl_sput_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt32Ty))
+
+// void sput_hl_wide(int field_idx, long val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputWide,
+                          art_portable_hl_sput_wide,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kInt64Ty))
+
+// void sput_hl_double(int field_idx, double val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputDouble,
+                          art_portable_hl_sput_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kDoubleTy))
+
+// void sput_hl_float(int field_idx, float val)
+_EVAL_DEF_INTRINSICS_FUNC(HLSputFloat,
+                          art_portable_hl_sput_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kFloatTy))
+
+//----------------------------------------------------------------------------
+// sget intrinsics to assist MIR to Greenland_ir conversion.
+// "HL" versions - will be deprecated when fast/slow path handling done
+// in the common frontend.
+//----------------------------------------------------------------------------
+
+// int sget_hl(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSget,
+                          art_portable_hl_sget,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// object* sget_hl_object(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetObject,
+                          art_portable_hl_sget_object,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// boolean sget_hl_boolean(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetBoolean,
+                          art_portable_hl_sget_boolean,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// byte sget_hl_byte(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetByte,
+                          art_portable_hl_sget_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// char sget_hl_char(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetChar,
+                          art_portable_hl_sget_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// char sget_hl_short(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetShort,
+                          art_portable_hl_sget_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// char sget_hl_wide(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetWide,
+                          art_portable_hl_sget_wide,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// char sget_hl_double(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetDouble,
+                          art_portable_hl_sget_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kDoubleTy,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// char sget_hl_float(int field_idx)
+_EVAL_DEF_INTRINSICS_FUNC(HLSgetFloat,
+                          art_portable_hl_sget_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kFloatTy,
+                          _EXPAND_ARG1(kInt32Ty))
+//----------------------------------------------------------------------------
+// Monitor enter/exit
+//----------------------------------------------------------------------------
+// uint32_t art_portable_monitor_enter(int optFlags, JavaObject* obj)
+_EVAL_DEF_INTRINSICS_FUNC(MonitorEnter,
+                          art_portable_monitor_enter,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kJavaObjectTy))
+
+// uint32_t art_portable_monitor_exit(int optFlags, JavaObject* obj)
+_EVAL_DEF_INTRINSICS_FUNC(MonitorExit,
+                          art_portable_monitor_exit,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32Ty, kJavaObjectTy))
+
+//----------------------------------------------------------------------------
+// Shadow Frame
+//----------------------------------------------------------------------------
+
+// void art_portable_alloca_shadow_frame(int num_entry)
+_EVAL_DEF_INTRINSICS_FUNC(AllocaShadowFrame,
+                          art_portable_alloca_shadow_frame,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+// void art_portable_set_vreg(int entry_idx, ...)
+_EVAL_DEF_INTRINSICS_FUNC(SetVReg,
+                          art_portable_set_vreg,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG2(kInt32ConstantTy, kVarArgTy))
+
+// void art_portable_pop_shadow_frame()
+_EVAL_DEF_INTRINSICS_FUNC(PopShadowFrame,
+                          art_portable_pop_shadow_frame,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG0())
+
+// void art_portable_update_dex_pc(uint32_t dex_pc)
+_EVAL_DEF_INTRINSICS_FUNC(UpdateDexPC,
+                          art_portable_update_dex_pc,
+                          kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG1(kInt32ConstantTy))
+
+//----------------------------------------------------------------------------
+// FP Comparison
+//----------------------------------------------------------------------------
+// int cmpl_float(float, float)
+_EVAL_DEF_INTRINSICS_FUNC(CmplFloat,
+                          art_portable_cmpl_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kFloatTy, kFloatTy))
+
+// int cmpg_float(float, float)
+_EVAL_DEF_INTRINSICS_FUNC(CmpgFloat,
+                          art_portable_cmpg_float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kFloatTy, kFloatTy))
+
+// int cmpl_double(double, double)
+_EVAL_DEF_INTRINSICS_FUNC(CmplDouble,
+                          art_portable_cmpl_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kDoubleTy, kDoubleTy))
+
+// int cmpg_double(double, double)
+_EVAL_DEF_INTRINSICS_FUNC(CmpgDouble,
+                          art_portable_cmpg_double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kDoubleTy, kDoubleTy))
+
+//----------------------------------------------------------------------------
+// Long Comparison
+//----------------------------------------------------------------------------
+// int cmp_long(long, long)
+_EVAL_DEF_INTRINSICS_FUNC(CmpLong,
+                          art_portable_cmp_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt64Ty, kInt64Ty))
+
+//----------------------------------------------------------------------------
+// Const intrinsics to assist MIR to Greenland_ir conversion.  Should not materialize
+// For simplicity, all use integer input
+//----------------------------------------------------------------------------
+// int const_int(int)
+_EVAL_DEF_INTRINSICS_FUNC(ConstInt,
+                          art_portable_const_int,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// JavaObject* const_obj(int)
+_EVAL_DEF_INTRINSICS_FUNC(ConstObj,
+                          art_portable_const_obj,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// long const_long(long)
+_EVAL_DEF_INTRINSICS_FUNC(ConstLong,
+                          art_portable_const_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kInt64Ty))
+
+// float const_float(int)
+_EVAL_DEF_INTRINSICS_FUNC(ConstFloat,
+                          art_portable_const_Float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kFloatTy,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// double const_double(long)
+_EVAL_DEF_INTRINSICS_FUNC(ConstDouble,
+                          art_portable_const_Double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kDoubleTy,
+                          _EXPAND_ARG1(kInt64Ty))
+
+
+//----------------------------------------------------------------------------
+// Copy intrinsics to assist MIR to Greenland_ir conversion.  Should not materialize
+//----------------------------------------------------------------------------
+
+// void method_info(void)
+_EVAL_DEF_INTRINSICS_FUNC(MethodInfo,
+                          art_portable_method_info,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG0())
+
+// int copy_int(int)
+_EVAL_DEF_INTRINSICS_FUNC(CopyInt,
+                          art_portable_copy_int,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// JavaObject* copy_obj(obj)
+_EVAL_DEF_INTRINSICS_FUNC(CopyObj,
+                          art_portable_copy_obj,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kJavaObjectTy,
+                          _EXPAND_ARG1(kJavaObjectTy))
+
+// long copy_long(long)
+_EVAL_DEF_INTRINSICS_FUNC(CopyLong,
+                          art_portable_copy_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG1(kInt64Ty))
+
+// float copy_float(float)
+_EVAL_DEF_INTRINSICS_FUNC(CopyFloat,
+                          art_portable_copy_Float,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kFloatTy,
+                          _EXPAND_ARG1(kFloatTy))
+
+// double copy_double(double)
+_EVAL_DEF_INTRINSICS_FUNC(CopyDouble,
+                          art_portable_copy_Double,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kDoubleTy,
+                          _EXPAND_ARG1(kDoubleTy))
+
+//----------------------------------------------------------------------------
+// Shift intrinsics.  Shift semantics for Dalvik are a bit different than
+// the llvm shift operators.  For 32-bit shifts, the shift count is constrained
+// to the range of 0..31, while for 64-bit shifts we limit to 0..63.
+// Further, the shift count for Long shifts in Dalvik is 32 bits, while
+// llvm requires a 64-bit shift count. For GBC, we represent shifts as an
+//  intrinsic to allow most efficient target-dependent lowering.
+//----------------------------------------------------------------------------
+// long shl_long(long,int)
+_EVAL_DEF_INTRINSICS_FUNC(SHLLong,
+                          art_portable_shl_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kInt64Ty,kInt32Ty))
+// long shr_long(long,int)
+_EVAL_DEF_INTRINSICS_FUNC(SHRLong,
+                          art_portable_shr_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kInt64Ty,kInt32Ty))
+// long ushr_long(long,int)
+_EVAL_DEF_INTRINSICS_FUNC(USHRLong,
+                          art_portable_ushl_long,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt64Ty,
+                          _EXPAND_ARG2(kInt64Ty,kInt32Ty))
+// int shl_int(int,int)
+_EVAL_DEF_INTRINSICS_FUNC(SHLInt,
+                          art_portable_shl_int,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty,kInt32Ty))
+// long shr_int(int,int)
+_EVAL_DEF_INTRINSICS_FUNC(SHRInt,
+                          art_portable_shr_int,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty,kInt32Ty))
+// int ushr_long(int,int)
+_EVAL_DEF_INTRINSICS_FUNC(USHRInt,
+                          art_portable_ushl_int,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG2(kInt32Ty,kInt32Ty))
+//----------------------------------------------------------------------------
+// Conversion instrinsics.  Note: these should eventually be removed.  We
+// can express these directly in bitcode, but by using intrinsics the
+// Quick compiler can be more efficient.  Some extra optimization infrastructure
+// will have to be developed to undo the bitcode verbosity when these are
+// done inline.
+//----------------------------------------------------------------------------
+// int int_to_byte(int)
+_EVAL_DEF_INTRINSICS_FUNC(IntToByte,
+                          art_portable_int_to_byte,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// int int_to_char(int)
+_EVAL_DEF_INTRINSICS_FUNC(IntToChar,
+                          art_portable_int_to_char,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+// int int_to_short(int)
+_EVAL_DEF_INTRINSICS_FUNC(IntToShort,
+                          art_portable_int_to_short,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kInt32Ty,
+                          _EXPAND_ARG1(kInt32Ty))
+
+//----------------------------------------------------------------------------
+// Memory barrier
+//----------------------------------------------------------------------------
+// void constructor_barrier()
+_EVAL_DEF_INTRINSICS_FUNC(ConstructorBarrier,
+                          art_portable_constructor_barrier,
+                          kAttrReadOnly | kAttrNoThrow,
+                          kVoidTy,
+                          _EXPAND_ARG0())
+
+// Clean up all internal used macros
+#undef _EXPAND_ARG0
+#undef _EXPAND_ARG1
+#undef _EXPAND_ARG2
+#undef _EXPAND_ARG3
+#undef _EXPAND_ARG4
+#undef _EXPAND_ARG5
+
+#undef _JTYPE_OF_kInt1Ty_UNDER_kArray
+#undef _JTYPE_OF_kInt8Ty_UNDER_kArray
+#undef _JTYPE_OF_kInt16Ty_UNDER_kArray
+#undef _JTYPE_OF_kInt32Ty_UNDER_kArray
+#undef _JTYPE_OF_kInt64Ty_UNDER_kArray
+#undef _JTYPE_OF_kJavaObjectTy_UNDER_kArray
+
+#undef _JTYPE_OF_kInt1Ty_UNDER_kField
+#undef _JTYPE_OF_kInt8Ty_UNDER_kField
+#undef _JTYPE_OF_kInt16Ty_UNDER_kField
+#undef _JTYPE_OF_kInt32Ty_UNDER_kField
+#undef _JTYPE_OF_kInt64Ty_UNDER_kField
+#undef _JTYPE_OF_kJavaObjectTy_UNDER_kField
+
+#undef DEF_INTRINSICS_FUNC
diff --git a/src/compiler/llvm/intrinsic_helper.cc b/src/compiler/llvm/intrinsic_helper.cc
new file mode 100644
index 0000000..39c4a58
--- /dev/null
+++ b/src/compiler/llvm/intrinsic_helper.cc
@@ -0,0 +1,168 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "intrinsic_helper.h"
+
+#include "ir_builder.h"
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/Intrinsics.h>
+#include <llvm/Support/IRBuilder.h>
+
+namespace art {
+namespace llvm {
+
+const IntrinsicHelper::IntrinsicInfo IntrinsicHelper::Info[] = {
+#define DEF_INTRINSICS_FUNC(_, NAME, ATTR, RET_TYPE, ARG1_TYPE, ARG2_TYPE, \
+                                                     ARG3_TYPE, ARG4_TYPE, \
+                                                     ARG5_TYPE) \
+  { #NAME, ATTR, RET_TYPE, { ARG1_TYPE, ARG2_TYPE, \
+                             ARG3_TYPE, ARG4_TYPE, \
+                             ARG5_TYPE} },
+#include "intrinsic_func_list.def"
+};
+
+static ::llvm::Type* GetLLVMTypeOfIntrinsicValType(IRBuilder& irb,
+                                                   IntrinsicHelper::IntrinsicValType type) {
+  switch (type) {
+    case IntrinsicHelper::kVoidTy: {
+      return irb.getVoidTy();
+    }
+    case IntrinsicHelper::kJavaObjectTy: {
+      return irb.getJObjectTy();
+    }
+    case IntrinsicHelper::kJavaMethodTy: {
+      return irb.getJMethodTy();
+    }
+    case IntrinsicHelper::kJavaThreadTy: {
+      return irb.getJThreadTy();
+    }
+    case IntrinsicHelper::kInt1Ty:
+    case IntrinsicHelper::kInt1ConstantTy: {
+      return irb.getInt1Ty();
+    }
+    case IntrinsicHelper::kInt8Ty:
+    case IntrinsicHelper::kInt8ConstantTy: {
+      return irb.getInt8Ty();
+    }
+    case IntrinsicHelper::kInt16Ty:
+    case IntrinsicHelper::kInt16ConstantTy: {
+      return irb.getInt16Ty();
+    }
+    case IntrinsicHelper::kInt32Ty:
+    case IntrinsicHelper::kInt32ConstantTy: {
+      return irb.getInt32Ty();
+    }
+    case IntrinsicHelper::kInt64Ty:
+    case IntrinsicHelper::kInt64ConstantTy: {
+      return irb.getInt64Ty();
+    }
+    case IntrinsicHelper::kFloatTy:
+    case IntrinsicHelper::kFloatConstantTy: {
+      return irb.getFloatTy();
+    }
+    case IntrinsicHelper::kDoubleTy:
+    case IntrinsicHelper::kDoubleConstantTy: {
+      return irb.getDoubleTy();
+    }
+    case IntrinsicHelper::kNone:
+    case IntrinsicHelper::kVarArgTy:
+    default: {
+      LOG(FATAL) << "Invalid intrinsic type " << type << "to get LLVM type!";
+      return NULL;
+    }
+  }
+  // unreachable
+}
+
+IntrinsicHelper::IntrinsicHelper(::llvm::LLVMContext& context,
+                                 ::llvm::Module& module) {
+  IRBuilder irb(context, module, *this);
+
+  ::memset(intrinsic_funcs_, 0, sizeof(intrinsic_funcs_));
+
+  // This loop does the following things:
+  // 1. Introduce the intrinsic function into the module
+  // 2. Add "nocapture" and "noalias" attribute to the arguments in all
+  //    intrinsics functions.
+  // 3. Initialize intrinsic_funcs_map_.
+  for (unsigned i = 0; i < MaxIntrinsicId; i++) {
+    IntrinsicId id = static_cast<IntrinsicId>(i);
+    const IntrinsicInfo& info = Info[i];
+
+    // Parse and construct the argument type from IntrinsicInfo
+    ::llvm::Type* arg_type[kIntrinsicMaxArgc];
+    unsigned num_args = 0;
+    bool is_var_arg = false;
+    for (unsigned arg_iter = 0; arg_iter < kIntrinsicMaxArgc; arg_iter++) {
+      IntrinsicValType type = info.arg_type_[arg_iter];
+
+      if (type == kNone) {
+        break;
+      } else if (type == kVarArgTy) {
+        // Variable argument type must be the last argument
+        is_var_arg = true;
+        break;
+      }
+
+      arg_type[num_args++] = GetLLVMTypeOfIntrinsicValType(irb, type);
+    }
+
+    // Construct the function type
+    ::llvm::Type* ret_type =
+        GetLLVMTypeOfIntrinsicValType(irb, info.ret_val_type_);
+
+    ::llvm::FunctionType* type =
+        ::llvm::FunctionType::get(ret_type,
+                                  ::llvm::ArrayRef< ::llvm::Type*>(arg_type, num_args),
+                                  is_var_arg);
+
+    // Declare the function
+    ::llvm::Function *fn = ::llvm::Function::Create(type,
+                                                    ::llvm::Function::ExternalLinkage,
+                                                     info.name_, &module);
+
+    fn->setOnlyReadsMemory(info.attr_ & kAttrReadOnly);
+    fn->setDoesNotAccessMemory(info.attr_ & kAttrReadNone);
+    // None of the intrinsics throws exception
+    fn->setDoesNotThrow(true);
+
+    intrinsic_funcs_[id] = fn;
+
+    DCHECK_NE(fn, static_cast< ::llvm::Function*>(NULL)) << "Intrinsic `"
+        << GetName(id) << "' was not defined!";
+
+    // Add "noalias" and "nocapture" attribute to all arguments of pointer type
+    for (::llvm::Function::arg_iterator arg_iter = fn->arg_begin(),
+            arg_end = fn->arg_end(); arg_iter != arg_end; arg_iter++) {
+      if (arg_iter->getType()->isPointerTy()) {
+        arg_iter->addAttr(::llvm::Attribute::NoCapture);
+        arg_iter->addAttr(::llvm::Attribute::NoAlias);
+      }
+    }
+
+    // Insert the newly created intrinsic to intrinsic_funcs_map_
+    if (!intrinsic_funcs_map_.insert(std::make_pair(fn, id)).second) {
+      LOG(FATAL) << "Duplicate entry in intrinsic functions map?";
+    }
+  }
+
+  return;
+}
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/intrinsic_helper.h b/src/compiler/llvm/intrinsic_helper.h
new file mode 100644
index 0000000..49b8a95
--- /dev/null
+++ b/src/compiler/llvm/intrinsic_helper.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_GREENLAND_INTRINSIC_HELPER_H_
+#define ART_SRC_GREENLAND_INTRINSIC_HELPER_H_
+
+#include "base/logging.h"
+
+#include <llvm/ADT/DenseMap.h>
+
+namespace llvm {
+  class Function;
+  class FunctionType;
+  class LLVMContext;
+  class Module;
+}  // namespace llvm
+
+namespace art {
+namespace llvm {
+
+class IRBuilder;
+
+class IntrinsicHelper {
+ public:
+  enum IntrinsicId {
+#define DEF_INTRINSICS_FUNC(ID, ...) ID,
+#include "intrinsic_func_list.def"
+    MaxIntrinsicId,
+
+    // Pseudo-intrinsics Id
+    UnknownId
+  };
+
+  enum IntrinsicAttribute {
+    kAttrNone     = 0,
+
+    // Intrinsic that neither modified the memory state nor refer to the global
+    // state
+    kAttrReadNone = 1 << 0,
+
+    // Intrinsic that doesn't modify the memory state. Note that one should set
+    // this flag carefully when the intrinsic may throw exception. Since the
+    // thread state is implicitly modified when an exception is thrown.
+    kAttrReadOnly = 1 << 1,
+
+    // Note that intrinsic without kAttrNoThrow and kAttrDoThrow set means that
+    // intrinsic generates exception in some cases
+
+    // Intrinsic that never generates exception
+    kAttrNoThrow  = 1 << 2,
+    // Intrinsic that always generate exception
+    kAttrDoThrow  = 1 << 3,
+  };
+
+  enum IntrinsicValType {
+    kNone,
+
+    kVoidTy,
+
+    kJavaObjectTy,
+    kJavaMethodTy,
+    kJavaThreadTy,
+
+    kInt1Ty,
+    kInt8Ty,
+    kInt16Ty,
+    kInt32Ty,
+    kInt64Ty,
+    kFloatTy,
+    kDoubleTy,
+
+    kInt1ConstantTy,
+    kInt8ConstantTy,
+    kInt16ConstantTy,
+    kInt32ConstantTy,
+    kInt64ConstantTy,
+    kFloatConstantTy,
+    kDoubleConstantTy,
+
+    kVarArgTy,
+  };
+
+  enum {
+    kIntrinsicMaxArgc = 5
+  };
+
+  typedef struct IntrinsicInfo {
+    const char* name_;
+    unsigned attr_;
+    IntrinsicValType ret_val_type_;
+    IntrinsicValType arg_type_[kIntrinsicMaxArgc];
+  } IntrinsicInfo;
+
+ private:
+  static const IntrinsicInfo Info[];
+
+ public:
+  static const IntrinsicInfo& GetInfo(IntrinsicId id) {
+    DCHECK(id >= 0 && id < MaxIntrinsicId) << "Unknown ART intrinsics ID: "
+                                           << id;
+    return Info[id];
+  }
+
+  static const char* GetName(IntrinsicId id) {
+    return (id <= MaxIntrinsicId) ? GetInfo(id).name_ : "InvalidIntrinsic";
+  }
+
+  static unsigned GetAttr(IntrinsicId id) {
+    return GetInfo(id).attr_;
+  }
+
+ public:
+  IntrinsicHelper(::llvm::LLVMContext& context, ::llvm::Module& module);
+
+  ::llvm::Function* GetIntrinsicFunction(IntrinsicId id) {
+    DCHECK(id >= 0 && id < MaxIntrinsicId) << "Unknown ART intrinsics ID: "
+                                           << id;
+    return intrinsic_funcs_[id];
+  }
+
+  IntrinsicId GetIntrinsicId(const ::llvm::Function* func) const {
+    ::llvm::DenseMap<const ::llvm::Function*, IntrinsicId>::const_iterator
+        i = intrinsic_funcs_map_.find(func);
+    if (i == intrinsic_funcs_map_.end()) {
+      return UnknownId;
+    } else {
+      return i->second;
+    }
+  }
+
+ private:
+  // FIXME: "+1" is to workaround the GCC bugs:
+  // http://gcc.gnu.org/bugzilla/show_bug.cgi?id=43949
+  // Remove this when uses newer GCC (> 4.4.3)
+  ::llvm::Function* intrinsic_funcs_[MaxIntrinsicId + 1];
+
+  // Map a llvm::Function to its intrinsic id
+  ::llvm::DenseMap<const ::llvm::Function*, IntrinsicId> intrinsic_funcs_map_;
+};
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_GREENLAND_INTRINSIC_HELPER_H_
diff --git a/src/compiler/llvm/ir_builder.cc b/src/compiler/llvm/ir_builder.cc
new file mode 100644
index 0000000..1fd1c90
--- /dev/null
+++ b/src/compiler/llvm/ir_builder.cc
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "ir_builder.h"
+
+#include "base/stringprintf.h"
+
+#include <llvm/Module.h>
+
+namespace art {
+namespace llvm {
+
+
+//----------------------------------------------------------------------------
+// General
+//----------------------------------------------------------------------------
+
+IRBuilder::IRBuilder(::llvm::LLVMContext& context, ::llvm::Module& module,
+                     IntrinsicHelper& intrinsic_helper)
+    : LLVMIRBuilder(context), module_(&module), mdb_(context), java_object_type_(NULL),
+      java_method_type_(NULL), java_thread_type_(NULL), intrinsic_helper_(intrinsic_helper) {
+  // Get java object type from module
+  ::llvm::Type* jobject_struct_type = module.getTypeByName("JavaObject");
+  CHECK(jobject_struct_type != NULL);
+  java_object_type_ = jobject_struct_type->getPointerTo();
+
+  // If type of Method is not explicitly defined in the module, use JavaObject*
+  ::llvm::Type* type = module.getTypeByName("Method");
+  if (type != NULL) {
+    java_method_type_ = type->getPointerTo();
+  } else {
+    java_method_type_ = java_object_type_;
+  }
+
+  // If type of Thread is not explicitly defined in the module, use JavaObject*
+  type = module.getTypeByName("Thread");
+  if (type != NULL) {
+    java_thread_type_ = type->getPointerTo();
+  } else {
+    java_thread_type_ = java_object_type_;
+  }
+
+  // Create JEnv* type
+  ::llvm::Type* jenv_struct_type = ::llvm::StructType::create(context, "JEnv");
+  jenv_type_ = jenv_struct_type->getPointerTo();
+
+  // Get Art shadow frame struct type from module
+  art_frame_type_ = module.getTypeByName("ShadowFrame");
+  CHECK(art_frame_type_ != NULL);
+
+  runtime_support_ = NULL;
+}
+
+
+//----------------------------------------------------------------------------
+// Type Helper Function
+//----------------------------------------------------------------------------
+
+::llvm::Type* IRBuilder::getJType(JType jty) {
+  switch (jty) {
+  case kVoid:
+    return getJVoidTy();
+
+  case kBoolean:
+    return getJBooleanTy();
+
+  case kByte:
+    return getJByteTy();
+
+  case kChar:
+    return getJCharTy();
+
+  case kShort:
+    return getJShortTy();
+
+  case kInt:
+    return getJIntTy();
+
+  case kLong:
+    return getJLongTy();
+
+  case kFloat:
+    return getJFloatTy();
+
+  case kDouble:
+    return getJDoubleTy();
+
+  case kObject:
+    return getJObjectTy();
+
+  default:
+    LOG(FATAL) << "Unknown java type: " << jty;
+    return NULL;
+  }
+}
+
+::llvm::StructType* IRBuilder::getShadowFrameTy(uint32_t vreg_size) {
+  std::string name(StringPrintf("ShadowFrame%u", vreg_size));
+
+  // Try to find the existing struct type definition
+  if (::llvm::Type* type = module_->getTypeByName(name)) {
+    CHECK(::llvm::isa< ::llvm::StructType>(type));
+    return static_cast< ::llvm::StructType*>(type);
+  }
+
+  // Create new struct type definition
+  ::llvm::Type* elem_types[] = {
+    art_frame_type_,
+    ::llvm::ArrayType::get(getInt32Ty(), vreg_size),
+  };
+
+  return ::llvm::StructType::create(elem_types, name);
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/ir_builder.h b/src/compiler/llvm/ir_builder.h
new file mode 100644
index 0000000..9362a75
--- /dev/null
+++ b/src/compiler/llvm/ir_builder.h
@@ -0,0 +1,487 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_IR_BUILDER_H_
+#define ART_SRC_COMPILER_LLVM_IR_BUILDER_H_
+
+#include "backend_types.h"
+#include "compiler/dex/compiler_enums.h"
+#include "intrinsic_helper.h"
+#include "md_builder.h"
+#include "runtime_support_builder.h"
+#include "runtime_support_func.h"
+
+#include <llvm/Constants.h>
+#include <llvm/DerivedTypes.h>
+#include <llvm/LLVMContext.h>
+#include <llvm/Support/IRBuilder.h>
+#include <llvm/Support/NoFolder.h>
+#include <llvm/Type.h>
+
+#include <stdint.h>
+
+
+namespace art {
+namespace llvm {
+
+class InserterWithDexOffset : public ::llvm::IRBuilderDefaultInserter<true> {
+  public:
+    InserterWithDexOffset() : node_(NULL) {}
+
+    void InsertHelper(::llvm::Instruction *I, const ::llvm::Twine &Name,
+                      ::llvm::BasicBlock *BB,
+                      ::llvm::BasicBlock::iterator InsertPt) const {
+      ::llvm::IRBuilderDefaultInserter<true>::InsertHelper(I, Name, BB, InsertPt);
+      if (node_ != NULL) {
+        I->setMetadata("DexOff", node_);
+      }
+    }
+
+    void SetDexOffset(::llvm::MDNode* node) {
+      node_ = node;
+    }
+  private:
+    ::llvm::MDNode* node_;
+};
+
+typedef ::llvm::IRBuilder<true, ::llvm::ConstantFolder, InserterWithDexOffset> LLVMIRBuilder;
+// NOTE: Here we define our own LLVMIRBuilder type alias, so that we can
+// switch "preserveNames" template parameter easily.
+
+
+class IRBuilder : public LLVMIRBuilder {
+ public:
+  //--------------------------------------------------------------------------
+  // General
+  //--------------------------------------------------------------------------
+
+  IRBuilder(::llvm::LLVMContext& context, ::llvm::Module& module,
+            IntrinsicHelper& intrinsic_helper);
+
+
+  //--------------------------------------------------------------------------
+  // Extend load & store for TBAA
+  //--------------------------------------------------------------------------
+
+  ::llvm::LoadInst* CreateLoad(::llvm::Value* ptr, ::llvm::MDNode* tbaa_info) {
+    ::llvm::LoadInst* inst = LLVMIRBuilder::CreateLoad(ptr);
+    inst->setMetadata(::llvm::LLVMContext::MD_tbaa, tbaa_info);
+    return inst;
+  }
+
+  ::llvm::StoreInst* CreateStore(::llvm::Value* val, ::llvm::Value* ptr, ::llvm::MDNode* tbaa_info) {
+    ::llvm::StoreInst* inst = LLVMIRBuilder::CreateStore(val, ptr);
+    inst->setMetadata(::llvm::LLVMContext::MD_tbaa, tbaa_info);
+    return inst;
+  }
+
+  ::llvm::AtomicCmpXchgInst*
+  CreateAtomicCmpXchgInst(::llvm::Value* ptr, ::llvm::Value* cmp, ::llvm::Value* val,
+                          ::llvm::MDNode* tbaa_info) {
+    ::llvm::AtomicCmpXchgInst* inst =
+        LLVMIRBuilder::CreateAtomicCmpXchg(ptr, cmp, val, ::llvm::Acquire);
+    inst->setMetadata(::llvm::LLVMContext::MD_tbaa, tbaa_info);
+    return inst;
+  }
+
+  //--------------------------------------------------------------------------
+  // Extend memory barrier
+  //--------------------------------------------------------------------------
+  void CreateMemoryBarrier(MemBarrierKind barrier_kind) {
+#if ANDROID_SMP
+    // TODO: select atomic ordering according to given barrier kind.
+    CreateFence(::llvm::SequentiallyConsistent);
+#endif
+  }
+
+  //--------------------------------------------------------------------------
+  // TBAA
+  //--------------------------------------------------------------------------
+
+  // TODO: After we design the non-special TBAA info, re-design the TBAA interface.
+  ::llvm::LoadInst* CreateLoad(::llvm::Value* ptr, TBAASpecialType special_ty) {
+    return CreateLoad(ptr, mdb_.GetTBAASpecialType(special_ty));
+  }
+
+  ::llvm::StoreInst* CreateStore(::llvm::Value* val, ::llvm::Value* ptr, TBAASpecialType special_ty) {
+    DCHECK_NE(special_ty, kTBAAConstJObject) << "ConstJObject is read only!";
+    return CreateStore(val, ptr, mdb_.GetTBAASpecialType(special_ty));
+  }
+
+  ::llvm::LoadInst* CreateLoad(::llvm::Value* ptr, TBAASpecialType special_ty, JType j_ty) {
+    return CreateLoad(ptr, mdb_.GetTBAAMemoryJType(special_ty, j_ty));
+  }
+
+  ::llvm::StoreInst* CreateStore(::llvm::Value* val, ::llvm::Value* ptr,
+                               TBAASpecialType special_ty, JType j_ty) {
+    DCHECK_NE(special_ty, kTBAAConstJObject) << "ConstJObject is read only!";
+    return CreateStore(val, ptr, mdb_.GetTBAAMemoryJType(special_ty, j_ty));
+  }
+
+  ::llvm::LoadInst* LoadFromObjectOffset(::llvm::Value* object_addr,
+                                       int64_t offset,
+                                       ::llvm::Type* type,
+                                       TBAASpecialType special_ty) {
+    return LoadFromObjectOffset(object_addr, offset, type, mdb_.GetTBAASpecialType(special_ty));
+  }
+
+  void StoreToObjectOffset(::llvm::Value* object_addr,
+                           int64_t offset,
+                           ::llvm::Value* new_value,
+                           TBAASpecialType special_ty) {
+    DCHECK_NE(special_ty, kTBAAConstJObject) << "ConstJObject is read only!";
+    StoreToObjectOffset(object_addr, offset, new_value, mdb_.GetTBAASpecialType(special_ty));
+  }
+
+  ::llvm::LoadInst* LoadFromObjectOffset(::llvm::Value* object_addr,
+                                       int64_t offset,
+                                       ::llvm::Type* type,
+                                       TBAASpecialType special_ty, JType j_ty) {
+    return LoadFromObjectOffset(object_addr, offset, type, mdb_.GetTBAAMemoryJType(special_ty, j_ty));
+  }
+
+  void StoreToObjectOffset(::llvm::Value* object_addr,
+                           int64_t offset,
+                           ::llvm::Value* new_value,
+                           TBAASpecialType special_ty, JType j_ty) {
+    DCHECK_NE(special_ty, kTBAAConstJObject) << "ConstJObject is read only!";
+    StoreToObjectOffset(object_addr, offset, new_value, mdb_.GetTBAAMemoryJType(special_ty, j_ty));
+  }
+
+  ::llvm::AtomicCmpXchgInst*
+  CompareExchangeObjectOffset(::llvm::Value* object_addr,
+                              int64_t offset,
+                              ::llvm::Value* cmp_value,
+                              ::llvm::Value* new_value,
+                              TBAASpecialType special_ty) {
+    DCHECK_NE(special_ty, kTBAAConstJObject) << "ConstJObject is read only!";
+    return CompareExchangeObjectOffset(object_addr, offset, cmp_value, new_value,
+                                       mdb_.GetTBAASpecialType(special_ty));
+  }
+
+  void SetTBAA(::llvm::Instruction* inst, TBAASpecialType special_ty) {
+    inst->setMetadata(::llvm::LLVMContext::MD_tbaa, mdb_.GetTBAASpecialType(special_ty));
+  }
+
+
+  //--------------------------------------------------------------------------
+  // Static Branch Prediction
+  //--------------------------------------------------------------------------
+
+  // Import the orignal conditional branch
+  using LLVMIRBuilder::CreateCondBr;
+  ::llvm::BranchInst* CreateCondBr(::llvm::Value *cond,
+                                 ::llvm::BasicBlock* true_bb,
+                                 ::llvm::BasicBlock* false_bb,
+                                 ExpectCond expect) {
+    ::llvm::BranchInst* branch_inst = CreateCondBr(cond, true_bb, false_bb);
+    branch_inst->setMetadata(::llvm::LLVMContext::MD_prof, mdb_.GetBranchWeights(expect));
+    return branch_inst;
+  }
+
+
+  //--------------------------------------------------------------------------
+  // Pointer Arithmetic Helper Function
+  //--------------------------------------------------------------------------
+
+  ::llvm::IntegerType* getPtrEquivIntTy() {
+    return getInt32Ty();
+  }
+
+  size_t getSizeOfPtrEquivInt() {
+    return 4;
+  }
+
+  ::llvm::ConstantInt* getSizeOfPtrEquivIntValue() {
+    return getPtrEquivInt(getSizeOfPtrEquivInt());
+  }
+
+  ::llvm::ConstantInt* getPtrEquivInt(int64_t i) {
+    return ::llvm::ConstantInt::get(getPtrEquivIntTy(), i);
+  }
+
+  ::llvm::Value* CreatePtrDisp(::llvm::Value* base,
+                             ::llvm::Value* offset,
+                             ::llvm::PointerType* ret_ty) {
+
+    ::llvm::Value* base_int = CreatePtrToInt(base, getPtrEquivIntTy());
+    ::llvm::Value* result_int = CreateAdd(base_int, offset);
+    ::llvm::Value* result = CreateIntToPtr(result_int, ret_ty);
+
+    return result;
+  }
+
+  ::llvm::Value* CreatePtrDisp(::llvm::Value* base,
+                             ::llvm::Value* bs,
+                             ::llvm::Value* count,
+                             ::llvm::Value* offset,
+                             ::llvm::PointerType* ret_ty) {
+
+    ::llvm::Value* block_offset = CreateMul(bs, count);
+    ::llvm::Value* total_offset = CreateAdd(block_offset, offset);
+
+    return CreatePtrDisp(base, total_offset, ret_ty);
+  }
+
+  ::llvm::LoadInst* LoadFromObjectOffset(::llvm::Value* object_addr,
+                                       int64_t offset,
+                                       ::llvm::Type* type,
+                                       ::llvm::MDNode* tbaa_info) {
+    // Convert offset to ::llvm::value
+    ::llvm::Value* llvm_offset = getPtrEquivInt(offset);
+    // Calculate the value's address
+    ::llvm::Value* value_addr = CreatePtrDisp(object_addr, llvm_offset, type->getPointerTo());
+    // Load
+    return CreateLoad(value_addr, tbaa_info);
+  }
+
+  void StoreToObjectOffset(::llvm::Value* object_addr,
+                           int64_t offset,
+                           ::llvm::Value* new_value,
+                           ::llvm::MDNode* tbaa_info) {
+    // Convert offset to ::llvm::value
+    ::llvm::Value* llvm_offset = getPtrEquivInt(offset);
+    // Calculate the value's address
+    ::llvm::Value* value_addr = CreatePtrDisp(object_addr,
+                                            llvm_offset,
+                                            new_value->getType()->getPointerTo());
+    // Store
+    CreateStore(new_value, value_addr, tbaa_info);
+  }
+
+  ::llvm::AtomicCmpXchgInst* CompareExchangeObjectOffset(::llvm::Value* object_addr,
+                                                       int64_t offset,
+                                                       ::llvm::Value* cmp_value,
+                                                       ::llvm::Value* new_value,
+                                                       ::llvm::MDNode* tbaa_info) {
+    // Convert offset to ::llvm::value
+    ::llvm::Value* llvm_offset = getPtrEquivInt(offset);
+    // Calculate the value's address
+    ::llvm::Value* value_addr = CreatePtrDisp(object_addr,
+                                            llvm_offset,
+                                            new_value->getType()->getPointerTo());
+    // Atomic compare and exchange
+    return CreateAtomicCmpXchgInst(value_addr, cmp_value, new_value, tbaa_info);
+  }
+
+
+  //--------------------------------------------------------------------------
+  // Runtime Helper Function
+  //--------------------------------------------------------------------------
+
+  RuntimeSupportBuilder& Runtime() {
+    return *runtime_support_;
+  }
+
+  // TODO: Deprecate
+  ::llvm::Function* GetRuntime(runtime_support::RuntimeId rt) {
+    return runtime_support_->GetRuntimeSupportFunction(rt);
+  }
+
+  // TODO: Deprecate
+  void SetRuntimeSupport(RuntimeSupportBuilder* runtime_support) {
+    // Can only set once. We can't do this on constructor, because RuntimeSupportBuilder needs
+    // IRBuilder.
+    if (runtime_support_ == NULL && runtime_support != NULL) {
+      runtime_support_ = runtime_support;
+    }
+  }
+
+
+  //--------------------------------------------------------------------------
+  // Type Helper Function
+  //--------------------------------------------------------------------------
+
+  ::llvm::Type* getJType(char shorty_jty) {
+    return getJType(GetJTypeFromShorty(shorty_jty));
+  }
+
+  ::llvm::Type* getJType(JType jty);
+
+  ::llvm::Type* getJVoidTy() {
+    return getVoidTy();
+  }
+
+  ::llvm::IntegerType* getJBooleanTy() {
+    return getInt8Ty();
+  }
+
+  ::llvm::IntegerType* getJByteTy() {
+    return getInt8Ty();
+  }
+
+  ::llvm::IntegerType* getJCharTy() {
+    return getInt16Ty();
+  }
+
+  ::llvm::IntegerType* getJShortTy() {
+    return getInt16Ty();
+  }
+
+  ::llvm::IntegerType* getJIntTy() {
+    return getInt32Ty();
+  }
+
+  ::llvm::IntegerType* getJLongTy() {
+    return getInt64Ty();
+  }
+
+  ::llvm::Type* getJFloatTy() {
+    return getFloatTy();
+  }
+
+  ::llvm::Type* getJDoubleTy() {
+    return getDoubleTy();
+  }
+
+  ::llvm::PointerType* getJObjectTy() {
+    return java_object_type_;
+  }
+
+  ::llvm::PointerType* getJMethodTy() {
+    return java_method_type_;
+  }
+
+  ::llvm::PointerType* getJThreadTy() {
+    return java_thread_type_;
+  }
+
+  ::llvm::Type* getArtFrameTy() {
+    return art_frame_type_;
+  }
+
+  ::llvm::PointerType* getJEnvTy() {
+    return jenv_type_;
+  }
+
+  ::llvm::Type* getJValueTy() {
+    // NOTE: JValue is an union type, which may contains boolean, byte, char,
+    // short, int, long, float, double, Object.  However, LLVM itself does
+    // not support union type, so we have to return a type with biggest size,
+    // then bitcast it before we use it.
+    return getJLongTy();
+  }
+
+  ::llvm::StructType* getShadowFrameTy(uint32_t vreg_size);
+
+
+  //--------------------------------------------------------------------------
+  // Constant Value Helper Function
+  //--------------------------------------------------------------------------
+
+  ::llvm::ConstantInt* getJBoolean(bool is_true) {
+    return (is_true) ? getTrue() : getFalse();
+  }
+
+  ::llvm::ConstantInt* getJByte(int8_t i) {
+    return ::llvm::ConstantInt::getSigned(getJByteTy(), i);
+  }
+
+  ::llvm::ConstantInt* getJChar(int16_t i) {
+    return ::llvm::ConstantInt::getSigned(getJCharTy(), i);
+  }
+
+  ::llvm::ConstantInt* getJShort(int16_t i) {
+    return ::llvm::ConstantInt::getSigned(getJShortTy(), i);
+  }
+
+  ::llvm::ConstantInt* getJInt(int32_t i) {
+    return ::llvm::ConstantInt::getSigned(getJIntTy(), i);
+  }
+
+  ::llvm::ConstantInt* getJLong(int64_t i) {
+    return ::llvm::ConstantInt::getSigned(getJLongTy(), i);
+  }
+
+  ::llvm::Constant* getJFloat(float f) {
+    return ::llvm::ConstantFP::get(getJFloatTy(), f);
+  }
+
+  ::llvm::Constant* getJDouble(double d) {
+    return ::llvm::ConstantFP::get(getJDoubleTy(), d);
+  }
+
+  ::llvm::ConstantPointerNull* getJNull() {
+    return ::llvm::ConstantPointerNull::get(getJObjectTy());
+  }
+
+  ::llvm::Constant* getJZero(char shorty_jty) {
+    return getJZero(GetJTypeFromShorty(shorty_jty));
+  }
+
+  ::llvm::Constant* getJZero(JType jty) {
+    switch (jty) {
+    case kVoid:
+      LOG(FATAL) << "Zero is not a value of void type";
+      return NULL;
+
+    case kBoolean:
+      return getJBoolean(false);
+
+    case kByte:
+      return getJByte(0);
+
+    case kChar:
+      return getJChar(0);
+
+    case kShort:
+      return getJShort(0);
+
+    case kInt:
+      return getJInt(0);
+
+    case kLong:
+      return getJLong(0);
+
+    case kFloat:
+      return getJFloat(0.0f);
+
+    case kDouble:
+      return getJDouble(0.0);
+
+    case kObject:
+      return getJNull();
+
+    default:
+      LOG(FATAL) << "Unknown java type: " << jty;
+      return NULL;
+    }
+  }
+
+
+ private:
+  ::llvm::Module* module_;
+
+  MDBuilder mdb_;
+
+  ::llvm::PointerType* java_object_type_;
+  ::llvm::PointerType* java_method_type_;
+  ::llvm::PointerType* java_thread_type_;
+
+  ::llvm::PointerType* jenv_type_;
+
+  ::llvm::StructType* art_frame_type_;
+
+  RuntimeSupportBuilder* runtime_support_;
+
+  IntrinsicHelper& intrinsic_helper_;
+};
+
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_IR_BUILDER_H_
diff --git a/src/compiler/llvm/llvm_compilation_unit.cc b/src/compiler/llvm/llvm_compilation_unit.cc
new file mode 100644
index 0000000..aad18fb
--- /dev/null
+++ b/src/compiler/llvm/llvm_compilation_unit.cc
@@ -0,0 +1,420 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "llvm_compilation_unit.h"
+
+#include "base/logging.h"
+#include "compiled_method.h"
+#include "compiler_llvm.h"
+#include "instruction_set.h"
+#include "ir_builder.h"
+#include "os.h"
+
+#include "runtime_support_builder_arm.h"
+#include "runtime_support_builder_thumb2.h"
+#include "runtime_support_builder_x86.h"
+
+#include <llvm/ADT/OwningPtr.h>
+#include <llvm/ADT/StringSet.h>
+#include <llvm/ADT/Triple.h>
+#include <llvm/Analysis/CallGraph.h>
+#include <llvm/Analysis/DebugInfo.h>
+#include <llvm/Analysis/Dominators.h>
+#include <llvm/Analysis/LoopInfo.h>
+#include <llvm/Analysis/LoopPass.h>
+#include <llvm/Analysis/RegionPass.h>
+#include <llvm/Analysis/ScalarEvolution.h>
+#include <llvm/Analysis/Verifier.h>
+#include <llvm/Assembly/PrintModulePass.h>
+#include <llvm/Bitcode/ReaderWriter.h>
+#include <llvm/CallGraphSCCPass.h>
+#include <llvm/CodeGen/MachineFrameInfo.h>
+#include <llvm/CodeGen/MachineFunction.h>
+#include <llvm/CodeGen/MachineFunctionPass.h>
+#include <llvm/DerivedTypes.h>
+#include <llvm/LLVMContext.h>
+#include <llvm/Module.h>
+#include <llvm/Object/ObjectFile.h>
+#include <llvm/PassManager.h>
+#include <llvm/Support/Debug.h>
+#include <llvm/Support/ELF.h>
+#include <llvm/Support/FormattedStream.h>
+#include <llvm/Support/ManagedStatic.h>
+#include <llvm/Support/MemoryBuffer.h>
+#include <llvm/Support/PassNameParser.h>
+#include <llvm/Support/PluginLoader.h>
+#include <llvm/Support/PrettyStackTrace.h>
+#include <llvm/Support/Signals.h>
+#include <llvm/Support/SystemUtils.h>
+#include <llvm/Support/TargetRegistry.h>
+#include <llvm/Support/TargetSelect.h>
+#include <llvm/Support/ToolOutputFile.h>
+#include <llvm/Support/raw_ostream.h>
+#include <llvm/Support/system_error.h>
+#include <llvm/Target/TargetData.h>
+#include <llvm/Target/TargetLibraryInfo.h>
+#include <llvm/Target/TargetMachine.h>
+#include <llvm/Transforms/IPO.h>
+#include <llvm/Transforms/IPO/PassManagerBuilder.h>
+#include <llvm/Transforms/Scalar.h>
+
+#include <sys/types.h>
+#include <sys/wait.h>
+#include <unistd.h>
+
+#include <string>
+
+namespace art {
+namespace llvm {
+
+::llvm::FunctionPass*
+CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
+                      CompilerDriver* compiler, DexCompilationUnit* dex_compilation_unit);
+
+::llvm::Module* makeLLVMModuleContents(::llvm::Module* module);
+
+
+LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm, size_t cunit_idx)
+    : compiler_llvm_(compiler_llvm), cunit_idx_(cunit_idx) {
+  driver_ = NULL;
+  dex_compilation_unit_ = NULL;
+  llvm_info_.reset(new LLVMInfo());
+  context_.reset(llvm_info_->GetLLVMContext());
+  module_ = llvm_info_->GetLLVMModule();
+
+  // Include the runtime function declaration
+  makeLLVMModuleContents(module_);
+
+
+  intrinsic_helper_.reset(new IntrinsicHelper(*context_, *module_));
+
+  // Create IRBuilder
+  irb_.reset(new IRBuilder(*context_, *module_, *intrinsic_helper_));
+
+  // We always need a switch case, so just use a normal function.
+  switch(GetInstructionSet()) {
+  default:
+    runtime_support_.reset(new RuntimeSupportBuilder(*context_, *module_, *irb_));
+    break;
+  case kArm:
+    runtime_support_.reset(new RuntimeSupportBuilderARM(*context_, *module_, *irb_));
+    break;
+  case kThumb2:
+    runtime_support_.reset(new RuntimeSupportBuilderThumb2(*context_, *module_, *irb_));
+    break;
+  case kX86:
+    runtime_support_.reset(new RuntimeSupportBuilderX86(*context_, *module_, *irb_));
+    break;
+  }
+
+  irb_->SetRuntimeSupport(runtime_support_.get());
+}
+
+
+LlvmCompilationUnit::~LlvmCompilationUnit() {
+  ::llvm::LLVMContext* llvm_context = context_.release(); // Managed by llvm_info_
+  CHECK(llvm_context != NULL);
+}
+
+
+InstructionSet LlvmCompilationUnit::GetInstructionSet() const {
+  return compiler_llvm_->GetInstructionSet();
+}
+
+
+bool LlvmCompilationUnit::Materialize() {
+  std::string elf_image;
+
+  // Compile and prelink ::llvm::Module
+  if (!MaterializeToString(elf_image)) {
+    LOG(ERROR) << "Failed to materialize compilation unit " << cunit_idx_;
+    return false;
+  }
+
+#if 0
+  // Dump the ELF image for debugging
+  std::string filename(StringPrintf("%s/Art%zu.elf",
+                                    GetArtCacheOrDie(GetAndroidData()).c_str(),
+                                    cunit_idx_));
+  UniquePtr<File> output(OS::OpenFile(filename.c_str(), true));
+  output->WriteFully(elf_image.data(), elf_image.size());
+#endif
+
+  // Extract the .text section and prelink the code
+  if (!ExtractCodeAndPrelink(elf_image)) {
+    LOG(ERROR) << "Failed to extract code from compilation unit " << cunit_idx_;
+    return false;
+  }
+
+  return true;
+}
+
+
+bool LlvmCompilationUnit::MaterializeToString(std::string& str_buffer) {
+  ::llvm::raw_string_ostream str_os(str_buffer);
+  return MaterializeToRawOStream(str_os);
+}
+
+
+bool LlvmCompilationUnit::MaterializeToRawOStream(::llvm::raw_ostream& out_stream) {
+  // Lookup the LLVM target
+  std::string target_triple;
+  std::string target_cpu;
+  std::string target_attr;
+  CompilerDriver::InstructionSetToLLVMTarget(GetInstructionSet(), target_triple, target_cpu, target_attr);
+
+  std::string errmsg;
+  const ::llvm::Target* target =
+    ::llvm::TargetRegistry::lookupTarget(target_triple, errmsg);
+
+  CHECK(target != NULL) << errmsg;
+
+  // Target options
+  ::llvm::TargetOptions target_options;
+  target_options.FloatABIType = ::llvm::FloatABI::Soft;
+  target_options.NoFramePointerElim = true;
+  target_options.NoFramePointerElimNonLeaf = true;
+  target_options.UseSoftFloat = false;
+  target_options.EnableFastISel = false;
+
+  // Create the ::llvm::TargetMachine
+  ::llvm::OwningPtr< ::llvm::TargetMachine> target_machine(
+    target->createTargetMachine(target_triple, target_cpu, target_attr, target_options,
+                                ::llvm::Reloc::Static, ::llvm::CodeModel::Small,
+                                ::llvm::CodeGenOpt::Aggressive));
+
+  CHECK(target_machine.get() != NULL) << "Failed to create target machine";
+
+  // Add target data
+  const ::llvm::TargetData* target_data = target_machine->getTargetData();
+
+  // PassManager for code generation passes
+  ::llvm::PassManager pm;
+  pm.add(new ::llvm::TargetData(*target_data));
+
+  // FunctionPassManager for optimization pass
+  ::llvm::FunctionPassManager fpm(module_);
+  fpm.add(new ::llvm::TargetData(*target_data));
+
+  if (bitcode_filename_.empty()) {
+    // If we don't need write the bitcode to file, add the AddSuspendCheckToLoopLatchPass to the
+    // regular FunctionPass.
+    fpm.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
+                                  driver_, dex_compilation_unit_));
+  } else {
+    ::llvm::FunctionPassManager fpm2(module_);
+    fpm2.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
+                                   driver_, dex_compilation_unit_));
+    fpm2.doInitialization();
+    for (::llvm::Module::iterator F = module_->begin(), E = module_->end();
+         F != E; ++F) {
+      fpm2.run(*F);
+    }
+    fpm2.doFinalization();
+
+    // Write bitcode to file
+    std::string errmsg;
+
+    ::llvm::OwningPtr< ::llvm::tool_output_file> out_file(
+      new ::llvm::tool_output_file(bitcode_filename_.c_str(), errmsg,
+                                 ::llvm::raw_fd_ostream::F_Binary));
+
+
+    if (!errmsg.empty()) {
+      LOG(ERROR) << "Failed to create bitcode output file: " << errmsg;
+      return false;
+    }
+
+    ::llvm::WriteBitcodeToFile(module_, out_file->os());
+    out_file->keep();
+  }
+
+  // Add optimization pass
+  ::llvm::PassManagerBuilder pm_builder;
+  // TODO: Use inliner after we can do IPO.
+  pm_builder.Inliner = NULL;
+  //pm_builder.Inliner = ::llvm::createFunctionInliningPass();
+  //pm_builder.Inliner = ::llvm::createAlwaysInlinerPass();
+  //pm_builder.Inliner = ::llvm::createPartialInliningPass();
+  pm_builder.OptLevel = 3;
+  pm_builder.DisableSimplifyLibCalls = 1;
+  pm_builder.DisableUnitAtATime = 1;
+  pm_builder.populateFunctionPassManager(fpm);
+  pm_builder.populateModulePassManager(pm);
+  pm.add(::llvm::createStripDeadPrototypesPass());
+
+  // Add passes to emit ELF image
+  {
+    ::llvm::formatted_raw_ostream formatted_os(out_stream, false);
+
+    // Ask the target to add backend passes as necessary.
+    if (target_machine->addPassesToEmitFile(pm,
+                                            formatted_os,
+                                            ::llvm::TargetMachine::CGFT_ObjectFile,
+                                            true)) {
+      LOG(FATAL) << "Unable to generate ELF for this target";
+      return false;
+    }
+
+    // Run the per-function optimization
+    fpm.doInitialization();
+    for (::llvm::Module::iterator F = module_->begin(), E = module_->end();
+         F != E; ++F) {
+      fpm.run(*F);
+    }
+    fpm.doFinalization();
+
+    // Run the code generation passes
+    pm.run(*module_);
+  }
+
+  return true;
+}
+
+bool LlvmCompilationUnit::ExtractCodeAndPrelink(const std::string& elf_image) {
+  if (GetInstructionSet() == kX86) {
+    compiled_code_.push_back(0xccU);
+    compiled_code_.push_back(0xccU);
+    compiled_code_.push_back(0xccU);
+    compiled_code_.push_back(0xccU);
+    return true;
+  }
+
+  ::llvm::OwningPtr< ::llvm::MemoryBuffer> elf_image_buff(
+    ::llvm::MemoryBuffer::getMemBuffer(::llvm::StringRef(elf_image.data(),
+                                                     elf_image.size())));
+
+  ::llvm::OwningPtr< ::llvm::object::ObjectFile> elf_file(
+    ::llvm::object::ObjectFile::createELFObjectFile(elf_image_buff.take()));
+
+  ::llvm::error_code ec;
+
+  const ProcedureLinkageTable& plt = compiler_llvm_->GetProcedureLinkageTable();
+
+  for (::llvm::object::section_iterator
+       sec_iter = elf_file->begin_sections(),
+       sec_end = elf_file->end_sections();
+       sec_iter != sec_end; sec_iter.increment(ec)) {
+
+    CHECK(ec == 0) << "Failed to read section because " << ec.message();
+
+    // Read the section information
+    ::llvm::StringRef name;
+    uint64_t alignment = 0u;
+    uint64_t size = 0u;
+
+    CHECK(sec_iter->getName(name) == 0);
+    CHECK(sec_iter->getSize(size) == 0);
+    CHECK(sec_iter->getAlignment(alignment) == 0);
+
+    if (name == ".data" || name == ".bss" || name == ".rodata") {
+      if (size > 0) {
+        LOG(FATAL) << "Compilation unit " << cunit_idx_ << " has non-empty "
+                   << name.str() << " section";
+      }
+
+    } else if (name == "" || name == ".rel.text" ||
+               name == ".ARM.attributes" || name == ".symtab" ||
+               name == ".strtab" || name == ".shstrtab") {
+      // We can ignore these sections.  We don't have to copy them into
+      // the result Oat file.
+
+    } else if (name == ".text") {
+      // Ensure the alignment requirement is less than or equal to
+      // kArchAlignment
+      CheckCodeAlign(alignment);
+
+      // Copy the compiled code
+      ::llvm::StringRef contents;
+      CHECK(sec_iter->getContents(contents) == 0);
+
+      copy(contents.data(),
+           contents.data() + contents.size(),
+           back_inserter(compiled_code_));
+
+      // Prelink the compiled code
+      for (::llvm::object::relocation_iterator
+           rel_iter = sec_iter->begin_relocations(),
+           rel_end = sec_iter->end_relocations(); rel_iter != rel_end;
+           rel_iter.increment(ec)) {
+
+        CHECK(ec == 0) << "Failed to read relocation because " << ec.message();
+
+        // Read the relocation information
+        ::llvm::object::SymbolRef sym_ref;
+        uint64_t rel_offset = 0;
+        uint64_t rel_type = 0;
+        int64_t rel_addend = 0;
+
+        CHECK(rel_iter->getSymbol(sym_ref) == 0);
+        CHECK(rel_iter->getOffset(rel_offset) == 0);
+        CHECK(rel_iter->getType(rel_type) == 0);
+        CHECK(rel_iter->getAdditionalInfo(rel_addend) == 0);
+
+        // Read the symbol related to this relocation fixup
+        ::llvm::StringRef sym_name;
+        CHECK(sym_ref.getName(sym_name) == 0);
+
+        // Relocate the fixup.
+        // TODO: Support more relocation type.
+        CHECK(rel_type == ::llvm::ELF::R_ARM_ABS32);
+        CHECK_LE(rel_offset + 4, compiled_code_.size());
+
+        uintptr_t dest_addr = plt.GetEntryAddress(sym_name.str().c_str());
+        uintptr_t final_addr = dest_addr + rel_addend;
+        compiled_code_[rel_offset] = final_addr & 0xff;
+        compiled_code_[rel_offset + 1] = (final_addr >> 8) & 0xff;
+        compiled_code_[rel_offset + 2] = (final_addr >> 16) & 0xff;
+        compiled_code_[rel_offset + 3] = (final_addr >> 24) & 0xff;
+      }
+
+    } else {
+      LOG(WARNING) << "Unexpected section: " << name.str();
+    }
+  }
+
+  return true;
+}
+
+
+// Check whether the align is less than or equal to the code alignment of
+// that architecture.  Since the Oat writer only guarantee that the compiled
+// method being aligned to kArchAlignment, we have no way to align the ELf
+// section if the section alignment is greater than kArchAlignment.
+void LlvmCompilationUnit::CheckCodeAlign(uint32_t align) const {
+  InstructionSet insn_set = GetInstructionSet();
+  switch (insn_set) {
+  case kThumb2:
+  case kArm:
+    CHECK_LE(align, static_cast<uint32_t>(kArmAlignment));
+    break;
+
+  case kX86:
+    CHECK_LE(align, static_cast<uint32_t>(kX86Alignment));
+    break;
+
+  case kMips:
+    CHECK_LE(align, static_cast<uint32_t>(kMipsAlignment));
+    break;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set;
+  }
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/llvm_compilation_unit.h b/src/compiler/llvm/llvm_compilation_unit.h
new file mode 100644
index 0000000..9ca9e3f
--- /dev/null
+++ b/src/compiler/llvm/llvm_compilation_unit.h
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_
+#define ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_
+
+#include "base/logging.h"
+#include "base/mutex.h"
+#include "compiler/dex/compiler_internals.h"
+#include "compiler/driver/compiler_driver.h"
+#include "globals.h"
+#include "instruction_set.h"
+#include "compiler/driver/dex_compilation_unit.h"
+#include "runtime_support_builder.h"
+#include "runtime_support_func.h"
+#include "safe_map.h"
+
+#include <UniquePtr.h>
+#include <string>
+#include <vector>
+
+namespace art {
+  class CompiledMethod;
+}
+
+namespace llvm {
+  class Function;
+  class LLVMContext;
+  class Module;
+  class raw_ostream;
+}
+
+namespace art {
+namespace llvm {
+
+class CompilerLLVM;
+class IRBuilder;
+
+class LlvmCompilationUnit {
+ public:
+  ~LlvmCompilationUnit();
+
+  size_t GetIndex() const {
+    return cunit_idx_;
+  }
+
+  InstructionSet GetInstructionSet() const;
+
+  ::llvm::LLVMContext* GetLLVMContext() const {
+    return context_.get();
+  }
+
+  ::llvm::Module* GetModule() const {
+    return module_;
+  }
+
+  IRBuilder* GetIRBuilder() const {
+    return irb_.get();
+  }
+
+  void SetBitcodeFileName(const std::string& bitcode_filename) {
+    bitcode_filename_ = bitcode_filename;
+  }
+
+  LLVMInfo* GetQuickContext() const {
+    return llvm_info_.get();
+  }
+  void SetCompiler(CompilerDriver* driver) {
+    driver_ = driver;
+  }
+  void SetDexCompilationUnit(DexCompilationUnit* dex_compilation_unit) {
+    dex_compilation_unit_ = dex_compilation_unit;
+  }
+
+  bool Materialize();
+
+  bool IsMaterialized() const {
+    return !compiled_code_.empty();
+  }
+
+  const std::vector<uint8_t>& GetCompiledCode() const {
+    DCHECK(IsMaterialized());
+    return compiled_code_;
+  }
+
+ private:
+  LlvmCompilationUnit(const CompilerLLVM* compiler_llvm,
+                      size_t cunit_idx);
+
+  const CompilerLLVM* compiler_llvm_;
+  const size_t cunit_idx_;
+
+  UniquePtr< ::llvm::LLVMContext> context_;
+  UniquePtr<IRBuilder> irb_;
+  UniquePtr<RuntimeSupportBuilder> runtime_support_;
+  ::llvm::Module* module_; // Managed by context_
+  UniquePtr<IntrinsicHelper> intrinsic_helper_;
+  UniquePtr<LLVMInfo> llvm_info_;
+  CompilerDriver* driver_;
+  DexCompilationUnit* dex_compilation_unit_;
+
+  std::string bitcode_filename_;
+
+  std::vector<uint8_t> compiled_code_;
+
+  SafeMap<const ::llvm::Function*, CompiledMethod*> compiled_methods_map_;
+
+  void CheckCodeAlign(uint32_t offset) const;
+
+  bool MaterializeToString(std::string& str_buffer);
+  bool MaterializeToRawOStream(::llvm::raw_ostream& out_stream);
+
+  bool ExtractCodeAndPrelink(const std::string& elf_image);
+
+  friend class CompilerLLVM;  // For LlvmCompilationUnit constructor
+};
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_LLVM_COMPILATION_UNIT_H_
diff --git a/src/compiler/llvm/md_builder.cc b/src/compiler/llvm/md_builder.cc
new file mode 100644
index 0000000..afb3611
--- /dev/null
+++ b/src/compiler/llvm/md_builder.cc
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#include "md_builder.h"
+
+#include "llvm/Support/MDBuilder.h"
+
+#include <string>
+
+namespace art {
+namespace llvm {
+
+
+::llvm::MDNode* MDBuilder::GetTBAASpecialType(TBAASpecialType sty_id) {
+  DCHECK_GE(sty_id, 0) << "Unknown TBAA special type: " << sty_id;
+  DCHECK_LT(sty_id, MAX_TBAA_SPECIAL_TYPE) << "Unknown TBAA special type: " << sty_id;
+  DCHECK(tbaa_root_ != NULL);
+
+  ::llvm::MDNode*& spec_ty = tbaa_special_type_[sty_id];
+  if (spec_ty == NULL) {
+    switch (sty_id) {
+    case kTBAARegister:     spec_ty = createTBAANode("Register", tbaa_root_); break;
+    case kTBAAStackTemp:    spec_ty = createTBAANode("StackTemp", tbaa_root_); break;
+    case kTBAAHeapArray:    spec_ty = createTBAANode("HeapArray", tbaa_root_); break;
+    case kTBAAHeapInstance: spec_ty = createTBAANode("HeapInstance", tbaa_root_); break;
+    case kTBAAHeapStatic:   spec_ty = createTBAANode("HeapStatic", tbaa_root_); break;
+    case kTBAAJRuntime:     spec_ty = createTBAANode("JRuntime", tbaa_root_); break;
+    case kTBAARuntimeInfo:  spec_ty = createTBAANode("RuntimeInfo",
+                                                     GetTBAASpecialType(kTBAAJRuntime)); break;
+    case kTBAAShadowFrame:  spec_ty = createTBAANode("ShadowFrame",
+                                                     GetTBAASpecialType(kTBAAJRuntime)); break;
+    case kTBAAConstJObject: spec_ty = createTBAANode("ConstJObject", tbaa_root_, true); break;
+    default:
+      LOG(FATAL) << "Unknown TBAA special type: " << sty_id;
+      break;
+    }
+  }
+  return spec_ty;
+}
+
+::llvm::MDNode* MDBuilder::GetTBAAMemoryJType(TBAASpecialType sty_id, JType jty_id) {
+  DCHECK(sty_id == kTBAAHeapArray ||
+         sty_id == kTBAAHeapInstance ||
+         sty_id == kTBAAHeapStatic) << "SpecialType must be array, instance, or static";
+
+  DCHECK_GE(jty_id, 0) << "Unknown JType: " << jty_id;
+  DCHECK_LT(jty_id, MAX_JTYPE) << "Unknown JType: " << jty_id;
+  DCHECK_NE(jty_id, kVoid) << "Can't load/store Void type!";
+
+  std::string name;
+  size_t sty_mapped_index = 0;
+  switch (sty_id) {
+  case kTBAAHeapArray:    sty_mapped_index = 0; name = "HeapArray "; break;
+  case kTBAAHeapInstance: sty_mapped_index = 1; name = "HeapInstance "; break;
+  case kTBAAHeapStatic:   sty_mapped_index = 2; name = "HeapStatic "; break;
+  default:
+    LOG(FATAL) << "Unknown TBAA special type: " << sty_id;
+    break;
+  }
+
+  ::llvm::MDNode*& spec_ty = tbaa_memory_jtype_[sty_mapped_index][jty_id];
+  if (spec_ty != NULL) {
+    return spec_ty;
+  }
+
+  switch (jty_id) {
+  case kBoolean: name += "Boolean"; break;
+  case kByte:    name += "Byte"; break;
+  case kChar:    name += "Char"; break;
+  case kShort:   name += "Short"; break;
+  case kInt:     name += "Int"; break;
+  case kLong:    name += "Long"; break;
+  case kFloat:   name += "Float"; break;
+  case kDouble:  name += "Double"; break;
+  case kObject:  name += "Object"; break;
+  default:
+    LOG(FATAL) << "Unknown JType: " << jty_id;
+    break;
+  }
+
+  spec_ty = createTBAANode(name, GetTBAASpecialType(sty_id));
+  return spec_ty;
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/md_builder.h b/src/compiler/llvm/md_builder.h
new file mode 100644
index 0000000..5231c14
--- /dev/null
+++ b/src/compiler/llvm/md_builder.h
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_MD_BUILDER_H_
+#define ART_SRC_COMPILER_LLVM_MD_BUILDER_H_
+
+#include "backend_types.h"
+
+#include "llvm/Support/MDBuilder.h"
+
+#include <cstring>
+
+namespace llvm {
+  class LLVMContext;
+  class MDNode;
+}
+
+namespace art {
+namespace llvm {
+
+typedef ::llvm::MDBuilder LLVMMDBuilder;
+
+class MDBuilder : public LLVMMDBuilder {
+ public:
+  MDBuilder(::llvm::LLVMContext& context)
+     : LLVMMDBuilder(context), tbaa_root_(createTBAARoot("Art TBAA Root")) {
+    std::memset(tbaa_special_type_, 0, sizeof(tbaa_special_type_));
+    std::memset(tbaa_memory_jtype_, 0, sizeof(tbaa_memory_jtype_));
+
+    // Pre-generate the MDNode for static branch prediction
+    // 64 and 4 are the llvm.expect's default values
+    expect_cond_[kLikely] = createBranchWeights(64, 4);
+    expect_cond_[kUnlikely] = createBranchWeights(4, 64);
+  }
+
+  ::llvm::MDNode* GetTBAASpecialType(TBAASpecialType special_ty);
+  ::llvm::MDNode* GetTBAAMemoryJType(TBAASpecialType special_ty, JType j_ty);
+
+  ::llvm::MDNode* GetBranchWeights(ExpectCond expect) {
+    DCHECK_LT(expect, MAX_EXPECT) << "MAX_EXPECT is not for branch weight";
+    return expect_cond_[expect];
+  }
+
+ private:
+  ::llvm::MDNode* const tbaa_root_;
+  ::llvm::MDNode* tbaa_special_type_[MAX_TBAA_SPECIAL_TYPE];
+  // There are 3 categories of memory types will not alias: array element, instance field, and
+  // static field.
+  ::llvm::MDNode* tbaa_memory_jtype_[3][MAX_JTYPE];
+
+  ::llvm::MDNode* expect_cond_[MAX_EXPECT];
+};
+
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_MD_BUILDER_H_
diff --git a/src/compiler/llvm/procedure_linkage_table.cc b/src/compiler/llvm/procedure_linkage_table.cc
new file mode 100644
index 0000000..47ba9bd
--- /dev/null
+++ b/src/compiler/llvm/procedure_linkage_table.cc
@@ -0,0 +1,326 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "procedure_linkage_table.h"
+
+#include "base/logging.h"
+#include "compiler_runtime_func_list.h"
+#include "globals.h"
+#include "instruction_set.h"
+#include "runtime_support_func_list.h"
+#include "runtime_support_llvm.h"
+#include "utils_llvm.h"
+
+#include <algorithm>
+
+#include <UniquePtr.h>
+
+#include <stddef.h>
+#include <stdint.h>
+#include <sys/mman.h>
+#include <unistd.h>
+
+
+namespace {
+  const char* const art_runtime_func_name_list[] = {
+#define DEFINE_ENTRY(ID, NAME) #NAME,
+    RUNTIME_SUPPORT_FUNC_LIST(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  const char* const compiler_runtime_func_name_list_arm[] = {
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
+    COMPILER_RUNTIME_FUNC_LIST_ARM(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  const char* const compiler_runtime_func_name_list_mips[] = {
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
+    COMPILER_RUNTIME_FUNC_LIST_MIPS(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  const char* const compiler_runtime_func_name_list_x86[] = {
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME,
+    COMPILER_RUNTIME_FUNC_LIST_X86(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  const size_t art_runtime_func_count =
+    sizeof(art_runtime_func_name_list) / sizeof(const char*);
+
+  const size_t compiler_runtime_func_count_arm =
+    sizeof(compiler_runtime_func_name_list_arm) / sizeof(const char*);
+
+  const size_t compiler_runtime_func_count_mips =
+    sizeof(compiler_runtime_func_name_list_mips) / sizeof(const char*);
+
+  const size_t compiler_runtime_func_count_x86 =
+    sizeof(compiler_runtime_func_name_list_x86) / sizeof(const char*);
+}
+
+
+namespace art {
+namespace llvm {
+
+
+ProcedureLinkageTable::ProcedureLinkageTable(InstructionSet insn_set)
+    : insn_set_(insn_set) {
+}
+
+
+ProcedureLinkageTable::~ProcedureLinkageTable() {
+}
+
+
+bool ProcedureLinkageTable::AllocateTable() {
+  if (table_mmap_.get()) {
+    return true;
+  }
+
+  // Allocate the PLT
+  byte* suggested_table_addr = reinterpret_cast<byte*>(kTableAddress);
+
+  UniquePtr<MemMap> table_mmap(
+      MemMap::MapAnonymous(".plt", suggested_table_addr,
+                           GetTableSizeInBytes(), PROT_READ | PROT_WRITE));
+
+  if (!table_mmap.get()) {
+    return false;
+  }
+
+  if (table_mmap->Begin() != suggested_table_addr) {
+    // Our PLT should be allocated at the FIXED address
+    return false;
+  }
+
+  // Create the stubs in the PLT
+  byte* stub_ptr = table_mmap->Begin();
+  size_t stub_size = GetStubSizeInBytes();
+
+  for (size_t i = 0; i < art_runtime_func_count; ++i, stub_ptr += stub_size) {
+    const char* name = art_runtime_func_name_list[i];
+    void* func = art_portable_find_runtime_support_func(NULL, name);
+    DCHECK(func != NULL);
+    CreateStub(stub_ptr, func);
+  }
+
+  const char* const* crt_name_list = NULL;
+  size_t crt_count = 0u;
+
+  switch (insn_set_) {
+  case kArm:
+  case kThumb2:
+    crt_name_list = compiler_runtime_func_name_list_arm;
+    crt_count = compiler_runtime_func_count_arm;
+    break;
+
+  case kMips:
+    crt_name_list = compiler_runtime_func_name_list_mips;
+    crt_count = compiler_runtime_func_count_mips;
+    break;
+
+  case kX86:
+    crt_name_list = compiler_runtime_func_name_list_x86;
+    crt_count = compiler_runtime_func_count_x86;
+    break;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set_;
+    return false;
+  }
+
+  for (size_t i = 0; i < crt_count; ++i, stub_ptr += stub_size) {
+    void* func = art_portable_find_runtime_support_func(NULL, crt_name_list[i]);
+    DCHECK(func != NULL);
+    CreateStub(stub_ptr, func);
+  }
+
+  // Protect the procedure linkage table
+  table_mmap->Protect(PROT_READ | PROT_EXEC);
+
+  // Flush the instruction cache on specific architecture
+#if defined(__arm__) || defined(__mips__)
+  cacheflush(reinterpret_cast<long int>(table_mmap->Begin()),
+             reinterpret_cast<long int>(table_mmap->End()), 0);
+#endif
+
+  // Transfer the ownership
+  table_mmap_.reset(table_mmap.release());
+
+  return true;
+}
+
+
+uintptr_t ProcedureLinkageTable::GetEntryAddress(const char* name) const {
+  int func_idx = IndexOfRuntimeFunc(name);
+  if (func_idx == -1) {
+    return 0u;
+  }
+
+  return (kTableAddress + func_idx * GetStubSizeInBytes());
+}
+
+
+
+int ProcedureLinkageTable::IndexOfRuntimeFunc(const char* name) const {
+  int result = IndexOfCompilerRuntimeFunc(name);
+  if (result != -1) {
+    return art_runtime_func_count + result;
+  }
+
+  return IndexOfArtRuntimeFunc(name);
+}
+
+
+int ProcedureLinkageTable::IndexOfArtRuntimeFunc(const char* name) {
+  for (size_t i = 0; i < art_runtime_func_count; ++i) {
+    if (strcmp(name, art_runtime_func_name_list[i]) == 0) {
+      return static_cast<int>(i);
+    }
+  }
+  return -1;
+}
+
+int ProcedureLinkageTable::IndexOfCompilerRuntimeFunc(InstructionSet insn_set,
+                                                      const char* name) {
+  const char* const* rt_begin = NULL;
+  const char* const* rt_end = NULL;
+
+  switch (insn_set) {
+  case kArm:
+  case kThumb2:
+    rt_begin = compiler_runtime_func_name_list_arm;
+    rt_end = compiler_runtime_func_name_list_arm +
+             compiler_runtime_func_count_arm;
+    break;
+
+  case kMips:
+    rt_begin = compiler_runtime_func_name_list_mips;
+    rt_end = compiler_runtime_func_name_list_mips +
+             compiler_runtime_func_count_mips;
+    break;
+
+  case kX86:
+    rt_begin = compiler_runtime_func_name_list_x86;
+    rt_end = compiler_runtime_func_name_list_x86 +
+             compiler_runtime_func_count_x86;
+    break;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set;
+    return -1;
+  }
+
+  const char* const* name_lbound_ptr =
+      std::lower_bound(rt_begin, rt_end, name, CStringLessThanComparator());
+
+  if (name_lbound_ptr < rt_end && strcmp(*name_lbound_ptr, name) == 0) {
+    return (name_lbound_ptr - rt_begin);
+  } else {
+    return -1;
+  }
+}
+
+
+size_t ProcedureLinkageTable::GetStubCount(InstructionSet insn_set) {
+  switch (insn_set) {
+  case kArm:
+  case kThumb2:
+    return art_runtime_func_count + compiler_runtime_func_count_arm;
+
+  case kMips:
+    return art_runtime_func_count + compiler_runtime_func_count_mips;
+
+  case kX86:
+    return art_runtime_func_count + compiler_runtime_func_count_x86;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set;
+    return 0u;
+  }
+}
+
+
+size_t ProcedureLinkageTable::GetStubSizeInBytes(InstructionSet insn_set) {
+  switch (insn_set) {
+  case kArm:
+  case kThumb2:
+    return 8u;
+
+  case kMips:
+    return 16u;
+
+  case kX86:
+    return 8u;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set;
+    return 0u;
+  }
+}
+
+
+void ProcedureLinkageTable::CreateStub(InstructionSet insn_set,
+                                       byte* stub, void* dest_) {
+  switch (insn_set) {
+  case kArm:
+  case kThumb2:
+    {
+      uint32_t dest = static_cast<uint32_t>(
+                      reinterpret_cast<uintptr_t>(dest_) & 0xfffffffful);
+      uint32_t* stub_w = reinterpret_cast<uint32_t*>(stub);
+
+      stub_w[0] = 0xe51ff004ul; // ldr pc, [pc #-4]
+      stub_w[1] = dest;
+    }
+    break;
+
+  case kMips:
+    {
+      uint32_t dest = static_cast<uint32_t>(
+                      reinterpret_cast<uintptr_t>(dest_) & 0xfffffffful);
+      uint32_t* stub_w = reinterpret_cast<uint32_t*>(stub);
+
+      stub_w[0] = 0x3c190000ul | ((dest >> 16) & 0xfffful); // lui
+      stub_w[1] = 0x37390000ul | (dest & 0xfffful);; // ori
+      stub_w[2] = 0x03200008ul; // jr (jump register)
+      stub_w[3] = 0x00000000ul; // nop
+    }
+    break;
+
+  case kX86:
+    {
+      uint32_t off = static_cast<uint32_t>(
+                     reinterpret_cast<uintptr_t>(dest_) -
+                     reinterpret_cast<uintptr_t>(stub + 1) - 4);
+      // jmp (32-bit offset)
+      stub[0] = 0xe9u;
+      stub[1] = off & 0xffu;
+      stub[2] = (off >> 8) & 0xffu;
+      stub[2] = (off >> 16) & 0xffu;
+      stub[2] = (off >> 24) & 0xffu;
+    }
+    break;
+
+  default:
+    LOG(FATAL) << "Unknown instruction set: " << insn_set;
+  }
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/procedure_linkage_table.h b/src/compiler/llvm/procedure_linkage_table.h
new file mode 100644
index 0000000..1c89d29
--- /dev/null
+++ b/src/compiler/llvm/procedure_linkage_table.h
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_
+#define ART_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_
+
+#include "globals.h"
+#include "instruction_set.h"
+#include "mem_map.h"
+
+#include <UniquePtr.h>
+
+#include <stddef.h>
+#include <stdint.h>
+
+namespace art {
+namespace llvm {
+
+
+class ProcedureLinkageTable {
+ public:
+  ProcedureLinkageTable(InstructionSet insn_set);
+
+  ~ProcedureLinkageTable();
+
+  bool AllocateTable();
+
+  uintptr_t GetEntryAddress(const char* func_name) const;
+
+ private:
+  static size_t GetStubCount(InstructionSet insn_set);
+  static size_t GetStubSizeInBytes(InstructionSet insn_set);
+  static void CreateStub(InstructionSet insn_set,
+                         byte* stub, void* branch_dest);
+
+  int IndexOfRuntimeFunc(const char* name) const;
+  static int IndexOfArtRuntimeFunc(const char* name);
+  static int IndexOfCompilerRuntimeFunc(InstructionSet insn_set,
+                                        const char* name);
+
+  size_t GetStubCount() const {
+    return GetStubCount(insn_set_);
+  }
+
+  size_t GetStubSizeInBytes() const {
+    return GetStubSizeInBytes(insn_set_);
+  }
+
+  size_t GetTableSizeInBytes() const {
+    return GetStubSizeInBytes() * GetStubCount();
+  }
+
+  void CreateStub(byte* stub, void* branch_dest) {
+    return CreateStub(insn_set_, stub, branch_dest);
+  }
+
+  int IndexOfCompilerRuntimeFunc(const char* name) const {
+    return IndexOfCompilerRuntimeFunc(insn_set_, name);
+  }
+
+  InstructionSet insn_set_;
+  UniquePtr<MemMap> table_mmap_;
+
+  static const size_t kTableSizeInBytes = 1024u;
+  static const uintptr_t kTableAddress = 0x5fffc000u;
+};
+
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_PROCEDURE_LINKAGE_TABLE_H_
diff --git a/src/compiler/llvm/runtime_support_builder.cc b/src/compiler/llvm/runtime_support_builder.cc
new file mode 100644
index 0000000..4548d18
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder.cc
@@ -0,0 +1,279 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime_support_builder.h"
+
+#include "gc/card_table.h"
+#include "ir_builder.h"
+#include "monitor.h"
+#include "mirror/object.h"
+#include "thread.h"
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+using namespace llvm;
+
+namespace art {
+namespace llvm {
+
+using namespace runtime_support;
+
+
+RuntimeSupportBuilder::RuntimeSupportBuilder(::llvm::LLVMContext& context,
+                                             ::llvm::Module& module,
+                                             IRBuilder& irb)
+    : context_(context), module_(module), irb_(irb)
+{
+  memset(target_runtime_support_func_, 0, sizeof(target_runtime_support_func_));
+#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_[runtime_support::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
+}
+
+
+/* Thread */
+
+::llvm::Value* RuntimeSupportBuilder::EmitGetCurrentThread() {
+  Function* func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
+  CallInst* call_inst = irb_.CreateCall(func);
+  call_inst->setOnlyReadsMemory();
+  irb_.SetTBAA(call_inst, kTBAAConstJObject);
+  return call_inst;
+}
+
+::llvm::Value* RuntimeSupportBuilder::EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                             TBAASpecialType s_ty) {
+  Value* thread = EmitGetCurrentThread();
+  return irb_.LoadFromObjectOffset(thread, offset, type, s_ty);
+}
+
+void RuntimeSupportBuilder::EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                                    TBAASpecialType s_ty) {
+  Value* thread = EmitGetCurrentThread();
+  irb_.StoreToObjectOffset(thread, offset, value, s_ty);
+}
+
+::llvm::Value* RuntimeSupportBuilder::EmitSetCurrentThread(::llvm::Value* thread) {
+  Function* func = GetRuntimeSupportFunction(runtime_support::SetCurrentThread);
+  return irb_.CreateCall(func, thread);
+}
+
+
+/* ShadowFrame */
+
+::llvm::Value* RuntimeSupportBuilder::EmitPushShadowFrame(::llvm::Value* new_shadow_frame,
+                                                        ::llvm::Value* method,
+                                                        uint32_t num_vregs) {
+  Value* old_shadow_frame = EmitLoadFromThreadOffset(Thread::TopShadowFrameOffset().Int32Value(),
+                                                     irb_.getArtFrameTy()->getPointerTo(),
+                                                     kTBAARuntimeInfo);
+  EmitStoreToThreadOffset(Thread::TopShadowFrameOffset().Int32Value(),
+                          new_shadow_frame,
+                          kTBAARuntimeInfo);
+
+  // Store the method pointer
+  irb_.StoreToObjectOffset(new_shadow_frame,
+                           ShadowFrame::MethodOffset(),
+                           method,
+                           kTBAAShadowFrame);
+
+  // Store the number of vregs
+  irb_.StoreToObjectOffset(new_shadow_frame,
+                           ShadowFrame::NumberOfVRegsOffset(),
+                           irb_.getInt32(num_vregs),
+                           kTBAAShadowFrame);
+
+  // Store the link to previous shadow frame
+  irb_.StoreToObjectOffset(new_shadow_frame,
+                           ShadowFrame::LinkOffset(),
+                           old_shadow_frame,
+                           kTBAAShadowFrame);
+
+  return old_shadow_frame;
+}
+
+::llvm::Value*
+RuntimeSupportBuilder::EmitPushShadowFrameNoInline(::llvm::Value* new_shadow_frame,
+                                                   ::llvm::Value* method,
+                                                   uint32_t num_vregs) {
+  Function* func = GetRuntimeSupportFunction(runtime_support::PushShadowFrame);
+  ::llvm::CallInst* call_inst =
+      irb_.CreateCall4(func,
+                       EmitGetCurrentThread(),
+                       new_shadow_frame,
+                       method,
+                       irb_.getInt32(num_vregs));
+  irb_.SetTBAA(call_inst, kTBAARuntimeInfo);
+  return call_inst;
+}
+
+void RuntimeSupportBuilder::EmitPopShadowFrame(::llvm::Value* old_shadow_frame) {
+  // Store old shadow frame to TopShadowFrame
+  EmitStoreToThreadOffset(Thread::TopShadowFrameOffset().Int32Value(),
+                          old_shadow_frame,
+                          kTBAARuntimeInfo);
+}
+
+
+/* Exception */
+
+::llvm::Value* RuntimeSupportBuilder::EmitGetAndClearException() {
+  Function* slow_func = GetRuntimeSupportFunction(runtime_support::GetAndClearException);
+  return irb_.CreateCall(slow_func, EmitGetCurrentThread());
+}
+
+::llvm::Value* RuntimeSupportBuilder::EmitIsExceptionPending() {
+  Value* exception = EmitLoadFromThreadOffset(Thread::ExceptionOffset().Int32Value(),
+                                              irb_.getJObjectTy(),
+                                              kTBAARuntimeInfo);
+  // If exception not null
+  return irb_.CreateIsNotNull(exception);
+}
+
+
+/* Suspend */
+
+void RuntimeSupportBuilder::EmitTestSuspend() {
+  Function* slow_func = GetRuntimeSupportFunction(runtime_support::TestSuspend);
+  CallInst* call_inst = irb_.CreateCall(slow_func, EmitGetCurrentThread());
+  irb_.SetTBAA(call_inst, kTBAAJRuntime);
+}
+
+
+/* Monitor */
+
+void RuntimeSupportBuilder::EmitLockObject(::llvm::Value* object) {
+  Value* monitor =
+      irb_.LoadFromObjectOffset(object,
+                                mirror::Object::MonitorOffset().Int32Value(),
+                                irb_.getJIntTy(),
+                                kTBAARuntimeInfo);
+
+  Value* real_monitor =
+      irb_.CreateAnd(monitor, ~(LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT));
+
+  // Is thin lock, unheld and not recursively acquired.
+  Value* unheld = irb_.CreateICmpEQ(real_monitor, irb_.getInt32(0));
+
+  Function* parent_func = irb_.GetInsertBlock()->getParent();
+  BasicBlock* bb_fast = BasicBlock::Create(context_, "lock_fast", parent_func);
+  BasicBlock* bb_slow = BasicBlock::Create(context_, "lock_slow", parent_func);
+  BasicBlock* bb_cont = BasicBlock::Create(context_, "lock_cont", parent_func);
+  irb_.CreateCondBr(unheld, bb_fast, bb_slow, kLikely);
+
+  irb_.SetInsertPoint(bb_fast);
+
+  // Calculate new monitor: new = old | (lock_id << LW_LOCK_OWNER_SHIFT)
+  Value* lock_id =
+      EmitLoadFromThreadOffset(Thread::ThinLockIdOffset().Int32Value(),
+                               irb_.getInt32Ty(), kTBAARuntimeInfo);
+
+  Value* owner = irb_.CreateShl(lock_id, LW_LOCK_OWNER_SHIFT);
+  Value* new_monitor = irb_.CreateOr(monitor, owner);
+
+  // Atomically update monitor.
+  Value* old_monitor =
+      irb_.CompareExchangeObjectOffset(object,
+                                       mirror::Object::MonitorOffset().Int32Value(),
+                                       monitor, new_monitor, kTBAARuntimeInfo);
+
+  Value* retry_slow_path = irb_.CreateICmpEQ(old_monitor, monitor);
+  irb_.CreateCondBr(retry_slow_path, bb_cont, bb_slow, kLikely);
+
+  irb_.SetInsertPoint(bb_slow);
+  Function* slow_func = GetRuntimeSupportFunction(runtime_support::LockObject);
+  irb_.CreateCall2(slow_func, object, EmitGetCurrentThread());
+  irb_.CreateBr(bb_cont);
+
+  irb_.SetInsertPoint(bb_cont);
+}
+
+void RuntimeSupportBuilder::EmitUnlockObject(::llvm::Value* object) {
+  Value* lock_id =
+      EmitLoadFromThreadOffset(Thread::ThinLockIdOffset().Int32Value(),
+                               irb_.getJIntTy(),
+                               kTBAARuntimeInfo);
+  Value* monitor =
+      irb_.LoadFromObjectOffset(object,
+                                mirror::Object::MonitorOffset().Int32Value(),
+                                irb_.getJIntTy(),
+                                kTBAARuntimeInfo);
+
+  Value* my_monitor = irb_.CreateShl(lock_id, LW_LOCK_OWNER_SHIFT);
+  Value* hash_state = irb_.CreateAnd(monitor, (LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT));
+  Value* real_monitor = irb_.CreateAnd(monitor, ~(LW_HASH_STATE_MASK << LW_HASH_STATE_SHIFT));
+
+  // Is thin lock, held by us and not recursively acquired
+  Value* is_fast_path = irb_.CreateICmpEQ(real_monitor, my_monitor);
+
+  Function* parent_func = irb_.GetInsertBlock()->getParent();
+  BasicBlock* bb_fast = BasicBlock::Create(context_, "unlock_fast", parent_func);
+  BasicBlock* bb_slow = BasicBlock::Create(context_, "unlock_slow", parent_func);
+  BasicBlock* bb_cont = BasicBlock::Create(context_, "unlock_cont", parent_func);
+  irb_.CreateCondBr(is_fast_path, bb_fast, bb_slow, kLikely);
+
+  irb_.SetInsertPoint(bb_fast);
+  // Set all bits to zero (except hash state)
+  irb_.StoreToObjectOffset(object,
+                           mirror::Object::MonitorOffset().Int32Value(),
+                           hash_state,
+                           kTBAARuntimeInfo);
+  irb_.CreateBr(bb_cont);
+
+  irb_.SetInsertPoint(bb_slow);
+  Function* slow_func = GetRuntimeSupportFunction(runtime_support::UnlockObject);
+  irb_.CreateCall2(slow_func, object, EmitGetCurrentThread());
+  irb_.CreateBr(bb_cont);
+
+  irb_.SetInsertPoint(bb_cont);
+}
+
+
+void RuntimeSupportBuilder::EmitMarkGCCard(::llvm::Value* value, ::llvm::Value* target_addr) {
+  Function* parent_func = irb_.GetInsertBlock()->getParent();
+  BasicBlock* bb_mark_gc_card = BasicBlock::Create(context_, "mark_gc_card", parent_func);
+  BasicBlock* bb_cont = BasicBlock::Create(context_, "mark_gc_card_cont", parent_func);
+
+  ::llvm::Value* not_null = irb_.CreateIsNotNull(value);
+  irb_.CreateCondBr(not_null, bb_mark_gc_card, bb_cont);
+
+  irb_.SetInsertPoint(bb_mark_gc_card);
+  Value* card_table = EmitLoadFromThreadOffset(Thread::CardTableOffset().Int32Value(),
+                                               irb_.getInt8Ty()->getPointerTo(),
+                                               kTBAAConstJObject);
+  Value* target_addr_int = irb_.CreatePtrToInt(target_addr, irb_.getPtrEquivIntTy());
+  Value* card_no = irb_.CreateLShr(target_addr_int, irb_.getPtrEquivInt(CardTable::kCardShift));
+  Value* card_table_entry = irb_.CreateGEP(card_table, card_no);
+  irb_.CreateStore(irb_.getInt8(CardTable::kCardDirty), card_table_entry, kTBAARuntimeInfo);
+  irb_.CreateBr(bb_cont);
+
+  irb_.SetInsertPoint(bb_cont);
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/runtime_support_builder.h b/src/compiler/llvm/runtime_support_builder.h
new file mode 100644
index 0000000..04d72b8
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder.h
@@ -0,0 +1,98 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_
+
+#include "backend_types.h"
+#include "base/logging.h"
+#include "runtime_support_func.h"
+
+#include <stdint.h>
+
+namespace llvm {
+  class LLVMContext;
+  class Module;
+  class Function;
+  class Type;
+  class Value;
+}
+
+namespace art {
+namespace llvm {
+
+class IRBuilder;
+
+
+class RuntimeSupportBuilder {
+ public:
+  RuntimeSupportBuilder(::llvm::LLVMContext& context, ::llvm::Module& module, IRBuilder& irb);
+
+  /* Thread */
+  virtual ::llvm::Value* EmitGetCurrentThread();
+  virtual ::llvm::Value* EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                TBAASpecialType s_ty);
+  virtual void EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                       TBAASpecialType s_ty);
+  virtual ::llvm::Value* EmitSetCurrentThread(::llvm::Value* thread);
+
+  /* ShadowFrame */
+  virtual ::llvm::Value* EmitPushShadowFrame(::llvm::Value* new_shadow_frame,
+                                           ::llvm::Value* method, uint32_t num_vregs);
+  virtual ::llvm::Value* EmitPushShadowFrameNoInline(::llvm::Value* new_shadow_frame,
+                                                   ::llvm::Value* method, uint32_t num_vregs);
+  virtual void EmitPopShadowFrame(::llvm::Value* old_shadow_frame);
+
+  /* Exception */
+  virtual ::llvm::Value* EmitGetAndClearException();
+  virtual ::llvm::Value* EmitIsExceptionPending();
+
+  /* Suspend */
+  virtual void EmitTestSuspend();
+
+  /* Monitor */
+  virtual void EmitLockObject(::llvm::Value* object);
+  virtual void EmitUnlockObject(::llvm::Value* object);
+
+  /* MarkGCCard */
+  virtual void EmitMarkGCCard(::llvm::Value* value, ::llvm::Value* target_addr);
+
+  ::llvm::Function* GetRuntimeSupportFunction(runtime_support::RuntimeId id) {
+    if (id >= 0 && id < runtime_support::MAX_ID) {
+      return runtime_support_func_decls_[id];
+    } else {
+      LOG(ERROR) << "Unknown runtime function id: " << id;
+      return NULL;
+    }
+  }
+
+  virtual ~RuntimeSupportBuilder() {}
+
+ protected:
+  ::llvm::LLVMContext& context_;
+  ::llvm::Module& module_;
+  IRBuilder& irb_;
+
+ private:
+  ::llvm::Function* runtime_support_func_decls_[runtime_support::MAX_ID];
+  bool target_runtime_support_func_[runtime_support::MAX_ID];
+};
+
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_
diff --git a/src/compiler/llvm/runtime_support_builder_arm.cc b/src/compiler/llvm/runtime_support_builder_arm.cc
new file mode 100644
index 0000000..753ae9a
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_arm.cc
@@ -0,0 +1,134 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime_support_builder_arm.h"
+
+#include "ir_builder.h"
+#include "thread.h"
+#include "utils_llvm.h"
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/InlineAsm.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+#include <vector>
+
+using namespace llvm;
+
+namespace {
+
+char LDRSTRSuffixByType(art::llvm::IRBuilder& irb, ::llvm::Type* type) {
+  int width = type->isPointerTy() ?
+              irb.getSizeOfPtrEquivInt()*8 :
+              ::llvm::cast<IntegerType>(type)->getBitWidth();
+  switch (width) {
+    case 8:  return 'b';
+    case 16: return 'h';
+    case 32: return ' ';
+    default:
+      LOG(FATAL) << "Unsupported width: " << width;
+      return ' ';
+  }
+}
+
+} // namespace
+
+namespace art {
+namespace llvm {
+
+/* Thread */
+
+::llvm::Value* RuntimeSupportBuilderARM::EmitGetCurrentThread() {
+  Function* ori_func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
+  InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), "mov $0, r9", "=r", false);
+  CallInst* thread = irb_.CreateCall(func);
+  thread->setDoesNotAccessMemory();
+  irb_.SetTBAA(thread, kTBAAConstJObject);
+  return thread;
+}
+
+::llvm::Value* RuntimeSupportBuilderARM::EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                                TBAASpecialType s_ty) {
+  FunctionType* func_ty = FunctionType::get(/*Result=*/type,
+                                            /*isVarArg=*/false);
+  std::string inline_asm(StringPrintf("ldr%c $0, [r9, #%d]",
+                                      LDRSTRSuffixByType(irb_, type),
+                                      static_cast<int>(offset)));
+  InlineAsm* func = InlineAsm::get(func_ty, inline_asm, "=r", true);
+  CallInst* result = irb_.CreateCall(func);
+  result->setOnlyReadsMemory();
+  irb_.SetTBAA(result, s_ty);
+  return result;
+}
+
+void RuntimeSupportBuilderARM::EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                                       TBAASpecialType s_ty) {
+  FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                            /*Params=*/value->getType(),
+                                            /*isVarArg=*/false);
+  std::string inline_asm(StringPrintf("str%c $0, [r9, #%d]",
+                                      LDRSTRSuffixByType(irb_, value->getType()),
+                                      static_cast<int>(offset)));
+  InlineAsm* func = InlineAsm::get(func_ty, inline_asm, "r", true);
+  CallInst* call_inst = irb_.CreateCall(func, value);
+  irb_.SetTBAA(call_inst, s_ty);
+}
+
+::llvm::Value*
+RuntimeSupportBuilderARM::EmitSetCurrentThread(::llvm::Value* thread) {
+  // Separate to two InlineAsm: The first one produces the return value, while the second,
+  // sets the current thread.
+  // LLVM can delete the first one if the caller in LLVM IR doesn't use the return value.
+  //
+  // Here we don't call EmitGetCurrentThread, because we mark it as DoesNotAccessMemory and
+  // ConstJObject. We denote side effect to "true" below instead, so LLVM won't
+  // reorder these instructions incorrectly.
+  Function* ori_func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
+  InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), "mov $0, r9", "=r", true);
+  CallInst* old_thread_register = irb_.CreateCall(func);
+  old_thread_register->setOnlyReadsMemory();
+
+  FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                            /*Params=*/irb_.getJObjectTy(),
+                                            /*isVarArg=*/false);
+  func = InlineAsm::get(func_ty, "mov r9, $0", "r", true);
+  irb_.CreateCall(func, thread);
+  return old_thread_register;
+}
+
+
+/* Monitor */
+
+void RuntimeSupportBuilderARM::EmitLockObject(::llvm::Value* object) {
+  RuntimeSupportBuilder::EmitLockObject(object);
+  FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                            /*isVarArg=*/false);
+  InlineAsm* func = InlineAsm::get(func_ty, "dmb sy", "", true);
+  irb_.CreateCall(func);
+}
+
+void RuntimeSupportBuilderARM::EmitUnlockObject(::llvm::Value* object) {
+  RuntimeSupportBuilder::EmitUnlockObject(object);
+  FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                            /*isVarArg=*/false);
+  InlineAsm* func = InlineAsm::get(func_ty, "dmb sy", "", true);
+  irb_.CreateCall(func);
+}
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/runtime_support_builder_arm.h b/src/compiler/llvm/runtime_support_builder_arm.h
new file mode 100644
index 0000000..3c5972f
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_arm.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_
+
+#include "runtime_support_builder.h"
+
+namespace art {
+namespace llvm {
+
+class RuntimeSupportBuilderARM : public RuntimeSupportBuilder {
+ public:
+  RuntimeSupportBuilderARM(::llvm::LLVMContext& context, ::llvm::Module& module, IRBuilder& irb)
+    : RuntimeSupportBuilder(context, module, irb) {}
+
+  /* Thread */
+  virtual ::llvm::Value* EmitGetCurrentThread();
+  virtual ::llvm::Value* EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                TBAASpecialType s_ty);
+  virtual void EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                       TBAASpecialType s_ty);
+  virtual ::llvm::Value* EmitSetCurrentThread(::llvm::Value* thread);
+
+  /* Monitor */
+  virtual void EmitLockObject(::llvm::Value* object);
+  virtual void EmitUnlockObject(::llvm::Value* object);
+};
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_ARM_H_
diff --git a/src/compiler/llvm/runtime_support_builder_thumb2.cc b/src/compiler/llvm/runtime_support_builder_thumb2.cc
new file mode 100644
index 0000000..c16717b
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_thumb2.cc
@@ -0,0 +1,85 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime_support_builder_thumb2.h"
+
+#include "ir_builder.h"
+#include "mirror/object.h"
+#include "monitor.h"
+#include "thread.h"
+#include "utils_llvm.h"
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/InlineAsm.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+#include <inttypes.h>
+#include <vector>
+
+using namespace llvm;
+
+namespace art {
+namespace llvm {
+
+
+void RuntimeSupportBuilderThumb2::EmitLockObject(::llvm::Value* object) {
+  FunctionType* func_ty = FunctionType::get(/*Result=*/irb_.getInt32Ty(),
+                                            /*Params=*/irb_.getJObjectTy(),
+                                            /*isVarArg=*/false);
+  // $0: result
+  // $1: object
+  // $2: temp
+  // $3: temp
+  std::string asms;
+  StringAppendF(&asms, "add $3, $1, #%"PRId32"\n", mirror::Object::MonitorOffset().Int32Value());
+  StringAppendF(&asms, "ldr $2, [r9, #%"PRId32"]\n", Thread::ThinLockIdOffset().Int32Value());
+  StringAppendF(&asms, "ldrex $0, [$3]\n");
+  StringAppendF(&asms, "lsl $2, $2, %d\n", LW_LOCK_OWNER_SHIFT);
+  StringAppendF(&asms, "bfi $2, $0, #0, #%d\n", LW_LOCK_OWNER_SHIFT - 1);
+  StringAppendF(&asms, "bfc $0, #%d, #%d\n", LW_HASH_STATE_SHIFT, LW_LOCK_OWNER_SHIFT - 1);
+  StringAppendF(&asms, "cmp $0, #0\n");
+  StringAppendF(&asms, "it eq\n");
+  StringAppendF(&asms, "strexeq $0, $2, [$3]\n");
+
+  InlineAsm* func = InlineAsm::get(func_ty, asms, "=&l,l,~l,~l", true);
+
+  ::llvm::Value* retry_slow_path = irb_.CreateCall(func, object);
+  retry_slow_path = irb_.CreateICmpNE(retry_slow_path, irb_.getJInt(0));
+
+  ::llvm::Function* parent_func = irb_.GetInsertBlock()->getParent();
+  BasicBlock* basic_block_lock = BasicBlock::Create(context_, "lock", parent_func);
+  BasicBlock* basic_block_cont = BasicBlock::Create(context_, "lock_cont", parent_func);
+  irb_.CreateCondBr(retry_slow_path, basic_block_lock, basic_block_cont, kUnlikely);
+
+  irb_.SetInsertPoint(basic_block_lock);
+  Function* slow_func = GetRuntimeSupportFunction(runtime_support::LockObject);
+  irb_.CreateCall2(slow_func, object, EmitGetCurrentThread());
+  irb_.CreateBr(basic_block_cont);
+
+  irb_.SetInsertPoint(basic_block_cont);
+  { // Memory barrier
+    FunctionType* asm_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                              /*isVarArg=*/false);
+    InlineAsm* func = InlineAsm::get(asm_ty, "dmb sy", "", true);
+    irb_.CreateCall(func);
+  }
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/runtime_support_builder_thumb2.h b/src/compiler/llvm/runtime_support_builder_thumb2.h
new file mode 100644
index 0000000..4762a26
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_thumb2.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_
+
+#include "runtime_support_builder_arm.h"
+
+namespace art {
+namespace llvm {
+
+class RuntimeSupportBuilderThumb2 : public RuntimeSupportBuilderARM {
+ public:
+  RuntimeSupportBuilderThumb2(::llvm::LLVMContext& context, ::llvm::Module& module, IRBuilder& irb)
+    : RuntimeSupportBuilderARM(context, module, irb) {}
+
+  /* Monitor */
+  virtual void EmitLockObject(::llvm::Value* object);
+};
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_THUMB2_H_
diff --git a/src/compiler/llvm/runtime_support_builder_x86.cc b/src/compiler/llvm/runtime_support_builder_x86.cc
new file mode 100644
index 0000000..cd00b0b
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_x86.cc
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime_support_builder_x86.h"
+
+#include "base/stringprintf.h"
+#include "ir_builder.h"
+#include "thread.h"
+#include "utils_llvm.h"
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/InlineAsm.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+#include <vector>
+
+using namespace llvm;
+
+namespace art {
+namespace llvm {
+
+
+::llvm::Value* RuntimeSupportBuilderX86::EmitGetCurrentThread() {
+  Function* ori_func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
+  std::string inline_asm(StringPrintf("mov %%fs:%d, $0", Thread::SelfOffset().Int32Value()));
+  InlineAsm* func = InlineAsm::get(ori_func->getFunctionType(), inline_asm, "=r", false);
+  CallInst* thread = irb_.CreateCall(func);
+  thread->setDoesNotAccessMemory();
+  irb_.SetTBAA(thread, kTBAAConstJObject);
+  return thread;
+}
+
+::llvm::Value* RuntimeSupportBuilderX86::EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                                TBAASpecialType s_ty) {
+  FunctionType* func_ty = FunctionType::get(/*Result=*/type,
+                                            /*isVarArg=*/false);
+  std::string inline_asm(StringPrintf("mov %%fs:%d, $0", static_cast<int>(offset)));
+  InlineAsm* func = InlineAsm::get(func_ty, inline_asm, "=r", true);
+  CallInst* result = irb_.CreateCall(func);
+  result->setOnlyReadsMemory();
+  irb_.SetTBAA(result, s_ty);
+  return result;
+}
+
+void RuntimeSupportBuilderX86::EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                                       TBAASpecialType s_ty) {
+  FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
+                                            /*Params=*/value->getType(),
+                                            /*isVarArg=*/false);
+  std::string inline_asm(StringPrintf("mov $0, %%fs:%d", static_cast<int>(offset)));
+  InlineAsm* func = InlineAsm::get(func_ty, inline_asm, "r", true);
+  CallInst* call_inst = irb_.CreateCall(func, value);
+  irb_.SetTBAA(call_inst, s_ty);
+}
+
+::llvm::Value* RuntimeSupportBuilderX86::EmitSetCurrentThread(::llvm::Value*) {
+  /* Nothing to be done. */
+  return ::llvm::UndefValue::get(irb_.getJObjectTy());
+}
+
+
+} // namespace llvm
+} // namespace art
diff --git a/src/compiler/llvm/runtime_support_builder_x86.h b/src/compiler/llvm/runtime_support_builder_x86.h
new file mode 100644
index 0000000..e5fdbc2
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_builder_x86.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_
+
+#include "runtime_support_builder.h"
+
+namespace art {
+namespace llvm {
+
+class RuntimeSupportBuilderX86 : public RuntimeSupportBuilder {
+ public:
+  RuntimeSupportBuilderX86(::llvm::LLVMContext& context, ::llvm::Module& module, IRBuilder& irb)
+    : RuntimeSupportBuilder(context, module, irb) {}
+
+  /* Thread */
+  virtual ::llvm::Value* EmitGetCurrentThread();
+  virtual ::llvm::Value* EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
+                                                TBAASpecialType s_ty);
+  virtual void EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
+                                       TBAASpecialType s_ty);
+  virtual ::llvm::Value* EmitSetCurrentThread(::llvm::Value* thread);
+};
+
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_X86_H_
diff --git a/src/compiler/llvm/runtime_support_func.h b/src/compiler/llvm/runtime_support_func.h
new file mode 100644
index 0000000..6dfa961
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_func.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_
+
+namespace art {
+namespace llvm {
+namespace runtime_support {
+
+  enum RuntimeId {
+#define DEFINE_RUNTIME_SUPPORT_FUNC_ID(ID, NAME) ID,
+#include "runtime_support_func_list.h"
+    RUNTIME_SUPPORT_FUNC_LIST(DEFINE_RUNTIME_SUPPORT_FUNC_ID)
+#undef RUNTIME_SUPPORT_FUNC_LIST
+#undef DEFINE_RUNTIME_SUPPORT_FUNC_ID
+
+    MAX_ID
+  };
+
+} // namespace runtime_support
+} // namespace llvm
+} // namespace art
+
+#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_
diff --git a/src/compiler/llvm/runtime_support_func_list.h b/src/compiler/llvm/runtime_support_func_list.h
new file mode 100644
index 0000000..a58b061
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_func_list.h
@@ -0,0 +1,76 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#define RUNTIME_SUPPORT_FUNC_LIST(V) \
+  V(LockObject, art_portable_lock_object_from_code) \
+  V(UnlockObject, art_portable_unlock_object_from_code) \
+  V(GetCurrentThread, art_portable_get_current_thread_from_code) \
+  V(SetCurrentThread, art_portable_set_current_thread_from_code) \
+  V(PushShadowFrame, art_portable_push_shadow_frame_from_code) \
+  V(PopShadowFrame, art_portable_pop_shadow_frame_from_code) \
+  V(TestSuspend, art_portable_test_suspend_from_code) \
+  V(ThrowException, art_portable_throw_exception_from_code) \
+  V(ThrowStackOverflowException, art_portable_throw_stack_overflow_from_code) \
+  V(ThrowNullPointerException, art_portable_throw_null_pointer_exception_from_code) \
+  V(ThrowDivZeroException, art_portable_throw_div_zero_from_code) \
+  V(ThrowIndexOutOfBounds, art_portable_throw_array_bounds_from_code) \
+  V(InitializeTypeAndVerifyAccess, art_portable_initialize_type_and_verify_access_from_code) \
+  V(InitializeType, art_portable_initialize_type_from_code) \
+  V(IsAssignable, art_portable_is_assignable_from_code) \
+  V(CheckCast, art_portable_check_cast_from_code) \
+  V(CheckPutArrayElement, art_portable_check_put_array_element_from_code) \
+  V(AllocObject, art_portable_alloc_object_from_code) \
+  V(AllocObjectWithAccessCheck, art_portable_alloc_object_from_code_with_access_check) \
+  V(AllocArray, art_portable_alloc_array_from_code) \
+  V(AllocArrayWithAccessCheck, art_portable_alloc_array_from_code_with_access_check) \
+  V(CheckAndAllocArray, art_portable_check_and_alloc_array_from_code) \
+  V(CheckAndAllocArrayWithAccessCheck, art_portable_check_and_alloc_array_from_code_with_access_check) \
+  V(FindStaticMethodWithAccessCheck, art_portable_find_static_method_from_code_with_access_check) \
+  V(FindDirectMethodWithAccessCheck, art_portable_find_direct_method_from_code_with_access_check) \
+  V(FindVirtualMethodWithAccessCheck, art_portable_find_virtual_method_from_code_with_access_check) \
+  V(FindSuperMethodWithAccessCheck, art_portable_find_super_method_from_code_with_access_check) \
+  V(FindInterfaceMethodWithAccessCheck, art_portable_find_interface_method_from_code_with_access_check) \
+  V(FindInterfaceMethod, art_portable_find_interface_method_from_code) \
+  V(ResolveString, art_portable_resolve_string_from_code) \
+  V(Set32Static, art_portable_set32_static_from_code) \
+  V(Set64Static, art_portable_set64_static_from_code) \
+  V(SetObjectStatic, art_portable_set_obj_static_from_code) \
+  V(Get32Static, art_portable_get32_static_from_code) \
+  V(Get64Static, art_portable_get64_static_from_code) \
+  V(GetObjectStatic, art_portable_get_obj_static_from_code) \
+  V(Set32Instance, art_portable_set32_instance_from_code) \
+  V(Set64Instance, art_portable_set64_instance_from_code) \
+  V(SetObjectInstance, art_portable_set_obj_instance_from_code) \
+  V(Get32Instance, art_portable_get32_instance_from_code) \
+  V(Get64Instance, art_portable_get64_instance_from_code) \
+  V(GetObjectInstance, art_portable_get_obj_instance_from_code) \
+  V(InitializeStaticStorage, art_portable_initialize_static_storage_from_code) \
+  V(FillArrayData, art_portable_fill_array_data_from_code) \
+  V(GetAndClearException, art_portable_get_and_clear_exception) \
+  V(IsExceptionPending, art_portable_is_exception_pending_from_code) \
+  V(FindCatchBlock, art_portable_find_catch_block_from_code) \
+  V(MarkGCCard, art_portable_mark_gc_card_from_code) \
+  V(ProxyInvokeHandler, art_portable_proxy_invoke_handler_from_code) \
+  V(art_d2l, art_d2l) \
+  V(art_d2i, art_d2i) \
+  V(art_f2l, art_f2l) \
+  V(art_f2i, art_f2i) \
+  V(JniMethodStart,                        art_portable_jni_method_start) \
+  V(JniMethodStartSynchronized,            art_portable_jni_method_start_synchronized) \
+  V(JniMethodEnd,                          art_portable_jni_method_end) \
+  V(JniMethodEndSynchronized,              art_portable_jni_method_end_synchronized) \
+  V(JniMethodEndWithReference,             art_portable_jni_method_end_with_reference) \
+  V(JniMethodEndWithReferenceSynchronized, art_portable_jni_method_end_with_reference_synchronized)
diff --git a/src/compiler/llvm/runtime_support_llvm.cc b/src/compiler/llvm/runtime_support_llvm.cc
new file mode 100644
index 0000000..ae8bb4a
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_llvm.cc
@@ -0,0 +1,908 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "runtime_support_llvm.h"
+
+#include "ScopedLocalRef.h"
+#include "asm_support.h"
+#include "class_linker.h"
+#include "class_linker-inl.h"
+#include "compiler_runtime_func_list.h"
+#include "dex_file.h"
+#include "dex_instruction.h"
+#include "mirror/abstract_method-inl.h"
+#include "mirror/class-inl.h"
+#include "mirror/field-inl.h"
+#include "mirror/object.h"
+#include "mirror/object-inl.h"
+#include "mirror/object_array-inl.h"
+#include "nth_caller_visitor.h"
+#include "object_utils.h"
+#include "reflection.h"
+#include "runtime_support.h"
+#include "runtime_support_func_list.h"
+#include "scoped_thread_state_change.h"
+#include "thread.h"
+#include "thread_list.h"
+#include "utils_llvm.h"
+#include "verifier/dex_gc_map.h"
+#include "verifier/method_verifier.h"
+#include "well_known_classes.h"
+
+#include <algorithm>
+#include <math.h>
+#include <stdarg.h>
+#include <stdint.h>
+#include <stdlib.h>
+
+using namespace art;
+
+extern "C" {
+
+class ShadowFrameCopyVisitor : public StackVisitor {
+ public:
+  explicit ShadowFrameCopyVisitor(Thread* self) : StackVisitor(self, NULL), prev_frame_(NULL),
+      top_frame_(NULL) {}
+
+  bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+    if (IsShadowFrame()) {
+      ShadowFrame* cur_frame = GetCurrentShadowFrame();
+      size_t num_regs = cur_frame->NumberOfVRegs();
+      mirror::AbstractMethod* method = cur_frame->GetMethod();
+      uint32_t dex_pc = cur_frame->GetDexPC();
+      ShadowFrame* new_frame = ShadowFrame::Create(num_regs, NULL, method, dex_pc);
+
+      const uint8_t* gc_map = method->GetNativeGcMap();
+      uint32_t gc_map_length = static_cast<uint32_t>((gc_map[0] << 24) |
+                                                     (gc_map[1] << 16) |
+                                                     (gc_map[2] << 8) |
+                                                     (gc_map[3] << 0));
+      verifier::DexPcToReferenceMap dex_gc_map(gc_map + 4, gc_map_length);
+      const uint8_t* reg_bitmap = dex_gc_map.FindBitMap(dex_pc);
+      for (size_t reg = 0; reg < num_regs; ++reg) {
+        if (TestBitmap(reg, reg_bitmap)) {
+          new_frame->SetVRegReference(reg, cur_frame->GetVRegReference(reg));
+        } else {
+          new_frame->SetVReg(reg, cur_frame->GetVReg(reg));
+        }
+      }
+
+      if (prev_frame_ != NULL) {
+        prev_frame_->SetLink(new_frame);
+      } else {
+        top_frame_ = new_frame;
+      }
+      prev_frame_ = new_frame;
+    }
+    return true;
+  }
+
+  ShadowFrame* GetShadowFrameCopy() {
+    return top_frame_;
+  }
+
+ private:
+  static bool TestBitmap(int reg, const uint8_t* reg_vector) {
+    return ((reg_vector[reg / 8] >> (reg % 8)) & 0x01) != 0;
+  }
+
+  ShadowFrame* prev_frame_;
+  ShadowFrame* top_frame_;
+};
+
+//----------------------------------------------------------------------------
+// Thread
+//----------------------------------------------------------------------------
+
+Thread* art_portable_get_current_thread_from_code() {
+#if defined(__arm__) || defined(__i386__)
+  LOG(FATAL) << "UNREACHABLE";
+#endif
+  return Thread::Current();
+}
+
+void* art_portable_set_current_thread_from_code(void* thread_object_addr) {
+  // Hijacked to set r9 on ARM.
+  LOG(FATAL) << "UNREACHABLE";
+  return NULL;
+}
+
+void art_portable_lock_object_from_code(mirror::Object* obj, Thread* thread)
+    EXCLUSIVE_LOCK_FUNCTION(monitor_lock_) {
+  DCHECK(obj != NULL);        // Assumed to have been checked before entry
+  obj->MonitorEnter(thread);  // May block
+  DCHECK(thread->HoldsLock(obj));
+  // Only possible exception is NPE and is handled before entry
+  DCHECK(!thread->IsExceptionPending());
+}
+
+void art_portable_unlock_object_from_code(mirror::Object* obj, Thread* thread)
+    UNLOCK_FUNCTION(monitor_lock_) {
+  DCHECK(obj != NULL);  // Assumed to have been checked before entry
+  // MonitorExit may throw exception
+  obj->MonitorExit(thread);
+}
+
+void art_portable_test_suspend_from_code(Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  CheckSuspend(thread);
+  if (thread->ReadFlag(kEnterInterpreter)) {
+    // Save out the shadow frame to the heap
+    ShadowFrameCopyVisitor visitor(thread);
+    visitor.WalkStack(true);
+    thread->SetDeoptimizationShadowFrame(visitor.GetShadowFrameCopy(), JValue());
+    thread->SetException(reinterpret_cast<mirror::Throwable*>(-1));
+  }
+}
+
+ShadowFrame* art_portable_push_shadow_frame_from_code(Thread* thread,
+                                              ShadowFrame* new_shadow_frame,
+                                              mirror::AbstractMethod* method,
+                                              uint32_t num_vregs) {
+  ShadowFrame* old_frame = thread->PushShadowFrame(new_shadow_frame);
+  new_shadow_frame->SetMethod(method);
+  new_shadow_frame->SetNumberOfVRegs(num_vregs);
+  return old_frame;
+}
+
+void art_portable_pop_shadow_frame_from_code(void*) {
+  LOG(FATAL) << "Implemented by IRBuilder.";
+}
+
+void art_portable_mark_gc_card_from_code(void *, void*) {
+  LOG(FATAL) << "Implemented by IRBuilder.";
+}
+
+//----------------------------------------------------------------------------
+// Exception
+//----------------------------------------------------------------------------
+
+bool art_portable_is_exception_pending_from_code() {
+  LOG(FATAL) << "Implemented by IRBuilder.";
+  return false;
+}
+
+void art_portable_throw_div_zero_from_code() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  Thread::Current()->ThrowNewException("Ljava/lang/ArithmeticException;",
+                                       "divide by zero");
+}
+
+void art_portable_throw_array_bounds_from_code(int32_t index, int32_t length)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayIndexOutOfBoundsException;",
+                                        "length=%d; index=%d", length, index);
+}
+
+void art_portable_throw_no_such_method_from_code(int32_t method_idx)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  // We need the calling method as context for the method_idx.
+  mirror::AbstractMethod* method = Thread::Current()->GetCurrentMethod();
+  ThrowNoSuchMethodError(method_idx, method);
+}
+
+void art_portable_throw_null_pointer_exception_from_code(uint32_t dex_pc)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::AbstractMethod* throw_method =
+      Thread::Current()->GetManagedStack()->GetTopShadowFrame()->GetMethod();
+  ThrowNullPointerExceptionFromDexPC(throw_method, dex_pc);
+}
+
+void art_portable_throw_stack_overflow_from_code() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  ThrowStackOverflowError(Thread::Current());
+}
+
+void art_portable_throw_exception_from_code(mirror::Object* exception) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  Thread::Current()->DeliverException(static_cast<mirror::Throwable*>(exception));
+}
+
+void* art_portable_get_and_clear_exception(Thread* self)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  DCHECK(self->IsExceptionPending());
+  mirror::Throwable* exception = self->GetException();
+  self->ClearException();
+  return exception;
+}
+
+int32_t art_portable_find_catch_block_from_code(mirror::AbstractMethod* current_method, uint32_t ti_offset)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Throwable* exception = Thread::Current()->GetException();
+  // Check for magic deoptimization exception.
+  if (reinterpret_cast<int32_t>(exception) == -1) {
+    return -1;
+  }
+  mirror::Class* exception_type = exception->GetClass();
+  MethodHelper mh(current_method);
+  const DexFile::CodeItem* code_item = mh.GetCodeItem();
+  DCHECK_LT(ti_offset, code_item->tries_size_);
+  const DexFile::TryItem* try_item = DexFile::GetTryItems(*code_item, ti_offset);
+
+  int iter_index = 0;
+  // Iterate over the catch handlers associated with dex_pc
+  for (CatchHandlerIterator it(*code_item, *try_item); it.HasNext(); it.Next()) {
+    uint16_t iter_type_idx = it.GetHandlerTypeIndex();
+    // Catch all case
+    if (iter_type_idx == DexFile::kDexNoIndex16) {
+      return iter_index;
+    }
+    // Does this catch exception type apply?
+    mirror::Class* iter_exception_type = mh.GetDexCacheResolvedType(iter_type_idx);
+    if (iter_exception_type == NULL) {
+      // The verifier should take care of resolving all exception classes early
+      LOG(WARNING) << "Unresolved exception class when finding catch block: "
+          << mh.GetTypeDescriptorFromTypeIdx(iter_type_idx);
+    } else if (iter_exception_type->IsAssignableFrom(exception_type)) {
+      return iter_index;
+    }
+    ++iter_index;
+  }
+  // Handler not found
+  return -1;
+}
+
+
+//----------------------------------------------------------------------------
+// Object Space
+//----------------------------------------------------------------------------
+
+mirror::Object* art_portable_alloc_object_from_code(uint32_t type_idx,
+                                            mirror::AbstractMethod* referrer,
+                                            Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return AllocObjectFromCode(type_idx, referrer, thread, false);
+}
+
+mirror::Object* art_portable_alloc_object_from_code_with_access_check(uint32_t type_idx,
+                                                              mirror::AbstractMethod* referrer,
+                                                              Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return AllocObjectFromCode(type_idx, referrer, thread, true);
+}
+
+mirror::Object* art_portable_alloc_array_from_code(uint32_t type_idx,
+                                           mirror::AbstractMethod* referrer,
+                                           uint32_t length,
+                                           Thread* self)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return AllocArrayFromCode(type_idx, referrer, length, self, false);
+}
+
+mirror::Object* art_portable_alloc_array_from_code_with_access_check(uint32_t type_idx,
+                                                             mirror::AbstractMethod* referrer,
+                                                             uint32_t length,
+                                                             Thread* self)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return AllocArrayFromCode(type_idx, referrer, length, self, true);
+}
+
+mirror::Object* art_portable_check_and_alloc_array_from_code(uint32_t type_idx,
+                                                     mirror::AbstractMethod* referrer,
+                                                     uint32_t length,
+                                                     Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return CheckAndAllocArrayFromCode(type_idx, referrer, length, thread, false);
+}
+
+mirror::Object* art_portable_check_and_alloc_array_from_code_with_access_check(uint32_t type_idx,
+                                                                       mirror::AbstractMethod* referrer,
+                                                                       uint32_t length,
+                                                                       Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return CheckAndAllocArrayFromCode(type_idx, referrer, length, thread, true);
+}
+
+static mirror::AbstractMethod* FindMethodHelper(uint32_t method_idx, mirror::Object* this_object,
+                                        mirror::AbstractMethod* caller_method, bool access_check,
+                                        InvokeType type, Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::AbstractMethod* method = FindMethodFast(method_idx, this_object, caller_method, access_check, type);
+  if (UNLIKELY(method == NULL)) {
+    method = FindMethodFromCode(method_idx, this_object, caller_method,
+                                thread, access_check, type);
+    if (UNLIKELY(method == NULL)) {
+      CHECK(thread->IsExceptionPending());
+      return 0;  // failure
+    }
+  }
+  DCHECK(!thread->IsExceptionPending());
+  const void* code = method->GetCode();
+
+  // When we return, the caller will branch to this address, so it had better not be 0!
+  if (UNLIKELY(code == NULL)) {
+      MethodHelper mh(method);
+      LOG(FATAL) << "Code was NULL in method: " << PrettyMethod(method)
+                 << " location: " << mh.GetDexFile().GetLocation();
+  }
+  return method;
+}
+
+mirror::Object* art_portable_find_static_method_from_code_with_access_check(uint32_t method_idx,
+                                                                    mirror::Object* this_object,
+                                                                    mirror::AbstractMethod* referrer,
+                                                                    Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, true, kStatic, thread);
+}
+
+mirror::Object* art_portable_find_direct_method_from_code_with_access_check(uint32_t method_idx,
+                                                                    mirror::Object* this_object,
+                                                                    mirror::AbstractMethod* referrer,
+                                                                    Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, true, kDirect, thread);
+}
+
+mirror::Object* art_portable_find_virtual_method_from_code_with_access_check(uint32_t method_idx,
+                                                                     mirror::Object* this_object,
+                                                                     mirror::AbstractMethod* referrer,
+                                                                     Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, true, kVirtual, thread);
+}
+
+mirror::Object* art_portable_find_super_method_from_code_with_access_check(uint32_t method_idx,
+                                                                   mirror::Object* this_object,
+                                                                   mirror::AbstractMethod* referrer,
+                                                                   Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, true, kSuper, thread);
+}
+
+mirror::Object*
+art_portable_find_interface_method_from_code_with_access_check(uint32_t method_idx,
+                                                       mirror::Object* this_object,
+                                                       mirror::AbstractMethod* referrer,
+                                                       Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, true, kInterface, thread);
+}
+
+mirror::Object* art_portable_find_interface_method_from_code(uint32_t method_idx,
+                                                     mirror::Object* this_object,
+                                                     mirror::AbstractMethod* referrer,
+                                                     Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return FindMethodHelper(method_idx, this_object, referrer, false, kInterface, thread);
+}
+
+mirror::Object* art_portable_initialize_static_storage_from_code(uint32_t type_idx,
+                                                         mirror::AbstractMethod* referrer,
+                                                         Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return ResolveVerifyAndClinit(type_idx, referrer, thread, true, false);
+}
+
+mirror::Object* art_portable_initialize_type_from_code(uint32_t type_idx,
+                                               mirror::AbstractMethod* referrer,
+                                               Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return ResolveVerifyAndClinit(type_idx, referrer, thread, false, false);
+}
+
+mirror::Object* art_portable_initialize_type_and_verify_access_from_code(uint32_t type_idx,
+                                                                 mirror::AbstractMethod* referrer,
+                                                                 Thread* thread)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  // Called when caller isn't guaranteed to have access to a type and the dex cache may be
+  // unpopulated
+  return ResolveVerifyAndClinit(type_idx, referrer, thread, false, true);
+}
+
+mirror::Object* art_portable_resolve_string_from_code(mirror::AbstractMethod* referrer, uint32_t string_idx)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  return ResolveStringFromCode(referrer, string_idx);
+}
+
+int32_t art_portable_set32_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, int32_t new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    field->Set32(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticPrimitiveWrite, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    field->Set32(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_set64_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, int64_t new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveWrite, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    field->Set64(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticPrimitiveWrite, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    field->Set64(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_set_obj_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, mirror::Object* new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectWrite, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    field->SetObj(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticObjectWrite, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    field->SetObj(field->GetDeclaringClass(), new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_get32_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get32(field->GetDeclaringClass());
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticPrimitiveRead, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get32(field->GetDeclaringClass());
+  }
+  return 0;
+}
+
+int64_t art_portable_get64_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticPrimitiveRead, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get64(field->GetDeclaringClass());
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticPrimitiveRead, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get64(field->GetDeclaringClass());
+  }
+  return 0;
+}
+
+mirror::Object* art_portable_get_obj_static_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, StaticObjectRead, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    return field->GetObj(field->GetDeclaringClass());
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            StaticObjectRead, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    return field->GetObj(field->GetDeclaringClass());
+  }
+  return 0;
+}
+
+int32_t art_portable_set32_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer,
+                                     mirror::Object* obj, uint32_t new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    field->Set32(obj, new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstancePrimitiveWrite, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    field->Set32(obj, new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_set64_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer,
+                                      mirror::Object* obj, int64_t new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveWrite, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    field->Set64(obj, new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstancePrimitiveWrite, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    field->Set64(obj, new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_set_obj_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer,
+                                        mirror::Object* obj, mirror::Object* new_value)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectWrite, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    field->SetObj(obj, new_value);
+    return 0;
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstanceObjectWrite, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    field->SetObj(obj, new_value);
+    return 0;
+  }
+  return -1;
+}
+
+int32_t art_portable_get32_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, mirror::Object* obj)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get32(obj);
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstancePrimitiveRead, sizeof(uint32_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get32(obj);
+  }
+  return 0;
+}
+
+int64_t art_portable_get64_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, mirror::Object* obj)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstancePrimitiveRead, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get64(obj);
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstancePrimitiveRead, sizeof(uint64_t));
+  if (LIKELY(field != NULL)) {
+    return field->Get64(obj);
+  }
+  return 0;
+}
+
+mirror::Object* art_portable_get_obj_instance_from_code(uint32_t field_idx, mirror::AbstractMethod* referrer, mirror::Object* obj)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  mirror::Field* field = FindFieldFast(field_idx, referrer, InstanceObjectRead, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    return field->GetObj(obj);
+  }
+  field = FindFieldFromCode(field_idx, referrer, Thread::Current(),
+                            InstanceObjectRead, sizeof(mirror::Object*));
+  if (LIKELY(field != NULL)) {
+    return field->GetObj(obj);
+  }
+  return 0;
+}
+
+void art_portable_fill_array_data_from_code(mirror::AbstractMethod* method, uint32_t dex_pc,
+                                    mirror::Array* array, uint32_t payload_offset)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  // Test: Is array equal to null? (Guard NullPointerException)
+  if (UNLIKELY(array == NULL)) {
+    art_portable_throw_null_pointer_exception_from_code(dex_pc);
+    return;
+  }
+
+  // Find the payload from the CodeItem
+  MethodHelper mh(method);
+  const DexFile::CodeItem* code_item = mh.GetCodeItem();
+
+  DCHECK_GT(code_item->insns_size_in_code_units_, payload_offset);
+
+  const Instruction::ArrayDataPayload* payload =
+    reinterpret_cast<const Instruction::ArrayDataPayload*>(
+        code_item->insns_ + payload_offset);
+
+  DCHECK_EQ(payload->ident,
+            static_cast<uint16_t>(Instruction::kArrayDataSignature));
+
+  // Test: Is array big enough?
+  uint32_t array_len = static_cast<uint32_t>(array->GetLength());
+  if (UNLIKELY(array_len < payload->element_count)) {
+    int32_t last_index = payload->element_count - 1;
+    art_portable_throw_array_bounds_from_code(array_len, last_index);
+    return;
+  }
+
+  // Copy the data
+  size_t size = payload->element_width * payload->element_count;
+  memcpy(array->GetRawData(payload->element_width), payload->data, size);
+}
+
+
+
+//----------------------------------------------------------------------------
+// Type checking, in the nature of casting
+//----------------------------------------------------------------------------
+
+int32_t art_portable_is_assignable_from_code(const mirror::Class* dest_type, const mirror::Class* src_type)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  DCHECK(dest_type != NULL);
+  DCHECK(src_type != NULL);
+  return dest_type->IsAssignableFrom(src_type) ? 1 : 0;
+}
+
+void art_portable_check_cast_from_code(const mirror::Class* dest_type, const mirror::Class* src_type)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  DCHECK(dest_type->IsClass()) << PrettyClass(dest_type);
+  DCHECK(src_type->IsClass()) << PrettyClass(src_type);
+  if (UNLIKELY(!dest_type->IsAssignableFrom(src_type))) {
+    Thread::Current()->ThrowNewExceptionF("Ljava/lang/ClassCastException;",
+                                          "%s cannot be cast to %s",
+                                          PrettyDescriptor(src_type).c_str(),
+                                          PrettyDescriptor(dest_type).c_str());
+  }
+}
+
+void art_portable_check_put_array_element_from_code(const mirror::Object* element, const mirror::Object* array)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  if (element == NULL) {
+    return;
+  }
+  DCHECK(array != NULL);
+  mirror::Class* array_class = array->GetClass();
+  DCHECK(array_class != NULL);
+  mirror::Class* component_type = array_class->GetComponentType();
+  mirror::Class* element_class = element->GetClass();
+  if (UNLIKELY(!component_type->IsAssignableFrom(element_class))) {
+    Thread::Current()->ThrowNewExceptionF("Ljava/lang/ArrayStoreException;",
+                                          "%s cannot be stored in an array of type %s",
+                                          PrettyDescriptor(element_class).c_str(),
+                                          PrettyDescriptor(array_class).c_str());
+  }
+  return;
+}
+
+//----------------------------------------------------------------------------
+// JNI
+//----------------------------------------------------------------------------
+
+// Called on entry to JNI, transition out of Runnable and release share of mutator_lock_.
+uint32_t art_portable_jni_method_start(Thread* self)
+    UNLOCK_FUNCTION(GlobalSynchronizatio::mutator_lock_) {
+  JNIEnvExt* env = self->GetJniEnv();
+  uint32_t saved_local_ref_cookie = env->local_ref_cookie;
+  env->local_ref_cookie = env->locals.GetSegmentState();
+  self->TransitionFromRunnableToSuspended(kNative);
+  return saved_local_ref_cookie;
+}
+
+uint32_t art_portable_jni_method_start_synchronized(jobject to_lock, Thread* self)
+    UNLOCK_FUNCTION(Locks::mutator_lock_) {
+  self->DecodeJObject(to_lock)->MonitorEnter(self);
+  return art_portable_jni_method_start(self);
+}
+
+static inline void PopLocalReferences(uint32_t saved_local_ref_cookie, Thread* self) {
+  JNIEnvExt* env = self->GetJniEnv();
+  env->locals.SetSegmentState(env->local_ref_cookie);
+  env->local_ref_cookie = saved_local_ref_cookie;
+}
+
+void art_portable_jni_method_end(uint32_t saved_local_ref_cookie, Thread* self)
+    SHARED_LOCK_FUNCTION(Locks::mutator_lock_) {
+  self->TransitionFromSuspendedToRunnable();
+  PopLocalReferences(saved_local_ref_cookie, self);
+}
+
+
+void art_portable_jni_method_end_synchronized(uint32_t saved_local_ref_cookie,
+                                      jobject locked,
+                                      Thread* self)
+    SHARED_LOCK_FUNCTION(Locks::mutator_lock_) {
+  self->TransitionFromSuspendedToRunnable();
+  UnlockJniSynchronizedMethod(locked, self);  // Must decode before pop.
+  PopLocalReferences(saved_local_ref_cookie, self);
+}
+
+mirror::Object* art_portable_jni_method_end_with_reference(jobject result, uint32_t saved_local_ref_cookie,
+                                                   Thread* self)
+    SHARED_LOCK_FUNCTION(Locks::mutator_lock_) {
+  self->TransitionFromSuspendedToRunnable();
+  mirror::Object* o = self->DecodeJObject(result);  // Must decode before pop.
+  PopLocalReferences(saved_local_ref_cookie, self);
+  // Process result.
+  if (UNLIKELY(self->GetJniEnv()->check_jni)) {
+    if (self->IsExceptionPending()) {
+      return NULL;
+    }
+    CheckReferenceResult(o, self);
+  }
+  return o;
+}
+
+mirror::Object* art_portable_jni_method_end_with_reference_synchronized(jobject result,
+                                                                uint32_t saved_local_ref_cookie,
+                                                                jobject locked, Thread* self)
+    SHARED_LOCK_FUNCTION(Locks::mutator_lock_) {
+  self->TransitionFromSuspendedToRunnable();
+  UnlockJniSynchronizedMethod(locked, self);  // Must decode before pop.
+  mirror::Object* o = self->DecodeJObject(result);
+  PopLocalReferences(saved_local_ref_cookie, self);
+  // Process result.
+  if (UNLIKELY(self->GetJniEnv()->check_jni)) {
+    if (self->IsExceptionPending()) {
+      return NULL;
+    }
+    CheckReferenceResult(o, self);
+  }
+  return o;
+}
+
+//----------------------------------------------------------------------------
+// Runtime Support Function Lookup Callback
+//----------------------------------------------------------------------------
+
+#define EXTERNAL_LINKAGE(NAME, RETURN_TYPE, ...) \
+extern "C" RETURN_TYPE NAME(__VA_ARGS__);
+COMPILER_RUNTIME_FUNC_LIST_NATIVE(EXTERNAL_LINKAGE)
+#undef EXTERNAL_LINKAGE
+
+static void* art_portable_find_compiler_runtime_func(const char* name) {
+// TODO: If target support some math func, use the target's version. (e.g. art_portable_d2i -> __aeabi_d2iz)
+  static const char* const names[] = {
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) #NAME ,
+    COMPILER_RUNTIME_FUNC_LIST_NATIVE(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  static void* const funcs[] = {
+#define DEFINE_ENTRY(NAME, RETURN_TYPE, ...) \
+    reinterpret_cast<void*>(static_cast<RETURN_TYPE (*)(__VA_ARGS__)>(NAME)) ,
+    COMPILER_RUNTIME_FUNC_LIST_NATIVE(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  static const size_t num_entries = sizeof(names) / sizeof(const char* const);
+
+  const char* const* const names_begin = names;
+  const char* const* const names_end = names + num_entries;
+
+  const char* const* name_lbound_ptr =
+      std::lower_bound(names_begin, names_end, name,
+                       CStringLessThanComparator());
+
+  if (name_lbound_ptr < names_end && strcmp(*name_lbound_ptr, name) == 0) {
+    return funcs[name_lbound_ptr - names_begin];
+  } else {
+    return NULL;
+  }
+}
+
+// Handler for invocation on proxy methods. Create a boxed argument array and invoke the invocation
+// handler which is a field within the proxy object receiver. The var args encode the arguments
+// with the last argument being a pointer to a JValue to store the result in.
+void art_portable_proxy_invoke_handler_from_code(mirror::AbstractMethod* proxy_method, ...)
+    SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
+  va_list ap;
+  va_start(ap, proxy_method);
+
+  mirror::Object* receiver = va_arg(ap, mirror::Object*);
+  Thread* self = va_arg(ap, Thread*);
+  MethodHelper proxy_mh(proxy_method);
+
+  // Ensure we don't get thread suspension until the object arguments are safely in jobjects.
+  const char* old_cause =
+      self->StartAssertNoThreadSuspension("Adding to IRT proxy object arguments");
+  self->VerifyStack();
+
+  // Start new JNI local reference state.
+  JNIEnvExt* env = self->GetJniEnv();
+  ScopedObjectAccessUnchecked soa(env);
+  ScopedJniEnvLocalRefState env_state(env);
+
+  // Create local ref. copies of the receiver.
+  jobject rcvr_jobj = soa.AddLocalReference<jobject>(receiver);
+
+  // Convert proxy method into expected interface method.
+  mirror::AbstractMethod* interface_method = proxy_method->FindOverriddenMethod();
+  DCHECK(interface_method != NULL);
+  DCHECK(!interface_method->IsProxyMethod()) << PrettyMethod(interface_method);
+  jobject interface_method_jobj = soa.AddLocalReference<jobject>(interface_method);
+
+  // Record arguments and turn mirror::Object* arguments into jobject to survive GC.
+  std::vector<jvalue> args;
+  const size_t num_params = proxy_mh.NumArgs();
+  for (size_t i = 1; i < num_params; ++i) {
+    jvalue val;
+    switch (proxy_mh.GetParamPrimitiveType(i)) {
+      case Primitive::kPrimNot:
+        val.l = soa.AddLocalReference<jobject>(va_arg(ap, mirror::Object*));
+        break;
+      case Primitive::kPrimBoolean:  // Fall-through.
+      case Primitive::kPrimByte:     // Fall-through.
+      case Primitive::kPrimChar:     // Fall-through.
+      case Primitive::kPrimShort:    // Fall-through.
+      case Primitive::kPrimInt:      // Fall-through.
+        val.i = va_arg(ap, jint);
+        break;
+      case Primitive::kPrimFloat:
+        // TODO: should this be jdouble? Floats aren't passed to var arg routines.
+        val.i = va_arg(ap, jint);
+        break;
+      case Primitive::kPrimDouble:
+        val.d = (va_arg(ap, jdouble));
+        break;
+      case Primitive::kPrimLong:
+        val.j = (va_arg(ap, jlong));
+        break;
+      case Primitive::kPrimVoid:
+        LOG(FATAL) << "UNREACHABLE";
+        val.j = 0;
+        break;
+    }
+    args.push_back(val);
+  }
+  self->EndAssertNoThreadSuspension(old_cause);
+  JValue* result_location = NULL;
+  const char* shorty = proxy_mh.GetShorty();
+  if (shorty[0] != 'V') {
+    result_location = va_arg(ap, JValue*);
+  }
+  va_end(ap);
+  JValue result = InvokeProxyInvocationHandler(soa, shorty, rcvr_jobj, interface_method_jobj, args);
+  if (result_location != NULL) {
+    *result_location = result;
+  }
+}
+
+void* art_portable_find_runtime_support_func(void* context, const char* name) {
+  struct func_entry_t {
+    const char* name;
+    size_t name_len;
+    void* addr;
+  };
+
+  static struct func_entry_t const tab[] = {
+#define DEFINE_ENTRY(ID, NAME) \
+    { #NAME, sizeof(#NAME) - 1, reinterpret_cast<void*>(NAME) },
+    RUNTIME_SUPPORT_FUNC_LIST(DEFINE_ENTRY)
+#undef DEFINE_ENTRY
+  };
+
+  static size_t const tab_size = sizeof(tab) / sizeof(struct func_entry_t);
+
+  // Search the compiler runtime (such as __divdi3)
+  void* result = art_portable_find_compiler_runtime_func(name);
+  if (result != NULL) {
+    return result;
+  }
+
+  // Note: Since our table is small, we are using trivial O(n) searching
+  // function.  For bigger table, it will be better to use a binary
+  // search or hash function.
+  size_t i;
+  size_t name_len = strlen(name);
+  for (i = 0; i < tab_size; ++i) {
+    if (name_len == tab[i].name_len && strcmp(name, tab[i].name) == 0) {
+      return tab[i].addr;
+    }
+  }
+
+  LOG(FATAL) << "Error: Can't find symbol " << name;
+  return 0;
+}
+
+//----------------------------------------------------------------------------
+// Memory barrier
+//----------------------------------------------------------------------------
+
+void art_portable_constructor_barrier() {
+  LOG(FATAL) << "Implemented by IRBuilder.";
+}
+
+}  // extern "C"
diff --git a/src/compiler/llvm/runtime_support_llvm.h b/src/compiler/llvm/runtime_support_llvm.h
new file mode 100644
index 0000000..af99842
--- /dev/null
+++ b/src/compiler/llvm/runtime_support_llvm.h
@@ -0,0 +1,30 @@
+/*
+ * Copyright (C) 2012 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_
+#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_
+
+extern "C" {
+
+//----------------------------------------------------------------------------
+// Runtime Support Function Lookup Callback
+//----------------------------------------------------------------------------
+
+void* art_portable_find_runtime_support_func(void* context, const char* name);
+
+}  // extern "C"
+
+#endif  // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_LLVM_H_
diff --git a/src/compiler/llvm/tools/gen_art_module_cc.sh b/src/compiler/llvm/tools/gen_art_module_cc.sh
new file mode 100755
index 0000000..b691bbf
--- /dev/null
+++ b/src/compiler/llvm/tools/gen_art_module_cc.sh
@@ -0,0 +1,50 @@
+#!/bin/bash -e
+
+# Copyright (C) 2012 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+SCRIPTDIR=`dirname "$0"`
+cd "${SCRIPTDIR}/.."
+
+mkdir -p generated
+
+OUTPUT_FILE=generated/art_module.cc
+
+echo "// Generated with ${0}" > ${OUTPUT_FILE}
+
+echo '
+
+#pragma GCC diagnostic ignored "-Wframe-larger-than="
+// TODO: Remove this pragma after llc can generate makeLLVMModuleContents()
+// with smaller frame size.
+
+#include <llvm/DerivedTypes.h>
+#include <llvm/Function.h>
+#include <llvm/Module.h>
+#include <llvm/Type.h>
+
+#include <vector>
+
+using namespace llvm;
+
+namespace art {
+namespace llvm {
+
+' >> ${OUTPUT_FILE}
+
+llc -march=cpp -cppgen=contents art_module.ll -o - >> ${OUTPUT_FILE}
+
+echo '
+} // namespace llvm
+} // namespace art' >> ${OUTPUT_FILE}
diff --git a/src/compiler/llvm/utils_llvm.h b/src/compiler/llvm/utils_llvm.h
new file mode 100644
index 0000000..e06e113
--- /dev/null
+++ b/src/compiler/llvm/utils_llvm.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_SRC_UTILS_LLVM_H_
+#define ART_SRC_UTILS_LLVM_H_
+
+#include "base/stringprintf.h"
+
+#include <llvm/Analysis/Verifier.h>
+
+#include <stdint.h>
+#include <string>
+
+namespace art {
+
+#ifndef NDEBUG
+#define VERIFY_LLVM_FUNCTION(func) ::llvm::verifyFunction(func, ::llvm::AbortProcessAction)
+#else
+#define VERIFY_LLVM_FUNCTION(func)
+#endif
+
+inline static std::string ElfFuncName(uint32_t idx) {
+  return StringPrintf("Art%u", static_cast<unsigned int>(idx));
+}
+
+class CStringLessThanComparator {
+ public:
+  bool operator()(const char* lhs, const char* rhs) const {
+    return (strcmp(lhs, rhs) < 0);
+  }
+};
+
+}  // namespace art
+
+#endif  // ART_SRC_UTILS_LLVM_H_