tor-browser

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

LIR-loong64.h (3549B)


      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 #ifndef jit_loong64_LIR_loong64_h
      8 #define jit_loong64_LIR_loong64_h
      9 
     10 namespace js {
     11 namespace jit {
     12 
     13 class LUnbox : public LInstructionHelper<1, BOX_PIECES, 0> {
     14 public:
     15  LIR_HEADER(Unbox);
     16 
     17  explicit LUnbox(const LAllocation& input) : LInstructionHelper(classOpcode) {
     18    setOperand(0, input);
     19  }
     20 
     21  static const size_t Input = 0;
     22 
     23  LBoxAllocation input() const { return getBoxOperand(Input); }
     24 
     25  MUnbox* mir() const { return mir_->toUnbox(); }
     26  const char* extraName() const { return StringFromMIRType(mir()->type()); }
     27 };
     28 
     29 class LUDivOrMod : public LBinaryMath<0> {
     30 public:
     31  LIR_HEADER(UDivOrMod);
     32 
     33  LUDivOrMod() : LBinaryMath(classOpcode) {}
     34 
     35  MBinaryArithInstruction* mir() const {
     36    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
     37    return static_cast<MBinaryArithInstruction*>(mir_);
     38  }
     39 
     40  bool canBeDivideByZero() const {
     41    if (mir_->isMod()) {
     42      return mir_->toMod()->canBeDivideByZero();
     43    }
     44    return mir_->toDiv()->canBeDivideByZero();
     45  }
     46 
     47  bool trapOnError() const {
     48    if (mir_->isMod()) {
     49      return mir_->toMod()->trapOnError();
     50    }
     51    return mir_->toDiv()->trapOnError();
     52  }
     53 
     54  wasm::TrapSiteDesc trapSiteDesc() const {
     55    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
     56    if (mir_->isMod()) {
     57      return mir_->toMod()->trapSiteDesc();
     58    }
     59    return mir_->toDiv()->trapSiteDesc();
     60  }
     61 };
     62 
     63 class LDivOrModI64 : public LBinaryMath<0> {
     64 public:
     65  LIR_HEADER(DivOrModI64);
     66 
     67  LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
     68      : LBinaryMath(classOpcode) {
     69    setOperand(0, lhs);
     70    setOperand(1, rhs);
     71  }
     72 
     73  MBinaryArithInstruction* mir() const {
     74    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
     75    return static_cast<MBinaryArithInstruction*>(mir_);
     76  }
     77 
     78  bool canBeDivideByZero() const {
     79    if (mir_->isMod()) {
     80      return mir_->toMod()->canBeDivideByZero();
     81    }
     82    return mir_->toDiv()->canBeDivideByZero();
     83  }
     84  bool canBeNegativeOverflow() const {
     85    if (mir_->isMod()) {
     86      return mir_->toMod()->canBeNegativeDividend();
     87    }
     88    return mir_->toDiv()->canBeNegativeOverflow();
     89  }
     90  wasm::TrapSiteDesc trapSiteDesc() const {
     91    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
     92    if (mir_->isMod()) {
     93      return mir_->toMod()->trapSiteDesc();
     94    }
     95    return mir_->toDiv()->trapSiteDesc();
     96  }
     97 };
     98 
     99 class LUDivOrModI64 : public LBinaryMath<0> {
    100 public:
    101  LIR_HEADER(UDivOrModI64);
    102 
    103  LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs)
    104      : LBinaryMath(classOpcode) {
    105    setOperand(0, lhs);
    106    setOperand(1, rhs);
    107  }
    108 
    109  const char* extraName() const {
    110    return mir()->isTruncated() ? "Truncated" : nullptr;
    111  }
    112 
    113  MBinaryArithInstruction* mir() const {
    114    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
    115    return static_cast<MBinaryArithInstruction*>(mir_);
    116  }
    117  bool canBeDivideByZero() const {
    118    if (mir_->isMod()) {
    119      return mir_->toMod()->canBeDivideByZero();
    120    }
    121    return mir_->toDiv()->canBeDivideByZero();
    122  }
    123  wasm::TrapSiteDesc trapSiteDesc() const {
    124    MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
    125    if (mir_->isMod()) {
    126      return mir_->toMod()->trapSiteDesc();
    127    }
    128    return mir_->toDiv()->trapSiteDesc();
    129  }
    130 };
    131 
    132 }  // namespace jit
    133 }  // namespace js
    134 
    135 #endif /* jit_loong64_LIR_loong64_h */