Mercurial > hg > truffle
annotate graal/com.oracle.graal.compiler.amd64.test/src/com/oracle/graal/compiler/amd64/test/StackStoreTest.java @ 21449:006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
author | Josef Eisl <josef.eisl@jku.at> |
---|---|
date | Thu, 21 May 2015 13:28:41 +0200 |
parents | graal/com.oracle.graal.lir.jtt/src/com/oracle/graal/lir/jtt/StackStoreTest.java@a6c7b3a7e63a |
children | 48c1ebd24120 |
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 |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
25 import static org.junit.Assume.*; |
21433 | 26 |
27 import org.junit.*; | |
28 | |
21449
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
29 import com.oracle.graal.amd64.*; |
21433 | 30 import com.oracle.graal.api.code.*; |
31 import com.oracle.graal.api.meta.*; | |
32 import com.oracle.graal.lir.framemap.*; | |
33 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
|
34 import com.oracle.graal.lir.jtt.*; |
21433 | 35 |
36 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
|
37 @Before |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
38 public void checkAMD64() { |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
39 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
|
40 } |
006d8ddb7ef9
Move ConstantStackMoveTest and StackStoreTest to amd64 specific project.
Josef Eisl <josef.eisl@jku.at>
parents:
21433
diff
changeset
|
41 |
21433 | 42 private static final LIRTestSpecification stackCopy0 = new LIRTestSpecification() { |
43 @Override | |
44 public void generate(LIRGeneratorTool gen, Value a) { | |
45 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
46 // create slots | |
47 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
48 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
49 // move stuff around | |
50 gen.emitMove(s1, a); | |
51 gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); | |
52 setResult(gen.emitMove(s1)); | |
53 gen.emitBlackhole(s1); | |
54 gen.emitBlackhole(s2); | |
55 } | |
56 }; | |
57 | |
58 private static final LIRTestSpecification stackCopy1 = new LIRTestSpecification() { | |
59 @Override | |
60 public void generate(LIRGeneratorTool gen, Value a) { | |
61 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
62 // create slots | |
63 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
64 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
65 // move stuff around | |
66 gen.emitMove(s1, a); | |
67 Value v = gen.emitMove(JavaConstant.forShort(Short.MIN_VALUE)); | |
68 gen.emitMove(s2, v); | |
69 setResult(gen.emitMove(s1)); | |
70 gen.emitBlackhole(s1); | |
71 gen.emitBlackhole(s2); | |
72 } | |
73 }; | |
74 | |
75 private static final LIRTestSpecification stackCopy2 = new LIRTestSpecification() { | |
76 @Override | |
77 public void generate(LIRGeneratorTool gen, Value a) { | |
78 FrameMapBuilder frameMapBuilder = gen.getResult().getFrameMapBuilder(); | |
79 // create slots | |
80 StackSlotValue s1 = frameMapBuilder.allocateSpillSlot(a.getLIRKind()); | |
81 StackSlotValue s2 = frameMapBuilder.allocateSpillSlot(LIRKind.value(Kind.Short)); | |
82 // move stuff around | |
83 gen.emitMove(s2, JavaConstant.forShort(Short.MIN_VALUE)); | |
84 gen.emitMove(s1, a); | |
85 setResult(gen.emitMove(s2)); | |
86 gen.emitBlackhole(s1); | |
87 gen.emitBlackhole(s2); | |
88 } | |
89 }; | |
90 | |
91 @SuppressWarnings("unused") | |
92 @LIRIntrinsic | |
93 public static int testShortStackSlot(LIRTestSpecification spec, int a) { | |
94 return a; | |
95 } | |
96 | |
97 @SuppressWarnings("unused") | |
98 @LIRIntrinsic | |
99 public static short testShortStackSlot2(LIRTestSpecification spec, int a) { | |
100 return Short.MIN_VALUE; | |
101 } | |
102 | |
103 public int test0(int a) { | |
104 return testShortStackSlot(stackCopy0, a); | |
105 } | |
106 | |
107 @Test | |
108 public void run0() throws Throwable { | |
109 runTest("test0", 0xDEADDEAD); | |
110 } | |
111 | |
112 public int test1(int a) { | |
113 return testShortStackSlot(stackCopy1, a); | |
114 } | |
115 | |
116 @Test | |
117 public void run1() throws Throwable { | |
118 runTest("test1", 0xDEADDEAD); | |
119 } | |
120 | |
121 public int test2(int a) { | |
122 return testShortStackSlot2(stackCopy2, a); | |
123 } | |
124 | |
125 @Test | |
126 public void run2() throws Throwable { | |
127 runTest("test2", 0xDEADDEAD); | |
128 } | |
129 | |
130 } |