Move inferred_reg_category_map to greenland.
Change-Id: I33e98b3cfe661f69046362d71f9315bd5b439abd
diff --git a/src/compiler_llvm/inferred_reg_category_map.cc b/src/compiler_llvm/inferred_reg_category_map.cc
deleted file mode 100644
index 0875a3f..0000000
--- a/src/compiler_llvm/inferred_reg_category_map.cc
+++ /dev/null
@@ -1,103 +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.
- */
-
-#include "inferred_reg_category_map.h"
-
-#include "backend_types.h"
-#include "stl_util.h"
-
-#include <stdint.h>
-#include <vector>
-
-namespace art {
-namespace compiler_llvm {
-
-
-InferredRegCategoryMap::InferredRegCategoryMap(uint32_t insns_size,
- uint16_t regs_size)
-: registers_size_(regs_size), can_be_object_(regs_size) {
-}
-
-InferredRegCategoryMap::~InferredRegCategoryMap() {
- STLDeleteValues(&lines_);
-}
-
-RegCategory InferredRegCategoryMap::GetRegCategory(uint32_t dex_pc,
- uint16_t reg_idx) const {
- if (lines_.count(dex_pc) == 0) {
- return kRegUnknown;
- }
- return lines_.Get(dex_pc)->GetRegCategory(reg_idx);
-}
-
-void InferredRegCategoryMap::SetRegCategory(uint32_t dex_pc,
- uint16_t reg_idx,
- RegCategory cat) {
- if (cat != kRegUnknown) {
- if (lines_.count(dex_pc) == 0) {
- lines_.Put(dex_pc, new RegCategoryLine(registers_size_));
- }
-
- lines_.Get(dex_pc)->SetRegCategory(reg_idx, cat);
- }
-}
-
-bool InferredRegCategoryMap::IsRegCanBeObject(uint16_t reg_idx) const {
- return can_be_object_[reg_idx];
-}
-
-void InferredRegCategoryMap::SetRegCanBeObject(uint16_t reg_idx) {
- can_be_object_[reg_idx] = true;
-}
-
-bool InferredRegCategoryMap::
-operator==(InferredRegCategoryMap const& rhs) const {
-
- if (registers_size_ != rhs.registers_size_) {
- return false;
- }
-
- if (lines_.size() != rhs.lines_.size()) {
- return false;
- }
-
- for (size_t i = 0; i < lines_.size(); ++i) {
- if (lines_.count(i) == 0 && rhs.lines_.count(i) == 0) {
- continue;
- }
-
- if ((lines_.count(i) == 0 && rhs.lines_.count(i) != 0) ||
- (lines_.count(i) != 0 && rhs.lines_.count(i) == 0)) {
- return false;
- }
-
- if (*lines_.Get(i) != *rhs.lines_.Get(i)) {
- return false;
- }
- }
-
- return true;
-}
-
-bool InferredRegCategoryMap::
-operator!=(InferredRegCategoryMap const& rhs) const {
-
- return !(*this == rhs);
-}
-
-
-} // namespace compiler_llvm
-} // namespace art
diff --git a/src/compiler_llvm/inferred_reg_category_map.h b/src/compiler_llvm/inferred_reg_category_map.h
deleted file mode 100644
index 1626d92..0000000
--- a/src/compiler_llvm/inferred_reg_category_map.h
+++ /dev/null
@@ -1,86 +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_INFERRED_REG_CATEGORY_MAP_H_
-#define ART_SRC_COMPILER_LLVM_INFERRED_REG_CATEGORY_MAP_H_
-
-#include "backend_types.h"
-
-#include <stdint.h>
-#include <vector>
-
-#include "safe_map.h"
-
-namespace art {
-namespace compiler_llvm {
-
-
-class InferredRegCategoryMap {
- private:
- class RegCategoryLine {
- private:
- typedef std::vector<uint8_t> Table;
- Table reg_category_line_;
-
- public:
- RegCategoryLine(size_t num_regs) : reg_category_line_(num_regs, kRegUnknown) {}
- RegCategory GetRegCategory(uint16_t reg_idx) const {
- DCHECK_LT(reg_idx, reg_category_line_.size());
- return static_cast<RegCategory>(reg_category_line_[reg_idx]);
- }
-
- void SetRegCategory(uint16_t reg_idx, RegCategory cat) {
- DCHECK_LT(reg_idx, reg_category_line_.size());
- reg_category_line_[reg_idx] = cat;
- }
-
- bool operator==(RegCategoryLine const& rhs) const {
- return reg_category_line_ == rhs.reg_category_line_;
- }
- bool operator!=(RegCategoryLine const& rhs) const {
- return reg_category_line_ != rhs.reg_category_line_;
- }
- };
-
- public:
- InferredRegCategoryMap(uint32_t insns_size_in_code_units, uint16_t regs_size);
-
- ~InferredRegCategoryMap();
-
- RegCategory GetRegCategory(uint32_t dex_pc, uint16_t reg_idx) const;
- void SetRegCategory(uint32_t dex_pc, uint16_t reg_idx, RegCategory cat);
-
- bool IsRegCanBeObject(uint16_t reg_idx) const;
- void SetRegCanBeObject(uint16_t reg_idx);
-
- bool operator==(InferredRegCategoryMap const& rhs) const;
- bool operator!=(InferredRegCategoryMap const& rhs) const;
-
- private:
- uint16_t registers_size_;
-
- SafeMap<uint32_t, RegCategoryLine*> lines_;
-
- std::vector<bool> can_be_object_;
-
- DISALLOW_COPY_AND_ASSIGN(InferredRegCategoryMap);
-};
-
-
-} // namespace compiler_llvm
-} // namespace art
-
-#endif // ART_SRC_COMPILER_LLVM_INFERRED_REG_CATEGORY_MAP_H_
diff --git a/src/compiler_llvm/method_compiler.cc b/src/compiler_llvm/method_compiler.cc
index ca8888c..a74a6a4 100644
--- a/src/compiler_llvm/method_compiler.cc
+++ b/src/compiler_llvm/method_compiler.cc
@@ -20,7 +20,7 @@
#include "compilation_unit.h"
#include "compiler.h"
#include "dalvik_reg.h"
-#include "inferred_reg_category_map.h"
+#include "greenland/inferred_reg_category_map.h"
#include "ir_builder.h"
#include "logging.h"
#include "oat_compilation_unit.h"
@@ -2042,26 +2042,26 @@
DecodedInstruction dec_insn(insn);
- int8_t src1_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vA);
- int8_t src2_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vB);
+ greenland::RegCategory src1_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vA);
+ greenland::RegCategory src2_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vB);
- DCHECK_NE(kRegUnknown, src1_reg_cat);
- DCHECK_NE(kRegUnknown, src2_reg_cat);
- DCHECK_NE(kRegCat2, src1_reg_cat);
- DCHECK_NE(kRegCat2, src2_reg_cat);
+ DCHECK_NE(greenland::kRegUnknown, src1_reg_cat);
+ DCHECK_NE(greenland::kRegUnknown, src2_reg_cat);
+ DCHECK_NE(greenland::kRegCat2, src1_reg_cat);
+ DCHECK_NE(greenland::kRegCat2, src2_reg_cat);
int32_t branch_offset = dec_insn.vC;
llvm::Value* src1_value;
llvm::Value* src2_value;
- if (src1_reg_cat == kRegZero && src2_reg_cat == kRegZero) {
+ if (src1_reg_cat == greenland::kRegZero && src2_reg_cat == greenland::kRegZero) {
src1_value = irb_.getInt32(0);
src2_value = irb_.getInt32(0);
- } else if (src1_reg_cat != kRegZero && src2_reg_cat != kRegZero) {
+ } else if (src1_reg_cat != greenland::kRegZero && src2_reg_cat != greenland::kRegZero) {
CHECK_EQ(src1_reg_cat, src2_reg_cat);
- if (src1_reg_cat == kRegCat1nr) {
+ if (src1_reg_cat == greenland::kRegCat1nr) {
src1_value = EmitLoadDalvikReg(dec_insn.vA, kInt, kAccurate);
src2_value = EmitLoadDalvikReg(dec_insn.vB, kInt, kAccurate);
} else {
@@ -2069,11 +2069,11 @@
src2_value = EmitLoadDalvikReg(dec_insn.vB, kObject, kAccurate);
}
} else {
- DCHECK(src1_reg_cat == kRegZero ||
- src2_reg_cat == kRegZero);
+ DCHECK(src1_reg_cat == greenland::kRegZero ||
+ src2_reg_cat == greenland::kRegZero);
- if (src1_reg_cat == kRegZero) {
- if (src2_reg_cat == kRegCat1nr) {
+ if (src1_reg_cat == greenland::kRegZero) {
+ if (src2_reg_cat == greenland::kRegCat1nr) {
src1_value = irb_.getJInt(0);
src2_value = EmitLoadDalvikReg(dec_insn.vA, kInt, kAccurate);
} else {
@@ -2081,7 +2081,7 @@
src2_value = EmitLoadDalvikReg(dec_insn.vA, kObject, kAccurate);
}
} else { // src2_reg_cat == kRegZero
- if (src2_reg_cat == kRegCat1nr) {
+ if (src2_reg_cat == greenland::kRegCat1nr) {
src1_value = EmitLoadDalvikReg(dec_insn.vA, kInt, kAccurate);
src2_value = irb_.getJInt(0);
} else {
@@ -2106,20 +2106,20 @@
DecodedInstruction dec_insn(insn);
- int8_t src_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vA);
+ greenland::RegCategory src_reg_cat = GetInferredRegCategory(dex_pc, dec_insn.vA);
- DCHECK_NE(kRegUnknown, src_reg_cat);
- DCHECK_NE(kRegCat2, src_reg_cat);
+ DCHECK_NE(greenland::kRegUnknown, src_reg_cat);
+ DCHECK_NE(greenland::kRegCat2, src_reg_cat);
int32_t branch_offset = dec_insn.vB;
llvm::Value* src1_value;
llvm::Value* src2_value;
- if (src_reg_cat == kRegZero) {
+ if (src_reg_cat == greenland::kRegZero) {
src1_value = irb_.getInt32(0);
src2_value = irb_.getInt32(0);
- } else if (src_reg_cat == kRegCat1nr) {
+ } else if (src_reg_cat == greenland::kRegCat1nr) {
src1_value = EmitLoadDalvikReg(dec_insn.vA, kInt, kAccurate);
src2_value = irb_.getInt32(0);
} else {
@@ -2135,26 +2135,26 @@
GetNextBasicBlock(dex_pc));
}
-const InferredRegCategoryMap* MethodCompiler::GetInferredRegCategoryMap() {
+const greenland::InferredRegCategoryMap* MethodCompiler::GetInferredRegCategoryMap() {
Compiler::MethodReference mref(dex_file_, method_idx_);
- const InferredRegCategoryMap* map =
+ const greenland::InferredRegCategoryMap* map =
verifier::MethodVerifier::GetInferredRegCategoryMap(mref);
- CHECK_NE(map, static_cast<InferredRegCategoryMap*>(NULL));
+ CHECK_NE(map, static_cast<greenland::InferredRegCategoryMap*>(NULL));
return map;
}
-RegCategory MethodCompiler::GetInferredRegCategory(uint32_t dex_pc,
- uint16_t reg_idx) {
- const InferredRegCategoryMap* map = GetInferredRegCategoryMap();
+greenland::RegCategory MethodCompiler::GetInferredRegCategory(uint32_t dex_pc,
+ uint16_t reg_idx) {
+ const greenland::InferredRegCategoryMap* map = GetInferredRegCategoryMap();
return map->GetRegCategory(dex_pc, reg_idx);
}
bool MethodCompiler::IsRegCanBeObject(uint16_t reg_idx) {
- const InferredRegCategoryMap* map = GetInferredRegCategoryMap();
+ const greenland::InferredRegCategoryMap* map = GetInferredRegCategoryMap();
return map->IsRegCanBeObject(reg_idx);
}
diff --git a/src/compiler_llvm/method_compiler.h b/src/compiler_llvm/method_compiler.h
index d54be6b..15b8558 100644
--- a/src/compiler_llvm/method_compiler.h
+++ b/src/compiler_llvm/method_compiler.h
@@ -20,6 +20,7 @@
#include "backend_types.h"
#include "dex_file.h"
#include "dex_instruction.h"
+#include "greenland/backend_types.h"
#include "invoke_type.h"
#include "object_utils.h"
#include "runtime_support_func.h"
@@ -39,6 +40,10 @@
class DexCache;
class Field;
class OatCompilationUnit;
+
+ namespace greenland {
+ class InferredRegCategoryMap;
+ }
}
@@ -361,9 +366,9 @@
llvm::Value* array,
llvm::Value* index);
- RegCategory GetInferredRegCategory(uint32_t dex_pc, uint16_t reg);
+ greenland::RegCategory GetInferredRegCategory(uint32_t dex_pc, uint16_t reg);
- const InferredRegCategoryMap* GetInferredRegCategoryMap();
+ const greenland::InferredRegCategoryMap* GetInferredRegCategoryMap();
bool IsRegCanBeObject(uint16_t reg_idx);