1 /* $OpenBSD: mips_opcode.h,v 1.6 2011/03/23 16:54:36 pirofti Exp $ */ 2 3 /*- 4 * Copyright (c) 1992, 1993 5 * The Regents of the University of California. All rights reserved. 6 * 7 * This code is derived from software contributed to Berkeley by 8 * Ralph Campbell. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. Neither the name of the University nor the names of its contributors 19 * may be used to endorse or promote products derived from this software 20 * without specific prior written permission. 21 * 22 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 23 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32 * SUCH DAMAGE. 33 * 34 * from: @(#)mips_opcode.h 8.1 (Berkeley) 6/10/93 35 */ 36 37 #ifndef _MIPS64_MIPS_OPCODE_H_ 38 #define _MIPS64_MIPS_OPCODE_H_ 39 40 /* 41 * Define the instruction formats and opcode values for the 42 * MIPS instruction set. 43 */ 44 45 /* 46 * Define the instruction formats. 47 */ 48 typedef union { 49 unsigned word; 50 51 #if BYTE_ORDER == BIG_ENDIAN 52 struct { 53 unsigned op: 6; 54 unsigned rs: 5; 55 unsigned rt: 5; 56 unsigned imm: 16; 57 } IType; 58 59 struct { 60 unsigned op: 6; 61 unsigned target: 26; 62 } JType; 63 64 struct { 65 unsigned op: 6; 66 unsigned rs: 5; 67 unsigned rt: 5; 68 unsigned rd: 5; 69 unsigned shamt: 5; 70 unsigned func: 6; 71 } RType; 72 73 struct { 74 unsigned op: 6; /* COP1 */ 75 unsigned : 1; /* always '1' */ 76 unsigned fmt: 4; 77 unsigned ft: 5; 78 unsigned fs: 5; 79 unsigned fd: 5; 80 unsigned func: 6; 81 } FRType; 82 83 struct { 84 unsigned op: 6; /* COP1X */ 85 unsigned fr: 5; 86 unsigned ft: 5; 87 unsigned fs: 5; 88 unsigned fd: 5; 89 unsigned op4: 3; 90 unsigned fmt3: 3; 91 } FQType; 92 #endif 93 #if BYTE_ORDER == LITTLE_ENDIAN 94 struct { 95 unsigned imm: 16; 96 unsigned rt: 5; 97 unsigned rs: 5; 98 unsigned op: 6; 99 } IType; 100 101 struct { 102 unsigned target: 26; 103 unsigned op: 6; 104 } JType; 105 106 struct { 107 unsigned func: 6; 108 unsigned shamt: 5; 109 unsigned rd: 5; 110 unsigned rt: 5; 111 unsigned rs: 5; 112 unsigned op: 6; 113 } RType; 114 115 struct { 116 unsigned func: 6; 117 unsigned fd: 5; 118 unsigned fs: 5; 119 unsigned ft: 5; 120 unsigned fmt: 4; 121 unsigned : 1; /* always '1' */ 122 unsigned op: 6; /* COP1 */ 123 } FRType; 124 125 struct { 126 unsigned fmt3: 3; 127 unsigned op4: 3; 128 unsigned fd: 5; 129 unsigned fs: 5; 130 unsigned ft: 5; 131 unsigned fr: 5; 132 unsigned op: 6; /* COP1X */ 133 } FQType; 134 #endif 135 } InstFmt; 136 137 /* 138 * Values for the 'op' field. 139 */ 140 #define OP_SPECIAL 000 141 #define OP_BCOND 001 142 #define OP_J 002 143 #define OP_JAL 003 144 #define OP_BEQ 004 145 #define OP_BNE 005 146 #define OP_BLEZ 006 147 #define OP_BGTZ 007 148 149 #define OP_ADDI 010 150 #define OP_ADDIU 011 151 #define OP_SLTI 012 152 #define OP_SLTIU 013 153 #define OP_ANDI 014 154 #define OP_ORI 015 155 #define OP_XORI 016 156 #define OP_LUI 017 157 158 #define OP_COP0 020 159 #define OP_COP1 021 160 #define OP_COP2 022 161 #define OP_COP3 023 162 #define OP_COP1X 023 163 #define OP_BEQL 024 164 #define OP_BNEL 025 165 #define OP_BLEZL 026 166 #define OP_BGTZL 027 167 168 #define OP_DADDI 030 169 #define OP_DADDIU 031 170 #define OP_LDL 032 171 #define OP_LDR 033 172 173 #define OP_LB 040 174 #define OP_LH 041 175 #define OP_LWL 042 176 #define OP_LW 043 177 #define OP_LBU 044 178 #define OP_LHU 045 179 #define OP_LWR 046 180 #define OP_LWU 047 181 182 #define OP_SB 050 183 #define OP_SH 051 184 #define OP_SWL 052 185 #define OP_SW 053 186 #define OP_SDL 054 187 #define OP_SDR 055 188 #define OP_SWR 056 189 #define OP_CACHE 057 190 191 #define OP_LL 060 192 #define OP_LWC1 061 193 #define OP_LWC2 062 194 #define OP_LWC3 063 195 #define OP_PREF 063 196 #define OP_LLD 064 197 #define OP_LDC1 065 198 #define OP_LDC2 066 199 #define OP_LD 067 200 201 #define OP_SC 070 202 #define OP_SWC1 071 203 #define OP_SWC2 072 204 #define OP_SWC3 073 205 #define OP_SCD 074 206 #define OP_SDC1 075 207 #define OP_SDC2 076 208 #define OP_SD 077 209 210 /* 211 * Values for the 'func' field when 'op' == OP_SPECIAL. 212 */ 213 #define OP_SLL 000 214 #define OP_MOVCI 001 215 #define OP_SRL 002 216 #define OP_SRA 003 217 #define OP_SLLV 004 218 #define OP_SRLV 006 219 #define OP_SRAV 007 220 221 #define OP_JR 010 222 #define OP_JALR 011 223 #define OP_MOVZ 012 224 #define OP_MOVN 013 225 #define OP_SYSCALL 014 226 #define OP_BREAK 015 227 #define OP_SYNC 017 228 229 #define OP_MFHI 020 230 #define OP_MTHI 021 231 #define OP_MFLO 022 232 #define OP_MTLO 023 233 #define OP_DSLLV 024 234 #define OP_DSRLV 026 235 #define OP_DSRAV 027 236 237 #define OP_MULT 030 238 #define OP_MULTU 031 239 #define OP_DIV 032 240 #define OP_DIVU 033 241 #define OP_DMULT 034 242 #define OP_DMULTU 035 243 #define OP_DDIV 036 244 #define OP_DDIVU 037 245 246 #define OP_ADD 040 247 #define OP_ADDU 041 248 #define OP_SUB 042 249 #define OP_SUBU 043 250 #define OP_AND 044 251 #define OP_OR 045 252 #define OP_XOR 046 253 #define OP_NOR 047 254 255 #define OP_SLT 052 256 #define OP_SLTU 053 257 #define OP_DADD 054 258 #define OP_DADDU 055 259 #define OP_DSUB 056 260 #define OP_DSUBU 057 261 262 #define OP_TGE 060 263 #define OP_TGEU 061 264 #define OP_TLT 062 265 #define OP_TLTU 063 266 #define OP_TEQ 064 267 #define OP_TNE 066 268 269 #define OP_DSLL 070 270 #define OP_DSRL 072 271 #define OP_DSRA 073 272 #define OP_DSLL32 074 273 #define OP_DSRL32 076 274 #define OP_DSRA32 077 275 276 /* 277 * Values for the 'func' field when 'op' == OP_BCOND. 278 */ 279 #define OP_BLTZ 000 280 #define OP_BGEZ 001 281 #define OP_BLTZL 002 282 #define OP_BGEZL 003 283 284 #define OP_TGEI 010 285 #define OP_TGEIU 011 286 #define OP_TLTI 012 287 #define OP_TLTIU 013 288 #define OP_TEQI 014 289 #define OP_TNEI 016 290 291 #define OP_BLTZAL 020 292 #define OP_BGEZAL 021 293 #define OP_BLTZALL 022 294 #define OP_BGEZALL 023 295 296 /* 297 * Values for the 'rs' field when 'op' == OP_COPz. 298 */ 299 #define OP_MF 000 300 #define OP_DMF 001 301 #define OP_CF 002 302 #define OP_MFH 003 303 #define OP_MT 004 304 #define OP_DMT 005 305 #define OP_CT 006 306 #define OP_MTH 007 307 #define OP_BC 010 308 #define OP_C0MISC 020 /* cop0 only */ 309 310 /* 311 * Values for the 'rt' field when 'op' == OP_COPz. 312 */ 313 #define COPz_BC_TF_MASK 0x01 314 #define COPz_BC_TRUE 0x01 315 #define COPz_BC_FALSE 0x00 316 #define COPz_BCL_TF_MASK 0x02 317 #define COPz_BCL_TRUE 0x02 318 #define COPz_BCL_FALSE 0x00 319 #define COPz_BC_CC_MASK 0x1c 320 #define COPz_BC_CC_SHIFT 2 321 322 /* 323 * Values for the 'func' field when 'op' == OP_COP1X. 324 */ 325 #define OP_LWXC1 000 326 #define OP_LDXC1 001 327 #define OP_SWXC1 010 328 #define OP_SDXC1 011 329 #define OP_PREFX 017 330 331 /* 332 * Values for the 'op4' field when 'op' == OP_COP1X. 333 */ 334 #define OP_MADD 04 335 #define OP_MSUB 05 336 #define OP_NMADD 06 337 #define OP_NMSUB 07 338 339 #endif /* !_MIPS64_MIPS_OPCODE_H_ */ 340