comparison agent/src/share/classes/sun/jvm/hotspot/asm/sparc/SPARCLogicInstruction.java @ 0:a61af66fc99e jdk7-b24

Initial load
author duke
date Sat, 01 Dec 2007 00:00:00 +0000
parents
children c18cbe5936b8
comparison
equal deleted inserted replaced
-1:000000000000 0:a61af66fc99e
1 /*
2 * Copyright 2002 Sun Microsystems, Inc. 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 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
20 * CA 95054 USA or visit www.sun.com if you need additional information or
21 * have any questions.
22 *
23 */
24
25 package sun.jvm.hotspot.asm.sparc;
26
27 import sun.jvm.hotspot.asm.*;
28
29 public class SPARCLogicInstruction extends SPARCFormat3AInstruction
30 implements LogicInstruction {
31 final private int operation;
32
33 public SPARCLogicInstruction(String name, int opcode, int operation, SPARCRegister rs1,
34 ImmediateOrRegister operand2, SPARCRegister rd) {
35 super(name, opcode, rs1, operand2, rd);
36 this.operation = operation;
37 }
38
39 protected String getDescription() {
40 SPARCRegister G0 = SPARCRegisters.G0;
41 if (opcode == ORcc && rd == G0 && rd == operand2) {
42 StringBuffer buf = new StringBuffer();
43 buf.append("tst");
44 buf.append(spaces);
45 buf.append(getOperand2String());
46 return buf.toString();
47 } else if (opcode == XNOR && G0 == operand2) {
48 StringBuffer buf = new StringBuffer();
49 buf.append("not");
50 buf.append(spaces);
51 buf.append(rs1.toString());
52 if (rs1 != rd) {
53 buf.append(comma);
54 buf.append(rd.toString());
55 }
56 return buf.toString();
57 } else if (opcode == ANDcc && rd == G0) {
58 StringBuffer buf = new StringBuffer();
59 buf.append("btst");
60 buf.append(spaces);
61 buf.append(getOperand2String());
62 buf.append(comma);
63 buf.append(rd.toString());
64 return buf.toString();
65 } else if (rs1 == rd) {
66 StringBuffer buf = new StringBuffer();
67 switch (opcode) {
68 case OR:
69 buf.append("bset");
70 break;
71 case ANDN:
72 buf.append("bclr");
73 break;
74 case XOR:
75 buf.append("btog");
76 break;
77 default:
78 return super.getDescription();
79 }
80 buf.append(spaces);
81 buf.append(getOperand2String());
82 buf.append(comma);
83 buf.append(rd.toString());
84 return buf.toString();
85 } else {
86 return super.getDescription();
87 }
88 }
89
90 public Operand getLogicDestination() {
91 return getDestinationRegister();
92 }
93
94 public Operand[] getLogicSources() {
95 return (new Operand[] { rs1, operand2 });
96 }
97
98 public int getOperation() {
99 return operation;
100 }
101
102 public boolean isLogic() {
103 return true;
104 }
105 }