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