1 /* Instruction building/extraction support for frv. -*- 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-2016 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 "frv-desc.h" 34 #include "frv-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_within_word, shift_to_word, shift; 212 213 /* How to shift the value to BIT0 of the word. */ 214 shift_to_word = total_length - (word_offset + word_length); 215 216 /* How to shift the value to the field within the word. */ 217 if (CGEN_INSN_LSB0_P) 218 shift_within_word = start + 1 - length; 219 else 220 shift_within_word = word_length - start - length; 221 222 /* The total SHIFT, then mask in the value. */ 223 shift = shift_to_word + shift_within_word; 224 *buffer = (*buffer & ~(mask << shift)) | ((value & mask) << shift); 225 } 226 227 #else /* ! CGEN_INT_INSN_P */ 228 229 { 230 unsigned char *bufp = (unsigned char *) buffer + word_offset / 8; 231 232 insert_1 (cd, value, start, length, word_length, bufp); 233 } 234 235 #endif /* ! CGEN_INT_INSN_P */ 236 237 return NULL; 238 } 239 240 /* Default insn builder (insert handler). 241 The instruction is recorded in CGEN_INT_INSN_P byte order (meaning 242 that if CGEN_INSN_BYTES_PTR is an int * and thus, the value is 243 recorded in host byte order, otherwise BUFFER is an array of bytes 244 and the value is recorded in target byte order). 245 The result is an error message or NULL if success. */ 246 247 static const char * 248 insert_insn_normal (CGEN_CPU_DESC cd, 249 const CGEN_INSN * insn, 250 CGEN_FIELDS * fields, 251 CGEN_INSN_BYTES_PTR buffer, 252 bfd_vma pc) 253 { 254 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 255 unsigned long value; 256 const CGEN_SYNTAX_CHAR_TYPE * syn; 257 258 CGEN_INIT_INSERT (cd); 259 value = CGEN_INSN_BASE_VALUE (insn); 260 261 /* If we're recording insns as numbers (rather than a string of bytes), 262 target byte order handling is deferred until later. */ 263 264 #if CGEN_INT_INSN_P 265 266 put_insn_int_value (cd, buffer, cd->base_insn_bitsize, 267 CGEN_FIELDS_BITSIZE (fields), value); 268 269 #else 270 271 cgen_put_insn_value (cd, buffer, min ((unsigned) cd->base_insn_bitsize, 272 (unsigned) CGEN_FIELDS_BITSIZE (fields)), 273 value); 274 275 #endif /* ! CGEN_INT_INSN_P */ 276 277 /* ??? It would be better to scan the format's fields. 278 Still need to be able to insert a value based on the operand though; 279 e.g. storing a branch displacement that got resolved later. 280 Needs more thought first. */ 281 282 for (syn = CGEN_SYNTAX_STRING (syntax); * syn; ++ syn) 283 { 284 const char *errmsg; 285 286 if (CGEN_SYNTAX_CHAR_P (* syn)) 287 continue; 288 289 errmsg = (* cd->insert_operand) (cd, CGEN_SYNTAX_FIELD (*syn), 290 fields, buffer, pc); 291 if (errmsg) 292 return errmsg; 293 } 294 295 return NULL; 296 } 297 298 #if CGEN_INT_INSN_P 299 /* Cover function to store an insn value into an integral insn. Must go here 300 because it needs <prefix>-desc.h for CGEN_INT_INSN_P. */ 301 302 static void 303 put_insn_int_value (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 304 CGEN_INSN_BYTES_PTR buf, 305 int length, 306 int insn_length, 307 CGEN_INSN_INT value) 308 { 309 /* For architectures with insns smaller than the base-insn-bitsize, 310 length may be too big. */ 311 if (length > insn_length) 312 *buf = value; 313 else 314 { 315 int shift = insn_length - length; 316 /* Written this way to avoid undefined behaviour. */ 317 CGEN_INSN_INT mask = (((1L << (length - 1)) - 1) << 1) | 1; 318 319 *buf = (*buf & ~(mask << shift)) | ((value & mask) << shift); 320 } 321 } 322 #endif 323 324 /* Operand extraction. */ 326 327 #if ! CGEN_INT_INSN_P 328 329 /* Subroutine of extract_normal. 330 Ensure sufficient bytes are cached in EX_INFO. 331 OFFSET is the offset in bytes from the start of the insn of the value. 332 BYTES is the length of the needed value. 333 Returns 1 for success, 0 for failure. */ 334 335 static CGEN_INLINE int 336 fill_cache (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 337 CGEN_EXTRACT_INFO *ex_info, 338 int offset, 339 int bytes, 340 bfd_vma pc) 341 { 342 /* It's doubtful that the middle part has already been fetched so 343 we don't optimize that case. kiss. */ 344 unsigned int mask; 345 disassemble_info *info = (disassemble_info *) ex_info->dis_info; 346 347 /* First do a quick check. */ 348 mask = (1 << bytes) - 1; 349 if (((ex_info->valid >> offset) & mask) == mask) 350 return 1; 351 352 /* Search for the first byte we need to read. */ 353 for (mask = 1 << offset; bytes > 0; --bytes, ++offset, mask <<= 1) 354 if (! (mask & ex_info->valid)) 355 break; 356 357 if (bytes) 358 { 359 int status; 360 361 pc += offset; 362 status = (*info->read_memory_func) 363 (pc, ex_info->insn_bytes + offset, bytes, info); 364 365 if (status != 0) 366 { 367 (*info->memory_error_func) (status, pc, info); 368 return 0; 369 } 370 371 ex_info->valid |= ((1 << bytes) - 1) << offset; 372 } 373 374 return 1; 375 } 376 377 /* Subroutine of extract_normal. */ 378 379 static CGEN_INLINE long 380 extract_1 (CGEN_CPU_DESC cd, 381 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, 382 int start, 383 int length, 384 int word_length, 385 unsigned char *bufp, 386 bfd_vma pc ATTRIBUTE_UNUSED) 387 { 388 unsigned long x; 389 int shift; 390 391 x = cgen_get_insn_value (cd, bufp, word_length); 392 393 if (CGEN_INSN_LSB0_P) 394 shift = (start + 1) - length; 395 else 396 shift = (word_length - (start + length)); 397 return x >> shift; 398 } 399 400 #endif /* ! CGEN_INT_INSN_P */ 401 402 /* Default extraction routine. 403 404 INSN_VALUE is the first base_insn_bitsize bits of the insn in host order, 405 or sometimes less for cases like the m32r where the base insn size is 32 406 but some insns are 16 bits. 407 ATTRS is a mask of the boolean attributes. We only need `SIGNED', 408 but for generality we take a bitmask of all of them. 409 WORD_OFFSET is the offset in bits from the start of the insn of the value. 410 WORD_LENGTH is the length of the word in bits in which the value resides. 411 START is the starting bit number in the word, architecture origin. 412 LENGTH is the length of VALUE in bits. 413 TOTAL_LENGTH is the total length of the insn in bits. 414 415 Returns 1 for success, 0 for failure. */ 416 417 /* ??? The return code isn't properly used. wip. */ 418 419 /* ??? This doesn't handle bfd_vma's. Create another function when 420 necessary. */ 421 422 static int 423 extract_normal (CGEN_CPU_DESC cd, 424 #if ! CGEN_INT_INSN_P 425 CGEN_EXTRACT_INFO *ex_info, 426 #else 427 CGEN_EXTRACT_INFO *ex_info ATTRIBUTE_UNUSED, 428 #endif 429 CGEN_INSN_INT insn_value, 430 unsigned int attrs, 431 unsigned int word_offset, 432 unsigned int start, 433 unsigned int length, 434 unsigned int word_length, 435 unsigned int total_length, 436 #if ! CGEN_INT_INSN_P 437 bfd_vma pc, 438 #else 439 bfd_vma pc ATTRIBUTE_UNUSED, 440 #endif 441 long *valuep) 442 { 443 long value, mask; 444 445 /* If LENGTH is zero, this operand doesn't contribute to the value 446 so give it a standard value of zero. */ 447 if (length == 0) 448 { 449 *valuep = 0; 450 return 1; 451 } 452 453 if (word_length > 8 * sizeof (CGEN_INSN_INT)) 454 abort (); 455 456 /* For architectures with insns smaller than the insn-base-bitsize, 457 word_length may be too big. */ 458 if (cd->min_insn_bitsize < cd->base_insn_bitsize) 459 { 460 if (word_offset + word_length > total_length) 461 word_length = total_length - word_offset; 462 } 463 464 /* Does the value reside in INSN_VALUE, and at the right alignment? */ 465 466 if (CGEN_INT_INSN_P || (word_offset == 0 && word_length == total_length)) 467 { 468 if (CGEN_INSN_LSB0_P) 469 value = insn_value >> ((word_offset + start + 1) - length); 470 else 471 value = insn_value >> (total_length - ( word_offset + start + length)); 472 } 473 474 #if ! CGEN_INT_INSN_P 475 476 else 477 { 478 unsigned char *bufp = ex_info->insn_bytes + word_offset / 8; 479 480 if (word_length > 8 * sizeof (CGEN_INSN_INT)) 481 abort (); 482 483 if (fill_cache (cd, ex_info, word_offset / 8, word_length / 8, pc) == 0) 484 return 0; 485 486 value = extract_1 (cd, ex_info, start, length, word_length, bufp, pc); 487 } 488 489 #endif /* ! CGEN_INT_INSN_P */ 490 491 /* Written this way to avoid undefined behaviour. */ 492 mask = (((1L << (length - 1)) - 1) << 1) | 1; 493 494 value &= mask; 495 /* sign extend? */ 496 if (CGEN_BOOL_ATTR (attrs, CGEN_IFLD_SIGNED) 497 && (value & (1L << (length - 1)))) 498 value |= ~mask; 499 500 *valuep = value; 501 502 return 1; 503 } 504 505 /* Default insn extractor. 506 507 INSN_VALUE is the first base_insn_bitsize bits, translated to host order. 508 The extracted fields are stored in FIELDS. 509 EX_INFO is used to handle reading variable length insns. 510 Return the length of the insn in bits, or 0 if no match, 511 or -1 if an error occurs fetching data (memory_error_func will have 512 been called). */ 513 514 static int 515 extract_insn_normal (CGEN_CPU_DESC cd, 516 const CGEN_INSN *insn, 517 CGEN_EXTRACT_INFO *ex_info, 518 CGEN_INSN_INT insn_value, 519 CGEN_FIELDS *fields, 520 bfd_vma pc) 521 { 522 const CGEN_SYNTAX *syntax = CGEN_INSN_SYNTAX (insn); 523 const CGEN_SYNTAX_CHAR_TYPE *syn; 524 525 CGEN_FIELDS_BITSIZE (fields) = CGEN_INSN_BITSIZE (insn); 526 527 CGEN_INIT_EXTRACT (cd); 528 529 for (syn = CGEN_SYNTAX_STRING (syntax); *syn; ++syn) 530 { 531 int length; 532 533 if (CGEN_SYNTAX_CHAR_P (*syn)) 534 continue; 535 536 length = (* cd->extract_operand) (cd, CGEN_SYNTAX_FIELD (*syn), 537 ex_info, insn_value, fields, pc); 538 if (length <= 0) 539 return length; 540 } 541 542 /* We recognized and successfully extracted this insn. */ 543 return CGEN_INSN_BITSIZE (insn); 544 } 545 546 /* Machine generated code added here. */ 548 549 const char * frv_cgen_insert_operand 550 (CGEN_CPU_DESC, int, CGEN_FIELDS *, CGEN_INSN_BYTES_PTR, bfd_vma); 551 552 /* Main entry point for operand insertion. 553 554 This function is basically just a big switch statement. Earlier versions 555 used tables to look up the function to use, but 556 - if the table contains both assembler and disassembler functions then 557 the disassembler contains much of the assembler and vice-versa, 558 - there's a lot of inlining possibilities as things grow, 559 - using a switch statement avoids the function call overhead. 560 561 This function could be moved into `parse_insn_normal', but keeping it 562 separate makes clear the interface between `parse_insn_normal' and each of 563 the handlers. It's also needed by GAS to insert operands that couldn't be 564 resolved during parsing. */ 565 566 const char * 567 frv_cgen_insert_operand (CGEN_CPU_DESC cd, 568 int opindex, 569 CGEN_FIELDS * fields, 570 CGEN_INSN_BYTES_PTR buffer, 571 bfd_vma pc ATTRIBUTE_UNUSED) 572 { 573 const char * errmsg = NULL; 574 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); 575 576 switch (opindex) 577 { 578 case FRV_OPERAND_A0 : 579 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer); 580 break; 581 case FRV_OPERAND_A1 : 582 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer); 583 break; 584 case FRV_OPERAND_ACC40SI : 585 errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer); 586 break; 587 case FRV_OPERAND_ACC40SK : 588 errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer); 589 break; 590 case FRV_OPERAND_ACC40UI : 591 errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer); 592 break; 593 case FRV_OPERAND_ACC40UK : 594 errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer); 595 break; 596 case FRV_OPERAND_ACCGI : 597 errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer); 598 break; 599 case FRV_OPERAND_ACCGK : 600 errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer); 601 break; 602 case FRV_OPERAND_CCI : 603 errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer); 604 break; 605 case FRV_OPERAND_CPRDOUBLEK : 606 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer); 607 break; 608 case FRV_OPERAND_CPRI : 609 errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer); 610 break; 611 case FRV_OPERAND_CPRJ : 612 errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer); 613 break; 614 case FRV_OPERAND_CPRK : 615 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer); 616 break; 617 case FRV_OPERAND_CRI : 618 errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer); 619 break; 620 case FRV_OPERAND_CRJ : 621 errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer); 622 break; 623 case FRV_OPERAND_CRJ_FLOAT : 624 errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer); 625 break; 626 case FRV_OPERAND_CRJ_INT : 627 { 628 long value = fields->f_CRj_int; 629 value = ((value) - (4)); 630 errmsg = insert_normal (cd, value, 0, 0, 26, 2, 32, total_length, buffer); 631 } 632 break; 633 case FRV_OPERAND_CRK : 634 errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer); 635 break; 636 case FRV_OPERAND_FCCI_1 : 637 errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer); 638 break; 639 case FRV_OPERAND_FCCI_2 : 640 errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer); 641 break; 642 case FRV_OPERAND_FCCI_3 : 643 errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer); 644 break; 645 case FRV_OPERAND_FCCK : 646 errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer); 647 break; 648 case FRV_OPERAND_FRDOUBLEI : 649 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 650 break; 651 case FRV_OPERAND_FRDOUBLEJ : 652 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 653 break; 654 case FRV_OPERAND_FRDOUBLEK : 655 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 656 break; 657 case FRV_OPERAND_FRI : 658 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 659 break; 660 case FRV_OPERAND_FRINTI : 661 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 662 break; 663 case FRV_OPERAND_FRINTIEVEN : 664 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 665 break; 666 case FRV_OPERAND_FRINTJ : 667 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 668 break; 669 case FRV_OPERAND_FRINTJEVEN : 670 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 671 break; 672 case FRV_OPERAND_FRINTK : 673 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 674 break; 675 case FRV_OPERAND_FRINTKEVEN : 676 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 677 break; 678 case FRV_OPERAND_FRJ : 679 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 680 break; 681 case FRV_OPERAND_FRK : 682 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 683 break; 684 case FRV_OPERAND_FRKHI : 685 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 686 break; 687 case FRV_OPERAND_FRKLO : 688 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 689 break; 690 case FRV_OPERAND_GRDOUBLEK : 691 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 692 break; 693 case FRV_OPERAND_GRI : 694 errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer); 695 break; 696 case FRV_OPERAND_GRJ : 697 errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer); 698 break; 699 case FRV_OPERAND_GRK : 700 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 701 break; 702 case FRV_OPERAND_GRKHI : 703 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 704 break; 705 case FRV_OPERAND_GRKLO : 706 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 707 break; 708 case FRV_OPERAND_ICCI_1 : 709 errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer); 710 break; 711 case FRV_OPERAND_ICCI_2 : 712 errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer); 713 break; 714 case FRV_OPERAND_ICCI_3 : 715 errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer); 716 break; 717 case FRV_OPERAND_LI : 718 errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer); 719 break; 720 case FRV_OPERAND_LRAD : 721 errmsg = insert_normal (cd, fields->f_LRAD, 0, 0, 4, 1, 32, total_length, buffer); 722 break; 723 case FRV_OPERAND_LRAE : 724 errmsg = insert_normal (cd, fields->f_LRAE, 0, 0, 5, 1, 32, total_length, buffer); 725 break; 726 case FRV_OPERAND_LRAS : 727 errmsg = insert_normal (cd, fields->f_LRAS, 0, 0, 3, 1, 32, total_length, buffer); 728 break; 729 case FRV_OPERAND_TLBPRL : 730 errmsg = insert_normal (cd, fields->f_TLBPRL, 0, 0, 25, 1, 32, total_length, buffer); 731 break; 732 case FRV_OPERAND_TLBPROPX : 733 errmsg = insert_normal (cd, fields->f_TLBPRopx, 0, 0, 28, 3, 32, total_length, buffer); 734 break; 735 case FRV_OPERAND_AE : 736 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer); 737 break; 738 case FRV_OPERAND_CALLANN : 739 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 740 break; 741 case FRV_OPERAND_CCOND : 742 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer); 743 break; 744 case FRV_OPERAND_COND : 745 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer); 746 break; 747 case FRV_OPERAND_D12 : 748 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer); 749 break; 750 case FRV_OPERAND_DEBUG : 751 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer); 752 break; 753 case FRV_OPERAND_EIR : 754 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer); 755 break; 756 case FRV_OPERAND_HINT : 757 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 758 break; 759 case FRV_OPERAND_HINT_NOT_TAKEN : 760 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 761 break; 762 case FRV_OPERAND_HINT_TAKEN : 763 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 764 break; 765 case FRV_OPERAND_LABEL16 : 766 { 767 long value = fields->f_label16; 768 value = ((SI) (((value) - (pc))) >> (2)); 769 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer); 770 } 771 break; 772 case FRV_OPERAND_LABEL24 : 773 { 774 { 775 FLD (f_labelH6) = ((SI) (((FLD (f_label24)) - (pc))) >> (20)); 776 FLD (f_labelL18) = ((((UINT) (((FLD (f_label24)) - (pc))) >> (2))) & (262143)); 777 } 778 errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer); 779 if (errmsg) 780 break; 781 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer); 782 if (errmsg) 783 break; 784 } 785 break; 786 case FRV_OPERAND_LDANN : 787 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 788 break; 789 case FRV_OPERAND_LDDANN : 790 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 791 break; 792 case FRV_OPERAND_LOCK : 793 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer); 794 break; 795 case FRV_OPERAND_PACK : 796 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer); 797 break; 798 case FRV_OPERAND_S10 : 799 errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer); 800 break; 801 case FRV_OPERAND_S12 : 802 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer); 803 break; 804 case FRV_OPERAND_S16 : 805 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); 806 break; 807 case FRV_OPERAND_S5 : 808 errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer); 809 break; 810 case FRV_OPERAND_S6 : 811 errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer); 812 break; 813 case FRV_OPERAND_S6_1 : 814 errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer); 815 break; 816 case FRV_OPERAND_SLO16 : 817 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); 818 break; 819 case FRV_OPERAND_SPR : 820 { 821 { 822 FLD (f_spr_h) = ((UINT) (FLD (f_spr)) >> (6)); 823 FLD (f_spr_l) = ((FLD (f_spr)) & (63)); 824 } 825 errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer); 826 if (errmsg) 827 break; 828 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer); 829 if (errmsg) 830 break; 831 } 832 break; 833 case FRV_OPERAND_U12 : 834 { 835 { 836 FLD (f_u12_h) = ((SI) (FLD (f_u12)) >> (6)); 837 FLD (f_u12_l) = ((FLD (f_u12)) & (63)); 838 } 839 errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer); 840 if (errmsg) 841 break; 842 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer); 843 if (errmsg) 844 break; 845 } 846 break; 847 case FRV_OPERAND_U16 : 848 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 849 break; 850 case FRV_OPERAND_U6 : 851 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer); 852 break; 853 case FRV_OPERAND_UHI16 : 854 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 855 break; 856 case FRV_OPERAND_ULO16 : 857 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 858 break; 859 860 default : 861 /* xgettext:c-format */ 862 fprintf (stderr, _("Unrecognized field %d while building insn.\n"), 863 opindex); 864 abort (); 865 } 866 867 return errmsg; 868 } 869 870 int frv_cgen_extract_operand 871 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); 872 873 /* Main entry point for operand extraction. 874 The result is <= 0 for error, >0 for success. 875 ??? Actual values aren't well defined right now. 876 877 This function is basically just a big switch statement. Earlier versions 878 used tables to look up the function to use, but 879 - if the table contains both assembler and disassembler functions then 880 the disassembler contains much of the assembler and vice-versa, 881 - there's a lot of inlining possibilities as things grow, 882 - using a switch statement avoids the function call overhead. 883 884 This function could be moved into `print_insn_normal', but keeping it 885 separate makes clear the interface between `print_insn_normal' and each of 886 the handlers. */ 887 888 int 889 frv_cgen_extract_operand (CGEN_CPU_DESC cd, 890 int opindex, 891 CGEN_EXTRACT_INFO *ex_info, 892 CGEN_INSN_INT insn_value, 893 CGEN_FIELDS * fields, 894 bfd_vma pc) 895 { 896 /* Assume success (for those operands that are nops). */ 897 int length = 1; 898 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); 899 900 switch (opindex) 901 { 902 case FRV_OPERAND_A0 : 903 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A); 904 break; 905 case FRV_OPERAND_A1 : 906 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A); 907 break; 908 case FRV_OPERAND_ACC40SI : 909 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si); 910 break; 911 case FRV_OPERAND_ACC40SK : 912 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk); 913 break; 914 case FRV_OPERAND_ACC40UI : 915 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui); 916 break; 917 case FRV_OPERAND_ACC40UK : 918 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk); 919 break; 920 case FRV_OPERAND_ACCGI : 921 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi); 922 break; 923 case FRV_OPERAND_ACCGK : 924 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk); 925 break; 926 case FRV_OPERAND_CCI : 927 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi); 928 break; 929 case FRV_OPERAND_CPRDOUBLEK : 930 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk); 931 break; 932 case FRV_OPERAND_CPRI : 933 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi); 934 break; 935 case FRV_OPERAND_CPRJ : 936 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj); 937 break; 938 case FRV_OPERAND_CPRK : 939 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk); 940 break; 941 case FRV_OPERAND_CRI : 942 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi); 943 break; 944 case FRV_OPERAND_CRJ : 945 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj); 946 break; 947 case FRV_OPERAND_CRJ_FLOAT : 948 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float); 949 break; 950 case FRV_OPERAND_CRJ_INT : 951 { 952 long value; 953 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value); 954 value = ((value) + (4)); 955 fields->f_CRj_int = value; 956 } 957 break; 958 case FRV_OPERAND_CRK : 959 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk); 960 break; 961 case FRV_OPERAND_FCCI_1 : 962 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1); 963 break; 964 case FRV_OPERAND_FCCI_2 : 965 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2); 966 break; 967 case FRV_OPERAND_FCCI_3 : 968 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3); 969 break; 970 case FRV_OPERAND_FCCK : 971 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk); 972 break; 973 case FRV_OPERAND_FRDOUBLEI : 974 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 975 break; 976 case FRV_OPERAND_FRDOUBLEJ : 977 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 978 break; 979 case FRV_OPERAND_FRDOUBLEK : 980 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 981 break; 982 case FRV_OPERAND_FRI : 983 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 984 break; 985 case FRV_OPERAND_FRINTI : 986 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 987 break; 988 case FRV_OPERAND_FRINTIEVEN : 989 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 990 break; 991 case FRV_OPERAND_FRINTJ : 992 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 993 break; 994 case FRV_OPERAND_FRINTJEVEN : 995 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 996 break; 997 case FRV_OPERAND_FRINTK : 998 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 999 break; 1000 case FRV_OPERAND_FRINTKEVEN : 1001 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1002 break; 1003 case FRV_OPERAND_FRJ : 1004 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 1005 break; 1006 case FRV_OPERAND_FRK : 1007 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1008 break; 1009 case FRV_OPERAND_FRKHI : 1010 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1011 break; 1012 case FRV_OPERAND_FRKLO : 1013 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1014 break; 1015 case FRV_OPERAND_GRDOUBLEK : 1016 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1017 break; 1018 case FRV_OPERAND_GRI : 1019 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi); 1020 break; 1021 case FRV_OPERAND_GRJ : 1022 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj); 1023 break; 1024 case FRV_OPERAND_GRK : 1025 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1026 break; 1027 case FRV_OPERAND_GRKHI : 1028 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1029 break; 1030 case FRV_OPERAND_GRKLO : 1031 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1032 break; 1033 case FRV_OPERAND_ICCI_1 : 1034 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1); 1035 break; 1036 case FRV_OPERAND_ICCI_2 : 1037 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2); 1038 break; 1039 case FRV_OPERAND_ICCI_3 : 1040 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3); 1041 break; 1042 case FRV_OPERAND_LI : 1043 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI); 1044 break; 1045 case FRV_OPERAND_LRAD : 1046 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 1, 32, total_length, pc, & fields->f_LRAD); 1047 break; 1048 case FRV_OPERAND_LRAE : 1049 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_LRAE); 1050 break; 1051 case FRV_OPERAND_LRAS : 1052 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 1, 32, total_length, pc, & fields->f_LRAS); 1053 break; 1054 case FRV_OPERAND_TLBPRL : 1055 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_TLBPRL); 1056 break; 1057 case FRV_OPERAND_TLBPROPX : 1058 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_TLBPRopx); 1059 break; 1060 case FRV_OPERAND_AE : 1061 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae); 1062 break; 1063 case FRV_OPERAND_CALLANN : 1064 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1065 break; 1066 case FRV_OPERAND_CCOND : 1067 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond); 1068 break; 1069 case FRV_OPERAND_COND : 1070 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond); 1071 break; 1072 case FRV_OPERAND_D12 : 1073 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12); 1074 break; 1075 case FRV_OPERAND_DEBUG : 1076 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug); 1077 break; 1078 case FRV_OPERAND_EIR : 1079 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir); 1080 break; 1081 case FRV_OPERAND_HINT : 1082 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1083 break; 1084 case FRV_OPERAND_HINT_NOT_TAKEN : 1085 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1086 break; 1087 case FRV_OPERAND_HINT_TAKEN : 1088 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1089 break; 1090 case FRV_OPERAND_LABEL16 : 1091 { 1092 long value; 1093 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); 1094 value = ((((value) << (2))) + (pc)); 1095 fields->f_label16 = value; 1096 } 1097 break; 1098 case FRV_OPERAND_LABEL24 : 1099 { 1100 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6); 1101 if (length <= 0) break; 1102 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18); 1103 if (length <= 0) break; 1104 { 1105 FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc)); 1106 } 1107 } 1108 break; 1109 case FRV_OPERAND_LDANN : 1110 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1111 break; 1112 case FRV_OPERAND_LDDANN : 1113 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1114 break; 1115 case FRV_OPERAND_LOCK : 1116 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock); 1117 break; 1118 case FRV_OPERAND_PACK : 1119 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack); 1120 break; 1121 case FRV_OPERAND_S10 : 1122 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10); 1123 break; 1124 case FRV_OPERAND_S12 : 1125 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12); 1126 break; 1127 case FRV_OPERAND_S16 : 1128 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16); 1129 break; 1130 case FRV_OPERAND_S5 : 1131 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5); 1132 break; 1133 case FRV_OPERAND_S6 : 1134 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6); 1135 break; 1136 case FRV_OPERAND_S6_1 : 1137 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1); 1138 break; 1139 case FRV_OPERAND_SLO16 : 1140 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16); 1141 break; 1142 case FRV_OPERAND_SPR : 1143 { 1144 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h); 1145 if (length <= 0) break; 1146 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l); 1147 if (length <= 0) break; 1148 { 1149 FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l))); 1150 } 1151 } 1152 break; 1153 case FRV_OPERAND_U12 : 1154 { 1155 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h); 1156 if (length <= 0) break; 1157 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l); 1158 if (length <= 0) break; 1159 { 1160 FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l))); 1161 } 1162 } 1163 break; 1164 case FRV_OPERAND_U16 : 1165 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1166 break; 1167 case FRV_OPERAND_U6 : 1168 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6); 1169 break; 1170 case FRV_OPERAND_UHI16 : 1171 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1172 break; 1173 case FRV_OPERAND_ULO16 : 1174 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1175 break; 1176 1177 default : 1178 /* xgettext:c-format */ 1179 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), 1180 opindex); 1181 abort (); 1182 } 1183 1184 return length; 1185 } 1186 1187 cgen_insert_fn * const frv_cgen_insert_handlers[] = 1188 { 1189 insert_insn_normal, 1190 }; 1191 1192 cgen_extract_fn * const frv_cgen_extract_handlers[] = 1193 { 1194 extract_insn_normal, 1195 }; 1196 1197 int frv_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 1198 bfd_vma frv_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 1199 1200 /* Getting values from cgen_fields is handled by a collection of functions. 1201 They are distinguished by the type of the VALUE argument they return. 1202 TODO: floating point, inlining support, remove cases where result type 1203 not appropriate. */ 1204 1205 int 1206 frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1207 int opindex, 1208 const CGEN_FIELDS * fields) 1209 { 1210 int value; 1211 1212 switch (opindex) 1213 { 1214 case FRV_OPERAND_A0 : 1215 value = fields->f_A; 1216 break; 1217 case FRV_OPERAND_A1 : 1218 value = fields->f_A; 1219 break; 1220 case FRV_OPERAND_ACC40SI : 1221 value = fields->f_ACC40Si; 1222 break; 1223 case FRV_OPERAND_ACC40SK : 1224 value = fields->f_ACC40Sk; 1225 break; 1226 case FRV_OPERAND_ACC40UI : 1227 value = fields->f_ACC40Ui; 1228 break; 1229 case FRV_OPERAND_ACC40UK : 1230 value = fields->f_ACC40Uk; 1231 break; 1232 case FRV_OPERAND_ACCGI : 1233 value = fields->f_ACCGi; 1234 break; 1235 case FRV_OPERAND_ACCGK : 1236 value = fields->f_ACCGk; 1237 break; 1238 case FRV_OPERAND_CCI : 1239 value = fields->f_CCi; 1240 break; 1241 case FRV_OPERAND_CPRDOUBLEK : 1242 value = fields->f_CPRk; 1243 break; 1244 case FRV_OPERAND_CPRI : 1245 value = fields->f_CPRi; 1246 break; 1247 case FRV_OPERAND_CPRJ : 1248 value = fields->f_CPRj; 1249 break; 1250 case FRV_OPERAND_CPRK : 1251 value = fields->f_CPRk; 1252 break; 1253 case FRV_OPERAND_CRI : 1254 value = fields->f_CRi; 1255 break; 1256 case FRV_OPERAND_CRJ : 1257 value = fields->f_CRj; 1258 break; 1259 case FRV_OPERAND_CRJ_FLOAT : 1260 value = fields->f_CRj_float; 1261 break; 1262 case FRV_OPERAND_CRJ_INT : 1263 value = fields->f_CRj_int; 1264 break; 1265 case FRV_OPERAND_CRK : 1266 value = fields->f_CRk; 1267 break; 1268 case FRV_OPERAND_FCCI_1 : 1269 value = fields->f_FCCi_1; 1270 break; 1271 case FRV_OPERAND_FCCI_2 : 1272 value = fields->f_FCCi_2; 1273 break; 1274 case FRV_OPERAND_FCCI_3 : 1275 value = fields->f_FCCi_3; 1276 break; 1277 case FRV_OPERAND_FCCK : 1278 value = fields->f_FCCk; 1279 break; 1280 case FRV_OPERAND_FRDOUBLEI : 1281 value = fields->f_FRi; 1282 break; 1283 case FRV_OPERAND_FRDOUBLEJ : 1284 value = fields->f_FRj; 1285 break; 1286 case FRV_OPERAND_FRDOUBLEK : 1287 value = fields->f_FRk; 1288 break; 1289 case FRV_OPERAND_FRI : 1290 value = fields->f_FRi; 1291 break; 1292 case FRV_OPERAND_FRINTI : 1293 value = fields->f_FRi; 1294 break; 1295 case FRV_OPERAND_FRINTIEVEN : 1296 value = fields->f_FRi; 1297 break; 1298 case FRV_OPERAND_FRINTJ : 1299 value = fields->f_FRj; 1300 break; 1301 case FRV_OPERAND_FRINTJEVEN : 1302 value = fields->f_FRj; 1303 break; 1304 case FRV_OPERAND_FRINTK : 1305 value = fields->f_FRk; 1306 break; 1307 case FRV_OPERAND_FRINTKEVEN : 1308 value = fields->f_FRk; 1309 break; 1310 case FRV_OPERAND_FRJ : 1311 value = fields->f_FRj; 1312 break; 1313 case FRV_OPERAND_FRK : 1314 value = fields->f_FRk; 1315 break; 1316 case FRV_OPERAND_FRKHI : 1317 value = fields->f_FRk; 1318 break; 1319 case FRV_OPERAND_FRKLO : 1320 value = fields->f_FRk; 1321 break; 1322 case FRV_OPERAND_GRDOUBLEK : 1323 value = fields->f_GRk; 1324 break; 1325 case FRV_OPERAND_GRI : 1326 value = fields->f_GRi; 1327 break; 1328 case FRV_OPERAND_GRJ : 1329 value = fields->f_GRj; 1330 break; 1331 case FRV_OPERAND_GRK : 1332 value = fields->f_GRk; 1333 break; 1334 case FRV_OPERAND_GRKHI : 1335 value = fields->f_GRk; 1336 break; 1337 case FRV_OPERAND_GRKLO : 1338 value = fields->f_GRk; 1339 break; 1340 case FRV_OPERAND_ICCI_1 : 1341 value = fields->f_ICCi_1; 1342 break; 1343 case FRV_OPERAND_ICCI_2 : 1344 value = fields->f_ICCi_2; 1345 break; 1346 case FRV_OPERAND_ICCI_3 : 1347 value = fields->f_ICCi_3; 1348 break; 1349 case FRV_OPERAND_LI : 1350 value = fields->f_LI; 1351 break; 1352 case FRV_OPERAND_LRAD : 1353 value = fields->f_LRAD; 1354 break; 1355 case FRV_OPERAND_LRAE : 1356 value = fields->f_LRAE; 1357 break; 1358 case FRV_OPERAND_LRAS : 1359 value = fields->f_LRAS; 1360 break; 1361 case FRV_OPERAND_TLBPRL : 1362 value = fields->f_TLBPRL; 1363 break; 1364 case FRV_OPERAND_TLBPROPX : 1365 value = fields->f_TLBPRopx; 1366 break; 1367 case FRV_OPERAND_AE : 1368 value = fields->f_ae; 1369 break; 1370 case FRV_OPERAND_CALLANN : 1371 value = fields->f_reloc_ann; 1372 break; 1373 case FRV_OPERAND_CCOND : 1374 value = fields->f_ccond; 1375 break; 1376 case FRV_OPERAND_COND : 1377 value = fields->f_cond; 1378 break; 1379 case FRV_OPERAND_D12 : 1380 value = fields->f_d12; 1381 break; 1382 case FRV_OPERAND_DEBUG : 1383 value = fields->f_debug; 1384 break; 1385 case FRV_OPERAND_EIR : 1386 value = fields->f_eir; 1387 break; 1388 case FRV_OPERAND_HINT : 1389 value = fields->f_hint; 1390 break; 1391 case FRV_OPERAND_HINT_NOT_TAKEN : 1392 value = fields->f_hint; 1393 break; 1394 case FRV_OPERAND_HINT_TAKEN : 1395 value = fields->f_hint; 1396 break; 1397 case FRV_OPERAND_LABEL16 : 1398 value = fields->f_label16; 1399 break; 1400 case FRV_OPERAND_LABEL24 : 1401 value = fields->f_label24; 1402 break; 1403 case FRV_OPERAND_LDANN : 1404 value = fields->f_reloc_ann; 1405 break; 1406 case FRV_OPERAND_LDDANN : 1407 value = fields->f_reloc_ann; 1408 break; 1409 case FRV_OPERAND_LOCK : 1410 value = fields->f_lock; 1411 break; 1412 case FRV_OPERAND_PACK : 1413 value = fields->f_pack; 1414 break; 1415 case FRV_OPERAND_S10 : 1416 value = fields->f_s10; 1417 break; 1418 case FRV_OPERAND_S12 : 1419 value = fields->f_d12; 1420 break; 1421 case FRV_OPERAND_S16 : 1422 value = fields->f_s16; 1423 break; 1424 case FRV_OPERAND_S5 : 1425 value = fields->f_s5; 1426 break; 1427 case FRV_OPERAND_S6 : 1428 value = fields->f_s6; 1429 break; 1430 case FRV_OPERAND_S6_1 : 1431 value = fields->f_s6_1; 1432 break; 1433 case FRV_OPERAND_SLO16 : 1434 value = fields->f_s16; 1435 break; 1436 case FRV_OPERAND_SPR : 1437 value = fields->f_spr; 1438 break; 1439 case FRV_OPERAND_U12 : 1440 value = fields->f_u12; 1441 break; 1442 case FRV_OPERAND_U16 : 1443 value = fields->f_u16; 1444 break; 1445 case FRV_OPERAND_U6 : 1446 value = fields->f_u6; 1447 break; 1448 case FRV_OPERAND_UHI16 : 1449 value = fields->f_u16; 1450 break; 1451 case FRV_OPERAND_ULO16 : 1452 value = fields->f_u16; 1453 break; 1454 1455 default : 1456 /* xgettext:c-format */ 1457 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), 1458 opindex); 1459 abort (); 1460 } 1461 1462 return value; 1463 } 1464 1465 bfd_vma 1466 frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1467 int opindex, 1468 const CGEN_FIELDS * fields) 1469 { 1470 bfd_vma value; 1471 1472 switch (opindex) 1473 { 1474 case FRV_OPERAND_A0 : 1475 value = fields->f_A; 1476 break; 1477 case FRV_OPERAND_A1 : 1478 value = fields->f_A; 1479 break; 1480 case FRV_OPERAND_ACC40SI : 1481 value = fields->f_ACC40Si; 1482 break; 1483 case FRV_OPERAND_ACC40SK : 1484 value = fields->f_ACC40Sk; 1485 break; 1486 case FRV_OPERAND_ACC40UI : 1487 value = fields->f_ACC40Ui; 1488 break; 1489 case FRV_OPERAND_ACC40UK : 1490 value = fields->f_ACC40Uk; 1491 break; 1492 case FRV_OPERAND_ACCGI : 1493 value = fields->f_ACCGi; 1494 break; 1495 case FRV_OPERAND_ACCGK : 1496 value = fields->f_ACCGk; 1497 break; 1498 case FRV_OPERAND_CCI : 1499 value = fields->f_CCi; 1500 break; 1501 case FRV_OPERAND_CPRDOUBLEK : 1502 value = fields->f_CPRk; 1503 break; 1504 case FRV_OPERAND_CPRI : 1505 value = fields->f_CPRi; 1506 break; 1507 case FRV_OPERAND_CPRJ : 1508 value = fields->f_CPRj; 1509 break; 1510 case FRV_OPERAND_CPRK : 1511 value = fields->f_CPRk; 1512 break; 1513 case FRV_OPERAND_CRI : 1514 value = fields->f_CRi; 1515 break; 1516 case FRV_OPERAND_CRJ : 1517 value = fields->f_CRj; 1518 break; 1519 case FRV_OPERAND_CRJ_FLOAT : 1520 value = fields->f_CRj_float; 1521 break; 1522 case FRV_OPERAND_CRJ_INT : 1523 value = fields->f_CRj_int; 1524 break; 1525 case FRV_OPERAND_CRK : 1526 value = fields->f_CRk; 1527 break; 1528 case FRV_OPERAND_FCCI_1 : 1529 value = fields->f_FCCi_1; 1530 break; 1531 case FRV_OPERAND_FCCI_2 : 1532 value = fields->f_FCCi_2; 1533 break; 1534 case FRV_OPERAND_FCCI_3 : 1535 value = fields->f_FCCi_3; 1536 break; 1537 case FRV_OPERAND_FCCK : 1538 value = fields->f_FCCk; 1539 break; 1540 case FRV_OPERAND_FRDOUBLEI : 1541 value = fields->f_FRi; 1542 break; 1543 case FRV_OPERAND_FRDOUBLEJ : 1544 value = fields->f_FRj; 1545 break; 1546 case FRV_OPERAND_FRDOUBLEK : 1547 value = fields->f_FRk; 1548 break; 1549 case FRV_OPERAND_FRI : 1550 value = fields->f_FRi; 1551 break; 1552 case FRV_OPERAND_FRINTI : 1553 value = fields->f_FRi; 1554 break; 1555 case FRV_OPERAND_FRINTIEVEN : 1556 value = fields->f_FRi; 1557 break; 1558 case FRV_OPERAND_FRINTJ : 1559 value = fields->f_FRj; 1560 break; 1561 case FRV_OPERAND_FRINTJEVEN : 1562 value = fields->f_FRj; 1563 break; 1564 case FRV_OPERAND_FRINTK : 1565 value = fields->f_FRk; 1566 break; 1567 case FRV_OPERAND_FRINTKEVEN : 1568 value = fields->f_FRk; 1569 break; 1570 case FRV_OPERAND_FRJ : 1571 value = fields->f_FRj; 1572 break; 1573 case FRV_OPERAND_FRK : 1574 value = fields->f_FRk; 1575 break; 1576 case FRV_OPERAND_FRKHI : 1577 value = fields->f_FRk; 1578 break; 1579 case FRV_OPERAND_FRKLO : 1580 value = fields->f_FRk; 1581 break; 1582 case FRV_OPERAND_GRDOUBLEK : 1583 value = fields->f_GRk; 1584 break; 1585 case FRV_OPERAND_GRI : 1586 value = fields->f_GRi; 1587 break; 1588 case FRV_OPERAND_GRJ : 1589 value = fields->f_GRj; 1590 break; 1591 case FRV_OPERAND_GRK : 1592 value = fields->f_GRk; 1593 break; 1594 case FRV_OPERAND_GRKHI : 1595 value = fields->f_GRk; 1596 break; 1597 case FRV_OPERAND_GRKLO : 1598 value = fields->f_GRk; 1599 break; 1600 case FRV_OPERAND_ICCI_1 : 1601 value = fields->f_ICCi_1; 1602 break; 1603 case FRV_OPERAND_ICCI_2 : 1604 value = fields->f_ICCi_2; 1605 break; 1606 case FRV_OPERAND_ICCI_3 : 1607 value = fields->f_ICCi_3; 1608 break; 1609 case FRV_OPERAND_LI : 1610 value = fields->f_LI; 1611 break; 1612 case FRV_OPERAND_LRAD : 1613 value = fields->f_LRAD; 1614 break; 1615 case FRV_OPERAND_LRAE : 1616 value = fields->f_LRAE; 1617 break; 1618 case FRV_OPERAND_LRAS : 1619 value = fields->f_LRAS; 1620 break; 1621 case FRV_OPERAND_TLBPRL : 1622 value = fields->f_TLBPRL; 1623 break; 1624 case FRV_OPERAND_TLBPROPX : 1625 value = fields->f_TLBPRopx; 1626 break; 1627 case FRV_OPERAND_AE : 1628 value = fields->f_ae; 1629 break; 1630 case FRV_OPERAND_CALLANN : 1631 value = fields->f_reloc_ann; 1632 break; 1633 case FRV_OPERAND_CCOND : 1634 value = fields->f_ccond; 1635 break; 1636 case FRV_OPERAND_COND : 1637 value = fields->f_cond; 1638 break; 1639 case FRV_OPERAND_D12 : 1640 value = fields->f_d12; 1641 break; 1642 case FRV_OPERAND_DEBUG : 1643 value = fields->f_debug; 1644 break; 1645 case FRV_OPERAND_EIR : 1646 value = fields->f_eir; 1647 break; 1648 case FRV_OPERAND_HINT : 1649 value = fields->f_hint; 1650 break; 1651 case FRV_OPERAND_HINT_NOT_TAKEN : 1652 value = fields->f_hint; 1653 break; 1654 case FRV_OPERAND_HINT_TAKEN : 1655 value = fields->f_hint; 1656 break; 1657 case FRV_OPERAND_LABEL16 : 1658 value = fields->f_label16; 1659 break; 1660 case FRV_OPERAND_LABEL24 : 1661 value = fields->f_label24; 1662 break; 1663 case FRV_OPERAND_LDANN : 1664 value = fields->f_reloc_ann; 1665 break; 1666 case FRV_OPERAND_LDDANN : 1667 value = fields->f_reloc_ann; 1668 break; 1669 case FRV_OPERAND_LOCK : 1670 value = fields->f_lock; 1671 break; 1672 case FRV_OPERAND_PACK : 1673 value = fields->f_pack; 1674 break; 1675 case FRV_OPERAND_S10 : 1676 value = fields->f_s10; 1677 break; 1678 case FRV_OPERAND_S12 : 1679 value = fields->f_d12; 1680 break; 1681 case FRV_OPERAND_S16 : 1682 value = fields->f_s16; 1683 break; 1684 case FRV_OPERAND_S5 : 1685 value = fields->f_s5; 1686 break; 1687 case FRV_OPERAND_S6 : 1688 value = fields->f_s6; 1689 break; 1690 case FRV_OPERAND_S6_1 : 1691 value = fields->f_s6_1; 1692 break; 1693 case FRV_OPERAND_SLO16 : 1694 value = fields->f_s16; 1695 break; 1696 case FRV_OPERAND_SPR : 1697 value = fields->f_spr; 1698 break; 1699 case FRV_OPERAND_U12 : 1700 value = fields->f_u12; 1701 break; 1702 case FRV_OPERAND_U16 : 1703 value = fields->f_u16; 1704 break; 1705 case FRV_OPERAND_U6 : 1706 value = fields->f_u6; 1707 break; 1708 case FRV_OPERAND_UHI16 : 1709 value = fields->f_u16; 1710 break; 1711 case FRV_OPERAND_ULO16 : 1712 value = fields->f_u16; 1713 break; 1714 1715 default : 1716 /* xgettext:c-format */ 1717 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), 1718 opindex); 1719 abort (); 1720 } 1721 1722 return value; 1723 } 1724 1725 void frv_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); 1726 void frv_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); 1727 1728 /* Stuffing values in cgen_fields is handled by a collection of functions. 1729 They are distinguished by the type of the VALUE argument they accept. 1730 TODO: floating point, inlining support, remove cases where argument type 1731 not appropriate. */ 1732 1733 void 1734 frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1735 int opindex, 1736 CGEN_FIELDS * fields, 1737 int value) 1738 { 1739 switch (opindex) 1740 { 1741 case FRV_OPERAND_A0 : 1742 fields->f_A = value; 1743 break; 1744 case FRV_OPERAND_A1 : 1745 fields->f_A = value; 1746 break; 1747 case FRV_OPERAND_ACC40SI : 1748 fields->f_ACC40Si = value; 1749 break; 1750 case FRV_OPERAND_ACC40SK : 1751 fields->f_ACC40Sk = value; 1752 break; 1753 case FRV_OPERAND_ACC40UI : 1754 fields->f_ACC40Ui = value; 1755 break; 1756 case FRV_OPERAND_ACC40UK : 1757 fields->f_ACC40Uk = value; 1758 break; 1759 case FRV_OPERAND_ACCGI : 1760 fields->f_ACCGi = value; 1761 break; 1762 case FRV_OPERAND_ACCGK : 1763 fields->f_ACCGk = value; 1764 break; 1765 case FRV_OPERAND_CCI : 1766 fields->f_CCi = value; 1767 break; 1768 case FRV_OPERAND_CPRDOUBLEK : 1769 fields->f_CPRk = value; 1770 break; 1771 case FRV_OPERAND_CPRI : 1772 fields->f_CPRi = value; 1773 break; 1774 case FRV_OPERAND_CPRJ : 1775 fields->f_CPRj = value; 1776 break; 1777 case FRV_OPERAND_CPRK : 1778 fields->f_CPRk = value; 1779 break; 1780 case FRV_OPERAND_CRI : 1781 fields->f_CRi = value; 1782 break; 1783 case FRV_OPERAND_CRJ : 1784 fields->f_CRj = value; 1785 break; 1786 case FRV_OPERAND_CRJ_FLOAT : 1787 fields->f_CRj_float = value; 1788 break; 1789 case FRV_OPERAND_CRJ_INT : 1790 fields->f_CRj_int = value; 1791 break; 1792 case FRV_OPERAND_CRK : 1793 fields->f_CRk = value; 1794 break; 1795 case FRV_OPERAND_FCCI_1 : 1796 fields->f_FCCi_1 = value; 1797 break; 1798 case FRV_OPERAND_FCCI_2 : 1799 fields->f_FCCi_2 = value; 1800 break; 1801 case FRV_OPERAND_FCCI_3 : 1802 fields->f_FCCi_3 = value; 1803 break; 1804 case FRV_OPERAND_FCCK : 1805 fields->f_FCCk = value; 1806 break; 1807 case FRV_OPERAND_FRDOUBLEI : 1808 fields->f_FRi = value; 1809 break; 1810 case FRV_OPERAND_FRDOUBLEJ : 1811 fields->f_FRj = value; 1812 break; 1813 case FRV_OPERAND_FRDOUBLEK : 1814 fields->f_FRk = value; 1815 break; 1816 case FRV_OPERAND_FRI : 1817 fields->f_FRi = value; 1818 break; 1819 case FRV_OPERAND_FRINTI : 1820 fields->f_FRi = value; 1821 break; 1822 case FRV_OPERAND_FRINTIEVEN : 1823 fields->f_FRi = value; 1824 break; 1825 case FRV_OPERAND_FRINTJ : 1826 fields->f_FRj = value; 1827 break; 1828 case FRV_OPERAND_FRINTJEVEN : 1829 fields->f_FRj = value; 1830 break; 1831 case FRV_OPERAND_FRINTK : 1832 fields->f_FRk = value; 1833 break; 1834 case FRV_OPERAND_FRINTKEVEN : 1835 fields->f_FRk = value; 1836 break; 1837 case FRV_OPERAND_FRJ : 1838 fields->f_FRj = value; 1839 break; 1840 case FRV_OPERAND_FRK : 1841 fields->f_FRk = value; 1842 break; 1843 case FRV_OPERAND_FRKHI : 1844 fields->f_FRk = value; 1845 break; 1846 case FRV_OPERAND_FRKLO : 1847 fields->f_FRk = value; 1848 break; 1849 case FRV_OPERAND_GRDOUBLEK : 1850 fields->f_GRk = value; 1851 break; 1852 case FRV_OPERAND_GRI : 1853 fields->f_GRi = value; 1854 break; 1855 case FRV_OPERAND_GRJ : 1856 fields->f_GRj = value; 1857 break; 1858 case FRV_OPERAND_GRK : 1859 fields->f_GRk = value; 1860 break; 1861 case FRV_OPERAND_GRKHI : 1862 fields->f_GRk = value; 1863 break; 1864 case FRV_OPERAND_GRKLO : 1865 fields->f_GRk = value; 1866 break; 1867 case FRV_OPERAND_ICCI_1 : 1868 fields->f_ICCi_1 = value; 1869 break; 1870 case FRV_OPERAND_ICCI_2 : 1871 fields->f_ICCi_2 = value; 1872 break; 1873 case FRV_OPERAND_ICCI_3 : 1874 fields->f_ICCi_3 = value; 1875 break; 1876 case FRV_OPERAND_LI : 1877 fields->f_LI = value; 1878 break; 1879 case FRV_OPERAND_LRAD : 1880 fields->f_LRAD = value; 1881 break; 1882 case FRV_OPERAND_LRAE : 1883 fields->f_LRAE = value; 1884 break; 1885 case FRV_OPERAND_LRAS : 1886 fields->f_LRAS = value; 1887 break; 1888 case FRV_OPERAND_TLBPRL : 1889 fields->f_TLBPRL = value; 1890 break; 1891 case FRV_OPERAND_TLBPROPX : 1892 fields->f_TLBPRopx = value; 1893 break; 1894 case FRV_OPERAND_AE : 1895 fields->f_ae = value; 1896 break; 1897 case FRV_OPERAND_CALLANN : 1898 fields->f_reloc_ann = value; 1899 break; 1900 case FRV_OPERAND_CCOND : 1901 fields->f_ccond = value; 1902 break; 1903 case FRV_OPERAND_COND : 1904 fields->f_cond = value; 1905 break; 1906 case FRV_OPERAND_D12 : 1907 fields->f_d12 = value; 1908 break; 1909 case FRV_OPERAND_DEBUG : 1910 fields->f_debug = value; 1911 break; 1912 case FRV_OPERAND_EIR : 1913 fields->f_eir = value; 1914 break; 1915 case FRV_OPERAND_HINT : 1916 fields->f_hint = value; 1917 break; 1918 case FRV_OPERAND_HINT_NOT_TAKEN : 1919 fields->f_hint = value; 1920 break; 1921 case FRV_OPERAND_HINT_TAKEN : 1922 fields->f_hint = value; 1923 break; 1924 case FRV_OPERAND_LABEL16 : 1925 fields->f_label16 = value; 1926 break; 1927 case FRV_OPERAND_LABEL24 : 1928 fields->f_label24 = value; 1929 break; 1930 case FRV_OPERAND_LDANN : 1931 fields->f_reloc_ann = value; 1932 break; 1933 case FRV_OPERAND_LDDANN : 1934 fields->f_reloc_ann = value; 1935 break; 1936 case FRV_OPERAND_LOCK : 1937 fields->f_lock = value; 1938 break; 1939 case FRV_OPERAND_PACK : 1940 fields->f_pack = value; 1941 break; 1942 case FRV_OPERAND_S10 : 1943 fields->f_s10 = value; 1944 break; 1945 case FRV_OPERAND_S12 : 1946 fields->f_d12 = value; 1947 break; 1948 case FRV_OPERAND_S16 : 1949 fields->f_s16 = value; 1950 break; 1951 case FRV_OPERAND_S5 : 1952 fields->f_s5 = value; 1953 break; 1954 case FRV_OPERAND_S6 : 1955 fields->f_s6 = value; 1956 break; 1957 case FRV_OPERAND_S6_1 : 1958 fields->f_s6_1 = value; 1959 break; 1960 case FRV_OPERAND_SLO16 : 1961 fields->f_s16 = value; 1962 break; 1963 case FRV_OPERAND_SPR : 1964 fields->f_spr = value; 1965 break; 1966 case FRV_OPERAND_U12 : 1967 fields->f_u12 = value; 1968 break; 1969 case FRV_OPERAND_U16 : 1970 fields->f_u16 = value; 1971 break; 1972 case FRV_OPERAND_U6 : 1973 fields->f_u6 = value; 1974 break; 1975 case FRV_OPERAND_UHI16 : 1976 fields->f_u16 = value; 1977 break; 1978 case FRV_OPERAND_ULO16 : 1979 fields->f_u16 = value; 1980 break; 1981 1982 default : 1983 /* xgettext:c-format */ 1984 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), 1985 opindex); 1986 abort (); 1987 } 1988 } 1989 1990 void 1991 frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1992 int opindex, 1993 CGEN_FIELDS * fields, 1994 bfd_vma value) 1995 { 1996 switch (opindex) 1997 { 1998 case FRV_OPERAND_A0 : 1999 fields->f_A = value; 2000 break; 2001 case FRV_OPERAND_A1 : 2002 fields->f_A = value; 2003 break; 2004 case FRV_OPERAND_ACC40SI : 2005 fields->f_ACC40Si = value; 2006 break; 2007 case FRV_OPERAND_ACC40SK : 2008 fields->f_ACC40Sk = value; 2009 break; 2010 case FRV_OPERAND_ACC40UI : 2011 fields->f_ACC40Ui = value; 2012 break; 2013 case FRV_OPERAND_ACC40UK : 2014 fields->f_ACC40Uk = value; 2015 break; 2016 case FRV_OPERAND_ACCGI : 2017 fields->f_ACCGi = value; 2018 break; 2019 case FRV_OPERAND_ACCGK : 2020 fields->f_ACCGk = value; 2021 break; 2022 case FRV_OPERAND_CCI : 2023 fields->f_CCi = value; 2024 break; 2025 case FRV_OPERAND_CPRDOUBLEK : 2026 fields->f_CPRk = value; 2027 break; 2028 case FRV_OPERAND_CPRI : 2029 fields->f_CPRi = value; 2030 break; 2031 case FRV_OPERAND_CPRJ : 2032 fields->f_CPRj = value; 2033 break; 2034 case FRV_OPERAND_CPRK : 2035 fields->f_CPRk = value; 2036 break; 2037 case FRV_OPERAND_CRI : 2038 fields->f_CRi = value; 2039 break; 2040 case FRV_OPERAND_CRJ : 2041 fields->f_CRj = value; 2042 break; 2043 case FRV_OPERAND_CRJ_FLOAT : 2044 fields->f_CRj_float = value; 2045 break; 2046 case FRV_OPERAND_CRJ_INT : 2047 fields->f_CRj_int = value; 2048 break; 2049 case FRV_OPERAND_CRK : 2050 fields->f_CRk = value; 2051 break; 2052 case FRV_OPERAND_FCCI_1 : 2053 fields->f_FCCi_1 = value; 2054 break; 2055 case FRV_OPERAND_FCCI_2 : 2056 fields->f_FCCi_2 = value; 2057 break; 2058 case FRV_OPERAND_FCCI_3 : 2059 fields->f_FCCi_3 = value; 2060 break; 2061 case FRV_OPERAND_FCCK : 2062 fields->f_FCCk = value; 2063 break; 2064 case FRV_OPERAND_FRDOUBLEI : 2065 fields->f_FRi = value; 2066 break; 2067 case FRV_OPERAND_FRDOUBLEJ : 2068 fields->f_FRj = value; 2069 break; 2070 case FRV_OPERAND_FRDOUBLEK : 2071 fields->f_FRk = value; 2072 break; 2073 case FRV_OPERAND_FRI : 2074 fields->f_FRi = value; 2075 break; 2076 case FRV_OPERAND_FRINTI : 2077 fields->f_FRi = value; 2078 break; 2079 case FRV_OPERAND_FRINTIEVEN : 2080 fields->f_FRi = value; 2081 break; 2082 case FRV_OPERAND_FRINTJ : 2083 fields->f_FRj = value; 2084 break; 2085 case FRV_OPERAND_FRINTJEVEN : 2086 fields->f_FRj = value; 2087 break; 2088 case FRV_OPERAND_FRINTK : 2089 fields->f_FRk = value; 2090 break; 2091 case FRV_OPERAND_FRINTKEVEN : 2092 fields->f_FRk = value; 2093 break; 2094 case FRV_OPERAND_FRJ : 2095 fields->f_FRj = value; 2096 break; 2097 case FRV_OPERAND_FRK : 2098 fields->f_FRk = value; 2099 break; 2100 case FRV_OPERAND_FRKHI : 2101 fields->f_FRk = value; 2102 break; 2103 case FRV_OPERAND_FRKLO : 2104 fields->f_FRk = value; 2105 break; 2106 case FRV_OPERAND_GRDOUBLEK : 2107 fields->f_GRk = value; 2108 break; 2109 case FRV_OPERAND_GRI : 2110 fields->f_GRi = value; 2111 break; 2112 case FRV_OPERAND_GRJ : 2113 fields->f_GRj = value; 2114 break; 2115 case FRV_OPERAND_GRK : 2116 fields->f_GRk = value; 2117 break; 2118 case FRV_OPERAND_GRKHI : 2119 fields->f_GRk = value; 2120 break; 2121 case FRV_OPERAND_GRKLO : 2122 fields->f_GRk = value; 2123 break; 2124 case FRV_OPERAND_ICCI_1 : 2125 fields->f_ICCi_1 = value; 2126 break; 2127 case FRV_OPERAND_ICCI_2 : 2128 fields->f_ICCi_2 = value; 2129 break; 2130 case FRV_OPERAND_ICCI_3 : 2131 fields->f_ICCi_3 = value; 2132 break; 2133 case FRV_OPERAND_LI : 2134 fields->f_LI = value; 2135 break; 2136 case FRV_OPERAND_LRAD : 2137 fields->f_LRAD = value; 2138 break; 2139 case FRV_OPERAND_LRAE : 2140 fields->f_LRAE = value; 2141 break; 2142 case FRV_OPERAND_LRAS : 2143 fields->f_LRAS = value; 2144 break; 2145 case FRV_OPERAND_TLBPRL : 2146 fields->f_TLBPRL = value; 2147 break; 2148 case FRV_OPERAND_TLBPROPX : 2149 fields->f_TLBPRopx = value; 2150 break; 2151 case FRV_OPERAND_AE : 2152 fields->f_ae = value; 2153 break; 2154 case FRV_OPERAND_CALLANN : 2155 fields->f_reloc_ann = value; 2156 break; 2157 case FRV_OPERAND_CCOND : 2158 fields->f_ccond = value; 2159 break; 2160 case FRV_OPERAND_COND : 2161 fields->f_cond = value; 2162 break; 2163 case FRV_OPERAND_D12 : 2164 fields->f_d12 = value; 2165 break; 2166 case FRV_OPERAND_DEBUG : 2167 fields->f_debug = value; 2168 break; 2169 case FRV_OPERAND_EIR : 2170 fields->f_eir = value; 2171 break; 2172 case FRV_OPERAND_HINT : 2173 fields->f_hint = value; 2174 break; 2175 case FRV_OPERAND_HINT_NOT_TAKEN : 2176 fields->f_hint = value; 2177 break; 2178 case FRV_OPERAND_HINT_TAKEN : 2179 fields->f_hint = value; 2180 break; 2181 case FRV_OPERAND_LABEL16 : 2182 fields->f_label16 = value; 2183 break; 2184 case FRV_OPERAND_LABEL24 : 2185 fields->f_label24 = value; 2186 break; 2187 case FRV_OPERAND_LDANN : 2188 fields->f_reloc_ann = value; 2189 break; 2190 case FRV_OPERAND_LDDANN : 2191 fields->f_reloc_ann = value; 2192 break; 2193 case FRV_OPERAND_LOCK : 2194 fields->f_lock = value; 2195 break; 2196 case FRV_OPERAND_PACK : 2197 fields->f_pack = value; 2198 break; 2199 case FRV_OPERAND_S10 : 2200 fields->f_s10 = value; 2201 break; 2202 case FRV_OPERAND_S12 : 2203 fields->f_d12 = value; 2204 break; 2205 case FRV_OPERAND_S16 : 2206 fields->f_s16 = value; 2207 break; 2208 case FRV_OPERAND_S5 : 2209 fields->f_s5 = value; 2210 break; 2211 case FRV_OPERAND_S6 : 2212 fields->f_s6 = value; 2213 break; 2214 case FRV_OPERAND_S6_1 : 2215 fields->f_s6_1 = value; 2216 break; 2217 case FRV_OPERAND_SLO16 : 2218 fields->f_s16 = value; 2219 break; 2220 case FRV_OPERAND_SPR : 2221 fields->f_spr = value; 2222 break; 2223 case FRV_OPERAND_U12 : 2224 fields->f_u12 = value; 2225 break; 2226 case FRV_OPERAND_U16 : 2227 fields->f_u16 = value; 2228 break; 2229 case FRV_OPERAND_U6 : 2230 fields->f_u6 = value; 2231 break; 2232 case FRV_OPERAND_UHI16 : 2233 fields->f_u16 = value; 2234 break; 2235 case FRV_OPERAND_ULO16 : 2236 fields->f_u16 = value; 2237 break; 2238 2239 default : 2240 /* xgettext:c-format */ 2241 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), 2242 opindex); 2243 abort (); 2244 } 2245 } 2246 2247 /* Function to call before using the instruction builder tables. */ 2248 2249 void 2250 frv_cgen_init_ibld_table (CGEN_CPU_DESC cd) 2251 { 2252 cd->insert_handlers = & frv_cgen_insert_handlers[0]; 2253 cd->extract_handlers = & frv_cgen_extract_handlers[0]; 2254 2255 cd->insert_operand = frv_cgen_insert_operand; 2256 cd->extract_operand = frv_cgen_extract_operand; 2257 2258 cd->get_int_operand = frv_cgen_get_int_operand; 2259 cd->set_int_operand = frv_cgen_set_int_operand; 2260 cd->get_vma_operand = frv_cgen_get_vma_operand; 2261 cd->set_vma_operand = frv_cgen_set_vma_operand; 2262 } 2263