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/class_linker.cc b/src/class_linker.cc
index a00b4b9..ca7cc00 100644
--- a/src/class_linker.cc
+++ b/src/class_linker.cc
@@ -58,7 +58,7 @@
#include "runtime.h"
#include "runtime_support.h"
#if defined(ART_USE_PORTABLE_COMPILER)
-#include "compiler_llvm/runtime_support_llvm.h"
+#include "compiler/llvm/runtime_support_llvm.h"
#endif
#include "ScopedLocalRef.h"
#include "scoped_thread_state_change.h"
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_llvm/stub_compiler.cc b/src/compiler/invoke_stubs/portable/stub_compiler.cc
similarity index 67%
rename from src/compiler_llvm/stub_compiler.cc
rename to src/compiler/invoke_stubs/portable/stub_compiler.cc
index 6639ca7..5c314e6 100644
--- a/src/compiler_llvm/stub_compiler.cc
+++ b/src/compiler/invoke_stubs/portable/stub_compiler.cc
@@ -19,12 +19,12 @@
#include "base/logging.h"
#include "compiled_method.h"
#include "compiler/driver/compiler_driver.h"
-#include "compiler_llvm.h"
-#include "ir_builder.h"
-#include "llvm_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 "mirror/abstract_method.h"
-#include "runtime_support_func.h"
-#include "utils_llvm.h"
#include <llvm/BasicBlock.h>
#include <llvm/Function.h>
@@ -35,7 +35,7 @@
#include <string.h>
namespace art {
-namespace compiler_llvm {
+namespace llvm {
using namespace runtime_support;
@@ -55,7 +55,7 @@
std::string func_name(ElfFuncName(cunit_->GetIndex()));
// Get argument types
- llvm::Type* arg_types[] = {
+ ::llvm::Type* arg_types[] = {
irb_.getJObjectTy(), // Method object pointer
irb_.getJObjectTy(), // "this" object pointer (NULL for static)
irb_.getJObjectTy(), // Thread object pointer
@@ -64,37 +64,37 @@
};
// Function type
- llvm::FunctionType* func_type =
- llvm::FunctionType::get(irb_.getVoidTy(), arg_types, false);
+ ::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,
+ ::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);
+ ::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::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++;
+ ::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);
+ ::llvm::Value* old_thread_register = irb_.Runtime().EmitSetCurrentThread(thread_object_addr);
// Accurate function type
- llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
+ ::llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
- std::vector<llvm::Type*> accurate_arg_types;
+ std::vector< ::llvm::Type*> accurate_arg_types;
accurate_arg_types.push_back(irb_.getJObjectTy()); // method object pointer
@@ -106,11 +106,11 @@
accurate_arg_types.push_back(irb_.getJType(shorty[i]));
}
- llvm::FunctionType* accurate_func_type =
- llvm::FunctionType::get(accurate_ret_type, accurate_arg_types, false);
+ ::llvm::FunctionType* accurate_func_type =
+ ::llvm::FunctionType::get(accurate_ret_type, accurate_arg_types, false);
// Load actual arguments
- std::vector<llvm::Value*> args;
+ std::vector< ::llvm::Value*> args;
args.push_back(method_object_addr);
@@ -125,13 +125,13 @@
arg_shorty == 'S' || arg_shorty == 'I' || arg_shorty == 'J' ||
arg_shorty == 'F' || arg_shorty == 'D' || arg_shorty == 'L') {
- llvm::Type* arg_type =
+ ::llvm::Type* arg_type =
irb_.getJType(shorty[i])->getPointerTo();
- llvm::Value* arg_jvalue_addr =
+ ::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);
+ ::llvm::Value* arg_addr = irb_.CreateBitCast(arg_jvalue_addr, arg_type);
args.push_back(irb_.CreateLoad(arg_addr, kTBAAStackTemp));
@@ -141,26 +141,26 @@
}
// Invoke managed method now!
- llvm::Value* code_field_offset_value =
+ ::llvm::Value* code_field_offset_value =
irb_.getPtrEquivInt(mirror::AbstractMethod::GetCodeOffset().Int32Value());
- llvm::Value* code_field_addr =
+ ::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::Value* code_addr = irb_.CreateLoad(code_field_addr, kTBAARuntimeInfo);
- llvm::CallInst* retval = irb_.CreateCall(code_addr, args);
+ ::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);
+ 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);
+ retval->addAttribute(i + (is_static ? 1 : 2), ::llvm::Attribute::SExt);
break;
default: break;
@@ -169,7 +169,7 @@
// Store the returned value
if (shorty[0] != 'V') {
- llvm::Value* ret_addr =
+ ::llvm::Value* ret_addr =
irb_.CreateBitCast(retval_addr, accurate_ret_type->getPointerTo());
irb_.CreateStore(retval, ret_addr, kTBAAStackTemp);
@@ -197,9 +197,9 @@
std::string func_name(ElfFuncName(cunit_->GetIndex()));
// Accurate function type
- llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
+ ::llvm::Type* accurate_ret_type = irb_.getJType(shorty[0]);
- std::vector<llvm::Type*> accurate_arg_types;
+ std::vector< ::llvm::Type*> accurate_arg_types;
accurate_arg_types.push_back(irb_.getJObjectTy()); // method
accurate_arg_types.push_back(irb_.getJObjectTy()); // this
@@ -207,39 +207,39 @@
accurate_arg_types.push_back(irb_.getJType(shorty[i]));
}
- llvm::FunctionType* accurate_func_type =
- llvm::FunctionType::get(accurate_ret_type, accurate_arg_types, false);
+ ::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_);
+ ::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);
+ func->addAttribute(0, ::llvm::Attribute::ZExt);
break;
case 'B':
case 'S':
- func->addAttribute(0, llvm::Attribute::SExt);
+ 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);
+ ::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());
+ ::llvm::AllocaInst* jvalue_temp = irb_.CreateAlloca(irb_.getJValueTy());
// Load actual arguments
- llvm::Function::arg_iterator arg_iter = func->arg_begin();
+ ::llvm::Function::arg_iterator arg_iter = func->arg_begin();
- std::vector<llvm::Value*> args;
+ std::vector< ::llvm::Value*> args;
args.push_back(arg_iter++); // method
args.push_back(arg_iter++); // this
args.push_back(irb_.Runtime().EmitGetCurrentThread()); // thread
@@ -257,9 +257,9 @@
irb_.CreateCall(irb_.GetRuntime(ProxyInvokeHandler), args);
if (shorty[0] != 'V') {
- llvm::Value* result_addr =
+ ::llvm::Value* result_addr =
irb_.CreateBitCast(jvalue_temp, accurate_ret_type->getPointerTo());
- llvm::Value* retval = irb_.CreateLoad(result_addr, kTBAAStackTemp);
+ ::llvm::Value* retval = irb_.CreateLoad(result_addr, kTBAAStackTemp);
irb_.CreateRet(retval);
} else {
irb_.CreateRetVoid();
@@ -275,5 +275,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/stub_compiler.h b/src/compiler/invoke_stubs/portable/stub_compiler.h
similarity index 92%
rename from src/compiler_llvm/stub_compiler.h
rename to src/compiler/invoke_stubs/portable/stub_compiler.h
index 63b283d..ceb8f58 100644
--- a/src/compiler_llvm/stub_compiler.h
+++ b/src/compiler/invoke_stubs/portable/stub_compiler.h
@@ -31,7 +31,7 @@
}
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class LlvmCompilationUnit;
class CompilerLLVM;
@@ -47,13 +47,13 @@
private:
LlvmCompilationUnit* cunit_;
const CompilerDriver* const driver_;
- llvm::Module* module_;
- llvm::LLVMContext* context_;
+ ::llvm::Module* module_;
+ ::llvm::LLVMContext* context_;
IRBuilder& irb_;
};
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/oat/jni/arm/jni_internal_arm.cc b/src/compiler/invoke_stubs/quick/jni_internal_arm.cc
similarity index 100%
rename from src/oat/jni/arm/jni_internal_arm.cc
rename to src/compiler/invoke_stubs/quick/jni_internal_arm.cc
diff --git a/src/oat/jni/mips/jni_internal_mips.cc b/src/compiler/invoke_stubs/quick/jni_internal_mips.cc
similarity index 100%
rename from src/oat/jni/mips/jni_internal_mips.cc
rename to src/compiler/invoke_stubs/quick/jni_internal_mips.cc
diff --git a/src/oat/jni/x86/jni_internal_x86.cc b/src/compiler/invoke_stubs/quick/jni_internal_x86.cc
similarity index 100%
rename from src/oat/jni/x86/jni_internal_x86.cc
rename to src/compiler/invoke_stubs/quick/jni_internal_x86.cc
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
similarity index 100%
rename from src/compiler_llvm/art_module.ll
rename to src/compiler/llvm/art_module.ll
diff --git a/src/compiler_llvm/backend_options.h b/src/compiler/llvm/backend_options.h
similarity index 96%
rename from src/compiler_llvm/backend_options.h
rename to src/compiler/llvm/backend_options.h
index bccf8a3..924a346 100644
--- a/src/compiler_llvm/backend_options.h
+++ b/src/compiler/llvm/backend_options.h
@@ -37,14 +37,14 @@
#include "llvm/Config/Targets.def"
namespace art {
-namespace compiler_llvm {
+namespace llvm {
inline void InitialBackendOptions() {
#define LLVM_TARGET(TargetName) INITIAL_##TargetName##_BACKEND_OPTIONS
#include "llvm/Config/Targets.def"
}
-} // namespace compiler_llvm
+} // 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
similarity index 97%
rename from src/compiler_llvm/backend_types.h
rename to src/compiler/llvm/backend_types.h
index cd889fa..09f6de7 100644
--- a/src/compiler_llvm/backend_types.h
+++ b/src/compiler/llvm/backend_types.h
@@ -21,7 +21,7 @@
namespace art {
-namespace compiler_llvm {
+namespace llvm {
enum JType {
@@ -139,7 +139,7 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/compiler_llvm.cc b/src/compiler/llvm/compiler_llvm.cc
similarity index 90%
rename from src/compiler_llvm/compiler_llvm.cc
rename to src/compiler/llvm/compiler_llvm.cc
index 3030dce..1c9a494 100644
--- a/src/compiler_llvm/compiler_llvm.cc
+++ b/src/compiler/llvm/compiler_llvm.cc
@@ -22,11 +22,11 @@
#include "compiled_method.h"
#include "compiler/driver/compiler_driver.h"
#include "compiler/driver/dex_compilation_unit.h"
-#include "ir_builder.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 "stub_compiler.h"
#include "utils_llvm.h"
#include "verifier/method_verifier.h"
@@ -62,7 +62,7 @@
//llvm::TimePassesIsEnabled = true;
// Initialize LLVM target-specific options.
- art::compiler_llvm::InitialBackendOptions();
+ art::llvm::InitialBackendOptions();
// Initialize LLVM target, MC subsystem, asm printer, and asm parser.
#if defined(ART_TARGET)
@@ -102,10 +102,10 @@
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-llvm::Module* makeLLVMModuleContents(llvm::Module* module);
+::llvm::Module* makeLLVMModuleContents(::llvm::Module* module);
CompilerLLVM::CompilerLLVM(CompilerDriver* driver, InstructionSet insn_set)
@@ -195,27 +195,26 @@
return stub_compiler->CreateProxyStub(shorty);
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
-inline static art::compiler_llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) {
+inline static art::llvm::CompilerLLVM* ContextOf(art::CompilerDriver& driver) {
void *compiler_context = driver.GetCompilerContext();
CHECK(compiler_context != NULL);
- return reinterpret_cast<art::compiler_llvm::CompilerLLVM*>(compiler_context);
+ return reinterpret_cast<art::llvm::CompilerLLVM*>(compiler_context);
}
-inline static const art::compiler_llvm::CompilerLLVM* ContextOf(const art::CompilerDriver& driver) {
+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::compiler_llvm::CompilerLLVM*>(compiler_context);
+ return reinterpret_cast<const art::llvm::CompilerLLVM*>(compiler_context);
}
extern "C" void ArtInitCompilerContext(art::CompilerDriver& driver) {
CHECK(driver.GetCompilerContext() == NULL);
- art::compiler_llvm::CompilerLLVM* compiler_llvm =
- new art::compiler_llvm::CompilerLLVM(&driver,
- driver.GetInstructionSet());
+ art::llvm::CompilerLLVM* compiler_llvm = new art::llvm::CompilerLLVM(&driver,
+ driver.GetInstructionSet());
driver.SetCompilerContext(compiler_llvm);
}
@@ -238,7 +237,7 @@
art::DexCompilationUnit dex_compilation_unit(
class_loader, class_linker, dex_file, code_item,
class_def_idx, method_idx, access_flags);
- art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+ art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
art::CompiledMethod* result = compiler_llvm->CompileDexMethod(&dex_compilation_unit, invoke_type);
return result;
}
@@ -252,7 +251,7 @@
NULL, class_linker, dex_file, NULL,
0, method_idx, access_flags);
- art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+ art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
art::CompiledMethod* result = compiler_llvm->CompileNativeMethod(&dex_compilation_unit);
return result;
}
@@ -261,7 +260,7 @@
bool is_static,
const char* shorty,
uint32_t shorty_len) {
- art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+ art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
art::CompiledInvokeStub* result = compiler_llvm->CreateInvokeStub(is_static, shorty);
return result;
}
@@ -269,7 +268,7 @@
extern "C" art::CompiledInvokeStub* ArtCreateProxyStub(art::CompilerDriver& driver,
const char* shorty,
uint32_t shorty_len) {
- art::compiler_llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
+ art::llvm::CompilerLLVM* compiler_llvm = ContextOf(driver);
art::CompiledInvokeStub* result = compiler_llvm->CreateProxyStub(shorty);
return result;
}
diff --git a/src/compiler_llvm/compiler_llvm.h b/src/compiler/llvm/compiler_llvm.h
similarity index 97%
rename from src/compiler_llvm/compiler_llvm.h
rename to src/compiler/llvm/compiler_llvm.h
index 0470f29..870a541 100644
--- a/src/compiler_llvm/compiler_llvm.h
+++ b/src/compiler/llvm/compiler_llvm.h
@@ -53,7 +53,7 @@
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class LlvmCompilationUnit;
class IRBuilder;
@@ -109,7 +109,7 @@
};
-} // namespace compiler_llvm
+} // 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
similarity index 100%
rename from src/compiler_llvm/compiler_runtime_func_list.h
rename to src/compiler/llvm/compiler_runtime_func_list.h
diff --git a/src/compiler_llvm/gbc_expander.cc b/src/compiler/llvm/gbc_expander.cc
similarity index 99%
rename from src/compiler_llvm/gbc_expander.cc
rename to src/compiler/llvm/gbc_expander.cc
index 16d71af..4e1a91d 100644
--- a/src/compiler_llvm/gbc_expander.cc
+++ b/src/compiler/llvm/gbc_expander.cc
@@ -40,9 +40,9 @@
#include <map>
#include <utility>
-using namespace art::compiler_llvm;
+using namespace art::llvm;
-using art::compiler_llvm::IntrinsicHelper;
+using art::llvm::IntrinsicHelper;
namespace art {
extern char RemapShorty(char shortyType);
@@ -3630,13 +3630,13 @@
} // anonymous namespace
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-llvm::FunctionPass*
+::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 compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/generated/art_module.cc b/src/compiler/llvm/generated/art_module.cc
similarity index 99%
rename from src/compiler_llvm/generated/art_module.cc
rename to src/compiler/llvm/generated/art_module.cc
index f794be1..2748cd6 100644
--- a/src/compiler_llvm/generated/art_module.cc
+++ b/src/compiler/llvm/generated/art_module.cc
@@ -15,7 +15,7 @@
using namespace llvm;
namespace art {
-namespace compiler_llvm {
+namespace llvm {
// Generated by llvm2cpp - DO NOT MODIFY!
@@ -1092,5 +1092,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/intrinsic_func_list.def b/src/compiler/llvm/intrinsic_func_list.def
similarity index 100%
rename from src/compiler_llvm/intrinsic_func_list.def
rename to src/compiler/llvm/intrinsic_func_list.def
diff --git a/src/compiler_llvm/intrinsic_helper.cc b/src/compiler/llvm/intrinsic_helper.cc
similarity index 80%
rename from src/compiler_llvm/intrinsic_helper.cc
rename to src/compiler/llvm/intrinsic_helper.cc
index 3bb6948..39c4a58 100644
--- a/src/compiler_llvm/intrinsic_helper.cc
+++ b/src/compiler/llvm/intrinsic_helper.cc
@@ -23,14 +23,21 @@
#include <llvm/Intrinsics.h>
#include <llvm/Support/IRBuilder.h>
-using namespace art;
-using namespace compiler_llvm;
+namespace art {
+namespace llvm {
-namespace {
+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"
+};
-inline llvm::Type*
-GetLLVMTypeOfIntrinsicValType(IRBuilder& irb,
- IntrinsicHelper::IntrinsicValType type) {
+static ::llvm::Type* GetLLVMTypeOfIntrinsicValType(IRBuilder& irb,
+ IntrinsicHelper::IntrinsicValType type) {
switch (type) {
case IntrinsicHelper::kVoidTy: {
return irb.getVoidTy();
@@ -82,23 +89,8 @@
// unreachable
}
-} // anonymous namespace
-
-namespace art {
-namespace compiler_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"
-};
-
-IntrinsicHelper::IntrinsicHelper(llvm::LLVMContext& context,
- llvm::Module& module) {
+IntrinsicHelper::IntrinsicHelper(::llvm::LLVMContext& context,
+ ::llvm::Module& module) {
IRBuilder irb(context, module, *this);
::memset(intrinsic_funcs_, 0, sizeof(intrinsic_funcs_));
@@ -113,7 +105,7 @@
const IntrinsicInfo& info = Info[i];
// Parse and construct the argument type from IntrinsicInfo
- llvm::Type* arg_type[kIntrinsicMaxArgc];
+ ::llvm::Type* arg_type[kIntrinsicMaxArgc];
unsigned num_args = 0;
bool is_var_arg = false;
for (unsigned arg_iter = 0; arg_iter < kIntrinsicMaxArgc; arg_iter++) {
@@ -131,18 +123,18 @@
}
// Construct the function type
- llvm::Type* ret_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);
+ ::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);
+ ::llvm::Function *fn = ::llvm::Function::Create(type,
+ ::llvm::Function::ExternalLinkage,
+ info.name_, &module);
fn->setOnlyReadsMemory(info.attr_ & kAttrReadOnly);
fn->setDoesNotAccessMemory(info.attr_ & kAttrReadNone);
@@ -151,15 +143,15 @@
intrinsic_funcs_[id] = fn;
- DCHECK_NE(fn, static_cast<llvm::Function*>(NULL)) << "Intrinsic `"
+ 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(),
+ 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);
+ arg_iter->addAttr(::llvm::Attribute::NoCapture);
+ arg_iter->addAttr(::llvm::Attribute::NoAlias);
}
}
@@ -172,5 +164,5 @@
return;
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/intrinsic_helper.h b/src/compiler/llvm/intrinsic_helper.h
similarity index 88%
rename from src/compiler_llvm/intrinsic_helper.h
rename to src/compiler/llvm/intrinsic_helper.h
index 319127d..49b8a95 100644
--- a/src/compiler_llvm/intrinsic_helper.h
+++ b/src/compiler/llvm/intrinsic_helper.h
@@ -26,10 +26,10 @@
class FunctionType;
class LLVMContext;
class Module;
-}
+} // namespace llvm
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class IRBuilder;
@@ -123,16 +123,16 @@
}
public:
- IntrinsicHelper(llvm::LLVMContext& context, llvm::Module& module);
+ IntrinsicHelper(::llvm::LLVMContext& context, ::llvm::Module& module);
- inline llvm::Function* GetIntrinsicFunction(IntrinsicId id) {
+ ::llvm::Function* GetIntrinsicFunction(IntrinsicId id) {
DCHECK(id >= 0 && id < MaxIntrinsicId) << "Unknown ART intrinsics ID: "
<< id;
return intrinsic_funcs_[id];
}
- inline IntrinsicId GetIntrinsicId(const llvm::Function* func) const {
- llvm::DenseMap<const llvm::Function*, IntrinsicId>::const_iterator
+ 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;
@@ -145,13 +145,13 @@
// 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];
+ ::llvm::Function* intrinsic_funcs_[MaxIntrinsicId + 1];
// Map a llvm::Function to its intrinsic id
- llvm::DenseMap<const llvm::Function*, IntrinsicId> intrinsic_funcs_map_;
+ ::llvm::DenseMap<const ::llvm::Function*, IntrinsicId> intrinsic_funcs_map_;
};
-} // namespace compiler_llvm
+} // 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
similarity index 79%
rename from src/compiler_llvm/ir_builder.cc
rename to src/compiler/llvm/ir_builder.cc
index 88af166..1fd1c90 100644
--- a/src/compiler_llvm/ir_builder.cc
+++ b/src/compiler/llvm/ir_builder.cc
@@ -21,24 +21,24 @@
#include <llvm/Module.h>
namespace art {
-namespace compiler_llvm {
+namespace llvm {
//----------------------------------------------------------------------------
// General
//----------------------------------------------------------------------------
-IRBuilder::IRBuilder(llvm::LLVMContext& context, llvm::Module& module,
+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");
+ ::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");
+ ::llvm::Type* type = module.getTypeByName("Method");
if (type != NULL) {
java_method_type_ = type->getPointerTo();
} else {
@@ -54,7 +54,7 @@
}
// Create JEnv* type
- llvm::Type* jenv_struct_type = llvm::StructType::create(context, "JEnv");
+ ::llvm::Type* jenv_struct_type = ::llvm::StructType::create(context, "JEnv");
jenv_type_ = jenv_struct_type->getPointerTo();
// Get Art shadow frame struct type from module
@@ -69,7 +69,7 @@
// Type Helper Function
//----------------------------------------------------------------------------
-llvm::Type* IRBuilder::getJType(JType jty) {
+::llvm::Type* IRBuilder::getJType(JType jty) {
switch (jty) {
case kVoid:
return getJVoidTy();
@@ -107,24 +107,24 @@
}
}
-llvm::StructType* IRBuilder::getShadowFrameTy(uint32_t vreg_size) {
+::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);
+ 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[] = {
+ ::llvm::Type* elem_types[] = {
art_frame_type_,
- llvm::ArrayType::get(getInt32Ty(), vreg_size),
+ ::llvm::ArrayType::get(getInt32Ty(), vreg_size),
};
- return llvm::StructType::create(elem_types, name);
+ return ::llvm::StructType::create(elem_types, name);
}
-} // namespace compiler_llvm
+} // 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
similarity index 81%
rename from src/compiler_llvm/llvm_compilation_unit.cc
rename to src/compiler/llvm/llvm_compilation_unit.cc
index d240bac..aad18fb 100644
--- a/src/compiler_llvm/llvm_compilation_unit.cc
+++ b/src/compiler/llvm/llvm_compilation_unit.cc
@@ -78,13 +78,13 @@
#include <string>
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-llvm::FunctionPass*
+::llvm::FunctionPass*
CreateGBCExpanderPass(const IntrinsicHelper& intrinsic_helper, IRBuilder& irb,
CompilerDriver* compiler, DexCompilationUnit* dex_compilation_unit);
-llvm::Module* makeLLVMModuleContents(llvm::Module* module);
+::llvm::Module* makeLLVMModuleContents(::llvm::Module* module);
LlvmCompilationUnit::LlvmCompilationUnit(const CompilerLLVM* compiler_llvm, size_t cunit_idx)
@@ -125,7 +125,7 @@
LlvmCompilationUnit::~LlvmCompilationUnit() {
- llvm::LLVMContext* llvm_context = context_.release(); // Managed by llvm_info_
+ ::llvm::LLVMContext* llvm_context = context_.release(); // Managed by llvm_info_
CHECK(llvm_context != NULL);
}
@@ -138,7 +138,7 @@
bool LlvmCompilationUnit::Materialize() {
std::string elf_image;
- // Compile and prelink llvm::Module
+ // Compile and prelink ::llvm::Module
if (!MaterializeToString(elf_image)) {
LOG(ERROR) << "Failed to materialize compilation unit " << cunit_idx_;
return false;
@@ -164,12 +164,12 @@
bool LlvmCompilationUnit::MaterializeToString(std::string& str_buffer) {
- llvm::raw_string_ostream str_os(str_buffer);
+ ::llvm::raw_string_ostream str_os(str_buffer);
return MaterializeToRawOStream(str_os);
}
-bool LlvmCompilationUnit::MaterializeToRawOStream(llvm::raw_ostream& out_stream) {
+bool LlvmCompilationUnit::MaterializeToRawOStream(::llvm::raw_ostream& out_stream) {
// Lookup the LLVM target
std::string target_triple;
std::string target_cpu;
@@ -177,37 +177,37 @@
CompilerDriver::InstructionSetToLLVMTarget(GetInstructionSet(), target_triple, target_cpu, target_attr);
std::string errmsg;
- const llvm::Target* target =
- llvm::TargetRegistry::lookupTarget(target_triple, 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;
+ ::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(
+ // 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));
+ ::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();
+ const ::llvm::TargetData* target_data = target_machine->getTargetData();
// PassManager for code generation passes
- llvm::PassManager pm;
- pm.add(new llvm::TargetData(*target_data));
+ ::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));
+ ::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
@@ -215,11 +215,11 @@
fpm.add(CreateGBCExpanderPass(*llvm_info_->GetIntrinsicHelper(), *irb_.get(),
driver_, dex_compilation_unit_));
} else {
- llvm::FunctionPassManager fpm2(module_);
+ ::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();
+ for (::llvm::Module::iterator F = module_->begin(), E = module_->end();
F != E; ++F) {
fpm2.run(*F);
}
@@ -228,9 +228,9 @@
// 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));
+ ::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()) {
@@ -238,32 +238,32 @@
return false;
}
- llvm::WriteBitcodeToFile(module_, out_file->os());
+ ::llvm::WriteBitcodeToFile(module_, out_file->os());
out_file->keep();
}
// Add optimization pass
- llvm::PassManagerBuilder pm_builder;
+ ::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.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());
+ pm.add(::llvm::createStripDeadPrototypesPass());
// Add passes to emit ELF image
{
- llvm::formatted_raw_ostream formatted_os(out_stream, false);
+ ::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,
+ ::llvm::TargetMachine::CGFT_ObjectFile,
true)) {
LOG(FATAL) << "Unable to generate ELF for this target";
return false;
@@ -271,7 +271,7 @@
// Run the per-function optimization
fpm.doInitialization();
- for (llvm::Module::iterator F = module_->begin(), E = module_->end();
+ for (::llvm::Module::iterator F = module_->begin(), E = module_->end();
F != E; ++F) {
fpm.run(*F);
}
@@ -293,18 +293,18 @@
return true;
}
- llvm::OwningPtr<llvm::MemoryBuffer> elf_image_buff(
- llvm::MemoryBuffer::getMemBuffer(llvm::StringRef(elf_image.data(),
+ ::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::OwningPtr< ::llvm::object::ObjectFile> elf_file(
+ ::llvm::object::ObjectFile::createELFObjectFile(elf_image_buff.take()));
- llvm::error_code ec;
+ ::llvm::error_code ec;
const ProcedureLinkageTable& plt = compiler_llvm_->GetProcedureLinkageTable();
- for (llvm::object::section_iterator
+ 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)) {
@@ -312,7 +312,7 @@
CHECK(ec == 0) << "Failed to read section because " << ec.message();
// Read the section information
- llvm::StringRef name;
+ ::llvm::StringRef name;
uint64_t alignment = 0u;
uint64_t size = 0u;
@@ -338,7 +338,7 @@
CheckCodeAlign(alignment);
// Copy the compiled code
- llvm::StringRef contents;
+ ::llvm::StringRef contents;
CHECK(sec_iter->getContents(contents) == 0);
copy(contents.data(),
@@ -346,7 +346,7 @@
back_inserter(compiled_code_));
// Prelink the compiled code
- for (llvm::object::relocation_iterator
+ 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)) {
@@ -354,7 +354,7 @@
CHECK(ec == 0) << "Failed to read relocation because " << ec.message();
// Read the relocation information
- llvm::object::SymbolRef sym_ref;
+ ::llvm::object::SymbolRef sym_ref;
uint64_t rel_offset = 0;
uint64_t rel_type = 0;
int64_t rel_addend = 0;
@@ -365,12 +365,12 @@
CHECK(rel_iter->getAdditionalInfo(rel_addend) == 0);
// Read the symbol related to this relocation fixup
- llvm::StringRef sym_name;
+ ::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(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());
@@ -416,5 +416,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/llvm_compilation_unit.h b/src/compiler/llvm/llvm_compilation_unit.h
similarity index 89%
rename from src/compiler_llvm/llvm_compilation_unit.h
rename to src/compiler/llvm/llvm_compilation_unit.h
index acdeb58..9ca9e3f 100644
--- a/src/compiler_llvm/llvm_compilation_unit.h
+++ b/src/compiler/llvm/llvm_compilation_unit.h
@@ -44,7 +44,7 @@
}
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class CompilerLLVM;
class IRBuilder;
@@ -59,11 +59,11 @@
InstructionSet GetInstructionSet() const;
- llvm::LLVMContext* GetLLVMContext() const {
+ ::llvm::LLVMContext* GetLLVMContext() const {
return context_.get();
}
- llvm::Module* GetModule() const {
+ ::llvm::Module* GetModule() const {
return module_;
}
@@ -103,10 +103,10 @@
const CompilerLLVM* compiler_llvm_;
const size_t cunit_idx_;
- UniquePtr<llvm::LLVMContext> context_;
+ UniquePtr< ::llvm::LLVMContext> context_;
UniquePtr<IRBuilder> irb_;
UniquePtr<RuntimeSupportBuilder> runtime_support_;
- llvm::Module* module_; // Managed by context_
+ ::llvm::Module* module_; // Managed by context_
UniquePtr<IntrinsicHelper> intrinsic_helper_;
UniquePtr<LLVMInfo> llvm_info_;
CompilerDriver* driver_;
@@ -116,19 +116,19 @@
std::vector<uint8_t> compiled_code_;
- SafeMap<const llvm::Function*, CompiledMethod*> compiled_methods_map_;
+ 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 MaterializeToRawOStream(::llvm::raw_ostream& out_stream);
bool ExtractCodeAndPrelink(const std::string& elf_image);
friend class CompilerLLVM; // For LlvmCompilationUnit constructor
};
-} // namespace compiler_llvm
+} // 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
similarity index 90%
rename from src/compiler_llvm/md_builder.cc
rename to src/compiler/llvm/md_builder.cc
index 038e133..afb3611 100644
--- a/src/compiler_llvm/md_builder.cc
+++ b/src/compiler/llvm/md_builder.cc
@@ -22,15 +22,15 @@
#include <string>
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-llvm::MDNode* MDBuilder::GetTBAASpecialType(TBAASpecialType sty_id) {
+::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];
+ ::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;
@@ -52,7 +52,7 @@
return spec_ty;
}
-llvm::MDNode* MDBuilder::GetTBAAMemoryJType(TBAASpecialType sty_id, JType jty_id) {
+::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";
@@ -72,7 +72,7 @@
break;
}
- llvm::MDNode*& spec_ty = tbaa_memory_jtype_[sty_mapped_index][jty_id];
+ ::llvm::MDNode*& spec_ty = tbaa_memory_jtype_[sty_mapped_index][jty_id];
if (spec_ty != NULL) {
return spec_ty;
}
@@ -97,5 +97,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/md_builder.h b/src/compiler/llvm/md_builder.h
similarity index 73%
rename from src/compiler_llvm/md_builder.h
rename to src/compiler/llvm/md_builder.h
index 5b02500..5231c14 100644
--- a/src/compiler_llvm/md_builder.h
+++ b/src/compiler/llvm/md_builder.h
@@ -29,14 +29,14 @@
}
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-typedef llvm::MDBuilder LLVMMDBuilder;
+typedef ::llvm::MDBuilder LLVMMDBuilder;
class MDBuilder : public LLVMMDBuilder {
public:
- MDBuilder(llvm::LLVMContext& context) : LLVMMDBuilder(context) {
- tbaa_root_ = createTBAARoot("Art TBAA Root");
+ 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_));
@@ -46,26 +46,26 @@
expect_cond_[kUnlikely] = createBranchWeights(4, 64);
}
- llvm::MDNode* GetTBAASpecialType(TBAASpecialType special_ty);
- llvm::MDNode* GetTBAAMemoryJType(TBAASpecialType special_ty, JType j_ty);
+ ::llvm::MDNode* GetTBAASpecialType(TBAASpecialType special_ty);
+ ::llvm::MDNode* GetTBAAMemoryJType(TBAASpecialType special_ty, JType j_ty);
- llvm::MDNode* GetBranchWeights(ExpectCond expect) {
+ ::llvm::MDNode* GetBranchWeights(ExpectCond expect) {
DCHECK_LT(expect, MAX_EXPECT) << "MAX_EXPECT is not for branch weight";
return expect_cond_[expect];
}
private:
- llvm::MDNode* tbaa_root_;
- llvm::MDNode* tbaa_special_type_[MAX_TBAA_SPECIAL_TYPE];
+ ::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* tbaa_memory_jtype_[3][MAX_JTYPE];
- llvm::MDNode* expect_cond_[MAX_EXPECT];
+ ::llvm::MDNode* expect_cond_[MAX_EXPECT];
};
-} // namespace compiler_llvm
+} // 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
similarity index 99%
rename from src/compiler_llvm/procedure_linkage_table.cc
rename to src/compiler/llvm/procedure_linkage_table.cc
index b78db4e..47ba9bd 100644
--- a/src/compiler_llvm/procedure_linkage_table.cc
+++ b/src/compiler/llvm/procedure_linkage_table.cc
@@ -74,7 +74,7 @@
namespace art {
-namespace compiler_llvm {
+namespace llvm {
ProcedureLinkageTable::ProcedureLinkageTable(InstructionSet insn_set)
@@ -322,5 +322,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/procedure_linkage_table.h b/src/compiler/llvm/procedure_linkage_table.h
similarity index 97%
rename from src/compiler_llvm/procedure_linkage_table.h
rename to src/compiler/llvm/procedure_linkage_table.h
index 26c31ae..1c89d29 100644
--- a/src/compiler_llvm/procedure_linkage_table.h
+++ b/src/compiler/llvm/procedure_linkage_table.h
@@ -27,7 +27,7 @@
#include <stdint.h>
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class ProcedureLinkageTable {
@@ -79,7 +79,7 @@
};
-} // namespace compiler_llvm
+} // 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
similarity index 87%
rename from src/compiler_llvm/runtime_support_builder.cc
rename to src/compiler/llvm/runtime_support_builder.cc
index e661ec4..4548d18 100644
--- a/src/compiler_llvm/runtime_support_builder.cc
+++ b/src/compiler/llvm/runtime_support_builder.cc
@@ -30,20 +30,20 @@
using namespace llvm;
namespace art {
-namespace compiler_llvm {
+namespace llvm {
using namespace runtime_support;
-RuntimeSupportBuilder::RuntimeSupportBuilder(llvm::LLVMContext& context,
- llvm::Module& module,
+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); \
+ ::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);
@@ -57,7 +57,7 @@
/* Thread */
-llvm::Value* RuntimeSupportBuilder::EmitGetCurrentThread() {
+::llvm::Value* RuntimeSupportBuilder::EmitGetCurrentThread() {
Function* func = GetRuntimeSupportFunction(runtime_support::GetCurrentThread);
CallInst* call_inst = irb_.CreateCall(func);
call_inst->setOnlyReadsMemory();
@@ -65,19 +65,19 @@
return call_inst;
}
-llvm::Value* RuntimeSupportBuilder::EmitLoadFromThreadOffset(int64_t offset, llvm::Type* type,
+::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,
+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) {
+::llvm::Value* RuntimeSupportBuilder::EmitSetCurrentThread(::llvm::Value* thread) {
Function* func = GetRuntimeSupportFunction(runtime_support::SetCurrentThread);
return irb_.CreateCall(func, thread);
}
@@ -85,8 +85,8 @@
/* ShadowFrame */
-llvm::Value* RuntimeSupportBuilder::EmitPushShadowFrame(llvm::Value* new_shadow_frame,
- llvm::Value* method,
+::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(),
@@ -116,12 +116,12 @@
return old_shadow_frame;
}
-llvm::Value*
-RuntimeSupportBuilder::EmitPushShadowFrameNoInline(llvm::Value* new_shadow_frame,
- llvm::Value* method,
+::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 =
+ ::llvm::CallInst* call_inst =
irb_.CreateCall4(func,
EmitGetCurrentThread(),
new_shadow_frame,
@@ -131,7 +131,7 @@
return call_inst;
}
-void RuntimeSupportBuilder::EmitPopShadowFrame(llvm::Value* old_shadow_frame) {
+void RuntimeSupportBuilder::EmitPopShadowFrame(::llvm::Value* old_shadow_frame) {
// Store old shadow frame to TopShadowFrame
EmitStoreToThreadOffset(Thread::TopShadowFrameOffset().Int32Value(),
old_shadow_frame,
@@ -141,12 +141,12 @@
/* Exception */
-llvm::Value* RuntimeSupportBuilder::EmitGetAndClearException() {
+::llvm::Value* RuntimeSupportBuilder::EmitGetAndClearException() {
Function* slow_func = GetRuntimeSupportFunction(runtime_support::GetAndClearException);
return irb_.CreateCall(slow_func, EmitGetCurrentThread());
}
-llvm::Value* RuntimeSupportBuilder::EmitIsExceptionPending() {
+::llvm::Value* RuntimeSupportBuilder::EmitIsExceptionPending() {
Value* exception = EmitLoadFromThreadOffset(Thread::ExceptionOffset().Int32Value(),
irb_.getJObjectTy(),
kTBAARuntimeInfo);
@@ -166,7 +166,7 @@
/* Monitor */
-void RuntimeSupportBuilder::EmitLockObject(llvm::Value* object) {
+void RuntimeSupportBuilder::EmitLockObject(::llvm::Value* object) {
Value* monitor =
irb_.LoadFromObjectOffset(object,
mirror::Object::MonitorOffset().Int32Value(),
@@ -212,7 +212,7 @@
irb_.SetInsertPoint(bb_cont);
}
-void RuntimeSupportBuilder::EmitUnlockObject(llvm::Value* object) {
+void RuntimeSupportBuilder::EmitUnlockObject(::llvm::Value* object) {
Value* lock_id =
EmitLoadFromThreadOffset(Thread::ThinLockIdOffset().Int32Value(),
irb_.getJIntTy(),
@@ -253,12 +253,12 @@
}
-void RuntimeSupportBuilder::EmitMarkGCCard(llvm::Value* value, llvm::Value* target_addr) {
+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);
+ ::llvm::Value* not_null = irb_.CreateIsNotNull(value);
irb_.CreateCondBr(not_null, bb_mark_gc_card, bb_cont);
irb_.SetInsertPoint(bb_mark_gc_card);
@@ -275,5 +275,5 @@
}
-} // namespace compiler_llvm
+} // 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
similarity index 88%
rename from src/compiler_llvm/runtime_support_builder_arm.cc
rename to src/compiler/llvm/runtime_support_builder_arm.cc
index 7a166ad..753ae9a 100644
--- a/src/compiler_llvm/runtime_support_builder_arm.cc
+++ b/src/compiler/llvm/runtime_support_builder_arm.cc
@@ -32,10 +32,10 @@
namespace {
-char LDRSTRSuffixByType(art::compiler_llvm::IRBuilder& irb, llvm::Type* type) {
+char LDRSTRSuffixByType(art::llvm::IRBuilder& irb, ::llvm::Type* type) {
int width = type->isPointerTy() ?
irb.getSizeOfPtrEquivInt()*8 :
- llvm::cast<IntegerType>(type)->getBitWidth();
+ ::llvm::cast<IntegerType>(type)->getBitWidth();
switch (width) {
case 8: return 'b';
case 16: return 'h';
@@ -49,11 +49,11 @@
} // namespace
namespace art {
-namespace compiler_llvm {
+namespace llvm {
/* Thread */
-llvm::Value* RuntimeSupportBuilderARM::EmitGetCurrentThread() {
+::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);
@@ -62,7 +62,7 @@
return thread;
}
-llvm::Value* RuntimeSupportBuilderARM::EmitLoadFromThreadOffset(int64_t offset, llvm::Type* type,
+::llvm::Value* RuntimeSupportBuilderARM::EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
TBAASpecialType s_ty) {
FunctionType* func_ty = FunctionType::get(/*Result=*/type,
/*isVarArg=*/false);
@@ -76,7 +76,7 @@
return result;
}
-void RuntimeSupportBuilderARM::EmitStoreToThreadOffset(int64_t offset, llvm::Value* value,
+void RuntimeSupportBuilderARM::EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
TBAASpecialType s_ty) {
FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
/*Params=*/value->getType(),
@@ -89,8 +89,8 @@
irb_.SetTBAA(call_inst, s_ty);
}
-llvm::Value*
-RuntimeSupportBuilderARM::EmitSetCurrentThread(llvm::Value* thread) {
+::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.
@@ -114,7 +114,7 @@
/* Monitor */
-void RuntimeSupportBuilderARM::EmitLockObject(llvm::Value* object) {
+void RuntimeSupportBuilderARM::EmitLockObject(::llvm::Value* object) {
RuntimeSupportBuilder::EmitLockObject(object);
FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
/*isVarArg=*/false);
@@ -122,7 +122,7 @@
irb_.CreateCall(func);
}
-void RuntimeSupportBuilderARM::EmitUnlockObject(llvm::Value* object) {
+void RuntimeSupportBuilderARM::EmitUnlockObject(::llvm::Value* object) {
RuntimeSupportBuilder::EmitUnlockObject(object);
FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
/*isVarArg=*/false);
@@ -130,5 +130,5 @@
irb_.CreateCall(func);
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/runtime_support_builder_arm.h b/src/compiler/llvm/runtime_support_builder_arm.h
similarity index 69%
rename from src/compiler_llvm/runtime_support_builder_arm.h
rename to src/compiler/llvm/runtime_support_builder_arm.h
index 264689b..3c5972f 100644
--- a/src/compiler_llvm/runtime_support_builder_arm.h
+++ b/src/compiler/llvm/runtime_support_builder_arm.h
@@ -20,27 +20,27 @@
#include "runtime_support_builder.h"
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class RuntimeSupportBuilderARM : public RuntimeSupportBuilder {
public:
- RuntimeSupportBuilderARM(llvm::LLVMContext& context, llvm::Module& module, IRBuilder& irb)
+ 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,
+ 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,
+ virtual void EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
TBAASpecialType s_ty);
- virtual llvm::Value* EmitSetCurrentThread(llvm::Value* thread);
+ virtual ::llvm::Value* EmitSetCurrentThread(::llvm::Value* thread);
/* Monitor */
- virtual void EmitLockObject(llvm::Value* object);
- virtual void EmitUnlockObject(llvm::Value* object);
+ virtual void EmitLockObject(::llvm::Value* object);
+ virtual void EmitUnlockObject(::llvm::Value* object);
};
-} // namespace compiler_llvm
+} // 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
similarity index 91%
rename from src/compiler_llvm/runtime_support_builder_thumb2.cc
rename to src/compiler/llvm/runtime_support_builder_thumb2.cc
index 4113c1b..c16717b 100644
--- a/src/compiler_llvm/runtime_support_builder_thumb2.cc
+++ b/src/compiler/llvm/runtime_support_builder_thumb2.cc
@@ -34,10 +34,10 @@
using namespace llvm;
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-void RuntimeSupportBuilderThumb2::EmitLockObject(llvm::Value* object) {
+void RuntimeSupportBuilderThumb2::EmitLockObject(::llvm::Value* object) {
FunctionType* func_ty = FunctionType::get(/*Result=*/irb_.getInt32Ty(),
/*Params=*/irb_.getJObjectTy(),
/*isVarArg=*/false);
@@ -58,10 +58,10 @@
InlineAsm* func = InlineAsm::get(func_ty, asms, "=&l,l,~l,~l", true);
- llvm::Value* retry_slow_path = irb_.CreateCall(func, object);
+ ::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();
+ ::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);
@@ -81,5 +81,5 @@
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/runtime_support_builder_thumb2.h b/src/compiler/llvm/runtime_support_builder_thumb2.h
similarity index 83%
rename from src/compiler_llvm/runtime_support_builder_thumb2.h
rename to src/compiler/llvm/runtime_support_builder_thumb2.h
index 3ac0b9f..4762a26 100644
--- a/src/compiler_llvm/runtime_support_builder_thumb2.h
+++ b/src/compiler/llvm/runtime_support_builder_thumb2.h
@@ -20,18 +20,18 @@
#include "runtime_support_builder_arm.h"
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class RuntimeSupportBuilderThumb2 : public RuntimeSupportBuilderARM {
public:
- RuntimeSupportBuilderThumb2(llvm::LLVMContext& context, llvm::Module& module, IRBuilder& irb)
+ RuntimeSupportBuilderThumb2(::llvm::LLVMContext& context, ::llvm::Module& module, IRBuilder& irb)
: RuntimeSupportBuilderARM(context, module, irb) {}
/* Monitor */
- virtual void EmitLockObject(llvm::Value* object);
+ virtual void EmitLockObject(::llvm::Value* object);
};
-} // namespace compiler_llvm
+} // 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
similarity index 86%
rename from src/compiler_llvm/runtime_support_builder_x86.cc
rename to src/compiler/llvm/runtime_support_builder_x86.cc
index 0eb38af..cd00b0b 100644
--- a/src/compiler_llvm/runtime_support_builder_x86.cc
+++ b/src/compiler/llvm/runtime_support_builder_x86.cc
@@ -32,10 +32,10 @@
using namespace llvm;
namespace art {
-namespace compiler_llvm {
+namespace llvm {
-llvm::Value* RuntimeSupportBuilderX86::EmitGetCurrentThread() {
+::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);
@@ -45,7 +45,7 @@
return thread;
}
-llvm::Value* RuntimeSupportBuilderX86::EmitLoadFromThreadOffset(int64_t offset, llvm::Type* type,
+::llvm::Value* RuntimeSupportBuilderX86::EmitLoadFromThreadOffset(int64_t offset, ::llvm::Type* type,
TBAASpecialType s_ty) {
FunctionType* func_ty = FunctionType::get(/*Result=*/type,
/*isVarArg=*/false);
@@ -57,7 +57,7 @@
return result;
}
-void RuntimeSupportBuilderX86::EmitStoreToThreadOffset(int64_t offset, llvm::Value* value,
+void RuntimeSupportBuilderX86::EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
TBAASpecialType s_ty) {
FunctionType* func_ty = FunctionType::get(/*Result=*/Type::getVoidTy(context_),
/*Params=*/value->getType(),
@@ -68,11 +68,11 @@
irb_.SetTBAA(call_inst, s_ty);
}
-llvm::Value* RuntimeSupportBuilderX86::EmitSetCurrentThread(llvm::Value*) {
+::llvm::Value* RuntimeSupportBuilderX86::EmitSetCurrentThread(::llvm::Value*) {
/* Nothing to be done. */
- return llvm::UndefValue::get(irb_.getJObjectTy());
+ return ::llvm::UndefValue::get(irb_.getJObjectTy());
}
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art
diff --git a/src/compiler_llvm/runtime_support_builder_x86.h b/src/compiler/llvm/runtime_support_builder_x86.h
similarity index 73%
rename from src/compiler_llvm/runtime_support_builder_x86.h
rename to src/compiler/llvm/runtime_support_builder_x86.h
index 29a7d88..e5fdbc2 100644
--- a/src/compiler_llvm/runtime_support_builder_x86.h
+++ b/src/compiler/llvm/runtime_support_builder_x86.h
@@ -20,23 +20,23 @@
#include "runtime_support_builder.h"
namespace art {
-namespace compiler_llvm {
+namespace llvm {
class RuntimeSupportBuilderX86 : public RuntimeSupportBuilder {
public:
- RuntimeSupportBuilderX86(llvm::LLVMContext& context, llvm::Module& module, IRBuilder& irb)
+ 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,
+ 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,
+ virtual void EmitStoreToThreadOffset(int64_t offset, ::llvm::Value* value,
TBAASpecialType s_ty);
- virtual llvm::Value* EmitSetCurrentThread(llvm::Value* thread);
+ virtual ::llvm::Value* EmitSetCurrentThread(::llvm::Value* thread);
};
-} // namespace compiler_llvm
+} // 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
similarity index 95%
rename from src/compiler_llvm/runtime_support_func.h
rename to src/compiler/llvm/runtime_support_func.h
index de3ed26..6dfa961 100644
--- a/src/compiler_llvm/runtime_support_func.h
+++ b/src/compiler/llvm/runtime_support_func.h
@@ -18,7 +18,7 @@
#define ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_FUNC_H_
namespace art {
-namespace compiler_llvm {
+namespace llvm {
namespace runtime_support {
enum RuntimeId {
@@ -32,7 +32,7 @@
};
} // namespace runtime_support
-} // namespace compiler_llvm
+} // 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
similarity index 100%
rename from src/compiler_llvm/runtime_support_func_list.h
rename to src/compiler/llvm/runtime_support_func_list.h
diff --git a/src/compiler_llvm/runtime_support_llvm.cc b/src/compiler/llvm/runtime_support_llvm.cc
similarity index 100%
rename from src/compiler_llvm/runtime_support_llvm.cc
rename to src/compiler/llvm/runtime_support_llvm.cc
diff --git a/src/compiler_llvm/runtime_support_llvm.h b/src/compiler/llvm/runtime_support_llvm.h
similarity index 100%
rename from src/compiler_llvm/runtime_support_llvm.h
rename to 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
similarity index 95%
rename from src/compiler_llvm/tools/gen_art_module_cc.sh
rename to src/compiler/llvm/tools/gen_art_module_cc.sh
index 46360af..b691bbf 100755
--- a/src/compiler_llvm/tools/gen_art_module_cc.sh
+++ b/src/compiler/llvm/tools/gen_art_module_cc.sh
@@ -39,12 +39,12 @@
using namespace llvm;
namespace art {
-namespace compiler_llvm {
+namespace llvm {
' >> ${OUTPUT_FILE}
llc -march=cpp -cppgen=contents art_module.ll -o - >> ${OUTPUT_FILE}
echo '
-} // namespace compiler_llvm
+} // namespace llvm
} // namespace art' >> ${OUTPUT_FILE}
diff --git a/src/compiler_llvm/utils_llvm.h b/src/compiler/llvm/utils_llvm.h
similarity index 92%
rename from src/compiler_llvm/utils_llvm.h
rename to src/compiler/llvm/utils_llvm.h
index d3b31d8..e06e113 100644
--- a/src/compiler_llvm/utils_llvm.h
+++ b/src/compiler/llvm/utils_llvm.h
@@ -27,7 +27,7 @@
namespace art {
#ifndef NDEBUG
-#define VERIFY_LLVM_FUNCTION(func) llvm::verifyFunction(func, llvm::AbortProcessAction)
+#define VERIFY_LLVM_FUNCTION(func) ::llvm::verifyFunction(func, ::llvm::AbortProcessAction)
#else
#define VERIFY_LLVM_FUNCTION(func)
#endif
diff --git a/src/compiler_llvm/ir_builder.h b/src/compiler_llvm/ir_builder.h
deleted file mode 100644
index e722c68..0000000
--- a/src/compiler_llvm/ir_builder.h
+++ /dev/null
@@ -1,485 +0,0 @@
-/*
- * 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 compiler_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 compiler_llvm
-} // namespace art
-
-#endif // ART_SRC_COMPILER_LLVM_IR_BUILDER_H_
diff --git a/src/compiler_llvm/runtime_support_builder.h b/src/compiler_llvm/runtime_support_builder.h
deleted file mode 100644
index 7c11702..0000000
--- a/src/compiler_llvm/runtime_support_builder.h
+++ /dev/null
@@ -1,98 +0,0 @@
-/*
- * 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 compiler_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 compiler_llvm
-} // namespace art
-
-#endif // ART_SRC_COMPILER_LLVM_RUNTIME_SUPPORT_BUILDER_H_
diff --git a/src/elf_file.h b/src/elf_file.h
index 2c49f32..b1d787e 100644
--- a/src/elf_file.h
+++ b/src/elf_file.h
@@ -55,30 +55,30 @@
return map_->Size();
}
- llvm::ELF::Elf32_Ehdr& GetHeader();
+ ::llvm::ELF::Elf32_Ehdr& GetHeader();
- llvm::ELF::Elf32_Word GetProgramHeaderNum();
- llvm::ELF::Elf32_Phdr& GetProgramHeader(llvm::ELF::Elf32_Word);
- llvm::ELF::Elf32_Phdr* FindProgamHeaderByType(llvm::ELF::Elf32_Word type);
+ ::llvm::ELF::Elf32_Word GetProgramHeaderNum();
+ ::llvm::ELF::Elf32_Phdr& GetProgramHeader(::llvm::ELF::Elf32_Word);
+ ::llvm::ELF::Elf32_Phdr* FindProgamHeaderByType(::llvm::ELF::Elf32_Word type);
- llvm::ELF::Elf32_Word GetSectionHeaderNum();
- llvm::ELF::Elf32_Shdr& GetSectionHeader(llvm::ELF::Elf32_Word);
- llvm::ELF::Elf32_Shdr* FindSectionByType(llvm::ELF::Elf32_Word type);
+ ::llvm::ELF::Elf32_Word GetSectionHeaderNum();
+ ::llvm::ELF::Elf32_Shdr& GetSectionHeader(::llvm::ELF::Elf32_Word);
+ ::llvm::ELF::Elf32_Shdr* FindSectionByType(::llvm::ELF::Elf32_Word type);
byte* FindDynamicSymbolAddress(const std::string& symbol_name);
- static bool IsSymbolSectionType(llvm::ELF::Elf32_Word section_type);
- llvm::ELF::Elf32_Word GetSymbolNum(llvm::ELF::Elf32_Shdr&);
- llvm::ELF::Elf32_Sym& GetSymbol(llvm::ELF::Elf32_Word section_type, llvm::ELF::Elf32_Word i);
- llvm::ELF::Elf32_Sym* FindSymbolByName(llvm::ELF::Elf32_Word section_type,
+ static bool IsSymbolSectionType(::llvm::ELF::Elf32_Word section_type);
+ ::llvm::ELF::Elf32_Word GetSymbolNum(::llvm::ELF::Elf32_Shdr&);
+ ::llvm::ELF::Elf32_Sym& GetSymbol(::llvm::ELF::Elf32_Word section_type, ::llvm::ELF::Elf32_Word i);
+ ::llvm::ELF::Elf32_Sym* FindSymbolByName(::llvm::ELF::Elf32_Word section_type,
const std::string& symbol_name);
- llvm::ELF::Elf32_Addr FindSymbolAddress(llvm::ELF::Elf32_Word section_type,
+ ::llvm::ELF::Elf32_Addr FindSymbolAddress(::llvm::ELF::Elf32_Word section_type,
const std::string& symbol_name);
- char* GetString(llvm::ELF::Elf32_Shdr&, llvm::ELF::Elf32_Word);
+ char* GetString(::llvm::ELF::Elf32_Shdr&, ::llvm::ELF::Elf32_Word);
- llvm::ELF::Elf32_Word GetDynamicNum();
- llvm::ELF::Elf32_Dyn& GetDynamic(llvm::ELF::Elf32_Word);
+ ::llvm::ELF::Elf32_Word GetDynamicNum();
+ ::llvm::ELF::Elf32_Dyn& GetDynamic(::llvm::ELF::Elf32_Word);
// Returns the expected size when the file is loaded at runtime
size_t GetLoadedSize();
@@ -95,21 +95,21 @@
byte* GetProgramHeadersStart();
byte* GetSectionHeadersStart();
- llvm::ELF::Elf32_Phdr& GetDynamicProgramHeader();
- llvm::ELF::Elf32_Dyn* GetDynamicSectionStart();
- llvm::ELF::Elf32_Sym* GetSymbolSectionStart(llvm::ELF::Elf32_Word section_type);
- char* GetSymbolStringSectionStart(llvm::ELF::Elf32_Word section_type);
- llvm::ELF::Elf32_Word* GetHashSectionStart();
- llvm::ELF::Elf32_Word GetHashBucketNum();
- llvm::ELF::Elf32_Word GetHashChainNum();
- llvm::ELF::Elf32_Word GetHashBucket(size_t i);
- llvm::ELF::Elf32_Word GetHashChain(size_t i);
+ ::llvm::ELF::Elf32_Phdr& GetDynamicProgramHeader();
+ ::llvm::ELF::Elf32_Dyn* GetDynamicSectionStart();
+ ::llvm::ELF::Elf32_Sym* GetSymbolSectionStart(::llvm::ELF::Elf32_Word section_type);
+ char* GetSymbolStringSectionStart(::llvm::ELF::Elf32_Word section_type);
+ ::llvm::ELF::Elf32_Word* GetHashSectionStart();
+ ::llvm::ELF::Elf32_Word GetHashBucketNum();
+ ::llvm::ELF::Elf32_Word GetHashChainNum();
+ ::llvm::ELF::Elf32_Word GetHashBucket(size_t i);
+ ::llvm::ELF::Elf32_Word GetHashChain(size_t i);
File* file_;
bool writable_;
bool program_header_only_;
UniquePtr<MemMap> map_;
- llvm::ELF::Elf32_Ehdr* header_;
+ ::llvm::ELF::Elf32_Ehdr* header_;
std::vector<MemMap*> segments_;
byte* base_address_;
@@ -118,13 +118,13 @@
// Conditionally available values. Use accessors to ensure they exist if they are required.
byte* section_headers_start_;
- llvm::ELF::Elf32_Phdr* dynamic_program_header_;
- llvm::ELF::Elf32_Dyn* dynamic_section_start_;
- llvm::ELF::Elf32_Sym* symtab_section_start_;
- llvm::ELF::Elf32_Sym* dynsym_section_start_;
+ ::llvm::ELF::Elf32_Phdr* dynamic_program_header_;
+ ::llvm::ELF::Elf32_Dyn* dynamic_section_start_;
+ ::llvm::ELF::Elf32_Sym* symtab_section_start_;
+ ::llvm::ELF::Elf32_Sym* dynsym_section_start_;
char* strtab_section_start_;
char* dynstr_section_start_;
- llvm::ELF::Elf32_Word* hash_section_start_;
+ ::llvm::ELF::Elf32_Word* hash_section_start_;
};
diff --git a/src/elf_writer.cc b/src/elf_writer.cc
index 3fdb8e4..106ad44 100644
--- a/src/elf_writer.cc
+++ b/src/elf_writer.cc
@@ -47,11 +47,11 @@
static void InitializeLLVM() {
// TODO: this is lifted from art's compiler_llvm.cc, should be factored out
#if defined(ART_TARGET)
- llvm::InitializeNativeTarget();
+ ::llvm::InitializeNativeTarget();
// TODO: odd that there is no InitializeNativeTargetMC?
#else
- llvm::InitializeAllTargets();
- llvm::InitializeAllTargetMCs();
+ ::llvm::InitializeAllTargets();
+ ::llvm::InitializeAllTargetMCs();
#endif
}
@@ -124,7 +124,7 @@
mcld::LDSection* null_section = ir_builder->CreateELFHeader(*input,
"",
mcld::LDFileFormat::Null,
- llvm::ELF::SHT_NULL,
+ ::llvm::ELF::SHT_NULL,
0);
CHECK(null_section != NULL);
@@ -142,9 +142,9 @@
// TODO: ownership of text_section?
mcld::LDSection* text_section = ir_builder->CreateELFHeader(*input,
".text",
- llvm::ELF::SHT_PROGBITS,
- llvm::ELF::SHF_EXECINSTR
- | llvm::ELF::SHF_ALLOC,
+ ::llvm::ELF::SHT_PROGBITS,
+ ::llvm::ELF::SHF_EXECINSTR
+ | ::llvm::ELF::SHF_ALLOC,
alignment);
CHECK(text_section != NULL);
@@ -210,10 +210,10 @@
CHECK(elf_file.get() != NULL);
// Lookup "oatdata" symbol address.
- llvm::ELF::Elf32_Addr oatdata_address = elf_file->FindSymbolAddress(llvm::ELF::SHT_DYNSYM,
- "oatdata");
+ ::llvm::ELF::Elf32_Addr oatdata_address = elf_file->FindSymbolAddress(::llvm::ELF::SHT_DYNSYM,
+ "oatdata");
CHECK_NE(0U, oatdata_address);
- llvm::ELF::Elf32_Off base_address = oat_data_begin - oatdata_address;
+ ::llvm::ELF::Elf32_Off base_address = oat_data_begin - oatdata_address;
if (!FixupDynamic(*elf_file.get(), base_address)) {
LOG(WARNING) << "Failed fo fixup .dynamic in " << file->GetPath();
@@ -240,27 +240,27 @@
bool ElfWriter::FixupDynamic(ElfFile& elf_file, uintptr_t base_address) {
// TODO: C++0x auto.
- for (llvm::ELF::Elf32_Word i = 0; i < elf_file.GetDynamicNum(); i++) {
- llvm::ELF::Elf32_Dyn& elf_dyn = elf_file.GetDynamic(i);
+ for (::llvm::ELF::Elf32_Word i = 0; i < elf_file.GetDynamicNum(); i++) {
+ ::llvm::ELF::Elf32_Dyn& elf_dyn = elf_file.GetDynamic(i);
bool elf_dyn_needs_fixup = false;
// case 1: if Elf32_Dyn.d_tag implies Elf32_Dyn.d_un contains an address in d_ptr
switch (elf_dyn.d_tag) {
- case llvm::ELF::DT_PLTGOT:
- case llvm::ELF::DT_HASH:
- case llvm::ELF::DT_STRTAB:
- case llvm::ELF::DT_SYMTAB:
- case llvm::ELF::DT_RELA:
- case llvm::ELF::DT_INIT:
- case llvm::ELF::DT_FINI:
- case llvm::ELF::DT_REL:
- case llvm::ELF::DT_DEBUG:
- case llvm::ELF::DT_JMPREL: {
+ case ::llvm::ELF::DT_PLTGOT:
+ case ::llvm::ELF::DT_HASH:
+ case ::llvm::ELF::DT_STRTAB:
+ case ::llvm::ELF::DT_SYMTAB:
+ case ::llvm::ELF::DT_RELA:
+ case ::llvm::ELF::DT_INIT:
+ case ::llvm::ELF::DT_FINI:
+ case ::llvm::ELF::DT_REL:
+ case ::llvm::ELF::DT_DEBUG:
+ case ::llvm::ELF::DT_JMPREL: {
elf_dyn_needs_fixup = true;
break;
}
default: {
// case 2: if d_tag is even and greater than > DT_ENCODING
- if ((elf_dyn.d_tag > llvm::ELF::DT_ENCODING) && ((elf_dyn.d_tag % 2) == 0)) {
+ if ((elf_dyn.d_tag > ::llvm::ELF::DT_ENCODING) && ((elf_dyn.d_tag % 2) == 0)) {
elf_dyn_needs_fixup = true;
}
break;
@@ -276,8 +276,8 @@
}
bool ElfWriter::FixupSectionHeaders(ElfFile& elf_file, uintptr_t base_address) {
- for (llvm::ELF::Elf32_Word i = 0; i < elf_file.GetSectionHeaderNum(); i++) {
- llvm::ELF::Elf32_Shdr& sh = elf_file.GetSectionHeader(i);
+ for (::llvm::ELF::Elf32_Word i = 0; i < elf_file.GetSectionHeaderNum(); i++) {
+ ::llvm::ELF::Elf32_Shdr& sh = elf_file.GetSectionHeader(i);
// 0 implies that the section will not exist in the memory of the process
if (sh.sh_addr == 0) {
continue;
@@ -289,8 +289,8 @@
bool ElfWriter::FixupProgramHeaders(ElfFile& elf_file, uintptr_t base_address) {
// TODO: ELFObjectFile doesn't have give to Elf32_Phdr, so we do that ourselves for now.
- for (llvm::ELF::Elf32_Word i = 0; i < elf_file.GetProgramHeaderNum(); i++) {
- llvm::ELF::Elf32_Phdr& ph = elf_file.GetProgramHeader(i);
+ for (::llvm::ELF::Elf32_Word i = 0; i < elf_file.GetProgramHeaderNum(); i++) {
+ ::llvm::ELF::Elf32_Phdr& ph = elf_file.GetProgramHeader(i);
CHECK_EQ(ph.p_vaddr, ph.p_paddr) << elf_file.GetFile().GetPath() << " i=" << i;
CHECK((ph.p_align == 0) || (0 == ((ph.p_vaddr - ph.p_offset) & (ph.p_align - 1))));
ph.p_vaddr += base_address;
@@ -301,12 +301,12 @@
}
bool ElfWriter::FixupSymbols(ElfFile& elf_file, uintptr_t base_address, bool dynamic) {
- llvm::ELF::Elf32_Word section_type = dynamic ? llvm::ELF::SHT_DYNSYM : llvm::ELF::SHT_SYMTAB;
+ ::llvm::ELF::Elf32_Word section_type = dynamic ? ::llvm::ELF::SHT_DYNSYM : ::llvm::ELF::SHT_SYMTAB;
// TODO: Unfortunate ELFObjectFile has protected symbol access, so use ElfFile
- llvm::ELF::Elf32_Shdr* symbol_section = elf_file.FindSectionByType(section_type);
+ ::llvm::ELF::Elf32_Shdr* symbol_section = elf_file.FindSectionByType(section_type);
CHECK(symbol_section != NULL) << elf_file.GetFile().GetPath();
for (uint32_t i = 0; i < elf_file.GetSymbolNum(*symbol_section); i++) {
- llvm::ELF::Elf32_Sym& symbol = elf_file.GetSymbol(section_type, i);
+ ::llvm::ELF::Elf32_Sym& symbol = elf_file.GetSymbol(section_type, i);
if (symbol.st_value != 0) {
symbol.st_value += base_address;
}
@@ -322,7 +322,7 @@
oat_loaded_size = elf_file->GetLoadedSize();
CHECK_NE(0U, oat_loaded_size);
- oat_data_offset = elf_file->FindSymbolAddress(llvm::ELF::SHT_DYNSYM, "oatdata");
+ oat_data_offset = elf_file->FindSymbolAddress(::llvm::ELF::SHT_DYNSYM, "oatdata");
CHECK_NE(0U, oat_data_offset);
}
diff --git a/src/elf_writer_test.cc b/src/elf_writer_test.cc
index 341c602..0be624d 100644
--- a/src/elf_writer_test.cc
+++ b/src/elf_writer_test.cc
@@ -31,8 +31,8 @@
};
#define EXPECT_ELF_FILE_ADDRESS(ef, value, name) \
- EXPECT_EQ(value, reinterpret_cast<void*>(ef->FindSymbolAddress(llvm::ELF::SHT_SYMTAB, name))); \
- EXPECT_EQ(value, reinterpret_cast<void*>(ef->FindSymbolAddress(llvm::ELF::SHT_DYNSYM, name))); \
+ EXPECT_EQ(value, reinterpret_cast<void*>(ef->FindSymbolAddress(::llvm::ELF::SHT_SYMTAB, name))); \
+ EXPECT_EQ(value, reinterpret_cast<void*>(ef->FindSymbolAddress(::llvm::ELF::SHT_DYNSYM, name))); \
EXPECT_EQ(value, ef->FindDynamicSymbolAddress(name)); \
/*
diff --git a/src/runtime.cc b/src/runtime.cc
index 429dc32..c74757f 100644
--- a/src/runtime.cc
+++ b/src/runtime.cc
@@ -58,7 +58,7 @@
#include "well_known_classes.h"
#if defined(ART_USE_PORTABLE_COMPILER)
-#include "compiler_llvm/procedure_linkage_table.h"
+#include "compiler/llvm/procedure_linkage_table.h"
#endif
#include "JniConstants.h" // Last to avoid LOG redefinition in ics-mr1-plus-art.
diff --git a/src/runtime.h b/src/runtime.h
index 45304d7..411d618 100644
--- a/src/runtime.h
+++ b/src/runtime.h
@@ -37,7 +37,7 @@
#include "safe_map.h"
#if defined(ART_USE_PORTABLE_COMPILER)
-#include "compiler_llvm/procedure_linkage_table.h"
+#include "compiler/llvm/procedure_linkage_table.h"
#endif
namespace art {
@@ -478,7 +478,7 @@
jobject main_thread_group_;
jobject system_thread_group_;
#if defined(ART_USE_PORTABLE_COMPILER)
- compiler_llvm::ProcedureLinkageTable plt_;
+ art::llvm::ProcedureLinkageTable plt_;
#endif
DISALLOW_COPY_AND_ASSIGN(Runtime);