1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/jit/mips/Architecture-mips.cpp Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,76 @@ 1.4 +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 1.5 + * vim: set ts=8 sts=4 et sw=4 tw=99: 1.6 + * This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 + 1.10 +#include "jit/mips/Architecture-mips.h" 1.11 + 1.12 +#include <elf.h> 1.13 + 1.14 +#include <fcntl.h> 1.15 +#include <unistd.h> 1.16 + 1.17 +#define HWCAP_MIPS (1 << 31) 1.18 +#define HWCAP_FPU (1 << 0) 1.19 + 1.20 +namespace js { 1.21 +namespace jit { 1.22 + 1.23 +uint32_t GetMIPSFlags() 1.24 +{ 1.25 + static bool isSet = false; 1.26 + static uint32_t flags = 0; 1.27 + if (isSet) 1.28 + return flags; 1.29 +#if WTF_OS_LINUX 1.30 + FILE *fp = fopen("/proc/cpuinfo", "r"); 1.31 + if (!fp) 1.32 + return false; 1.33 + 1.34 + char buf[1024]; 1.35 + memset(buf, 0, sizeof(buf)); 1.36 + fread(buf, sizeof(char), sizeof(buf)-1, fp); 1.37 + fclose(fp); 1.38 + if (strstr(buf, "FPU")) 1.39 + flags |= HWCAP_FPU; 1.40 + 1.41 + isSet = true; 1.42 + return flags; 1.43 +#endif 1.44 + 1.45 + return false; 1.46 +} 1.47 + 1.48 +bool hasFPU() 1.49 +{ 1.50 + return js::jit::GetMIPSFlags() & HWCAP_FPU; 1.51 +} 1.52 + 1.53 +Registers::Code 1.54 +Registers::FromName(const char *name) 1.55 +{ 1.56 + for (size_t i = 0; i < Total; i++) { 1.57 + if (strcmp(GetName(i), name) == 0) 1.58 + return Code(i); 1.59 + } 1.60 + 1.61 + return Invalid; 1.62 +} 1.63 + 1.64 +FloatRegisters::Code 1.65 +FloatRegisters::FromName(const char *name) 1.66 +{ 1.67 + for (size_t i = 0; i < Total; i++) { 1.68 + if (strcmp(GetName(i), name) == 0) 1.69 + return Code(i); 1.70 + } 1.71 + 1.72 + return Invalid; 1.73 +} 1.74 + 1.75 + 1.76 + 1.77 +} // namespace ion 1.78 +} // namespace js 1.79 +