comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/gen/risc/sparc/ControlTransfer.java @ 3733:e233f5660da4

Added Java files from Maxine project.
author Thomas Wuerthinger <thomas.wuerthinger@oracle.com>
date Sat, 17 Dec 2011 19:59:18 +0100
parents
children
comparison
equal deleted inserted replaced
3732:3e2e8b8abdaf 3733:e233f5660da4
1 /*
2 * Copyright (c) 2007, 2011, 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 */
23 package com.sun.max.asm.gen.risc.sparc;
24
25 import static com.sun.max.asm.gen.risc.sparc.SPARCFields.*;
26 import static com.sun.max.asm.sparc.AnnulBit.*;
27 import static com.sun.max.asm.sparc.BranchPredictionBit.*;
28
29 import com.sun.max.asm.gen.risc.*;
30 import com.sun.max.asm.sparc.*;
31
32 /**
33 */
34 class ControlTransfer extends SPARCInstructionDescriptionCreator {
35
36 private void createBPr(String prefix, Object... objects) {
37 for (BPr condition : BPr.SYMBOLIZER) {
38 define(prefix + condition.name().toLowerCase(), objects, rcond_27_25(condition));
39 }
40 }
41
42 private void create_A3() {
43 createBPr("br", op(0x0), a, p, bits_28_28(0), bits_24_22(0x3), rs1, d16);
44 createBPr("br", op(0x0), a(NO_A), p(PT), bits_28_28(0), bits_24_22(0x3), rs1, d16);
45 define("br", op(0x0), rcond_27_25, a, p, bits_28_28(0), bits_24_22(0x3), rs1, d16);
46 }
47
48 private void createFBfcc(String prefix, Object... objects) {
49 for (FBfcc condition : FBfcc.SYMBOLIZER) {
50 define(prefix + condition.name().toLowerCase(), objects, fcond_28_25(condition));
51 }
52 }
53
54 private void create_A4() {
55 if (assembly().generatingDeprecatedInstructions()) {
56 createFBfcc("fb", op(0x0), a, bits_24_22(0x6), disp22);
57 createFBfcc("fb", op(0x0), a(NO_A), bits_24_22(0x6), disp22);
58 define("fb", op(0x0), fcond_28_25, a, bits_24_22(0x6), disp22);
59 }
60 }
61
62 private void create_A5() {
63 if (assembly().generatingV9Instructions()) {
64 createFBfcc("fb", op(0x0), a, p, bits_24_22(0x5), fcc_21_20, disp19);
65 createFBfcc("fb", op(0x0), a(NO_A), p(PT), bits_24_22(0x5), fcc_21_20, disp19);
66 define("fb", op(0x0), fcond_28_25, a, p, bits_24_22(0x5), fcc_21_20, disp19);
67 }
68 }
69
70 private void createBicc(String prefix, Object... objects) {
71 for (Bicc condition : Bicc.SYMBOLIZER) {
72 define(prefix + condition.name().toLowerCase(), objects, icond_28_25(condition));
73 }
74 }
75
76 private void create_A6() {
77 if (assembly().generatingDeprecatedInstructions()) {
78 createBicc("b", op(0x0), a, bits_24_22(0x2), disp22);
79 createBicc("b", op(0x0), a(NO_A), bits_24_22(0x2), disp22);
80 define("b", op(0x0), icond_28_25, a, bits_24_22(0x2), disp22);
81 }
82 }
83
84 private void create_A7() {
85 if (assembly().generatingV9Instructions()) {
86 createBicc("b", op(0x0), a, p, bits_24_22(0x1), cc, disp19);
87 createBicc("b", op(0x0), a(NO_A), p(PT), bits_24_22(0x1), cc, disp19);
88 define("b", op(0x0), icond_28_25, a, p, bits_24_22(0x1), cc, disp19);
89 }
90 }
91
92 private void create_A8() {
93 define("call", op(0x1), disp30);
94 }
95
96 private void create_A11() {
97 define("done", op(0x2), op3(0x3e), res_18_0, fcnc(0));
98 define("retry", op(0x2), op3(0x3e), res_18_0, fcnc(1));
99 }
100
101 private void create_A22() {
102 define("illtrap", op(0x0), res_29_25, op2(0x0), const22);
103 }
104
105 private void create_A24() {
106 define("jmpl", op(0x2), op3(0x38), rs1, " + ", i(0), res_12_5, rs2, rd);
107 define("jmpl", op(0x2), op3(0x38), rs1, " + ", i(1), simm13, rd);
108 }
109
110 private void create_A45() {
111 final Object[] head = {op(0x2), res_29_25, op3(0x39), rs1, " + "};
112
113 // should be called "return", but that's a Java keyword
114 define("return_", head, i(0), res_12_5, rs2).setExternalName("return");
115 define("return_", head, i(1), simm13).setExternalName("return");
116 }
117
118 private void create_A50() {
119 define("sir", op(0x2), rd(15), op3(0x30), bits_18_14(0), i(1), simm13);
120 }
121
122 private void create_A61() {
123 final Object[] head = {op(0x2), res_29_29, op3(0x3a), tcc, rs1, " + "};
124 createBicc("t", head, i(0), res_10_5, rs2);
125 createBicc("t", head, i(1), res_10_7, swTrapNumber);
126 }
127
128 ControlTransfer(RiscTemplateCreator templateCreator) {
129 super(templateCreator);
130
131 setCurrentArchitectureManualSection("A.3");
132 create_A3();
133
134 setCurrentArchitectureManualSection("A.4");
135 create_A4();
136
137 setCurrentArchitectureManualSection("A.5");
138 create_A5();
139
140 setCurrentArchitectureManualSection("A.6");
141 create_A6();
142
143 setCurrentArchitectureManualSection("A.7");
144 create_A7();
145
146 setCurrentArchitectureManualSection("A.8");
147 create_A8();
148
149 setCurrentArchitectureManualSection("A.11");
150 create_A11();
151
152 setCurrentArchitectureManualSection("A.22");
153 create_A22();
154
155 setCurrentArchitectureManualSection("A.24");
156 create_A24();
157
158 setCurrentArchitectureManualSection("A.45");
159 create_A45();
160
161 setCurrentArchitectureManualSection("A.50");
162 create_A50();
163
164 setCurrentArchitectureManualSection("A.61");
165 create_A61();
166
167 setCurrentArchitectureManualSection(null);
168 }
169 }