Commit b9ed2199 authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: [turbofan] Support for %_DoubleHi, %_DoubleLo and %_ConstructDouble.

Port 4436c264

Original commit message:
This adds support for the double bits intrinsics to TurboFan, and is
a first step towards fast Math functions inlined into TurboFan code
or even compiled by themselves with TurboFan.

BUG=

Review URL: https://codereview.chromium.org/980073003

Cr-Commit-Position: refs/heads/master@{#27028}
parent d2192c60
......@@ -621,6 +621,18 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ Trunc_uw_d(i.InputDoubleRegister(0), i.OutputRegister(), scratch);
break;
}
case kMipsFmoveLowUwD:
__ FmoveLow(i.OutputRegister(), i.InputDoubleRegister(0));
break;
case kMipsFmoveLowDUw:
__ FmoveLow(i.OutputDoubleRegister(), i.InputRegister(1));
break;
case kMipsFmoveHighUwD:
__ FmoveHigh(i.OutputRegister(), i.InputDoubleRegister(0));
break;
case kMipsFmoveHighDUw:
__ FmoveHigh(i.OutputDoubleRegister(), i.InputRegister(1));
break;
// ... more basic instructions ...
case kMipsLbu:
......
......@@ -61,6 +61,10 @@ namespace compiler {
V(MipsSwc1) \
V(MipsLdc1) \
V(MipsSdc1) \
V(MipsFmoveLowUwD) \
V(MipsFmoveLowDUw) \
V(MipsFmoveHighUwD) \
V(MipsFmoveHighDUw) \
V(MipsPush) \
V(MipsStoreToStackSlot) \
V(MipsStackClaim) \
......
......@@ -885,6 +885,38 @@ void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
}
void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
MipsOperandGenerator g(this);
Emit(kMipsFmoveLowUwD, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) {
MipsOperandGenerator g(this);
Emit(kMipsFmoveHighUwD, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) {
MipsOperandGenerator g(this);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Emit(kMipsFmoveLowDUw, g.DefineSameAsFirst(node), g.UseRegister(left),
g.UseRegister(right));
}
void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
MipsOperandGenerator g(this);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Emit(kMipsFmoveHighDUw, g.DefineSameAsFirst(node), g.UseRegister(left),
g.UseRegister(right));
}
// static
MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() {
......
......@@ -685,6 +685,21 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ Trunc_uw_d(i.InputDoubleRegister(0), i.OutputRegister(), scratch);
break;
}
case kMips64FmoveLowUwD:
__ FmoveLow(i.OutputRegister(), i.InputDoubleRegister(0));
// remove sign.
__ dsll32(i.OutputRegister(), i.OutputRegister(), 0);
__ dsrl32(i.OutputRegister(), i.OutputRegister(), 0);
break;
case kMips64FmoveLowDUw:
__ FmoveLow(i.OutputDoubleRegister(), i.InputRegister(1));
break;
case kMips64FmoveHighUwD:
__ FmoveHigh(i.OutputRegister(), i.InputDoubleRegister(0));
break;
case kMips64FmoveHighDUw:
__ FmoveHigh(i.OutputDoubleRegister(), i.InputRegister(1));
break;
// ... more basic instructions ...
case kMips64Lbu:
......
......@@ -76,6 +76,10 @@ namespace compiler {
V(Mips64Swc1) \
V(Mips64Ldc1) \
V(Mips64Sdc1) \
V(Mips64FmoveLowUwD) \
V(Mips64FmoveLowDUw) \
V(Mips64FmoveHighUwD) \
V(Mips64FmoveHighDUw) \
V(Mips64Push) \
V(Mips64StoreToStackSlot) \
V(Mips64StackClaim) \
......
......@@ -1137,6 +1137,38 @@ void InstructionSelector::VisitFloat64LessThanOrEqual(Node* node) {
}
void InstructionSelector::VisitFloat64ExtractLowWord32(Node* node) {
Mips64OperandGenerator g(this);
Emit(kMips64FmoveLowUwD, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitFloat64ExtractHighWord32(Node* node) {
Mips64OperandGenerator g(this);
Emit(kMips64FmoveHighUwD, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)));
}
void InstructionSelector::VisitFloat64InsertLowWord32(Node* node) {
Mips64OperandGenerator g(this);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Emit(kMips64FmoveLowDUw, g.DefineSameAsFirst(node), g.UseRegister(left),
g.UseRegister(right));
}
void InstructionSelector::VisitFloat64InsertHighWord32(Node* node) {
Mips64OperandGenerator g(this);
Node* left = node->InputAt(0);
Node* right = node->InputAt(1);
Emit(kMips64FmoveHighDUw, g.DefineSameAsFirst(node), g.UseRegister(left),
g.UseRegister(right));
}
// static
MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() {
......
......@@ -1549,6 +1549,18 @@ void MacroAssembler::BranchF(Label* target,
}
void MacroAssembler::FmoveLow(FPURegister dst, Register src_low) {
if (IsFp64Mode()) {
DCHECK(!src_low.is(at));
mfhc1(at, dst);
mtc1(src_low, dst);
mthc1(at, dst);
} else {
mtc1(src_low, dst);
}
}
void MacroAssembler::Move(FPURegister dst, float imm) {
li(at, Operand(bit_cast<int32_t>(imm)));
mtc1(at, dst);
......
......@@ -241,10 +241,16 @@ class MacroAssembler: public Assembler {
Mfhc1(dst_high, src);
}
inline void FmoveHigh(FPURegister dst, Register src_high) {
Mthc1(src_high, dst);
}
inline void FmoveLow(Register dst_low, FPURegister src) {
mfc1(dst_low, src);
}
void FmoveLow(FPURegister dst, Register src_low);
inline void Move(FPURegister dst, Register src_low, Register src_high) {
mtc1(src_low, dst);
Mthc1(src_high, dst);
......
......@@ -1717,6 +1717,14 @@ void MacroAssembler::BranchF(Label* target,
}
void MacroAssembler::FmoveLow(FPURegister dst, Register src_low) {
DCHECK(!src_low.is(at));
mfhc1(at, dst);
mtc1(src_low, dst);
mthc1(at, dst);
}
void MacroAssembler::Move(FPURegister dst, float imm) {
li(at, Operand(bit_cast<int32_t>(imm)));
mtc1(at, dst);
......
......@@ -262,10 +262,16 @@ class MacroAssembler: public Assembler {
mfhc1(dst_high, src);
}
inline void FmoveHigh(FPURegister dst, Register src_high) {
mthc1(src_high, dst);
}
inline void FmoveLow(Register dst_low, FPURegister src) {
mfc1(dst_low, src);
}
void FmoveLow(FPURegister dst, Register src_low);
inline void Move(FPURegister dst, Register src_low, Register src_high) {
mtc1(src_low, dst);
mthc1(src_high, dst);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment