summaryrefslogtreecommitdiffstats
path: root/test/422-type-conversion
diff options
context:
space:
mode:
authorRoland Levillain <rpl@google.com>2014-11-05 14:15:05 +0000
committerRoland Levillain <rpl@google.com>2014-11-05 16:51:59 +0000
commitdff1f2812ecdaea89978c5351f0c70cdabbc0821 (patch)
tree5305173d341263ad32deb98c0299ee8bad03baa9 /test/422-type-conversion
parent5e5632ff1651adbf95faaf8fb3239a36f9f61124 (diff)
downloadart-dff1f2812ecdaea89978c5351f0c70cdabbc0821.tar.gz
art-dff1f2812ecdaea89978c5351f0c70cdabbc0821.tar.bz2
art-dff1f2812ecdaea89978c5351f0c70cdabbc0821.zip
Support int-to-long conversions in the optimizing compiler.
- Add support for the int-to-float Dex instruction in the optimizing compiler. - Add a HTypeConversion node type for control-flow graphs. - Generate x86, x86-64 and ARM (but not ARM64) code for int-to-float HTypeConversion nodes. - Add a 64-bit "Move doubleword to quadword with sign-extension" (MOVSXD) instruction to the x86-64 assembler. - Add related tests to test/422-type-conversion. Change-Id: Ieb8ec5380f9c411857119c79aa8d0728fd10f780
Diffstat (limited to 'test/422-type-conversion')
-rw-r--r--test/422-type-conversion/expected.txt0
-rw-r--r--test/422-type-conversion/info.txt1
-rw-r--r--test/422-type-conversion/src/Main.java45
3 files changed, 46 insertions, 0 deletions
diff --git a/test/422-type-conversion/expected.txt b/test/422-type-conversion/expected.txt
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/test/422-type-conversion/expected.txt
diff --git a/test/422-type-conversion/info.txt b/test/422-type-conversion/info.txt
new file mode 100644
index 0000000000..e734f3213e
--- /dev/null
+++ b/test/422-type-conversion/info.txt
@@ -0,0 +1 @@
+Tests for type conversions.
diff --git a/test/422-type-conversion/src/Main.java b/test/422-type-conversion/src/Main.java
new file mode 100644
index 0000000000..997491997b
--- /dev/null
+++ b/test/422-type-conversion/src/Main.java
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2014 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+// Note that $opt$ is a marker for the optimizing compiler to ensure
+// it does compile the method.
+public class Main {
+
+ public static void assertEquals(long expected, long result) {
+ if (expected != result) {
+ throw new Error("Expected: " + expected + ", found: " + result);
+ }
+ }
+
+ public static void main(String[] args) {
+ intToLong();
+ }
+
+ private static void intToLong() {
+ assertEquals(1L, $opt$IntToLong(1));
+ assertEquals(0L, $opt$IntToLong(0));
+ assertEquals(-1L, $opt$IntToLong(-1));
+ assertEquals(51L, $opt$IntToLong(51));
+ assertEquals(-51L, $opt$IntToLong(-51));
+ assertEquals(2147483647L, $opt$IntToLong(2147483647)); // (2^31) - 1
+ assertEquals(-2147483647L, $opt$IntToLong(-2147483647)); // -(2^31) - 1
+ assertEquals(-2147483648L, $opt$IntToLong(-2147483648)); // -(2^31)
+ }
+
+ static long $opt$IntToLong(int a){
+ return a;
+ }
+}