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