fpu_instr.h revision 330897
1/*	$NetBSD: instr.h,v 1.4 2005/12/11 12:18:43 christos Exp $ */
2/* $FreeBSD: stable/11/sys/powerpc/fpu/fpu_instr.h 330897 2018-03-14 03:19:51Z eadler $ */
3
4/*-
5 * SPDX-License-Identifier: BSD-3-Clause
6 *
7 * Copyright (c) 1992, 1993
8 *	The Regents of the University of California.  All rights reserved.
9 *
10 * This software was developed by the Computer Systems Engineering group
11 * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
12 * contributed to Berkeley.
13 *
14 * All advertising materials mentioning features or use of this software
15 * must display the following acknowledgement:
16 *	This product includes software developed by the University of
17 *	California, Lawrence Berkeley Laboratory.
18 *
19 * Redistribution and use in source and binary forms, with or without
20 * modification, are permitted provided that the following conditions
21 * are met:
22 * 1. Redistributions of source code must retain the above copyright
23 *    notice, this list of conditions and the following disclaimer.
24 * 2. Redistributions in binary form must reproduce the above copyright
25 *    notice, this list of conditions and the following disclaimer in the
26 *    documentation and/or other materials provided with the distribution.
27 * 3. Neither the name of the University nor the names of its contributors
28 *    may be used to endorse or promote products derived from this software
29 *    without specific prior written permission.
30 *
31 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
32 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
33 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
34 * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
35 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
36 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
37 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
38 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
39 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
40 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
41 * SUCH DAMAGE.
42 *
43 *	@(#)instr.h	8.1 (Berkeley) 6/11/93
44 */
45
46/*
47 * An instruction.
48 */
49union instr {
50	int	i_int;			/* as a whole */
51
52	/*
53	 * Any instruction type.
54	 */
55	struct {
56		u_int	i_opcd:6;	/* first-level decode */
57		u_int	:25;
58		u_int	i_rc:1;
59	} i_any;
60
61	/*
62	 * Format A
63	 */
64	struct {
65		u_int	i_opcd:6;
66		u_int	i_frt:5;
67		u_int	i_fra:5;
68		u_int	i_frb:5;
69		u_int	i_frc:5;
70		u_int	i_xo:5;
71		u_int	i_rc:1;
72	} i_a;
73
74	/*
75	 * Format B
76	 */
77	struct {
78		u_int	i_opcd:6;
79		int	i_bo:5;
80		int	i_bi:5;
81		int	i_bd:14;
82		int	i_aa:1;
83		int	i_lk:1;
84	} i_b;
85
86	/*
87	 * Format D
88	 */
89	struct {
90		u_int	i_opcd:6;
91		u_int	i_rs:5;
92		u_int	i_ra:5;
93		int	i_d:16;
94	} i_d;
95
96	/*
97	 * Format DE
98	 */
99	struct {
100		u_int	i_opcd:6;
101		u_int	i_rs:5;
102		u_int	i_ra:5;
103		int	i_d:12;
104		u_int	i_xo:4;
105	} i_de;
106
107	/*
108	 * Format I
109	 */
110	struct {
111		u_int	i_opcd:6;
112		int	i_li:24;
113		int	i_aa:1;
114		int	i_lk:1;
115	} i_i;
116
117	/*
118	 * Format M
119	 */
120	struct {
121		u_int	i_opcd:6;
122		u_int	i_rs:5;
123		u_int	i_ra:5;
124		u_int	i_rb:5;
125		int	i_mb:5;
126		int	i_me:5;
127		u_int	i_rc:1;
128	} i_m;
129
130	/*
131	 * Format MD
132	 */
133	struct {
134		u_int	i_opcd:6;
135		u_int	i_rs:5;
136		u_int	i_ra:5;
137		u_int	i_rb:5;
138		int	i_sh1_5:5;
139		int	i_mb:6;
140		u_int	i_xo:3;
141		int	i_sh0:2;
142		u_int	i_rc:1;
143	} i_md;
144
145	/*
146	 * Format MDS
147	 */
148	struct {
149		u_int	i_opcd:6;
150		u_int	i_rs:5;
151		u_int	i_ra:5;
152		u_int	i_rb:5;
153		int	i_sh:5;
154		int	i_mb:6;
155		u_int	i_xo:4;
156		u_int	i_rc:1;
157	} i_mds;
158
159
160	/*
161	 * Format S
162	 */
163	struct {
164		u_int	i_opcd:6;
165		int	:24;
166		int	i_i:1;
167		int	:1;
168	} i_s;
169
170	/*
171	 * Format X
172	 */
173	struct {
174		u_int	i_opcd:6;
175		u_int	i_rs:5;
176		u_int	i_ra:5;
177		u_int	i_rb:5;
178		u_int	i_xo:10;
179		u_int	i_rc:1;
180	} i_x;
181
182	/*
183	 * Format XFL
184	 */
185	struct {
186		u_int	i_opcd:6;
187		int	:1;
188		int	i_flm:8;
189		int	:1;
190		int	i_frb:5;
191		u_int	i_xo:10;
192		int	:1;
193	} i_xfl;
194
195	/*
196	 * Format XFX
197	 */
198	struct {
199		u_int	i_opcd:6;
200		int	i_dcrn:10;
201		u_int	i_xo:10;
202		int	:1;
203	} i_xfx;
204
205	/*
206	 * Format XL
207	 */
208	struct {
209		u_int	i_opcd:6;
210		int	i_bt:5;
211		int	i_ba:5;
212		int	i_bb:5;
213		u_int	i_xo:10;
214		int	i_lk:1;
215	} i_xl;
216
217	/*
218	 * Format XS
219	 */
220	struct {
221		u_int	i_opcd:6;
222		u_int	i_rs:5;
223		u_int	i_ra:5;
224		int	i_sh0_4:5;
225		u_int	i_xo:9;
226		int	i_sh5:1;
227		u_int	i_rc:1;
228	} i_xs;
229
230};
231
232#define	i_rt	i_rs
233
234/*
235 * Primary opcode numbers:
236 */
237
238#define	OPC_TDI		0x02
239#define	OPC_TWI		0x03
240#define	OPC_MULLI	0x07
241#define	OPC_SUBFIC	0x08
242#define	OPC_BCE		0x09
243#define	OPC_CMPLI	0x0a
244#define	OPC_CMPI	0x0b
245#define	OPC_ADDIC	0x0c
246#define	OPC_ADDIC_DOT	0x0d
247#define	OPC_ADDI	0x0e
248#define	OPC_ADDIS	0x0f
249#define	OPC_BC		0x10
250#define	OPC_SC		0x11
251#define	OPC_B		0x12
252#define	OPC_branch_19	0x13
253#define	OPC_RLWIMI	0x14
254#define	OPC_RLWINM	0x15
255#define	OPC_BE		0x16
256#define	OPC_RLWNM	0x17
257#define	OPC_ORI		0x18
258#define	OPC_ORIS	0x19
259#define	OPC_XORI	0x1a
260#define	OPC_XORIS	0x1b
261#define	OPC_ANDI	0x1c
262#define	OPC_ANDIS	0x1d
263#define	OPC_dwe_rot_30	0x1e
264#define	OPC_integer_31	0x1f
265#define	OPC_LWZ		0x20
266#define	OPC_LWZU	0x21
267#define	OPC_LBZ		0x22
268#define	OPC_LBZU	0x23
269#define	OPC_STW		0x24
270#define	OPC_STWU	0x25
271#define	OPC_STB		0x26
272#define	OPC_STBU	0x27
273#define	OPC_LHZ		0x28
274#define	OPC_LHZU	0x29
275#define	OPC_LHA		0x2a
276#define	OPC_LHAU	0x2b
277#define	OPC_STH		0x2c
278#define	OPC_STHU	0x2d
279#define	OPC_LMW		0x2e
280#define	OPC_STMW	0x2f
281#define	OPC_LFS		0x30
282#define	OPC_LFSU	0x31
283#define	OPC_LFD		0x32
284#define	OPC_LFDU	0x33
285#define	OPC_STFS	0x34
286#define	OPC_STFSU	0x35
287#define	OPC_STFD	0x36
288#define	OPC_STFDU	0x37
289#define	OPC_load_st_58	0x3a
290#define	OPC_sp_fp_59	0x3b
291#define	OPC_load_st_62	0x3e
292#define	OPC_dp_fp_63	0x3f
293
294/*
295 * Opcode 31 sub-types (FP only)
296 */
297#define	OPC31_TW	0x004
298#define	OPC31_LFSX	0x217
299#define	OPC31_LFSUX	0x237
300#define	OPC31_LFDX	0x257
301#define	OPC31_LFDUX	0x277
302#define	OPC31_STFSX	0x297
303#define	OPC31_STFSUX	0x2b7
304#define	OPC31_STFDX	0x2d7
305#define	OPC31_STFDUX	0x2f7
306#define	OPC31_STFIWX	0x3d7
307
308/* Mask for all valid indexed FP load/store ops (except stfiwx) */
309#define	OPC31_FPMASK	0x31f
310#define	OPC31_FPOP	0x217
311
312/*
313 * Opcode 59 sub-types:
314 */
315
316#define	OPC59_FDIVS	0x12
317#define	OPC59_FSUBS	0x14
318#define	OPC59_FADDS	0x15
319#define	OPC59_FSQRTS	0x16
320#define	OPC59_FRES	0x18
321#define	OPC59_FMULS	0x19
322#define	OPC59_FMSUBS	0x1c
323#define	OPC59_FMADDS	0x1d
324#define	OPC59_FNMSUBS	0x1e
325#define	OPC59_FNMADDS	0x1f
326
327/*
328 * Opcode 62 sub-types:
329 */
330#define	OPC62_LDE	0x0
331#define	OPC62_LDEU	0x1
332#define	OPC62_LFSE	0x4
333#define	OPC62_LFSEU	0x5
334#define	OPC62_LFDE	0x6
335#define	OPC62_LFDEU	0x7
336#define	OPC62_STDE	0x8
337#define	OPC62_STDEU	0x9
338#define	OPC62_STFSE	0xc
339#define	OPC62_STFSEU	0xd
340#define	OPC62_STFDE	0xe
341#define	OPC62_STFDEU	0xf
342
343/*
344 * Opcode 63 sub-types:
345 *
346 * (The first group are masks....)
347 */
348
349#define	OPC63M_MASK	0x10
350#define	OPC63M_FDIV	0x12
351#define	OPC63M_FSUB	0x14
352#define	OPC63M_FADD	0x15
353#define	OPC63M_FSQRT	0x16
354#define	OPC63M_FSEL	0x17
355#define	OPC63M_FMUL	0x19
356#define	OPC63M_FRSQRTE	0x1a
357#define	OPC63M_FMSUB	0x1c
358#define	OPC63M_FMADD	0x1d
359#define	OPC63M_FNMSUB	0x1e
360#define	OPC63M_FNMADD	0x1f
361
362#define	OPC63_FCMPU	0x00
363#define	OPC63_FRSP	0x0c
364#define	OPC63_FCTIW	0x0e
365#define	OPC63_FCTIWZ	0x0f
366#define	OPC63_FCMPO	0x20
367#define	OPC63_MTFSB1	0x26
368#define	OPC63_FNEG	0x28
369#define	OPC63_MCRFS	0x40
370#define	OPC63_MTFSB0	0x46
371#define	OPC63_FMR	0x48
372#define	OPC63_MTFSFI	0x86
373#define	OPC63_FNABS	0x88
374#define	OPC63_FABS	0x108
375#define	OPC63_MFFS	0x247
376#define	OPC63_MTFSF	0x2c7
377#define	OPC63_FCTID	0x32e
378#define	OPC63_FCTIDZ	0x32f
379#define	OPC63_FCFID	0x34e
380
381/*
382 * FPU data types.
383 */
384#define FTYPE_LNG	-1	/* data = 64-bit signed long integer */
385#define	FTYPE_INT	0	/* data = 32-bit signed integer */
386#define	FTYPE_SNG	1	/* data = 32-bit float */
387#define	FTYPE_DBL	2	/* data = 64-bit double */
388
389