]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/sparc64/sparc64/db_disasm.c
Import DTS files from Linux 4.18
[FreeBSD/FreeBSD.git] / sys / sparc64 / sparc64 / db_disasm.c
1 /*-
2  * SPDX-License-Identifier: BSD-4-Clause
3  *
4  * Copyright (c) 1994 David S. Miller, davem@nadzieja.rutgers.edu
5  * Copyright (c) 1995 Paul Kranenburg
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  * 3. All advertising materials mentioning features or use of this software
17  *    must display the following acknowledgement:
18  *      This product includes software developed by David Miller.
19  * 4. The name of the author may not be used to endorse or promote products
20  *    derived from this software without specific prior written permission
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
23  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
24  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
25  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
26  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
27  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
31  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  *      from: NetBSD: db_disasm.c,v 1.9 2000/08/16 11:29:42 pk Exp
33  */
34
35 #include <sys/cdefs.h>
36 __FBSDID("$FreeBSD$");
37
38 #include <sys/param.h>
39 #include <sys/systm.h>
40
41 #include <ddb/ddb.h>
42 #include <ddb/db_access.h>
43 #include <ddb/db_sym.h>
44
45 #include <machine/db_machdep.h>
46 #include <machine/instr.h>
47
48 #define SIGN(v)                 (((v)<0)?"-":"")
49
50 /*
51  * All Sparc instructions are 32-bits, with the one exception being
52  * the set instruction which is actually a macro which expands into
53  * two instructions...
54  *
55  * There are 5 different fields that can be used to identify which
56  * operation is encoded into a particular 32-bit insn. There are 3
57  * formats for instuctions, which one being used is determined by
58  * bits 30-31 of the insn. Here are the bit fields and their names:
59  *
60  * 1100 0000 0000 0000 0000 0000 0000 0000 op field, determines format
61  * 0000 0001 1100 0000 0000 0000 0000 0000 op2 field, format 2 only
62  * 0000 0001 1111 1000 0000 0000 0000 0000 op3 field, format 3 only
63  * 0000 0000 0000 0000 0010 0000 0000 0000 f3i bit, format 3 only
64  * 0000 0000 0000 0000 0001 0000 0000 0000 X bit, format 3 only
65  */
66
67 /* FORMAT macros used in sparc_i table to decode each opcode */
68 #define FORMAT1(a)      (EIF_OP(a))
69 #define FORMAT2(a,b)    (EIF_OP(a) | EIF_F2_OP2(b))
70 /* For formats 3 and 4 */
71 #define FORMAT3(a,b,c)  (EIF_OP(a) | EIF_F3_OP3(b) | EIF_F3_I(c))
72 #define FORMAT3F(a,b,c) (EIF_OP(a) | EIF_F3_OP3(b) | EIF_F3_OPF(c))
73
74 /* Helper macros to construct OP3 & OPF */
75 #define OP3_X(x,y)      ((((x) & 3) << 4) | ((y) & 0xf))
76 #define OPF_X(x,y)      ((((x) & 0x1f) << 4) | ((y) & 0xf))
77
78 /* COND condition codes field... */
79 #define COND2(y,x)      (((((y)<<4) & 1)|((x) & 0xf)) << 14)
80
81 struct sparc_insn {
82           unsigned int match;
83           const char* name;
84           const char* format;
85 };
86
87 static const char *const regs[] = {
88         "g0", "g1", "g2", "g3", "g4", "g5", "g6", "g7",
89         "o0", "o1", "o2", "o3", "o4", "o5", "sp", "o7",
90         "l0", "l1", "l2", "l3", "l4", "l5", "l6", "l7",
91         "i0", "i1", "i2", "i3", "i4", "i5", "fp", "i7"
92 };
93
94 static const char *const priv_regs[] = {
95         "tpc", "tnpc", "tstate", "tt", "tick", "tba", "pstate", "tl",
96         "pil", "cwp", "cansave", "canrestore", "cleanwin", "otherwin",
97         "wstate", "fq",
98         "", "", "", "", "", "", "", "",
99         "", "", "", "", "", "", "", "ver"
100 };
101
102 static const char *const state_regs[] = {
103         "y", "", "ccr", "asi", "tick", "pc", "fprs", "asr",
104         "", "", "", "", "", "", "", "",
105         "pcr", "pic", "dcr", "gsr", "set_softint", "clr_softint", "softint",
106         "tick_cmpr", "sys_tick", "sys_tick_cmpr", "", "", "", "", "", "", ""
107 };
108
109 static const char *const ccodes[] = {
110         "fcc0", "fcc1", "fcc2", "fcc3", "icc", "", "xcc", ""
111 };
112
113 static const char *const prefetch[] = {
114         "n_reads", "one_read", "n_writes", "one_write", "page"
115 };
116
117
118 /* The sparc instruction table has a format field which tells what
119    the operand structure for this instruction is. Here are the codes:
120
121 Modifiers (nust be first):
122         a -- opcode has annul bit
123         p -- opcode has branch prediction bit
124
125 Codes:
126         1 -- source register operand stored in rs1
127         2 -- source register operand stored in rs2
128         d -- destination register operand stored in rd
129         3 -- floating source register in rs1
130         4 -- floating source register in rs2
131         e -- floating destination register in rd
132         i -- 13-bit immediate value stored in simm13
133         j -- 11-bit immediate value stored in simm11
134         l -- displacement using d16lo and d16hi
135         m -- 22-bit fcc displacement value
136         n -- 30-bit displacement used in call insns
137         o -- %fcc number specified in cc1 and cc0 fields
138         p -- address computed by the contents of rs1+rs2
139         q -- address computed by the contents of rs1+simm13
140         r -- prefetch
141         s -- %asi is implicit in the insn, rs1 value not used
142         t -- immediate 8-bit asi value
143         u -- 19-bit fcc displacement value
144         5 -- hard register, %fsr lower-half
145         6 -- hard register, %fsr all
146         7 -- [reg_addr rs1+rs2] imm_asi
147         8 -- [reg_addr rs1+simm13] %asi
148         9 -- logical or of the cmask and mmask fields (membar insn)
149         0 -- icc or xcc condition codes register
150         . -- %fcc, %icc, or %xcc in opf_cc field
151         r -- prefection function stored in fcn field
152         A -- privileged register encoded in rs1
153         B -- state register encoded in rs1
154         C -- %hi(value) where value is stored in imm22 field
155         D -- 32-bit shift count in shcnt32
156         E -- 64-bit shift count in shcnt64
157         F -- software trap number stored in sw_trap
158         G -- privileged register encoded in rd
159         H -- state register encoded in rd
160
161 V8 only:
162         Y -- write y register
163         P -- write psr register
164         T -- write tbr register
165         W -- write wim register
166 */
167
168
169 static const struct sparc_insn sparc_i[] = {
170
171         /*
172          * Format 1: Call
173          */
174         {(FORMAT1(1)), "call", "n"},
175
176         /*
177          * Format 0: Sethi & Branches
178          */
179         /* Illegal Instruction Trap */
180         {(FORMAT2(0, 0)), "illtrap", "m"},
181
182         /* Note: if imm22 is zero then this is actually a "nop" grrr... */
183         {(FORMAT2(0, 0x4)), "sethi", "Cd"},
184
185         /* Branch on Integer Co`ndition Codes "Bicc" */
186         {(FORMAT2(0, 2) | EIF_F2_COND(8)), "ba", "a,m"},
187         {(FORMAT2(0, 2) | EIF_F2_COND(0)), "bn", "a,m"},
188         {(FORMAT2(0, 2) | EIF_F2_COND(9)), "bne", "a,m"},
189         {(FORMAT2(0, 2) | EIF_F2_COND(1)), "be", "a,m"},
190         {(FORMAT2(0, 2) | EIF_F2_COND(10)), "bg", "a,m"},
191         {(FORMAT2(0, 2) | EIF_F2_COND(2)), "ble", "a,m"},
192         {(FORMAT2(0, 2) | EIF_F2_COND(11)), "bge", "a,m"},
193         {(FORMAT2(0, 2) | EIF_F2_COND(3)), "bl", "a,m"},
194         {(FORMAT2(0, 2) | EIF_F2_COND(12)), "bgu", "a,m"},
195         {(FORMAT2(0, 2) | EIF_F2_COND(4)), "bleu", "a,m"},
196         {(FORMAT2(0, 2) | EIF_F2_COND(13)), "bcc", "a,m"},
197         {(FORMAT2(0, 2) | EIF_F2_COND(5)), "bcs", "a,m"},
198         {(FORMAT2(0, 2) | EIF_F2_COND(14)), "bpos", "a,m"},
199         {(FORMAT2(0, 2) | EIF_F2_COND(6)), "bneg", "a,m"},
200         {(FORMAT2(0, 2) | EIF_F2_COND(15)), "bvc", "a,m"},
201         {(FORMAT2(0, 2) | EIF_F2_COND(7)), "bvs", "a,m"},
202
203         /* Branch on Integer Condition Codes with Prediction "BPcc" */
204         {(FORMAT2(0, 1) | EIF_F2_COND(8)), "ba", "ap,u"},
205         {(FORMAT2(0, 1) | EIF_F2_COND(0)), "bn", "ap,u"},
206         {(FORMAT2(0, 1) | EIF_F2_COND(9)), "bne", "ap,u"},
207         {(FORMAT2(0, 1) | EIF_F2_COND(1)), "be", "ap,u"},
208         {(FORMAT2(0, 1) | EIF_F2_COND(10)), "bg", "ap,u"},
209         {(FORMAT2(0, 1) | EIF_F2_COND(2)), "ble", "ap,u"},
210         {(FORMAT2(0, 1) | EIF_F2_COND(11)), "bge", "ap,u"},
211         {(FORMAT2(0, 1) | EIF_F2_COND(3)), "bl", "ap,u"},
212         {(FORMAT2(0, 1) | EIF_F2_COND(12)), "bgu", "ap,u"},
213         {(FORMAT2(0, 1) | EIF_F2_COND(4)), "bleu", "ap,u"},
214         {(FORMAT2(0, 1) | EIF_F2_COND(13)), "bcc", "ap,u"},
215         {(FORMAT2(0, 1) | EIF_F2_COND(5)), "bcs", "ap,u"},
216         {(FORMAT2(0, 1) | EIF_F2_COND(14)), "bpos", "ap,u"},
217         {(FORMAT2(0, 1) | EIF_F2_COND(6)), "bneg", "ap,u"},
218         {(FORMAT2(0, 1) | EIF_F2_COND(15)), "bvc", "ap,u"},
219         {(FORMAT2(0, 1) | EIF_F2_COND(7)), "bvs", "ap,u"},
220
221         /* Branch on Integer Register with Prediction "BPr" */
222         {(FORMAT2(0, 3) | EIF_F2_RCOND(1)), "brz", "ap,1l"},
223         {(FORMAT2(0, 3) | EIF_F2_A(1) | EIF_F2_P(1) |
224             EIF_F2_RCOND(2)), "brlex", "ap,1l"},
225         {(FORMAT2(0, 3) | EIF_F2_RCOND(3)), "brlz", "ap,1l"},
226         {(FORMAT2(0, 3) | EIF_F2_RCOND(5)), "brnz", "ap,1l"},
227         {(FORMAT2(0, 3) | EIF_F2_RCOND(6)), "brgz", "ap,1l"},
228         {(FORMAT2(0, 3) | EIF_F2_RCOND(7)), "brgez", "ap,1l"},
229
230         /* Branch on Floating-Point Condition Codes with Prediction "FBPfcc" */
231         {(FORMAT2(0, 5) | EIF_F2_COND(8)), "fba", "ap,m"},
232         {(FORMAT2(0, 5) | EIF_F2_COND(0)), "fbn", "ap,m"},
233         {(FORMAT2(0, 5) | EIF_F2_COND(7)), "fbu", "ap,m"},
234         {(FORMAT2(0, 5) | EIF_F2_COND(6)), "fbg", "ap,m"},
235         {(FORMAT2(0, 5) | EIF_F2_COND(5)), "fbug", "ap,m"},
236         {(FORMAT2(0, 5) | EIF_F2_COND(4)), "fbl", "ap,m"},
237         {(FORMAT2(0, 5) | EIF_F2_COND(3)), "fbul", "ap,m"},
238         {(FORMAT2(0, 5) | EIF_F2_COND(2)), "fblg", "ap,m"},
239         {(FORMAT2(0, 5) | EIF_F2_COND(1)), "fbne", "ap,m"},
240         {(FORMAT2(0, 5) | EIF_F2_COND(9)), "fbe", "ap,m"},
241         {(FORMAT2(0, 5) | EIF_F2_COND(10)), "fbue", "ap,m"},
242         {(FORMAT2(0, 5) | EIF_F2_COND(11)), "fbge", "ap,m"},
243         {(FORMAT2(0, 5) | EIF_F2_COND(12)), "fbuge", "ap,m"},
244         {(FORMAT2(0, 5) | EIF_F2_COND(13)), "fble", "ap,m"},
245         {(FORMAT2(0, 5) | EIF_F2_COND(14)), "fbule", "ap,m"},
246         {(FORMAT2(0, 5) | EIF_F2_COND(15)), "fbo", "ap,m"},
247
248         /* Branch on Floating-Point Condition Codes "FBfcc" */
249         {(FORMAT2(0, 6) | EIF_F2_COND(8)), "fba", "a,m"},
250         {(FORMAT2(0, 6) | EIF_F2_COND(0)), "fbn", "a,m"},
251         {(FORMAT2(0, 6) | EIF_F2_COND(7)), "fbu", "a,m"},
252         {(FORMAT2(0, 6) | EIF_F2_COND(6)), "fbg", "a,m"},
253         {(FORMAT2(0, 6) | EIF_F2_COND(5)), "fbug", "a,m"},
254         {(FORMAT2(0, 6) | EIF_F2_COND(4)), "fbl", "a,m"},
255         {(FORMAT2(0, 6) | EIF_F2_COND(3)), "fbul", "a,m"},
256         {(FORMAT2(0, 6) | EIF_F2_COND(2)), "fblg", "a,m"},
257         {(FORMAT2(0, 6) | EIF_F2_COND(1)), "fbne", "a,m"},
258         {(FORMAT2(0, 6) | EIF_F2_COND(9)), "fbe", "a,m"},
259         {(FORMAT2(0, 6) | EIF_F2_COND(10)), "fbue", "a,m"},
260         {(FORMAT2(0, 6) | EIF_F2_COND(11)), "fbge", "a,m"},
261         {(FORMAT2(0, 6) | EIF_F2_COND(12)), "fbuge", "a,m"},
262         {(FORMAT2(0, 6) | EIF_F2_COND(13)), "fble", "a,m"},
263         {(FORMAT2(0, 6) | EIF_F2_COND(14)), "fbule", "a,m"},
264         {(FORMAT2(0, 6) | EIF_F2_COND(15)), "fbo", "a,m"},
265
266
267
268         /*
269          * Format 3/2: Arithmetic & misc (table 32, appendix E)
270          */
271         {FORMAT3(2, OP3_X(0,0), 0), "add", "12d"},
272         {FORMAT3(2, OP3_X(0,0), 1), "add", "1id"},
273         {FORMAT3(2, OP3_X(1,0), 0), "addcc", "12d"},
274         {FORMAT3(2, OP3_X(1,0), 1), "addcc", "1id"},
275         {FORMAT3(2, OP3_X(2,0), 0), "taddcc", "12d"},
276         {FORMAT3(2, OP3_X(2,0), 1), "taddcc", "1id"},
277         {(FORMAT3(2, 0x30, 1) | EIF_F3_RD(0xf)), "sir", "i"},
278         {FORMAT3(2, OP3_X(3,0), 0), "wr", "12H"},
279         {FORMAT3(2, OP3_X(3,0), 1), "wr", "1iH"},
280
281         {FORMAT3(2, OP3_X(0,1), 0), "and", "12d"},
282         {FORMAT3(2, OP3_X(0,1), 1), "and", "1id"},
283         {FORMAT3(2, OP3_X(1,1), 0), "andcc", "12d"},
284         {FORMAT3(2, OP3_X(1,1), 1), "andcc", "1id"},
285         {FORMAT3(2, OP3_X(2,1), 0), "tsubcc", "12d"},
286         {FORMAT3(2, OP3_X(2,1), 1), "tsubcc", "1id"},
287         {FORMAT3(2, OP3_X(3,1), 0), "saved", ""},
288         {FORMAT3(2, OP3_X(3,1), 0) | EIF_F3_FCN(1), "restored", ""},
289
290         {FORMAT3(2, OP3_X(0,2), 0), "or", "12d"},
291         {FORMAT3(2, OP3_X(0,2), 1), "or", "1id"},
292         {FORMAT3(2, OP3_X(1,2), 0), "orcc", "12d"},
293         {FORMAT3(2, OP3_X(1,2), 1), "orcc", "1id"},
294         {FORMAT3(2, OP3_X(2,2), 0), "taddcctv", "12d"},
295         {FORMAT3(2, OP3_X(2,2), 1), "taddcctv", "1id"},
296         {FORMAT3(2, OP3_X(3,2), 0), "wrpr", "12G"},
297         {FORMAT3(2, OP3_X(3,2), 1), "wrpr", "1iG"},
298
299         {FORMAT3(2, OP3_X(0,3), 0), "xor", "12d"},
300         {FORMAT3(2, OP3_X(0,3), 1), "xor", "1id"},
301         {FORMAT3(2, OP3_X(1,3), 0), "xorcc", "12d"},
302         {FORMAT3(2, OP3_X(1,3), 1), "xorcc", "1id"},
303         {FORMAT3(2, OP3_X(2,3), 0), "tsubcctv", "12d"},
304         {FORMAT3(2, OP3_X(2,3), 1), "tsubcctv", "1id"},
305         {FORMAT3(2, OP3_X(3,3), 0), "UNDEFINED", ""},
306
307         {FORMAT3(2, OP3_X(0,4), 0), "sub", "12d"},
308         {FORMAT3(2, OP3_X(0,4), 1), "sub", "1id"},
309         {FORMAT3(2, OP3_X(1,4), 0), "subcc", "12d"},
310         {FORMAT3(2, OP3_X(1,4), 1), "subcc", "1id"},
311         {FORMAT3(2, OP3_X(2,4), 0), "mulscc", "12d"},
312         {FORMAT3(2, OP3_X(2,4), 1), "mulscc", "1id"},
313         {FORMAT3(2, OP3_X(3,4), 1), "FPop1", ""},       /* see below */
314
315         {FORMAT3(2, OP3_X(0,5), 0), "andn", "12d"},
316         {FORMAT3(2, OP3_X(0,5), 1), "andn", "1id"},
317         {FORMAT3(2, OP3_X(1,5), 0), "andncc", "12d"},
318         {FORMAT3(2, OP3_X(1,5), 1), "andncc", "1id"},
319         {FORMAT3(2, OP3_X(2,5), 0), "sll", "12d"},
320         {FORMAT3(2, OP3_X(2,5), 1), "sll", "1Dd"},
321         {FORMAT3(2, OP3_X(2,5), 0) | EIF_F3_X(1), "sllx", "12d"},
322         {FORMAT3(2, OP3_X(2,5), 1) | EIF_F3_X(1), "sllx", "1Ed"},
323         {FORMAT3(2, OP3_X(3,5), 1), "FPop2", ""},       /* see below */
324
325         {FORMAT3(2, OP3_X(0,6), 0), "orn", "12d"},
326         {FORMAT3(2, OP3_X(0,6), 1), "orn", "1id"},
327         {FORMAT3(2, OP3_X(1,6), 0), "orncc", "12d"},
328         {FORMAT3(2, OP3_X(1,6), 1), "orncc", "1id"},
329         {FORMAT3(2, OP3_X(2,6), 0), "srl", "12d"},
330         {FORMAT3(2, OP3_X(2,6), 1), "srl", "1Dd"},
331         {FORMAT3(2, OP3_X(2,6), 0) | EIF_F3_X(1), "srlx", "12d"},
332         {FORMAT3(2, OP3_X(2,6), 1) | EIF_F3_X(1), "srlx", "1Ed"},
333         {FORMAT3(2, OP3_X(3,6), 1), "impdep1", ""},
334
335         {FORMAT3(2, OP3_X(0,7), 0), "xorn", "12d"},
336         {FORMAT3(2, OP3_X(0,7), 1), "xorn", "1id"},
337         {FORMAT3(2, OP3_X(1,7), 0), "xorncc", "12d"},
338         {FORMAT3(2, OP3_X(1,7), 1), "xorncc", "1id"},
339         {FORMAT3(2, OP3_X(2,7), 0), "sra", "12d"},
340         {FORMAT3(2, OP3_X(2,7), 1), "sra", "1Dd"},
341         {FORMAT3(2, OP3_X(2,7), 0) | EIF_F3_X(1), "srax", "12d"},
342         {FORMAT3(2, OP3_X(2,7), 1) | EIF_F3_X(1), "srax", "1Ed"},
343         {FORMAT3(2, OP3_X(3,7), 1), "impdep2", ""},
344
345         {FORMAT3(2, OP3_X(0,8), 0), "addc", "12d"},
346         {FORMAT3(2, OP3_X(0,8), 1), "addc", "1id"},
347         {FORMAT3(2, OP3_X(1,8), 0), "addccc", "12d"},
348         {FORMAT3(2, OP3_X(1,8), 1), "addccc", "1id"},
349         {(FORMAT3(2, 0x28, 1) | EIF_F3_RS1(15)), "membar", "9"},
350         {(FORMAT3(2, 0x28, 0) | EIF_F3_RS1(15)), "stbar", ""},
351         {FORMAT3(2, OP3_X(2,8), 0), "rd", "Bd"},
352
353         {FORMAT3(2, OP3_X(3,8), 0), "jmpl", "pd"},
354         {FORMAT3(2, OP3_X(3,8), 1), "jmpl", "qd"},
355
356         {FORMAT3(2, OP3_X(0,9), 0), "mulx", "12d"},
357         {FORMAT3(2, OP3_X(0,9), 1), "mulx", "1id"},
358         {FORMAT3(2, OP3_X(1,9), 0), "UNDEFINED", ""},
359         {FORMAT3(2, OP3_X(2,9), 0), "UNDEFINED", ""},
360         {FORMAT3(2, OP3_X(3,9), 0), "return", "p"},
361         {FORMAT3(2, OP3_X(3,9), 1), "return", "q"},
362
363         {FORMAT3(2, OP3_X(0,10), 0), "umul", "12d"},
364         {FORMAT3(2, OP3_X(0,10), 1), "umul", "1id"},
365         {FORMAT3(2, OP3_X(1,10), 0), "umulcc", "12d"},
366         {FORMAT3(2, OP3_X(1,10), 1), "umulcc", "1id"},
367         {FORMAT3(2, OP3_X(2,10), 0), "rdpr", "Ad"},
368                 /*
369                  * OP3 = (3,10): TCC: Trap on Integer Condition Codes
370                  */
371                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x8)), "ta", "12F"},
372                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x8)), "ta", "0F"},
373                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x0)), "tn", "12F"},
374                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x0)), "tn", "0F"},
375                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x9)), "tne", "12F"},
376                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x9)), "tne", "0F"},
377                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x1)), "te", "12F"},
378                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x1)), "te", "0F"},
379                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xa)), "tg", "12F"},
380                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xa)), "tg", "0F"},
381                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x2)), "tle", "12F"},
382                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x2)), "tle", "0F"},
383                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xb)), "tge", "12F"},
384                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xb)), "tge", "0F"},
385                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x3)), "tl", "12F"},
386                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x3)), "tl", "0F"},
387                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xc)), "tgu", "12F"},
388                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xc)), "tgu", "0F"},
389                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x4)), "tleu", "12F"},
390                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x4)), "tleu", "0F"},
391                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xd)), "tcc", "12F"},
392                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xd)), "tcc", "0F"},
393                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x5)), "tcs", "12F"},
394                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x5)), "tcs", "0F"},
395                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xe)), "tpos", "12F"},
396                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xe)), "tpos", "0F"},
397                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x6)), "tneg", "12F"},
398                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x6)), "tneg", "0F"},
399                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0xf)), "tvc", "12F"},
400                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0xf)), "tvc", "0F"},
401                 {(FORMAT3(2, OP3_X(3,10), 0) | EIF_F4_TCOND(0x7)), "tvs", "12F"},
402                 {(FORMAT3(2, OP3_X(3,10), 1) | EIF_F4_TCOND(0x7)), "tvs", "0F"},
403
404         {FORMAT3(2, OP3_X(0,11), 0), "smul", "12d"},
405         {FORMAT3(2, OP3_X(0,11), 1), "smul", "1id"},
406         {FORMAT3(2, OP3_X(1,11), 0), "smulcc", "12d"},
407         {FORMAT3(2, OP3_X(1,11), 1), "smulcc", "1id"},
408         {FORMAT3(2, OP3_X(2,11), 0), "flushw", ""},
409         {FORMAT3(2, OP3_X(3,11), 0), "flush", "p"},
410         {FORMAT3(2, OP3_X(3,11), 1), "flush", "q"},
411
412         {FORMAT3(2, OP3_X(0,12), 0), "subc", "12d"},
413         {FORMAT3(2, OP3_X(0,12), 1), "subc", "1id"},
414         {FORMAT3(2, OP3_X(1,12), 0), "subccc", "12d"},
415         {FORMAT3(2, OP3_X(1,12), 1), "subccc", "1id"},
416                 /*
417                  * OP3 = (2,12): MOVcc, Move Integer Register on Condition
418                  */
419                 /* For Integer Condition Codes */
420                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,8)), "mova", "0jd"},
421                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,8)), "mova", "02d"},
422                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,0)), "movn", "0jd"},
423                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,0)), "movn", "02d"},
424                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,9)), "movne", "0jd"},
425                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,9)), "movne", "02d"},
426                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,1)), "move", "0jd"},
427                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,1)), "move", "02d"},
428                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,10)), "movg", "0jd"},
429                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,10)), "movg", "02d"},
430                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,2)), "movle", "0jd"},
431                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,2)), "movle", "02d"},
432                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,11)), "movge", "0jd"},
433                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,11)), "movge", "02d"},
434                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,3)), "movl", "0jd"},
435                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,3)), "movl", "02d"},
436                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,12)), "movgu", "0jd"},
437                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,12)), "movgu", "02d"},
438                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,4)), "movleu", "0jd"},
439                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,4)), "movleu", "02d"},
440                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,13)), "movcc", "0jd"},
441                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,13)), "movcc", "02d"},
442                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,5)), "movcs", "0jd"},
443                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,5)), "movcs", "02d"},
444                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,14)), "movpos", "0jd"},
445                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,14)), "movpos", "02d"},
446                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,6)), "movneg", "0jd"},
447                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,6)), "movneg", "02d"},
448                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,15)), "movvc", "0jd"},
449                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,15)), "movvc", "02d"},
450                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(1,7)), "movvs", "0jd"},
451                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(1,7)), "movvs", "02d"},
452
453                 /* For Floating-Point Condition Codes */
454                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,8)), "mova", "ojd"},
455                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,8)), "mova", "o2d"},
456                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,0)), "movn", "ojd"},
457                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,0)), "movn", "o2d"},
458                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,7)), "movu", "ojd"},
459                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,7)), "movu", "o2d"},
460                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,6)), "movg", "ojd"},
461                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,6)), "movg", "o2d"},
462                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,5)), "movug", "ojd"},
463                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,5)), "movug", "o2d"},
464                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,4)), "movl", "ojd"},
465                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,4)), "movl", "o2d"},
466                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,3)), "movul", "ojd"},
467                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,3)), "movul", "o2d"},
468                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,2)), "movlg", "ojd"},
469                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,2)), "movlg", "o2d"},
470                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,1)), "movne", "ojd"},
471                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,1)), "movne", "o2d"},
472                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,9)), "move", "ojd"},
473                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,9)), "move", "o2d"},
474                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,10)), "movue", "ojd"},
475                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,10)), "movue", "o2d"},
476                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,11)), "movge", "ojd"},
477                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,11)), "movge", "o2d"},
478                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,12)), "movuge", "ojd"},
479                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,12)), "movuge", "o2d"},
480                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,13)), "movle", "ojd"},
481                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,13)), "movle", "o2d"},
482                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,14)), "movule", "ojd"},
483                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,14)), "movule", "o2d"},
484                 {(FORMAT3(2, OP3_X(2,12), 1) | COND2(0,15)), "movo", "ojd"},
485                 {(FORMAT3(2, OP3_X(2,12), 0) | COND2(0,15)), "movo", "o2d"},
486
487         {FORMAT3(2, OP3_X(3,12), 0), "save", "12d"},
488         {FORMAT3(2, OP3_X(3,12), 1), "save", "1id"},
489
490         {FORMAT3(2, OP3_X(0,13), 0), "udivx", "12d"},
491         {FORMAT3(2, OP3_X(0,13), 1), "udivx", "1id"},
492         {FORMAT3(2, OP3_X(1,13), 0), "UNDEFINED", ""},
493         {FORMAT3(2, OP3_X(2,13), 0), "sdivx", "12d"},
494         {FORMAT3(2, OP3_X(2,13), 1), "sdivx", "1id"},
495         {FORMAT3(2, OP3_X(3,13), 0), "restore", "12d"},
496         {FORMAT3(2, OP3_X(3,13), 1), "restore", "1id"},
497
498         {FORMAT3(2, OP3_X(0,14), 0), "udiv", "12d"},
499         {FORMAT3(2, OP3_X(0,14), 1), "udiv", "1id"},
500         {FORMAT3(2, OP3_X(1,14), 0), "udivcc", "12d"},
501         {FORMAT3(2, OP3_X(1,14), 1), "udivcc", "1id"},
502         {FORMAT3(2, OP3_X(2,14), 0), "popc", "2d"},
503         {FORMAT3(2, OP3_X(2,14), 1), "popc", "id"},
504
505         {FORMAT3(2, OP3_X(3,14), 0), "done", ""},
506         {FORMAT3(2, OP3_X(3,14) | EIF_F3_FCN(1), 1), "retry", ""},
507
508         {FORMAT3(2, OP3_X(0,15), 0), "sdiv", "12d"},
509         {FORMAT3(2, OP3_X(0,15), 1), "sdiv", "1id"},
510         {FORMAT3(2, OP3_X(1,15), 0), "sdivcc", "12d"},
511         {FORMAT3(2, OP3_X(1,15), 1), "sdivcc", "1id"},
512                 /*
513                  * OP3 = (2,15): MOVr:
514                  *      Move Integer Register on Register Condition
515                  */
516                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(1)), "movrz", "1jd"},
517                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(1)), "movrz", "12d"},
518                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(2)), "movrlez", "1jd"},
519                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(2)), "movrlez", "12d"},
520                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(3)), "movrlz", "1jd"},
521                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(3)), "movrlz", "12d"},
522                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(5)), "movrnz", "1jd"},
523                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(5)), "movrnz", "12d"},
524                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(6)), "movrgz", "1jd"},
525                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(6)), "movrgz", "12d"},
526                 {(FORMAT3(2, OP3_X(2,15), 1) | EIF_F3_RCOND(7)), "movrgez", "1jd"},
527                 {(FORMAT3(2, OP3_X(2,15), 0) | EIF_F3_RCOND(7)), "movrgez", "12d"},
528
529         {FORMAT3(2, OP3_X(3,15), 0), "UNDEFINED", ""},
530
531
532         /*
533          * Format 3/3: Load and store (appendix E, table 33)
534          */
535
536         /* Loads */
537         {(FORMAT3(3, OP3_X(0,0), 0)), "lduw", "pd"},
538         {(FORMAT3(3, OP3_X(0,0), 1)), "lduw", "qd"},
539         {(FORMAT3(3, OP3_X(1,0), 0)), "lduwa", "7d"},
540         {(FORMAT3(3, OP3_X(1,0), 1)), "lduwa", "8d"},
541         {(FORMAT3(3, OP3_X(2,0), 0)), "ldf", "pe"},
542         {(FORMAT3(3, OP3_X(2,0), 1)), "ldf", "qe"},
543         {(FORMAT3(3, OP3_X(3,0), 0)), "ldfa", "7e"},
544         {(FORMAT3(3, OP3_X(3,0), 1)), "ldfa", "8e"},
545
546         {(FORMAT3(3, OP3_X(0,1), 0)), "ldub", "pd"},
547         {(FORMAT3(3, OP3_X(0,1), 1)), "ldub", "qd"},
548         {(FORMAT3(3, OP3_X(1,1), 0)), "lduba", "7d"},
549         {(FORMAT3(3, OP3_X(1,1), 1)), "lduba", "8d"},
550         {(FORMAT3(3, OP3_X(2,1), 0) | EIF_F3_RD(0)), "lduw", "p5"},
551         {(FORMAT3(3, OP3_X(2,1), 1) | EIF_F3_RD(0)), "lduw", "q5"},
552         {(FORMAT3(3, OP3_X(2,1), 0) | EIF_F3_RD(1)), "ldx", "p6"},
553         {(FORMAT3(3, OP3_X(2,1), 1) | EIF_F3_RD(1)), "ldx", "q6"},
554
555         {(FORMAT3(3, OP3_X(0,2), 0)), "lduh", "pd"},
556         {(FORMAT3(3, OP3_X(0,2), 1)), "lduh", "qd"},
557         {(FORMAT3(3, OP3_X(1,2), 0)), "lduha", "7d"},
558         {(FORMAT3(3, OP3_X(1,2), 1)), "lduha", "8d"},
559         {(FORMAT3(3, OP3_X(2,2), 0)), "ldq", "pe"},
560         {(FORMAT3(3, OP3_X(2,2), 1)), "ldq", "qe"},
561         {(FORMAT3(3, OP3_X(3,2), 0)), "ldqa", "7e"},
562         {(FORMAT3(3, OP3_X(3,2), 1)), "ldqa", "8e"},
563
564         {(FORMAT3(3, OP3_X(0,3), 0)), "ldd", "pd"},
565         {(FORMAT3(3, OP3_X(0,3), 1)), "ldd", "qd"},
566         {(FORMAT3(3, OP3_X(1,3), 0)), "ldda", "7d"},
567         {(FORMAT3(3, OP3_X(1,3), 1)), "ldda", "8d"},
568         {(FORMAT3(3, OP3_X(2,3), 0)), "ldd", "pe"},
569         {(FORMAT3(3, OP3_X(2,3), 1)), "ldd", "qe"},
570         {(FORMAT3(3, OP3_X(3,3), 0)), "ldda", "7e"},
571         {(FORMAT3(3, OP3_X(3,3), 1)), "ldda", "8e"},
572
573         {(FORMAT3(3, OP3_X(0,4), 0)), "stw", "dp"},
574         {(FORMAT3(3, OP3_X(0,4), 1)), "stw", "dq"},
575         {(FORMAT3(3, OP3_X(1,4), 0)), "stwa", "d7"},
576         {(FORMAT3(3, OP3_X(1,4), 1)), "stwa", "d8"},
577         {(FORMAT3(3, OP3_X(2,4), 0)), "stf", "ep"},
578         {(FORMAT3(3, OP3_X(2,4), 1)), "stf", "eq"},
579         {(FORMAT3(3, OP3_X(3,4), 0)), "stfa", "e7"},
580         {(FORMAT3(3, OP3_X(3,4), 1)), "stfa", "e8"},
581
582         {(FORMAT3(3, OP3_X(0,5), 0)), "stb", "dp"},
583         {(FORMAT3(3, OP3_X(0,5), 1)), "stb", "dq"},
584         {(FORMAT3(3, OP3_X(1,5), 0)), "stba", "d7"},
585         {(FORMAT3(3, OP3_X(1,5), 1)), "stba", "d8"},
586         {(FORMAT3(3, OP3_X(2,5), 0)), "stw", "5p"},
587         {(FORMAT3(3, OP3_X(2,5), 1)), "stw", "5q"},
588         {(FORMAT3(3, OP3_X(2,5), 0) | EIF_F3_RD(1)), "stx", "6p"},
589         {(FORMAT3(3, OP3_X(2,5), 1) | EIF_F3_RD(1)), "stx", "6q"},
590
591         {(FORMAT3(3, OP3_X(0,6), 0)), "sth", "dp"},
592         {(FORMAT3(3, OP3_X(0,6), 1)), "sth", "dq"},
593         {(FORMAT3(3, OP3_X(1,6), 0)), "stha", "d7"},
594         {(FORMAT3(3, OP3_X(1,6), 1)), "stha", "d8"},
595         {(FORMAT3(3, OP3_X(2,6), 0)), "stq", "ep"},
596         {(FORMAT3(3, OP3_X(2,6), 1)), "stq", "eq"},
597         {(FORMAT3(3, OP3_X(3,6), 0)), "stqa", "e7"},
598         {(FORMAT3(3, OP3_X(3,6), 1)), "stqa", "e8"},
599
600         {(FORMAT3(3, OP3_X(0,7), 0)), "std", "dp"},
601         {(FORMAT3(3, OP3_X(0,7), 1)), "std", "dq"},
602         {(FORMAT3(3, OP3_X(1,7), 0)), "stda", "d7"},
603         {(FORMAT3(3, OP3_X(1,7), 1)), "stda", "d8"},
604         {(FORMAT3(3, OP3_X(2,7), 0)), "std", "ep"},
605         {(FORMAT3(3, OP3_X(2,7), 1)), "std", "eq"},
606         {(FORMAT3(3, OP3_X(3,7), 0)), "stda", "e7"},
607         {(FORMAT3(3, OP3_X(3,7), 1)), "stda", "e8"},
608
609         {(FORMAT3(3, OP3_X(0,8), 0)), "ldsw", "pd"},
610         {(FORMAT3(3, OP3_X(0,8), 1)), "ldsw", "qd"},
611         {(FORMAT3(3, OP3_X(1,8), 0)), "ldswa", "7d"},
612         {(FORMAT3(3, OP3_X(1,8), 1)), "ldswa", "8d"},
613
614         {(FORMAT3(3, OP3_X(0,9), 0)), "ldsb", "pd"},
615         {(FORMAT3(3, OP3_X(0,9), 1)), "ldsb", "qd"},
616         {(FORMAT3(3, OP3_X(1,9), 0)), "ldsba", "7d"},
617         {(FORMAT3(3, OP3_X(1,9), 1)), "ldsba", "8d"},
618
619         {(FORMAT3(3, OP3_X(0,10), 0)), "ldsh", "pd"},
620         {(FORMAT3(3, OP3_X(0,10), 1)), "ldsh", "qd"},
621         {(FORMAT3(3, OP3_X(1,10), 0)), "ldsha", "7d"},
622         {(FORMAT3(3, OP3_X(1,10), 1)), "ldsha", "8d"},
623
624         {(FORMAT3(3, OP3_X(0,11), 0)), "ldx", "pd"},
625         {(FORMAT3(3, OP3_X(0,11), 1)), "ldx", "qd"},
626         {(FORMAT3(3, OP3_X(1,11), 0)), "ldxa", "7d"},
627         {(FORMAT3(3, OP3_X(1,11), 1)), "ldxa", "8d"},
628
629         {(FORMAT3(3, OP3_X(3,12), 1)), "casa", "s2d"},
630         {(FORMAT3(3, OP3_X(3,12), 0)), "casa", "t2d"},
631
632         {(FORMAT3(3, OP3_X(0,13), 0)), "ldstub", "7d"},
633         {(FORMAT3(3, OP3_X(0,13), 1)), "ldstub", "8d"},
634         {(FORMAT3(3, OP3_X(1,13), 0)), "ldstuba", "pd"},
635         {(FORMAT3(3, OP3_X(1,13), 1)), "ldstuba", "qd"},
636         {(FORMAT3(3, OP3_X(2,13), 0)), "prefetch", "pr"},
637         {(FORMAT3(3, OP3_X(2,13), 1)), "prefetch", "qr"},
638         {(FORMAT3(3, OP3_X(3,13), 0)), "prefetcha", "7r"},
639         {(FORMAT3(3, OP3_X(3,13), 1)), "prefetcha", "8r"},
640
641         {(FORMAT3(3, OP3_X(0,14), 0)), "stx", "dp"},
642         {(FORMAT3(3, OP3_X(0,14), 1)), "stx", "dq"},
643         {(FORMAT3(3, OP3_X(1,14), 0)), "stxa", "d7"},
644         {(FORMAT3(3, OP3_X(1,14), 1)), "stxa", "d8"},
645         {(FORMAT3(3, OP3_X(3,14), 0)), "casxa", "t2d"},
646         {(FORMAT3(3, OP3_X(3,14), 1)), "casxa", "s2d"},
647
648         /* Swap Register */
649         {(FORMAT3(3, OP3_X(0,15), 0)), "swap", "pd"},
650         {(FORMAT3(3, OP3_X(0,15), 1)), "swap", "qd"},
651         {(FORMAT3(3, OP3_X(1,15), 0)), "swapa", "7d"},
652         {(FORMAT3(3, OP3_X(1,15), 1)), "swapa", "8d"},
653
654
655         /*
656          * OP3 = (3,4): FPop1 (table 34)
657          */
658         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,1))), "fmovs", ".4e"},
659         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,2))), "fmovd", ".4e"},
660         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,3))), "fmovq", ".4e"},
661         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,5))), "fnegs", "4e"},
662         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,6))), "fnegd", "4e"},
663         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,7))), "fnegq", "4e"},
664         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,9))), "fabss", "4e"},
665         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,10))), "fabsd", "4e"},
666         {(FORMAT3F(2, OP3_X(3,4), OPF_X(0,11))), "fabsq", "4e"},
667
668         {(FORMAT3F(2, OP3_X(3,4), OPF_X(2,9))), "fsqrts", "4e"},
669         {(FORMAT3F(2, OP3_X(3,4), OPF_X(2,10))), "fsqrtd", "4e"},
670         {(FORMAT3F(2, OP3_X(3,4), OPF_X(2,11))), "fsqrtq", "4e"},
671
672         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,1))), "fadds", "34e"},
673         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,2))), "faddd", "34e"},
674         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,3))), "faddq", "34e"},
675         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,5))), "fsubs", "34e"},
676         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,6))), "fsubd", "34e"},
677         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,7))), "fsubq", "34e"},
678         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,9))), "fmuls", "34e"},
679         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,10))), "fmuld", "34e"},
680         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,11))), "fmulq", "34e"},
681         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,13))), "fdivs", "34e"},
682         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,14))), "fdivd", "34e"},
683         {(FORMAT3F(2, OP3_X(3,4), OPF_X(4,15))), "fdivq", "34e"},
684
685         {(FORMAT3F(2, OP3_X(3,4), OPF_X(6,9))), "fsmuld", "34e"},
686         {(FORMAT3F(2, OP3_X(3,4), OPF_X(6,14))), "fdmulq", "34e"},
687
688         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,1))), "fstox", "4e"},
689         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,2))), "fdtox", "4e"},
690         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,3))), "fqtox", "4e"},
691         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,4))), "fxtos", "4e"},
692         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,8))), "fxtod", "4e"},
693         {(FORMAT3F(2, OP3_X(3,4), OPF_X(8,12))), "fxtoq", "4e"},
694
695         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,4))), "fitos", "4e"},
696         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,6))), "fdtos", "4e"},
697         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,7))), "fqtos", "4e"},
698         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,8))), "fitod", "4e"},
699         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,9))), "fstod", "4e"},
700         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,11))), "fqtod", "4e"},
701         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,12))), "fitoq", "4e"},
702         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,13))), "fstoq", "4e"},
703         {(FORMAT3F(2, OP3_X(3,4), OPF_X(12,14))), "fdtoq", "4e"},
704
705         {(FORMAT3F(2, OP3_X(3,4), OPF_X(13,1))), "fstoi", "4e"},
706         {(FORMAT3F(2, OP3_X(3,4), OPF_X(13,2))), "fdtoi", "4e"},
707         {(FORMAT3F(2, OP3_X(3,4), OPF_X(13,3))), "fqtoi", "4e"},
708
709
710 #ifdef xxx
711         /*
712          * OP3 =(3,5): FPop2 (table 35)
713          */
714         {(FORMAT3F(2, OP3_X(3,5), 81)), "fcmps", "o34"},
715         {(FORMAT3F(2, OP3_X(3,5), 82)), "fcmpd", "o34"},
716         {(FORMAT3F(2, OP3_X(3,5), 83)), "fcmpq", "o34"},
717         {(FORMAT3F(2, OP3_X(3,5), 85)), "fcmpes", "o34"},
718         {(FORMAT3F(2, OP3_X(3,5), 86)), "fcmped", "o34"},
719         {(FORMAT3F(2, OP3_X(3,5), 87)), "fcmpeq", "o34"},
720
721         /* Move Floating-Point Register on Condition "FMOVcc" */
722         /* FIXME should check for single, double, and quad movements */
723         /* Integer Condition Codes */
724         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,8)), "fmova", "04e"},
725         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,0)), "fmovn", "04e"},
726         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,9)), "fmovne", "04e"},
727         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,1)), "fmove", "04e"},
728         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,10)), "fmovg", "04e"},
729         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,2)), "fmovle", "04e"},
730         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,11)), "fmovge", "04e"},
731         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,3)), "fmovl", "04e"},
732         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,12)), "fmovgu", "04e"},
733         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,4)), "fmovleu", "04e"},
734         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,13)), "fmovcc", "04e"},
735         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,5)), "fmovcs", "04e"},
736         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,14)), "fmovpos", "04e"},
737         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,6)), "fmovneg", "04e"},
738         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,15)), "fmovvc", "04e"},
739         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,7)), "fmovvs", "04e"},
740
741         /* Floating-Point Condition Codes */
742         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,8)), "fmova", "o4e"},
743         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,0)), "fmovn", "o4e"},
744         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,7)), "fmovu", "o4e"},
745         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,6)), "fmovg", "o4e"},
746         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,5)), "fmovug", "o4e"},
747         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,4)), "fmovk", "o4e"},
748         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,3)), "fmovul", "o4e"},
749         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,2)), "fmovlg", "o4e"},
750         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,1)), "fmovne", "o4e"},
751         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,9)), "fmove", "o4e"},
752         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,10)), "fmovue", "o4e"},
753         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,11)), "fmovge", "o4e"},
754         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,12)), "fmovuge", "o4e"},
755         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,13)), "fmovle", "o4e"},
756         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,14)), "fmovule", "o4e"},
757         {(FORMAT3(2, OP3_X(3,5), 0) | COND2(0,15)), "fmovo", "o4e"},
758
759         /* Move F-P Register on Integer Register Condition "FMOVr" */
760         /* FIXME: check for short, double, and quad's */
761         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(1)), "fmovre", "14e"},
762         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(2)), "fmovrlez", "14e"},
763         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(3)), "fmovrlz", "14e"},
764         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(5)), "fmovrne", "14e"},
765         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(6)), "fmovrgz", "14e"},
766         {(FORMAT3(2, OP3_X(3,5), 0) | EIF_F3_RCOND(7)), "fmovrgez", "14e"},
767 #endif
768         /* FP logical insns -- UltraSPARC extens */
769         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,0))), "fzero", "e"},
770         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,1))), "fzeros", "e"},
771         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,14))), "fone", "e"},
772         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,15))), "fones", "e"},
773         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,4))), "fsrc1", "3e"},
774         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,5))), "fsrc1s", "3e"},
775         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,8))), "fsrc2", "4e"},
776         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,9))), "fsrc2s", "4e"},
777         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,10))), "fnot1", "3e"},
778         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,11))), "fnot1s", "3e"},
779         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,6))), "fnot2", "4e"},
780         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,7))), "fnot2s", "4e"},
781         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,12))), "for", "34e"},
782         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,13))), "fors", "34e"},
783         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,2))), "fnor", "34e"},
784         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,3))), "fnors", "34e"},
785         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,0))), "fand", "34e"},
786         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,1))), "fands", "34e"},
787         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,14))), "fnand", "34e"},
788         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,15))), "fnands", "34e"},
789         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,12))), "fxor", "34e"},
790         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,13))), "fxors", "34e"},
791         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,2))), "fxnor", "34e"},
792         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,3))), "fxnors", "34e"},
793         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,10))), "fornot1", "34e"},
794         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,11))), "fornot1s", "34e"},
795         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,6))), "fornot2", "34e"},
796         {(FORMAT3F(2, OP3_X(3,6), OPF_X(7,7))), "fornot2s", "34e"},
797         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,8))), "fandnot1", "34e"},
798         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,9))), "fandnot1s", "34e"},
799         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,4))), "fandnot2", "34e"},
800         {(FORMAT3F(2, OP3_X(3,6), OPF_X(6,5))), "fandnot2s", "34e"},
801
802         /* grrrr.... */
803         {0, 0, 0}
804
805 };
806
807 db_addr_t
808 db_disasm(db_addr_t loc, bool altfmt)
809 {
810         const struct sparc_insn* i_ptr = (struct sparc_insn *)&sparc_i;
811         unsigned int insn, you_lose, bitmask;
812         int matchp;
813         const char* f_ptr, *cp;
814
815         you_lose = 0;
816         matchp = 0;
817         insn = db_get_value(loc, 4, 0);
818
819         if (insn == 0x01000000) {
820                 db_printf("nop\n");
821                 return loc + 4;
822         }
823
824         while (i_ptr->name) {
825                 /* calculate YOU_LOSE value */
826                 bitmask= (i_ptr->match);
827                 you_lose = (~bitmask);
828
829                 if (((bitmask>>30) & 0x3) == 0x1) {
830                         /* Call */
831                         you_lose = ((~0x1)<<30);
832                 } else if (((bitmask>>30) & 0x3) == 0x0) {
833                         if (((bitmask>>22) & 0x7) == 0x4) {
834                                 /* Sethi */
835                                 you_lose &= (FORMAT2(0x3,0x7));
836                         } else {
837                                 /* Branches */
838                                 you_lose &= (FORMAT2(0x3,0x7) |
839                                     EIF_F2_COND(0xf));
840                         }
841                 } else if (((bitmask>>30) & 0x3) == 0x2 &&
842                            ((bitmask>>19) & 0x3f) == 0x34) /* XXX */ {
843                         /* FPop1 */
844                         you_lose &= (FORMAT3(0x3,0x3f,0x1) |
845                             EIF_F3_OPF(0x1ff));
846                 } else if (((bitmask>>30) & 0x3) == 0x2 &&
847                            ((bitmask>>19) & 0x3f) == 0x3a) /* XXX */ {
848                         /* Tcc */
849                         you_lose &= (FORMAT3(0x3,0x3f,0x1) | EIF_F4_TCOND(0xf));
850                 } else if (((bitmask>>30) & 0x3) == 0x2 &&
851                            ((bitmask>>21) & 0xf) == 0x9 &&
852                            ((bitmask>>19) & 0x3) != 0) /* XXX */ {
853                         /* shifts */
854                         you_lose &= (FORMAT3(0x3,0x3f,0x1)) | EIF_F3_X(1);
855                 } else if (((bitmask>>30) & 0x3) == 0x2 &&
856                            ((bitmask>>19) & 0x3f) == 0x2c) /* XXX */ {
857                         /* cmov */
858                         you_lose &= (FORMAT3(0x3,0x3f,0x1) | COND2(1,0xf));
859                 } else if (((bitmask>>30) & 0x3) == 0x2 &&
860                            ((bitmask>>19) & 0x3f) == 0x35) /* XXX */ {
861                         /* fmov */
862                         you_lose &= (FORMAT3(0x3,0x3f,0x1) | COND2(1,0xf));
863                 } else {
864                         you_lose &= (FORMAT3(0x3,0x3f,0x1));
865                 }
866
867                 if (((bitmask & insn) == bitmask) && ((you_lose & insn) == 0)) {
868                         matchp = 1;
869                         break;
870                 }
871                 i_ptr++;
872         }
873
874         if (!matchp) {
875                 db_printf("undefined\n");
876                 return loc + 4;
877         }
878
879         db_printf("%s", i_ptr->name);
880
881         f_ptr = i_ptr->format;
882
883         for (cp = f_ptr; *cp; cp++) {
884                 if (*cp == ',') {
885                         for (;f_ptr < cp; f_ptr++)
886                                 switch (*f_ptr) {
887                                 case 'a':
888                                         if (insn & EIF_F2_A(1))
889                                                 db_printf(",a");
890                                         break;
891                                 case 'p':
892                                         if (insn & EIF_F2_P(1))
893                                                 db_printf(",pt");
894                                         else
895                                                 db_printf(",pn");
896                                         break;
897                                 }
898                         f_ptr++;
899                         break;
900                 }
901         }
902         db_printf("      \t");
903
904         while (*f_ptr) {
905                 switch (*f_ptr) {
906                         int64_t val;
907                 case '1':
908                         db_printf("%%%s", regs[((insn >> 14) & 0x1f)]);
909                         break;
910                 case '2':
911                         db_printf("%%%s", regs[(insn & 0x1f)]);
912                         break;
913                 case 'd':
914                         db_printf("%%%s", regs[((insn >> 25) & 0x1f)]);
915                         break;
916                 case '3':
917                         db_printf("%%f%d", ((insn >> 14) & 0x1f));
918                         break;
919                 case '4':
920                         db_printf("%%f%d", (insn & 0x1f));
921                         break;
922                 case 'e':
923                         db_printf("%%f%d", ((insn >> 25) & 0x1f));
924                         break;
925                 case 'i':
926                         /* simm13 -- signed */
927                         val = IF_SIMM(insn, 13);
928                         db_printf("%s0x%x", SIGN(val), (int)abs(val));
929                         break;
930                 case 'j':
931                         /* simm11 -- signed */
932                         val = IF_SIMM(insn, 11);
933                         db_printf("%s0x%x", SIGN(val), (int)abs(val));
934                         break;
935                 case 'l':
936                         val = (((insn>>20)&0x3)<<13)|(insn & 0x1fff);
937                         val = IF_SIMM(val, 16);
938                         db_printsym((db_addr_t)(loc + (4 * val)), DB_STGY_ANY);
939                         break;
940                 case 'm':
941                         db_printsym((db_addr_t)(loc + (4 * IF_SIMM(insn, 22))),
942                                 DB_STGY_ANY);
943                         break;
944                 case 'u':
945                         db_printsym((db_addr_t)(loc + (4 * IF_SIMM(insn, 19))),
946                             DB_STGY_ANY);
947                         break;
948                 case 'n':
949                         db_printsym((db_addr_t)(loc + (4 * IF_SIMM(insn, 30))),
950                             DB_STGY_PROC);
951                         break;
952                 case 's':
953                         db_printf("%%asi");
954                         break;
955                 case 't':
956                         db_printf("0x%-2.2x", ((insn >> 5) & 0xff));
957                         break;
958                 case 'o':
959                         db_printf("%%fcc%d", ((insn >> 25) & 0x3));
960                         break;
961                 case 'p':
962                 case '7':
963                         db_printf("[%%%s + %%%s]",
964                                   regs[((insn >> 14) & 0x1f)],
965                                   regs[(insn & 0x1f)]);
966                         if (*f_ptr == '7')
967                                 db_printf(" %d", ((insn >> 5) & 0xff));
968                         break;
969                 case 'q':
970                 case '8':
971                         val = IF_SIMM(insn, 13);
972                         db_printf("[%%%s %c 0x%x]",
973                                 regs[((insn >> 14) & 0x1f)],
974                                 (int)((val<0)?'-':'+'),
975                                 (int)abs(val));
976                         if (*f_ptr == '8')
977                                 db_printf(" %%asi");
978                         break;
979                 case '5':
980                         db_printf("%%fsr");
981                         break;
982                 case '6':
983                         db_printf("%%fsr");
984                         break;
985                 case '9':
986                         db_printf("0x%xl",
987                                   ((insn & 0xf) | ((insn >> 4) & 0x7)));
988                         break;
989                 case '0':
990                         db_printf("%%%s", ccodes[((insn >> 11) & 0x3) + 4]);
991                         break;
992                 case '.':
993                         db_printf("%%%s", ccodes[((insn >> 11) & 0x7)]);
994                         break;
995                 case 'r':
996                         db_printf("#%s", prefetch[((insn >> 25) & 0x1f)]);
997                         break;
998                 case 'A':
999                         db_printf("%%%s", priv_regs[((insn >> 14) & 0x1f)]);
1000                         break;
1001                 case 'B':
1002                         db_printf("%%%s", state_regs[((insn >> 14) & 0x1f)]);
1003                         break;
1004                 case 'C':
1005                         db_printf("%%hi(0x%x)", ((insn & 0x3fffff) << 10));
1006                         break;
1007                 case 'D':
1008                         db_printf("0x%x", (insn & 0x1f));
1009                         break;
1010                 case 'E':
1011                         db_printf("%d", (insn & 0x3f));
1012                         break;
1013                 case 'F':
1014                         db_printf("%d", (insn & 0x3f));
1015                         break;
1016                 case 'G':
1017                         db_printf("%%%s", priv_regs[((insn >> 25) & 0x1f)]);
1018                         break;
1019                 case 'H':
1020                         db_printf("%%%s", state_regs[((insn >> 25) & 0x1f)]);
1021                         break;
1022                 default:
1023                         db_printf("(UNKNOWN)");
1024                         break;
1025                 }
1026                 if (*(++f_ptr))
1027                         db_printf(", ");
1028         }
1029
1030         db_printf("\n");
1031
1032         return (loc + 4);
1033 }