Commit b785daa7 authored by chunyang.dai's avatar chunyang.dai Committed by Commit bot

X87: [turbofan] Add support for reinterpreting integers as floating point and vice versa.

port c610a222 (r30849).

original commit message:

BUG=

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

Cr-Commit-Position: refs/heads/master@{#30898}
parent 687ef62e
...@@ -1069,6 +1069,28 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { ...@@ -1069,6 +1069,28 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) {
} }
break; break;
} }
case kX87BitcastFI: {
__ fstp(0);
__ mov(i.OutputRegister(), MemOperand(esp, 0));
__ lea(esp, Operand(esp, kFloatSize));
break;
}
case kX87BitcastIF: {
if (instr->InputAt(0)->IsRegister()) {
__ lea(esp, Operand(esp, -kFloatSize));
__ mov(MemOperand(esp, 0), i.InputRegister(0));
__ fstp(0);
__ fld_s(MemOperand(esp, 0));
__ lea(esp, Operand(esp, kFloatSize));
} else {
__ lea(esp, Operand(esp, -kDoubleSize));
__ mov(MemOperand(esp, 0), i.InputRegister(0));
__ fstp(0);
__ fld_d(MemOperand(esp, 0));
__ lea(esp, Operand(esp, kDoubleSize));
}
break;
}
case kX87Lea: { case kX87Lea: {
AddressingMode mode = AddressingModeField::decode(instr->opcode()); AddressingMode mode = AddressingModeField::decode(instr->opcode());
// Shorten "leal" to "addl", "subl" or "shll" if the register allocation // Shorten "leal" to "addl", "subl" or "shll" if the register allocation
......
...@@ -74,6 +74,8 @@ namespace compiler { ...@@ -74,6 +74,8 @@ namespace compiler {
V(X87Movss) \ V(X87Movss) \
V(X87Movsd) \ V(X87Movsd) \
V(X87Lea) \ V(X87Lea) \
V(X87BitcastFI) \
V(X87BitcastIF) \
V(X87Push) \ V(X87Push) \
V(X87PushFloat64) \ V(X87PushFloat64) \
V(X87PushFloat32) \ V(X87PushFloat32) \
......
...@@ -665,12 +665,15 @@ void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) { ...@@ -665,12 +665,15 @@ void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) { void InstructionSelector::VisitBitcastFloat32ToInt32(Node* node) {
UNIMPLEMENTED(); X87OperandGenerator g(this);
Emit(kX87PushFloat32, g.NoOutput(), g.Use(node->InputAt(0)));
Emit(kX87BitcastFI, g.DefineAsRegister(node), 0, NULL);
} }
void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) { void InstructionSelector::VisitBitcastInt32ToFloat32(Node* node) {
UNIMPLEMENTED(); X87OperandGenerator g(this);
Emit(kX87BitcastIF, g.DefineAsFixed(node, stX_0), g.Use(node->InputAt(0)));
} }
......
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