Debian Codegraph @

js/src/jit/x64/LIR-x64.h

raw
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_x64_LIR_x64_h
8 #define jit_x64_LIR_x64_h
9
10 namespace js {
11 namespace jit {
12
13 // Given an untyped input, guards on whether it's a specific type and returns
14 // the unboxed payload.
15 class LUnbox : public LInstructionHelper<1, BOX_PIECES, 0> {
16 public:
17 LIR_HEADER(Unbox)
18
19 explicit LUnbox(const LAllocation& input) : LInstructionHelper(classOpcode) {
20 setOperand(0, input);
21 }
22
23 static const size_t Input = 0;
24
25 LBoxAllocation input() const { return getBoxOperand(Input); }
26
27 MUnbox* mir() const { return mir_->toUnbox(); }
28 const char* extraName() const { return StringFromMIRType(mir()->type()); }
29 };
30
31 class LDivOrModI64 : public LBinaryMath<1> {
32 public:
33 LIR_HEADER(DivOrModI64)
34
35 LDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
36 const LDefinition& temp)
37 : LBinaryMath(classOpcode) {
38 setOperand(0, lhs);
39 setOperand(1, rhs);
40 setTemp(0, temp);
41 }
42
43 const LDefinition* remainder() { return getTemp(0); }
44
45 MBinaryArithInstruction* mir() const {
46 MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
47 return static_cast<MBinaryArithInstruction*>(mir_);
48 }
49 bool canBeDivideByZero() const {
50 if (mir_->isMod()) {
51 return mir_->toMod()->canBeDivideByZero();
52 }
53 return mir_->toDiv()->canBeDivideByZero();
54 }
55 bool canBeNegativeOverflow() const {
56 if (mir_->isMod()) {
57 return mir_->toMod()->canBeNegativeDividend();
58 }
59 return mir_->toDiv()->canBeNegativeOverflow();
60 }
61 const wasm::TrapSiteDesc& trapSiteDesc() const {
62 MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
63 if (mir_->isMod()) {
64 return mir_->toMod()->trapSiteDesc();
65 }
66 return mir_->toDiv()->trapSiteDesc();
67 }
68 };
69
70 // This class performs a simple x86 'div', yielding either a quotient or
71 // remainder depending on whether this instruction is defined to output
72 // rax (quotient) or rdx (remainder).
73 class LUDivOrModI64 : public LBinaryMath<1> {
74 public:
75 LIR_HEADER(UDivOrModI64);
76
77 LUDivOrModI64(const LAllocation& lhs, const LAllocation& rhs,
78 const LDefinition& temp)
79 : LBinaryMath(classOpcode) {
80 setOperand(0, lhs);
81 setOperand(1, rhs);
82 setTemp(0, temp);
83 }
84
85 const LDefinition* remainder() { return getTemp(0); }
86
87 const char* extraName() const {
88 return mir()->isTruncated() ? "Truncated" : nullptr;
89 }
90
91 MBinaryArithInstruction* mir() const {
92 MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
93 return static_cast<MBinaryArithInstruction*>(mir_);
94 }
95
96 bool canBeDivideByZero() const {
97 if (mir_->isMod()) {
98 return mir_->toMod()->canBeDivideByZero();
99 }
100 return mir_->toDiv()->canBeDivideByZero();
101 }
102
103 const wasm::TrapSiteDesc& trapSiteDesc() const {
104 MOZ_ASSERT(mir_->isDiv() || mir_->isMod());
105 if (mir_->isMod()) {
106 return mir_->toMod()->trapSiteDesc();
107 }
108 return mir_->toDiv()->trapSiteDesc();
109 }
110 };
111
112 } // namespace jit
113 } // namespace js
114
115 #endif /* jit_x64_LIR_x64_h */