Index: src/compiler/mips64/code-generator-mips64.cc |
diff --git a/src/compiler/mips64/code-generator-mips64.cc b/src/compiler/mips64/code-generator-mips64.cc |
index 0607245e2f7cf818338374ed749011555648e522..e693b1ab78eb667f3ae9486b598e62ffc96a59df 100644 |
--- a/src/compiler/mips64/code-generator-mips64.cc |
+++ b/src/compiler/mips64/code-generator-mips64.cc |
@@ -192,6 +192,24 @@ class OutOfLineRound : public OutOfLineCode { |
}; |
+class OutOfLineRound32 : public OutOfLineCode { |
+ public: |
+ OutOfLineRound32(CodeGenerator* gen, DoubleRegister result) |
+ : OutOfLineCode(gen), result_(result) {} |
+ |
+ void Generate() final { |
+ // Handle rounding to zero case where sign has to be preserved. |
+ // High bits of float input already in kScratchReg. |
+ __ srl(at, kScratchReg, 31); |
+ __ sll(at, at, 31); |
+ __ mtc1(at, result_); |
+ } |
+ |
+ private: |
+ DoubleRegister const result_; |
+}; |
+ |
+ |
class OutOfLineTruncate final : public OutOfLineRound { |
public: |
OutOfLineTruncate(CodeGenerator* gen, DoubleRegister result) |
@@ -219,6 +237,33 @@ class OutOfLineTiesEven final : public OutOfLineRound { |
: OutOfLineRound(gen, result) {} |
}; |
+class OutOfLineTruncate32 final : public OutOfLineRound32 { |
titzer
2015/11/26 08:43:03
Looks like the out of line code is exactly the sam
dusan.milosavljevic
2015/11/26 12:52:37
Right, too much duplicated code.
dusan.milosavljevic
2015/11/26 12:52:37
Done.
|
+ public: |
+ OutOfLineTruncate32(CodeGenerator* gen, DoubleRegister result) |
+ : OutOfLineRound32(gen, result) {} |
+}; |
+ |
+ |
+class OutOfLineFloor32 final : public OutOfLineRound32 { |
+ public: |
+ OutOfLineFloor32(CodeGenerator* gen, DoubleRegister result) |
+ : OutOfLineRound32(gen, result) {} |
+}; |
+ |
+ |
+class OutOfLineCeil32 final : public OutOfLineRound32 { |
+ public: |
+ OutOfLineCeil32(CodeGenerator* gen, DoubleRegister result) |
+ : OutOfLineRound32(gen, result) {} |
+}; |
+ |
+ |
+class OutOfLineTiesEven32 final : public OutOfLineRound32 { |
+ public: |
+ OutOfLineTiesEven32(CodeGenerator* gen, DoubleRegister result) |
+ : OutOfLineRound32(gen, result) {} |
+}; |
+ |
class OutOfLineRecordWrite final : public OutOfLineCode { |
public: |
@@ -452,6 +497,26 @@ FPUCondition FlagsConditionToConditionCmpFPU(bool& predicate, |
__ bind(&done); \ |
} while (0) |
+#define ASSEMBLE_ROUND_FLOAT_TO_FLOAT(asm_instr, operation) \ |
+ do { \ |
+ int32_t kFloat32ExponentBias = 127; \ |
+ int32_t kFloat32MantissaBits = 23; \ |
+ int32_t kFloat32ExponentBits = 8; \ |
+ auto ool = \ |
+ new (zone()) OutOfLine##operation##32(this, i.OutputDoubleRegister()); \ |
+ Label done; \ |
+ __ mfc1(kScratchReg, i.InputDoubleRegister(0)); \ |
+ __ Ext(at, kScratchReg, kFloat32MantissaBits, kFloat32ExponentBits); \ |
+ __ Branch(USE_DELAY_SLOT, &done, hs, at, \ |
+ Operand(kFloat32ExponentBias + kFloat32MantissaBits)); \ |
+ __ mov_s(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
+ __ asm_instr(i.OutputDoubleRegister(), i.InputDoubleRegister(0)); \ |
+ __ mfc1(at, i.OutputDoubleRegister()); \ |
+ __ Branch(USE_DELAY_SLOT, ool->entry(), eq, at, Operand(zero_reg)); \ |
+ __ cvt_s_w(i.OutputDoubleRegister(), i.OutputDoubleRegister()); \ |
+ __ bind(ool->exit()); \ |
+ __ bind(&done); \ |
+ } while (0) |
void CodeGenerator::AssembleDeconstructActivationRecord(int stack_param_delta) { |
int sp_slot_delta = TailCallFrameStackSlotDelta(stack_param_delta); |
@@ -880,18 +945,34 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(floor_l_d, Floor); |
break; |
} |
+ case kMips64Float32RoundDown: { |
+ ASSEMBLE_ROUND_FLOAT_TO_FLOAT(floor_w_s, Floor); |
+ break; |
+ } |
case kMips64Float64RoundTruncate: { |
ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(trunc_l_d, Truncate); |
break; |
} |
+ case kMips64Float32RoundTruncate: { |
+ ASSEMBLE_ROUND_FLOAT_TO_FLOAT(trunc_w_s, Truncate); |
+ break; |
+ } |
case kMips64Float64RoundUp: { |
ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(ceil_l_d, Ceil); |
break; |
} |
+ case kMips64Float32RoundUp: { |
+ ASSEMBLE_ROUND_FLOAT_TO_FLOAT(ceil_w_s, Ceil); |
+ break; |
+ } |
case kMips64Float64RoundTiesEven: { |
ASSEMBLE_ROUND_DOUBLE_TO_DOUBLE(round_l_d, TiesEven); |
break; |
} |
+ case kMips64Float32RoundTiesEven: { |
+ ASSEMBLE_ROUND_FLOAT_TO_FLOAT(round_w_s, TiesEven); |
+ break; |
+ } |
case kMips64Float64Max: { |
// (b < a) ? a : b |
if (kArchVariant == kMips64r6) { |