]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blob - include/opcode/sparc.h
* sparc.h (SPARC_OPCODE_ARCH_MASK): New macro.
[thirdparty/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 each 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_SPARCLET,
42 SPARC_OPCODE_ARCH_SPARCLITE,
43 /* v9 variants must appear last */
44 SPARC_OPCODE_ARCH_V9,
45 SPARC_OPCODE_ARCH_V9A, /* v9 with ultrasparc additions */
46 SPARC_OPCODE_ARCH_BAD /* error return from sparc_opcode_lookup_arch */
47 };
48
49 /* The highest architecture in the table. */
50 #define SPARC_OPCODE_ARCH_MAX (SPARC_OPCODE_ARCH_BAD - 1)
51
52 /* Given an enum sparc_opcode_arch_val, return the bitmask to use in
53 insn encoding/decoding. */
54 #define SPARC_OPCODE_ARCH_MASK(arch) (1 << (arch))
55
56 /* Table of cpu variants. */
57
58 struct sparc_opcode_arch {
59 const char *name;
60 /* Mask of sparc_opcode_arch_val's supported.
61 EG: For v7 this would be
62 (SPARC_OPCODE_ARCH_MASK (..._V6) | SPARC_OPCODE_ARCH_MASK (..._V7)).
63 These are short's because sparc_opcode.architecture is. */
64 short supported;
65 };
66
67 extern const struct sparc_opcode_arch sparc_opcode_archs[];
68
69 /* Given architecture name, look up it's sparc_opcode_arch_val value. */
70 extern enum sparc_opcode_arch_val sparc_opcode_lookup_arch ();
71
72 /* Return the bitmask of supported architectures for ARCH. */
73 #define SPARC_OPCODE_SUPPORTED(ARCH) (sparc_opcode_archs[ARCH].supported)
74
75 /* Non-zero if ARCH1 conflicts with ARCH2.
76 IE: ARCH1 as a supported bit set that ARCH2 doesn't, and vice versa. */
77 #define SPARC_OPCODE_CONFLICT_P(ARCH1, ARCH2) \
78 (((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \
79 != SPARC_OPCODE_SUPPORTED (ARCH1)) \
80 && ((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \
81 != SPARC_OPCODE_SUPPORTED (ARCH2)))
82
83 /* Structure of an opcode table entry. */
84
85 struct sparc_opcode {
86 const char *name;
87 unsigned long match; /* Bits that must be set. */
88 unsigned long lose; /* Bits that must not be set. */
89 const char *args;
90 /* This was called "delayed" in versions before the flags. */
91 char flags;
92 short architecture; /* Bitmask of sparc_opcode_arch_val's. */
93 };
94
95 #define F_DELAYED 1 /* Delayed branch */
96 #define F_ALIAS 2 /* Alias for a "real" instruction */
97 #define F_UNBR 4 /* Unconditional branch */
98 #define F_CONDBR 8 /* Conditional branch */
99 #define F_JSR 16 /* Subroutine call */
100 /* FIXME: Add F_ANACHRONISTIC flag for v9. */
101
102 /*
103
104 All sparc opcodes are 32 bits, except for the `set' instruction (really a
105 macro), which is 64 bits. It is handled as a special case.
106
107 The match component is a mask saying which bits must match a particular
108 opcode in order for an instruction to be an instance of that opcode.
109
110 The args component is a string containing one character for each operand of the
111 instruction.
112
113 Kinds of operands:
114 # Number used by optimizer. It is ignored.
115 1 rs1 register.
116 2 rs2 register.
117 d rd register.
118 e frs1 floating point register.
119 v frs1 floating point register (double/even).
120 V frs1 floating point register (quad/multiple of 4).
121 f frs2 floating point register.
122 B frs2 floating point register (double/even).
123 R frs2 floating point register (quad/multiple of 4).
124 g frsd floating point register.
125 H frsd floating point register (double/even).
126 J frsd floating point register (quad/multiple of 4).
127 b crs1 coprocessor register
128 c crs2 coprocessor register
129 D crsd coprocessor register
130 m alternate space register (asr) in rd
131 M alternate space register (asr) in rs1
132 h 22 high bits.
133 K MEMBAR mask (7 bits). (v9)
134 j 10 bit Immediate. (v9)
135 I 11 bit Immediate. (v9)
136 i 13 bit Immediate.
137 n 22 bit immediate.
138 k 2+14 bit PC relative immediate. (v9)
139 G 19 bit PC relative immediate. (v9)
140 l 22 bit PC relative immediate.
141 L 30 bit PC relative immediate.
142 a Annul. The annul bit is set.
143 A Alternate address space. Stored as 8 bits.
144 C Coprocessor state register.
145 F floating point state register.
146 p Processor state register.
147 N Branch predict clear ",pn" (v9)
148 T Branch predict set ",pt" (v9)
149 z %icc. (v9)
150 Z %xcc. (v9)
151 q Floating point queue.
152 r Single register that is both rs1 and rd.
153 O Single register that is both rs2 and rd.
154 Q Coprocessor queue.
155 S Special case.
156 t Trap base register.
157 w Window invalid mask register.
158 y Y register.
159 u sparclet coprocessor registers in rd position
160 U sparclet coprocessor registers in rs1 position
161 E %ccr. (v9)
162 s %fprs. (v9)
163 P %pc. (v9)
164 W %tick. (v9)
165 o %asi. (v9)
166 6 %fcc0. (v9)
167 7 %fcc1. (v9)
168 8 %fcc2. (v9)
169 9 %fcc3. (v9)
170 ! Privileged Register in rd (v9)
171 ? Privileged Register in rs1 (v9)
172 * Prefetch function constant. (v9)
173 x OPF field (v9 impdep).
174
175 The following chars are unused: (note: ,[] are used as punctuation)
176 [XY3450]
177
178 */
179
180 #define OP2(x) (((x)&0x7) << 22) /* op2 field of format2 insns */
181 #define OP3(x) (((x)&0x3f) << 19) /* op3 field of format3 insns */
182 #define OP(x) ((unsigned)((x)&0x3) << 30) /* op field of all insns */
183 #define OPF(x) (((x)&0x1ff) << 5) /* opf field of float insns */
184 #define OPF_LOW5(x) OPF((x)&0x1f) /* v9 */
185 #define F3F(x, y, z) (OP(x) | OP3(y) | OPF(z)) /* format3 float insns */
186 #define F3I(x) (((x)&0x1) << 13) /* immediate field of format 3 insns */
187 #define F2(x, y) (OP(x) | OP2(y)) /* format 2 insns */
188 #define F3(x, y, z) (OP(x) | OP3(y) | F3I(z)) /* format3 insns */
189 #define F1(x) (OP(x))
190 #define DISP30(x) ((x)&0x3fffffff)
191 #define ASI(x) (((x)&0xff) << 5) /* asi field of format3 insns */
192 #define RS2(x) ((x)&0x1f) /* rs2 field */
193 #define SIMM13(x) ((x)&0x1fff) /* simm13 field */
194 #define RD(x) (((x)&0x1f) << 25) /* destination register field */
195 #define RS1(x) (((x)&0x1f) << 14) /* rs1 field */
196 #define ASI_RS2(x) (SIMM13(x))
197 #define MEMBAR(x) ((x)&0x7f)
198
199 #define ANNUL (1<<29)
200 #define BPRED (1<<19) /* v9 */
201 #define IMMED F3I(1)
202 #define RD_G0 RD(~0)
203 #define RS1_G0 RS1(~0)
204 #define RS2_G0 RS2(~0)
205
206 extern struct sparc_opcode sparc_opcodes[];
207 extern const int sparc_num_opcodes;
208
209 int sparc_encode_asi ();
210 char *sparc_decode_asi ();
211 int sparc_encode_membar ();
212 char *sparc_decode_membar ();
213 int sparc_encode_prefetch ();
214 char *sparc_decode_prefetch ();
215 int sparc_encode_sparclet_cpreg ();
216 char *sparc_decode_sparclet_cpreg ();
217
218 /*
219 * Local Variables:
220 * fill-column: 131
221 * comment-column: 0
222 * End:
223 */
224
225 /* end of sparc.h */