mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-29 11:57:32 +09:00
Issue #3049 - Split loongarch64 Ion lowering from mips64
This commit is contained in:
parent
70d8824b1d
commit
bb16a45039
8 changed files with 657 additions and 8 deletions
|
|
@ -20,7 +20,7 @@
|
|||
#elif defined(JS_CODEGEN_ARM64)
|
||||
# include "jit/arm64/CodeGenerator-arm64.h"
|
||||
#elif defined(JS_CODEGEN_LOONGARCH64)
|
||||
# include "jit/mips64/CodeGenerator-mips64.h"
|
||||
# include "jit/loongarch64/CodeGenerator-loongarch64.h"
|
||||
#elif defined(JS_CODEGEN_MIPS32)
|
||||
# include "jit/mips32/CodeGenerator-mips32.h"
|
||||
#elif defined(JS_CODEGEN_MIPS64)
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
#elif defined(JS_CODEGEN_ARM64)
|
||||
# include "jit/arm64/Lowering-arm64.h"
|
||||
#elif defined(JS_CODEGEN_LOONGARCH64)
|
||||
# include "jit/mips64/Lowering-mips64.h"
|
||||
# include "jit/loongarch64/Lowering-loongarch64.h"
|
||||
#elif defined(JS_CODEGEN_MIPS32)
|
||||
# include "jit/mips32/Lowering-mips32.h"
|
||||
#elif defined(JS_CODEGEN_MIPS64)
|
||||
|
|
|
|||
363
js/src/jit/loongarch64/CodeGenerator-loongarch64.cpp
Normal file
363
js/src/jit/loongarch64/CodeGenerator-loongarch64.cpp
Normal file
|
|
@ -0,0 +1,363 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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/loongarch64/CodeGenerator-loongarch64.h"
|
||||
|
||||
#include "jit/JitFrames.h"
|
||||
#include "jit/MIR.h"
|
||||
#include "jit/MIRGraph.h"
|
||||
#include "vm/Shape.h"
|
||||
#include "vm/TraceLogging.h"
|
||||
|
||||
#include "jit/MacroAssembler-inl.h"
|
||||
#include "jit/shared/CodeGenerator-shared-inl.h"
|
||||
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitCompare(LCompare* comp)
|
||||
{
|
||||
MCompare* mir = comp->mir();
|
||||
Assembler::Condition cond = JSOpToCondition(mir->compareType(), comp->jsop());
|
||||
const LAllocation* left = comp->getOperand(0);
|
||||
const LAllocation* right = comp->getOperand(1);
|
||||
const LDefinition* def = comp->getDef(0);
|
||||
|
||||
if (mir->compareType() == MCompare::Compare_Object) {
|
||||
if (right->isGeneralReg())
|
||||
masm.cmpPtrSet(cond, ToRegister(left), ToRegister(right), ToRegister(def));
|
||||
else
|
||||
masm.cmpPtrSet(cond, ToRegister(left), ToAddress(right), ToRegister(def));
|
||||
return;
|
||||
}
|
||||
|
||||
CodeGeneratorMIPSShared::visitCompare(comp);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitCompareAndBranch(LCompareAndBranch* comp)
|
||||
{
|
||||
MCompare* mir = comp->cmpMir();
|
||||
Assembler::Condition cond = JSOpToCondition(mir->compareType(), comp->jsop());
|
||||
|
||||
if (mir->compareType() == MCompare::Compare_Object) {
|
||||
if (comp->right()->isGeneralReg()) {
|
||||
emitBranch(ToRegister(comp->left()), ToRegister(comp->right()), cond,
|
||||
comp->ifTrue(), comp->ifFalse());
|
||||
} else {
|
||||
masm.loadPtr(ToAddress(comp->right()), ScratchRegister);
|
||||
emitBranch(ToRegister(comp->left()), ScratchRegister, cond,
|
||||
comp->ifTrue(), comp->ifFalse());
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
CodeGeneratorMIPSShared::visitCompareAndBranch(comp);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitDivI(LDivI* ins)
|
||||
{
|
||||
Register lhs = ToRegister(ins->lhs());
|
||||
Register rhs = ToRegister(ins->rhs());
|
||||
Register dest = ToRegister(ins->output());
|
||||
Register temp = ToRegister(ins->getTemp(0));
|
||||
MDiv* mir = ins->mir();
|
||||
|
||||
Label done;
|
||||
|
||||
if (mir->canBeDivideByZero()) {
|
||||
if (mir->trapOnError()) {
|
||||
masm.ma_b(rhs, rhs, trap(mir, wasm::Trap::IntegerDivideByZero), Assembler::Zero);
|
||||
} else if (mir->canTruncateInfinities()) {
|
||||
Label notzero;
|
||||
masm.ma_b(rhs, rhs, ¬zero, Assembler::NonZero, ShortJump);
|
||||
masm.move32(Imm32(0), dest);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(¬zero);
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
bailoutCmp32(Assembler::Zero, rhs, rhs, ins->snapshot());
|
||||
}
|
||||
}
|
||||
|
||||
if (mir->canBeNegativeOverflow()) {
|
||||
Label notMinInt;
|
||||
masm.move32(Imm32(INT32_MIN), temp);
|
||||
masm.ma_b(lhs, temp, ¬MinInt, Assembler::NotEqual, ShortJump);
|
||||
|
||||
masm.move32(Imm32(-1), temp);
|
||||
if (mir->trapOnError()) {
|
||||
masm.ma_b(rhs, temp, trap(mir, wasm::Trap::IntegerOverflow), Assembler::Equal);
|
||||
} else if (mir->canTruncateOverflow()) {
|
||||
Label skip;
|
||||
masm.ma_b(rhs, temp, &skip, Assembler::NotEqual, ShortJump);
|
||||
masm.move32(Imm32(INT32_MIN), dest);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(&skip);
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
bailoutCmp32(Assembler::Equal, rhs, temp, ins->snapshot());
|
||||
}
|
||||
masm.bind(¬MinInt);
|
||||
}
|
||||
|
||||
if (!mir->canTruncateNegativeZero() && mir->canBeNegativeZero()) {
|
||||
Label nonzero;
|
||||
masm.ma_b(lhs, lhs, &nonzero, Assembler::NonZero, ShortJump);
|
||||
bailoutCmp32(Assembler::LessThan, rhs, Imm32(0), ins->snapshot());
|
||||
masm.bind(&nonzero);
|
||||
}
|
||||
|
||||
if (mir->canTruncateRemainder()) {
|
||||
masm.as_div_w(dest, lhs, rhs);
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
|
||||
Label remainderNonZero;
|
||||
masm.ma_div_branch_overflow(dest, lhs, rhs, &remainderNonZero);
|
||||
bailoutFrom(&remainderNonZero, ins->snapshot());
|
||||
}
|
||||
|
||||
masm.bind(&done);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitModI(LModI* ins)
|
||||
{
|
||||
Register lhs = ToRegister(ins->lhs());
|
||||
Register rhs = ToRegister(ins->rhs());
|
||||
Register dest = ToRegister(ins->output());
|
||||
Register callTemp = ToRegister(ins->callTemp());
|
||||
MMod* mir = ins->mir();
|
||||
Label done, prevent;
|
||||
|
||||
masm.move32(lhs, callTemp);
|
||||
|
||||
if (mir->canBeNegativeDividend()) {
|
||||
masm.ma_b(lhs, Imm32(INT_MIN), &prevent, Assembler::NotEqual, ShortJump);
|
||||
if (mir->isTruncated()) {
|
||||
Label skip;
|
||||
masm.ma_b(rhs, Imm32(-1), &skip, Assembler::NotEqual, ShortJump);
|
||||
masm.move32(Imm32(0), dest);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(&skip);
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
bailoutCmp32(Assembler::Equal, rhs, Imm32(-1), ins->snapshot());
|
||||
}
|
||||
masm.bind(&prevent);
|
||||
}
|
||||
|
||||
if (mir->canBeDivideByZero()) {
|
||||
if (mir->isTruncated()) {
|
||||
if (mir->trapOnError()) {
|
||||
masm.ma_b(rhs, rhs, trap(mir, wasm::Trap::IntegerDivideByZero), Assembler::Zero);
|
||||
} else {
|
||||
Label skip;
|
||||
masm.ma_b(rhs, Imm32(0), &skip, Assembler::NotEqual, ShortJump);
|
||||
masm.move32(Imm32(0), dest);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(&skip);
|
||||
}
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
bailoutCmp32(Assembler::Equal, rhs, Imm32(0), ins->snapshot());
|
||||
}
|
||||
}
|
||||
|
||||
if (mir->canBeNegativeDividend()) {
|
||||
Label notNegative;
|
||||
masm.ma_b(rhs, Imm32(0), ¬Negative, Assembler::GreaterThan, ShortJump);
|
||||
if (mir->isTruncated()) {
|
||||
Label skip;
|
||||
masm.ma_b(lhs, Imm32(0), &skip, Assembler::NotEqual, ShortJump);
|
||||
masm.move32(Imm32(0), dest);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(&skip);
|
||||
} else {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
bailoutCmp32(Assembler::Equal, lhs, Imm32(0), ins->snapshot());
|
||||
}
|
||||
masm.bind(¬Negative);
|
||||
}
|
||||
|
||||
masm.as_mod_w(dest, lhs, rhs);
|
||||
|
||||
if (mir->canBeNegativeDividend() && !mir->isTruncated()) {
|
||||
MOZ_ASSERT(mir->fallible());
|
||||
masm.ma_b(dest, Imm32(0), &done, Assembler::NotEqual, ShortJump);
|
||||
bailoutCmp32(Assembler::Signed, callTemp, Imm32(0), ins->snapshot());
|
||||
}
|
||||
masm.bind(&done);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitUDivOrMod(LUDivOrMod* ins)
|
||||
{
|
||||
Register lhs = ToRegister(ins->lhs());
|
||||
Register rhs = ToRegister(ins->rhs());
|
||||
Register output = ToRegister(ins->output());
|
||||
Label done;
|
||||
|
||||
if (ins->canBeDivideByZero()) {
|
||||
if (ins->mir()->isTruncated()) {
|
||||
if (ins->trapOnError()) {
|
||||
masm.ma_b(rhs, rhs, trap(ins, wasm::Trap::IntegerDivideByZero), Assembler::Zero);
|
||||
} else {
|
||||
Label notzero;
|
||||
masm.ma_b(rhs, rhs, ¬zero, Assembler::NonZero, ShortJump);
|
||||
masm.move32(Imm32(0), output);
|
||||
masm.ma_b(&done, ShortJump);
|
||||
masm.bind(¬zero);
|
||||
}
|
||||
} else {
|
||||
bailoutCmp32(Assembler::Equal, rhs, Imm32(0), ins->snapshot());
|
||||
}
|
||||
}
|
||||
|
||||
masm.as_mod_wu(ScratchRegister, lhs, rhs);
|
||||
masm.move32(ScratchRegister, output);
|
||||
|
||||
if (ins->mir()->isDiv()) {
|
||||
if (!ins->mir()->toDiv()->canTruncateRemainder())
|
||||
bailoutCmp32(Assembler::NonZero, output, output, ins->snapshot());
|
||||
masm.as_div_wu(output, lhs, rhs);
|
||||
}
|
||||
|
||||
if (!ins->mir()->isTruncated())
|
||||
bailoutCmp32(Assembler::LessThan, output, Imm32(0), ins->snapshot());
|
||||
|
||||
masm.bind(&done);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitDivOrModI64(LDivOrModI64* lir)
|
||||
{
|
||||
Register lhs = ToRegister(lir->lhs());
|
||||
Register rhs = ToRegister(lir->rhs());
|
||||
Register output = ToRegister(lir->output());
|
||||
|
||||
Label done;
|
||||
|
||||
if (lir->canBeDivideByZero())
|
||||
masm.ma_b(rhs, rhs, trap(lir, wasm::Trap::IntegerDivideByZero), Assembler::Zero);
|
||||
|
||||
if (lir->canBeNegativeOverflow()) {
|
||||
Label notmin;
|
||||
masm.branchPtr(Assembler::NotEqual, lhs, ImmWord(INT64_MIN), ¬min);
|
||||
masm.branchPtr(Assembler::NotEqual, rhs, ImmWord(-1), ¬min);
|
||||
if (lir->mir()->isMod()) {
|
||||
masm.ma_xor(output, output);
|
||||
} else {
|
||||
masm.jump(trap(lir, wasm::Trap::IntegerOverflow));
|
||||
}
|
||||
masm.jump(&done);
|
||||
masm.bind(¬min);
|
||||
}
|
||||
|
||||
if (lir->mir()->isMod())
|
||||
masm.as_mod_d(output, lhs, rhs);
|
||||
else
|
||||
masm.as_div_d(output, lhs, rhs);
|
||||
|
||||
masm.bind(&done);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitUDivOrModI64(LUDivOrModI64* lir)
|
||||
{
|
||||
Register lhs = ToRegister(lir->lhs());
|
||||
Register rhs = ToRegister(lir->rhs());
|
||||
Register output = ToRegister(lir->output());
|
||||
|
||||
Label done;
|
||||
|
||||
if (lir->canBeDivideByZero())
|
||||
masm.ma_b(rhs, rhs, trap(lir, wasm::Trap::IntegerDivideByZero), Assembler::Zero);
|
||||
|
||||
if (lir->mir()->isMod())
|
||||
masm.as_mod_du(output, lhs, rhs);
|
||||
else
|
||||
masm.as_div_du(output, lhs, rhs);
|
||||
|
||||
masm.bind(&done);
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitWasmAddOffset(LWasmAddOffset* lir)
|
||||
{
|
||||
MWasmAddOffset* mir = lir->mir();
|
||||
Register base = ToRegister(lir->base());
|
||||
Register out = ToRegister(lir->output());
|
||||
|
||||
Register limitBase = base;
|
||||
if (base == out) {
|
||||
limitBase = ScratchRegister;
|
||||
masm.movePtr(base, limitBase);
|
||||
} else {
|
||||
masm.movePtr(base, out);
|
||||
}
|
||||
|
||||
masm.addPtr(Imm32(mir->offset()), out);
|
||||
masm.branchPtr(Assembler::Below, out, limitBase, trap(mir, wasm::Trap::OutOfBounds));
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAsmJSCompareExchangeHeap(LAsmJSCompareExchangeHeap* ins)
|
||||
{
|
||||
(void)ins;
|
||||
MOZ_CRASH("asm.js atomics are not supported on loongarch64 yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAsmJSAtomicExchangeHeap(LAsmJSAtomicExchangeHeap* ins)
|
||||
{
|
||||
(void)ins;
|
||||
MOZ_CRASH("asm.js atomics are not supported on loongarch64 yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAsmJSAtomicBinopHeap(LAsmJSAtomicBinopHeap* ins)
|
||||
{
|
||||
(void)ins;
|
||||
MOZ_CRASH("asm.js atomics are not supported on loongarch64 yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAsmJSAtomicBinopHeapForEffect(LAsmJSAtomicBinopHeapForEffect* ins)
|
||||
{
|
||||
(void)ins;
|
||||
MOZ_CRASH("asm.js atomics are not supported on loongarch64 yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAtomicTypedArrayElementBinop(LAtomicTypedArrayElementBinop* lir)
|
||||
{
|
||||
(void)lir;
|
||||
MOZ_CRASH("atomics are not supported on loongarch64 Ion yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAtomicTypedArrayElementBinopForEffect(LAtomicTypedArrayElementBinopForEffect* lir)
|
||||
{
|
||||
(void)lir;
|
||||
MOZ_CRASH("atomics are not supported on loongarch64 Ion yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitCompareExchangeTypedArrayElement(LCompareExchangeTypedArrayElement* lir)
|
||||
{
|
||||
(void)lir;
|
||||
MOZ_CRASH("atomics are not supported on loongarch64 Ion yet");
|
||||
}
|
||||
|
||||
void
|
||||
CodeGeneratorLoongArch64::visitAtomicExchangeTypedArrayElement(LAtomicExchangeTypedArrayElement* lir)
|
||||
{
|
||||
(void)lir;
|
||||
MOZ_CRASH("atomics are not supported on loongarch64 Ion yet");
|
||||
}
|
||||
44
js/src/jit/loongarch64/CodeGenerator-loongarch64.h
Normal file
44
js/src/jit/loongarch64/CodeGenerator-loongarch64.h
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef jit_loongarch64_CodeGenerator_loongarch64_h
|
||||
#define jit_loongarch64_CodeGenerator_loongarch64_h
|
||||
|
||||
#define CodeGeneratorSpecific CodeGeneratorMIPS64Specific
|
||||
#include "jit/mips64/CodeGenerator-mips64.h"
|
||||
#undef CodeGeneratorSpecific
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
class CodeGeneratorLoongArch64 : public CodeGeneratorMIPS64
|
||||
{
|
||||
public:
|
||||
using CodeGeneratorMIPS64::CodeGeneratorMIPS64;
|
||||
|
||||
void visitCompare(LCompare* comp);
|
||||
void visitCompareAndBranch(LCompareAndBranch* comp);
|
||||
void visitDivI(LDivI* ins);
|
||||
void visitModI(LModI* ins);
|
||||
void visitUDivOrMod(LUDivOrMod* ins);
|
||||
void visitDivOrModI64(LDivOrModI64* lir);
|
||||
void visitUDivOrModI64(LUDivOrModI64* lir);
|
||||
void visitWasmAddOffset(LWasmAddOffset* lir);
|
||||
void visitAsmJSCompareExchangeHeap(LAsmJSCompareExchangeHeap* ins);
|
||||
void visitAsmJSAtomicExchangeHeap(LAsmJSAtomicExchangeHeap* ins);
|
||||
void visitAsmJSAtomicBinopHeap(LAsmJSAtomicBinopHeap* ins);
|
||||
void visitAsmJSAtomicBinopHeapForEffect(LAsmJSAtomicBinopHeapForEffect* ins);
|
||||
void visitAtomicTypedArrayElementBinop(LAtomicTypedArrayElementBinop* lir);
|
||||
void visitAtomicTypedArrayElementBinopForEffect(LAtomicTypedArrayElementBinopForEffect* lir);
|
||||
void visitCompareExchangeTypedArrayElement(LCompareExchangeTypedArrayElement* lir);
|
||||
void visitAtomicExchangeTypedArrayElement(LAtomicExchangeTypedArrayElement* lir);
|
||||
};
|
||||
|
||||
typedef CodeGeneratorLoongArch64 CodeGeneratorSpecific;
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
#endif /* jit_loongarch64_CodeGenerator_loongarch64_h */
|
||||
189
js/src/jit/loongarch64/Lowering-loongarch64.cpp
Normal file
189
js/src/jit/loongarch64/Lowering-loongarch64.cpp
Normal file
|
|
@ -0,0 +1,189 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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/loongarch64/Lowering-loongarch64.h"
|
||||
|
||||
#include "jit/loongarch64/Assembler-loongarch64.h"
|
||||
|
||||
#include "jit/MIR.h"
|
||||
|
||||
#include "jit/shared/Lowering-shared-inl.h"
|
||||
|
||||
using namespace js;
|
||||
using namespace js::jit;
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::defineInt64Phi(MPhi* phi, size_t lirIndex)
|
||||
{
|
||||
defineTypedPhi(phi, lirIndex);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::lowerInt64PhiInput(MPhi* phi, uint32_t inputPosition,
|
||||
LBlock* block, size_t lirIndex)
|
||||
{
|
||||
lowerTypedPhiInput(phi, inputPosition, block, lirIndex);
|
||||
}
|
||||
|
||||
LBoxAllocation
|
||||
LIRGeneratorLoongArch64::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
|
||||
LIRGeneratorLoongArch64::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
|
||||
LIRGeneratorLoongArch64::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
|
||||
LIRGeneratorLoongArch64::lowerUDivI64(MDiv* div)
|
||||
{
|
||||
LUDivOrModI64* lir = new(alloc()) LUDivOrModI64(useRegister(div->lhs()),
|
||||
useRegister(div->rhs()),
|
||||
temp());
|
||||
defineInt64(lir, div);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::lowerUModI64(MMod* mod)
|
||||
{
|
||||
LUDivOrModI64* lir = new(alloc()) LUDivOrModI64(useRegister(mod->lhs()),
|
||||
useRegister(mod->rhs()),
|
||||
temp());
|
||||
defineInt64(lir, mod);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::visitBox(MBox* box)
|
||||
{
|
||||
MDefinition* opd = box->getOperand(0);
|
||||
|
||||
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
|
||||
LIRGeneratorLoongArch64::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()) {
|
||||
lir = new(alloc()) LUnbox(useRegisterAtStart(box));
|
||||
} else {
|
||||
lir = new(alloc()) LUnbox(useAtStart(box));
|
||||
}
|
||||
|
||||
if (unbox->fallible())
|
||||
assignSnapshot(lir, unbox->bailoutKind());
|
||||
|
||||
define(lir, unbox);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::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
|
||||
LIRGeneratorLoongArch64::defineUntypedPhi(MPhi* phi, size_t lirIndex)
|
||||
{
|
||||
defineTypedPhi(phi, lirIndex);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::lowerUntypedPhiInput(MPhi* phi, uint32_t inputPosition,
|
||||
LBlock* block, size_t lirIndex)
|
||||
{
|
||||
lowerTypedPhiInput(phi, inputPosition, block, lirIndex);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::lowerTruncateDToInt32(MTruncateToInt32* ins)
|
||||
{
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Double);
|
||||
|
||||
define(new(alloc())
|
||||
LTruncateDToInt32(useRegister(opd), tempDouble()), ins);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::lowerTruncateFToInt32(MTruncateToInt32* ins)
|
||||
{
|
||||
MDefinition* opd = ins->input();
|
||||
MOZ_ASSERT(opd->type() == MIRType::Float32);
|
||||
|
||||
define(new(alloc())
|
||||
LTruncateFToInt32(useRegister(opd), tempFloat32()), ins);
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::visitRandom(MRandom* ins)
|
||||
{
|
||||
LRandom *lir = new(alloc()) LRandom(temp(),
|
||||
temp(),
|
||||
temp(),
|
||||
temp());
|
||||
defineFixed(lir, ins, LFloatReg(ReturnDoubleReg));
|
||||
}
|
||||
|
||||
void
|
||||
LIRGeneratorLoongArch64::visitSignExtendInt64(MSignExtendInt64* ins)
|
||||
{
|
||||
defineInt64(new(alloc()) LSignExtendInt64(useInt64RegisterAtStart(ins->input())), ins);
|
||||
}
|
||||
56
js/src/jit/loongarch64/Lowering-loongarch64.h
Normal file
56
js/src/jit/loongarch64/Lowering-loongarch64.h
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* 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/. */
|
||||
|
||||
#ifndef jit_loongarch64_Lowering_loongarch64_h
|
||||
#define jit_loongarch64_Lowering_loongarch64_h
|
||||
|
||||
#include "jit/mips-shared/Lowering-mips-shared.h"
|
||||
|
||||
namespace js {
|
||||
namespace jit {
|
||||
|
||||
class LIRGeneratorLoongArch64 : public LIRGeneratorMIPSShared
|
||||
{
|
||||
protected:
|
||||
LIRGeneratorLoongArch64(MIRGenerator* gen, MIRGraph& graph, LIRGraph& lirGraph)
|
||||
: LIRGeneratorMIPSShared(gen, graph, lirGraph)
|
||||
{ }
|
||||
|
||||
protected:
|
||||
void lowerInt64PhiInput(MPhi*, uint32_t, LBlock*, size_t);
|
||||
void defineInt64Phi(MPhi*, size_t);
|
||||
|
||||
LBoxAllocation useBoxFixed(MDefinition* mir, Register reg1, Register reg2,
|
||||
bool useAtStart = false);
|
||||
|
||||
inline LDefinition tempToUnbox() {
|
||||
return temp();
|
||||
}
|
||||
|
||||
void lowerUntypedPhiInput(MPhi* phi, uint32_t inputPosition, LBlock* block, size_t lirIndex);
|
||||
void defineUntypedPhi(MPhi* phi, size_t lirIndex);
|
||||
|
||||
void lowerTruncateDToInt32(MTruncateToInt32* ins);
|
||||
void lowerTruncateFToInt32(MTruncateToInt32* ins);
|
||||
|
||||
void lowerDivI64(MDiv* div);
|
||||
void lowerModI64(MMod* mod);
|
||||
void lowerUDivI64(MDiv* div);
|
||||
void lowerUModI64(MMod* mod);
|
||||
|
||||
public:
|
||||
void visitBox(MBox* box);
|
||||
void visitUnbox(MUnbox* unbox);
|
||||
void visitReturn(MReturn* ret);
|
||||
void visitRandom(MRandom* ins);
|
||||
void visitSignExtendInt64(MSignExtendInt64* ins);
|
||||
};
|
||||
|
||||
typedef LIRGeneratorLoongArch64 LIRGeneratorSpecific;
|
||||
|
||||
} // namespace jit
|
||||
} // namespace js
|
||||
|
||||
#endif /* jit_loongarch64_Lowering_loongarch64_h */
|
||||
|
|
@ -5,11 +5,7 @@
|
|||
|
||||
#include "jit/mips64/Lowering-mips64.h"
|
||||
|
||||
#ifdef JS_CODEGEN_LOONGARCH64
|
||||
# include "jit/loongarch64/Assembler-loongarch64.h"
|
||||
#else
|
||||
# include "jit/mips64/Assembler-mips64.h"
|
||||
#endif
|
||||
#include "jit/mips64/Assembler-mips64.h"
|
||||
|
||||
#include "jit/MIR.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -548,11 +548,12 @@ elif CONFIG['JS_CODEGEN_LOONGARCH64']:
|
|||
'jit/loongarch64/Bailouts-loongarch64.cpp',
|
||||
'jit/loongarch64/BaselineCompiler-loongarch64.cpp',
|
||||
'jit/loongarch64/BaselineIC-loongarch64.cpp',
|
||||
'jit/loongarch64/CodeGenerator-loongarch64.cpp',
|
||||
'jit/loongarch64/Lowering-loongarch64.cpp',
|
||||
'jit/loongarch64/MacroAssembler-loongarch64.cpp',
|
||||
'jit/loongarch64/SharedIC-loongarch64.cpp',
|
||||
'jit/loongarch64/Trampoline-loongarch64.cpp',
|
||||
'jit/mips64/CodeGenerator-mips64.cpp',
|
||||
'jit/mips64/Lowering-mips64.cpp',
|
||||
'jit/mips64/MoveEmitter-mips64.cpp',
|
||||
]
|
||||
elif CONFIG['JS_CODEGEN_MIPS32'] or CONFIG['JS_CODEGEN_MIPS64']:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue