Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/StackStoreTest.java @ 21673:5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
author | Doug Simon <doug.simon@oracle.com> |
---|---|
date | Tue, 02 Jun 2015 22:11:52 +0200 |
parents | 48c1ebd24120 |
children |
rev | line source |
---|---|
21433 | 1 /* |
2 * Copyright (c) 2015, 2015, Oracle and/or its affiliates. All rights reserved. | |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
4 * | |
5 * This code is free software; you can redistribute it and/or modify it | |
6 * under the terms of the GNU General Public License version 2 only, as | |
7 * published by the Free Software Foundation. | |
8 * | |
9 * This code is distributed in the hope that it will be useful, but WITHOUT | |
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
12 * version 2 for more details (a copy is included in the LICENSE file that | |
13 * accompanied this code). | |
14 * | |
15 * You should have received a copy of the GNU General Public License version | |
16 * 2 along with this work; if not, write to the Free Software Foundation, | |
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | |
18 * | |
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | |
20 * or visit www.oracle.com if you need additional information or have any | |
21 * questions. | |
22 */ | |
21449
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
23 package com.oracle.graal.compiler.amd64.test; |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
24 |
21673
5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
25 import com.oracle.jvmci.amd64.*; |
21556
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21449
diff
changeset
|
26 import com.oracle.jvmci.code.StackSlotValue; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21449
diff
changeset
|
27 import com.oracle.jvmci.meta.JavaConstant; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21449
diff
changeset
|
28 import com.oracle.jvmci.meta.LIRKind; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21449
diff
changeset
|
29 import com.oracle.jvmci.meta.Kind; |
48c1ebd24120
renamed com.oracle.graal.api[meta|code] modules to com.oracle.jvmci.[meta|code] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21449
diff
changeset
|
30 import com.oracle.jvmci.meta.Value; |
21673
5024c80224c7
moved com.oracle.graal.[amd64|sparc] to com.oracle.jvmci.[amd64|sparc] (JBS:GRAAL-53)
Doug Simon <doug.simon@oracle.com>
parents:
21556
diff
changeset
|
31 |
21449
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
32 import static org.junit.Assume.*; |
21433 | 33 |
34 import org.junit.*; | |
35 | |
36 import com.oracle.graal.lir.framemap.*; | |
37 import com.oracle.graal.lir.gen.*; | |
21449
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
38 import com.oracle.graal.lir.jtt.*; |
21433 | 39 |
40 public class StackStoreTest extends LIRTest { | |
21449
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
41 @Before |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
42 public void checkAMD64() { |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
43 assumeTrue("skipping AMD64 specific test", getTarget().arch instanceof AMD64); |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
44 } |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
45 |
21433 | 46 private static final LIRTestSpecification stackCopy0 = new LIRTestSpecification() { |
47 @Override | |
48 public void generate(LIRGeneratorTool gen, Value a) { | |
49 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
50 // create slots | |
51 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
52 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
53 // move stuff around | |
54 gen.emitMove(s1, a); | |
55 gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); | |
56 setResult(gen.emitMove(s1)); | |
57 gen.emitBlackhole(s1); | |
58 gen.emitBlackhole(s2); | |
59 } | |
60 }; | |
61 | |
62 private static final LIRTestSpecification stackCopy1 = new LIRTestSpecification() { | |
63 @Override | |
64 public void generate(LIRGeneratorTool gen, Value a) { | |
65 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
66 // create slots | |
67 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
68 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
69 // move stuff around | |
70 gen.emitMove(s1, a); | |
71 Value v = gen.emitMove(JavaConstant.forShort(Short.MIN_VALUE)); | |
72 gen.emitMove(s2, v); | |
73 setResult(gen.emitMove(s1)); | |
74 gen.emitBlackhole(s1); | |
75 gen.emitBlackhole(s2); | |
76 } | |
77 }; | |
78 | |
79 private static final LIRTestSpecification stackCopy2 = new LIRTestSpecification() { | |
80 @Override | |
81 public void generate(LIRGeneratorTool gen, Value a) { | |
82 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
83 // create slots | |
84 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
85 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
86 // move stuff around | |
87 gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); | |
88 gen.emitMove(s1, a); | |
89 setResult(gen.emitMove(s2)); | |
90 gen.emitBlackhole(s1); | |
91 gen.emitBlackhole(s2); | |
92 } | |
93 }; | |
94 | |
95 @SuppressWarnings("unused") | |
96 @LIRIntrinsic | |
97 public static int testShortStackSlot(LIRTestSpecification spec, int a) { | |
98 return a; | |
99 } | |
100 | |
101 @SuppressWarnings("unused") | |
102 @LIRIntrinsic | |
103 public static short testShortStackSlot2(LIRTestSpecification spec, int a) { | |
104 return Short.MIN_VALUE; | |
105 } | |
106 | |
107 public int test0(int a) { | |
108 return testShortStackSlot(stackCopy0, a); | |
109 } | |
110 | |
111 @Test | |
112 public void run0() throws Throwable { | |
113 runTest("test0", 0xDEADDEAD); | |
114 } | |
115 | |
116 public int test1(int a) { | |
117 return testShortStackSlot(stackCopy1, a); | |
118 } | |
119 | |
120 @Test | |
121 public void run1() throws Throwable { | |
122 runTest("test1", 0xDEADDEAD); | |
123 } | |
124 | |
125 public int test2(int a) { | |
126 return testShortStackSlot2(stackCopy2, a); | |
127 } | |
128 | |
129 @Test | |
130 public void run2() throws Throwable { | |
131 runTest("test2", 0xDEADDEAD); | |
132 } | |
133 | |
134 } |