From 3b4be3decdb0da9ec03c1923ccb1b7715bed595c Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Sat, 24 Oct 2009 19:29:20 -0600 Subject: [PATCH] defer to helper thunk for frem and drem --- src/compile.cpp | 9 +++++++++ src/x86.cpp | 4 ++++ test/AllFloats.java | 6 ++++++ 3 files changed, 19 insertions(+) diff --git a/src/compile.cpp b/src/compile.cpp index a7ae226455..f2db4af7b3 100644 --- a/src/compile.cpp +++ b/src/compile.cpp @@ -873,6 +873,9 @@ class Context { case FloatDivide: return local::getThunk(t, divideDoubleThunk); + case FloatRemainder: + return local::getThunk(t, moduloDoubleThunk); + case JumpIfFloatEqual: case JumpIfFloatNotEqual: case JumpIfFloatLess: @@ -894,13 +897,19 @@ class Context { switch (op) { case FloatAdd: return local::getThunk(t, addFloatThunk); + case FloatSubtract: return local::getThunk(t, subtractFloatThunk); + case FloatMultiply: return local::getThunk(t, multiplyFloatThunk); + case FloatDivide: return local::getThunk(t, divideFloatThunk); + case FloatRemainder: + return local::getThunk(t, moduloFloatThunk); + case JumpIfFloatEqual: case JumpIfFloatNotEqual: case JumpIfFloatLess: diff --git a/src/x86.cpp b/src/x86.cpp index 15ad45af06..97e85dfb41 100644 --- a/src/x86.cpp +++ b/src/x86.cpp @@ -3109,6 +3109,10 @@ class MyArchitecture: public Assembler::Architecture { *thunk = true; } break; + + case FloatRemainder: + *thunk = true; + break; case Multiply: if (BytesPerWord == 4 and aSize == 8) { diff --git a/test/AllFloats.java b/test/AllFloats.java index 112a2e9c0d..ca68df4396 100644 --- a/test/AllFloats.java +++ b/test/AllFloats.java @@ -7,6 +7,9 @@ public class AllFloats { private static float divide(float a, float b) {return a / b;} private static double divide(double a, double b) {return a / b;} private static double divide(float a, double b) {return a / b;} + private static float remainder(float a, float b) {return a % b;} + private static double remainder(double a, double b) {return a % b;} + private static double remainder(float a, double b) {return a % b;} private static float add(float a, float b) {return a + b;} private static double add(double a, double b) {return a + b;} private static double add(float a, double b) {return a + b;} @@ -44,6 +47,9 @@ public class AllFloats { expect(divide(5f, 2f) == 5f/2f); expect(divide(5d, 2d) == 5d/2d); expect(divide(5f, 2d) == 5f/2d); + expect(remainder(5f, 2f) == 5f%2f); + expect(remainder(5d, 2d) == 5d%2d); + expect(remainder(5f, 2d) == 5f%2d); expect(add(5f, 4f) == 5f+4f); expect(add(5d, 4d) == 5f+4d); expect(add(5f, 4d) == 5f+4d);