Home | History | Annotate | Line # | Download | only in include
instr.h revision 1.4.14.1
      1  1.4.14.1    bouyer /*	$NetBSD: instr.h,v 1.4.14.1 2000/11/20 20:25:39 bouyer Exp $ */
      2       1.2   deraadt 
      3       1.1   deraadt /*
      4       1.1   deraadt  * Copyright (c) 1992, 1993
      5       1.1   deraadt  *	The Regents of the University of California.  All rights reserved.
      6       1.1   deraadt  *
      7       1.1   deraadt  * This software was developed by the Computer Systems Engineering group
      8       1.1   deraadt  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9       1.1   deraadt  * contributed to Berkeley.
     10       1.1   deraadt  *
     11       1.1   deraadt  * All advertising materials mentioning features or use of this software
     12       1.1   deraadt  * must display the following acknowledgement:
     13       1.1   deraadt  *	This product includes software developed by the University of
     14       1.1   deraadt  *	California, Lawrence Berkeley Laboratory.
     15       1.1   deraadt  *
     16       1.1   deraadt  * Redistribution and use in source and binary forms, with or without
     17       1.1   deraadt  * modification, are permitted provided that the following conditions
     18       1.1   deraadt  * are met:
     19       1.1   deraadt  * 1. Redistributions of source code must retain the above copyright
     20       1.1   deraadt  *    notice, this list of conditions and the following disclaimer.
     21       1.1   deraadt  * 2. Redistributions in binary form must reproduce the above copyright
     22       1.1   deraadt  *    notice, this list of conditions and the following disclaimer in the
     23       1.1   deraadt  *    documentation and/or other materials provided with the distribution.
     24       1.1   deraadt  * 3. All advertising materials mentioning features or use of this software
     25       1.1   deraadt  *    must display the following acknowledgement:
     26       1.1   deraadt  *	This product includes software developed by the University of
     27       1.1   deraadt  *	California, Berkeley and its contributors.
     28       1.1   deraadt  * 4. Neither the name of the University nor the names of its contributors
     29       1.1   deraadt  *    may be used to endorse or promote products derived from this software
     30       1.1   deraadt  *    without specific prior written permission.
     31       1.1   deraadt  *
     32       1.1   deraadt  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     33       1.1   deraadt  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     34       1.1   deraadt  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     35       1.1   deraadt  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     36       1.1   deraadt  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     37       1.1   deraadt  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     38       1.1   deraadt  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     39       1.1   deraadt  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     40       1.1   deraadt  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     41       1.1   deraadt  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     42       1.1   deraadt  * SUCH DAMAGE.
     43       1.1   deraadt  *
     44       1.1   deraadt  *	@(#)instr.h	8.1 (Berkeley) 6/11/93
     45       1.1   deraadt  */
     46       1.1   deraadt 
     47       1.1   deraadt /* see also Appendix F of the SPARC version 8 document */
     48       1.1   deraadt enum IOP { IOP_OP2, IOP_CALL, IOP_reg, IOP_mem };
     49       1.4        pk enum IOP2 { IOP2_UNIMP, IOP2_BPcc, IOP2_Bicc, IOP2_BPr,
     50       1.4        pk 	IOP2_SETHI, IOP2_FBPfcc, IOP2_FBfcc, IOP2_CBccc };
     51       1.1   deraadt enum IOP3_reg {
     52       1.1   deraadt 	IOP3_ADD, IOP3_AND, IOP3_OR, IOP3_XOR,
     53       1.1   deraadt 	IOP3_SUB, IOP3_ANDN, IOP3_ORN, IOP3_XNOR,
     54       1.1   deraadt 	IOP3_ADDX, IOP3_rerr09, IOP3_UMUL, IOP3_SMUL,
     55       1.1   deraadt 	IOP3_SUBX, IOP3_rerr0d, IOP3_UDIV, IOP3_SDIV,
     56       1.1   deraadt 	IOP3_ADDcc, IOP3_ANDcc, IOP3_ORcc, IOP3_XORcc,
     57       1.1   deraadt 	IOP3_SUBcc, IOP3_ANDNcc, IOP3_ORNcc, IOP3_XNORcc,
     58       1.1   deraadt 	IOP3_ADDXcc, IOP3_rerr19, IOP3_UMULcc, IOP3_SMULcc,
     59       1.1   deraadt 	IOP3_SUBXcc, IOP3_rerr1d, IOP3_UDIVcc, IOP3_SDIVcc,
     60       1.1   deraadt 	IOP3_TADDcc, IOP3_TSUBcc, IOP3_TADDccTV, IOP3_TSUBccTV,
     61       1.1   deraadt 	IOP3_MULScc, IOP3_SLL, IOP3_SRL, IOP3_SRA,
     62       1.1   deraadt 	IOP3_RDASR_RDY_STBAR, IOP3_RDPSR, IOP3_RDWIM, IOP3_RDTGBR,
     63       1.1   deraadt 	IOP3_rerr2c, IOP3_rerr2d, IOP3_rerr2e, IOP3_rerr2f,
     64       1.1   deraadt 	IOP3_WRASR_WRY, IOP3_WRPSR, IOP3_WRWIM, IOP3_WRTBR,
     65       1.1   deraadt 	IOP3_FPop1, IOP3_FPop2, IOP3_CPop1, IOP3_CPop2,
     66       1.1   deraadt 	IOP3_JMPL, IOP3_RETT, IOP3_Ticc, IOP3_FLUSH,
     67       1.1   deraadt 	IOP3_SAVE, IOP3_RESTORE, IOP3_rerr3e, IOP3_rerr3f
     68       1.1   deraadt };
     69       1.1   deraadt enum IOP3_mem {
     70       1.1   deraadt 	IOP3_LD, IOP3_LDUB, IOP3_LDUH, IOP3_LDD,
     71       1.1   deraadt 	IOP3_ST, IOP3_STB, IOP3_STH, IOP3_STD,
     72       1.1   deraadt 	IOP3_merr08, IOP3_LDSB, IOP3_LDSH, IOP3_merr0b,
     73       1.1   deraadt 	IOP3_merr0c, IOP3_LDSTUB, IOP3_merr0f, IOP3_SWAP,
     74       1.1   deraadt 	IOP3_LDA, IOP3_LDUBA, IOP3_LDUHA, IOP3_LDDA,
     75       1.1   deraadt 	IOP3_STA, IOP3_STBA, IOP3_STHA, IOP3_STDA,
     76       1.1   deraadt 	IOP3_merr18, IOP3_LDSBA, IOP3_LDSHA, IOP3_merr1b,
     77       1.1   deraadt 	IOP3_merr1c, IOP3_LDSTUBA, IOP3_merr1f, IOP3_SWAPA,
     78       1.1   deraadt 	IOP3_LDF, IOP3_LDFSR, IOP3_merr22, IOP3_LDDF,
     79       1.1   deraadt 	IOP3_STF, IOP3_STFSR, IOP3_STDFQ, IOP3_STDF,
     80       1.1   deraadt 	IOP3_merr28, IOP3_merr29, IOP3_merr2a, IOP3_merr2b,
     81       1.1   deraadt 	IOP3_merr2c, IOP3_merr2d, IOP3_merr2e, IOP3_merr2f,
     82       1.1   deraadt 	IOP3_LFC, IOP3_LDCSR, IOP3_merr32, IOP3_LDDC,
     83       1.1   deraadt 	IOP3_STC, IOP3_STCSR, IOP3_STDCQ, IOP3_STDC,
     84       1.1   deraadt 	IOP3_merr38, IOP3_merr39, IOP3_merr3a, IOP3_merr3b,
     85       1.1   deraadt 	IOP3_merr3c, IOP3_merr3d, IOP3_merr3e, IOP3_merr3f
     86       1.1   deraadt };
     87       1.1   deraadt 
     88       1.1   deraadt /*
     89       1.1   deraadt  * Integer condition codes.
     90       1.1   deraadt  */
     91       1.1   deraadt #define	Icc_N	0x0		/* never */
     92       1.1   deraadt #define	Icc_E	0x1		/* equal (equiv. zero) */
     93       1.1   deraadt #define	Icc_LE	0x2		/* less or equal */
     94       1.1   deraadt #define	Icc_L	0x3		/* less */
     95       1.1   deraadt #define	Icc_LEU	0x4		/* less or equal unsigned */
     96       1.1   deraadt #define	Icc_CS	0x5		/* carry set (equiv. less unsigned) */
     97       1.1   deraadt #define	Icc_NEG	0x6		/* negative */
     98       1.1   deraadt #define	Icc_VS	0x7		/* overflow set */
     99       1.1   deraadt #define	Icc_A	0x8		/* always */
    100       1.1   deraadt #define	Icc_NE	0x9		/* not equal (equiv. not zero) */
    101       1.1   deraadt #define	Icc_G	0xa		/* greater */
    102       1.1   deraadt #define	Icc_GE	0xb		/* greater or equal */
    103       1.1   deraadt #define	Icc_GU	0xc		/* greater unsigned */
    104       1.1   deraadt #define	Icc_CC	0xd		/* carry clear (equiv. gtr or eq unsigned) */
    105       1.1   deraadt #define	Icc_POS	0xe		/* positive */
    106       1.1   deraadt #define	Icc_VC	0xf		/* overflow clear */
    107       1.1   deraadt 
    108       1.1   deraadt /*
    109       1.1   deraadt  * Integer registers.
    110       1.1   deraadt  */
    111       1.1   deraadt #define	I_G0	0
    112       1.1   deraadt #define	I_G1	1
    113       1.1   deraadt #define	I_G2	2
    114       1.1   deraadt #define	I_G3	3
    115       1.1   deraadt #define	I_G4	4
    116       1.1   deraadt #define	I_G5	5
    117       1.1   deraadt #define	I_G6	6
    118       1.1   deraadt #define	I_G7	7
    119       1.1   deraadt #define	I_O0	8
    120       1.1   deraadt #define	I_O1	9
    121       1.1   deraadt #define	I_O2	10
    122       1.1   deraadt #define	I_O3	11
    123       1.1   deraadt #define	I_O4	12
    124       1.1   deraadt #define	I_O5	13
    125       1.1   deraadt #define	I_O6	14
    126       1.1   deraadt #define	I_O7	15
    127       1.1   deraadt #define	I_L0	16
    128       1.1   deraadt #define	I_L1	17
    129       1.1   deraadt #define	I_L2	18
    130       1.1   deraadt #define	I_L3	19
    131       1.1   deraadt #define	I_L4	20
    132       1.1   deraadt #define	I_L5	21
    133       1.1   deraadt #define	I_L6	22
    134       1.1   deraadt #define	I_L7	23
    135       1.1   deraadt #define	I_I0	24
    136       1.1   deraadt #define	I_I1	25
    137       1.1   deraadt #define	I_I2	26
    138       1.1   deraadt #define	I_I3	27
    139       1.1   deraadt #define	I_I4	28
    140       1.1   deraadt #define	I_I5	29
    141       1.1   deraadt #define	I_I6	30
    142       1.1   deraadt #define	I_I7	31
    143       1.1   deraadt 
    144       1.1   deraadt /*
    145       1.1   deraadt  * An instruction.
    146       1.1   deraadt  */
    147       1.1   deraadt union instr {
    148       1.1   deraadt 	int	i_int;			/* as a whole */
    149       1.1   deraadt 
    150       1.1   deraadt 	/*
    151       1.1   deraadt 	 * The first level of decoding is to use the top 2 bits.
    152       1.1   deraadt 	 * This gives us one of three `formats', which usually give
    153       1.1   deraadt 	 * a second level of decoding.
    154       1.1   deraadt 	 */
    155       1.1   deraadt 	struct {
    156       1.1   deraadt 		u_int	i_op:2;		/* first-level decode */
    157       1.1   deraadt 		u_int	:30;
    158       1.1   deraadt 	} i_any;
    159       1.1   deraadt 
    160       1.1   deraadt 	/*
    161       1.1   deraadt 	 * Format 1 instructions: CALL (undifferentiated).
    162       1.1   deraadt 	 */
    163       1.1   deraadt 	struct {
    164       1.1   deraadt 		u_int	:2;		/* 01 */
    165       1.1   deraadt 		int	i_disp:30;	/* displacement */
    166       1.1   deraadt 	} i_call;
    167       1.1   deraadt 
    168       1.1   deraadt 	/*
    169       1.1   deraadt 	 * Format 2 instructions (SETHI, UNIMP, and branches, plus illegal
    170       1.1   deraadt 	 * unused codes).
    171       1.1   deraadt 	 */
    172       1.1   deraadt 	struct {
    173       1.1   deraadt 		u_int	:2;		/* 00 */
    174       1.1   deraadt 		u_int	:5;
    175       1.1   deraadt 		u_int	i_op2:3;	/* second-level decode */
    176       1.1   deraadt 		u_int	:22;
    177       1.1   deraadt 	} i_op2;
    178       1.1   deraadt 
    179       1.1   deraadt 	/* UNIMP, SETHI */
    180       1.1   deraadt 	struct {
    181       1.1   deraadt 		u_int	:2;		/* 00 */
    182       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    183       1.1   deraadt 		u_int	i_op2:3;	/* opcode: UNIMP or SETHI */
    184       1.1   deraadt 		u_int	i_imm:22;	/* immediate value */
    185       1.1   deraadt 	} i_imm22;
    186       1.1   deraadt 
    187       1.1   deraadt 	/* branches: Bicc, FBfcc, CBccc */
    188       1.1   deraadt 	struct {
    189       1.1   deraadt 		u_int	:2;		/* 00 */
    190       1.1   deraadt 		u_int	i_annul:1;	/* annul bit */
    191       1.1   deraadt 		u_int	i_cond:4;	/* condition codes */
    192       1.1   deraadt 		u_int	i_op2:3;	/* opcode: {Bi,FBf,CBc}cc */
    193       1.1   deraadt 		int	i_disp:22;	/* branch displacement */
    194       1.1   deraadt 	} i_branch;
    195       1.4        pk 
    196       1.4        pk 	/* more branches: BPcc, FBPfcc */
    197       1.4        pk 	struct {
    198       1.4        pk 		u_int	:2;		/* 00 */
    199       1.4        pk 		u_int	i_annul:1;	/* annul bit */
    200       1.4        pk 		u_int	i_cond:4;	/* condition codes */
    201       1.4        pk 		u_int	i_op2:3;	/* opcode: {BP,FBPf}cc */
    202       1.4        pk 		u_int	i_cc:2;		/* condition code selector */
    203       1.4        pk 		u_int	i_pred:1;	/* branch prediction bit */
    204       1.4        pk 		int	i_disp:19;	/* branch displacement */
    205       1.4        pk 	} i_branch_p;
    206       1.4        pk 
    207       1.4        pk 	/* one last branch: BPr */
    208       1.4        pk 	struct {
    209       1.4        pk 		u_int	:2;		/* 00 */
    210       1.4        pk 		u_int	i_annul:1;	/* annul bit */
    211       1.4        pk 		u_int	:1;		/* 0 */
    212       1.4        pk 		u_int	i_rcond:4;	/* register condition */
    213       1.4        pk 		u_int	:3;		/* 011 */
    214       1.4        pk 		int	i_disphi:2;	/* branch displacement, hi bits */
    215       1.4        pk 		u_int   i_pred:1;	/* branch prediction bit */
    216       1.4        pk 		u_int   i_rs1:1;	/* source register 1 */
    217       1.4        pk 		u_int	i_displo:16;	/* branch displacement, lo bits */
    218       1.4        pk 	} i_branch_pr;
    219       1.4        pk 
    220       1.1   deraadt 
    221       1.1   deraadt 	/*
    222       1.1   deraadt 	 * Format 3 instructions (memory reference; arithmetic, logical,
    223       1.1   deraadt 	 * shift, and other miscellaneous operations).  The second-level
    224       1.1   deraadt 	 * decode almost always makes use of an `rd' and `rs1', however
    225       1.1   deraadt 	 * (see also IOP3_reg and IOP3_mem).
    226       1.1   deraadt 	 *
    227       1.1   deraadt 	 * Beyond that, the low 14 bits may be broken up in one of three
    228       1.1   deraadt 	 * different ways, if at all:
    229       1.1   deraadt 	 *	1 bit of imm=0 + 8 bits of asi + 5 bits of rs2 [reg & mem]
    230       1.1   deraadt 	 *	1 bit of imm=1 + 13 bits of signed immediate [reg & mem]
    231       1.1   deraadt 	 *	9 bits of copressor `opf' opcode + 5 bits of rs2 [reg only]
    232       1.1   deraadt 	 */
    233       1.1   deraadt 	struct {
    234       1.1   deraadt 		u_int	:2;		/* 10 or 11 */
    235       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    236       1.1   deraadt 		u_int	i_op3:6;	/* second-level decode */
    237       1.1   deraadt 		u_int	i_rs1:5;	/* source register 1 */
    238       1.1   deraadt 		u_int	i_low14:14;	/* varies */
    239       1.1   deraadt 	} i_op3;
    240       1.1   deraadt 
    241       1.1   deraadt 	/*
    242       1.1   deraadt 	 * Memory forms.  These set i_op=3 and use simm13 or asi layout.
    243       1.1   deraadt 	 * Memory references without an ASI should use 0, but the actual
    244       1.1   deraadt 	 * ASI field is simply ignored.
    245       1.1   deraadt 	 */
    246       1.1   deraadt 	struct {
    247       1.1   deraadt 		u_int	:2;		/* 11 only */
    248       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    249       1.1   deraadt 		u_int	i_op3:6;	/* second-level decode (see IOP3_mem) */
    250       1.1   deraadt 		u_int	i_i:1;		/* immediate vs asi */
    251       1.1   deraadt 		u_int	i_low13:13;	/* depend on i bit */
    252       1.1   deraadt 	} i_loadstore;
    253       1.1   deraadt 
    254       1.1   deraadt 	/*
    255       1.1   deraadt 	 * Memory and register forms.
    256       1.1   deraadt 	 * These come in quite a variety and we do not
    257       1.1   deraadt 	 * attempt to break them down much.
    258       1.1   deraadt 	 */
    259       1.1   deraadt 	struct {
    260       1.1   deraadt 		u_int	:2;		/* 10 or 11 */
    261       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    262       1.1   deraadt 		u_int	i_op3:6;	/* second-level decode */
    263       1.1   deraadt 		u_int	i_rs1:5;	/* source register 1 */
    264       1.1   deraadt 		u_int	i_i:1;		/* immediate bit (1) */
    265       1.1   deraadt 		int	i_simm13:13;	/* signed immediate */
    266       1.1   deraadt 	} i_simm13;
    267       1.1   deraadt 	struct {
    268       1.1   deraadt 		u_int	:2;		/* 10 or 11 */
    269       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    270       1.1   deraadt 		u_int	i_op3:6;	/* second-level decode */
    271       1.1   deraadt 		u_int	i_rs1:5;	/* source register 1 */
    272       1.3  christos 		u_int	i_i:1;		/* immediate vs asi */
    273       1.1   deraadt 		u_int	i_asi:8;	/* asi */
    274       1.1   deraadt 		u_int	i_rs2:5;	/* source register 2 */
    275       1.1   deraadt 	} i_asi;
    276       1.1   deraadt 	struct {
    277       1.1   deraadt 		u_int	:2;		/* 10 only (register, no memory) */
    278       1.1   deraadt 		u_int	i_rd:5;		/* destination register */
    279       1.1   deraadt 		u_int	i_op3:6;	/* second-level decode (see IOP3_reg) */
    280       1.1   deraadt 		u_int	i_rs1:5;	/* source register 1 */
    281       1.1   deraadt 		u_int	i_opf:9;	/* coprocessor 3rd-level decode */
    282       1.1   deraadt 		u_int	i_rs2:5;	/* source register 2 */
    283       1.1   deraadt 	} i_opf;
    284       1.1   deraadt 
    285  1.4.14.1    bouyer 	/*
    286  1.4.14.1    bouyer 	 * Format 4 instructions (movcc, fmovr, fmovcc, and tcc).  The
    287  1.4.14.1    bouyer 	 * second-level decode almost always makes use of an `rd' and either
    288  1.4.14.1    bouyer 	 * `rs1' or `cond'.
    289  1.4.14.1    bouyer 	 *
    290  1.4.14.1    bouyer 	 * Beyond that, the low 14 bits may be broken up in one of three
    291  1.4.14.1    bouyer 	 * different ways, if at all:
    292  1.4.14.1    bouyer 	 *	1 bit of imm=0 + 8 bits of asi + 5 bits of rs2 [reg & mem]
    293  1.4.14.1    bouyer 	 *	1 bit of imm=1 + 13 bits of signed immediate [reg & mem]
    294  1.4.14.1    bouyer 	 * 9 bits of copressor `opf' opcode + 5 bits of rs2 [reg only] */
    295  1.4.14.1    bouyer 	struct {
    296  1.4.14.1    bouyer 		u_int	:2;		/* 10 */
    297  1.4.14.1    bouyer 		u_int	i_rd:5;		/* destination register */
    298  1.4.14.1    bouyer 		u_int	i_op3:6;	/* second-level decode */
    299  1.4.14.1    bouyer 		u_int	i_rs1:5;	/* source register 1 */
    300  1.4.14.1    bouyer 		u_int	i_low14:14;	/* varies */
    301  1.4.14.1    bouyer 	} i_op4;
    302  1.4.14.1    bouyer 
    303  1.4.14.1    bouyer 	/*
    304  1.4.14.1    bouyer 	 * Move fp register on condition codes.
    305  1.4.14.1    bouyer 	 */
    306  1.4.14.1    bouyer 	struct {
    307  1.4.14.1    bouyer 		u_int	:2;		/* 10 */
    308  1.4.14.1    bouyer 		u_int	i_rd:5;		/* destination register */
    309  1.4.14.1    bouyer 		u_int	i_op3:6;	/* second-level decode */
    310  1.4.14.1    bouyer 		u_int	:1;
    311  1.4.14.1    bouyer 		u_int	i_cond:4;	/* condition */
    312  1.4.14.1    bouyer 		u_int	i_opf_cc:3;	/* condition code register */
    313  1.4.14.1    bouyer 		u_int	i_opf_low:6;	/* third level decode */
    314  1.4.14.1    bouyer 		u_int	i_rs2:5;	/* source register */
    315  1.4.14.1    bouyer 	} i_fmovcc;
    316  1.4.14.1    bouyer 
    317  1.4.14.1    bouyer 	/*
    318  1.4.14.1    bouyer 	 * Move fp register on integer register.
    319  1.4.14.1    bouyer 	 */
    320  1.4.14.1    bouyer 	struct {
    321  1.4.14.1    bouyer 		u_int	:2;		/* 10 */
    322  1.4.14.1    bouyer 		u_int	i_rd:5;		/* destination register */
    323  1.4.14.1    bouyer 		u_int	i_op3:6;	/* second-level decode */
    324  1.4.14.1    bouyer 		u_int	i_rs1:5;	/* source register 1 */
    325  1.4.14.1    bouyer 		u_int	:1;
    326  1.4.14.1    bouyer 		u_int	i_rcond:3;	/* register condition */
    327  1.4.14.1    bouyer 		u_int	i_opf_low:6;
    328  1.4.14.1    bouyer 		u_int	i_rs2:5;	/* source register 2 */
    329  1.4.14.1    bouyer 	} i_fmovr;
    330  1.4.14.1    bouyer 
    331       1.1   deraadt };
    332       1.1   deraadt 
    333       1.1   deraadt /*
    334       1.1   deraadt  * Internal macros for building instructions.  These correspond 1-to-1 to
    335       1.1   deraadt  * the names above.  Note that x << y | z == (x << y) | z.
    336       1.1   deraadt  */
    337       1.1   deraadt #define	_I_ANY(op, b)	((op) << 30 | (b))
    338       1.1   deraadt 
    339       1.1   deraadt #define	_I_OP2(high, op2, low) \
    340       1.1   deraadt 		_I_ANY(IOP_OP2, (high) << 25 | (op2) << 22 | (low))
    341       1.1   deraadt #define	_I_IMM22(rd, op2, imm) \
    342       1.1   deraadt 		_I_ANY(IOP_OP2, (rd) << 25 | (op2) << 22 | (imm))
    343       1.1   deraadt #define	_I_BRANCH(a, c, op2, disp) \
    344       1.1   deraadt 		_I_ANY(IOP_OP2, (a) << 29 | (c) << 25 | (op2) << 22 | (disp))
    345       1.1   deraadt #define	_I_FBFCC(a, cond, disp) \
    346       1.1   deraadt 		_I_BRANCH(a, cond, IOP2_FBfcc, disp)
    347       1.1   deraadt #define	_I_CBCCC(a, cond, disp) \
    348       1.1   deraadt 		_I_BRANCH(a, cond, IOP2_CBccc, disp)
    349       1.1   deraadt 
    350       1.1   deraadt #define	_I_SIMM(simm)		(1 << 13 | ((simm) & 0x1fff))
    351       1.1   deraadt 
    352       1.1   deraadt #define	_I_OP3_GEN(form, rd, op3, rs1, low14) \
    353       1.1   deraadt 		_I_ANY(form, (rd) << 25 | (op3) << 19 | (rs1) << 14 | (low14))
    354       1.1   deraadt #define	_I_OP3_LS_RAR(rd, op3, rs1, asi, rs2) \
    355       1.1   deraadt 		_I_OP3_GEN(IOP_mem, rd, op3, rs1, (asi) << 5 | (rs2))
    356       1.1   deraadt #define	_I_OP3_LS_RI(rd, op3, rs1, simm13) \
    357       1.1   deraadt 		_I_OP3_GEN(IOP_mem, rd, op3, rs1, _I_SIMM(simm13))
    358       1.1   deraadt #define	_I_OP3_LS_RR(rd, op3, rs1, rs2) \
    359       1.1   deraadt 		_I_OP3_GEN(IOP_mem, rd, op3, rs1, rs2)
    360       1.1   deraadt #define	_I_OP3_R_RAR(rd, op3, rs1, asi, rs2) \
    361       1.1   deraadt 		_I_OP3_GEN(IOP_reg, rd, op3, rs1, (asi) << 5 | (rs2))
    362       1.1   deraadt #define	_I_OP3_R_RI(rd, op3, rs1, simm13) \
    363       1.1   deraadt 		_I_OP3_GEN(IOP_reg, rd, op3, rs1, _I_SIMM(simm13))
    364       1.1   deraadt #define	_I_OP3_R_RR(rd, op3, rs1, rs2) \
    365       1.1   deraadt 		_I_OP3_GEN(IOP_reg, rd, op3, rs1, rs2)
    366       1.1   deraadt 
    367       1.1   deraadt #define	I_CALL(d)		_I_ANY(IOP_CALL, d)
    368       1.1   deraadt #define	I_UNIMP(v)		_I_IMM22(0, IOP2_UNIMP, v)
    369       1.1   deraadt #define	I_BN(a, d)		_I_BRANCH(a, Icc_N, IOP2_Bicc, d)
    370       1.1   deraadt #define	I_BE(a, d)		_I_BRANCH(a, Icc_E, IOP2_Bicc, d)
    371       1.1   deraadt #define	I_BZ(a, d)		_I_BRANCH(a, Icc_E, IOP2_Bicc, d)
    372       1.1   deraadt #define	I_BLE(a, d)		_I_BRANCH(a, Icc_LE, IOP2_Bicc, d)
    373       1.1   deraadt #define	I_BL(a, d)		_I_BRANCH(a, Icc_L, IOP2_Bicc, d)
    374       1.1   deraadt #define	I_BLEU(a, d)		_I_BRANCH(a, Icc_LEU, IOP2_Bicc, d)
    375       1.1   deraadt #define	I_BCS(a, d)		_I_BRANCH(a, Icc_CS, IOP2_Bicc, d)
    376       1.1   deraadt #define	I_BLU(a, d)		_I_BRANCH(a, Icc_CS, IOP2_Bicc, d)
    377       1.1   deraadt #define	I_BNEG(a, d)		_I_BRANCH(a, Icc_NEG, IOP2_Bicc, d)
    378       1.1   deraadt #define	I_BVS(a, d)		_I_BRANCH(a, Icc_VS, IOP2_Bicc, d)
    379       1.1   deraadt #define	I_BA(a, d)		_I_BRANCH(a, Icc_A, IOP2_Bicc, d)
    380       1.1   deraadt #define	I_B(a, d)		_I_BRANCH(a, Icc_A, IOP2_Bicc, d)
    381       1.1   deraadt #define	I_BNE(a, d)		_I_BRANCH(a, Icc_NE, IOP2_Bicc, d)
    382       1.1   deraadt #define	I_BNZ(a, d)		_I_BRANCH(a, Icc_NE, IOP2_Bicc, d)
    383       1.1   deraadt #define	I_BG(a, d)		_I_BRANCH(a, Icc_G, IOP2_Bicc, d)
    384       1.1   deraadt #define	I_BGE(a, d)		_I_BRANCH(a, Icc_GE, IOP2_Bicc, d)
    385       1.1   deraadt #define	I_BGU(a, d)		_I_BRANCH(a, Icc_GU, IOP2_Bicc, d)
    386       1.1   deraadt #define	I_BCC(a, d)		_I_BRANCH(a, Icc_CC, IOP2_Bicc, d)
    387       1.1   deraadt #define	I_BGEU(a, d)		_I_BRANCH(a, Icc_CC, IOP2_Bicc, d)
    388       1.1   deraadt #define	I_BPOS(a, d)		_I_BRANCH(a, Icc_POS, IOP2_Bicc, d)
    389       1.1   deraadt #define	I_BVC(a, d)		_I_BRANCH(a, Icc_VC, IOP2_Bicc, d)
    390       1.1   deraadt #define	I_SETHI(r, v)		_I_IMM22(r, 4, v)
    391       1.1   deraadt 
    392       1.1   deraadt #define	I_ORri(rd, rs1, imm)	_I_OP3_R_RI(rd, IOP3_OR, rs1, imm)
    393       1.1   deraadt #define	I_ORrr(rd, rs1, rs2)	_I_OP3_R_RR(rd, IOP3_OR, rs1, rs2)
    394       1.1   deraadt 
    395       1.1   deraadt #define	I_MOVi(rd, imm)		_I_OP3_R_RI(rd, IOP3_OR, I_G0, imm)
    396       1.1   deraadt #define	I_MOVr(rd, rs)		_I_OP3_R_RR(rd, IOP3_OR, I_G0, rs)
    397       1.1   deraadt 
    398       1.1   deraadt #define	I_RDPSR(rd)		_I_OP3_R_RR(rd, IOP3_RDPSR, 0, 0)
    399       1.1   deraadt 
    400       1.1   deraadt #define	I_JMPLri(rd, rs1, imm)	_I_OP3_R_RI(rd, IOP3_JMPL, rs1, imm)
    401       1.1   deraadt #define	I_JMPLrr(rd, rs1, rs2)	_I_OP3_R_RR(rd, IOP3_JMPL, rs1, rs2)
    402       1.1   deraadt 
    403       1.1   deraadt /*
    404       1.1   deraadt  * (Since these are sparse, we skip the enumerations for now.)
    405       1.1   deraadt  * FPop values.  All appear in both FPop1 and FPop2 spaces, but arithmetic
    406       1.1   deraadt  * ops should happen only with FPop1 and comparison only with FPop2.
    407       1.1   deraadt  * The type sits in the low two bits; those bits are given as zero here.
    408       1.1   deraadt  */
    409       1.1   deraadt #define	FMOV	0x00
    410       1.1   deraadt #define	FNEG	0x04
    411       1.1   deraadt #define	FABS	0x08
    412       1.1   deraadt #define	FSQRT	0x28
    413       1.1   deraadt #define	FADD	0x40
    414       1.1   deraadt #define	FSUB	0x44
    415       1.1   deraadt #define	FMUL	0x48
    416       1.1   deraadt #define	FDIV	0x4c
    417       1.1   deraadt #define	FCMP	0x50
    418       1.1   deraadt #define	FCMPE	0x54
    419       1.1   deraadt #define	FSMULD	0x68
    420       1.1   deraadt #define	FDMULX	0x6c
    421  1.4.14.1    bouyer #define FTOX	0x80
    422  1.4.14.1    bouyer #define FXTOS	0x84
    423  1.4.14.1    bouyer #define FXTOD	0x88
    424  1.4.14.1    bouyer #define FXTOQ	0x8c
    425       1.1   deraadt #define	FTOS	0xc4
    426       1.1   deraadt #define	FTOD	0xc8
    427  1.4.14.1    bouyer #define	FTOQ	0xcc
    428       1.1   deraadt #define	FTOI	0xd0
    429       1.1   deraadt 
    430  1.4.14.1    bouyer /* These are in FPop2 space */
    431  1.4.14.1    bouyer #define FMVFC0	0x00
    432  1.4.14.1    bouyer #define FMVRZ	0x24
    433  1.4.14.1    bouyer #define FMVFC1	0x40
    434  1.4.14.1    bouyer #define FMVRLEZ	0x44
    435  1.4.14.1    bouyer #define FMVRLZ	0x64
    436  1.4.14.1    bouyer #define FMVFC2	0x80
    437  1.4.14.1    bouyer #define FMVRNZ	0xa4
    438  1.4.14.1    bouyer #define FMVFC3	0xc0
    439  1.4.14.1    bouyer #define FMVRGZ	0xc4
    440  1.4.14.1    bouyer #define FMVRGEZ	0xe4
    441  1.4.14.1    bouyer #define FMVIC	0x100
    442  1.4.14.1    bouyer #define FMVXC	0x180
    443  1.4.14.1    bouyer 
    444       1.1   deraadt /*
    445       1.1   deraadt  * FPU data types.
    446       1.1   deraadt  */
    447  1.4.14.1    bouyer #define FTYPE_LNG	-1	/* data = 64-bit signed long integer */
    448       1.1   deraadt #define	FTYPE_INT	0	/* data = 32-bit signed integer */
    449       1.1   deraadt #define	FTYPE_SNG	1	/* data = 32-bit float */
    450       1.1   deraadt #define	FTYPE_DBL	2	/* data = 64-bit double */
    451       1.1   deraadt #define	FTYPE_EXT	3	/* data = 128-bit extended (quad-prec) */
    452