From d2f558905a491a0ddf34e8edb7c399f2e7008e3d Mon Sep 17 00:00:00 2001 From: Heiher Date: Tue, 15 Mar 2016 18:02:50 +0800 Subject: [PATCH] Bug 1256588 - IonMonkey: MIPS: Implement isLoongson. r=huangwenjun06 --- .../jit/mips-shared/Architecture-mips-shared.cpp | 29 ++++++++++++---------- js/src/jit/mips-shared/Architecture-mips-shared.h | 1 + 2 files changed, 17 insertions(+), 13 deletions(-) --- .../mips-shared/Architecture-mips-shared.cpp | 35 ++++++++++--------- .../mips-shared/Architecture-mips-shared.h | 1 + 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/js/src/jit/mips-shared/Architecture-mips-shared.cpp b/js/src/jit/mips-shared/Architecture-mips-shared.cpp index 11815903a341..cf739b8829fb 100644 --- a/js/src/jit/mips-shared/Architecture-mips-shared.cpp +++ b/js/src/jit/mips-shared/Architecture-mips-shared.cpp @@ -12,6 +12,7 @@ #include "jit/RegisterSets.h" #define HWCAP_MIPS (1 << 31) +#define HWCAP_LOONGSON (1 << 30) #define HWCAP_FPU (1 << 0) namespace js { @@ -19,20 +20,19 @@ namespace jit { uint32_t GetMIPSFlags() { - static bool isSet = false; static uint32_t flags = 0; - if (isSet) - return flags; -#if defined(JS_SIMULATOR_MIPS32) || defined(JS_SIMULATOR_MIPS64) - isSet = true; - flags |= HWCAP_FPU; - return flags; -#else -#ifdef __linux__ + if (flags) + return flags; + + flags |= HWCAP_MIPS; +#if defined(JS_SIMULATOR_MIPS32) || defined(JS_SIMULATOR_MIPS64) + flags |= HWCAP_FPU; +#else +# ifdef __linux__ FILE* fp = fopen("/proc/cpuinfo", "r"); if (!fp) - return false; + return flags; char buf[1024]; memset(buf, 0, sizeof(buf)); @@ -40,13 +40,11 @@ uint32_t GetMIPSFlags() fclose(fp); if (strstr(buf, "FPU")) flags |= HWCAP_FPU; - - isSet = true; - return flags; -#endif - - return flags; + if (strstr(buf, "Loongson")) + flags |= HWCAP_LOONGSON; +# endif #endif // JS_SIMULATOR_MIPS32 || JS_SIMULATOR_MIPS64 + return flags; } bool hasFPU() @@ -54,6 +52,11 @@ bool hasFPU() return js::jit::GetMIPSFlags() & HWCAP_FPU; } +bool isLoongson() +{ + return js::jit::GetMIPSFlags() & HWCAP_LOONGSON; +} + Registers::Code Registers::FromName(const char* name) { diff --git a/js/src/jit/mips-shared/Architecture-mips-shared.h b/js/src/jit/mips-shared/Architecture-mips-shared.h index c31f6544f389..995ddc81675f 100644 --- a/js/src/jit/mips-shared/Architecture-mips-shared.h +++ b/js/src/jit/mips-shared/Architecture-mips-shared.h @@ -310,6 +310,7 @@ class FloatRegisterMIPSShared uint32_t GetMIPSFlags(); bool hasFPU(); +bool isLoongson(); // MIPS doesn't have double registers that can NOT be treated as float32. inline bool