1 /* Instruction building/extraction support for iq2000. -*- C -*- 2 3 THIS FILE IS MACHINE GENERATED WITH CGEN: Cpu tools GENerator. 4 - the resultant file is machine generated, cgen-ibld.in isn't 5 6 Copyright (C) 1996-2014 Free Software Foundation, Inc. 7 8 This file is part of libopcodes. 9 10 This library is free software; you can redistribute it and/or modify 11 it under the terms of the GNU General Public License as published by 12 the Free Software Foundation; either version 3, or (at your option) 13 any later version. 14 15 It is distributed in the hope that it will be useful, but WITHOUT 16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 17 or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public 18 License for more details. 19 20 You should have received a copy of the GNU General Public License 21 along with this program; if not, write to the Free Software Foundation, Inc., 22 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ 23 24 /* ??? Eventually more and more of this stuff can go to cpu-independent files. 25 Keep that in mind. */ 26 27 #include "sysdep.h" 28 #include <stdio.h> 29 #include "ansidecl.h" 30 #include "dis-asm.h" 31 #include "bfd.h" 32 #include "symcat.h" 33 #include "iq2000-desc.h" 34 #include "iq2000-opc.h" 35 #include "cgen/basic-modes.h" 36 #include "opintl.h" 37 #include "safe-ctype.h" 38 39 #undef min 40 #define min(a,b) ((a) < (b) ? (a) : (b)) 41 #undef max 42 #define max(a,b) ((a) > (b) ? (a) : (b)) 43 44 /* Used by the ifield rtx function. */ 45 #define FLD(f) (fields->f) 46 47 static const char * insert_normal 48 (CGEN_CPU_DESC, long, unsigned int, unsigned int, unsigned int, 49 unsigned int, unsigned int, unsigned int, CGEN_INSN_BYTES_PTR); 50 static const char * insert_insn_normal 51 (CGEN_CPU_DESC, const CGEN_INSN *, 52 CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); 53 static int extract_normal 54 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, 55 unsigned int, unsigned int, unsigned int, unsigned int, 56 unsigned int, unsigned int, bfd_vma, long *); 57 static int extract_insn_normal 58 (CGEN_CPU_DESC, const CGEN_INSN *, CGEN_EXTRACT_INFO *, 59 CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); 60 #if CGEN_INT_INSN_P 61 static void put_insn_int_value 62 (CGEN_CPU_DESC, CGEN_INSN_BYTES_PTR, int, int, CGEN_INSN_INT); 63 #endif 64 #if ! CGEN_INT_INSN_P 65 static CGEN_INLINE void insert_1 66 (CGEN_CPU_DESC, unsigned long, int, int, int, unsigned char *); 67 static CGEN_INLINE int fill_cache 68 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, bfd_vma); 69 static CGEN_INLINE long extract_1 70 (CGEN_CPU_DESC, CGEN_EXTRACT_INFO *, int, int, int, unsigned char *, bfd_vma); 71 #endif 72 73 /* Operand insertion. */ 75 76 #if ! CGEN_INT_INSN_P 77 78 /* Subroutine of insert_normal. */ 79 80 static CGEN_INLINE void 81 insert_1 (CGEN_CPU_DESC cd, 82 unsigned long value, 83 int start, 84 int length, 85 int word_length, 86 unsigned char *bufp) 87 { 88 unsigned long x,mask; 89 int shift; 90 91 x = cgen_get_insn_value (cd, bufp, word_length); 92 93 /* Written this way to avoid undefined behaviour. */ 94 mask = (((1L << (length - 1)) - 1) << 1) | 1; 95 if (CGEN_INSN_LSB0_P) 96 shift = (start + 1) - length; 97 else 98 shift = (word_length - (start + length)); 99 x = (x & ~(mask << shift)) | ((value & mask) << shift); 100 101 cgen_put_insn_value (cd, bufp, word_length, (bfd_vma) x); 102 } 103 104 #endif /* ! CGEN_INT_INSN_P */ 105 106 /* Default insertion routine. 107 108 ATTRS is a mask of the boolean attributes. 109 WORD_OFFSET is the offset in bits from the start of the insn of the value. 110 WORD_LENGTH is the length of the word in bits in which the value resides. 111 START is the starting bit number in the word, architecture origin. 112 LENGTH is the length of VALUE in bits. 113 TOTAL_LENGTH is the total length of the insn in bits. 114 115 The result is an error message or NULL if success. */ 116 117 /* ??? This duplicates functionality with bfd's howto table and 118 bfd_install_relocation. */ 119 /* ??? This doesn't handle bfd_vma's. Create another function when 120 necessary. */ 121 122 static const char * 123 insert_normal (CGEN_CPU_DESC cd, 124 long value, 125 unsigned int attrs, 126 unsigned int word_offset, 127 unsigned int start, 128 unsigned int length, 129 unsigned int word_length, 130 unsigned int total_length, 131 CGEN_INSN_BYTES_PTR buffer) 132 { 133 static char errbuf[100]; 134 /* Written this way to avoid undefined behaviour. */ 135 unsigned long mask = (((1L << (length - 1)) - 1) << 1) | 1; 136 137 /* If LENGTH is zero, this operand doesn't contribute to the value. */ 138 if (length == 0) 139 return NULL; 140 141 if (word_length > 8 * sizeof (CGEN_INSN_INT)) 142 abort (); 143 144 /* For architectures with insns smaller than the base-insn-bitsize, 145 word_length may be too big. */ 146 if (cd->min_insn_bitsize < cd->base_insn_bitsize) 147 { 148 if (word_offset == 0 149 && word_length > total_length) 150 word_length = total_length; 151 } 152 153 /* Ensure VALUE will fit. */ 154 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGN_OPT)) 155 { 156 long minval = - (1L << (length - 1)); 157 unsigned long maxval = mask; 158 159 if ((value > 0 && (unsigned long) value > maxval) 160 || value < minval) 161 { 162 /* xgettext:c-format */ 163 sprintf (errbuf, 164 _("operand out of range (%ld not between %ld and %lu)"), 165 value, minval, maxval); 166 return errbuf; 167 } 168 } 169 else if (! CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED)) 170 { 171 unsigned long maxval = mask; 172 unsigned long val = (unsigned long) value; 173 174 /* For hosts with a word size > 32 check to see if value has been sign 175 extended beyond 32 bits. If so then ignore these higher sign bits 176 as the user is attempting to store a 32-bit signed value into an 177 unsigned 32-bit field which is allowed. */ 178 if (sizeof (unsigned long) > 4 && ((value >> 32) == -1)) 179 val &= 0xFFFFFFFF; 180 181 if (val > maxval) 182 { 183 /* xgettext:c-format */ 184 sprintf (errbuf, 185 _("operand out of range (0x%lx not between 0 and 0x%lx)"), 186 val, maxval); 187 return errbuf; 188 } 189 } 190 else 191 { 192 if (! cgen_signed_overflow_ok_p (cd)) 193 { 194 long minval = - (1L << (length - 1)); 195 long maxval = (1L << (length - 1)) - 1; 196 197 if (value < minval || value > maxval) 198 { 199 sprintf 200 /* xgettext:c-format */ 201 (errbuf, _("operand out of range (%ld not between %ld and %ld)"), 202 value, minval, maxval); 203 return errbuf; 204 } 205 } 206 } 207 208 #if CGEN_INT_INSN_P 209 210 { 211 int shift; 212 213 if (CGEN_INSN_LSB0_P) 214 shift = (word_offset + start + 1) - length; 215 else 216 shift = total_length - (word_offset + start + length); 217 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); 218 } 219 220 #else /* ! CGEN_INT_INSN_P */ 221 222 { 223 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; 224 225 insert_1 (cd, value, start, length, word_length, bufp); 226 } 227 228 #endif /* ! CGEN_INT_INSN_P */ 229 230 return NULL; 231 } 232 233 /* Default insn builder (insert handler). 234 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning 235 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is 236 recorded in host byte order, otherwise BUFFER is an array of bytes 237 and the value is recorded in target byte order). 238 The result is an error message or NULL if success. */ 239 240 static const char * 241 insert_insn_normal (CGEN_CPU_DESC cd, 242 const CGEN_INSN * insn, 243 CGEN_FIELDS * fields, 244 CGEN_INSN_BYTES_PTR buffer, 245 bfd_vma pc) 246 { 247 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 248 unsigned long value; 249 const CGEN_SYNTAX_CHAR_TYPE * syn; 250 251 CGEN_INIT_INSERT (cd); 252 value = CGEN_INSN_BASE_VALUE (insn); 253 254 /* If we're recording insns as numbers (rather than a string of bytes), 255 target byte order handling is deferred until later. */ 256 257 #if CGEN_INT_INSN_P 258 259 put_insn_int_value (cd, buffer, cd->base_insn_bitsize, 260 CGEN_FIELDS_BITSIZE (fields), value); 261 262 #else 263 264 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, 265 (unsigned) CGEN_FIELDS_BITSIZE (fields)), 266 value); 267 268 #endif /* ! CGEN_INT_INSN_P */ 269 270 /* ??? It would be better to scan the format's fields. 271 Still need to be able to insert a value based on the operand though; 272 e.g. storing a branch displacement that got resolved later. 273 Needs more thought first. */ 274 275 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) 276 { 277 const char *errmsg; 278 279 if (CGEN_SYNTAX_CHAR_P (* syn)) 280 continue; 281 282 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), 283 fields, buffer, pc); 284 if (errmsg) 285 return errmsg; 286 } 287 288 return NULL; 289 } 290 291 #if CGEN_INT_INSN_P 292 /* Cover function to store an insn value into an integral insn. Must go here 293 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */ 294 295 static void 296 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 297 CGEN_INSN_BYTES_PTR buf, 298 int length, 299 int insn_length, 300 CGEN_INSN_INT value) 301 { 302 /* For architectures with insns smaller than the base-insn-bitsize, 303 length may be too big. */ 304 if (length > insn_length) 305 *buf = value; 306 else 307 { 308 int shift = insn_length - length; 309 /* Written this way to avoid undefined behaviour. */ 310 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; 311 312 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); 313 } 314 } 315 #endif 316 317 /* Operand extraction. */ 319 320 #if ! CGEN_INT_INSN_P 321 322 /* Subroutine of extract_normal. 323 Ensure sufficient bytes are cached in EX_INFO. 324 OFFSET is the offset in bytes from the start of the insn of the value. 325 BYTES is the length of the needed value. 326 Returns 1 for success, 0 for failure. */ 327 328 static CGEN_INLINE int 329 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 330 CGEN_EXTRACT_INFO *ex_info, 331 int offset, 332 int bytes, 333 bfd_vma pc) 334 { 335 /* It's doubtful that the middle part has already been fetched so 336 we don't optimize that case. kiss. */ 337 unsigned int mask; 338 disassemble_info *info = (disassemble_info *) ex_info->dis_info; 339 340 /* First do a quick check. */ 341 mask = (1 << bytes) - 1; 342 if (((ex_info->valid >> offset) & mask) == mask) 343 return 1; 344 345 /* Search for the first byte we need to read. */ 346 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) 347 if (! (mask & ex_info->valid)) 348 break; 349 350 if (bytes) 351 { 352 int status; 353 354 pc += offset; 355 status = (*info->read_memory_func) 356 (pc, ex_info->insn_bytes + offset, bytes, info); 357 358 if (status != 0) 359 { 360 (*info->memory_error_func) (status, pc, info); 361 return 0; 362 } 363 364 ex_info->valid |= ((1 << bytes) - 1) << offset; 365 } 366 367 return 1; 368 } 369 370 /* Subroutine of extract_normal. */ 371 372 static CGEN_INLINE long 373 extract_1 (CGEN_CPU_DESC cd, 374 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, 375 int start, 376 int length, 377 int word_length, 378 unsigned char *bufp, 379 bfd_vma pc ATTRIBUTE_UNUSED) 380 { 381 unsigned long x; 382 int shift; 383 384 x = cgen_get_insn_value (cd, bufp, word_length); 385 386 if (CGEN_INSN_LSB0_P) 387 shift = (start + 1) - length; 388 else 389 shift = (word_length - (start + length)); 390 return x >> shift; 391 } 392 393 #endif /* ! CGEN_INT_INSN_P */ 394 395 /* Default extraction routine. 396 397 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, 398 or sometimes less for cases like the m32r where the base insn size is 32 399 but some insns are 16 bits. 400 ATTRS is a mask of the boolean attributes. We only need `SIGNED', 401 but for generality we take a bitmask of all of them. 402 WORD_OFFSET is the offset in bits from the start of the insn of the value. 403 WORD_LENGTH is the length of the word in bits in which the value resides. 404 START is the starting bit number in the word, architecture origin. 405 LENGTH is the length of VALUE in bits. 406 TOTAL_LENGTH is the total length of the insn in bits. 407 408 Returns 1 for success, 0 for failure. */ 409 410 /* ??? The return code isn't properly used. wip. */ 411 412 /* ??? This doesn't handle bfd_vma's. Create another function when 413 necessary. */ 414 415 static int 416 extract_normal (CGEN_CPU_DESC cd, 417 #if ! CGEN_INT_INSN_P 418 CGEN_EXTRACT_INFO *ex_info, 419 #else 420 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, 421 #endif 422 CGEN_INSN_INT insn_value, 423 unsigned int attrs, 424 unsigned int word_offset, 425 unsigned int start, 426 unsigned int length, 427 unsigned int word_length, 428 unsigned int total_length, 429 #if ! CGEN_INT_INSN_P 430 bfd_vma pc, 431 #else 432 bfd_vma pc ATTRIBUTE_UNUSED, 433 #endif 434 long *valuep) 435 { 436 long value, mask; 437 438 /* If LENGTH is zero, this operand doesn't contribute to the value 439 so give it a standard value of zero. */ 440 if (length == 0) 441 { 442 *valuep = 0; 443 return 1; 444 } 445 446 if (word_length > 8 * sizeof (CGEN_INSN_INT)) 447 abort (); 448 449 /* For architectures with insns smaller than the insn-base-bitsize, 450 word_length may be too big. */ 451 if (cd->min_insn_bitsize < cd->base_insn_bitsize) 452 { 453 if (word_offset + word_length > total_length) 454 word_length = total_length - word_offset; 455 } 456 457 /* Does the value reside in INSN_VALUE, and at the right alignment? */ 458 459 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) 460 { 461 if (CGEN_INSN_LSB0_P) 462 value = insn_value >> ((word_offset + start + 1) - length); 463 else 464 value = insn_value >> (total_length - ( word_offset + start + length)); 465 } 466 467 #if ! CGEN_INT_INSN_P 468 469 else 470 { 471 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; 472 473 if (word_length > 8 * sizeof (CGEN_INSN_INT)) 474 abort (); 475 476 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) 477 return 0; 478 479 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); 480 } 481 482 #endif /* ! CGEN_INT_INSN_P */ 483 484 /* Written this way to avoid undefined behaviour. */ 485 mask = (((1L << (length - 1)) - 1) << 1) | 1; 486 487 value &= mask; 488 /* sign extend? */ 489 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) 490 && (value & (1L << (length - 1)))) 491 value |= ~mask; 492 493 *valuep = value; 494 495 return 1; 496 } 497 498 /* Default insn extractor. 499 500 INSN_VALUE is the first base_insn_bitsize bits, translated to host order. 501 The extracted fields are stored in FIELDS. 502 EX_INFO is used to handle reading variable length insns. 503 Return the length of the insn in bits, or 0 if no match, 504 or -1 if an error occurs fetching data (memory_error_func will have 505 been called). */ 506 507 static int 508 extract_insn_normal (CGEN_CPU_DESC cd, 509 const CGEN_INSN *insn, 510 CGEN_EXTRACT_INFO *ex_info, 511 CGEN_INSN_INT insn_value, 512 CGEN_FIELDS *fields, 513 bfd_vma pc) 514 { 515 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 516 const CGEN_SYNTAX_CHAR_TYPE *syn; 517 518 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); 519 520 CGEN_INIT_EXTRACT (cd); 521 522 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) 523 { 524 int length; 525 526 if (CGEN_SYNTAX_CHAR_P (*syn)) 527 continue; 528 529 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), 530 ex_info, insn_value, fields, pc); 531 if (length <= 0) 532 return length; 533 } 534 535 /* We recognized and successfully extracted this insn. */ 536 return CGEN_INSN_BITSIZE (insn); 537 } 538 539 /* Machine generated code added here. */ 541 542 const char * iq2000_cgen_insert_operand 543 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); 544 545 /* Main entry point for operand insertion. 546 547 This function is basically just a big switch statement. Earlier versions 548 used tables to look up the function to use, but 549 - if the table contains both assembler and disassembler functions then 550 the disassembler contains much of the assembler and vice-versa, 551 - there's a lot of inlining possibilities as things grow, 552 - using a switch statement avoids the function call overhead. 553 554 This function could be moved into `parse_insn_normal', but keeping it 555 separate makes clear the interface between `parse_insn_normal' and each of 556 the handlers. It's also needed by GAS to insert operands that couldn't be 557 resolved during parsing. */ 558 559 const char * 560 iq2000_cgen_insert_operand (CGEN_CPU_DESC cd, 561 int opindex, 562 CGEN_FIELDS * fields, 563 CGEN_INSN_BYTES_PTR buffer, 564 bfd_vma pc ATTRIBUTE_UNUSED) 565 { 566 const char * errmsg = NULL; 567 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); 568 569 switch (opindex) 570 { 571 case IQ2000_OPERAND__INDEX : 572 errmsg = insert_normal (cd, fields->f_index, 0, 0, 8, 9, 32, total_length, buffer); 573 break; 574 case IQ2000_OPERAND_BASE : 575 errmsg = insert_normal (cd, fields->f_rs, 0, 0, 25, 5, 32, total_length, buffer); 576 break; 577 case IQ2000_OPERAND_BASEOFF : 578 errmsg = insert_normal (cd, fields->f_imm, 0, 0, 15, 16, 32, total_length, buffer); 579 break; 580 case IQ2000_OPERAND_BITNUM : 581 errmsg = insert_normal (cd, fields->f_rt, 0, 0, 20, 5, 32, total_length, buffer); 582 break; 583 case IQ2000_OPERAND_BYTECOUNT : 584 errmsg = insert_normal (cd, fields->f_bytecount, 0, 0, 7, 8, 32, total_length, buffer); 585 break; 586 case IQ2000_OPERAND_CAM_Y : 587 errmsg = insert_normal (cd, fields->f_cam_y, 0, 0, 2, 3, 32, total_length, buffer); 588 break; 589 case IQ2000_OPERAND_CAM_Z : 590 errmsg = insert_normal (cd, fields->f_cam_z, 0, 0, 5, 3, 32, total_length, buffer); 591 break; 592 case IQ2000_OPERAND_CM_3FUNC : 593 errmsg = insert_normal (cd, fields->f_cm_3func, 0, 0, 5, 3, 32, total_length, buffer); 594 break; 595 case IQ2000_OPERAND_CM_3Z : 596 errmsg = insert_normal (cd, fields->f_cm_3z, 0, 0, 1, 2, 32, total_length, buffer); 597 break; 598 case IQ2000_OPERAND_CM_4FUNC : 599 errmsg = insert_normal (cd, fields->f_cm_4func, 0, 0, 5, 4, 32, total_length, buffer); 600 break; 601 case IQ2000_OPERAND_CM_4Z : 602 errmsg = insert_normal (cd, fields->f_cm_4z, 0, 0, 2, 3, 32, total_length, buffer); 603 break; 604 case IQ2000_OPERAND_COUNT : 605 errmsg = insert_normal (cd, fields->f_count, 0, 0, 15, 7, 32, total_length, buffer); 606 break; 607 case IQ2000_OPERAND_EXECODE : 608 errmsg = insert_normal (cd, fields->f_excode, 0, 0, 25, 20, 32, total_length, buffer); 609 break; 610 case IQ2000_OPERAND_HI16 : 611 errmsg = insert_normal (cd, fields->f_imm, 0, 0, 15, 16, 32, total_length, buffer); 612 break; 613 case IQ2000_OPERAND_IMM : 614 errmsg = insert_normal (cd, fields->f_imm, 0, 0, 15, 16, 32, total_length, buffer); 615 break; 616 case IQ2000_OPERAND_JMPTARG : 617 { 618 long value = fields->f_jtarg; 619 value = ((USI) (((value) & (262143))) >> (2)); 620 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 16, 32, total_length, buffer); 621 } 622 break; 623 case IQ2000_OPERAND_JMPTARGQ10 : 624 { 625 long value = fields->f_jtargq10; 626 value = ((USI) (((value) & (8388607))) >> (2)); 627 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 20, 21, 32, total_length, buffer); 628 } 629 break; 630 case IQ2000_OPERAND_LO16 : 631 errmsg = insert_normal (cd, fields->f_imm, 0, 0, 15, 16, 32, total_length, buffer); 632 break; 633 case IQ2000_OPERAND_MASK : 634 errmsg = insert_normal (cd, fields->f_mask, 0, 0, 9, 4, 32, total_length, buffer); 635 break; 636 case IQ2000_OPERAND_MASKL : 637 errmsg = insert_normal (cd, fields->f_maskl, 0, 0, 4, 5, 32, total_length, buffer); 638 break; 639 case IQ2000_OPERAND_MASKQ10 : 640 errmsg = insert_normal (cd, fields->f_maskq10, 0, 0, 10, 5, 32, total_length, buffer); 641 break; 642 case IQ2000_OPERAND_MASKR : 643 errmsg = insert_normal (cd, fields->f_rs, 0, 0, 25, 5, 32, total_length, buffer); 644 break; 645 case IQ2000_OPERAND_MLO16 : 646 errmsg = insert_normal (cd, fields->f_imm, 0, 0, 15, 16, 32, total_length, buffer); 647 break; 648 case IQ2000_OPERAND_OFFSET : 649 { 650 long value = fields->f_offset; 651 value = ((SI) (((value) - (pc))) >> (2)); 652 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer); 653 } 654 break; 655 case IQ2000_OPERAND_RD : 656 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 5, 32, total_length, buffer); 657 break; 658 case IQ2000_OPERAND_RD_RS : 659 { 660 { 661 FLD (f_rd) = FLD (f_rd_rs); 662 FLD (f_rs) = FLD (f_rd_rs); 663 } 664 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 5, 32, total_length, buffer); 665 if (errmsg) 666 break; 667 errmsg = insert_normal (cd, fields->f_rs, 0, 0, 25, 5, 32, total_length, buffer); 668 if (errmsg) 669 break; 670 } 671 break; 672 case IQ2000_OPERAND_RD_RT : 673 { 674 { 675 FLD (f_rd) = FLD (f_rd_rt); 676 FLD (f_rt) = FLD (f_rd_rt); 677 } 678 errmsg = insert_normal (cd, fields->f_rd, 0, 0, 15, 5, 32, total_length, buffer); 679 if (errmsg) 680 break; 681 errmsg = insert_normal (cd, fields->f_rt, 0, 0, 20, 5, 32, total_length, buffer); 682 if (errmsg) 683 break; 684 } 685 break; 686 case IQ2000_OPERAND_RS : 687 errmsg = insert_normal (cd, fields->f_rs, 0, 0, 25, 5, 32, total_length, buffer); 688 break; 689 case IQ2000_OPERAND_RT : 690 errmsg = insert_normal (cd, fields->f_rt, 0, 0, 20, 5, 32, total_length, buffer); 691 break; 692 case IQ2000_OPERAND_RT_RS : 693 { 694 { 695 FLD (f_rt) = FLD (f_rt_rs); 696 FLD (f_rs) = FLD (f_rt_rs); 697 } 698 errmsg = insert_normal (cd, fields->f_rt, 0, 0, 20, 5, 32, total_length, buffer); 699 if (errmsg) 700 break; 701 errmsg = insert_normal (cd, fields->f_rs, 0, 0, 25, 5, 32, total_length, buffer); 702 if (errmsg) 703 break; 704 } 705 break; 706 case IQ2000_OPERAND_SHAMT : 707 errmsg = insert_normal (cd, fields->f_shamt, 0, 0, 10, 5, 32, total_length, buffer); 708 break; 709 710 default : 711 /* xgettext:c-format */ 712 fprintf (stderr, _("Unrecognized field %d while building insn.\n"), 713 opindex); 714 abort (); 715 } 716 717 return errmsg; 718 } 719 720 int iq2000_cgen_extract_operand 721 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); 722 723 /* Main entry point for operand extraction. 724 The result is <= 0 for error, >0 for success. 725 ??? Actual values aren't well defined right now. 726 727 This function is basically just a big switch statement. Earlier versions 728 used tables to look up the function to use, but 729 - if the table contains both assembler and disassembler functions then 730 the disassembler contains much of the assembler and vice-versa, 731 - there's a lot of inlining possibilities as things grow, 732 - using a switch statement avoids the function call overhead. 733 734 This function could be moved into `print_insn_normal', but keeping it 735 separate makes clear the interface between `print_insn_normal' and each of 736 the handlers. */ 737 738 int 739 iq2000_cgen_extract_operand (CGEN_CPU_DESC cd, 740 int opindex, 741 CGEN_EXTRACT_INFO *ex_info, 742 CGEN_INSN_INT insn_value, 743 CGEN_FIELDS * fields, 744 bfd_vma pc) 745 { 746 /* Assume success (for those operands that are nops). */ 747 int length = 1; 748 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); 749 750 switch (opindex) 751 { 752 case IQ2000_OPERAND__INDEX : 753 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 9, 32, total_length, pc, & fields->f_index); 754 break; 755 case IQ2000_OPERAND_BASE : 756 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_rs); 757 break; 758 case IQ2000_OPERAND_BASEOFF : 759 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm); 760 break; 761 case IQ2000_OPERAND_BITNUM : 762 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_rt); 763 break; 764 case IQ2000_OPERAND_BYTECOUNT : 765 length = extract_normal (cd, ex_info, insn_value, 0, 0, 7, 8, 32, total_length, pc, & fields->f_bytecount); 766 break; 767 case IQ2000_OPERAND_CAM_Y : 768 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_cam_y); 769 break; 770 case IQ2000_OPERAND_CAM_Z : 771 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_cam_z); 772 break; 773 case IQ2000_OPERAND_CM_3FUNC : 774 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 3, 32, total_length, pc, & fields->f_cm_3func); 775 break; 776 case IQ2000_OPERAND_CM_3Z : 777 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_cm_3z); 778 break; 779 case IQ2000_OPERAND_CM_4FUNC : 780 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 4, 32, total_length, pc, & fields->f_cm_4func); 781 break; 782 case IQ2000_OPERAND_CM_4Z : 783 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_cm_4z); 784 break; 785 case IQ2000_OPERAND_COUNT : 786 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 7, 32, total_length, pc, & fields->f_count); 787 break; 788 case IQ2000_OPERAND_EXECODE : 789 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 20, 32, total_length, pc, & fields->f_excode); 790 break; 791 case IQ2000_OPERAND_HI16 : 792 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm); 793 break; 794 case IQ2000_OPERAND_IMM : 795 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm); 796 break; 797 case IQ2000_OPERAND_JMPTARG : 798 { 799 long value; 800 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 15, 16, 32, total_length, pc, & value); 801 value = ((((pc) & (0xf0000000))) | (((value) << (2)))); 802 fields->f_jtarg = value; 803 } 804 break; 805 case IQ2000_OPERAND_JMPTARGQ10 : 806 { 807 long value; 808 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_ABS_ADDR), 0, 20, 21, 32, total_length, pc, & value); 809 value = ((((pc) & (0xf0000000))) | (((value) << (2)))); 810 fields->f_jtargq10 = value; 811 } 812 break; 813 case IQ2000_OPERAND_LO16 : 814 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm); 815 break; 816 case IQ2000_OPERAND_MASK : 817 length = extract_normal (cd, ex_info, insn_value, 0, 0, 9, 4, 32, total_length, pc, & fields->f_mask); 818 break; 819 case IQ2000_OPERAND_MASKL : 820 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 5, 32, total_length, pc, & fields->f_maskl); 821 break; 822 case IQ2000_OPERAND_MASKQ10 : 823 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 5, 32, total_length, pc, & fields->f_maskq10); 824 break; 825 case IQ2000_OPERAND_MASKR : 826 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_rs); 827 break; 828 case IQ2000_OPERAND_MLO16 : 829 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_imm); 830 break; 831 case IQ2000_OPERAND_OFFSET : 832 { 833 long value; 834 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, pc, & value); 835 value = ((((value) << (2))) + (((pc) + (4)))); 836 fields->f_offset = value; 837 } 838 break; 839 case IQ2000_OPERAND_RD : 840 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_rd); 841 break; 842 case IQ2000_OPERAND_RD_RS : 843 { 844 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_rd); 845 if (length <= 0) break; 846 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_rs); 847 if (length <= 0) break; 848 { 849 FLD (f_rd_rs) = FLD (f_rs); 850 } 851 } 852 break; 853 case IQ2000_OPERAND_RD_RT : 854 { 855 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 5, 32, total_length, pc, & fields->f_rd); 856 if (length <= 0) break; 857 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_rt); 858 if (length <= 0) break; 859 { 860 FLD (f_rd_rt) = FLD (f_rt); 861 } 862 } 863 break; 864 case IQ2000_OPERAND_RS : 865 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_rs); 866 break; 867 case IQ2000_OPERAND_RT : 868 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_rt); 869 break; 870 case IQ2000_OPERAND_RT_RS : 871 { 872 length = extract_normal (cd, ex_info, insn_value, 0, 0, 20, 5, 32, total_length, pc, & fields->f_rt); 873 if (length <= 0) break; 874 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 5, 32, total_length, pc, & fields->f_rs); 875 if (length <= 0) break; 876 { 877 FLD (f_rd_rs) = FLD (f_rs); 878 } 879 } 880 break; 881 case IQ2000_OPERAND_SHAMT : 882 length = extract_normal (cd, ex_info, insn_value, 0, 0, 10, 5, 32, total_length, pc, & fields->f_shamt); 883 break; 884 885 default : 886 /* xgettext:c-format */ 887 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), 888 opindex); 889 abort (); 890 } 891 892 return length; 893 } 894 895 cgen_insert_fn * const iq2000_cgen_insert_handlers[] = 896 { 897 insert_insn_normal, 898 }; 899 900 cgen_extract_fn * const iq2000_cgen_extract_handlers[] = 901 { 902 extract_insn_normal, 903 }; 904 905 int iq2000_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 906 bfd_vma iq2000_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 907 908 /* Getting values from cgen_fields is handled by a collection of functions. 909 They are distinguished by the type of the VALUE argument they return. 910 TODO: floating point, inlining support, remove cases where result type 911 not appropriate. */ 912 913 int 914 iq2000_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 915 int opindex, 916 const CGEN_FIELDS * fields) 917 { 918 int value; 919 920 switch (opindex) 921 { 922 case IQ2000_OPERAND__INDEX : 923 value = fields->f_index; 924 break; 925 case IQ2000_OPERAND_BASE : 926 value = fields->f_rs; 927 break; 928 case IQ2000_OPERAND_BASEOFF : 929 value = fields->f_imm; 930 break; 931 case IQ2000_OPERAND_BITNUM : 932 value = fields->f_rt; 933 break; 934 case IQ2000_OPERAND_BYTECOUNT : 935 value = fields->f_bytecount; 936 break; 937 case IQ2000_OPERAND_CAM_Y : 938 value = fields->f_cam_y; 939 break; 940 case IQ2000_OPERAND_CAM_Z : 941 value = fields->f_cam_z; 942 break; 943 case IQ2000_OPERAND_CM_3FUNC : 944 value = fields->f_cm_3func; 945 break; 946 case IQ2000_OPERAND_CM_3Z : 947 value = fields->f_cm_3z; 948 break; 949 case IQ2000_OPERAND_CM_4FUNC : 950 value = fields->f_cm_4func; 951 break; 952 case IQ2000_OPERAND_CM_4Z : 953 value = fields->f_cm_4z; 954 break; 955 case IQ2000_OPERAND_COUNT : 956 value = fields->f_count; 957 break; 958 case IQ2000_OPERAND_EXECODE : 959 value = fields->f_excode; 960 break; 961 case IQ2000_OPERAND_HI16 : 962 value = fields->f_imm; 963 break; 964 case IQ2000_OPERAND_IMM : 965 value = fields->f_imm; 966 break; 967 case IQ2000_OPERAND_JMPTARG : 968 value = fields->f_jtarg; 969 break; 970 case IQ2000_OPERAND_JMPTARGQ10 : 971 value = fields->f_jtargq10; 972 break; 973 case IQ2000_OPERAND_LO16 : 974 value = fields->f_imm; 975 break; 976 case IQ2000_OPERAND_MASK : 977 value = fields->f_mask; 978 break; 979 case IQ2000_OPERAND_MASKL : 980 value = fields->f_maskl; 981 break; 982 case IQ2000_OPERAND_MASKQ10 : 983 value = fields->f_maskq10; 984 break; 985 case IQ2000_OPERAND_MASKR : 986 value = fields->f_rs; 987 break; 988 case IQ2000_OPERAND_MLO16 : 989 value = fields->f_imm; 990 break; 991 case IQ2000_OPERAND_OFFSET : 992 value = fields->f_offset; 993 break; 994 case IQ2000_OPERAND_RD : 995 value = fields->f_rd; 996 break; 997 case IQ2000_OPERAND_RD_RS : 998 value = fields->f_rd_rs; 999 break; 1000 case IQ2000_OPERAND_RD_RT : 1001 value = fields->f_rd_rt; 1002 break; 1003 case IQ2000_OPERAND_RS : 1004 value = fields->f_rs; 1005 break; 1006 case IQ2000_OPERAND_RT : 1007 value = fields->f_rt; 1008 break; 1009 case IQ2000_OPERAND_RT_RS : 1010 value = fields->f_rt_rs; 1011 break; 1012 case IQ2000_OPERAND_SHAMT : 1013 value = fields->f_shamt; 1014 break; 1015 1016 default : 1017 /* xgettext:c-format */ 1018 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), 1019 opindex); 1020 abort (); 1021 } 1022 1023 return value; 1024 } 1025 1026 bfd_vma 1027 iq2000_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1028 int opindex, 1029 const CGEN_FIELDS * fields) 1030 { 1031 bfd_vma value; 1032 1033 switch (opindex) 1034 { 1035 case IQ2000_OPERAND__INDEX : 1036 value = fields->f_index; 1037 break; 1038 case IQ2000_OPERAND_BASE : 1039 value = fields->f_rs; 1040 break; 1041 case IQ2000_OPERAND_BASEOFF : 1042 value = fields->f_imm; 1043 break; 1044 case IQ2000_OPERAND_BITNUM : 1045 value = fields->f_rt; 1046 break; 1047 case IQ2000_OPERAND_BYTECOUNT : 1048 value = fields->f_bytecount; 1049 break; 1050 case IQ2000_OPERAND_CAM_Y : 1051 value = fields->f_cam_y; 1052 break; 1053 case IQ2000_OPERAND_CAM_Z : 1054 value = fields->f_cam_z; 1055 break; 1056 case IQ2000_OPERAND_CM_3FUNC : 1057 value = fields->f_cm_3func; 1058 break; 1059 case IQ2000_OPERAND_CM_3Z : 1060 value = fields->f_cm_3z; 1061 break; 1062 case IQ2000_OPERAND_CM_4FUNC : 1063 value = fields->f_cm_4func; 1064 break; 1065 case IQ2000_OPERAND_CM_4Z : 1066 value = fields->f_cm_4z; 1067 break; 1068 case IQ2000_OPERAND_COUNT : 1069 value = fields->f_count; 1070 break; 1071 case IQ2000_OPERAND_EXECODE : 1072 value = fields->f_excode; 1073 break; 1074 case IQ2000_OPERAND_HI16 : 1075 value = fields->f_imm; 1076 break; 1077 case IQ2000_OPERAND_IMM : 1078 value = fields->f_imm; 1079 break; 1080 case IQ2000_OPERAND_JMPTARG : 1081 value = fields->f_jtarg; 1082 break; 1083 case IQ2000_OPERAND_JMPTARGQ10 : 1084 value = fields->f_jtargq10; 1085 break; 1086 case IQ2000_OPERAND_LO16 : 1087 value = fields->f_imm; 1088 break; 1089 case IQ2000_OPERAND_MASK : 1090 value = fields->f_mask; 1091 break; 1092 case IQ2000_OPERAND_MASKL : 1093 value = fields->f_maskl; 1094 break; 1095 case IQ2000_OPERAND_MASKQ10 : 1096 value = fields->f_maskq10; 1097 break; 1098 case IQ2000_OPERAND_MASKR : 1099 value = fields->f_rs; 1100 break; 1101 case IQ2000_OPERAND_MLO16 : 1102 value = fields->f_imm; 1103 break; 1104 case IQ2000_OPERAND_OFFSET : 1105 value = fields->f_offset; 1106 break; 1107 case IQ2000_OPERAND_RD : 1108 value = fields->f_rd; 1109 break; 1110 case IQ2000_OPERAND_RD_RS : 1111 value = fields->f_rd_rs; 1112 break; 1113 case IQ2000_OPERAND_RD_RT : 1114 value = fields->f_rd_rt; 1115 break; 1116 case IQ2000_OPERAND_RS : 1117 value = fields->f_rs; 1118 break; 1119 case IQ2000_OPERAND_RT : 1120 value = fields->f_rt; 1121 break; 1122 case IQ2000_OPERAND_RT_RS : 1123 value = fields->f_rt_rs; 1124 break; 1125 case IQ2000_OPERAND_SHAMT : 1126 value = fields->f_shamt; 1127 break; 1128 1129 default : 1130 /* xgettext:c-format */ 1131 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), 1132 opindex); 1133 abort (); 1134 } 1135 1136 return value; 1137 } 1138 1139 void iq2000_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); 1140 void iq2000_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); 1141 1142 /* Stuffing values in cgen_fields is handled by a collection of functions. 1143 They are distinguished by the type of the VALUE argument they accept. 1144 TODO: floating point, inlining support, remove cases where argument type 1145 not appropriate. */ 1146 1147 void 1148 iq2000_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1149 int opindex, 1150 CGEN_FIELDS * fields, 1151 int value) 1152 { 1153 switch (opindex) 1154 { 1155 case IQ2000_OPERAND__INDEX : 1156 fields->f_index = value; 1157 break; 1158 case IQ2000_OPERAND_BASE : 1159 fields->f_rs = value; 1160 break; 1161 case IQ2000_OPERAND_BASEOFF : 1162 fields->f_imm = value; 1163 break; 1164 case IQ2000_OPERAND_BITNUM : 1165 fields->f_rt = value; 1166 break; 1167 case IQ2000_OPERAND_BYTECOUNT : 1168 fields->f_bytecount = value; 1169 break; 1170 case IQ2000_OPERAND_CAM_Y : 1171 fields->f_cam_y = value; 1172 break; 1173 case IQ2000_OPERAND_CAM_Z : 1174 fields->f_cam_z = value; 1175 break; 1176 case IQ2000_OPERAND_CM_3FUNC : 1177 fields->f_cm_3func = value; 1178 break; 1179 case IQ2000_OPERAND_CM_3Z : 1180 fields->f_cm_3z = value; 1181 break; 1182 case IQ2000_OPERAND_CM_4FUNC : 1183 fields->f_cm_4func = value; 1184 break; 1185 case IQ2000_OPERAND_CM_4Z : 1186 fields->f_cm_4z = value; 1187 break; 1188 case IQ2000_OPERAND_COUNT : 1189 fields->f_count = value; 1190 break; 1191 case IQ2000_OPERAND_EXECODE : 1192 fields->f_excode = value; 1193 break; 1194 case IQ2000_OPERAND_HI16 : 1195 fields->f_imm = value; 1196 break; 1197 case IQ2000_OPERAND_IMM : 1198 fields->f_imm = value; 1199 break; 1200 case IQ2000_OPERAND_JMPTARG : 1201 fields->f_jtarg = value; 1202 break; 1203 case IQ2000_OPERAND_JMPTARGQ10 : 1204 fields->f_jtargq10 = value; 1205 break; 1206 case IQ2000_OPERAND_LO16 : 1207 fields->f_imm = value; 1208 break; 1209 case IQ2000_OPERAND_MASK : 1210 fields->f_mask = value; 1211 break; 1212 case IQ2000_OPERAND_MASKL : 1213 fields->f_maskl = value; 1214 break; 1215 case IQ2000_OPERAND_MASKQ10 : 1216 fields->f_maskq10 = value; 1217 break; 1218 case IQ2000_OPERAND_MASKR : 1219 fields->f_rs = value; 1220 break; 1221 case IQ2000_OPERAND_MLO16 : 1222 fields->f_imm = value; 1223 break; 1224 case IQ2000_OPERAND_OFFSET : 1225 fields->f_offset = value; 1226 break; 1227 case IQ2000_OPERAND_RD : 1228 fields->f_rd = value; 1229 break; 1230 case IQ2000_OPERAND_RD_RS : 1231 fields->f_rd_rs = value; 1232 break; 1233 case IQ2000_OPERAND_RD_RT : 1234 fields->f_rd_rt = value; 1235 break; 1236 case IQ2000_OPERAND_RS : 1237 fields->f_rs = value; 1238 break; 1239 case IQ2000_OPERAND_RT : 1240 fields->f_rt = value; 1241 break; 1242 case IQ2000_OPERAND_RT_RS : 1243 fields->f_rt_rs = value; 1244 break; 1245 case IQ2000_OPERAND_SHAMT : 1246 fields->f_shamt = value; 1247 break; 1248 1249 default : 1250 /* xgettext:c-format */ 1251 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), 1252 opindex); 1253 abort (); 1254 } 1255 } 1256 1257 void 1258 iq2000_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1259 int opindex, 1260 CGEN_FIELDS * fields, 1261 bfd_vma value) 1262 { 1263 switch (opindex) 1264 { 1265 case IQ2000_OPERAND__INDEX : 1266 fields->f_index = value; 1267 break; 1268 case IQ2000_OPERAND_BASE : 1269 fields->f_rs = value; 1270 break; 1271 case IQ2000_OPERAND_BASEOFF : 1272 fields->f_imm = value; 1273 break; 1274 case IQ2000_OPERAND_BITNUM : 1275 fields->f_rt = value; 1276 break; 1277 case IQ2000_OPERAND_BYTECOUNT : 1278 fields->f_bytecount = value; 1279 break; 1280 case IQ2000_OPERAND_CAM_Y : 1281 fields->f_cam_y = value; 1282 break; 1283 case IQ2000_OPERAND_CAM_Z : 1284 fields->f_cam_z = value; 1285 break; 1286 case IQ2000_OPERAND_CM_3FUNC : 1287 fields->f_cm_3func = value; 1288 break; 1289 case IQ2000_OPERAND_CM_3Z : 1290 fields->f_cm_3z = value; 1291 break; 1292 case IQ2000_OPERAND_CM_4FUNC : 1293 fields->f_cm_4func = value; 1294 break; 1295 case IQ2000_OPERAND_CM_4Z : 1296 fields->f_cm_4z = value; 1297 break; 1298 case IQ2000_OPERAND_COUNT : 1299 fields->f_count = value; 1300 break; 1301 case IQ2000_OPERAND_EXECODE : 1302 fields->f_excode = value; 1303 break; 1304 case IQ2000_OPERAND_HI16 : 1305 fields->f_imm = value; 1306 break; 1307 case IQ2000_OPERAND_IMM : 1308 fields->f_imm = value; 1309 break; 1310 case IQ2000_OPERAND_JMPTARG : 1311 fields->f_jtarg = value; 1312 break; 1313 case IQ2000_OPERAND_JMPTARGQ10 : 1314 fields->f_jtargq10 = value; 1315 break; 1316 case IQ2000_OPERAND_LO16 : 1317 fields->f_imm = value; 1318 break; 1319 case IQ2000_OPERAND_MASK : 1320 fields->f_mask = value; 1321 break; 1322 case IQ2000_OPERAND_MASKL : 1323 fields->f_maskl = value; 1324 break; 1325 case IQ2000_OPERAND_MASKQ10 : 1326 fields->f_maskq10 = value; 1327 break; 1328 case IQ2000_OPERAND_MASKR : 1329 fields->f_rs = value; 1330 break; 1331 case IQ2000_OPERAND_MLO16 : 1332 fields->f_imm = value; 1333 break; 1334 case IQ2000_OPERAND_OFFSET : 1335 fields->f_offset = value; 1336 break; 1337 case IQ2000_OPERAND_RD : 1338 fields->f_rd = value; 1339 break; 1340 case IQ2000_OPERAND_RD_RS : 1341 fields->f_rd_rs = value; 1342 break; 1343 case IQ2000_OPERAND_RD_RT : 1344 fields->f_rd_rt = value; 1345 break; 1346 case IQ2000_OPERAND_RS : 1347 fields->f_rs = value; 1348 break; 1349 case IQ2000_OPERAND_RT : 1350 fields->f_rt = value; 1351 break; 1352 case IQ2000_OPERAND_RT_RS : 1353 fields->f_rt_rs = value; 1354 break; 1355 case IQ2000_OPERAND_SHAMT : 1356 fields->f_shamt = value; 1357 break; 1358 1359 default : 1360 /* xgettext:c-format */ 1361 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), 1362 opindex); 1363 abort (); 1364 } 1365 } 1366 1367 /* Function to call before using the instruction builder tables. */ 1368 1369 void 1370 iq2000_cgen_init_ibld_table (CGEN_CPU_DESC cd) 1371 { 1372 cd->insert_handlers = & iq2000_cgen_insert_handlers[0]; 1373 cd->extract_handlers = & iq2000_cgen_extract_handlers[0]; 1374 1375 cd->insert_operand = iq2000_cgen_insert_operand; 1376 cd->extract_operand = iq2000_cgen_extract_operand; 1377 1378 cd->get_int_operand = iq2000_cgen_get_int_operand; 1379 cd->set_int_operand = iq2000_cgen_set_int_operand; 1380 cd->get_vma_operand = iq2000_cgen_get_vma_operand; 1381 cd->set_vma_operand = iq2000_cgen_set_vma_operand; 1382 } 1383