1 1.1.1.5 christos /* DO NOT EDIT! -*- buffer-read-only: t -*- vi:set ro: */ 2 1.1 skrll /* Disassembler interface for targets using CGEN. -*- C -*- 3 1.1 skrll CGEN: Cpu tools GENerator 4 1.1 skrll 5 1.1 skrll THIS FILE IS MACHINE GENERATED WITH CGEN. 6 1.1 skrll - the resultant file is machine generated, cgen-dis.in isn't 7 1.1 skrll 8 1.1.1.11 christos Copyright (C) 1996-2026 Free Software Foundation, Inc. 9 1.1 skrll 10 1.1 skrll This file is part of libopcodes. 11 1.1 skrll 12 1.1 skrll This library is free software; you can redistribute it and/or modify 13 1.1 skrll it under the terms of the GNU General Public License as published by 14 1.1 skrll the Free Software Foundation; either version 3, or (at your option) 15 1.1 skrll any later version. 16 1.1 skrll 17 1.1 skrll It is distributed in the hope that it will be useful, but WITHOUT 18 1.1 skrll ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 19 1.1 skrll or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 20 1.1 skrll License for more details. 21 1.1 skrll 22 1.1 skrll You should have received a copy of the GNU General Public License 23 1.1 skrll along with this program; if not, write to the Free Software Foundation, Inc., 24 1.1 skrll 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 25 1.1 skrll 26 1.1 skrll /* ??? Eventually more and more of this stuff can go to cpu-independent files. 27 1.1 skrll Keep that in mind. */ 28 1.1 skrll 29 1.1 skrll #include "sysdep.h" 30 1.1 skrll #include <stdio.h> 31 1.1 skrll #include "ansidecl.h" 32 1.1.1.5 christos #include "disassemble.h" 33 1.1 skrll #include "bfd.h" 34 1.1 skrll #include "symcat.h" 35 1.1 skrll #include "libiberty.h" 36 1.1 skrll #include "mep-desc.h" 37 1.1 skrll #include "mep-opc.h" 38 1.1 skrll #include "opintl.h" 39 1.1 skrll 40 1.1 skrll /* Default text to print if an instruction isn't recognized. */ 41 1.1 skrll #define UNKNOWN_INSN_MSG _("*unknown*") 42 1.1 skrll 43 1.1 skrll static void print_normal 44 1.1 skrll (CGEN_CPU_DESC, void *, long, unsigned int, bfd_vma, int); 45 1.1 skrll static void print_address 46 1.1 skrll (CGEN_CPU_DESC, void *, bfd_vma, unsigned int, bfd_vma, int) ATTRIBUTE_UNUSED; 47 1.1 skrll static void print_keyword 48 1.1 skrll (CGEN_CPU_DESC, void *, CGEN_KEYWORD *, long, unsigned int) ATTRIBUTE_UNUSED; 49 1.1 skrll static void print_insn_normal 50 1.1 skrll (CGEN_CPU_DESC, void *, const CGEN_INSN *, CGEN_FIELDS *, bfd_vma, int); 51 1.1 skrll static int print_insn 52 1.1 skrll (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, unsigned); 53 1.1 skrll static int default_print_insn 54 1.1 skrll (CGEN_CPU_DESC, bfd_vma, disassemble_info *) ATTRIBUTE_UNUSED; 55 1.1 skrll static int read_insn 56 1.1 skrll (CGEN_CPU_DESC, bfd_vma, disassemble_info *, bfd_byte *, int, CGEN_EXTRACT_INFO *, 57 1.1 skrll unsigned long *); 58 1.1 skrll 59 1.1 skrll /* -- disassembler routines inserted here. */ 61 1.1 skrll 62 1.1 skrll /* -- dis.c */ 63 1.1 skrll 64 1.1 skrll #include "elf/mep.h" 65 1.1 skrll #include "elf-bfd.h" 66 1.1 skrll 67 1.1 skrll #define CGEN_VALIDATE_INSN_SUPPORTED 68 1.1 skrll 69 1.1.1.8 christos static void 70 1.1 skrll print_tpreg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, void *dis_info, 71 1.1 skrll CGEN_KEYWORD *table ATTRIBUTE_UNUSED, long val ATTRIBUTE_UNUSED, 72 1.1 skrll unsigned int flags ATTRIBUTE_UNUSED) 73 1.1 skrll { 74 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 75 1.1 skrll 76 1.1 skrll (*info->fprintf_func) (info->stream, "$tp"); 77 1.1 skrll } 78 1.1 skrll 79 1.1.1.8 christos static void 80 1.1 skrll print_spreg (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, void *dis_info, 81 1.1 skrll CGEN_KEYWORD *table ATTRIBUTE_UNUSED, long val ATTRIBUTE_UNUSED, 82 1.1 skrll unsigned int flags ATTRIBUTE_UNUSED) 83 1.1 skrll { 84 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 85 1.1 skrll 86 1.1 skrll (*info->fprintf_func) (info->stream, "$sp"); 87 1.1 skrll } 88 1.1 skrll 89 1.1 skrll /* begin-cop-ip-print-handlers */ 90 1.1.1.2 christos static void 91 1.1.1.2 christos print_ivc2_cr (CGEN_CPU_DESC, 92 1.1.1.2 christos void *, 93 1.1.1.2 christos CGEN_KEYWORD *, 94 1.1.1.2 christos long, 95 1.1.1.2 christos unsigned int) ATTRIBUTE_UNUSED; 96 1.1.1.2 christos static void 97 1.1 skrll print_ivc2_cr (CGEN_CPU_DESC cd, 98 1.1 skrll void *dis_info, 99 1.1 skrll CGEN_KEYWORD *keyword_table ATTRIBUTE_UNUSED, 100 1.1 skrll long value, 101 1.1 skrll unsigned int attrs) 102 1.1.1.2 christos { 103 1.1 skrll print_keyword (cd, dis_info, & mep_cgen_opval_h_cr_ivc2, value, attrs); 104 1.1 skrll } 105 1.1.1.2 christos static void 106 1.1.1.2 christos print_ivc2_ccr (CGEN_CPU_DESC, 107 1.1.1.2 christos void *, 108 1.1.1.2 christos CGEN_KEYWORD *, 109 1.1.1.2 christos long, 110 1.1.1.2 christos unsigned int) ATTRIBUTE_UNUSED; 111 1.1.1.2 christos static void 112 1.1 skrll print_ivc2_ccr (CGEN_CPU_DESC cd, 113 1.1 skrll void *dis_info, 114 1.1 skrll CGEN_KEYWORD *keyword_table ATTRIBUTE_UNUSED, 115 1.1 skrll long value, 116 1.1 skrll unsigned int attrs) 117 1.1.1.2 christos { 118 1.1 skrll print_keyword (cd, dis_info, & mep_cgen_opval_h_ccr_ivc2, value, attrs); 119 1.1 skrll } 120 1.1 skrll /* end-cop-ip-print-handlers */ 121 1.1 skrll 122 1.1 skrll /************************************************************\ 123 1.1 skrll *********************** Experimental ************************* 124 1.1 skrll \************************************************************/ 125 1.1 skrll 126 1.1 skrll #undef CGEN_PRINT_INSN 127 1.1 skrll #define CGEN_PRINT_INSN mep_print_insn 128 1.1 skrll 129 1.1 skrll static int 130 1.1 skrll mep_print_vliw_insns (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info, 131 1.1 skrll bfd_byte *buf, int corelength, int copro1length, 132 1.1 skrll int copro2length ATTRIBUTE_UNUSED) 133 1.1 skrll { 134 1.1 skrll int i; 135 1.1 skrll int status = 0; 136 1.1 skrll /* char insnbuf[CGEN_MAX_INSN_SIZE]; */ 137 1.1 skrll bfd_byte insnbuf[64]; 138 1.1 skrll 139 1.1 skrll /* If corelength > 0 then there is a core insn present. It 140 1.1 skrll will be at the beginning of the buffer. After printing 141 1.1 skrll the core insn, we need to print the + on the next line. */ 142 1.1 skrll if (corelength > 0) 143 1.1 skrll { 144 1.1.1.3 christos int my_status = 0; 145 1.1 skrll 146 1.1 skrll for (i = 0; i < corelength; i++ ) 147 1.1 skrll insnbuf[i] = buf[i]; 148 1.1.1.3 christos cd->isas = & MEP_CORE_ISA; 149 1.1 skrll 150 1.1 skrll my_status = print_insn (cd, pc, info, insnbuf, corelength); 151 1.1 skrll if (my_status != corelength) 152 1.1 skrll { 153 1.1 skrll (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); 154 1.1 skrll my_status = corelength; 155 1.1 skrll } 156 1.1 skrll status += my_status; 157 1.1.1.9 christos 158 1.1.1.9 christos /* Print the + to indicate that the following copro insn is 159 1.1 skrll part of a vliw group. */ 160 1.1.1.3 christos if (copro1length > 0) 161 1.1 skrll (*info->fprintf_func) (info->stream, " + "); 162 1.1 skrll } 163 1.1 skrll 164 1.1 skrll /* Now all that is left to be processed is the coprocessor insns 165 1.1 skrll In vliw mode, there will always be one. Its positioning will 166 1.1 skrll be from byte corelength to byte corelength+copro1length -1. 167 1.1 skrll No need to check for existence. Also, the first vliw insn, 168 1.1 skrll will, as spec'd, always be at least as long as the core insn 169 1.1 skrll so we don't need to flush the buffer. */ 170 1.1 skrll if (copro1length > 0) 171 1.1 skrll { 172 1.1.1.3 christos int my_status = 0; 173 1.1 skrll 174 1.1 skrll for (i = corelength; i < corelength + copro1length; i++ ) 175 1.1 skrll insnbuf[i - corelength] = buf[i]; 176 1.1 skrll 177 1.1 skrll switch (copro1length) 178 1.1 skrll { 179 1.1 skrll case 0: 180 1.1 skrll break; 181 1.1 skrll case 2: 182 1.1 skrll cd->isas = & MEP_COP16_ISA; 183 1.1 skrll break; 184 1.1 skrll case 4: 185 1.1 skrll cd->isas = & MEP_COP32_ISA; 186 1.1 skrll break; 187 1.1 skrll case 6: 188 1.1 skrll cd->isas = & MEP_COP48_ISA; 189 1.1 skrll break; 190 1.1 skrll case 8: 191 1.1.1.3 christos cd->isas = & MEP_COP64_ISA; 192 1.1 skrll break; 193 1.1 skrll default: 194 1.1 skrll /* Shouldn't be anything but 16,32,48,64. */ 195 1.1 skrll break; 196 1.1 skrll } 197 1.1 skrll 198 1.1 skrll my_status = print_insn (cd, pc, info, insnbuf, copro1length); 199 1.1 skrll 200 1.1 skrll if (my_status != copro1length) 201 1.1 skrll { 202 1.1 skrll (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); 203 1.1 skrll my_status = copro1length; 204 1.1 skrll } 205 1.1 skrll status += my_status; 206 1.1 skrll } 207 1.1 skrll 208 1.1 skrll #if 0 209 1.1 skrll /* Now we need to process the second copro insn if it exists. We 210 1.1 skrll have no guarantee that the second copro insn will be longer 211 1.1 skrll than the first, so we have to flush the buffer if we are have 212 1.1 skrll a second copro insn to process. If present, this insn will 213 1.1 skrll be in the position from byte corelength+copro1length to byte 214 1.1 skrll corelength+copro1length+copro2length-1 (which better equal 8 215 1.1 skrll or else we're in big trouble. */ 216 1.1 skrll if (copro2length > 0) 217 1.1 skrll { 218 1.1 skrll int my_status = 0; 219 1.1 skrll 220 1.1 skrll for (i = 0; i < 64 ; i++) 221 1.1 skrll insnbuf[i] = 0; 222 1.1 skrll 223 1.1 skrll for (i = corelength + copro1length; i < 64; i++) 224 1.1.1.3 christos insnbuf[i - (corelength + copro1length)] = buf[i]; 225 1.1 skrll 226 1.1 skrll switch (copro2length) 227 1.1 skrll { 228 1.1 skrll case 2: 229 1.1 skrll cd->isas = 1 << ISA_EXT_COP1_16; 230 1.1 skrll break; 231 1.1 skrll case 4: 232 1.1 skrll cd->isas = 1 << ISA_EXT_COP1_32; 233 1.1 skrll break; 234 1.1 skrll case 6: 235 1.1 skrll cd->isas = 1 << ISA_EXT_COP1_48; 236 1.1 skrll break; 237 1.1.1.3 christos case 8: 238 1.1 skrll cd->isas = 1 << ISA_EXT_COP1_64; 239 1.1 skrll break; 240 1.1 skrll default: 241 1.1 skrll /* Shouldn't be anything but 16,32,48,64. */ 242 1.1 skrll break; 243 1.1 skrll } 244 1.1 skrll 245 1.1 skrll my_status = print_insn (cd, pc, info, insnbuf, copro2length); 246 1.1 skrll 247 1.1 skrll if (my_status != copro2length) 248 1.1 skrll { 249 1.1 skrll (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); 250 1.1 skrll my_status = copro2length; 251 1.1 skrll } 252 1.1 skrll 253 1.1 skrll status += my_status; 254 1.1 skrll } 255 1.1 skrll #endif 256 1.1 skrll 257 1.1 skrll /* Status should now be the number of bytes that were printed 258 1.1 skrll which should be 4 for VLIW32 mode and 64 for VLIW64 mode. */ 259 1.1 skrll 260 1.1 skrll if ((!MEP_VLIW64 && (status != 4)) || (MEP_VLIW64 && (status != 8))) 261 1.1 skrll return -1; 262 1.1 skrll else 263 1.1 skrll return status; 264 1.1 skrll } 265 1.1.1.3 christos 266 1.1.1.3 christos /* The two functions mep_examine_vliw[32,64]_insns are used find out 267 1.1.1.3 christos which vliw combinaion (16 bit core with 48 bit copro, 32 bit core 268 1.1.1.3 christos with 32 bit copro, etc.) is present. Later on, when internally 269 1.1.1.3 christos parallel coprocessors are handled, only these functions should 270 1.1.1.3 christos need to be changed. 271 1.1.1.3 christos 272 1.1 skrll At this time only the following combinations are supported: 273 1.1 skrll 274 1.1 skrll VLIW32 Mode: 275 1.1 skrll 16 bit core insn (core) and 16 bit coprocessor insn (cop1) 276 1.1 skrll 32 bit core insn (core) 277 1.1 skrll 32 bit coprocessor insn (cop1) 278 1.1 skrll Note: As of this time, I do not believe we have enough information 279 1.1.1.3 christos to distinguish a 32 bit core insn from a 32 bit cop insn. Also, 280 1.1 skrll no 16 bit coprocessor insns have been specified. 281 1.1 skrll 282 1.1 skrll VLIW64 Mode: 283 1.1 skrll 16 bit core insn (core) and 48 bit coprocessor insn (cop1) 284 1.1 skrll 32 bit core insn (core) and 32 bit coprocessor insn (cop1) 285 1.1.1.3 christos 64 bit coprocessor insn (cop1) 286 1.1 skrll 287 1.1.1.3 christos The framework for an internally parallel coprocessor is also 288 1.1 skrll present (2nd coprocessor insn is cop2), but at this time it 289 1.1 skrll is not used. This only appears to be valid in VLIW64 mode. */ 290 1.1 skrll 291 1.1 skrll static int 292 1.1 skrll mep_examine_vliw32_insns (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) 293 1.1 skrll { 294 1.1 skrll int status; 295 1.1 skrll int buflength; 296 1.1 skrll int corebuflength; 297 1.1 skrll int cop1buflength; 298 1.1.1.3 christos int cop2buflength; 299 1.1 skrll bfd_byte buf[CGEN_MAX_INSN_SIZE]; 300 1.1.1.3 christos char indicator16[1]; 301 1.1 skrll char indicatorcop32[2]; 302 1.1 skrll 303 1.1 skrll /* At this time we're not supporting internally parallel coprocessors, 304 1.1 skrll so cop2buflength will always be 0. */ 305 1.1 skrll cop2buflength = 0; 306 1.1 skrll 307 1.1 skrll /* Read in 32 bits. */ 308 1.1 skrll buflength = 4; /* VLIW insn spans 4 bytes. */ 309 1.1 skrll status = (*info->read_memory_func) (pc, buf, buflength, info); 310 1.1 skrll 311 1.1 skrll if (status != 0) 312 1.1 skrll { 313 1.1 skrll (*info->memory_error_func) (status, pc, info); 314 1.1 skrll return -1; 315 1.1 skrll } 316 1.1 skrll 317 1.1 skrll /* Put the big endian representation of the bytes to be examined 318 1.1 skrll in the temporary buffers for examination. */ 319 1.1 skrll 320 1.1 skrll if (info->endian == BFD_ENDIAN_BIG) 321 1.1 skrll { 322 1.1 skrll indicator16[0] = buf[0]; 323 1.1 skrll indicatorcop32[0] = buf[0]; 324 1.1 skrll indicatorcop32[1] = buf[1]; 325 1.1 skrll } 326 1.1 skrll else 327 1.1 skrll { 328 1.1 skrll indicator16[0] = buf[1]; 329 1.1 skrll indicatorcop32[0] = buf[1]; 330 1.1 skrll indicatorcop32[1] = buf[0]; 331 1.1 skrll } 332 1.1 skrll 333 1.1 skrll /* If the two high order bits are 00, 01 or 10, we have a 16 bit 334 1.1 skrll core insn and a 48 bit copro insn. */ 335 1.1 skrll 336 1.1 skrll if ((indicator16[0] & 0x80) && (indicator16[0] & 0x40)) 337 1.1 skrll { 338 1.1 skrll if ((indicatorcop32[0] & 0xf0) == 0xf0 && (indicatorcop32[1] & 0x07) == 0x07) 339 1.1.1.9 christos { 340 1.1.1.9 christos /* We have a 32 bit copro insn. */ 341 1.1 skrll corebuflength = 0; 342 1.1.1.9 christos /* All 4 4ytes are one copro insn. */ 343 1.1 skrll cop1buflength = 4; 344 1.1 skrll } 345 1.1 skrll else 346 1.1.1.9 christos { 347 1.1.1.9 christos /* We have a 32 bit core. */ 348 1.1.1.9 christos corebuflength = 4; 349 1.1 skrll cop1buflength = 0; 350 1.1 skrll } 351 1.1 skrll } 352 1.1 skrll else 353 1.1 skrll { 354 1.1 skrll /* We have a 16 bit core insn and a 16 bit copro insn. */ 355 1.1 skrll corebuflength = 2; 356 1.1 skrll cop1buflength = 2; 357 1.1 skrll } 358 1.1 skrll 359 1.1 skrll /* Now we have the distrubution set. Print them out. */ 360 1.1 skrll status = mep_print_vliw_insns (cd, pc, info, buf, corebuflength, 361 1.1 skrll cop1buflength, cop2buflength); 362 1.1 skrll 363 1.1 skrll return status; 364 1.1 skrll } 365 1.1 skrll 366 1.1 skrll static int 367 1.1 skrll mep_examine_vliw64_insns (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) 368 1.1 skrll { 369 1.1 skrll int status; 370 1.1 skrll int buflength; 371 1.1 skrll int corebuflength; 372 1.1 skrll int cop1buflength; 373 1.1 skrll int cop2buflength; 374 1.1 skrll bfd_byte buf[CGEN_MAX_INSN_SIZE]; 375 1.1 skrll char indicator16[1]; 376 1.1 skrll char indicator64[4]; 377 1.1 skrll 378 1.1 skrll /* At this time we're not supporting internally parallel 379 1.1 skrll coprocessors, so cop2buflength will always be 0. */ 380 1.1 skrll cop2buflength = 0; 381 1.1 skrll 382 1.1 skrll /* Read in 64 bits. */ 383 1.1 skrll buflength = 8; /* VLIW insn spans 8 bytes. */ 384 1.1 skrll status = (*info->read_memory_func) (pc, buf, buflength, info); 385 1.1 skrll 386 1.1 skrll if (status != 0) 387 1.1 skrll { 388 1.1 skrll (*info->memory_error_func) (status, pc, info); 389 1.1 skrll return -1; 390 1.1 skrll } 391 1.1 skrll 392 1.1 skrll /* We have all 64 bits in the buffer now. We have to figure out 393 1.1 skrll what combination of instruction sizes are present. The two 394 1.1 skrll high order bits will indicate whether or not we have a 16 bit 395 1.1 skrll core insn or not. If not, then we have to look at the 7,8th 396 1.1 skrll bytes to tell whether we have 64 bit copro insn or a 32 bit 397 1.1 skrll core insn with a 32 bit copro insn. Endianness will make a 398 1.1 skrll difference here. */ 399 1.1 skrll 400 1.1 skrll /* Put the big endian representation of the bytes to be examined 401 1.1 skrll in the temporary buffers for examination. */ 402 1.1 skrll 403 1.1 skrll /* indicator16[0] = buf[0]; */ 404 1.1 skrll if (info->endian == BFD_ENDIAN_BIG) 405 1.1 skrll { 406 1.1 skrll indicator16[0] = buf[0]; 407 1.1 skrll indicator64[0] = buf[0]; 408 1.1 skrll indicator64[1] = buf[1]; 409 1.1 skrll indicator64[2] = buf[2]; 410 1.1 skrll indicator64[3] = buf[3]; 411 1.1 skrll } 412 1.1 skrll else 413 1.1 skrll { 414 1.1 skrll indicator16[0] = buf[1]; 415 1.1 skrll indicator64[0] = buf[1]; 416 1.1 skrll indicator64[1] = buf[0]; 417 1.1 skrll indicator64[2] = buf[3]; 418 1.1 skrll indicator64[3] = buf[2]; 419 1.1 skrll } 420 1.1 skrll 421 1.1 skrll /* If the two high order bits are 00, 01 or 10, we have a 16 bit 422 1.1 skrll core insn and a 48 bit copro insn. */ 423 1.1 skrll 424 1.1 skrll if ((indicator16[0] & 0x80) && (indicator16[0] & 0x40)) 425 1.1 skrll { 426 1.1 skrll if ((indicator64[0] & 0xf0) == 0xf0 && (indicator64[1] & 0x07) == 0x07 427 1.1 skrll && ((indicator64[2] & 0xfe) != 0xf0 || (indicator64[3] & 0xf4) != 0)) 428 1.1.1.9 christos { 429 1.1.1.9 christos /* We have a 64 bit copro insn. */ 430 1.1 skrll corebuflength = 0; 431 1.1.1.9 christos /* All 8 bytes are one copro insn. */ 432 1.1 skrll cop1buflength = 8; 433 1.1 skrll } 434 1.1 skrll else 435 1.1.1.9 christos { 436 1.1.1.9 christos /* We have a 32 bit core insn and a 32 bit copro insn. */ 437 1.1.1.9 christos corebuflength = 4; 438 1.1 skrll cop1buflength = 4; 439 1.1 skrll } 440 1.1 skrll } 441 1.1 skrll else 442 1.1 skrll { 443 1.1 skrll /* We have a 16 bit core insn and a 48 bit copro insn. */ 444 1.1 skrll corebuflength = 2; 445 1.1 skrll cop1buflength = 6; 446 1.1 skrll } 447 1.1 skrll 448 1.1 skrll /* Now we have the distrubution set. Print them out. */ 449 1.1 skrll status = mep_print_vliw_insns (cd, pc, info, buf, corebuflength, 450 1.1 skrll cop1buflength, cop2buflength); 451 1.1 skrll 452 1.1 skrll return status; 453 1.1 skrll } 454 1.1.1.2 christos 455 1.1.1.2 christos #ifdef MEP_IVC2_SUPPORTED 456 1.1.1.2 christos 457 1.1.1.2 christos static int 458 1.1.1.2 christos print_slot_insn (CGEN_CPU_DESC cd, 459 1.1.1.2 christos bfd_vma pc, 460 1.1.1.2 christos disassemble_info *info, 461 1.1.1.2 christos SLOTS_ATTR slot, 462 1.1.1.2 christos bfd_byte *buf) 463 1.1.1.2 christos { 464 1.1.1.2 christos const CGEN_INSN_LIST *insn_list; 465 1.1.1.2 christos CGEN_INSN_INT insn_value; 466 1.1.1.2 christos CGEN_EXTRACT_INFO ex_info; 467 1.1.1.8 christos 468 1.1.1.2 christos insn_value = cgen_get_insn_value (cd, buf, 32, cd->insn_endian); 469 1.1.1.2 christos 470 1.1.1.2 christos /* Fill in ex_info fields like read_insn would. Don't actually call 471 1.1.1.2 christos read_insn, since the incoming buffer is already read (and possibly 472 1.1.1.2 christos modified a la m32r). */ 473 1.1.1.2 christos ex_info.valid = (1 << 8) - 1; 474 1.1.1.2 christos ex_info.dis_info = info; 475 1.1.1.2 christos ex_info.insn_bytes = buf; 476 1.1.1.2 christos 477 1.1.1.2 christos /* The instructions are stored in hash lists. 478 1.1.1.2 christos Pick the first one and keep trying until we find the right one. */ 479 1.1.1.2 christos 480 1.1.1.2 christos insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value); 481 1.1.1.2 christos while (insn_list != NULL) 482 1.1.1.2 christos { 483 1.1.1.2 christos const CGEN_INSN *insn = insn_list->insn; 484 1.1.1.2 christos CGEN_FIELDS fields; 485 1.1.1.2 christos int length; 486 1.1.1.2 christos 487 1.1.1.2 christos if ((CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_CONFIG) 488 1.1.1.2 christos && CGEN_INSN_ATTR_VALUE (insn, CGEN_INSN_CONFIG) != MEP_CONFIG) 489 1.1.1.9 christos || ! (CGEN_ATTR_CGEN_INSN_SLOTS_VALUE (CGEN_INSN_ATTRS (insn)) & (1 << slot))) 490 1.1.1.9 christos { 491 1.1.1.2 christos insn_list = CGEN_DIS_NEXT_INSN (insn_list); 492 1.1.1.9 christos continue; 493 1.1.1.2 christos } 494 1.1.1.2 christos 495 1.1.1.2 christos if ((insn_value & CGEN_INSN_BASE_MASK (insn)) 496 1.1.1.2 christos == CGEN_INSN_BASE_VALUE (insn)) 497 1.1.1.2 christos { 498 1.1.1.2 christos /* Printing is handled in two passes. The first pass parses the 499 1.1.1.2 christos machine insn and extracts the fields. The second pass prints 500 1.1.1.2 christos them. */ 501 1.1.1.2 christos 502 1.1.1.2 christos length = CGEN_EXTRACT_FN (cd, insn) 503 1.1.1.2 christos (cd, insn, &ex_info, insn_value, &fields, pc); 504 1.1.1.2 christos 505 1.1.1.2 christos /* Length < 0 -> error. */ 506 1.1.1.2 christos if (length < 0) 507 1.1.1.2 christos return length; 508 1.1.1.2 christos if (length > 0) 509 1.1.1.2 christos { 510 1.1.1.2 christos CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length); 511 1.1.1.2 christos /* Length is in bits, result is in bytes. */ 512 1.1.1.2 christos return length / 8; 513 1.1.1.2 christos } 514 1.1.1.2 christos } 515 1.1.1.2 christos 516 1.1.1.2 christos insn_list = CGEN_DIS_NEXT_INSN (insn_list); 517 1.1.1.2 christos } 518 1.1.1.2 christos 519 1.1.1.2 christos if (slot == SLOTS_P0S) 520 1.1.1.2 christos (*info->fprintf_func) (info->stream, "*unknown-p0s*"); 521 1.1.1.2 christos else if (slot == SLOTS_P0) 522 1.1.1.2 christos (*info->fprintf_func) (info->stream, "*unknown-p0*"); 523 1.1.1.2 christos else if (slot == SLOTS_P1) 524 1.1.1.2 christos (*info->fprintf_func) (info->stream, "*unknown-p1*"); 525 1.1.1.2 christos else if (slot == SLOTS_C3) 526 1.1.1.2 christos (*info->fprintf_func) (info->stream, "*unknown-c3*"); 527 1.1.1.2 christos return 0; 528 1.1.1.2 christos } 529 1.1.1.2 christos 530 1.1.1.2 christos static int 531 1.1.1.2 christos mep_examine_ivc2_insns (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, bfd_vma pc ATTRIBUTE_UNUSED, disassemble_info *info ATTRIBUTE_UNUSED) 532 1.1.1.2 christos { 533 1.1.1.2 christos int status; 534 1.1.1.2 christos int buflength; 535 1.1.1.2 christos bfd_byte buf[8]; 536 1.1.1.2 christos bfd_byte insn[8]; 537 1.1.1.2 christos int e; 538 1.1.1.2 christos 539 1.1.1.2 christos /* Read in 64 bits. */ 540 1.1.1.2 christos buflength = 8; /* VLIW insn spans 8 bytes. */ 541 1.1.1.2 christos status = (*info->read_memory_func) (pc, buf, buflength, info); 542 1.1.1.2 christos 543 1.1.1.2 christos if (status != 0) 544 1.1.1.2 christos { 545 1.1.1.2 christos (*info->memory_error_func) (status, pc, info); 546 1.1.1.2 christos return -1; 547 1.1.1.2 christos } 548 1.1.1.2 christos 549 1.1.1.2 christos if (info->endian == BFD_ENDIAN_LITTLE) 550 1.1.1.2 christos e = 1; 551 1.1.1.2 christos else 552 1.1.1.2 christos e = 0; 553 1.1.1.2 christos 554 1.1.1.2 christos if (((unsigned char)buf[0^e] & 0xf0) < 0xc0) 555 1.1.1.2 christos { 556 1.1.1.2 christos /* <--00--><--11--><--22--><--33--><--44--><--55--><--66--><--77--> */ 557 1.1.1.2 christos /* V1 [-----core-----][--------p0s-------][------------p1------------] */ 558 1.1.1.2 christos 559 1.1.1.2 christos print_insn (cd, pc, info, buf, 2); 560 1.1.1.2 christos 561 1.1.1.2 christos insn[0^e] = 0; 562 1.1.1.2 christos insn[1^e] = buf[2^e]; 563 1.1.1.2 christos insn[2^e] = buf[3^e]; 564 1.1.1.2 christos insn[3^e] = buf[4^e] & 0xf0; 565 1.1.1.2 christos (*info->fprintf_func) (info->stream, " + "); 566 1.1.1.2 christos print_slot_insn (cd, pc, info, SLOTS_P0S, insn); 567 1.1.1.2 christos 568 1.1.1.2 christos insn[0^e] = buf[4^e] << 4 | buf[5^e] >> 4; 569 1.1.1.2 christos insn[1^e] = buf[5^e] << 4 | buf[6^e] >> 4; 570 1.1.1.2 christos insn[2^e] = buf[6^e] << 4 | buf[7^e] >> 4; 571 1.1.1.2 christos insn[3^e] = buf[7^e] << 4; 572 1.1.1.2 christos (*info->fprintf_func) (info->stream, " + "); 573 1.1.1.2 christos print_slot_insn (cd, pc, info, SLOTS_P1, insn); 574 1.1.1.2 christos } 575 1.1.1.2 christos else if ((buf[0^e] & 0xf0) == 0xf0 && (buf[1^e] & 0x0f) == 0x07) 576 1.1.1.2 christos { 577 1.1.1.2 christos /* <--00--><--11--><--22--><--33--><--44--><--55--><--66--><--77--> */ 578 1.1.1.2 christos /* V3 1111[--p0--]0111[--------p0--------][------------p1------------] */ 579 1.1.1.2 christos /* 00000000111111112222222233333333 */ 580 1.1.1.2 christos 581 1.1.1.2 christos insn[0^e] = buf[0^e] << 4 | buf[1^e] >> 4; 582 1.1.1.2 christos insn[1^e] = buf[2^e]; 583 1.1.1.2 christos insn[2^e] = buf[3^e]; 584 1.1.1.2 christos insn[3^e] = buf[4^e] & 0xf0; 585 1.1.1.2 christos print_slot_insn (cd, pc, info, SLOTS_P0, insn); 586 1.1.1.2 christos 587 1.1.1.2 christos insn[0^e] = buf[4^e] << 4 | buf[5^e] >> 4; 588 1.1.1.2 christos insn[1^e] = buf[5^e] << 4 | buf[6^e] >> 4; 589 1.1.1.2 christos insn[2^e] = buf[6^e] << 4 | buf[7^e] >> 4; 590 1.1.1.2 christos insn[3^e] = buf[7^e] << 4; 591 1.1.1.2 christos (*info->fprintf_func) (info->stream, " + "); 592 1.1.1.2 christos print_slot_insn (cd, pc, info, SLOTS_P1, insn); 593 1.1.1.2 christos } 594 1.1.1.2 christos else 595 1.1.1.2 christos { 596 1.1.1.2 christos /* <--00--><--11--><--22--><--33--><--44--><--55--><--66--><--77--> */ 597 1.1.1.2 christos /* V2 [-------------core-------------]xxxx[------------p1------------] */ 598 1.1.1.2 christos print_insn (cd, pc, info, buf, 4); 599 1.1.1.2 christos 600 1.1.1.2 christos insn[0^e] = buf[4^e] << 4 | buf[5^e] >> 4; 601 1.1.1.2 christos insn[1^e] = buf[5^e] << 4 | buf[6^e] >> 4; 602 1.1.1.2 christos insn[2^e] = buf[6^e] << 4 | buf[7^e] >> 4; 603 1.1.1.2 christos insn[3^e] = buf[7^e] << 4; 604 1.1.1.2 christos (*info->fprintf_func) (info->stream, " + "); 605 1.1.1.2 christos print_slot_insn (cd, pc, info, SLOTS_P1, insn); 606 1.1.1.2 christos } 607 1.1.1.2 christos 608 1.1.1.2 christos return 8; 609 1.1.1.2 christos } 610 1.1.1.2 christos 611 1.1.1.2 christos #endif /* MEP_IVC2_SUPPORTED */ 612 1.1.1.2 christos 613 1.1.1.2 christos /* This is a hack. SID calls this to update the disassembler as the 614 1.1.1.2 christos CPU changes modes. */ 615 1.1.1.2 christos static int mep_ivc2_disassemble_p = 0; 616 1.1.1.2 christos static int mep_ivc2_vliw_disassemble_p = 0; 617 1.1.1.2 christos 618 1.1.1.2 christos void 619 1.1.1.2 christos mep_print_insn_set_ivc2_mode (int ivc2_p, int vliw_p, int cfg_idx); 620 1.1.1.2 christos void 621 1.1.1.2 christos mep_print_insn_set_ivc2_mode (int ivc2_p, int vliw_p, int cfg_idx) 622 1.1.1.2 christos { 623 1.1.1.2 christos mep_ivc2_disassemble_p = ivc2_p; 624 1.1.1.2 christos mep_ivc2_vliw_disassemble_p = vliw_p; 625 1.1.1.2 christos mep_config_index = cfg_idx; 626 1.1.1.2 christos } 627 1.1 skrll 628 1.1 skrll static int 629 1.1 skrll mep_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) 630 1.1 skrll { 631 1.1.1.2 christos int status; 632 1.1.1.2 christos int cop_type; 633 1.1.1.2 christos int ivc2 = 0; 634 1.1.1.2 christos static CGEN_ATTR_VALUE_BITSET_TYPE *ivc2_core_isa = NULL; 635 1.1.1.2 christos 636 1.1.1.2 christos if (ivc2_core_isa == NULL) 637 1.1.1.2 christos { 638 1.1.1.2 christos /* IVC2 has some core-only coprocessor instructions. We 639 1.1.1.2 christos use COP32 to flag those, and COP64 for the VLIW ones, 640 1.1.1.2 christos since they have the same names. */ 641 1.1.1.2 christos ivc2_core_isa = cgen_bitset_create (MAX_ISAS); 642 1.1 skrll } 643 1.1 skrll 644 1.1 skrll /* Extract and adapt to configuration number, if available. */ 645 1.1 skrll if (info->section && info->section->owner) 646 1.1 skrll { 647 1.1.1.8 christos bfd *abfd = info->section->owner; 648 1.1.1.8 christos if (bfd_get_flavour (abfd) == bfd_target_elf_flavour) 649 1.1.1.8 christos { 650 1.1.1.8 christos mep_config_index = abfd->tdata.elf_obj_data->elf_header->e_flags & EF_MEP_INDEX_MASK; 651 1.1.1.2 christos /* This instantly redefines MEP_CONFIG, MEP_OMASK, .... MEP_VLIW64 */ 652 1.1.1.9 christos 653 1.1.1.9 christos /* mep_config_map is a variable sized array, so we do not know how big it is. 654 1.1.1.9 christos The only safe way to check the index therefore is to iterate over the array. 655 1.1.1.9 christos We do know that the last entry is all null. */ 656 1.1.1.9 christos int i; 657 1.1.1.9 christos for (i = 0; i <= mep_config_index; i++) 658 1.1.1.9 christos if (mep_config_map[i].name == NULL) 659 1.1.1.9 christos break; 660 1.1.1.9 christos 661 1.1.1.9 christos if (i < mep_config_index) 662 1.1.1.9 christos { 663 1.1.1.9 christos opcodes_error_handler (_("illegal MEP INDEX setting '%x' in ELF header e_flags field"), mep_config_index); 664 1.1.1.9 christos mep_config_index = 0; 665 1.1.1.9 christos } 666 1.1.1.8 christos 667 1.1.1.8 christos cop_type = abfd->tdata.elf_obj_data->elf_header->e_flags & EF_MEP_COP_MASK; 668 1.1.1.8 christos if (cop_type == EF_MEP_COP_IVC2) 669 1.1.1.8 christos ivc2 = 1; 670 1.1 skrll } 671 1.1 skrll } 672 1.1 skrll 673 1.1 skrll /* Picking the right ISA bitmask for the current context is tricky. */ 674 1.1 skrll if (info->section) 675 1.1 skrll { 676 1.1 skrll if (info->section->flags & SEC_MEP_VLIW) 677 1.1.1.2 christos { 678 1.1.1.2 christos #ifdef MEP_IVC2_SUPPORTED 679 1.1.1.2 christos if (ivc2) 680 1.1.1.2 christos { 681 1.1.1.2 christos /* ivc2 has its own way of selecting its functions. */ 682 1.1.1.2 christos cd->isas = & MEP_CORE_ISA; 683 1.1.1.2 christos status = mep_examine_ivc2_insns (cd, pc, info); 684 1.1 skrll } 685 1.1.1.2 christos else 686 1.1.1.2 christos #endif 687 1.1.1.2 christos /* Are we in 32 or 64 bit vliw mode? */ 688 1.1.1.2 christos if (MEP_VLIW64) 689 1.1.1.2 christos status = mep_examine_vliw64_insns (cd, pc, info); 690 1.1.1.2 christos else 691 1.1 skrll status = mep_examine_vliw32_insns (cd, pc, info); 692 1.1 skrll /* Both the above branches set their own isa bitmasks. */ 693 1.1 skrll } 694 1.1 skrll else 695 1.1.1.2 christos { 696 1.1.1.2 christos if (ivc2) 697 1.1.1.2 christos { 698 1.1.1.2 christos cgen_bitset_clear (ivc2_core_isa); 699 1.1.1.2 christos cgen_bitset_union (ivc2_core_isa, &MEP_CORE_ISA, ivc2_core_isa); 700 1.1.1.2 christos cgen_bitset_union (ivc2_core_isa, &MEP_COP32_ISA, ivc2_core_isa); 701 1.1.1.2 christos cd->isas = ivc2_core_isa; 702 1.1.1.2 christos } 703 1.1.1.2 christos else 704 1.1 skrll cd->isas = & MEP_CORE_ISA; 705 1.1 skrll status = default_print_insn (cd, pc, info); 706 1.1 skrll } 707 1.1 skrll } 708 1.1 skrll else /* sid or gdb */ 709 1.1.1.2 christos { 710 1.1.1.2 christos #ifdef MEP_IVC2_SUPPORTED 711 1.1.1.2 christos if (mep_ivc2_disassemble_p) 712 1.1.1.2 christos { 713 1.1.1.2 christos if (mep_ivc2_vliw_disassemble_p) 714 1.1.1.2 christos { 715 1.1.1.2 christos cd->isas = & MEP_CORE_ISA; 716 1.1.1.2 christos status = mep_examine_ivc2_insns (cd, pc, info); 717 1.1.1.2 christos return status; 718 1.1.1.2 christos } 719 1.1.1.2 christos else 720 1.1.1.2 christos { 721 1.1.1.2 christos if (ivc2) 722 1.1.1.2 christos cd->isas = ivc2_core_isa; 723 1.1.1.2 christos } 724 1.1.1.2 christos } 725 1.1.1.2 christos #endif 726 1.1 skrll 727 1.1 skrll status = default_print_insn (cd, pc, info); 728 1.1 skrll } 729 1.1 skrll 730 1.1 skrll return status; 731 1.1 skrll } 732 1.1 skrll 733 1.1 skrll 734 1.1 skrll /* -- opc.c */ 735 1.1 skrll 736 1.1.1.8 christos void mep_cgen_print_operand 737 1.1 skrll (CGEN_CPU_DESC, int, void *, CGEN_FIELDS *, void const *, bfd_vma, int); 738 1.1 skrll 739 1.1 skrll /* Main entry point for printing operands. 740 1.1 skrll XINFO is a `void *' and not a `disassemble_info *' to not put a requirement 741 1.1 skrll of dis-asm.h on cgen.h. 742 1.1 skrll 743 1.1 skrll This function is basically just a big switch statement. Earlier versions 744 1.1 skrll used tables to look up the function to use, but 745 1.1 skrll - if the table contains both assembler and disassembler functions then 746 1.1 skrll the disassembler contains much of the assembler and vice-versa, 747 1.1 skrll - there's a lot of inlining possibilities as things grow, 748 1.1 skrll - using a switch statement avoids the function call overhead. 749 1.1 skrll 750 1.1 skrll This function could be moved into `print_insn_normal', but keeping it 751 1.1 skrll separate makes clear the interface between `print_insn_normal' and each of 752 1.1 skrll the handlers. */ 753 1.1 skrll 754 1.1 skrll void 755 1.1 skrll mep_cgen_print_operand (CGEN_CPU_DESC cd, 756 1.1 skrll int opindex, 757 1.1 skrll void * xinfo, 758 1.1 skrll CGEN_FIELDS *fields, 759 1.1 skrll void const *attrs ATTRIBUTE_UNUSED, 760 1.1 skrll bfd_vma pc, 761 1.1 skrll int length) 762 1.1 skrll { 763 1.1 skrll disassemble_info *info = (disassemble_info *) xinfo; 764 1.1 skrll 765 1.1 skrll switch (opindex) 766 1.1 skrll { 767 1.1 skrll case MEP_OPERAND_ADDR24A4 : 768 1.1 skrll print_normal (cd, info, fields->f_24u8a4n, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 769 1.1.1.2 christos break; 770 1.1.1.2 christos case MEP_OPERAND_C5RMUIMM20 : 771 1.1.1.2 christos print_normal (cd, info, fields->f_c5_rmuimm20, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 772 1.1.1.2 christos break; 773 1.1.1.2 christos case MEP_OPERAND_C5RNMUIMM24 : 774 1.1.1.2 christos print_normal (cd, info, fields->f_c5_rnmuimm24, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 775 1.1 skrll break; 776 1.1 skrll case MEP_OPERAND_CALLNUM : 777 1.1 skrll print_normal (cd, info, fields->f_callnum, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 778 1.1 skrll break; 779 1.1 skrll case MEP_OPERAND_CCCC : 780 1.1 skrll print_normal (cd, info, fields->f_rm, 0, pc, length); 781 1.1 skrll break; 782 1.1 skrll case MEP_OPERAND_CCRN : 783 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_ccr, fields->f_ccrn, 0|(1<<CGEN_OPERAND_VIRTUAL)); 784 1.1.1.2 christos break; 785 1.1.1.2 christos case MEP_OPERAND_CDISP10 : 786 1.1.1.2 christos print_normal (cd, info, fields->f_cdisp10, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 787 1.1.1.2 christos break; 788 1.1.1.2 christos case MEP_OPERAND_CDISP10A2 : 789 1.1 skrll print_normal (cd, info, fields->f_cdisp10, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 790 1.1.1.2 christos break; 791 1.1.1.2 christos case MEP_OPERAND_CDISP10A4 : 792 1.1 skrll print_normal (cd, info, fields->f_cdisp10, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 793 1.1.1.2 christos break; 794 1.1.1.2 christos case MEP_OPERAND_CDISP10A8 : 795 1.1 skrll print_normal (cd, info, fields->f_cdisp10, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 796 1.1.1.2 christos break; 797 1.1.1.2 christos case MEP_OPERAND_CDISP12 : 798 1.1 skrll print_normal (cd, info, fields->f_12s20, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 799 1.1 skrll break; 800 1.1 skrll case MEP_OPERAND_CIMM4 : 801 1.1 skrll print_normal (cd, info, fields->f_rn, 0, pc, length); 802 1.1 skrll break; 803 1.1 skrll case MEP_OPERAND_CIMM5 : 804 1.1 skrll print_normal (cd, info, fields->f_5u24, 0, pc, length); 805 1.1 skrll break; 806 1.1 skrll case MEP_OPERAND_CODE16 : 807 1.1 skrll print_normal (cd, info, fields->f_16u16, 0, pc, length); 808 1.1 skrll break; 809 1.1 skrll case MEP_OPERAND_CODE24 : 810 1.1 skrll print_normal (cd, info, fields->f_24u4n, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 811 1.1 skrll break; 812 1.1 skrll case MEP_OPERAND_CP_FLAG : 813 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_ccr, 0, 0); 814 1.1 skrll break; 815 1.1 skrll case MEP_OPERAND_CRN : 816 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_cr, fields->f_crn, 0); 817 1.1 skrll break; 818 1.1 skrll case MEP_OPERAND_CRN64 : 819 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_crn, 0); 820 1.1 skrll break; 821 1.1 skrll case MEP_OPERAND_CRNX : 822 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_cr, fields->f_crnx, 0|(1<<CGEN_OPERAND_VIRTUAL)); 823 1.1 skrll break; 824 1.1 skrll case MEP_OPERAND_CRNX64 : 825 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_crnx, 0|(1<<CGEN_OPERAND_VIRTUAL)); 826 1.1.1.2 christos break; 827 1.1.1.2 christos case MEP_OPERAND_CROC : 828 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u7, 0); 829 1.1.1.2 christos break; 830 1.1.1.2 christos case MEP_OPERAND_CROP : 831 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u23, 0); 832 1.1.1.2 christos break; 833 1.1.1.2 christos case MEP_OPERAND_CRPC : 834 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u26, 0); 835 1.1.1.2 christos break; 836 1.1.1.2 christos case MEP_OPERAND_CRPP : 837 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u18, 0); 838 1.1.1.2 christos break; 839 1.1.1.2 christos case MEP_OPERAND_CRQC : 840 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u21, 0); 841 1.1.1.2 christos break; 842 1.1.1.2 christos case MEP_OPERAND_CRQP : 843 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_5u13, 0); 844 1.1 skrll break; 845 1.1 skrll case MEP_OPERAND_CSRN : 846 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, fields->f_csrn, 0|(1<<CGEN_OPERAND_VIRTUAL)); 847 1.1 skrll break; 848 1.1 skrll case MEP_OPERAND_CSRN_IDX : 849 1.1 skrll print_normal (cd, info, fields->f_csrn, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 850 1.1 skrll break; 851 1.1 skrll case MEP_OPERAND_DBG : 852 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 853 1.1 skrll break; 854 1.1 skrll case MEP_OPERAND_DEPC : 855 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 856 1.1 skrll break; 857 1.1 skrll case MEP_OPERAND_EPC : 858 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 859 1.1 skrll break; 860 1.1 skrll case MEP_OPERAND_EXC : 861 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 862 1.1.1.2 christos break; 863 1.1.1.2 christos case MEP_OPERAND_HI : 864 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 865 1.1.1.2 christos break; 866 1.1.1.2 christos case MEP_OPERAND_IMM16P0 : 867 1.1 skrll print_normal (cd, info, fields->f_ivc2_imm16p0, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 868 1.1.1.2 christos break; 869 1.1.1.2 christos case MEP_OPERAND_IMM3P12 : 870 1.1 skrll print_normal (cd, info, fields->f_ivc2_3u12, 0, pc, length); 871 1.1.1.2 christos break; 872 1.1.1.2 christos case MEP_OPERAND_IMM3P25 : 873 1.1 skrll print_normal (cd, info, fields->f_ivc2_3u25, 0, pc, length); 874 1.1.1.2 christos break; 875 1.1.1.2 christos case MEP_OPERAND_IMM3P4 : 876 1.1 skrll print_normal (cd, info, fields->f_ivc2_3u4, 0, pc, length); 877 1.1.1.2 christos break; 878 1.1.1.2 christos case MEP_OPERAND_IMM3P5 : 879 1.1 skrll print_normal (cd, info, fields->f_ivc2_3u5, 0, pc, length); 880 1.1.1.2 christos break; 881 1.1.1.2 christos case MEP_OPERAND_IMM3P9 : 882 1.1 skrll print_normal (cd, info, fields->f_ivc2_3u9, 0, pc, length); 883 1.1.1.2 christos break; 884 1.1.1.2 christos case MEP_OPERAND_IMM4P10 : 885 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_4u10, 0, pc, length); 886 1.1.1.2 christos break; 887 1.1.1.2 christos case MEP_OPERAND_IMM4P4 : 888 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_4u4, 0, pc, length); 889 1.1.1.2 christos break; 890 1.1.1.2 christos case MEP_OPERAND_IMM4P8 : 891 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_4u8, 0, pc, length); 892 1.1.1.2 christos break; 893 1.1.1.2 christos case MEP_OPERAND_IMM5P23 : 894 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_5u23, 0, pc, length); 895 1.1.1.2 christos break; 896 1.1.1.2 christos case MEP_OPERAND_IMM5P3 : 897 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_5u3, 0, pc, length); 898 1.1.1.2 christos break; 899 1.1.1.2 christos case MEP_OPERAND_IMM5P7 : 900 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_5u7, 0, pc, length); 901 1.1.1.2 christos break; 902 1.1.1.2 christos case MEP_OPERAND_IMM5P8 : 903 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_5u8, 0, pc, length); 904 1.1.1.2 christos break; 905 1.1.1.2 christos case MEP_OPERAND_IMM6P2 : 906 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_6u2, 0, pc, length); 907 1.1.1.2 christos break; 908 1.1.1.2 christos case MEP_OPERAND_IMM6P6 : 909 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_6u6, 0, pc, length); 910 1.1.1.2 christos break; 911 1.1.1.2 christos case MEP_OPERAND_IMM8P0 : 912 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8u0, 0, pc, length); 913 1.1.1.2 christos break; 914 1.1.1.2 christos case MEP_OPERAND_IMM8P20 : 915 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8u20, 0, pc, length); 916 1.1.1.2 christos break; 917 1.1.1.2 christos case MEP_OPERAND_IMM8P4 : 918 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8u4, 0, pc, length); 919 1.1.1.2 christos break; 920 1.1.1.2 christos case MEP_OPERAND_IVC_X_0_2 : 921 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_2u0, 0, pc, length); 922 1.1.1.2 christos break; 923 1.1.1.2 christos case MEP_OPERAND_IVC_X_0_3 : 924 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_3u0, 0, pc, length); 925 1.1.1.2 christos break; 926 1.1.1.2 christos case MEP_OPERAND_IVC_X_0_4 : 927 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_4u0, 0, pc, length); 928 1.1.1.2 christos break; 929 1.1.1.2 christos case MEP_OPERAND_IVC_X_0_5 : 930 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_5u0, 0, pc, length); 931 1.1.1.2 christos break; 932 1.1.1.2 christos case MEP_OPERAND_IVC_X_6_1 : 933 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_1u6, 0, pc, length); 934 1.1.1.2 christos break; 935 1.1.1.2 christos case MEP_OPERAND_IVC_X_6_2 : 936 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_2u6, 0, pc, length); 937 1.1.1.2 christos break; 938 1.1.1.2 christos case MEP_OPERAND_IVC_X_6_3 : 939 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_3u6, 0, pc, length); 940 1.1.1.2 christos break; 941 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_0 : 942 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 943 1.1.1.2 christos break; 944 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_1 : 945 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 946 1.1.1.2 christos break; 947 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_2 : 948 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 949 1.1.1.2 christos break; 950 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_3 : 951 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 952 1.1.1.2 christos break; 953 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_4 : 954 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 955 1.1.1.2 christos break; 956 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_5 : 957 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 958 1.1.1.2 christos break; 959 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_6 : 960 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 961 1.1.1.2 christos break; 962 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC0_7 : 963 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 964 1.1.1.2 christos break; 965 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_0 : 966 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 967 1.1.1.2 christos break; 968 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_1 : 969 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 970 1.1.1.2 christos break; 971 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_2 : 972 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 973 1.1.1.2 christos break; 974 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_3 : 975 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 976 1.1.1.2 christos break; 977 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_4 : 978 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 979 1.1.1.2 christos break; 980 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_5 : 981 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 982 1.1.1.2 christos break; 983 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_6 : 984 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 985 1.1.1.2 christos break; 986 1.1.1.2 christos case MEP_OPERAND_IVC2_ACC1_7 : 987 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 988 1.1.1.2 christos break; 989 1.1.1.2 christos case MEP_OPERAND_IVC2_CC : 990 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 991 1.1.1.2 christos break; 992 1.1.1.2 christos case MEP_OPERAND_IVC2_COFA0 : 993 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 994 1.1.1.2 christos break; 995 1.1.1.2 christos case MEP_OPERAND_IVC2_COFA1 : 996 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 997 1.1.1.2 christos break; 998 1.1.1.2 christos case MEP_OPERAND_IVC2_COFR0 : 999 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 1000 1.1.1.2 christos break; 1001 1.1.1.2 christos case MEP_OPERAND_IVC2_COFR1 : 1002 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 1003 1.1.1.2 christos break; 1004 1.1.1.2 christos case MEP_OPERAND_IVC2_CSAR0 : 1005 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 1006 1.1.1.2 christos break; 1007 1.1.1.2 christos case MEP_OPERAND_IVC2_CSAR1 : 1008 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, 0, 0); 1009 1.1.1.2 christos break; 1010 1.1.1.2 christos case MEP_OPERAND_IVC2C3CCRN : 1011 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, fields->f_ivc2_ccrn_c3, 0|(1<<CGEN_OPERAND_VIRTUAL)); 1012 1.1.1.2 christos break; 1013 1.1.1.2 christos case MEP_OPERAND_IVC2CCRN : 1014 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_ccr_ivc2, fields->f_ivc2_ccrn, 0|(1<<CGEN_OPERAND_VIRTUAL)); 1015 1.1.1.2 christos break; 1016 1.1.1.2 christos case MEP_OPERAND_IVC2CRN : 1017 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_cr64, fields->f_ivc2_crnx, 0|(1<<CGEN_OPERAND_VIRTUAL)); 1018 1.1.1.2 christos break; 1019 1.1.1.2 christos case MEP_OPERAND_IVC2RM : 1020 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_ivc2_crm, 0); 1021 1.1 skrll break; 1022 1.1 skrll case MEP_OPERAND_LO : 1023 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1024 1.1 skrll break; 1025 1.1 skrll case MEP_OPERAND_LP : 1026 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1027 1.1 skrll break; 1028 1.1 skrll case MEP_OPERAND_MB0 : 1029 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1030 1.1 skrll break; 1031 1.1 skrll case MEP_OPERAND_MB1 : 1032 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1033 1.1 skrll break; 1034 1.1 skrll case MEP_OPERAND_ME0 : 1035 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1036 1.1 skrll break; 1037 1.1 skrll case MEP_OPERAND_ME1 : 1038 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1039 1.1 skrll break; 1040 1.1 skrll case MEP_OPERAND_NPC : 1041 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1042 1.1 skrll break; 1043 1.1 skrll case MEP_OPERAND_OPT : 1044 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1045 1.1 skrll break; 1046 1.1 skrll case MEP_OPERAND_PCABS24A2 : 1047 1.1 skrll print_address (cd, info, fields->f_24u5a2n, 0|(1<<CGEN_OPERAND_ABS_ADDR)|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 1048 1.1 skrll break; 1049 1.1 skrll case MEP_OPERAND_PCREL12A2 : 1050 1.1 skrll print_address (cd, info, fields->f_12s4a2, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length); 1051 1.1 skrll break; 1052 1.1 skrll case MEP_OPERAND_PCREL17A2 : 1053 1.1 skrll print_address (cd, info, fields->f_17s16a2, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length); 1054 1.1 skrll break; 1055 1.1 skrll case MEP_OPERAND_PCREL24A2 : 1056 1.1 skrll print_address (cd, info, fields->f_24s5a2n, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_PCREL_ADDR)|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 1057 1.1 skrll break; 1058 1.1 skrll case MEP_OPERAND_PCREL8A2 : 1059 1.1 skrll print_address (cd, info, fields->f_8s8a2, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_RELAX)|(1<<CGEN_OPERAND_PCREL_ADDR), pc, length); 1060 1.1 skrll break; 1061 1.1 skrll case MEP_OPERAND_PSW : 1062 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1063 1.1 skrll break; 1064 1.1 skrll case MEP_OPERAND_R0 : 1065 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1066 1.1 skrll break; 1067 1.1 skrll case MEP_OPERAND_R1 : 1068 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1069 1.1 skrll break; 1070 1.1 skrll case MEP_OPERAND_RL : 1071 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rl, 0); 1072 1.1.1.2 christos break; 1073 1.1.1.2 christos case MEP_OPERAND_RL5 : 1074 1.1.1.2 christos print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rl5, 0); 1075 1.1 skrll break; 1076 1.1 skrll case MEP_OPERAND_RM : 1077 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rm, 0); 1078 1.1 skrll break; 1079 1.1 skrll case MEP_OPERAND_RMA : 1080 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rm, 0); 1081 1.1 skrll break; 1082 1.1 skrll case MEP_OPERAND_RN : 1083 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1084 1.1 skrll break; 1085 1.1 skrll case MEP_OPERAND_RN3 : 1086 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1087 1.1 skrll break; 1088 1.1 skrll case MEP_OPERAND_RN3C : 1089 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1090 1.1 skrll break; 1091 1.1 skrll case MEP_OPERAND_RN3L : 1092 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1093 1.1 skrll break; 1094 1.1 skrll case MEP_OPERAND_RN3S : 1095 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1096 1.1 skrll break; 1097 1.1 skrll case MEP_OPERAND_RN3UC : 1098 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1099 1.1 skrll break; 1100 1.1 skrll case MEP_OPERAND_RN3UL : 1101 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1102 1.1 skrll break; 1103 1.1 skrll case MEP_OPERAND_RN3US : 1104 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn3, 0); 1105 1.1 skrll break; 1106 1.1 skrll case MEP_OPERAND_RNC : 1107 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1108 1.1 skrll break; 1109 1.1 skrll case MEP_OPERAND_RNL : 1110 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1111 1.1 skrll break; 1112 1.1 skrll case MEP_OPERAND_RNS : 1113 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1114 1.1 skrll break; 1115 1.1 skrll case MEP_OPERAND_RNUC : 1116 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1117 1.1 skrll break; 1118 1.1 skrll case MEP_OPERAND_RNUL : 1119 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1120 1.1 skrll break; 1121 1.1 skrll case MEP_OPERAND_RNUS : 1122 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, fields->f_rn, 0); 1123 1.1 skrll break; 1124 1.1 skrll case MEP_OPERAND_SAR : 1125 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_csr, 0, 0); 1126 1.1 skrll break; 1127 1.1 skrll case MEP_OPERAND_SDISP16 : 1128 1.1 skrll print_normal (cd, info, fields->f_16s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1129 1.1 skrll break; 1130 1.1 skrll case MEP_OPERAND_SIMM16 : 1131 1.1 skrll print_normal (cd, info, fields->f_16s16, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1132 1.1.1.2 christos break; 1133 1.1.1.2 christos case MEP_OPERAND_SIMM16P0 : 1134 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_simm16p0, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 1135 1.1 skrll break; 1136 1.1 skrll case MEP_OPERAND_SIMM6 : 1137 1.1 skrll print_normal (cd, info, fields->f_6s8, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1138 1.1 skrll break; 1139 1.1 skrll case MEP_OPERAND_SIMM8 : 1140 1.1 skrll print_normal (cd, info, fields->f_8s8, 0|(1<<CGEN_OPERAND_SIGNED)|(1<<CGEN_OPERAND_RELOC_IMPLIES_OVERFLOW), pc, length); 1141 1.1.1.2 christos break; 1142 1.1.1.2 christos case MEP_OPERAND_SIMM8P0 : 1143 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8s0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1144 1.1.1.2 christos break; 1145 1.1.1.2 christos case MEP_OPERAND_SIMM8P20 : 1146 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8s20, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1147 1.1.1.2 christos break; 1148 1.1.1.2 christos case MEP_OPERAND_SIMM8P4 : 1149 1.1.1.2 christos print_normal (cd, info, fields->f_ivc2_8s4, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1150 1.1 skrll break; 1151 1.1 skrll case MEP_OPERAND_SP : 1152 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1153 1.1 skrll break; 1154 1.1 skrll case MEP_OPERAND_SPR : 1155 1.1 skrll print_spreg (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1156 1.1 skrll break; 1157 1.1 skrll case MEP_OPERAND_TP : 1158 1.1 skrll print_keyword (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1159 1.1 skrll break; 1160 1.1 skrll case MEP_OPERAND_TPR : 1161 1.1 skrll print_tpreg (cd, info, & mep_cgen_opval_h_gpr, 0, 0); 1162 1.1 skrll break; 1163 1.1 skrll case MEP_OPERAND_UDISP2 : 1164 1.1 skrll print_normal (cd, info, fields->f_2u6, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1165 1.1 skrll break; 1166 1.1 skrll case MEP_OPERAND_UDISP7 : 1167 1.1 skrll print_normal (cd, info, fields->f_7u9, 0, pc, length); 1168 1.1 skrll break; 1169 1.1 skrll case MEP_OPERAND_UDISP7A2 : 1170 1.1 skrll print_normal (cd, info, fields->f_7u9a2, 0, pc, length); 1171 1.1 skrll break; 1172 1.1 skrll case MEP_OPERAND_UDISP7A4 : 1173 1.1 skrll print_normal (cd, info, fields->f_7u9a4, 0, pc, length); 1174 1.1 skrll break; 1175 1.1 skrll case MEP_OPERAND_UIMM16 : 1176 1.1 skrll print_normal (cd, info, fields->f_16u16, 0, pc, length); 1177 1.1 skrll break; 1178 1.1 skrll case MEP_OPERAND_UIMM2 : 1179 1.1 skrll print_normal (cd, info, fields->f_2u10, 0, pc, length); 1180 1.1 skrll break; 1181 1.1 skrll case MEP_OPERAND_UIMM24 : 1182 1.1 skrll print_normal (cd, info, fields->f_24u8n, 0|(1<<CGEN_OPERAND_VIRTUAL), pc, length); 1183 1.1 skrll break; 1184 1.1 skrll case MEP_OPERAND_UIMM3 : 1185 1.1 skrll print_normal (cd, info, fields->f_3u5, 0, pc, length); 1186 1.1 skrll break; 1187 1.1 skrll case MEP_OPERAND_UIMM4 : 1188 1.1 skrll print_normal (cd, info, fields->f_4u8, 0, pc, length); 1189 1.1 skrll break; 1190 1.1 skrll case MEP_OPERAND_UIMM5 : 1191 1.1 skrll print_normal (cd, info, fields->f_5u8, 0, pc, length); 1192 1.1 skrll break; 1193 1.1 skrll case MEP_OPERAND_UIMM7A4 : 1194 1.1 skrll print_normal (cd, info, fields->f_7u9a4, 0, pc, length); 1195 1.1 skrll break; 1196 1.1 skrll case MEP_OPERAND_ZERO : 1197 1.1 skrll print_normal (cd, info, 0, 0|(1<<CGEN_OPERAND_SIGNED), pc, length); 1198 1.1 skrll break; 1199 1.1 skrll 1200 1.1 skrll default : 1201 1.1.1.6 christos /* xgettext:c-format */ 1202 1.1.1.6 christos opcodes_error_handler 1203 1.1.1.6 christos (_("internal error: unrecognized field %d while printing insn"), 1204 1.1.1.6 christos opindex); 1205 1.1 skrll abort (); 1206 1.1 skrll } 1207 1.1 skrll } 1208 1.1.1.3 christos 1209 1.1 skrll cgen_print_fn * const mep_cgen_print_handlers[] = 1210 1.1 skrll { 1211 1.1 skrll print_insn_normal, 1212 1.1 skrll }; 1213 1.1 skrll 1214 1.1 skrll 1215 1.1 skrll void 1216 1.1 skrll mep_cgen_init_dis (CGEN_CPU_DESC cd) 1217 1.1 skrll { 1218 1.1 skrll mep_cgen_init_opcode_table (cd); 1219 1.1 skrll mep_cgen_init_ibld_table (cd); 1220 1.1 skrll cd->print_handlers = & mep_cgen_print_handlers[0]; 1221 1.1 skrll cd->print_operand = mep_cgen_print_operand; 1222 1.1 skrll } 1223 1.1 skrll 1224 1.1 skrll 1225 1.1 skrll /* Default print handler. */ 1227 1.1 skrll 1228 1.1 skrll static void 1229 1.1 skrll print_normal (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1230 1.1 skrll void *dis_info, 1231 1.1 skrll long value, 1232 1.1 skrll unsigned int attrs, 1233 1.1 skrll bfd_vma pc ATTRIBUTE_UNUSED, 1234 1.1 skrll int length ATTRIBUTE_UNUSED) 1235 1.1 skrll { 1236 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 1237 1.1 skrll 1238 1.1 skrll /* Print the operand as directed by the attributes. */ 1239 1.1 skrll if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) 1240 1.1 skrll ; /* nothing to do */ 1241 1.1 skrll else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) 1242 1.1 skrll (*info->fprintf_func) (info->stream, "%ld", value); 1243 1.1 skrll else 1244 1.1 skrll (*info->fprintf_func) (info->stream, "0x%lx", value); 1245 1.1 skrll } 1246 1.1 skrll 1247 1.1 skrll /* Default address handler. */ 1248 1.1 skrll 1249 1.1 skrll static void 1250 1.1 skrll print_address (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1251 1.1 skrll void *dis_info, 1252 1.1 skrll bfd_vma value, 1253 1.1 skrll unsigned int attrs, 1254 1.1 skrll bfd_vma pc ATTRIBUTE_UNUSED, 1255 1.1 skrll int length ATTRIBUTE_UNUSED) 1256 1.1 skrll { 1257 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 1258 1.1 skrll 1259 1.1 skrll /* Print the operand as directed by the attributes. */ 1260 1.1 skrll if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SEM_ONLY)) 1261 1.1 skrll ; /* Nothing to do. */ 1262 1.1 skrll else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_PCREL_ADDR)) 1263 1.1 skrll (*info->print_address_func) (value, info); 1264 1.1 skrll else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_ABS_ADDR)) 1265 1.1 skrll (*info->print_address_func) (value, info); 1266 1.1 skrll else if (CGEN_BOOL_ATTR (attrs, CGEN_OPERAND_SIGNED)) 1267 1.1 skrll (*info->fprintf_func) (info->stream, "%ld", (long) value); 1268 1.1 skrll else 1269 1.1 skrll (*info->fprintf_func) (info->stream, "0x%lx", (long) value); 1270 1.1 skrll } 1271 1.1 skrll 1272 1.1 skrll /* Keyword print handler. */ 1273 1.1 skrll 1274 1.1 skrll static void 1275 1.1 skrll print_keyword (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1276 1.1 skrll void *dis_info, 1277 1.1 skrll CGEN_KEYWORD *keyword_table, 1278 1.1 skrll long value, 1279 1.1 skrll unsigned int attrs ATTRIBUTE_UNUSED) 1280 1.1 skrll { 1281 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 1282 1.1 skrll const CGEN_KEYWORD_ENTRY *ke; 1283 1.1 skrll 1284 1.1 skrll ke = cgen_keyword_lookup_value (keyword_table, value); 1285 1.1 skrll if (ke != NULL) 1286 1.1 skrll (*info->fprintf_func) (info->stream, "%s", ke->name); 1287 1.1 skrll else 1288 1.1 skrll (*info->fprintf_func) (info->stream, "???"); 1289 1.1 skrll } 1290 1.1 skrll 1291 1.1 skrll /* Default insn printer. 1293 1.1 skrll 1294 1.1 skrll DIS_INFO is defined as `void *' so the disassembler needn't know anything 1295 1.1 skrll about disassemble_info. */ 1296 1.1 skrll 1297 1.1 skrll static void 1298 1.1 skrll print_insn_normal (CGEN_CPU_DESC cd, 1299 1.1 skrll void *dis_info, 1300 1.1 skrll const CGEN_INSN *insn, 1301 1.1 skrll CGEN_FIELDS *fields, 1302 1.1 skrll bfd_vma pc, 1303 1.1 skrll int length) 1304 1.1 skrll { 1305 1.1 skrll const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 1306 1.1 skrll disassemble_info *info = (disassemble_info *) dis_info; 1307 1.1 skrll const CGEN_SYNTAX_CHAR_TYPE *syn; 1308 1.1 skrll 1309 1.1 skrll CGEN_INIT_PRINT (cd); 1310 1.1 skrll 1311 1.1 skrll for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) 1312 1.1 skrll { 1313 1.1 skrll if (CGEN_SYNTAX_MNEMONIC_P (*syn)) 1314 1.1 skrll { 1315 1.1 skrll (*info->fprintf_func) (info->stream, "%s", CGEN_INSN_MNEMONIC (insn)); 1316 1.1 skrll continue; 1317 1.1 skrll } 1318 1.1 skrll if (CGEN_SYNTAX_CHAR_P (*syn)) 1319 1.1 skrll { 1320 1.1 skrll (*info->fprintf_func) (info->stream, "%c", CGEN_SYNTAX_CHAR (*syn)); 1321 1.1 skrll continue; 1322 1.1 skrll } 1323 1.1 skrll 1324 1.1 skrll /* We have an operand. */ 1325 1.1 skrll mep_cgen_print_operand (cd, CGEN_SYNTAX_FIELD (*syn), info, 1326 1.1 skrll fields, CGEN_INSN_ATTRS (insn), pc, length); 1327 1.1 skrll } 1328 1.1 skrll } 1329 1.1 skrll 1330 1.1 skrll /* Subroutine of print_insn. Reads an insn into the given buffers and updates 1332 1.1 skrll the extract info. 1333 1.1 skrll Returns 0 if all is well, non-zero otherwise. */ 1334 1.1 skrll 1335 1.1 skrll static int 1336 1.1 skrll read_insn (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1337 1.1 skrll bfd_vma pc, 1338 1.1 skrll disassemble_info *info, 1339 1.1 skrll bfd_byte *buf, 1340 1.1 skrll int buflen, 1341 1.1 skrll CGEN_EXTRACT_INFO *ex_info, 1342 1.1 skrll unsigned long *insn_value) 1343 1.1 skrll { 1344 1.1 skrll int status = (*info->read_memory_func) (pc, buf, buflen, info); 1345 1.1 skrll 1346 1.1 skrll if (status != 0) 1347 1.1 skrll { 1348 1.1 skrll (*info->memory_error_func) (status, pc, info); 1349 1.1 skrll return -1; 1350 1.1 skrll } 1351 1.1 skrll 1352 1.1 skrll ex_info->dis_info = info; 1353 1.1 skrll ex_info->valid = (1 << buflen) - 1; 1354 1.1 skrll ex_info->insn_bytes = buf; 1355 1.1 skrll 1356 1.1 skrll *insn_value = bfd_get_bits (buf, buflen * 8, info->endian == BFD_ENDIAN_BIG); 1357 1.1 skrll return 0; 1358 1.1 skrll } 1359 1.1 skrll 1360 1.1 skrll /* Utility to print an insn. 1361 1.1 skrll BUF is the base part of the insn, target byte order, BUFLEN bytes long. 1362 1.1 skrll The result is the size of the insn in bytes or zero for an unknown insn 1363 1.1 skrll or -1 if an error occurs fetching data (memory_error_func will have 1364 1.1 skrll been called). */ 1365 1.1 skrll 1366 1.1 skrll static int 1367 1.1 skrll print_insn (CGEN_CPU_DESC cd, 1368 1.1 skrll bfd_vma pc, 1369 1.1 skrll disassemble_info *info, 1370 1.1 skrll bfd_byte *buf, 1371 1.1 skrll unsigned int buflen) 1372 1.1 skrll { 1373 1.1 skrll CGEN_INSN_INT insn_value; 1374 1.1 skrll const CGEN_INSN_LIST *insn_list; 1375 1.1 skrll CGEN_EXTRACT_INFO ex_info; 1376 1.1 skrll int basesize; 1377 1.1.1.8 christos 1378 1.1 skrll /* Extract base part of instruction, just in case CGEN_DIS_* uses it. */ 1379 1.1 skrll basesize = cd->base_insn_bitsize < buflen * 8 ? 1380 1.1 skrll cd->base_insn_bitsize : buflen * 8; 1381 1.1 skrll insn_value = cgen_get_insn_value (cd, buf, basesize, cd->insn_endian); 1382 1.1 skrll 1383 1.1 skrll 1384 1.1 skrll /* Fill in ex_info fields like read_insn would. Don't actually call 1385 1.1 skrll read_insn, since the incoming buffer is already read (and possibly 1386 1.1 skrll modified a la m32r). */ 1387 1.1 skrll ex_info.valid = (1 << buflen) - 1; 1388 1.1 skrll ex_info.dis_info = info; 1389 1.1 skrll ex_info.insn_bytes = buf; 1390 1.1 skrll 1391 1.1 skrll /* The instructions are stored in hash lists. 1392 1.1 skrll Pick the first one and keep trying until we find the right one. */ 1393 1.1 skrll 1394 1.1 skrll insn_list = CGEN_DIS_LOOKUP_INSN (cd, (char *) buf, insn_value); 1395 1.1 skrll while (insn_list != NULL) 1396 1.1 skrll { 1397 1.1 skrll const CGEN_INSN *insn = insn_list->insn; 1398 1.1.1.3 christos CGEN_FIELDS fields; 1399 1.1 skrll int length; 1400 1.1 skrll unsigned long insn_value_cropped; 1401 1.1 skrll 1402 1.1 skrll #ifdef CGEN_VALIDATE_INSN_SUPPORTED 1403 1.1 skrll /* Not needed as insn shouldn't be in hash lists if not supported. */ 1404 1.1 skrll /* Supported by this cpu? */ 1405 1.1 skrll if (! mep_cgen_insn_supported (cd, insn)) 1406 1.1 skrll { 1407 1.1 skrll insn_list = CGEN_DIS_NEXT_INSN (insn_list); 1408 1.1 skrll continue; 1409 1.1 skrll } 1410 1.1 skrll #endif 1411 1.1 skrll 1412 1.1 skrll /* Basic bit mask must be correct. */ 1413 1.1 skrll /* ??? May wish to allow target to defer this check until the extract 1414 1.1 skrll handler. */ 1415 1.1 skrll 1416 1.1.1.3 christos /* Base size may exceed this instruction's size. Extract the 1417 1.1 skrll relevant part from the buffer. */ 1418 1.1 skrll if ((unsigned) (CGEN_INSN_BITSIZE (insn) / 8) < buflen && 1419 1.1 skrll (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) 1420 1.1 skrll insn_value_cropped = bfd_get_bits (buf, CGEN_INSN_BITSIZE (insn), 1421 1.1 skrll info->endian == BFD_ENDIAN_BIG); 1422 1.1 skrll else 1423 1.1 skrll insn_value_cropped = insn_value; 1424 1.1 skrll 1425 1.1 skrll if ((insn_value_cropped & CGEN_INSN_BASE_MASK (insn)) 1426 1.1 skrll == CGEN_INSN_BASE_VALUE (insn)) 1427 1.1 skrll { 1428 1.1 skrll /* Printing is handled in two passes. The first pass parses the 1429 1.1 skrll machine insn and extracts the fields. The second pass prints 1430 1.1 skrll them. */ 1431 1.1 skrll 1432 1.1 skrll /* Make sure the entire insn is loaded into insn_value, if it 1433 1.1 skrll can fit. */ 1434 1.1 skrll if (((unsigned) CGEN_INSN_BITSIZE (insn) > cd->base_insn_bitsize) && 1435 1.1 skrll (unsigned) (CGEN_INSN_BITSIZE (insn) / 8) <= sizeof (unsigned long)) 1436 1.1 skrll { 1437 1.1 skrll unsigned long full_insn_value; 1438 1.1 skrll int rc = read_insn (cd, pc, info, buf, 1439 1.1 skrll CGEN_INSN_BITSIZE (insn) / 8, 1440 1.1 skrll & ex_info, & full_insn_value); 1441 1.1 skrll if (rc != 0) 1442 1.1 skrll return rc; 1443 1.1 skrll length = CGEN_EXTRACT_FN (cd, insn) 1444 1.1 skrll (cd, insn, &ex_info, full_insn_value, &fields, pc); 1445 1.1 skrll } 1446 1.1 skrll else 1447 1.1 skrll length = CGEN_EXTRACT_FN (cd, insn) 1448 1.1 skrll (cd, insn, &ex_info, insn_value_cropped, &fields, pc); 1449 1.1 skrll 1450 1.1 skrll /* Length < 0 -> error. */ 1451 1.1 skrll if (length < 0) 1452 1.1 skrll return length; 1453 1.1 skrll if (length > 0) 1454 1.1 skrll { 1455 1.1 skrll CGEN_PRINT_FN (cd, insn) (cd, info, insn, &fields, pc, length); 1456 1.1 skrll /* Length is in bits, result is in bytes. */ 1457 1.1 skrll return length / 8; 1458 1.1 skrll } 1459 1.1 skrll } 1460 1.1 skrll 1461 1.1 skrll insn_list = CGEN_DIS_NEXT_INSN (insn_list); 1462 1.1 skrll } 1463 1.1 skrll 1464 1.1 skrll return 0; 1465 1.1 skrll } 1466 1.1 skrll 1467 1.1 skrll /* Default value for CGEN_PRINT_INSN. 1468 1.1 skrll The result is the size of the insn in bytes or zero for an unknown insn 1469 1.1 skrll or -1 if an error occured fetching bytes. */ 1470 1.1 skrll 1471 1.1 skrll #ifndef CGEN_PRINT_INSN 1472 1.1 skrll #define CGEN_PRINT_INSN default_print_insn 1473 1.1 skrll #endif 1474 1.1 skrll 1475 1.1 skrll static int 1476 1.1 skrll default_print_insn (CGEN_CPU_DESC cd, bfd_vma pc, disassemble_info *info) 1477 1.1 skrll { 1478 1.1 skrll bfd_byte buf[CGEN_MAX_INSN_SIZE]; 1479 1.1 skrll int buflen; 1480 1.1 skrll int status; 1481 1.1 skrll 1482 1.1 skrll /* Attempt to read the base part of the insn. */ 1483 1.1 skrll buflen = cd->base_insn_bitsize / 8; 1484 1.1 skrll status = (*info->read_memory_func) (pc, buf, buflen, info); 1485 1.1 skrll 1486 1.1 skrll /* Try again with the minimum part, if min < base. */ 1487 1.1 skrll if (status != 0 && (cd->min_insn_bitsize < cd->base_insn_bitsize)) 1488 1.1 skrll { 1489 1.1 skrll buflen = cd->min_insn_bitsize / 8; 1490 1.1 skrll status = (*info->read_memory_func) (pc, buf, buflen, info); 1491 1.1 skrll } 1492 1.1 skrll 1493 1.1 skrll if (status != 0) 1494 1.1 skrll { 1495 1.1 skrll (*info->memory_error_func) (status, pc, info); 1496 1.1 skrll return -1; 1497 1.1 skrll } 1498 1.1 skrll 1499 1.1 skrll return print_insn (cd, pc, info, buf, buflen); 1500 1.1 skrll } 1501 1.1 skrll 1502 1.1 skrll /* Main entry point. 1503 1.1 skrll Print one instruction from PC on INFO->STREAM. 1504 1.1 skrll Return the size of the instruction (in bytes). */ 1505 1.1 skrll 1506 1.1 skrll typedef struct cpu_desc_list 1507 1.1 skrll { 1508 1.1.1.8 christos struct cpu_desc_list *next; 1509 1.1 skrll CGEN_BITSET *isa; 1510 1.1 skrll int mach; 1511 1.1 skrll int endian; 1512 1.1 skrll int insn_endian; 1513 1.1 skrll CGEN_CPU_DESC cd; 1514 1.1 skrll } cpu_desc_list; 1515 1.1 skrll 1516 1.1 skrll int 1517 1.1 skrll print_insn_mep (bfd_vma pc, disassemble_info *info) 1518 1.1 skrll { 1519 1.1 skrll static cpu_desc_list *cd_list = 0; 1520 1.1 skrll cpu_desc_list *cl = 0; 1521 1.1.1.8 christos static CGEN_CPU_DESC cd = 0; 1522 1.1 skrll static CGEN_BITSET *prev_isa; 1523 1.1 skrll static int prev_mach; 1524 1.1 skrll static int prev_endian; 1525 1.1 skrll static int prev_insn_endian; 1526 1.1 skrll int length; 1527 1.1 skrll CGEN_BITSET *isa; 1528 1.1.1.8 christos int mach; 1529 1.1.1.8 christos int endian = (info->endian == BFD_ENDIAN_BIG 1530 1.1.1.8 christos ? CGEN_ENDIAN_BIG 1531 1.1 skrll : CGEN_ENDIAN_LITTLE); 1532 1.1 skrll int insn_endian = (info->endian_code == BFD_ENDIAN_BIG 1533 1.1 skrll ? CGEN_ENDIAN_BIG 1534 1.1 skrll : CGEN_ENDIAN_LITTLE); 1535 1.1 skrll enum bfd_architecture arch; 1536 1.1 skrll 1537 1.1 skrll /* ??? gdb will set mach but leave the architecture as "unknown" */ 1538 1.1 skrll #ifndef CGEN_BFD_ARCH 1539 1.1 skrll #define CGEN_BFD_ARCH bfd_arch_mep 1540 1.1.1.3 christos #endif 1541 1.1 skrll arch = info->arch; 1542 1.1 skrll if (arch == bfd_arch_unknown) 1543 1.1 skrll arch = CGEN_BFD_ARCH; 1544 1.1 skrll 1545 1.1 skrll /* There's no standard way to compute the machine or isa number 1546 1.1 skrll so we leave it to the target. */ 1547 1.1 skrll #ifdef CGEN_COMPUTE_MACH 1548 1.1 skrll mach = CGEN_COMPUTE_MACH (info); 1549 1.1 skrll #else 1550 1.1 skrll mach = info->mach; 1551 1.1 skrll #endif 1552 1.1 skrll 1553 1.1 skrll #ifdef CGEN_COMPUTE_ISA 1554 1.1 skrll { 1555 1.1 skrll static CGEN_BITSET *permanent_isa; 1556 1.1 skrll 1557 1.1 skrll if (!permanent_isa) 1558 1.1 skrll permanent_isa = cgen_bitset_create (MAX_ISAS); 1559 1.1 skrll isa = permanent_isa; 1560 1.1.1.7 christos cgen_bitset_clear (isa); 1561 1.1 skrll cgen_bitset_add (isa, CGEN_COMPUTE_ISA (info)); 1562 1.1 skrll } 1563 1.1 skrll #else 1564 1.1 skrll isa = info->private_data; 1565 1.1 skrll #endif 1566 1.1 skrll 1567 1.1 skrll /* If we've switched cpu's, try to find a handle we've used before */ 1568 1.1 skrll if (cd 1569 1.1 skrll && (cgen_bitset_compare (isa, prev_isa) != 0 1570 1.1 skrll || mach != prev_mach 1571 1.1 skrll || endian != prev_endian)) 1572 1.1 skrll { 1573 1.1 skrll cd = 0; 1574 1.1 skrll for (cl = cd_list; cl; cl = cl->next) 1575 1.1 skrll { 1576 1.1 skrll if (cgen_bitset_compare (cl->isa, isa) == 0 && 1577 1.1 skrll cl->mach == mach && 1578 1.1 skrll cl->endian == endian) 1579 1.1 skrll { 1580 1.1 skrll cd = cl->cd; 1581 1.1.1.3 christos prev_isa = cd->isas; 1582 1.1 skrll break; 1583 1.1 skrll } 1584 1.1 skrll } 1585 1.1 skrll } 1586 1.1 skrll 1587 1.1 skrll /* If we haven't initialized yet, initialize the opcode table. */ 1588 1.1 skrll if (! cd) 1589 1.1 skrll { 1590 1.1 skrll const bfd_arch_info_type *arch_type = bfd_lookup_arch (arch, mach); 1591 1.1 skrll const char *mach_name; 1592 1.1 skrll 1593 1.1 skrll if (!arch_type) 1594 1.1 skrll abort (); 1595 1.1 skrll mach_name = arch_type->printable_name; 1596 1.1.1.8 christos 1597 1.1 skrll prev_isa = cgen_bitset_copy (isa); 1598 1.1 skrll prev_mach = mach; 1599 1.1 skrll prev_endian = endian; 1600 1.1.1.8 christos prev_insn_endian = insn_endian; 1601 1.1 skrll cd = mep_cgen_cpu_open (CGEN_CPU_OPEN_ISAS, prev_isa, 1602 1.1 skrll CGEN_CPU_OPEN_BFDMACH, mach_name, 1603 1.1 skrll CGEN_CPU_OPEN_ENDIAN, prev_endian, 1604 1.1 skrll CGEN_CPU_OPEN_INSN_ENDIAN, prev_insn_endian, 1605 1.1 skrll CGEN_CPU_OPEN_END); 1606 1.1 skrll if (!cd) 1607 1.1 skrll abort (); 1608 1.1 skrll 1609 1.1 skrll /* Save this away for future reference. */ 1610 1.1 skrll cl = xmalloc (sizeof (struct cpu_desc_list)); 1611 1.1 skrll cl->cd = cd; 1612 1.1 skrll cl->isa = prev_isa; 1613 1.1 skrll cl->mach = mach; 1614 1.1 skrll cl->endian = endian; 1615 1.1 skrll cl->next = cd_list; 1616 1.1 skrll cd_list = cl; 1617 1.1 skrll 1618 1.1 skrll mep_cgen_init_dis (cd); 1619 1.1 skrll } 1620 1.1 skrll 1621 1.1 skrll /* We try to have as much common code as possible. 1622 1.1 skrll But at this point some targets need to take over. */ 1623 1.1 skrll /* ??? Some targets may need a hook elsewhere. Try to avoid this, 1624 1.1 skrll but if not possible try to move this hook elsewhere rather than 1625 1.1 skrll have two hooks. */ 1626 1.1 skrll length = CGEN_PRINT_INSN (cd, pc, info); 1627 1.1 skrll if (length > 0) 1628 1.1 skrll return length; 1629 1.1 skrll if (length < 0) 1630 1.1 skrll return -1; 1631 1632 (*info->fprintf_func) (info->stream, UNKNOWN_INSN_MSG); 1633 return cd->default_insn_bitsize / 8; 1634 } 1635