]>
Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* Definitions for opcode table for the sparc. |
2571583a | 2 | Copyright (C) 1989-2017 Free Software Foundation, Inc. |
252b5132 | 3 | |
47b0e7ad NC |
4 | This file is part of GAS, the GNU Assembler, GDB, the GNU debugger, and |
5 | the GNU Binutils. | |
252b5132 | 6 | |
47b0e7ad NC |
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 | |
e4e42b45 | 9 | the Free Software Foundation; either version 3, or (at your option) |
47b0e7ad | 10 | any later version. |
252b5132 | 11 | |
47b0e7ad NC |
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. | |
252b5132 | 16 | |
47b0e7ad | 17 | You should have received a copy of the GNU General Public License |
e4e42b45 | 18 | along with GAS or GDB; see the file COPYING3. If not, write to |
47b0e7ad NC |
19 | the Free Software Foundation, 51 Franklin Street - Fifth Floor, |
20 | Boston, MA 02110-1301, USA. */ | |
252b5132 | 21 | |
b3f7d5fd | 22 | #include "ansidecl.h" |
252b5132 | 23 | |
1fe0971e TS |
24 | #ifdef __cplusplus |
25 | extern "C" { | |
26 | #endif | |
27 | ||
252b5132 RH |
28 | /* The SPARC opcode table (and other related data) is defined in |
29 | the opcodes library in sparc-opc.c. If you change anything here, make | |
30 | sure you fix up that file, and vice versa. */ | |
31 | ||
32 | /* FIXME-someday: perhaps the ,a's and such should be embedded in the | |
33 | instruction's name rather than the args. This would make gas faster, pinsn | |
34 | slower, but would mess up some macros a bit. xoxorich. */ | |
35 | ||
36 | /* List of instruction sets variations. | |
37 | These values are such that each element is either a superset of a | |
38 | preceding each one or they conflict in which case SPARC_OPCODE_CONFLICT_P | |
39 | returns non-zero. | |
40 | The values are indices into `sparc_opcode_archs' defined in sparc-opc.c. | |
41 | Don't change this without updating sparc-opc.c. */ | |
42 | ||
47b0e7ad NC |
43 | enum sparc_opcode_arch_val |
44 | { | |
252b5132 RH |
45 | SPARC_OPCODE_ARCH_V6 = 0, |
46 | SPARC_OPCODE_ARCH_V7, | |
47 | SPARC_OPCODE_ARCH_V8, | |
d6787ef9 | 48 | SPARC_OPCODE_ARCH_LEON, |
252b5132 RH |
49 | SPARC_OPCODE_ARCH_SPARCLET, |
50 | SPARC_OPCODE_ARCH_SPARCLITE, | |
47b0e7ad | 51 | /* V9 variants must appear last. */ |
252b5132 | 52 | SPARC_OPCODE_ARCH_V9, |
47b0e7ad NC |
53 | SPARC_OPCODE_ARCH_V9A, /* V9 with ultrasparc additions. */ |
54 | SPARC_OPCODE_ARCH_V9B, /* V9 with ultrasparc and cheetah additions. */ | |
4f26fb3a JM |
55 | SPARC_OPCODE_ARCH_V9C, /* V9 with UA2005 and T1 additions. */ |
56 | SPARC_OPCODE_ARCH_V9D, /* V9 with UA2007 and T3 additions. */ | |
57 | SPARC_OPCODE_ARCH_V9E, /* V9 with OSA2011 and T4 additions modulus integer multiply-add. */ | |
58 | SPARC_OPCODE_ARCH_V9V, /* V9 with OSA2011 and T4 additions, integer | |
59 | multiply and Fujitsu fp multiply-add. */ | |
60 | SPARC_OPCODE_ARCH_V9M, /* V9 with OSA2015 and M7 additions. */ | |
042c94de | 61 | SPARC_OPCODE_ARCH_MAX = SPARC_OPCODE_ARCH_V9M, |
47b0e7ad | 62 | SPARC_OPCODE_ARCH_BAD /* Error return from sparc_opcode_lookup_arch. */ |
252b5132 RH |
63 | }; |
64 | ||
252b5132 RH |
65 | |
66 | /* Given an enum sparc_opcode_arch_val, return the bitmask to use in | |
67 | insn encoding/decoding. */ | |
68 | #define SPARC_OPCODE_ARCH_MASK(arch) (1 << (arch)) | |
69 | ||
70 | /* Given a valid sparc_opcode_arch_val, return non-zero if it's v9. */ | |
71 | #define SPARC_OPCODE_ARCH_V9_P(arch) ((arch) >= SPARC_OPCODE_ARCH_V9) | |
72 | ||
73 | /* Table of cpu variants. */ | |
74 | ||
47b0e7ad NC |
75 | typedef struct sparc_opcode_arch |
76 | { | |
252b5132 RH |
77 | const char *name; |
78 | /* Mask of sparc_opcode_arch_val's supported. | |
79 | EG: For v7 this would be | |
80 | (SPARC_OPCODE_ARCH_MASK (..._V6) | SPARC_OPCODE_ARCH_MASK (..._V7)). | |
81 | These are short's because sparc_opcode.architecture is. */ | |
82 | short supported; | |
6884417a JM |
83 | /* Bitmaps describing the set of hardware capabilities implemented |
84 | by the opcode arch. */ | |
85 | int hwcaps; | |
86 | int hwcaps2; | |
47b0e7ad | 87 | } sparc_opcode_arch; |
252b5132 RH |
88 | |
89 | extern const struct sparc_opcode_arch sparc_opcode_archs[]; | |
90 | ||
91 | /* Given architecture name, look up it's sparc_opcode_arch_val value. */ | |
8cf3f354 | 92 | extern enum sparc_opcode_arch_val sparc_opcode_lookup_arch (const char *); |
252b5132 RH |
93 | |
94 | /* Return the bitmask of supported architectures for ARCH. */ | |
95 | #define SPARC_OPCODE_SUPPORTED(ARCH) (sparc_opcode_archs[ARCH].supported) | |
96 | ||
97 | /* Non-zero if ARCH1 conflicts with ARCH2. | |
98 | IE: ARCH1 as a supported bit set that ARCH2 doesn't, and vice versa. */ | |
99 | #define SPARC_OPCODE_CONFLICT_P(ARCH1, ARCH2) \ | |
47b0e7ad NC |
100 | (((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \ |
101 | != SPARC_OPCODE_SUPPORTED (ARCH1)) \ | |
102 | && ((SPARC_OPCODE_SUPPORTED (ARCH1) & SPARC_OPCODE_SUPPORTED (ARCH2)) \ | |
252b5132 RH |
103 | != SPARC_OPCODE_SUPPORTED (ARCH2))) |
104 | ||
105 | /* Structure of an opcode table entry. */ | |
106 | ||
47b0e7ad NC |
107 | typedef struct sparc_opcode |
108 | { | |
252b5132 | 109 | const char *name; |
47b0e7ad NC |
110 | unsigned long match; /* Bits that must be set. */ |
111 | unsigned long lose; /* Bits that must not be set. */ | |
252b5132 | 112 | const char *args; |
47b0e7ad | 113 | /* This was called "delayed" in versions before the flags. */ |
9e8c70f9 | 114 | unsigned int flags; |
ec668d69 | 115 | unsigned int hwcaps; |
3d68f91c | 116 | unsigned int hwcaps2; |
252b5132 | 117 | short architecture; /* Bitmask of sparc_opcode_arch_val's. */ |
47b0e7ad NC |
118 | } sparc_opcode; |
119 | ||
1e9d41d4 SL |
120 | /* Struct for ASIs - to handle ASIs introduced in a specific architecture */ |
121 | typedef struct | |
122 | { | |
123 | int value; | |
124 | const char *name; | |
125 | short architecture; | |
126 | } sparc_asi; | |
127 | ||
252b5132 | 128 | /* FIXME: Add F_ANACHRONISTIC flag for v9. */ |
9e8c70f9 DM |
129 | #define F_DELAYED 0x00000001 /* Delayed branch. */ |
130 | #define F_ALIAS 0x00000002 /* Alias for a "real" instruction. */ | |
131 | #define F_UNBR 0x00000004 /* Unconditional branch. */ | |
132 | #define F_CONDBR 0x00000008 /* Conditional branch. */ | |
133 | #define F_JSR 0x00000010 /* Subroutine call. */ | |
134 | #define F_FLOAT 0x00000020 /* Floating point instruction (not a branch). */ | |
135 | #define F_FBR 0x00000040 /* Floating point branch. */ | |
0afd1215 DM |
136 | #define F_PREFERRED 0x00000080 /* A preferred alias. */ |
137 | ||
138 | #define F_PREF_ALIAS (F_ALIAS|F_PREFERRED) | |
ec668d69 | 139 | |
3d68f91c JM |
140 | /* These must match the ELF_SPARC_HWCAP_* and ELF_SPARC_HWCAP2_* |
141 | values precisely. See include/elf/sparc.h. */ | |
ec668d69 DM |
142 | #define HWCAP_MUL32 0x00000001 /* umul/umulcc/smul/smulcc insns */ |
143 | #define HWCAP_DIV32 0x00000002 /* udiv/udivcc/sdiv/sdivcc insns */ | |
144 | #define HWCAP_FSMULD 0x00000004 /* 'fsmuld' insn */ | |
145 | #define HWCAP_V8PLUS 0x00000008 /* v9 insns available to 32bit */ | |
146 | #define HWCAP_POPC 0x00000010 /* 'popc' insn */ | |
147 | #define HWCAP_VIS 0x00000020 /* VIS insns */ | |
148 | #define HWCAP_VIS2 0x00000040 /* VIS2 insns */ | |
149 | #define HWCAP_ASI_BLK_INIT \ | |
150 | 0x00000080 /* block init ASIs */ | |
151 | #define HWCAP_FMAF 0x00000100 /* fused multiply-add */ | |
152 | #define HWCAP_VIS3 0x00000400 /* VIS3 insns */ | |
153 | #define HWCAP_HPC 0x00000800 /* HPC insns */ | |
154 | #define HWCAP_RANDOM 0x00001000 /* 'random' insn */ | |
155 | #define HWCAP_TRANS 0x00002000 /* transaction insns */ | |
156 | #define HWCAP_FJFMAU 0x00004000 /* unfused multiply-add */ | |
157 | #define HWCAP_IMA 0x00008000 /* integer multiply-add */ | |
158 | #define HWCAP_ASI_CACHE_SPARING \ | |
159 | 0x00010000 /* cache sparing ASIs */ | |
160 | #define HWCAP_AES 0x00020000 /* AES crypto insns */ | |
161 | #define HWCAP_DES 0x00040000 /* DES crypto insns */ | |
162 | #define HWCAP_KASUMI 0x00080000 /* KASUMI crypto insns */ | |
163 | #define HWCAP_CAMELLIA 0x00100000 /* CAMELLIA crypto insns */ | |
164 | #define HWCAP_MD5 0x00200000 /* MD5 hashing insns */ | |
165 | #define HWCAP_SHA1 0x00400000 /* SHA1 hashing insns */ | |
166 | #define HWCAP_SHA256 0x00800000 /* SHA256 hashing insns */ | |
167 | #define HWCAP_SHA512 0x01000000 /* SHA512 hashing insns */ | |
168 | #define HWCAP_MPMUL 0x02000000 /* Multiple Precision Multiply */ | |
169 | #define HWCAP_MONT 0x04000000 /* Montgomery Mult/Sqrt */ | |
170 | #define HWCAP_PAUSE 0x08000000 /* Pause insn */ | |
171 | #define HWCAP_CBCOND 0x10000000 /* Compare and Branch insns */ | |
172 | #define HWCAP_CRC32C 0x20000000 /* CRC32C insn */ | |
252b5132 | 173 | |
3d68f91c | 174 | #define HWCAP2_FJATHPLUS 0x00000001 /* Fujitsu Athena+ */ |
0b6be415 | 175 | #define HWCAP2_VIS3B 0x00000002 /* Subset of VIS3 present on sparc64 X+. */ |
3d68f91c JM |
176 | #define HWCAP2_ADP 0x00000004 /* Application Data Protection */ |
177 | #define HWCAP2_SPARC5 0x00000008 /* The 29 new fp and sub instructions */ | |
178 | #define HWCAP2_MWAIT 0x00000010 /* mwait instruction and load/monitor ASIs */ | |
179 | #define HWCAP2_XMPMUL 0x00000020 /* XOR multiple precision multiply */ | |
180 | #define HWCAP2_XMONT 0x00000040 /* XOR Montgomery mult/sqr instructions */ | |
181 | #define HWCAP2_NSEC \ | |
182 | 0x00000080 /* pause insn with support for nsec timings */ | |
183 | #define HWCAP2_FJATHHPC 0x00001000 /* Fujitsu HPC instrs */ | |
184 | #define HWCAP2_FJDES 0x00002000 /* Fujitsu DES instrs */ | |
185 | #define HWCAP2_FJAES 0x00010000 /* Fujitsu AES instrs */ | |
186 | ||
187 | ||
47b0e7ad NC |
188 | /* All sparc opcodes are 32 bits, except for the `set' instruction (really a |
189 | macro), which is 64 bits. It is handled as a special case. | |
252b5132 | 190 | |
47b0e7ad NC |
191 | The match component is a mask saying which bits must match a particular |
192 | opcode in order for an instruction to be an instance of that opcode. | |
252b5132 | 193 | |
47b0e7ad NC |
194 | The args component is a string containing one character for each operand of the |
195 | instruction. | |
252b5132 | 196 | |
47b0e7ad | 197 | Kinds of operands: |
252b5132 RH |
198 | # Number used by optimizer. It is ignored. |
199 | 1 rs1 register. | |
200 | 2 rs2 register. | |
201 | d rd register. | |
202 | e frs1 floating point register. | |
203 | v frs1 floating point register (double/even). | |
204 | V frs1 floating point register (quad/multiple of 4). | |
205 | f frs2 floating point register. | |
206 | B frs2 floating point register (double/even). | |
207 | R frs2 floating point register (quad/multiple of 4). | |
ea783ef3 DM |
208 | 4 frs3 floating point register. |
209 | 5 frs3 floating point register (doube/even). | |
252b5132 RH |
210 | g frsd floating point register. |
211 | H frsd floating point register (double/even). | |
212 | J frsd floating point register (quad/multiple of 4). | |
3d68f91c | 213 | } frsd floating point register (double/even) that is == frs2 |
252b5132 RH |
214 | b crs1 coprocessor register |
215 | c crs2 coprocessor register | |
216 | D crsd coprocessor register | |
217 | m alternate space register (asr) in rd | |
218 | M alternate space register (asr) in rs1 | |
219 | h 22 high bits. | |
220 | X 5 bit unsigned immediate | |
221 | Y 6 bit unsigned immediate | |
19f7b010 | 222 | 3 SIAM mode (3 bits). (v9b) |
252b5132 RH |
223 | K MEMBAR mask (7 bits). (v9) |
224 | j 10 bit Immediate. (v9) | |
225 | I 11 bit Immediate. (v9) | |
226 | i 13 bit Immediate. | |
227 | n 22 bit immediate. | |
228 | k 2+14 bit PC relative immediate. (v9) | |
229 | G 19 bit PC relative immediate. (v9) | |
230 | l 22 bit PC relative immediate. | |
231 | L 30 bit PC relative immediate. | |
232 | a Annul. The annul bit is set. | |
233 | A Alternate address space. Stored as 8 bits. | |
234 | C Coprocessor state register. | |
235 | F floating point state register. | |
236 | p Processor state register. | |
237 | N Branch predict clear ",pn" (v9) | |
238 | T Branch predict set ",pt" (v9) | |
239 | z %icc. (v9) | |
240 | Z %xcc. (v9) | |
241 | q Floating point queue. | |
242 | r Single register that is both rs1 and rd. | |
243 | O Single register that is both rs2 and rd. | |
244 | Q Coprocessor queue. | |
245 | S Special case. | |
246 | t Trap base register. | |
247 | w Window invalid mask register. | |
248 | y Y register. | |
249 | u sparclet coprocessor registers in rd position | |
250 | U sparclet coprocessor registers in rs1 position | |
251 | E %ccr. (v9) | |
252 | s %fprs. (v9) | |
253 | P %pc. (v9) | |
254 | W %tick. (v9) | |
3d68f91c | 255 | { %mcdper. (v9b) |
252b5132 RH |
256 | o %asi. (v9) |
257 | 6 %fcc0. (v9) | |
258 | 7 %fcc1. (v9) | |
259 | 8 %fcc2. (v9) | |
260 | 9 %fcc3. (v9) | |
261 | ! Privileged Register in rd (v9) | |
262 | ? Privileged Register in rs1 (v9) | |
337c570c JM |
263 | % Hyperprivileged Register in rd (v9b) |
264 | $ Hyperprivileged Register in rs1 (v9b) | |
252b5132 RH |
265 | * Prefetch function constant. (v9) |
266 | x OPF field (v9 impdep). | |
267 | 0 32/64 bit immediate for set or setx (v9) insns | |
268 | _ Ancillary state register in rd (v9a) | |
269 | / Ancillary state register in rs1 (v9a) | |
2615994e | 270 | ( entire floating point state register (%efsr) |
6cda1326 | 271 | ) 5 bit immediate placed in RS3 field |
2615994e | 272 | = 2+8 bit PC relative immediate. (v9) */ |
47b0e7ad NC |
273 | |
274 | #define OP2(x) (((x) & 0x7) << 22) /* Op2 field of format2 insns. */ | |
275 | #define OP3(x) (((x) & 0x3f) << 19) /* Op3 field of format3 insns. */ | |
276 | #define OP(x) ((unsigned) ((x) & 0x3) << 30) /* Op field of all insns. */ | |
277 | #define OPF(x) (((x) & 0x1ff) << 5) /* Opf field of float insns. */ | |
278 | #define OPF_LOW5(x) OPF ((x) & 0x1f) /* V9. */ | |
ea783ef3 | 279 | #define OPF_LOW4(x) OPF ((x) & 0xf) /* V9. */ |
47b0e7ad | 280 | #define F3F(x, y, z) (OP (x) | OP3 (y) | OPF (z)) /* Format3 float insns. */ |
2c63854f | 281 | #define F3F4(x, y, z) (OP (x) | OP3 (y) | OPF_LOW4 (z)) |
47b0e7ad NC |
282 | #define F3I(x) (((x) & 0x1) << 13) /* Immediate field of format 3 insns. */ |
283 | #define F2(x, y) (OP (x) | OP2(y)) /* Format 2 insns. */ | |
284 | #define F3(x, y, z) (OP (x) | OP3(y) | F3I(z)) /* Format3 insns. */ | |
285 | #define F1(x) (OP (x)) | |
286 | #define DISP30(x) ((x) & 0x3fffffff) | |
287 | #define ASI(x) (((x) & 0xff) << 5) /* Asi field of format3 insns. */ | |
288 | #define RS2(x) ((x) & 0x1f) /* Rs2 field. */ | |
289 | #define SIMM13(x) ((x) & 0x1fff) /* Simm13 field. */ | |
290 | #define RD(x) (((x) & 0x1f) << 25) /* Destination register field. */ | |
291 | #define RS1(x) (((x) & 0x1f) << 14) /* Rs1 field. */ | |
ea783ef3 | 292 | #define RS3(x) (((x) & 0x1f) << 9) /* Rs3 field. */ |
47b0e7ad NC |
293 | #define ASI_RS2(x) (SIMM13 (x)) |
294 | #define MEMBAR(x) ((x) & 0x7f) | |
295 | #define SLCPOP(x) (((x) & 0x7f) << 6) /* Sparclet cpop. */ | |
296 | ||
297 | #define ANNUL (1 << 29) | |
298 | #define BPRED (1 << 19) /* V9. */ | |
299 | #define IMMED F3I (1) | |
300 | #define RD_G0 RD (~0) | |
301 | #define RS1_G0 RS1 (~0) | |
302 | #define RS2_G0 RS2 (~0) | |
252b5132 RH |
303 | |
304 | extern const struct sparc_opcode sparc_opcodes[]; | |
305 | extern const int sparc_num_opcodes; | |
306 | ||
1e9d41d4 | 307 | extern const sparc_asi *sparc_encode_asi (const char *); |
8cf3f354 AM |
308 | extern const char *sparc_decode_asi (int); |
309 | extern int sparc_encode_membar (const char *); | |
310 | extern const char *sparc_decode_membar (int); | |
311 | extern int sparc_encode_prefetch (const char *); | |
312 | extern const char *sparc_decode_prefetch (int); | |
313 | extern int sparc_encode_sparclet_cpreg (const char *); | |
314 | extern const char *sparc_decode_sparclet_cpreg (int); | |
252b5132 | 315 | |
47b0e7ad NC |
316 | /* Local Variables: |
317 | fill-column: 131 | |
318 | comment-column: 0 | |
319 | End: */ | |
252b5132 | 320 | |
1fe0971e TS |
321 | #ifdef __cplusplus |
322 | } | |
323 | #endif |