* sparc.h (enum sparc_opcode_arch_val): Replaces sparc_architecture.
[binutils-gdb.git] / include / opcode / sparc.h
1 /* Definitions for opcode table for the sparc.
2 Copyright (C) 1989, 1991, 1992, 1995, 1996 Free Software Foundation, Inc.
3
4 This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and
5 the GNU Binutils.
6
7 GAS/GDB is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2, or (at your option)
10 any later version.
11
12 GAS/GDB is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with GAS or GDB; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 /* The SPARC opcode table (and other related data) is defined in
23 the opcodes library in sparc-opc.c. If you change anything here, make
24 sure you fix up that file, and vice versa. */
25
26 /* FIXME-someday: perhaps the ,a's and such should be embedded in the
27 instruction's name rather than the args. This would make gas faster, pinsn
28 slower, but would mess up some macros a bit. xoxorich. */
29
30 /* List of instruction sets variations.
31 These values are such that each element is either a superset of a
32 preceding one or they conflict in which case SPARC_OPCODE_CONFLICT_P
33 returns non-zero.
34 The values are indices into `sparc_opcode_archs' defined in sparc-opc.c.
35 Don't change this without updating sparc-opc.c. */
36
37 enum sparc_opcode_arch_val {
38 SPARC_OPCODE_ARCH_V6 = 0,
39 SPARC_OPCODE_ARCH_V7,
40 SPARC_OPCODE_ARCH_V8,
41 SPARC_OPCODE_ARCH_SPARCLITE,
42 /* v9 variants must appear last */
43 SPARC_OPCODE_ARCH_V9,
44 SPARC_OPCODE_ARCH_V9A, /* v9 with ultrasparc additions */
45 SPARC_OPCODE_ARCH_BAD /* error return from sparc_opcode_lookup_arch */
46 };
47
48 /* The highest architecture in the table. */
49 #define SPARC_OPCODE_ARCH_MAX (SPARC_OPCODE_ARCH_BAD - 1)
50
51 /* Table of cpu variants. */
52
53 struct sparc_opcode_arch {
54 const char *name;
55 int conflicts;
56 };
57
58 extern const struct sparc_opcode_arch sparc_opcode_archs[];
59
60 extern enum sparc_opcode_arch_val sparc_opcode_lookup_arch ();
61
62 /* Non-zero if ARCH1 conflicts with ARCH2. */
63
64 #define SPARC_OPCODE_CONFLICT_P(ARCH1, ARCH2) \
65 ((1 << (ARCH1)) & sparc_opcode_archs[ARCH2].conflicts)
66
67 /* Structure of an opcode table entry. */
68
69 struct sparc_opcode {
70 const char *name;
71 unsigned long match; /* Bits that must be set. */
72 unsigned long lose; /* Bits that must not be set. */
73 const char *args;
74 /* This was called "delayed" in versions before the flags. */
75 char flags;
76 enum sparc_opcode_arch_val architecture;
77 };
78
79 #define F_DELAYED 1 /* Delayed branch */
80 #define F_ALIAS 2 /* Alias for a "real" instruction */
81 #define F_UNBR 4 /* Unconditional branch */
82 #define F_CONDBR 8 /* Conditional branch */
83 #define F_JSR 16 /* Subroutine call */
84 /* ??? One can argue this shouldn't be here and the architecture
85 field should be used instead. */
86 #define F_NOTV9 32 /* Doesn't exist in v9 */
87 /* FIXME: Add F_ANACHRONISTIC flag for v9. */
88
89 /*
90
91 All sparc opcodes are 32 bits, except for the `set' instruction (really a
92 macro), which is 64 bits. It is handled as a special case.
93
94 The match component is a mask saying which bits must match a particular
95 opcode in order for an instruction to be an instance of that opcode.
96
97 The args component is a string containing one character for each operand of the
98 instruction.
99
100 Kinds of operands:
101 # Number used by optimizer. It is ignored.
102 1 rs1 register.
103 2 rs2 register.
104 d rd register.
105 e frs1 floating point register.
106 v frs1 floating point register (double/even).
107 V frs1 floating point register (quad/multiple of 4).
108 f frs2 floating point register.
109 B frs2 floating point register (double/even).
110 R frs2 floating point register (quad/multiple of 4).
111 g frsd floating point register.
112 H frsd floating point register (double/even).
113 J frsd floating point register (quad/multiple of 4).
114 b crs1 coprocessor register
115 c crs2 coprocessor register
116 D crsd coprocessor register
117 m alternate space register (asr) in rd
118 M alternate space register (asr) in rs1
119 h 22 high bits.
120 K MEMBAR mask (7 bits). (v9)
121 j 10 bit Immediate. (v9)
122 I 11 bit Immediate. (v9)
123 i 13 bit Immediate.
124 n 22 bit immediate.
125 k 2+14 bit PC relative immediate. (v9)
126 G 19 bit PC relative immediate. (v9)
127 l 22 bit PC relative immediate.
128 L 30 bit PC relative immediate.
129 a Annul. The annul bit is set.
130 A Alternate address space. Stored as 8 bits.
131 C Coprocessor state register.
132 F floating point state register.
133 p Processor state register.
134 N Branch predict clear ",pn" (v9)
135 T Branch predict set ",pt" (v9)
136 z %icc. (v9)
137 Z %xcc. (v9)
138 q Floating point queue.
139 r Single register that is both rs1 and rsd.
140 Q Coprocessor queue.
141 S Special case.
142 t Trap base register.
143 w Window invalid mask register.
144 y Y register.
145 E %ccr. (v9)
146 s %fprs. (v9)
147 P %pc. (v9)
148 W %tick. (v9)
149 o %asi. (v9)
150 6 %fcc0. (v9)
151 7 %fcc1. (v9)
152 8 %fcc2. (v9)
153 9 %fcc3. (v9)
154 ! Privileged Register in rd (v9)
155 ? Privileged Register in rs1 (v9)
156 * Prefetch function constant. (v9)
157 x OPF field (v9 impdep).
158
159 The following chars are unused: (note: ,[] are used as punctuation)
160 [uOUXY3450]
161
162 */
163
164 #define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */
165 #define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */
166 #define OP(x) ((unsigned)((x)&0x3) << 30) /* op field of all insns */
167 #define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */
168 #define OPF_LOW5(x) OPF((x)&0x1f) /* v9 */
169 #define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */
170 #define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */
171 #define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */
172 #define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */
173 #define F1(x) (OP(x))
174 #define DISP30(x) ((x)&0x3fffffff)
175 #define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */
176 #define RS2(x) ((x)&0x1f) /* rs2 field */
177 #define SIMM13(x) ((x)&0x1fff) /* simm13 field */
178 #define RD(x) (((x)&0x1f) << 25) /* destination register field */
179 #define RS1(x) (((x)&0x1f) << 14) /* rs1 field */
180 #define ASI_RS2(x) (SIMM13(x))
181 #define MEMBAR(x) ((x)&0x7f)
182
183 #define ANNUL (1<<29)
184 #define BPRED (1<<19) /* v9 */
185 #define IMMED F3I(1)
186 #define RD_G0 RD(~0)
187 #define RS1_G0 RS1(~0)
188 #define RS2_G0 RS2(~0)
189
190 extern struct sparc_opcode sparc_opcodes[];
191 extern const int sparc_num_opcodes;
192
193 int sparc_encode_asi ();
194 char *sparc_decode_asi ();
195 int sparc_encode_membar ();
196 char *sparc_decode_membar ();
197 int sparc_encode_prefetch ();
198 char *sparc_decode_prefetch ();
199
200 /*
201 * Local Variables:
202 * fill-column: 131
203 * comment-column: 0
204 * End:
205 */
206
207 /* end of sparc.h */