< prev index next >
src/jdk.internal.vm.compiler/share/classes/org.graalvm.compiler.core.aarch64.test/src/org/graalvm/compiler/core/aarch64/test/AArch64AddSubShiftTest.java
Print this page
rev 52889 : 8214023: Update Graal
@@ -24,15 +24,19 @@
package org.graalvm.compiler.core.aarch64.test;
+import org.graalvm.compiler.lir.LIRInstruction;
import org.graalvm.compiler.lir.aarch64.AArch64ArithmeticOp;
-import org.junit.Assert;
import org.junit.Test;
+import java.util.function.Predicate;
+
public class AArch64AddSubShiftTest extends AArch64MatchRuleTest {
+ private static final Predicate<LIRInstruction> predicate = op -> (op instanceof AArch64ArithmeticOp.BinaryShiftOp);
+
/**
* addSubShift match rule test for add operation with int type.
*/
private static int addLeftShiftInt(int input) {
int output = (input << 5) + input;
@@ -53,27 +57,22 @@
output += output >>> -5;
output += output >>> 32;
return output;
}
- private static int addShiftInt(int input) {
+ public static int addShiftInt(int input) {
return addLeftShiftInt(input) + addRightShiftInt(input) + addUnsignedRightShiftInt(input);
}
/**
* Check whether the addSubShift match rule in AArch64NodeMatchRules does work for add operation
* with int type and check if the expected LIR instructions show up.
*/
@Test
public void testAddShiftInt() {
- int expected = addShiftInt(123);
-
- Result result = executeActual(getResolvedJavaMethod("addShiftInt"), null, 123);
- int actual = (int) result.returnValue;
- Assert.assertEquals(expected, actual);
-
- checkLIR(AArch64ArithmeticOp.AddSubShiftOp.class, 6);
+ test("addShiftInt", 123);
+ checkLIR("addShiftInt", predicate, 6);
}
/**
* addSubShift match rule test for add operation with long type.
*/
@@ -96,27 +95,22 @@
output += output >>> -5;
output += output >>> 64;
return output;
}
- private static long addShiftLong(long input) {
+ public static long addShiftLong(long input) {
return addLeftShiftLong(input) + addRightShiftLong(input) + addUnsignedRightShiftLong(input);
}
/**
* Check whether the addSubShift match rule in AArch64NodeMatchRules does work for add operation
* with long type and check if the expected LIR instructions show up.
*/
@Test
public void testAddShiftLong() {
- long expected = addShiftLong(1234567);
-
- Result result = executeActual(getResolvedJavaMethod("addShiftLong"), null, (long) 1234567);
- long actual = (long) result.returnValue;
- Assert.assertEquals(expected, actual);
-
- checkLIR(AArch64ArithmeticOp.AddSubShiftOp.class, 6);
+ test("addShiftLong", 1234567L);
+ checkLIR("addShiftLong", predicate, 6);
}
/**
* addSubShift match rule test for sub operation with int type.
*/
@@ -130,27 +124,22 @@
private static int subUnsignedRightShiftInt(int input0, int input1) {
return input0 - (input1 >>> 5);
}
- private static int subShiftInt(int input0, int input1) {
+ public static int subShiftInt(int input0, int input1) {
return subLeftShiftInt(input0, input1) + subRightShiftInt(input0, input1) + subUnsignedRightShiftInt(input0, input1);
}
/**
* Check whether the addSubShift match rule in AArch64NodeMatchRules does work for sub operation
* with int type and check if the expected LIR instructions show up.
*/
@Test
public void testSubShiftInt() {
- int expected = subShiftInt(123, 456);
-
- Result result = executeActual(getResolvedJavaMethod("subShiftInt"), null, 123, 456);
- int actual = (int) result.returnValue;
- Assert.assertEquals(expected, actual);
-
- checkLIR(AArch64ArithmeticOp.AddSubShiftOp.class, 3);
+ test("subShiftInt", 123, 456);
+ checkLIR("subShiftInt", predicate, 3);
}
/**
* addSubShift match rule test for sub operation with long type.
*/
@@ -164,24 +153,19 @@
private static long subUnsignedRightShiftLong(long input0, long input1) {
return input0 - (input1 >>> 5);
}
- private static long subShiftLong(long input0, long input1) {
+ public static long subShiftLong(long input0, long input1) {
return subLeftShiftLong(input0, input1) + subRightShiftLong(input0, input1) + subUnsignedRightShiftLong(input0, input1);
}
/**
* Check whether the addSubShift match rule in AArch64NodeMatchRules does work for sub operation
* with long type and check if the expected LIR instructions show up.
*/
@Test
public void testSubShiftLong() {
- long expected = subShiftLong(1234567, 123);
-
- Result result = executeActual(getResolvedJavaMethod("subShiftLong"), null, (long) 1234567, (long) 123);
- long actual = (long) result.returnValue;
- Assert.assertEquals(expected, actual);
-
- checkLIR(AArch64ArithmeticOp.AddSubShiftOp.class, 3);
+ test("subShiftLong", 1234567L, 123L);
+ checkLIR("subShiftLong", predicate, 3);
}
}
< prev index next >