tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

Architecture-loong64.cpp (2210B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*-
      2 * vim: set ts=8 sts=2 et sw=2 tw=80:
      3 * This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this
      5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #include "jit/loong64/Architecture-loong64.h"
      8 
      9 #include "jit/FlushICache.h"  // js::jit::FlushICache
     10 #include "jit/loong64/Simulator-loong64.h"
     11 #include "jit/RegisterSets.h"
     12 
     13 namespace js {
     14 namespace jit {
     15 
     16 Registers::Code Registers::FromName(const char* name) {
     17  for (size_t i = 0; i < Total; i++) {
     18    if (strcmp(GetName(i), name) == 0) {
     19      return Code(i);
     20    }
     21  }
     22 
     23  return Invalid;
     24 }
     25 
     26 FloatRegisters::Code FloatRegisters::FromName(const char* name) {
     27  for (size_t i = 0; i < Total; i++) {
     28    if (strcmp(GetName(i), name) == 0) {
     29      return Code(i);
     30    }
     31  }
     32 
     33  return Invalid;
     34 }
     35 
     36 FloatRegisterSet FloatRegister::ReduceSetForPush(const FloatRegisterSet& s) {
     37 #ifdef ENABLE_WASM_SIMD
     38 #  error "Needs more careful logic if SIMD is enabled"
     39 #endif
     40 
     41  LiveFloatRegisterSet ret;
     42  for (FloatRegisterIterator iter(s); iter.more(); ++iter) {
     43    ret.addUnchecked(FromCode((*iter).encoding()));
     44  }
     45  return ret.set();
     46 }
     47 
     48 uint32_t FloatRegister::GetPushSizeInBytes(const FloatRegisterSet& s) {
     49 #ifdef ENABLE_WASM_SIMD
     50 #  error "Needs more careful logic if SIMD is enabled"
     51 #endif
     52 
     53  return s.size() * sizeof(double);
     54 }
     55 
     56 uint32_t FloatRegister::getRegisterDumpOffsetInBytes() {
     57 #ifdef ENABLE_WASM_SIMD
     58 #  error "Needs more careful logic if SIMD is enabled"
     59 #endif
     60 
     61  return encoding() * sizeof(double);
     62 }
     63 
     64 bool CPUFlagsHaveBeenComputed() {
     65  // TODO(loong64): Add CPU flags support.
     66  return true;
     67 }
     68 
     69 uint32_t GetLOONG64Flags() { return 0; }
     70 
     71 void FlushICache(void* code, size_t size) {
     72 #if defined(JS_SIMULATOR)
     73  js::jit::SimulatorProcess::FlushICache(code, size);
     74 
     75 #elif defined(__GNUC__)
     76  intptr_t end = reinterpret_cast<intptr_t>(code) + size;
     77  __builtin___clear_cache(reinterpret_cast<char*>(code),
     78                          reinterpret_cast<char*>(end));
     79 
     80 #else
     81  _flush_cache(reinterpret_cast<char*>(code), size, BCACHE);
     82 
     83 #endif
     84 }
     85 
     86 }  // namespace jit
     87 }  // namespace js