diff options
| author | 2015-03-20 19:56:21 +0000 | |
|---|---|---|
| committer | 2015-03-20 19:56:22 +0000 | |
| commit | 2a39584820c46c18c3b013e13d758c707e9f363e (patch) | |
| tree | 693b528462ed70b4d2dfff40e3b022b3c26b0111 | |
| parent | dbd065a8df06e7595a0ed05d3c18e68b6dac9cd1 (diff) | |
| parent | 3d12eadf67e263ebc7e533f8daa65029feb41313 (diff) | |
Merge "ART: Change the isa defaults for Mips"
| -rw-r--r-- | Android.mk | 1 | ||||
| -rw-r--r-- | build/Android.oat.mk | 1 | ||||
| -rw-r--r-- | runtime/arch/mips/instruction_set_features_mips.cc | 81 |
3 files changed, 56 insertions, 27 deletions
diff --git a/Android.mk b/Android.mk index c740a0d979..216e86585f 100644 --- a/Android.mk +++ b/Android.mk @@ -360,6 +360,7 @@ $$(OUT_OAT_FILE): $(PRODUCT_OUT)/$(1) $(DEFAULT_DEX_PREOPT_BUILT_IMAGE) $(DEX2OA --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 4d2fa41692..710b130282 100644 --- a/build/Android.oat.mk +++ b/build/Android.oat.mk @@ -230,6 +230,7 @@ $$(core_image_name): $$(TARGET_CORE_DEX_FILES) $$(core_dex2oat_dependency) $$(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 00ab613b94..93d79b7763 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::FromBitmap(uint32_ 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 @@ const MipsInstructionSetFeatures* MipsInstructionSetFeatures::FromCpuInfo() { // 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()) { |