michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- michael@0: * vim: set ts=8 sts=4 et sw=4 tw=99: michael@0: * This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #include "jit/mips/Architecture-mips.h" michael@0: michael@0: #include michael@0: michael@0: #include michael@0: #include michael@0: michael@0: #define HWCAP_MIPS (1 << 31) michael@0: #define HWCAP_FPU (1 << 0) michael@0: michael@0: namespace js { michael@0: namespace jit { michael@0: michael@0: uint32_t GetMIPSFlags() michael@0: { michael@0: static bool isSet = false; michael@0: static uint32_t flags = 0; michael@0: if (isSet) michael@0: return flags; michael@0: #if WTF_OS_LINUX michael@0: FILE *fp = fopen("/proc/cpuinfo", "r"); michael@0: if (!fp) michael@0: return false; michael@0: michael@0: char buf[1024]; michael@0: memset(buf, 0, sizeof(buf)); michael@0: fread(buf, sizeof(char), sizeof(buf)-1, fp); michael@0: fclose(fp); michael@0: if (strstr(buf, "FPU")) michael@0: flags |= HWCAP_FPU; michael@0: michael@0: isSet = true; michael@0: return flags; michael@0: #endif michael@0: michael@0: return false; michael@0: } michael@0: michael@0: bool hasFPU() michael@0: { michael@0: return js::jit::GetMIPSFlags() & HWCAP_FPU; michael@0: } michael@0: michael@0: Registers::Code michael@0: Registers::FromName(const char *name) michael@0: { michael@0: for (size_t i = 0; i < Total; i++) { michael@0: if (strcmp(GetName(i), name) == 0) michael@0: return Code(i); michael@0: } michael@0: michael@0: return Invalid; michael@0: } michael@0: michael@0: FloatRegisters::Code michael@0: FloatRegisters::FromName(const char *name) michael@0: { michael@0: for (size_t i = 0; i < Total; i++) { michael@0: if (strcmp(GetName(i), name) == 0) michael@0: return Code(i); michael@0: } michael@0: michael@0: return Invalid; michael@0: } michael@0: michael@0: michael@0: michael@0: } // namespace ion michael@0: } // namespace js michael@0: