comparison graal/com.oracle.max.asmdis/src/com/sun/max/asm/gen/risc/sparc/FloatingPointOperate.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
27 import com.sun.max.asm.gen.risc.*;
28
29 /**
30 */
31 public class FloatingPointOperate extends SPARCInstructionDescriptionCreator {
32
33 private void createCompare(String name, String type, Object frs1Field, Object frs2Field, int opfContents) {
34 define("f" + name + type, op(0x2), bits_29_27(0), fcc_26_25, op3(0x35), frs1Field, frs2Field, opf(opfContents));
35 }
36
37 private void createBinaryArithmetic(String name, String type, Object[] head, Object frs1Field, Object frs2Field,
38 final Object frdField, int opfContents) {
39 define("f" + name + type, head, opf(opfContents), frs1Field, frs2Field, frdField);
40 }
41
42 private void createToX(String type, Object[] head, Object frs2Field, int opfContents) {
43 define("f" + type + "tox", head, opf(opfContents), frs2Field, dfrd);
44 }
45
46 private void createToI(String type, Object[] head, Object frs2Field, int opfContents) {
47 define("f" + type + "toi", head, opf(opfContents), frs2Field, sfrd);
48 }
49
50 private void createFromTo(String fromType, String toType, Object[] head, Object frs2Field, Object frdField, int opfContents) {
51 define("f" + fromType + "to" + toType, head, opf(opfContents), frs2Field, frdField);
52 }
53
54 private void createXorITo(String type, Object[] head, Object frdField, int opfContents) {
55 define("fxto" + type, head, opf(opfContents | 0x80), dfrs2, frdField);
56 define("fito" + type, head, opf(opfContents | 0xc0), sfrs2, frdField);
57 }
58
59 private void createUnaryArithmetic(String name, String type, Object[] head, Object frs2Field, Object frdField, int opfContents) {
60 define("f" + name + type, head, opf(opfContents), frs2Field, frdField);
61 }
62
63 private void create_A12(Object[] head) {
64 createBinaryArithmetic("add", "s", head, sfrs1, sfrs2, sfrd, 0x41);
65 createBinaryArithmetic("add", "d", head, dfrs1, dfrs2, dfrd, 0x42);
66 createBinaryArithmetic("add", "q", head, qfrs1, qfrs2, qfrd, 0x43);
67 createBinaryArithmetic("sub", "s", head, sfrs1, sfrs2, sfrd, 0x45);
68 createBinaryArithmetic("sub", "d", head, dfrs1, dfrs2, dfrd, 0x46);
69 createBinaryArithmetic("sub", "q", head, qfrs1, qfrs2, qfrd, 0x47);
70 }
71
72 private void create_A13() {
73 createCompare("cmp", "s", sfrs1, sfrs2, 0x51);
74 createCompare("cmp", "d", dfrs1, dfrs2, 0x52);
75 createCompare("cmp", "q", qfrs1, qfrs2, 0x53);
76 createCompare("cmpe", "s", sfrs1, sfrs2, 0x55);
77 createCompare("cmpe", "d", dfrs1, dfrs2, 0x56);
78 createCompare("cmpe", "q", qfrs1, qfrs2, 0x57);
79 }
80
81 private void create_A14(Object[] head) {
82 createToX("s", head, sfrs2, 0x81);
83 createToX("d", head, dfrs2, 0x82);
84 createToX("q", head, qfrs2, 0x83);
85 createToI("s", head, sfrs2, 0xd1);
86 createToI("d", head, dfrs2, 0xd2);
87 createToI("q", head, qfrs2, 0xd3);
88 }
89
90 private void create_A15(Object[] head) {
91 createFromTo("s", "d", head, sfrs2, dfrd, 0xc9);
92 createFromTo("s", "q", head, sfrs2, qfrd, 0xcd);
93 createFromTo("d", "s", head, dfrs2, sfrd, 0xc6);
94 createFromTo("d", "q", head, dfrs2, qfrd, 0xce);
95 createFromTo("q", "s", head, qfrs2, sfrd, 0xc7);
96 createFromTo("q", "d", head, qfrs2, dfrd, 0xcb);
97 }
98
99 private void create_A16(Object[] head) {
100 createXorITo("s", head, sfrd, 0x4);
101 createXorITo("d", head, dfrd, 0x8);
102 createXorITo("q", head, qfrd, 0xc);
103 }
104
105 private void create_A17(Object[] head) {
106 createUnaryArithmetic("mov", "s", head, sfrs2, sfrd, 0x1);
107 createUnaryArithmetic("mov", "d", head, dfrs2, dfrd, 0x2);
108 createUnaryArithmetic("mov", "q", head, qfrs2, qfrd, 0x3);
109 createUnaryArithmetic("neg", "s", head, sfrs2, sfrd, 0x5);
110 createUnaryArithmetic("neg", "d", head, dfrs2, dfrd, 0x6);
111 createUnaryArithmetic("neg", "q", head, qfrs2, qfrd, 0x7);
112 createUnaryArithmetic("abs", "s", head, sfrs2, sfrd, 0x9);
113 createUnaryArithmetic("abs", "d", head, dfrs2, dfrd, 0xa);
114 createUnaryArithmetic("abs", "q", head, qfrs2, qfrd, 0xb);
115 }
116
117 private void create_A18(Object[] head) {
118 createBinaryArithmetic("mul", "s", head, sfrs1, sfrs2, sfrd, 0x49);
119 createBinaryArithmetic("mul", "d", head, dfrs1, dfrs2, dfrd, 0x4a);
120 createBinaryArithmetic("mul", "q", head, qfrs1, qfrs2, qfrd, 0x4b);
121 createBinaryArithmetic("div", "s", head, sfrs1, sfrs2, sfrd, 0x4d);
122 createBinaryArithmetic("div", "d", head, dfrs1, dfrs2, dfrd, 0x4e);
123 createBinaryArithmetic("div", "q", head, qfrs1, qfrs2, qfrd, 0x4f);
124
125 define("fsmuld", head, opf(0x69), sfrs1, sfrs2, dfrd);
126 define("fdmulq", head, opf(0x6e), dfrs1, dfrs2, qfrd);
127 }
128
129 private void create_A19(Object[] head) {
130 createUnaryArithmetic("sqrt", "s", head, sfrs2, sfrd, 0x29);
131 createUnaryArithmetic("sqrt", "d", head, dfrs2, dfrd, 0x2a);
132 createUnaryArithmetic("sqrt", "q", head, qfrs2, qfrd, 0x2b);
133 }
134
135 FloatingPointOperate(RiscTemplateCreator templateCreator) {
136 super(templateCreator);
137
138 final Object[] head1 = {op(0x2), op3(0x34)};
139 final Object[] head2 = {res_18_14, head1};
140
141 setCurrentArchitectureManualSection("A.12");
142 create_A12(head1);
143
144 setCurrentArchitectureManualSection("A.13");
145 create_A13();
146
147 setCurrentArchitectureManualSection("A.14");
148 create_A14(head2);
149
150 setCurrentArchitectureManualSection("A.15");
151 create_A15(head2);
152
153 setCurrentArchitectureManualSection("A.16");
154 create_A16(head2);
155
156 setCurrentArchitectureManualSection("A.17");
157 create_A17(head2);
158
159 setCurrentArchitectureManualSection("A.18");
160 create_A18(head1);
161
162 setCurrentArchitectureManualSection("A.19");
163 create_A19(head2);
164 }
165
166 }