| 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_riscv64_LIR_riscv64_h |
| 8 |
#define jit_riscv64_LIR_riscv64_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 |
const 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<1> { |
| 64 |
public: |
| 65 |
LIR_HEADER(DivOrModI64) |
| 66 |
|
| 67 |
LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs, |
| 68 |
const LDefinition& temp) |
| 69 |
: LBinaryMath(classOpcode) { |
| 70 |
setOperand(0, lhs); |
| 71 |
setOperand(1, rhs); |
| 72 |
setTemp(0, temp); |
| 73 |
} |
| 74 |
|
| 75 |
const LDefinition* remainder() { return getTemp(0); } |
| 76 |
MBinaryArithInstruction* mir() const { |
| 77 |
MOZ_ASSERT(mir_->isDiv() || mir_->isMod()); |
| 78 |
return static_cast<MBinaryArithInstruction*>(mir_); |
| 79 |
} |
| 80 |
|
| 81 |
bool canBeDivideByZero() const { |
| 82 |
if (mir_->isMod()) { |
| 83 |
return mir_->toMod()->canBeDivideByZero(); |
| 84 |
} |
| 85 |
return mir_->toDiv()->canBeDivideByZero(); |
| 86 |
} |
| 87 |
bool canBeNegativeOverflow() const { |
| 88 |
if (mir_->isMod()) { |
| 89 |
return mir_->toMod()->canBeNegativeDividend(); |
| 90 |
} |
| 91 |
return mir_->toDiv()->canBeNegativeOverflow(); |
| 92 |
} |
| 93 |
const wasm::TrapSiteDesc& trapSiteDesc() const { |
| 94 |
MOZ_ASSERT(mir_->isDiv() || mir_->isMod()); |
| 95 |
if (mir_->isMod()) { |
| 96 |
return mir_->toMod()->trapSiteDesc(); |
| 97 |
} |
| 98 |
return mir_->toDiv()->trapSiteDesc(); |
| 99 |
} |
| 100 |
}; |
| 101 |
|
| 102 |
class LUDivOrModI64 : public LBinaryMath<1> { |
| 103 |
public: |
| 104 |
LIR_HEADER(UDivOrModI64); |
| 105 |
|
| 106 |
LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs, |
| 107 |
const LDefinition& temp) |
| 108 |
: LBinaryMath(classOpcode) { |
| 109 |
setOperand(0, lhs); |
| 110 |
setOperand(1, rhs); |
| 111 |
setTemp(0, temp); |
| 112 |
} |
| 113 |
|
| 114 |
const LDefinition* remainder() { return getTemp(0); } |
| 115 |
const char* extraName() const { |
| 116 |
return mir()->isTruncated() ? "Truncated" : nullptr; |
| 117 |
} |
| 118 |
|
| 119 |
MBinaryArithInstruction* mir() const { |
| 120 |
MOZ_ASSERT(mir_->isDiv() || mir_->isMod()); |
| 121 |
return static_cast<MBinaryArithInstruction*>(mir_); |
| 122 |
} |
| 123 |
bool canBeDivideByZero() const { |
| 124 |
if (mir_->isMod()) { |
| 125 |
return mir_->toMod()->canBeDivideByZero(); |
| 126 |
} |
| 127 |
return mir_->toDiv()->canBeDivideByZero(); |
| 128 |
} |
| 129 |
const wasm::TrapSiteDesc& trapSiteDesc() const { |
| 130 |
MOZ_ASSERT(mir_->isDiv() || mir_->isMod()); |
| 131 |
if (mir_->isMod()) { |
| 132 |
return mir_->toMod()->trapSiteDesc(); |
| 133 |
} |
| 134 |
return mir_->toDiv()->trapSiteDesc(); |
| 135 |
} |
| 136 |
}; |
| 137 |
|
| 138 |
} // namespace jit |
| 139 |
} // namespace js |
| 140 |
|
| 141 |
#endif /* jit_riscv64_LIR_riscv64_h */ |