ART: Change the isa defaults for Mips
Select the correct cpu variant for ART and select the default
features based on compile flags for when the variant is not
defined.
Change-Id: I13622db85446ed6fbb467a699d8d3e27833f6f88
diff --git a/Android.mk b/Android.mk
index c740a0d..216e865 100644
--- a/Android.mk
+++ b/Android.mk
@@ -360,6 +360,7 @@
--boot-image=$(DEFAULT_DEX_PREOPT_BUILT_IMAGE) --dex-file=$(PRODUCT_OUT)/$(1) \
--dex-location=/$(1) --oat-file=$$@ \
--instruction-set=$(DEX2OAT_TARGET_ARCH) \
+ --instruction-set-variant=$(DEX2OAT_TARGET_CPU_VARIANT) \
--instruction-set-features=$(DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
--android-root=$(PRODUCT_OUT)/system --include-patch-information \
--runtime-arg -Xnorelocate
diff --git a/build/Android.oat.mk b/build/Android.oat.mk
index 4d2fa41..710b130 100644
--- a/build/Android.oat.mk
+++ b/build/Android.oat.mk
@@ -230,6 +230,7 @@
$$(addprefix --dex-location=,$$(TARGET_CORE_DEX_LOCATIONS)) --oat-file=$$(PRIVATE_CORE_OAT_NAME) \
--oat-location=$$(PRIVATE_CORE_OAT_NAME) --image=$$(PRIVATE_CORE_IMG_NAME) \
--base=$$(LIBART_IMG_TARGET_BASE_ADDRESS) --instruction-set=$$($(3)TARGET_ARCH) \
+ --instruction-set-variant=$$($(3)DEX2OAT_TARGET_CPU_VARIANT) \
--instruction-set-features=$$($(3)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES) \
--android-root=$$(PRODUCT_OUT)/system --include-patch-information \
$$(PRIVATE_CORE_COMPILE_OPTIONS) || (rm $$(PRIVATE_CORE_OAT_NAME); exit 1)
diff --git a/runtime/arch/mips/instruction_set_features_mips.cc b/runtime/arch/mips/instruction_set_features_mips.cc
index 00ab613..93d79b7 100644
--- a/runtime/arch/mips/instruction_set_features_mips.cc
+++ b/runtime/arch/mips/instruction_set_features_mips.cc
@@ -24,13 +24,56 @@
namespace art {
+// An enum for the Mips revision.
+enum class MipsLevel {
+ kBase,
+ kR2,
+ kR5,
+ kR6
+};
+
+#if defined(_MIPS_ARCH_MIPS32R6)
+static constexpr MipsLevel kRuntimeMipsLevel = MipsLevel::kR6;
+#elif defined(_MIPS_ARCH_MIPS32R5)
+static constexpr MipsLevel kRuntimeMipsLevel = MipsLevel::kR5;
+#elif defined(_MIPS_ARCH_MIPS32R2)
+static constexpr MipsLevel kRuntimeMipsLevel = MipsLevel::kR2;
+#else
+static constexpr MipsLevel kRuntimeMipsLevel = MipsLevel::kBase;
+#endif
+
+static void GetFlagsFromCppDefined(bool* mips_isa_gte2, bool* r6, bool* fpu_32bit) {
+ // Override defaults based on compiler flags.
+ if (kRuntimeMipsLevel >= MipsLevel::kR2) {
+ *mips_isa_gte2 = true;
+ } else {
+ *mips_isa_gte2 = false;
+ }
+
+ if (kRuntimeMipsLevel >= MipsLevel::kR5) {
+ *fpu_32bit = false;
+ } else {
+ *fpu_32bit = true;
+ }
+
+ if (kRuntimeMipsLevel >= MipsLevel::kR6) {
+ *r6 = true;
+ } else {
+ *r6 = false;
+ }
+}
+
const MipsInstructionSetFeatures* MipsInstructionSetFeatures::FromVariant(
const std::string& variant, std::string* error_msg ATTRIBUTE_UNUSED) {
bool smp = true; // Conservative default.
- bool fpu_32bit = true;
- bool mips_isa_gte2 = false;
- bool r6 = false;
+
+ // Override defaults based on compiler flags.
+ // This is needed when running ART test where the variant is not defined.
+ bool fpu_32bit;
+ bool mips_isa_gte2;
+ bool r6;
+ GetFlagsFromCppDefined(&mips_isa_gte2, &r6, &fpu_32bit);
// Override defaults based on variant string.
// Only care if it is R1, R2 or R6 and we assume all CPUs will have a FP unit.
@@ -67,19 +110,11 @@
const MipsInstructionSetFeatures* MipsInstructionSetFeatures::FromCppDefines() {
// Assume conservative defaults.
const bool smp = true;
- bool fpu_32bit = true;
- bool mips_isa_gte2 = false;
- bool r6 = false;
- // Override defaults based on compiler flags.
-#if (_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS32R5) || defined(_MIPS_ARCH_MIPS32R6)
- mips_isa_gte2 = true;
-#endif
-
-#if defined(_MIPS_ARCH_MIPS32R6)
- r6 = true;
- fpu_32bit = false;
-#endif
+ bool fpu_32bit;
+ bool mips_isa_gte2;
+ bool r6;
+ GetFlagsFromCppDefined(&mips_isa_gte2, &r6, &fpu_32bit);
return new MipsInstructionSetFeatures(smp, fpu_32bit, mips_isa_gte2, r6);
}
@@ -89,19 +124,11 @@
// the kernel puts the appropriate feature flags in here. Sometimes it doesn't.
// Assume conservative defaults.
bool smp = false;
- bool fpu_32bit = true;
- bool mips_isa_gte2 = false;
- bool r6 = false;
- // Override defaults based on compiler flags.
-#if (_MIPS_ARCH_MIPS32R2) || defined(_MIPS_ARCH_MIPS32R5) || defined(_MIPS_ARCH_MIPS32R6)
- mips_isa_gte2 = true;
-#endif
-
-#if defined(_MIPS_ARCH_MIPS32R6)
- r6 = true;
- fpu_32bit = false;
-#endif
+ bool fpu_32bit;
+ bool mips_isa_gte2;
+ bool r6;
+ GetFlagsFromCppDefined(&mips_isa_gte2, &r6, &fpu_32bit);
std::ifstream in("/proc/cpuinfo");
if (!in.fail()) {