58877
|
1 |
/*
|
|
2 |
* Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
|
|
3 |
* Copyright (c) 2019, Arm Limited. All rights reserved.
|
|
4 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
5 |
*
|
|
6 |
* This code is free software; you can redistribute it and/or modify it
|
|
7 |
* under the terms of the GNU General Public License version 2 only, as
|
|
8 |
* published by the Free Software Foundation.
|
|
9 |
*
|
|
10 |
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
11 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
12 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
13 |
* version 2 for more details (a copy is included in the LICENSE file that
|
|
14 |
* accompanied this code).
|
|
15 |
*
|
|
16 |
* You should have received a copy of the GNU General Public License version
|
|
17 |
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
18 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
19 |
*
|
|
20 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
21 |
* or visit www.oracle.com if you need additional information or have any
|
|
22 |
* questions.
|
|
23 |
*/
|
|
24 |
|
|
25 |
|
|
26 |
package org.graalvm.compiler.core.aarch64.test;
|
|
27 |
|
|
28 |
import org.junit.Test;
|
|
29 |
|
|
30 |
public class AArch64MultiplyLongTest extends AArch64MatchRuleTest {
|
|
31 |
|
|
32 |
public long signedMulLong(int a, int b) {
|
|
33 |
return a * (long) b;
|
|
34 |
}
|
|
35 |
|
|
36 |
public long signedMulLongFromShort(short a, short b) {
|
|
37 |
return (long) a * b;
|
|
38 |
}
|
|
39 |
|
|
40 |
public long signedMulLongFromChar(char a, char b) {
|
|
41 |
return a * (long) b;
|
|
42 |
}
|
|
43 |
|
|
44 |
public long signedMulLongFromByte(byte a, byte b) {
|
|
45 |
return (long) a * b;
|
|
46 |
}
|
|
47 |
|
|
48 |
@Test
|
|
49 |
public void testSignedMulLong() {
|
|
50 |
test("signedMulLong", 0x12345678, 0x87654321);
|
|
51 |
checkLIR("signedMulLong", op -> op.name().equals("SMULL"), 1);
|
|
52 |
test("signedMulLongFromShort", (short) 32767, (short) -32768);
|
|
53 |
checkLIR("signedMulLongFromShort", op -> op.name().equals("SMULL"), 1);
|
|
54 |
test("signedMulLongFromChar", (char) 59999, (char) 65535);
|
|
55 |
checkLIR("signedMulLongFromChar", op -> op.name().equals("SMULL"), 1);
|
|
56 |
test("signedMulLongFromByte", (byte) 10, (byte) -256);
|
|
57 |
checkLIR("signedMulLongFromByte", op -> op.name().equals("SMULL"), 1);
|
|
58 |
}
|
|
59 |
|
|
60 |
public long signedMNegLong1(int a, int b) {
|
|
61 |
return -(a * (long) b);
|
|
62 |
}
|
|
63 |
|
|
64 |
public long signedMNegLong2(int a, int b) {
|
|
65 |
return a * (-(long) b);
|
|
66 |
}
|
|
67 |
|
|
68 |
@Test
|
|
69 |
public void testSignedMNegLong() {
|
|
70 |
test("signedMNegLong1", 0x89abcdef, 0xfedcba98);
|
|
71 |
checkLIR("signedMNegLong1", op -> op.name().equals("SMNEGL"), 1);
|
|
72 |
test("signedMNegLong2", 0x89abcdef, 0xfedcba98);
|
|
73 |
checkLIR("signedMNegLong2", op -> op.name().equals("SMNEGL"), 1);
|
|
74 |
}
|
|
75 |
|
|
76 |
public long signedMAddLong1(int a, int b, long c) {
|
|
77 |
return c + a * (long) b;
|
|
78 |
}
|
|
79 |
|
|
80 |
public long signedMAddLong2(int a, int b, long c) {
|
|
81 |
return a * (long) b + c;
|
|
82 |
}
|
|
83 |
|
|
84 |
@Test
|
|
85 |
public void testSignedMAddLong() {
|
|
86 |
test("signedMAddLong1", 0x22228888, 0xaaaacccc, 0x123456789abcdL);
|
|
87 |
checkLIR("signedMAddLong1", op -> op.name().equals("SMADDL"), 1);
|
|
88 |
test("signedMAddLong2", 0x22228888, 0xaaaacccc, 0x123456789abcdL);
|
|
89 |
checkLIR("signedMAddLong2", op -> op.name().equals("SMADDL"), 1);
|
|
90 |
}
|
|
91 |
|
|
92 |
public long signedMSubLong(int a, int b, long c) {
|
|
93 |
return c - a * (long) b;
|
|
94 |
}
|
|
95 |
|
|
96 |
@Test
|
|
97 |
public void testSignedMSubLong() {
|
|
98 |
test("signedMSubLong", 0x99995555, 0xeeeebbbb, 0x3456789abcdefL);
|
|
99 |
checkLIR("signedMSubLong", op -> op.name().equals("SMSUBL"), 1);
|
|
100 |
}
|
|
101 |
}
|