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(-)
This commit is contained in:
Heiher 2016-03-15 18:02:50 +08:00
Родитель 7b1faa29bc
Коммит d2f558905a
2 изменённых файлов: 20 добавлений и 16 удалений

Просмотреть файл

@ -12,6 +12,7 @@
#include "jit/RegisterSets.h" #include "jit/RegisterSets.h"
#define HWCAP_MIPS (1 << 31) #define HWCAP_MIPS (1 << 31)
#define HWCAP_LOONGSON (1 << 30)
#define HWCAP_FPU (1 << 0) #define HWCAP_FPU (1 << 0)
namespace js { namespace js {
@ -19,20 +20,19 @@ namespace jit {
uint32_t GetMIPSFlags() uint32_t GetMIPSFlags()
{ {
static bool isSet = false;
static uint32_t flags = 0; 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"); FILE* fp = fopen("/proc/cpuinfo", "r");
if (!fp) if (!fp)
return false; return flags;
char buf[1024]; char buf[1024];
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
@ -40,13 +40,11 @@ uint32_t GetMIPSFlags()
fclose(fp); fclose(fp);
if (strstr(buf, "FPU")) if (strstr(buf, "FPU"))
flags |= HWCAP_FPU; flags |= HWCAP_FPU;
if (strstr(buf, "Loongson"))
isSet = true; flags |= HWCAP_LOONGSON;
return flags; # endif
#endif
return flags;
#endif // JS_SIMULATOR_MIPS32 || JS_SIMULATOR_MIPS64 #endif // JS_SIMULATOR_MIPS32 || JS_SIMULATOR_MIPS64
return flags;
} }
bool hasFPU() bool hasFPU()
@ -54,6 +52,11 @@ bool hasFPU()
return js::jit::GetMIPSFlags() & HWCAP_FPU; return js::jit::GetMIPSFlags() & HWCAP_FPU;
} }
bool isLoongson()
{
return js::jit::GetMIPSFlags() & HWCAP_LOONGSON;
}
Registers::Code Registers::Code
Registers::FromName(const char* name) Registers::FromName(const char* name)
{ {

Просмотреть файл

@ -310,6 +310,7 @@ class FloatRegisterMIPSShared
uint32_t GetMIPSFlags(); uint32_t GetMIPSFlags();
bool hasFPU(); bool hasFPU();
bool isLoongson();
// MIPS doesn't have double registers that can NOT be treated as float32. // MIPS doesn't have double registers that can NOT be treated as float32.
inline bool inline bool