1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
* vim: set ts=8 sts=4 et sw=4 tw=99:
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "jit/mips64/Lowering-mips64.h"
#include "jit/mips64/Assembler-mips64.h"
#include "jit/MIR.h"
#include "jit/shared/Lowering-shared-inl.h"
using namespace js;
using namespace js::jit;
void
LIRGeneratorMIPS64::defineInt64Phi(MPhi* phi, size_t lirIndex)
{
defineTypedPhi(phi, lirIndex);
}
void
LIRGeneratorMIPS64::lowerInt64PhiInput(MPhi* phi, uint32_t inputPosition,
LBlock* block, size_t lirIndex)
{
lowerTypedPhiInput(phi, inputPosition, block, lirIndex);
}
LBoxAllocation
LIRGeneratorMIPS64::useBoxFixed(MDefinition* mir, Register reg1, Register reg2, bool useAtStart)
{
MOZ_ASSERT(mir->type() == MIRType::Value);
ensureDefined(mir);
return LBoxAllocation(LUse(reg1, mir->virtualRegister(), useAtStart));
}
void
LIRGeneratorMIPS64::lowerDivI64(MDiv* div)
{
if (div->isUnsigned()) {
lowerUDivI64(div);
return;
}
LDivOrModI64* lir = new(alloc()) LDivOrModI64(useRegister(div->lhs()), useRegister(div->rhs()),
temp());
defineInt64(lir, div);
}
void
LIRGeneratorMIPS64::lowerModI64(MMod* mod)
{
if (mod->isUnsigned()) {
lowerUModI64(mod);
return;
}
LDivOrModI64* lir = new(alloc()) LDivOrModI64(useRegister(mod->lhs()), useRegister(mod->rhs()),
temp());
defineInt64(lir, mod);
}
void
LIRGeneratorMIPS64::lowerUDivI64(MDiv* div)
{
LUDivOrModI64* lir = new(alloc()) LUDivOrModI64(useRegister(div->lhs()),
useRegister(div->rhs()),
temp());
defineInt64(lir, div);
}
void
LIRGeneratorMIPS64::lowerUModI64(MMod* mod)
{
LUDivOrModI64* lir = new(alloc()) LUDivOrModI64(useRegister(mod->lhs()),
useRegister(mod->rhs()),
temp());
defineInt64(lir, mod);
}
void
LIRGeneratorMIPS64::visitBox(MBox* box)
{
MDefinition* opd = box->getOperand(0);
// If the operand is a constant, emit near its uses.
if (opd->isConstant() && box->canEmitAtUses()) {
emitAtUses(box);
return;
}
if (opd->isConstant()) {
define(new(alloc()) LValue(opd->toConstant()->toJSValue()), box, LDefinition(LDefinition::BOX));
} else {
LBox* ins = new(alloc()) LBox(useRegister(opd), opd->type());
define(ins, box, LDefinition(LDefinition::BOX));
}
}
void
LIRGeneratorMIPS64::visitUnbox(MUnbox* unbox)
{
MDefinition* box = unbox->getOperand(0);
if (box->type() == MIRType::ObjectOrNull) {
LUnboxObjectOrNull* lir = new(alloc()) LUnboxObjectOrNull(useRegisterAtStart(box));
if (unbox->fallible())
assignSnapshot(lir, unbox->bailoutKind());
defineReuseInput(lir, unbox, 0);
return;
}
MOZ_ASSERT(box->type() == MIRType::Value);
LUnbox* lir;
if (IsFloatingPointType(unbox->type())) {
lir = new(alloc()) LUnboxFloatingPoint(useRegisterAtStart(box), unbox->type());
} else if (unbox->fallible()) {
// If the unbox is fallible, load the Value in a register first to
// avoid multiple loads.
lir = new(alloc()) LUnbox(useRegisterAtStart(box));
} else {
lir = new(alloc()) LUnbox(useAtStart(box));
}
if (unbox->fallible())
assignSnapshot(lir, unbox->bailoutKind());
define(lir, unbox);
}
void
LIRGeneratorMIPS64::visitReturn(MReturn* ret)
{
MDefinition* opd = ret->getOperand(0);
MOZ_ASSERT(opd->type() == MIRType::Value);
LReturn* ins = new(alloc()) LReturn;
ins->setOperand(0, useFixed(opd, JSReturnReg));
add(ins);
}
void
LIRGeneratorMIPS64::defineUntypedPhi(MPhi* phi, size_t lirIndex)
{
defineTypedPhi(phi, lirIndex);
}
void
LIRGeneratorMIPS64::lowerUntypedPhiInput(MPhi* phi, uint32_t inputPosition,
LBlock* block, size_t lirIndex)
{
lowerTypedPhiInput(phi, inputPosition, block, lirIndex);
}
void
LIRGeneratorMIPS64::lowerTruncateDToInt32(MTruncateToInt32* ins)
{
MDefinition* opd = ins->input();
MOZ_ASSERT(opd->type() == MIRType::Double);
define(new(alloc())
LTruncateDToInt32(useRegister(opd), tempDouble()), ins);
}
void
LIRGeneratorMIPS64::lowerTruncateFToInt32(MTruncateToInt32* ins)
{
MDefinition* opd = ins->input();
MOZ_ASSERT(opd->type() == MIRType::Float32);
define(new(alloc())
LTruncateFToInt32(useRegister(opd), tempFloat32()), ins);
}
void
LIRGeneratorMIPS64::visitRandom(MRandom* ins)
{
LRandom *lir = new(alloc()) LRandom(temp(), temp(), temp());
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
}
|