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