Commit 693c553c authored by mbrandy's avatar mbrandy Committed by Commit bot

PPC64: Implemented the RoundInt64ToFloat32 TurboFan operator.

R=ahaas@chromium.org, joransiu@ca.ibm.com, jyan@ca.ibm.com, michael_dawson@ca.ibm.com, dstence@us.ibm.com
BUG=

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

Cr-Commit-Position: refs/heads/master@{#31933}
parent d62efc12
......@@ -1087,6 +1087,10 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
__ Move(i.OutputRegister(), i.InputRegister(0));
DCHECK_EQ(LeaveRC, i.OutputRCBit());
break;
case kPPC_Int64ToFloat32:
__ ConvertInt64ToFloat(i.InputRegister(0), i.OutputDoubleRegister());
DCHECK_EQ(LeaveRC, i.OutputRCBit());
break;
case kPPC_Int64ToDouble:
__ ConvertInt64ToDouble(i.InputRegister(0), i.OutputDoubleRegister());
DCHECK_EQ(LeaveRC, i.OutputRCBit());
......
......@@ -78,6 +78,7 @@ namespace compiler {
V(PPC_ExtendSignWord32) \
V(PPC_Uint32ToUint64) \
V(PPC_Int64ToInt32) \
V(PPC_Int64ToFloat32) \
V(PPC_Int64ToDouble) \
V(PPC_Int32ToDouble) \
V(PPC_Uint32ToDouble) \
......
......@@ -963,6 +963,11 @@ void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
}
void InstructionSelector::VisitRoundInt64ToFloat32(Node* node) {
VisitRR(this, kPPC_Int64ToFloat32, node);
}
void InstructionSelector::VisitRoundInt64ToFloat64(Node* node) {
VisitRR(this, kPPC_Int64ToDouble, node);
}
......
......@@ -2163,6 +2163,12 @@ void Assembler::fcfid(const DoubleRegister frt, const DoubleRegister frb,
}
void Assembler::fcfids(const DoubleRegister frt, const DoubleRegister frb,
RCBit rc) {
emit(EXT3 | FCFID | frt.code() * B21 | frb.code() * B11 | rc);
}
void Assembler::fctid(const DoubleRegister frt, const DoubleRegister frb,
RCBit rc) {
emit(EXT4 | FCTID | frt.code() * B21 | frb.code() * B11 | rc);
......
......@@ -1050,6 +1050,8 @@ class Assembler : public AssemblerBase {
RCBit rc = LeaveRC);
void fcfid(const DoubleRegister frt, const DoubleRegister frb,
RCBit rc = LeaveRC);
void fcfids(const DoubleRegister frt, const DoubleRegister frb,
RCBit rc = LeaveRC);
void fctid(const DoubleRegister frt, const DoubleRegister frb,
RCBit rc = LeaveRC);
void fctidz(const DoubleRegister frt, const DoubleRegister frb,
......
......@@ -78,6 +78,7 @@ class Decoder {
void DecodeExt1(Instruction* instr);
void DecodeExt2(Instruction* instr);
void DecodeExt3(Instruction* instr);
void DecodeExt4(Instruction* instr);
void DecodeExt5(Instruction* instr);
......@@ -882,6 +883,19 @@ void Decoder::DecodeExt2(Instruction* instr) {
}
void Decoder::DecodeExt3(Instruction* instr) {
switch (instr->Bits(10, 1) << 1) {
case FCFID: {
Format(instr, "fcfids'. 'Dt, 'Db");
break;
}
default: {
Unknown(instr); // not used by V8
}
}
}
void Decoder::DecodeExt4(Instruction* instr) {
switch (instr->Bits(5, 1) << 1) {
case FDIV: {
......@@ -1299,7 +1313,10 @@ int Decoder::InstructionDecode(byte* instr_ptr) {
Format(instr, "stfdu 'Dt, 'int16('ra)");
break;
}
case EXT3:
case EXT3: {
DecodeExt3(instr);
break;
}
case EXT4: {
DecodeExt4(instr);
break;
......
......@@ -659,8 +659,7 @@ void MacroAssembler::ConvertIntToFloat(const DoubleRegister dst,
const Register src,
const Register int_scratch) {
MovIntToDouble(dst, src, int_scratch);
fcfid(dst, dst);
frsp(dst, dst);
fcfids(dst, dst);
}
......@@ -670,6 +669,13 @@ void MacroAssembler::ConvertInt64ToDouble(Register src,
MovInt64ToDouble(double_dst, src);
fcfid(double_dst, double_dst);
}
void MacroAssembler::ConvertInt64ToFloat(Register src,
DoubleRegister double_dst) {
MovInt64ToDouble(double_dst, src);
fcfids(double_dst, double_dst);
}
#endif
......
......@@ -388,6 +388,7 @@ class MacroAssembler : public Assembler {
#if V8_TARGET_ARCH_PPC64
void ConvertInt64ToDouble(Register src, DoubleRegister double_dst);
void ConvertInt64ToFloat(Register src, DoubleRegister double_dst);
#endif
// Converts the double_input to an integer. Note that, upon return,
......
......@@ -2695,6 +2695,24 @@ void Simulator::ExecuteExt2(Instruction* instr) {
}
void Simulator::ExecuteExt3(Instruction* instr) {
int opcode = instr->Bits(10, 1) << 1;
switch (opcode) {
case FCFID: {
// fcfids
int frt = instr->RTValue();
int frb = instr->RBValue();
double t_val = get_double_from_d_register(frb);
int64_t* frb_val_p = reinterpret_cast<int64_t*>(&t_val);
double frt_val = static_cast<float>(*frb_val_p);
set_d_register_from_double(frt, frt_val);
return;
}
}
UNIMPLEMENTED(); // Not used by V8.
}
void Simulator::ExecuteExt4(Instruction* instr) {
switch (instr->Bits(5, 1) << 1) {
case FDIV: {
......@@ -3610,8 +3628,10 @@ void Simulator::ExecuteGeneric(Instruction* instr) {
break;
}
case EXT3:
UNIMPLEMENTED();
case EXT3: {
ExecuteExt3(instr);
break;
}
case EXT4: {
ExecuteExt4(instr);
break;
......
......@@ -311,6 +311,7 @@ class Simulator {
bool ExecuteExt2_9bit_part2(Instruction* instr);
void ExecuteExt2_5bit(Instruction* instr);
void ExecuteExt2(Instruction* instr);
void ExecuteExt3(Instruction* instr);
void ExecuteExt4(Instruction* instr);
#if V8_TARGET_ARCH_PPC64
void ExecuteExt5(Instruction* instr);
......
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