summaryrefslogtreecommitdiffstats
path: root/test/422-type-conversion
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2014-12-04 11:54:28 +0000
committerRoland Levillain <rpl@google.com>2014-12-04 11:54:28 +0000
commit624279f3c70f9904cbaf428078981b05d3b324c0 (patch)
treea81f8d8facfc28cac479a68a1042edc74c36d25b /test/422-type-conversion
parent9a64a46e8edfa89402598d8650b8ebb337ba3d52 (diff)
downloadart-624279f3c70f9904cbaf428078981b05d3b324c0.zip
art-624279f3c70f9904cbaf428078981b05d3b324c0.tar.gz
art-624279f3c70f9904cbaf428078981b05d3b324c0.tar.bz2
Add support for float-to-long in the optimizing compiler.
- Add support for the float-to-long Dex instruction in the optimizing compiler. - Add a Dex PC field to art::HTypeConversion to allow the x86 and ARM code generators to produce runtime calls. - Instruct art::CodeGenerator::RecordPcInfo not to record PC information for HTypeConversion instructions. - Add S0 to the list of ARM FPU parameter registers. - Have art::x86_64::X86_64Assembler::cvttss2si work with 64-bit operands. - Generate x86, x86-64 and ARM (but not ARM64) code for float to long HTypeConversion nodes. - Add related tests to test/422-type-conversion. Change-Id: I954214f0d537187883f83f7a83a1bb2dd8a21fd4
Diffstat (limited to 'test/422-type-conversion')
-rw-r--r--test/422-type-conversion/src/Main.java32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java
index e7dbe24..05cdf42 100644
--- a/test/422-type-conversion/src/Main.java
+++ b/test/422-type-conversion/src/Main.java
@@ -94,6 +94,9 @@ public class Main {
// Generate, compile and check float-to-int Dex instructions.
floatToInt();
+ // Generate, compile and check float-to-long Dex instructions.
+ floatToLong();
+
// Generate, compile and check int-to-byte Dex instructions.
shortToByte();
intToByte();
@@ -342,6 +345,32 @@ public class Main {
assertIntEquals(-2147483648, $opt$FloatToInt(Float.NEGATIVE_INFINITY));
}
+ private static void floatToLong() {
+ assertLongEquals(1L, $opt$FloatToLong(1F));
+ assertLongEquals(0L, $opt$FloatToLong(0F));
+ assertLongEquals(0L, $opt$FloatToLong(-0F));
+ assertLongEquals(-1L, $opt$FloatToLong(-1F));
+ assertLongEquals(51L, $opt$FloatToLong(51F));
+ assertLongEquals(-51L, $opt$FloatToLong(-51F));
+ assertLongEquals(0L, $opt$FloatToLong(0.5F));
+ assertLongEquals(0L, $opt$FloatToLong(0.4999999F));
+ assertLongEquals(0L, $opt$FloatToLong(-0.4999999F));
+ assertLongEquals(0L, $opt$FloatToLong(-0.5F));
+ assertLongEquals(42L, $opt$FloatToLong(42.199F));
+ assertLongEquals(-42L, $opt$FloatToLong(-42.199F));
+ assertLongEquals(2147483648L, $opt$FloatToLong(2147483647F)); // 2^31 - 1
+ assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483647F)); // -(2^31 - 1)
+ assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483648F)); // -(2^31)
+ assertLongEquals(2147483648L, $opt$FloatToLong(2147483648F)); // (2^31)
+ assertLongEquals(-2147483648L, $opt$FloatToLong(-2147483649F)); // -(2^31 + 1)
+ assertLongEquals(9223372036854775807L, $opt$FloatToLong(9223372036854775807F)); // 2^63 - 1
+ assertLongEquals(-9223372036854775808L, $opt$FloatToLong(-9223372036854775807F)); // -(2^63 - 1)
+ assertLongEquals(-9223372036854775808L, $opt$FloatToLong(-9223372036854775808F)); // -(2^63)
+ assertLongEquals(0L, $opt$FloatToLong(Float.NaN));
+ assertLongEquals(9223372036854775807L, $opt$FloatToLong(Float.POSITIVE_INFINITY));
+ assertLongEquals(-9223372036854775808L, $opt$FloatToLong(Float.NEGATIVE_INFINITY));
+ }
+
private static void shortToByte() {
assertByteEquals((byte)1, $opt$ShortToByte((short)1));
assertByteEquals((byte)0, $opt$ShortToByte((short)0));
@@ -500,6 +529,9 @@ public class Main {
// This method produces a float-to-int Dex instruction.
static int $opt$FloatToInt(float a){ return (int)a; }
+ // This method produces a float-to-long Dex instruction.
+ static long $opt$FloatToLong(float a){ return (long)a; }
+
// These methods produce int-to-byte Dex instructions.
static byte $opt$ShortToByte(short a){ return (byte)a; }
static byte $opt$IntToByte(int a){ return (byte)a; }