From 7f429e62c3de67ffe511e7890bfe6aefcd2c55d4 Mon Sep 17 00:00:00 2001 From: "rmcilroy@chromium.org" Date: Mon, 23 Jun 2014 12:19:54 +0000 Subject: [PATCH] [Arm]: Simplify compile-time Arm feature detection. Simplify the compile time feature detection on Arm: - Define CAN_USE_XXX definitions unconditionally for all target/host toolchain combinations - Rename arm_test / ARM_TEST to arm_test_noprob / ARM_TEST_NO_FEATURE_PROBE - Don't set ARM_TEST_NO_FEATURE_PROBE implicitly on the simulator to make make simulator / native more consistent - Unify CpuFeatures::PrintTarget for simulator and native builds - Remove unecessary CAN_USE_VFP_INSTRUCTIONS definition for android (this is the default for arm_fpu=default) - Add a CpuFeatures::Probe() before calling CpuFeatures::PrintFeatures() in PrintHelp to ensure we have probed features before printing them. BUG=384474 LOG=N R=jkummerow@chromium.org Review URL: https://codereview.chromium.org/340373002 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@21935 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- Makefile | 7 ++- build/toolchain.gypi | 130 +++++++++++------------------------------------ src/arm/assembler-arm.cc | 55 ++++++++++---------- src/flag-definitions.h | 8 +-- src/flags.cc | 1 + tools/gyp/v8.gyp | 3 -- 6 files changed, 65 insertions(+), 139 deletions(-) diff --git a/Makefile b/Makefile index d5ce783..9c170f6 100644 --- a/Makefile +++ b/Makefile @@ -191,15 +191,14 @@ ifeq ($(armthumb), on) GYPFLAGS += -Darm_thumb=1 endif endif -# armtest=on +# arm_test_noprobe=on # With this flag set, by default v8 will only use features implied # by the compiler (no probe). This is done by modifying the default # values of enable_armv7, enable_vfp3, enable_32dregs and enable_neon. # Modifying these flags when launching v8 will enable the probing for # the specified values. -# When using the simulator, this flag is implied. -ifeq ($(armtest), on) - GYPFLAGS += -Darm_test=on +ifeq ($(arm_test_noprobe), on) + GYPFLAGS += -Darm_test_noprobe=on endif # ----------------- available targets: -------------------- diff --git a/build/toolchain.gypi b/build/toolchain.gypi index 6b421ca..4e6869b 100644 --- a/build/toolchain.gypi +++ b/build/toolchain.gypi @@ -47,7 +47,7 @@ # these registers in the snapshot and use CPU feature probing when running # on the target. 'v8_can_use_vfp32dregs%': 'false', - 'arm_test%': 'off', + 'arm_test_noprobe%': 'off', # Similar to vfp but on MIPS. 'v8_can_use_fpu_instructions%': 'true', @@ -89,6 +89,36 @@ 'defines': [ 'V8_TARGET_ARCH_ARM', ], + 'conditions': [ + [ 'arm_version==7 or arm_version=="default"', { + 'defines': [ + 'CAN_USE_ARMV7_INSTRUCTIONS', + ], + }], + [ 'arm_fpu=="vfpv3-d16" or arm_fpu=="default"', { + 'defines': [ + 'CAN_USE_VFP3_INSTRUCTIONS', + ], + }], + [ 'arm_fpu=="vfpv3"', { + 'defines': [ + 'CAN_USE_VFP3_INSTRUCTIONS', + 'CAN_USE_VFP32DREGS', + ], + }], + [ 'arm_fpu=="neon"', { + 'defines': [ + 'CAN_USE_VFP3_INSTRUCTIONS', + 'CAN_USE_VFP32DREGS', + 'CAN_USE_NEON', + ], + }], + [ 'arm_test_noprobe=="on"', { + 'defines': [ + 'ARM_TEST_NO_FEATURE_PROBE', + ], + }], + ], 'target_conditions': [ ['_toolset=="host"', { 'variables': { @@ -116,45 +146,10 @@ [ 'arm_thumb==0', { 'cflags': ['-marm',], }], - [ 'arm_test=="on"', { - 'defines': [ - 'ARM_TEST', - ], - }], ], }, { # armcompiler=="no" 'conditions': [ - [ 'arm_version==7 or arm_version=="default"', { - 'defines': [ - 'CAN_USE_ARMV7_INSTRUCTIONS=1', - ], - 'conditions': [ - [ 'arm_fpu=="default"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - ], - }], - [ 'arm_fpu=="vfpv3-d16"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - ], - }], - [ 'arm_fpu=="vfpv3"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - ], - }], - [ 'arm_fpu=="neon"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - 'CAN_USE_NEON', - ], - }], - ], - }], [ 'arm_float_abi=="hard"', { 'defines': [ 'USE_EABI_HARDFLOAT=1', @@ -166,9 +161,6 @@ ], }], ], - 'defines': [ - 'ARM_TEST', - ], }], ], }], # _toolset=="host" @@ -198,67 +190,10 @@ [ 'arm_thumb==0', { 'cflags': ['-marm',], }], - [ 'arm_test=="on"', { - 'defines': [ - 'ARM_TEST', - ], - 'conditions': [ - [ 'arm_fpu=="vfpv3-d16"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - ], - }], - [ 'arm_fpu=="vfpv3"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - ], - }], - [ 'arm_fpu=="neon"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - 'CAN_USE_NEON', - ], - }], - ], - }], ], }, { # armcompiler=="no" 'conditions': [ - [ 'arm_version==7 or arm_version=="default"', { - 'defines': [ - 'CAN_USE_ARMV7_INSTRUCTIONS=1', - ], - 'conditions': [ - [ 'arm_fpu=="default"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - 'CAN_USE_NEON', - ], - }], - [ 'arm_fpu=="vfpv3-d16"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - ], - }], - [ 'arm_fpu=="vfpv3"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - ], - }], - [ 'arm_fpu=="neon"', { - 'defines': [ - 'CAN_USE_VFP3_INSTRUCTIONS', - 'CAN_USE_VFP32DREGS', - 'CAN_USE_NEON', - ], - }], - ], - }], [ 'arm_float_abi=="hard"', { 'defines': [ 'USE_EABI_HARDFLOAT=1', @@ -270,9 +205,6 @@ ], }], ], - 'defines': [ - 'ARM_TEST', - ], }], ], }], # _toolset=="target" diff --git a/src/arm/assembler-arm.cc b/src/arm/assembler-arm.cc index c3afeaa..6a35d93 100644 --- a/src/arm/assembler-arm.cc +++ b/src/arm/assembler-arm.cc @@ -129,56 +129,53 @@ void CpuFeatures::ProbeImpl(bool cross_compile) { void CpuFeatures::PrintTarget() { const char* arm_arch = NULL; - const char* arm_test = ""; + const char* arm_target_type = ""; + const char* arm_no_probe = ""; const char* arm_fpu = ""; const char* arm_thumb = ""; const char* arm_float_abi = NULL; +#if !defined __arm__ + arm_target_type = " simulator"; +#endif + +#if defined ARM_TEST_NO_FEATURE_PROBE + arm_no_probe = " noprobe"; +#endif + #if defined CAN_USE_ARMV7_INSTRUCTIONS arm_arch = "arm v7"; #else arm_arch = "arm v6"; #endif -#ifdef __arm__ - -# ifdef ARM_TEST - arm_test = " test"; -# endif -# if defined __ARM_NEON__ +#if defined CAN_USE_NEON arm_fpu = " neon"; -# elif defined CAN_USE_VFP3_INSTRUCTIONS - arm_fpu = " vfp3"; -# else - arm_fpu = " vfp2"; -# endif -# if (defined __thumb__) || (defined __thumb2__) - arm_thumb = " thumb"; -# endif - arm_float_abi = OS::ArmUsingHardFloat() ? "hard" : "softfp"; - -#else // __arm__ - - arm_test = " simulator"; -# if defined CAN_USE_VFP3_INSTRUCTIONS +#elif defined CAN_USE_VFP3_INSTRUCTIONS # if defined CAN_USE_VFP32DREGS arm_fpu = " vfp3"; # else arm_fpu = " vfp3-d16"; # endif -# else +#else arm_fpu = " vfp2"; -# endif -# if USE_EABI_HARDFLOAT == 1 +#endif + +#ifdef __arm__ + arm_float_abi = OS::ArmUsingHardFloat() ? "hard" : "softfp"; +#elif USE_EABI_HARDFLOAT arm_float_abi = "hard"; -# else +#else arm_float_abi = "softfp"; -# endif +#endif -#endif // __arm__ +#if defined __arm__ && (defined __thumb__) || (defined __thumb2__) + arm_thumb = " thumb"; +#endif - printf("target%s %s%s%s %s\n", - arm_test, arm_arch, arm_fpu, arm_thumb, arm_float_abi); + printf("target%s%s %s%s%s %s\n", + arm_target_type, arm_no_probe, arm_arch, arm_fpu, arm_thumb, + arm_float_abi); } diff --git a/src/flag-definitions.h b/src/flag-definitions.h index 14bea60..587ef6c 100644 --- a/src/flag-definitions.h +++ b/src/flag-definitions.h @@ -105,22 +105,22 @@ struct MaybeBoolFlag { }; #endif -#if (defined CAN_USE_VFP3_INSTRUCTIONS) || !(defined ARM_TEST) +#if (defined CAN_USE_VFP3_INSTRUCTIONS) || !(defined ARM_TEST_NO_FEATURE_PROBE) # define ENABLE_VFP3_DEFAULT true #else # define ENABLE_VFP3_DEFAULT false #endif -#if (defined CAN_USE_ARMV7_INSTRUCTIONS) || !(defined ARM_TEST) +#if (defined CAN_USE_ARMV7_INSTRUCTIONS) || !(defined ARM_TEST_NO_FEATURE_PROBE) # define ENABLE_ARMV7_DEFAULT true #else # define ENABLE_ARMV7_DEFAULT false #endif -#if (defined CAN_USE_VFP32DREGS) || !(defined ARM_TEST) +#if (defined CAN_USE_VFP32DREGS) || !(defined ARM_TEST_NO_FEATURE_PROBE) # define ENABLE_32DREGS_DEFAULT true #else # define ENABLE_32DREGS_DEFAULT false #endif -#if (defined CAN_USE_NEON) || !(defined ARM_TEST) +#if (defined CAN_USE_NEON) || !(defined ARM_TEST_NO_FEATURE_PROBE) # define ENABLE_NEON_DEFAULT true #else # define ENABLE_NEON_DEFAULT false diff --git a/src/flags.cc b/src/flags.cc index daf5631..53942aa 100644 --- a/src/flags.cc +++ b/src/flags.cc @@ -517,6 +517,7 @@ void FlagList::ResetAllFlags() { // static void FlagList::PrintHelp() { + CpuFeatures::Probe(false); CpuFeatures::PrintTarget(); CpuFeatures::PrintFeatures(); diff --git a/tools/gyp/v8.gyp b/tools/gyp/v8.gyp index 72450d8..d719611 100644 --- a/tools/gyp/v8.gyp +++ b/tools/gyp/v8.gyp @@ -837,9 +837,6 @@ } ], ['OS=="android"', { - 'defines': [ - 'CAN_USE_VFP_INSTRUCTIONS', - ], 'sources': [ '../../src/platform-posix.cc' ], -- 2.7.4