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