aboutsummaryrefslogtreecommitdiff
path: root/agent/src/share/classes/sun/jvm/hotspot/asm/sparc/SPARCV8Disassembler.java
blob: 05842770ab9815fc0e7676b66f55b152ac397adb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/*
 * Copyright 2002 Sun Microsystems, Inc.  All Rights Reserved.
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
 *
 * This code is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2 only, as
 * published by the Free Software Foundation.
 *
 * This code is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 * version 2 for more details (a copy is included in the LICENSE file that
 * accompanied this code).
 *
 * You should have received a copy of the GNU General Public License version
 * 2 along with this work; if not, write to the Free Software Foundation,
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
 * CA 95054 USA or visit www.sun.com if you need additional information or
 * have any questions.
 *
 */

package sun.jvm.hotspot.asm.sparc;

import sun.jvm.hotspot.asm.*;
import java.io.*;
import java.util.*;

// Please refer to "The SPARC Architecture Manual - Version 8"

public class SPARCV8Disassembler extends SPARCDisassembler {

    public SPARCV8Disassembler(long startPc, byte[] code, SPARCInstructionFactory factory) {
        super(startPc, code, factory);
    }

    public SPARCV8Disassembler(long startPc, byte[] code) {
        this(startPc, code, new SPARCInstructionFactoryImpl());
    }

    // decoders for format 2 instructions
    private static InstructionDecoder format2Decoders[] = {
        new UnimpDecoder(),
        illegalDecoder,
        new IntegerBranchDecoder(),
        illegalDecoder,
        new SethiDecoder(),
        illegalDecoder,
        new FloatBranchDecoder(),
        new CoprocessorBranchDecoder()
    };

    protected InstructionDecoder getFormat2Decoder(int op2) {
        return format2Decoders[op2];
    }

    // op3 decoder table for op=3 (FORMAT_3) instructions - (memory instructions)
    // Appendix F - Opcodes and Condition Codes - Page 229 - Table F-4

    private static final InstructionDecoder format3Decoders[][] = {
        {
          new LoadDecoder(LD, "ld", RTLDT_UNSIGNED_WORD), new AlternateSpaceLoadDecoder(LDA, "lda", RTLDT_UNSIGNED_WORD),
          new LoadDecoder(LDF,"ld", RTLDT_FL_SINGLE),     new SpecialLoadDecoder(LDC,"ld", SPARCSpecialRegisters.CREG)
        },
        {
          new LoadDecoder(LDUB, "ldub", RTLDT_UNSIGNED_BYTE),   new AlternateSpaceLoadDecoder(LDUBA, "lduba", RTLDT_UNSIGNED_BYTE),
          new SpecialLoadDecoder(LDFSR, "ld", SPARCSpecialRegisters.FSR), new SpecialLoadDecoder(LDCSR, "ld", SPARCSpecialRegisters.CSR)
        },
        {
          new LoadDecoder(LDUH, "lduh", RTLDT_UNSIGNED_HALF),  new AlternateSpaceLoadDecoder(LDUHA, "lduha", RTLDT_UNSIGNED_HALF),
          illegalDecoder, illegalDecoder
        },
        {
          new LoadDecoder(LDD, "ldd", RTLDT_UNSIGNED_DWORD), new AlternateSpaceLoadDecoder(LDDA, "ldda", RTLDT_UNSIGNED_DWORD),
          new LoadDecoder(LDDF, "ldd", RTLDT_FL_DOUBLE),  new SpecialLoadDecoder(LDDC, "ldd", SPARCSpecialRegisters.CREG)
        },
        {
          new StoreDecoder(ST, "st", RTLDT_UNSIGNED_WORD), new AlternateSpaceStoreDecoder(STA, "sta", RTLDT_UNSIGNED_WORD),
          new StoreDecoder(STF, "st", RTLDT_FL_SINGLE),   new SpecialStoreDecoder(STC, "st", SPARCSpecialRegisters.CREG)
        },
        {
          new StoreDecoder(STB, "stb", RTLDT_UNSIGNED_BYTE), new AlternateSpaceStoreDecoder(STBA, "stba", RTLDT_UNSIGNED_BYTE),
          new SpecialStoreDecoder(STFSR, "st", SPARCSpecialRegisters.FSR), new SpecialStoreDecoder(STCSR, "st", SPARCSpecialRegisters.CSR),
        },
        {
          new StoreDecoder(STH, "sth", RTLDT_UNSIGNED_HALF), new AlternateSpaceStoreDecoder(STHA, "stha", RTLDT_UNSIGNED_HALF),
          new SpecialStoreDecoder(STDFQ, "std", SPARCSpecialRegisters.FQ), new SpecialStoreDecoder(STDCQ, "std", SPARCSpecialRegisters.CQ),
        },
        {
          new StoreDecoder(STD, "std", RTLDT_UNSIGNED_DWORD),  new AlternateSpaceStoreDecoder(STDA, "stda", RTLDT_UNSIGNED_DWORD),
          new StoreDecoder(STDF, "std", RTLDT_FL_DOUBLE),  new SpecialStoreDecoder(STDC, "std", SPARCSpecialRegisters.CREG)
        },
        {
          illegalDecoder, illegalDecoder,
          illegalDecoder, illegalDecoder
        },
        {
          new LoadDecoder(LDSB, "ldsb", RTLDT_SIGNED_BYTE), new AlternateSpaceLoadDecoder(LDSBA, "ldsba", RTLDT_UNSIGNED_BYTE),
          illegalDecoder, illegalDecoder
        },
        {
          new LoadDecoder(LDSH, "ldsh", RTLDT_SIGNED_HALF), new AlternateSpaceLoadDecoder(LDSHA, "ldsha", RTLDT_UNSIGNED_HALF),
          illegalDecoder, illegalDecoder
        },
        {
          illegalDecoder, illegalDecoder,
          illegalDecoder, illegalDecoder
        },
        {
          illegalDecoder, illegalDecoder,
          illegalDecoder, illegalDecoder
        },
        {
          new LdstubDecoder(LDSTUB, "ldstub", RTLDT_UNSIGNED_BYTE), new AlternateSpaceLdstubDecoder(LDSTUBA, "ldstuba", RTLDT_UNSIGNED_BYTE),
          illegalDecoder, illegalDecoder
        },
        {
          illegalDecoder, illegalDecoder,
          illegalDecoder, illegalDecoder
        },
        {
          new SwapDecoder(SWAP, "swap", RTLDT_UNSIGNED_WORD), new AlternateSpaceSwapDecoder(SWAPA, "swapa", RTLDT_UNSIGNED_WORD),
          illegalDecoder, illegalDecoder
        },
    };

    protected InstructionDecoder getFormat3Decoder(int row, int column) {
        return format3Decoders[row][column];
    }

    // op3 decoder table for op=2 (FORMAT_3A) instructions
    // Appendix F - Opcodes and Condition Codes - Page 228 - Table F-3
    protected static final InstructionDecoder format3ADecoders[][] = {
        {
          new ArithmeticDecoder(ADD, "add", RTLOP_ADD), new ArithmeticDecoder(ADDcc, "addcc", RTLOP_ADD),
          new ArithmeticDecoder(TADDcc, "taddcc", RTLOP_ADD),  new WriteDecoder(SPARCSpecialRegisters.ASR)
        },
        {
          new LogicDecoder(AND, "and", RTLOP_AND), new LogicDecoder(ANDcc, "andcc", RTLOP_AND),
          new ArithmeticDecoder(TSUBcc, "tsubcc", RTLOP_ADD),  new WriteDecoder(SPARCSpecialRegisters.PSR)
        },
        {
          new LogicDecoder(OR, "or", RTLOP_OR), new LogicDecoder(ORcc, "orcc", RTLOP_OR),
          new ArithmeticDecoder(TADDccTV, "taddcctv", RTLOP_ADD),  new WriteDecoder(SPARCSpecialRegisters.WIM)
        },
        {
          new LogicDecoder(XOR, "xor", RTLOP_XOR), new LogicDecoder(XORcc, "xorcc", RTLOP_XOR),
          new ArithmeticDecoder(TSUBccTV, "tsubcctv", RTLOP_SUB),  new WriteDecoder(SPARCSpecialRegisters.TBR)
        },
        {
          new ArithmeticDecoder(SUB, "sub", RTLOP_SUB),  new ArithmeticDecoder(SUBcc, "subcc", RTLOP_SUB),
          new ArithmeticDecoder(MULScc, "mulscc", RTLOP_SMUL), new V8FPop1Decoder()
        },
        {
          new LogicDecoder(ANDN, "andn", RTLOP_NAND), new LogicDecoder(ANDNcc, "andncc", RTLOP_NAND),
          new ShiftDecoder(SLL, "sll", RTLOP_SLL), new V8FPop2Decoder()
        },
        {
          new LogicDecoder(ORN, "orn", RTLOP_NOR), new LogicDecoder(ORNcc, "orncc", RTLOP_NOR),
          new ShiftDecoder(SRL, "srl", RTLOP_SRL), new CoprocessorDecoder(CPop1)
        },
        {
          new LogicDecoder(XNOR, "xnor", RTLOP_XNOR), new LogicDecoder(XNORcc, "xnorcc", RTLOP_XNOR),
          new ShiftDecoder(SRA, "sra", RTLOP_SRA), new CoprocessorDecoder(CPop2)
        },
        {
          new ArithmeticDecoder(ADDX, "addx", RTLOP_ADDC), new ArithmeticDecoder(ADDXcc, "addxcc", RTLOP_ADDC),
          new ReadDecoder(SPARCSpecialRegisters.ASR), new JmplDecoder()
        },
        {
          illegalDecoder, illegalDecoder,
          new ReadDecoder(SPARCSpecialRegisters.PSR), new RettDecoder()
        },
        {
          new ArithmeticDecoder(UMUL, "umul", RTLOP_UMUL), new ArithmeticDecoder(UMULcc, "umulcc", RTLOP_UMUL),
          new ReadDecoder(SPARCSpecialRegisters.WIM), new TrapDecoder()
        },
        {
          new ArithmeticDecoder(SMUL, "smul", RTLOP_SMUL), new ArithmeticDecoder(SMULcc, "smulcc", RTLOP_SMUL),
          new ReadDecoder(SPARCSpecialRegisters.TBR), new FlushDecoder()
        },
        {
          new ArithmeticDecoder(SUBX, "subx", RTLOP_SUBC), new ArithmeticDecoder(SUBXcc, "subxcc", RTLOP_SUBC),
          illegalDecoder, new SaveDecoder()
        },
        {
          illegalDecoder, illegalDecoder,
          illegalDecoder, new RestoreDecoder()
        },
        {
          new ArithmeticDecoder(UDIV, "udiv", RTLOP_UDIV),  new ArithmeticDecoder(UDIVcc, "udivcc", RTLOP_UDIV),
          illegalDecoder, illegalDecoder
        },
        {
          new ArithmeticDecoder(SDIV, "sdiv", RTLOP_SDIV), new ArithmeticDecoder(SDIVcc, "sdivcc", RTLOP_SDIV),
          illegalDecoder, illegalDecoder
        }
    };

    protected InstructionDecoder getFormat3ADecoder(int row, int column) {
        return format3ADecoders[row][column];
    }
}