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-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 "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; 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 * frv_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 frv_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 FRV_OPERAND_A0 : 572 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer); 573 break; 574 case FRV_OPERAND_A1 : 575 errmsg = insert_normal (cd, fields->f_A, 0, 0, 17, 1, 32, total_length, buffer); 576 break; 577 case FRV_OPERAND_ACC40SI : 578 errmsg = insert_normal (cd, fields->f_ACC40Si, 0, 0, 17, 6, 32, total_length, buffer); 579 break; 580 case FRV_OPERAND_ACC40SK : 581 errmsg = insert_normal (cd, fields->f_ACC40Sk, 0, 0, 30, 6, 32, total_length, buffer); 582 break; 583 case FRV_OPERAND_ACC40UI : 584 errmsg = insert_normal (cd, fields->f_ACC40Ui, 0, 0, 17, 6, 32, total_length, buffer); 585 break; 586 case FRV_OPERAND_ACC40UK : 587 errmsg = insert_normal (cd, fields->f_ACC40Uk, 0, 0, 30, 6, 32, total_length, buffer); 588 break; 589 case FRV_OPERAND_ACCGI : 590 errmsg = insert_normal (cd, fields->f_ACCGi, 0, 0, 17, 6, 32, total_length, buffer); 591 break; 592 case FRV_OPERAND_ACCGK : 593 errmsg = insert_normal (cd, fields->f_ACCGk, 0, 0, 30, 6, 32, total_length, buffer); 594 break; 595 case FRV_OPERAND_CCI : 596 errmsg = insert_normal (cd, fields->f_CCi, 0, 0, 11, 3, 32, total_length, buffer); 597 break; 598 case FRV_OPERAND_CPRDOUBLEK : 599 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer); 600 break; 601 case FRV_OPERAND_CPRI : 602 errmsg = insert_normal (cd, fields->f_CPRi, 0, 0, 17, 6, 32, total_length, buffer); 603 break; 604 case FRV_OPERAND_CPRJ : 605 errmsg = insert_normal (cd, fields->f_CPRj, 0, 0, 5, 6, 32, total_length, buffer); 606 break; 607 case FRV_OPERAND_CPRK : 608 errmsg = insert_normal (cd, fields->f_CPRk, 0, 0, 30, 6, 32, total_length, buffer); 609 break; 610 case FRV_OPERAND_CRI : 611 errmsg = insert_normal (cd, fields->f_CRi, 0, 0, 14, 3, 32, total_length, buffer); 612 break; 613 case FRV_OPERAND_CRJ : 614 errmsg = insert_normal (cd, fields->f_CRj, 0, 0, 2, 3, 32, total_length, buffer); 615 break; 616 case FRV_OPERAND_CRJ_FLOAT : 617 errmsg = insert_normal (cd, fields->f_CRj_float, 0, 0, 26, 2, 32, total_length, buffer); 618 break; 619 case FRV_OPERAND_CRJ_INT : 620 { 621 long value = fields->f_CRj_int; 622 value = ((value) - (4)); 623 errmsg = insert_normal (cd, value, 0, 0, 26, 2, 32, total_length, buffer); 624 } 625 break; 626 case FRV_OPERAND_CRK : 627 errmsg = insert_normal (cd, fields->f_CRk, 0, 0, 27, 3, 32, total_length, buffer); 628 break; 629 case FRV_OPERAND_FCCI_1 : 630 errmsg = insert_normal (cd, fields->f_FCCi_1, 0, 0, 11, 2, 32, total_length, buffer); 631 break; 632 case FRV_OPERAND_FCCI_2 : 633 errmsg = insert_normal (cd, fields->f_FCCi_2, 0, 0, 26, 2, 32, total_length, buffer); 634 break; 635 case FRV_OPERAND_FCCI_3 : 636 errmsg = insert_normal (cd, fields->f_FCCi_3, 0, 0, 1, 2, 32, total_length, buffer); 637 break; 638 case FRV_OPERAND_FCCK : 639 errmsg = insert_normal (cd, fields->f_FCCk, 0, 0, 26, 2, 32, total_length, buffer); 640 break; 641 case FRV_OPERAND_FRDOUBLEI : 642 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 643 break; 644 case FRV_OPERAND_FRDOUBLEJ : 645 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 646 break; 647 case FRV_OPERAND_FRDOUBLEK : 648 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 649 break; 650 case FRV_OPERAND_FRI : 651 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 652 break; 653 case FRV_OPERAND_FRINTI : 654 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 655 break; 656 case FRV_OPERAND_FRINTIEVEN : 657 errmsg = insert_normal (cd, fields->f_FRi, 0, 0, 17, 6, 32, total_length, buffer); 658 break; 659 case FRV_OPERAND_FRINTJ : 660 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 661 break; 662 case FRV_OPERAND_FRINTJEVEN : 663 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 664 break; 665 case FRV_OPERAND_FRINTK : 666 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 667 break; 668 case FRV_OPERAND_FRINTKEVEN : 669 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 670 break; 671 case FRV_OPERAND_FRJ : 672 errmsg = insert_normal (cd, fields->f_FRj, 0, 0, 5, 6, 32, total_length, buffer); 673 break; 674 case FRV_OPERAND_FRK : 675 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 676 break; 677 case FRV_OPERAND_FRKHI : 678 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 679 break; 680 case FRV_OPERAND_FRKLO : 681 errmsg = insert_normal (cd, fields->f_FRk, 0, 0, 30, 6, 32, total_length, buffer); 682 break; 683 case FRV_OPERAND_GRDOUBLEK : 684 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 685 break; 686 case FRV_OPERAND_GRI : 687 errmsg = insert_normal (cd, fields->f_GRi, 0, 0, 17, 6, 32, total_length, buffer); 688 break; 689 case FRV_OPERAND_GRJ : 690 errmsg = insert_normal (cd, fields->f_GRj, 0, 0, 5, 6, 32, total_length, buffer); 691 break; 692 case FRV_OPERAND_GRK : 693 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 694 break; 695 case FRV_OPERAND_GRKHI : 696 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 697 break; 698 case FRV_OPERAND_GRKLO : 699 errmsg = insert_normal (cd, fields->f_GRk, 0, 0, 30, 6, 32, total_length, buffer); 700 break; 701 case FRV_OPERAND_ICCI_1 : 702 errmsg = insert_normal (cd, fields->f_ICCi_1, 0, 0, 11, 2, 32, total_length, buffer); 703 break; 704 case FRV_OPERAND_ICCI_2 : 705 errmsg = insert_normal (cd, fields->f_ICCi_2, 0, 0, 26, 2, 32, total_length, buffer); 706 break; 707 case FRV_OPERAND_ICCI_3 : 708 errmsg = insert_normal (cd, fields->f_ICCi_3, 0, 0, 1, 2, 32, total_length, buffer); 709 break; 710 case FRV_OPERAND_LI : 711 errmsg = insert_normal (cd, fields->f_LI, 0, 0, 25, 1, 32, total_length, buffer); 712 break; 713 case FRV_OPERAND_LRAD : 714 errmsg = insert_normal (cd, fields->f_LRAD, 0, 0, 4, 1, 32, total_length, buffer); 715 break; 716 case FRV_OPERAND_LRAE : 717 errmsg = insert_normal (cd, fields->f_LRAE, 0, 0, 5, 1, 32, total_length, buffer); 718 break; 719 case FRV_OPERAND_LRAS : 720 errmsg = insert_normal (cd, fields->f_LRAS, 0, 0, 3, 1, 32, total_length, buffer); 721 break; 722 case FRV_OPERAND_TLBPRL : 723 errmsg = insert_normal (cd, fields->f_TLBPRL, 0, 0, 25, 1, 32, total_length, buffer); 724 break; 725 case FRV_OPERAND_TLBPROPX : 726 errmsg = insert_normal (cd, fields->f_TLBPRopx, 0, 0, 28, 3, 32, total_length, buffer); 727 break; 728 case FRV_OPERAND_AE : 729 errmsg = insert_normal (cd, fields->f_ae, 0, 0, 25, 1, 32, total_length, buffer); 730 break; 731 case FRV_OPERAND_CALLANN : 732 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 733 break; 734 case FRV_OPERAND_CCOND : 735 errmsg = insert_normal (cd, fields->f_ccond, 0, 0, 12, 1, 32, total_length, buffer); 736 break; 737 case FRV_OPERAND_COND : 738 errmsg = insert_normal (cd, fields->f_cond, 0, 0, 8, 1, 32, total_length, buffer); 739 break; 740 case FRV_OPERAND_D12 : 741 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer); 742 break; 743 case FRV_OPERAND_DEBUG : 744 errmsg = insert_normal (cd, fields->f_debug, 0, 0, 25, 1, 32, total_length, buffer); 745 break; 746 case FRV_OPERAND_EIR : 747 errmsg = insert_normal (cd, fields->f_eir, 0, 0, 17, 6, 32, total_length, buffer); 748 break; 749 case FRV_OPERAND_HINT : 750 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 751 break; 752 case FRV_OPERAND_HINT_NOT_TAKEN : 753 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 754 break; 755 case FRV_OPERAND_HINT_TAKEN : 756 errmsg = insert_normal (cd, fields->f_hint, 0, 0, 17, 2, 32, total_length, buffer); 757 break; 758 case FRV_OPERAND_LABEL16 : 759 { 760 long value = fields->f_label16; 761 value = ((SI) (((value) - (pc))) >> (2)); 762 errmsg = insert_normal (cd, value, 0|(1<<CGEN_IFLD_SIGNED)|(1<<CGEN_IFLD_PCREL_ADDR), 0, 15, 16, 32, total_length, buffer); 763 } 764 break; 765 case FRV_OPERAND_LABEL24 : 766 { 767 { 768 FLD (f_labelH6) = ((SI) (((FLD (f_label24)) - (pc))) >> (20)); 769 FLD (f_labelL18) = ((((UINT) (((FLD (f_label24)) - (pc))) >> (2))) & (262143)); 770 } 771 errmsg = insert_normal (cd, fields->f_labelH6, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, buffer); 772 if (errmsg) 773 break; 774 errmsg = insert_normal (cd, fields->f_labelL18, 0, 0, 17, 18, 32, total_length, buffer); 775 if (errmsg) 776 break; 777 } 778 break; 779 case FRV_OPERAND_LDANN : 780 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 781 break; 782 case FRV_OPERAND_LDDANN : 783 errmsg = insert_normal (cd, fields->f_reloc_ann, 0, 0, 0, 0, 32, total_length, buffer); 784 break; 785 case FRV_OPERAND_LOCK : 786 errmsg = insert_normal (cd, fields->f_lock, 0, 0, 25, 1, 32, total_length, buffer); 787 break; 788 case FRV_OPERAND_PACK : 789 errmsg = insert_normal (cd, fields->f_pack, 0, 0, 31, 1, 32, total_length, buffer); 790 break; 791 case FRV_OPERAND_S10 : 792 errmsg = insert_normal (cd, fields->f_s10, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, buffer); 793 break; 794 case FRV_OPERAND_S12 : 795 errmsg = insert_normal (cd, fields->f_d12, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, buffer); 796 break; 797 case FRV_OPERAND_S16 : 798 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); 799 break; 800 case FRV_OPERAND_S5 : 801 errmsg = insert_normal (cd, fields->f_s5, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, buffer); 802 break; 803 case FRV_OPERAND_S6 : 804 errmsg = insert_normal (cd, fields->f_s6, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, buffer); 805 break; 806 case FRV_OPERAND_S6_1 : 807 errmsg = insert_normal (cd, fields->f_s6_1, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, buffer); 808 break; 809 case FRV_OPERAND_SLO16 : 810 errmsg = insert_normal (cd, fields->f_s16, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, buffer); 811 break; 812 case FRV_OPERAND_SPR : 813 { 814 { 815 FLD (f_spr_h) = ((UINT) (FLD (f_spr)) >> (6)); 816 FLD (f_spr_l) = ((FLD (f_spr)) & (63)); 817 } 818 errmsg = insert_normal (cd, fields->f_spr_h, 0, 0, 30, 6, 32, total_length, buffer); 819 if (errmsg) 820 break; 821 errmsg = insert_normal (cd, fields->f_spr_l, 0, 0, 17, 6, 32, total_length, buffer); 822 if (errmsg) 823 break; 824 } 825 break; 826 case FRV_OPERAND_U12 : 827 { 828 { 829 FLD (f_u12_h) = ((SI) (FLD (f_u12)) >> (6)); 830 FLD (f_u12_l) = ((FLD (f_u12)) & (63)); 831 } 832 errmsg = insert_normal (cd, fields->f_u12_h, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, buffer); 833 if (errmsg) 834 break; 835 errmsg = insert_normal (cd, fields->f_u12_l, 0, 0, 5, 6, 32, total_length, buffer); 836 if (errmsg) 837 break; 838 } 839 break; 840 case FRV_OPERAND_U16 : 841 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 842 break; 843 case FRV_OPERAND_U6 : 844 errmsg = insert_normal (cd, fields->f_u6, 0, 0, 5, 6, 32, total_length, buffer); 845 break; 846 case FRV_OPERAND_UHI16 : 847 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 848 break; 849 case FRV_OPERAND_ULO16 : 850 errmsg = insert_normal (cd, fields->f_u16, 0, 0, 15, 16, 32, total_length, buffer); 851 break; 852 853 default : 854 /* xgettext:c-format */ 855 fprintf (stderr, _("Unrecognized field %d while building insn.\n"), 856 opindex); 857 abort (); 858 } 859 860 return errmsg; 861 } 862 863 int frv_cgen_extract_operand 864 (CGEN_CPU_DESC, int, CGEN_EXTRACT_INFO *, CGEN_INSN_INT, CGEN_FIELDS *, bfd_vma); 865 866 /* Main entry point for operand extraction. 867 The result is <= 0 for error, >0 for success. 868 ??? Actual values aren't well defined right now. 869 870 This function is basically just a big switch statement. Earlier versions 871 used tables to look up the function to use, but 872 - if the table contains both assembler and disassembler functions then 873 the disassembler contains much of the assembler and vice-versa, 874 - there's a lot of inlining possibilities as things grow, 875 - using a switch statement avoids the function call overhead. 876 877 This function could be moved into `print_insn_normal', but keeping it 878 separate makes clear the interface between `print_insn_normal' and each of 879 the handlers. */ 880 881 int 882 frv_cgen_extract_operand (CGEN_CPU_DESC cd, 883 int opindex, 884 CGEN_EXTRACT_INFO *ex_info, 885 CGEN_INSN_INT insn_value, 886 CGEN_FIELDS * fields, 887 bfd_vma pc) 888 { 889 /* Assume success (for those operands that are nops). */ 890 int length = 1; 891 unsigned int total_length = CGEN_FIELDS_BITSIZE (fields); 892 893 switch (opindex) 894 { 895 case FRV_OPERAND_A0 : 896 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A); 897 break; 898 case FRV_OPERAND_A1 : 899 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 1, 32, total_length, pc, & fields->f_A); 900 break; 901 case FRV_OPERAND_ACC40SI : 902 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Si); 903 break; 904 case FRV_OPERAND_ACC40SK : 905 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Sk); 906 break; 907 case FRV_OPERAND_ACC40UI : 908 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACC40Ui); 909 break; 910 case FRV_OPERAND_ACC40UK : 911 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACC40Uk); 912 break; 913 case FRV_OPERAND_ACCGI : 914 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_ACCGi); 915 break; 916 case FRV_OPERAND_ACCGK : 917 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_ACCGk); 918 break; 919 case FRV_OPERAND_CCI : 920 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 3, 32, total_length, pc, & fields->f_CCi); 921 break; 922 case FRV_OPERAND_CPRDOUBLEK : 923 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk); 924 break; 925 case FRV_OPERAND_CPRI : 926 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_CPRi); 927 break; 928 case FRV_OPERAND_CPRJ : 929 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_CPRj); 930 break; 931 case FRV_OPERAND_CPRK : 932 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_CPRk); 933 break; 934 case FRV_OPERAND_CRI : 935 length = extract_normal (cd, ex_info, insn_value, 0, 0, 14, 3, 32, total_length, pc, & fields->f_CRi); 936 break; 937 case FRV_OPERAND_CRJ : 938 length = extract_normal (cd, ex_info, insn_value, 0, 0, 2, 3, 32, total_length, pc, & fields->f_CRj); 939 break; 940 case FRV_OPERAND_CRJ_FLOAT : 941 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_CRj_float); 942 break; 943 case FRV_OPERAND_CRJ_INT : 944 { 945 long value; 946 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & value); 947 value = ((value) + (4)); 948 fields->f_CRj_int = value; 949 } 950 break; 951 case FRV_OPERAND_CRK : 952 length = extract_normal (cd, ex_info, insn_value, 0, 0, 27, 3, 32, total_length, pc, & fields->f_CRk); 953 break; 954 case FRV_OPERAND_FCCI_1 : 955 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_FCCi_1); 956 break; 957 case FRV_OPERAND_FCCI_2 : 958 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCi_2); 959 break; 960 case FRV_OPERAND_FCCI_3 : 961 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_FCCi_3); 962 break; 963 case FRV_OPERAND_FCCK : 964 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_FCCk); 965 break; 966 case FRV_OPERAND_FRDOUBLEI : 967 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 968 break; 969 case FRV_OPERAND_FRDOUBLEJ : 970 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 971 break; 972 case FRV_OPERAND_FRDOUBLEK : 973 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 974 break; 975 case FRV_OPERAND_FRI : 976 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 977 break; 978 case FRV_OPERAND_FRINTI : 979 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 980 break; 981 case FRV_OPERAND_FRINTIEVEN : 982 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_FRi); 983 break; 984 case FRV_OPERAND_FRINTJ : 985 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 986 break; 987 case FRV_OPERAND_FRINTJEVEN : 988 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 989 break; 990 case FRV_OPERAND_FRINTK : 991 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 992 break; 993 case FRV_OPERAND_FRINTKEVEN : 994 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 995 break; 996 case FRV_OPERAND_FRJ : 997 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_FRj); 998 break; 999 case FRV_OPERAND_FRK : 1000 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1001 break; 1002 case FRV_OPERAND_FRKHI : 1003 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1004 break; 1005 case FRV_OPERAND_FRKLO : 1006 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_FRk); 1007 break; 1008 case FRV_OPERAND_GRDOUBLEK : 1009 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1010 break; 1011 case FRV_OPERAND_GRI : 1012 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_GRi); 1013 break; 1014 case FRV_OPERAND_GRJ : 1015 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_GRj); 1016 break; 1017 case FRV_OPERAND_GRK : 1018 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1019 break; 1020 case FRV_OPERAND_GRKHI : 1021 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1022 break; 1023 case FRV_OPERAND_GRKLO : 1024 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_GRk); 1025 break; 1026 case FRV_OPERAND_ICCI_1 : 1027 length = extract_normal (cd, ex_info, insn_value, 0, 0, 11, 2, 32, total_length, pc, & fields->f_ICCi_1); 1028 break; 1029 case FRV_OPERAND_ICCI_2 : 1030 length = extract_normal (cd, ex_info, insn_value, 0, 0, 26, 2, 32, total_length, pc, & fields->f_ICCi_2); 1031 break; 1032 case FRV_OPERAND_ICCI_3 : 1033 length = extract_normal (cd, ex_info, insn_value, 0, 0, 1, 2, 32, total_length, pc, & fields->f_ICCi_3); 1034 break; 1035 case FRV_OPERAND_LI : 1036 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_LI); 1037 break; 1038 case FRV_OPERAND_LRAD : 1039 length = extract_normal (cd, ex_info, insn_value, 0, 0, 4, 1, 32, total_length, pc, & fields->f_LRAD); 1040 break; 1041 case FRV_OPERAND_LRAE : 1042 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 1, 32, total_length, pc, & fields->f_LRAE); 1043 break; 1044 case FRV_OPERAND_LRAS : 1045 length = extract_normal (cd, ex_info, insn_value, 0, 0, 3, 1, 32, total_length, pc, & fields->f_LRAS); 1046 break; 1047 case FRV_OPERAND_TLBPRL : 1048 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_TLBPRL); 1049 break; 1050 case FRV_OPERAND_TLBPROPX : 1051 length = extract_normal (cd, ex_info, insn_value, 0, 0, 28, 3, 32, total_length, pc, & fields->f_TLBPRopx); 1052 break; 1053 case FRV_OPERAND_AE : 1054 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_ae); 1055 break; 1056 case FRV_OPERAND_CALLANN : 1057 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1058 break; 1059 case FRV_OPERAND_CCOND : 1060 length = extract_normal (cd, ex_info, insn_value, 0, 0, 12, 1, 32, total_length, pc, & fields->f_ccond); 1061 break; 1062 case FRV_OPERAND_COND : 1063 length = extract_normal (cd, ex_info, insn_value, 0, 0, 8, 1, 32, total_length, pc, & fields->f_cond); 1064 break; 1065 case FRV_OPERAND_D12 : 1066 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12); 1067 break; 1068 case FRV_OPERAND_DEBUG : 1069 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_debug); 1070 break; 1071 case FRV_OPERAND_EIR : 1072 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_eir); 1073 break; 1074 case FRV_OPERAND_HINT : 1075 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1076 break; 1077 case FRV_OPERAND_HINT_NOT_TAKEN : 1078 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1079 break; 1080 case FRV_OPERAND_HINT_TAKEN : 1081 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 2, 32, total_length, pc, & fields->f_hint); 1082 break; 1083 case FRV_OPERAND_LABEL16 : 1084 { 1085 long value; 1086 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); 1087 value = ((((value) << (2))) + (pc)); 1088 fields->f_label16 = value; 1089 } 1090 break; 1091 case FRV_OPERAND_LABEL24 : 1092 { 1093 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 30, 6, 32, total_length, pc, & fields->f_labelH6); 1094 if (length <= 0) break; 1095 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 18, 32, total_length, pc, & fields->f_labelL18); 1096 if (length <= 0) break; 1097 { 1098 FLD (f_label24) = ((((((((FLD (f_labelH6)) << (18))) | (FLD (f_labelL18)))) << (2))) + (pc)); 1099 } 1100 } 1101 break; 1102 case FRV_OPERAND_LDANN : 1103 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1104 break; 1105 case FRV_OPERAND_LDDANN : 1106 length = extract_normal (cd, ex_info, insn_value, 0, 0, 0, 0, 32, total_length, pc, & fields->f_reloc_ann); 1107 break; 1108 case FRV_OPERAND_LOCK : 1109 length = extract_normal (cd, ex_info, insn_value, 0, 0, 25, 1, 32, total_length, pc, & fields->f_lock); 1110 break; 1111 case FRV_OPERAND_PACK : 1112 length = extract_normal (cd, ex_info, insn_value, 0, 0, 31, 1, 32, total_length, pc, & fields->f_pack); 1113 break; 1114 case FRV_OPERAND_S10 : 1115 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 9, 10, 32, total_length, pc, & fields->f_s10); 1116 break; 1117 case FRV_OPERAND_S12 : 1118 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 12, 32, total_length, pc, & fields->f_d12); 1119 break; 1120 case FRV_OPERAND_S16 : 1121 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16); 1122 break; 1123 case FRV_OPERAND_S5 : 1124 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 4, 5, 32, total_length, pc, & fields->f_s5); 1125 break; 1126 case FRV_OPERAND_S6 : 1127 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 5, 6, 32, total_length, pc, & fields->f_s6); 1128 break; 1129 case FRV_OPERAND_S6_1 : 1130 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 11, 6, 32, total_length, pc, & fields->f_s6_1); 1131 break; 1132 case FRV_OPERAND_SLO16 : 1133 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 15, 16, 32, total_length, pc, & fields->f_s16); 1134 break; 1135 case FRV_OPERAND_SPR : 1136 { 1137 length = extract_normal (cd, ex_info, insn_value, 0, 0, 30, 6, 32, total_length, pc, & fields->f_spr_h); 1138 if (length <= 0) break; 1139 length = extract_normal (cd, ex_info, insn_value, 0, 0, 17, 6, 32, total_length, pc, & fields->f_spr_l); 1140 if (length <= 0) break; 1141 { 1142 FLD (f_spr) = ((((FLD (f_spr_h)) << (6))) | (FLD (f_spr_l))); 1143 } 1144 } 1145 break; 1146 case FRV_OPERAND_U12 : 1147 { 1148 length = extract_normal (cd, ex_info, insn_value, 0|(1<<CGEN_IFLD_SIGNED), 0, 17, 6, 32, total_length, pc, & fields->f_u12_h); 1149 if (length <= 0) break; 1150 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u12_l); 1151 if (length <= 0) break; 1152 { 1153 FLD (f_u12) = ((((FLD (f_u12_h)) << (6))) | (FLD (f_u12_l))); 1154 } 1155 } 1156 break; 1157 case FRV_OPERAND_U16 : 1158 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1159 break; 1160 case FRV_OPERAND_U6 : 1161 length = extract_normal (cd, ex_info, insn_value, 0, 0, 5, 6, 32, total_length, pc, & fields->f_u6); 1162 break; 1163 case FRV_OPERAND_UHI16 : 1164 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1165 break; 1166 case FRV_OPERAND_ULO16 : 1167 length = extract_normal (cd, ex_info, insn_value, 0, 0, 15, 16, 32, total_length, pc, & fields->f_u16); 1168 break; 1169 1170 default : 1171 /* xgettext:c-format */ 1172 fprintf (stderr, _("Unrecognized field %d while decoding insn.\n"), 1173 opindex); 1174 abort (); 1175 } 1176 1177 return length; 1178 } 1179 1180 cgen_insert_fn * const frv_cgen_insert_handlers[] = 1181 { 1182 insert_insn_normal, 1183 }; 1184 1185 cgen_extract_fn * const frv_cgen_extract_handlers[] = 1186 { 1187 extract_insn_normal, 1188 }; 1189 1190 int frv_cgen_get_int_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 1191 bfd_vma frv_cgen_get_vma_operand (CGEN_CPU_DESC, int, const CGEN_FIELDS *); 1192 1193 /* Getting values from cgen_fields is handled by a collection of functions. 1194 They are distinguished by the type of the VALUE argument they return. 1195 TODO: floating point, inlining support, remove cases where result type 1196 not appropriate. */ 1197 1198 int 1199 frv_cgen_get_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1200 int opindex, 1201 const CGEN_FIELDS * fields) 1202 { 1203 int value; 1204 1205 switch (opindex) 1206 { 1207 case FRV_OPERAND_A0 : 1208 value = fields->f_A; 1209 break; 1210 case FRV_OPERAND_A1 : 1211 value = fields->f_A; 1212 break; 1213 case FRV_OPERAND_ACC40SI : 1214 value = fields->f_ACC40Si; 1215 break; 1216 case FRV_OPERAND_ACC40SK : 1217 value = fields->f_ACC40Sk; 1218 break; 1219 case FRV_OPERAND_ACC40UI : 1220 value = fields->f_ACC40Ui; 1221 break; 1222 case FRV_OPERAND_ACC40UK : 1223 value = fields->f_ACC40Uk; 1224 break; 1225 case FRV_OPERAND_ACCGI : 1226 value = fields->f_ACCGi; 1227 break; 1228 case FRV_OPERAND_ACCGK : 1229 value = fields->f_ACCGk; 1230 break; 1231 case FRV_OPERAND_CCI : 1232 value = fields->f_CCi; 1233 break; 1234 case FRV_OPERAND_CPRDOUBLEK : 1235 value = fields->f_CPRk; 1236 break; 1237 case FRV_OPERAND_CPRI : 1238 value = fields->f_CPRi; 1239 break; 1240 case FRV_OPERAND_CPRJ : 1241 value = fields->f_CPRj; 1242 break; 1243 case FRV_OPERAND_CPRK : 1244 value = fields->f_CPRk; 1245 break; 1246 case FRV_OPERAND_CRI : 1247 value = fields->f_CRi; 1248 break; 1249 case FRV_OPERAND_CRJ : 1250 value = fields->f_CRj; 1251 break; 1252 case FRV_OPERAND_CRJ_FLOAT : 1253 value = fields->f_CRj_float; 1254 break; 1255 case FRV_OPERAND_CRJ_INT : 1256 value = fields->f_CRj_int; 1257 break; 1258 case FRV_OPERAND_CRK : 1259 value = fields->f_CRk; 1260 break; 1261 case FRV_OPERAND_FCCI_1 : 1262 value = fields->f_FCCi_1; 1263 break; 1264 case FRV_OPERAND_FCCI_2 : 1265 value = fields->f_FCCi_2; 1266 break; 1267 case FRV_OPERAND_FCCI_3 : 1268 value = fields->f_FCCi_3; 1269 break; 1270 case FRV_OPERAND_FCCK : 1271 value = fields->f_FCCk; 1272 break; 1273 case FRV_OPERAND_FRDOUBLEI : 1274 value = fields->f_FRi; 1275 break; 1276 case FRV_OPERAND_FRDOUBLEJ : 1277 value = fields->f_FRj; 1278 break; 1279 case FRV_OPERAND_FRDOUBLEK : 1280 value = fields->f_FRk; 1281 break; 1282 case FRV_OPERAND_FRI : 1283 value = fields->f_FRi; 1284 break; 1285 case FRV_OPERAND_FRINTI : 1286 value = fields->f_FRi; 1287 break; 1288 case FRV_OPERAND_FRINTIEVEN : 1289 value = fields->f_FRi; 1290 break; 1291 case FRV_OPERAND_FRINTJ : 1292 value = fields->f_FRj; 1293 break; 1294 case FRV_OPERAND_FRINTJEVEN : 1295 value = fields->f_FRj; 1296 break; 1297 case FRV_OPERAND_FRINTK : 1298 value = fields->f_FRk; 1299 break; 1300 case FRV_OPERAND_FRINTKEVEN : 1301 value = fields->f_FRk; 1302 break; 1303 case FRV_OPERAND_FRJ : 1304 value = fields->f_FRj; 1305 break; 1306 case FRV_OPERAND_FRK : 1307 value = fields->f_FRk; 1308 break; 1309 case FRV_OPERAND_FRKHI : 1310 value = fields->f_FRk; 1311 break; 1312 case FRV_OPERAND_FRKLO : 1313 value = fields->f_FRk; 1314 break; 1315 case FRV_OPERAND_GRDOUBLEK : 1316 value = fields->f_GRk; 1317 break; 1318 case FRV_OPERAND_GRI : 1319 value = fields->f_GRi; 1320 break; 1321 case FRV_OPERAND_GRJ : 1322 value = fields->f_GRj; 1323 break; 1324 case FRV_OPERAND_GRK : 1325 value = fields->f_GRk; 1326 break; 1327 case FRV_OPERAND_GRKHI : 1328 value = fields->f_GRk; 1329 break; 1330 case FRV_OPERAND_GRKLO : 1331 value = fields->f_GRk; 1332 break; 1333 case FRV_OPERAND_ICCI_1 : 1334 value = fields->f_ICCi_1; 1335 break; 1336 case FRV_OPERAND_ICCI_2 : 1337 value = fields->f_ICCi_2; 1338 break; 1339 case FRV_OPERAND_ICCI_3 : 1340 value = fields->f_ICCi_3; 1341 break; 1342 case FRV_OPERAND_LI : 1343 value = fields->f_LI; 1344 break; 1345 case FRV_OPERAND_LRAD : 1346 value = fields->f_LRAD; 1347 break; 1348 case FRV_OPERAND_LRAE : 1349 value = fields->f_LRAE; 1350 break; 1351 case FRV_OPERAND_LRAS : 1352 value = fields->f_LRAS; 1353 break; 1354 case FRV_OPERAND_TLBPRL : 1355 value = fields->f_TLBPRL; 1356 break; 1357 case FRV_OPERAND_TLBPROPX : 1358 value = fields->f_TLBPRopx; 1359 break; 1360 case FRV_OPERAND_AE : 1361 value = fields->f_ae; 1362 break; 1363 case FRV_OPERAND_CALLANN : 1364 value = fields->f_reloc_ann; 1365 break; 1366 case FRV_OPERAND_CCOND : 1367 value = fields->f_ccond; 1368 break; 1369 case FRV_OPERAND_COND : 1370 value = fields->f_cond; 1371 break; 1372 case FRV_OPERAND_D12 : 1373 value = fields->f_d12; 1374 break; 1375 case FRV_OPERAND_DEBUG : 1376 value = fields->f_debug; 1377 break; 1378 case FRV_OPERAND_EIR : 1379 value = fields->f_eir; 1380 break; 1381 case FRV_OPERAND_HINT : 1382 value = fields->f_hint; 1383 break; 1384 case FRV_OPERAND_HINT_NOT_TAKEN : 1385 value = fields->f_hint; 1386 break; 1387 case FRV_OPERAND_HINT_TAKEN : 1388 value = fields->f_hint; 1389 break; 1390 case FRV_OPERAND_LABEL16 : 1391 value = fields->f_label16; 1392 break; 1393 case FRV_OPERAND_LABEL24 : 1394 value = fields->f_label24; 1395 break; 1396 case FRV_OPERAND_LDANN : 1397 value = fields->f_reloc_ann; 1398 break; 1399 case FRV_OPERAND_LDDANN : 1400 value = fields->f_reloc_ann; 1401 break; 1402 case FRV_OPERAND_LOCK : 1403 value = fields->f_lock; 1404 break; 1405 case FRV_OPERAND_PACK : 1406 value = fields->f_pack; 1407 break; 1408 case FRV_OPERAND_S10 : 1409 value = fields->f_s10; 1410 break; 1411 case FRV_OPERAND_S12 : 1412 value = fields->f_d12; 1413 break; 1414 case FRV_OPERAND_S16 : 1415 value = fields->f_s16; 1416 break; 1417 case FRV_OPERAND_S5 : 1418 value = fields->f_s5; 1419 break; 1420 case FRV_OPERAND_S6 : 1421 value = fields->f_s6; 1422 break; 1423 case FRV_OPERAND_S6_1 : 1424 value = fields->f_s6_1; 1425 break; 1426 case FRV_OPERAND_SLO16 : 1427 value = fields->f_s16; 1428 break; 1429 case FRV_OPERAND_SPR : 1430 value = fields->f_spr; 1431 break; 1432 case FRV_OPERAND_U12 : 1433 value = fields->f_u12; 1434 break; 1435 case FRV_OPERAND_U16 : 1436 value = fields->f_u16; 1437 break; 1438 case FRV_OPERAND_U6 : 1439 value = fields->f_u6; 1440 break; 1441 case FRV_OPERAND_UHI16 : 1442 value = fields->f_u16; 1443 break; 1444 case FRV_OPERAND_ULO16 : 1445 value = fields->f_u16; 1446 break; 1447 1448 default : 1449 /* xgettext:c-format */ 1450 fprintf (stderr, _("Unrecognized field %d while getting int operand.\n"), 1451 opindex); 1452 abort (); 1453 } 1454 1455 return value; 1456 } 1457 1458 bfd_vma 1459 frv_cgen_get_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1460 int opindex, 1461 const CGEN_FIELDS * fields) 1462 { 1463 bfd_vma value; 1464 1465 switch (opindex) 1466 { 1467 case FRV_OPERAND_A0 : 1468 value = fields->f_A; 1469 break; 1470 case FRV_OPERAND_A1 : 1471 value = fields->f_A; 1472 break; 1473 case FRV_OPERAND_ACC40SI : 1474 value = fields->f_ACC40Si; 1475 break; 1476 case FRV_OPERAND_ACC40SK : 1477 value = fields->f_ACC40Sk; 1478 break; 1479 case FRV_OPERAND_ACC40UI : 1480 value = fields->f_ACC40Ui; 1481 break; 1482 case FRV_OPERAND_ACC40UK : 1483 value = fields->f_ACC40Uk; 1484 break; 1485 case FRV_OPERAND_ACCGI : 1486 value = fields->f_ACCGi; 1487 break; 1488 case FRV_OPERAND_ACCGK : 1489 value = fields->f_ACCGk; 1490 break; 1491 case FRV_OPERAND_CCI : 1492 value = fields->f_CCi; 1493 break; 1494 case FRV_OPERAND_CPRDOUBLEK : 1495 value = fields->f_CPRk; 1496 break; 1497 case FRV_OPERAND_CPRI : 1498 value = fields->f_CPRi; 1499 break; 1500 case FRV_OPERAND_CPRJ : 1501 value = fields->f_CPRj; 1502 break; 1503 case FRV_OPERAND_CPRK : 1504 value = fields->f_CPRk; 1505 break; 1506 case FRV_OPERAND_CRI : 1507 value = fields->f_CRi; 1508 break; 1509 case FRV_OPERAND_CRJ : 1510 value = fields->f_CRj; 1511 break; 1512 case FRV_OPERAND_CRJ_FLOAT : 1513 value = fields->f_CRj_float; 1514 break; 1515 case FRV_OPERAND_CRJ_INT : 1516 value = fields->f_CRj_int; 1517 break; 1518 case FRV_OPERAND_CRK : 1519 value = fields->f_CRk; 1520 break; 1521 case FRV_OPERAND_FCCI_1 : 1522 value = fields->f_FCCi_1; 1523 break; 1524 case FRV_OPERAND_FCCI_2 : 1525 value = fields->f_FCCi_2; 1526 break; 1527 case FRV_OPERAND_FCCI_3 : 1528 value = fields->f_FCCi_3; 1529 break; 1530 case FRV_OPERAND_FCCK : 1531 value = fields->f_FCCk; 1532 break; 1533 case FRV_OPERAND_FRDOUBLEI : 1534 value = fields->f_FRi; 1535 break; 1536 case FRV_OPERAND_FRDOUBLEJ : 1537 value = fields->f_FRj; 1538 break; 1539 case FRV_OPERAND_FRDOUBLEK : 1540 value = fields->f_FRk; 1541 break; 1542 case FRV_OPERAND_FRI : 1543 value = fields->f_FRi; 1544 break; 1545 case FRV_OPERAND_FRINTI : 1546 value = fields->f_FRi; 1547 break; 1548 case FRV_OPERAND_FRINTIEVEN : 1549 value = fields->f_FRi; 1550 break; 1551 case FRV_OPERAND_FRINTJ : 1552 value = fields->f_FRj; 1553 break; 1554 case FRV_OPERAND_FRINTJEVEN : 1555 value = fields->f_FRj; 1556 break; 1557 case FRV_OPERAND_FRINTK : 1558 value = fields->f_FRk; 1559 break; 1560 case FRV_OPERAND_FRINTKEVEN : 1561 value = fields->f_FRk; 1562 break; 1563 case FRV_OPERAND_FRJ : 1564 value = fields->f_FRj; 1565 break; 1566 case FRV_OPERAND_FRK : 1567 value = fields->f_FRk; 1568 break; 1569 case FRV_OPERAND_FRKHI : 1570 value = fields->f_FRk; 1571 break; 1572 case FRV_OPERAND_FRKLO : 1573 value = fields->f_FRk; 1574 break; 1575 case FRV_OPERAND_GRDOUBLEK : 1576 value = fields->f_GRk; 1577 break; 1578 case FRV_OPERAND_GRI : 1579 value = fields->f_GRi; 1580 break; 1581 case FRV_OPERAND_GRJ : 1582 value = fields->f_GRj; 1583 break; 1584 case FRV_OPERAND_GRK : 1585 value = fields->f_GRk; 1586 break; 1587 case FRV_OPERAND_GRKHI : 1588 value = fields->f_GRk; 1589 break; 1590 case FRV_OPERAND_GRKLO : 1591 value = fields->f_GRk; 1592 break; 1593 case FRV_OPERAND_ICCI_1 : 1594 value = fields->f_ICCi_1; 1595 break; 1596 case FRV_OPERAND_ICCI_2 : 1597 value = fields->f_ICCi_2; 1598 break; 1599 case FRV_OPERAND_ICCI_3 : 1600 value = fields->f_ICCi_3; 1601 break; 1602 case FRV_OPERAND_LI : 1603 value = fields->f_LI; 1604 break; 1605 case FRV_OPERAND_LRAD : 1606 value = fields->f_LRAD; 1607 break; 1608 case FRV_OPERAND_LRAE : 1609 value = fields->f_LRAE; 1610 break; 1611 case FRV_OPERAND_LRAS : 1612 value = fields->f_LRAS; 1613 break; 1614 case FRV_OPERAND_TLBPRL : 1615 value = fields->f_TLBPRL; 1616 break; 1617 case FRV_OPERAND_TLBPROPX : 1618 value = fields->f_TLBPRopx; 1619 break; 1620 case FRV_OPERAND_AE : 1621 value = fields->f_ae; 1622 break; 1623 case FRV_OPERAND_CALLANN : 1624 value = fields->f_reloc_ann; 1625 break; 1626 case FRV_OPERAND_CCOND : 1627 value = fields->f_ccond; 1628 break; 1629 case FRV_OPERAND_COND : 1630 value = fields->f_cond; 1631 break; 1632 case FRV_OPERAND_D12 : 1633 value = fields->f_d12; 1634 break; 1635 case FRV_OPERAND_DEBUG : 1636 value = fields->f_debug; 1637 break; 1638 case FRV_OPERAND_EIR : 1639 value = fields->f_eir; 1640 break; 1641 case FRV_OPERAND_HINT : 1642 value = fields->f_hint; 1643 break; 1644 case FRV_OPERAND_HINT_NOT_TAKEN : 1645 value = fields->f_hint; 1646 break; 1647 case FRV_OPERAND_HINT_TAKEN : 1648 value = fields->f_hint; 1649 break; 1650 case FRV_OPERAND_LABEL16 : 1651 value = fields->f_label16; 1652 break; 1653 case FRV_OPERAND_LABEL24 : 1654 value = fields->f_label24; 1655 break; 1656 case FRV_OPERAND_LDANN : 1657 value = fields->f_reloc_ann; 1658 break; 1659 case FRV_OPERAND_LDDANN : 1660 value = fields->f_reloc_ann; 1661 break; 1662 case FRV_OPERAND_LOCK : 1663 value = fields->f_lock; 1664 break; 1665 case FRV_OPERAND_PACK : 1666 value = fields->f_pack; 1667 break; 1668 case FRV_OPERAND_S10 : 1669 value = fields->f_s10; 1670 break; 1671 case FRV_OPERAND_S12 : 1672 value = fields->f_d12; 1673 break; 1674 case FRV_OPERAND_S16 : 1675 value = fields->f_s16; 1676 break; 1677 case FRV_OPERAND_S5 : 1678 value = fields->f_s5; 1679 break; 1680 case FRV_OPERAND_S6 : 1681 value = fields->f_s6; 1682 break; 1683 case FRV_OPERAND_S6_1 : 1684 value = fields->f_s6_1; 1685 break; 1686 case FRV_OPERAND_SLO16 : 1687 value = fields->f_s16; 1688 break; 1689 case FRV_OPERAND_SPR : 1690 value = fields->f_spr; 1691 break; 1692 case FRV_OPERAND_U12 : 1693 value = fields->f_u12; 1694 break; 1695 case FRV_OPERAND_U16 : 1696 value = fields->f_u16; 1697 break; 1698 case FRV_OPERAND_U6 : 1699 value = fields->f_u6; 1700 break; 1701 case FRV_OPERAND_UHI16 : 1702 value = fields->f_u16; 1703 break; 1704 case FRV_OPERAND_ULO16 : 1705 value = fields->f_u16; 1706 break; 1707 1708 default : 1709 /* xgettext:c-format */ 1710 fprintf (stderr, _("Unrecognized field %d while getting vma operand.\n"), 1711 opindex); 1712 abort (); 1713 } 1714 1715 return value; 1716 } 1717 1718 void frv_cgen_set_int_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, int); 1719 void frv_cgen_set_vma_operand (CGEN_CPU_DESC, int, CGEN_FIELDS *, bfd_vma); 1720 1721 /* Stuffing values in cgen_fields is handled by a collection of functions. 1722 They are distinguished by the type of the VALUE argument they accept. 1723 TODO: floating point, inlining support, remove cases where argument type 1724 not appropriate. */ 1725 1726 void 1727 frv_cgen_set_int_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1728 int opindex, 1729 CGEN_FIELDS * fields, 1730 int value) 1731 { 1732 switch (opindex) 1733 { 1734 case FRV_OPERAND_A0 : 1735 fields->f_A = value; 1736 break; 1737 case FRV_OPERAND_A1 : 1738 fields->f_A = value; 1739 break; 1740 case FRV_OPERAND_ACC40SI : 1741 fields->f_ACC40Si = value; 1742 break; 1743 case FRV_OPERAND_ACC40SK : 1744 fields->f_ACC40Sk = value; 1745 break; 1746 case FRV_OPERAND_ACC40UI : 1747 fields->f_ACC40Ui = value; 1748 break; 1749 case FRV_OPERAND_ACC40UK : 1750 fields->f_ACC40Uk = value; 1751 break; 1752 case FRV_OPERAND_ACCGI : 1753 fields->f_ACCGi = value; 1754 break; 1755 case FRV_OPERAND_ACCGK : 1756 fields->f_ACCGk = value; 1757 break; 1758 case FRV_OPERAND_CCI : 1759 fields->f_CCi = value; 1760 break; 1761 case FRV_OPERAND_CPRDOUBLEK : 1762 fields->f_CPRk = value; 1763 break; 1764 case FRV_OPERAND_CPRI : 1765 fields->f_CPRi = value; 1766 break; 1767 case FRV_OPERAND_CPRJ : 1768 fields->f_CPRj = value; 1769 break; 1770 case FRV_OPERAND_CPRK : 1771 fields->f_CPRk = value; 1772 break; 1773 case FRV_OPERAND_CRI : 1774 fields->f_CRi = value; 1775 break; 1776 case FRV_OPERAND_CRJ : 1777 fields->f_CRj = value; 1778 break; 1779 case FRV_OPERAND_CRJ_FLOAT : 1780 fields->f_CRj_float = value; 1781 break; 1782 case FRV_OPERAND_CRJ_INT : 1783 fields->f_CRj_int = value; 1784 break; 1785 case FRV_OPERAND_CRK : 1786 fields->f_CRk = value; 1787 break; 1788 case FRV_OPERAND_FCCI_1 : 1789 fields->f_FCCi_1 = value; 1790 break; 1791 case FRV_OPERAND_FCCI_2 : 1792 fields->f_FCCi_2 = value; 1793 break; 1794 case FRV_OPERAND_FCCI_3 : 1795 fields->f_FCCi_3 = value; 1796 break; 1797 case FRV_OPERAND_FCCK : 1798 fields->f_FCCk = value; 1799 break; 1800 case FRV_OPERAND_FRDOUBLEI : 1801 fields->f_FRi = value; 1802 break; 1803 case FRV_OPERAND_FRDOUBLEJ : 1804 fields->f_FRj = value; 1805 break; 1806 case FRV_OPERAND_FRDOUBLEK : 1807 fields->f_FRk = value; 1808 break; 1809 case FRV_OPERAND_FRI : 1810 fields->f_FRi = value; 1811 break; 1812 case FRV_OPERAND_FRINTI : 1813 fields->f_FRi = value; 1814 break; 1815 case FRV_OPERAND_FRINTIEVEN : 1816 fields->f_FRi = value; 1817 break; 1818 case FRV_OPERAND_FRINTJ : 1819 fields->f_FRj = value; 1820 break; 1821 case FRV_OPERAND_FRINTJEVEN : 1822 fields->f_FRj = value; 1823 break; 1824 case FRV_OPERAND_FRINTK : 1825 fields->f_FRk = value; 1826 break; 1827 case FRV_OPERAND_FRINTKEVEN : 1828 fields->f_FRk = value; 1829 break; 1830 case FRV_OPERAND_FRJ : 1831 fields->f_FRj = value; 1832 break; 1833 case FRV_OPERAND_FRK : 1834 fields->f_FRk = value; 1835 break; 1836 case FRV_OPERAND_FRKHI : 1837 fields->f_FRk = value; 1838 break; 1839 case FRV_OPERAND_FRKLO : 1840 fields->f_FRk = value; 1841 break; 1842 case FRV_OPERAND_GRDOUBLEK : 1843 fields->f_GRk = value; 1844 break; 1845 case FRV_OPERAND_GRI : 1846 fields->f_GRi = value; 1847 break; 1848 case FRV_OPERAND_GRJ : 1849 fields->f_GRj = value; 1850 break; 1851 case FRV_OPERAND_GRK : 1852 fields->f_GRk = value; 1853 break; 1854 case FRV_OPERAND_GRKHI : 1855 fields->f_GRk = value; 1856 break; 1857 case FRV_OPERAND_GRKLO : 1858 fields->f_GRk = value; 1859 break; 1860 case FRV_OPERAND_ICCI_1 : 1861 fields->f_ICCi_1 = value; 1862 break; 1863 case FRV_OPERAND_ICCI_2 : 1864 fields->f_ICCi_2 = value; 1865 break; 1866 case FRV_OPERAND_ICCI_3 : 1867 fields->f_ICCi_3 = value; 1868 break; 1869 case FRV_OPERAND_LI : 1870 fields->f_LI = value; 1871 break; 1872 case FRV_OPERAND_LRAD : 1873 fields->f_LRAD = value; 1874 break; 1875 case FRV_OPERAND_LRAE : 1876 fields->f_LRAE = value; 1877 break; 1878 case FRV_OPERAND_LRAS : 1879 fields->f_LRAS = value; 1880 break; 1881 case FRV_OPERAND_TLBPRL : 1882 fields->f_TLBPRL = value; 1883 break; 1884 case FRV_OPERAND_TLBPROPX : 1885 fields->f_TLBPRopx = value; 1886 break; 1887 case FRV_OPERAND_AE : 1888 fields->f_ae = value; 1889 break; 1890 case FRV_OPERAND_CALLANN : 1891 fields->f_reloc_ann = value; 1892 break; 1893 case FRV_OPERAND_CCOND : 1894 fields->f_ccond = value; 1895 break; 1896 case FRV_OPERAND_COND : 1897 fields->f_cond = value; 1898 break; 1899 case FRV_OPERAND_D12 : 1900 fields->f_d12 = value; 1901 break; 1902 case FRV_OPERAND_DEBUG : 1903 fields->f_debug = value; 1904 break; 1905 case FRV_OPERAND_EIR : 1906 fields->f_eir = value; 1907 break; 1908 case FRV_OPERAND_HINT : 1909 fields->f_hint = value; 1910 break; 1911 case FRV_OPERAND_HINT_NOT_TAKEN : 1912 fields->f_hint = value; 1913 break; 1914 case FRV_OPERAND_HINT_TAKEN : 1915 fields->f_hint = value; 1916 break; 1917 case FRV_OPERAND_LABEL16 : 1918 fields->f_label16 = value; 1919 break; 1920 case FRV_OPERAND_LABEL24 : 1921 fields->f_label24 = value; 1922 break; 1923 case FRV_OPERAND_LDANN : 1924 fields->f_reloc_ann = value; 1925 break; 1926 case FRV_OPERAND_LDDANN : 1927 fields->f_reloc_ann = value; 1928 break; 1929 case FRV_OPERAND_LOCK : 1930 fields->f_lock = value; 1931 break; 1932 case FRV_OPERAND_PACK : 1933 fields->f_pack = value; 1934 break; 1935 case FRV_OPERAND_S10 : 1936 fields->f_s10 = value; 1937 break; 1938 case FRV_OPERAND_S12 : 1939 fields->f_d12 = value; 1940 break; 1941 case FRV_OPERAND_S16 : 1942 fields->f_s16 = value; 1943 break; 1944 case FRV_OPERAND_S5 : 1945 fields->f_s5 = value; 1946 break; 1947 case FRV_OPERAND_S6 : 1948 fields->f_s6 = value; 1949 break; 1950 case FRV_OPERAND_S6_1 : 1951 fields->f_s6_1 = value; 1952 break; 1953 case FRV_OPERAND_SLO16 : 1954 fields->f_s16 = value; 1955 break; 1956 case FRV_OPERAND_SPR : 1957 fields->f_spr = value; 1958 break; 1959 case FRV_OPERAND_U12 : 1960 fields->f_u12 = value; 1961 break; 1962 case FRV_OPERAND_U16 : 1963 fields->f_u16 = value; 1964 break; 1965 case FRV_OPERAND_U6 : 1966 fields->f_u6 = value; 1967 break; 1968 case FRV_OPERAND_UHI16 : 1969 fields->f_u16 = value; 1970 break; 1971 case FRV_OPERAND_ULO16 : 1972 fields->f_u16 = value; 1973 break; 1974 1975 default : 1976 /* xgettext:c-format */ 1977 fprintf (stderr, _("Unrecognized field %d while setting int operand.\n"), 1978 opindex); 1979 abort (); 1980 } 1981 } 1982 1983 void 1984 frv_cgen_set_vma_operand (CGEN_CPU_DESC cd ATTRIBUTE_UNUSED, 1985 int opindex, 1986 CGEN_FIELDS * fields, 1987 bfd_vma value) 1988 { 1989 switch (opindex) 1990 { 1991 case FRV_OPERAND_A0 : 1992 fields->f_A = value; 1993 break; 1994 case FRV_OPERAND_A1 : 1995 fields->f_A = value; 1996 break; 1997 case FRV_OPERAND_ACC40SI : 1998 fields->f_ACC40Si = value; 1999 break; 2000 case FRV_OPERAND_ACC40SK : 2001 fields->f_ACC40Sk = value; 2002 break; 2003 case FRV_OPERAND_ACC40UI : 2004 fields->f_ACC40Ui = value; 2005 break; 2006 case FRV_OPERAND_ACC40UK : 2007 fields->f_ACC40Uk = value; 2008 break; 2009 case FRV_OPERAND_ACCGI : 2010 fields->f_ACCGi = value; 2011 break; 2012 case FRV_OPERAND_ACCGK : 2013 fields->f_ACCGk = value; 2014 break; 2015 case FRV_OPERAND_CCI : 2016 fields->f_CCi = value; 2017 break; 2018 case FRV_OPERAND_CPRDOUBLEK : 2019 fields->f_CPRk = value; 2020 break; 2021 case FRV_OPERAND_CPRI : 2022 fields->f_CPRi = value; 2023 break; 2024 case FRV_OPERAND_CPRJ : 2025 fields->f_CPRj = value; 2026 break; 2027 case FRV_OPERAND_CPRK : 2028 fields->f_CPRk = value; 2029 break; 2030 case FRV_OPERAND_CRI : 2031 fields->f_CRi = value; 2032 break; 2033 case FRV_OPERAND_CRJ : 2034 fields->f_CRj = value; 2035 break; 2036 case FRV_OPERAND_CRJ_FLOAT : 2037 fields->f_CRj_float = value; 2038 break; 2039 case FRV_OPERAND_CRJ_INT : 2040 fields->f_CRj_int = value; 2041 break; 2042 case FRV_OPERAND_CRK : 2043 fields->f_CRk = value; 2044 break; 2045 case FRV_OPERAND_FCCI_1 : 2046 fields->f_FCCi_1 = value; 2047 break; 2048 case FRV_OPERAND_FCCI_2 : 2049 fields->f_FCCi_2 = value; 2050 break; 2051 case FRV_OPERAND_FCCI_3 : 2052 fields->f_FCCi_3 = value; 2053 break; 2054 case FRV_OPERAND_FCCK : 2055 fields->f_FCCk = value; 2056 break; 2057 case FRV_OPERAND_FRDOUBLEI : 2058 fields->f_FRi = value; 2059 break; 2060 case FRV_OPERAND_FRDOUBLEJ : 2061 fields->f_FRj = value; 2062 break; 2063 case FRV_OPERAND_FRDOUBLEK : 2064 fields->f_FRk = value; 2065 break; 2066 case FRV_OPERAND_FRI : 2067 fields->f_FRi = value; 2068 break; 2069 case FRV_OPERAND_FRINTI : 2070 fields->f_FRi = value; 2071 break; 2072 case FRV_OPERAND_FRINTIEVEN : 2073 fields->f_FRi = value; 2074 break; 2075 case FRV_OPERAND_FRINTJ : 2076 fields->f_FRj = value; 2077 break; 2078 case FRV_OPERAND_FRINTJEVEN : 2079 fields->f_FRj = value; 2080 break; 2081 case FRV_OPERAND_FRINTK : 2082 fields->f_FRk = value; 2083 break; 2084 case FRV_OPERAND_FRINTKEVEN : 2085 fields->f_FRk = value; 2086 break; 2087 case FRV_OPERAND_FRJ : 2088 fields->f_FRj = value; 2089 break; 2090 case FRV_OPERAND_FRK : 2091 fields->f_FRk = value; 2092 break; 2093 case FRV_OPERAND_FRKHI : 2094 fields->f_FRk = value; 2095 break; 2096 case FRV_OPERAND_FRKLO : 2097 fields->f_FRk = value; 2098 break; 2099 case FRV_OPERAND_GRDOUBLEK : 2100 fields->f_GRk = value; 2101 break; 2102 case FRV_OPERAND_GRI : 2103 fields->f_GRi = value; 2104 break; 2105 case FRV_OPERAND_GRJ : 2106 fields->f_GRj = value; 2107 break; 2108 case FRV_OPERAND_GRK : 2109 fields->f_GRk = value; 2110 break; 2111 case FRV_OPERAND_GRKHI : 2112 fields->f_GRk = value; 2113 break; 2114 case FRV_OPERAND_GRKLO : 2115 fields->f_GRk = value; 2116 break; 2117 case FRV_OPERAND_ICCI_1 : 2118 fields->f_ICCi_1 = value; 2119 break; 2120 case FRV_OPERAND_ICCI_2 : 2121 fields->f_ICCi_2 = value; 2122 break; 2123 case FRV_OPERAND_ICCI_3 : 2124 fields->f_ICCi_3 = value; 2125 break; 2126 case FRV_OPERAND_LI : 2127 fields->f_LI = value; 2128 break; 2129 case FRV_OPERAND_LRAD : 2130 fields->f_LRAD = value; 2131 break; 2132 case FRV_OPERAND_LRAE : 2133 fields->f_LRAE = value; 2134 break; 2135 case FRV_OPERAND_LRAS : 2136 fields->f_LRAS = value; 2137 break; 2138 case FRV_OPERAND_TLBPRL : 2139 fields->f_TLBPRL = value; 2140 break; 2141 case FRV_OPERAND_TLBPROPX : 2142 fields->f_TLBPRopx = value; 2143 break; 2144 case FRV_OPERAND_AE : 2145 fields->f_ae = value; 2146 break; 2147 case FRV_OPERAND_CALLANN : 2148 fields->f_reloc_ann = value; 2149 break; 2150 case FRV_OPERAND_CCOND : 2151 fields->f_ccond = value; 2152 break; 2153 case FRV_OPERAND_COND : 2154 fields->f_cond = value; 2155 break; 2156 case FRV_OPERAND_D12 : 2157 fields->f_d12 = value; 2158 break; 2159 case FRV_OPERAND_DEBUG : 2160 fields->f_debug = value; 2161 break; 2162 case FRV_OPERAND_EIR : 2163 fields->f_eir = value; 2164 break; 2165 case FRV_OPERAND_HINT : 2166 fields->f_hint = value; 2167 break; 2168 case FRV_OPERAND_HINT_NOT_TAKEN : 2169 fields->f_hint = value; 2170 break; 2171 case FRV_OPERAND_HINT_TAKEN : 2172 fields->f_hint = value; 2173 break; 2174 case FRV_OPERAND_LABEL16 : 2175 fields->f_label16 = value; 2176 break; 2177 case FRV_OPERAND_LABEL24 : 2178 fields->f_label24 = value; 2179 break; 2180 case FRV_OPERAND_LDANN : 2181 fields->f_reloc_ann = value; 2182 break; 2183 case FRV_OPERAND_LDDANN : 2184 fields->f_reloc_ann = value; 2185 break; 2186 case FRV_OPERAND_LOCK : 2187 fields->f_lock = value; 2188 break; 2189 case FRV_OPERAND_PACK : 2190 fields->f_pack = value; 2191 break; 2192 case FRV_OPERAND_S10 : 2193 fields->f_s10 = value; 2194 break; 2195 case FRV_OPERAND_S12 : 2196 fields->f_d12 = value; 2197 break; 2198 case FRV_OPERAND_S16 : 2199 fields->f_s16 = value; 2200 break; 2201 case FRV_OPERAND_S5 : 2202 fields->f_s5 = value; 2203 break; 2204 case FRV_OPERAND_S6 : 2205 fields->f_s6 = value; 2206 break; 2207 case FRV_OPERAND_S6_1 : 2208 fields->f_s6_1 = value; 2209 break; 2210 case FRV_OPERAND_SLO16 : 2211 fields->f_s16 = value; 2212 break; 2213 case FRV_OPERAND_SPR : 2214 fields->f_spr = value; 2215 break; 2216 case FRV_OPERAND_U12 : 2217 fields->f_u12 = value; 2218 break; 2219 case FRV_OPERAND_U16 : 2220 fields->f_u16 = value; 2221 break; 2222 case FRV_OPERAND_U6 : 2223 fields->f_u6 = value; 2224 break; 2225 case FRV_OPERAND_UHI16 : 2226 fields->f_u16 = value; 2227 break; 2228 case FRV_OPERAND_ULO16 : 2229 fields->f_u16 = value; 2230 break; 2231 2232 default : 2233 /* xgettext:c-format */ 2234 fprintf (stderr, _("Unrecognized field %d while setting vma operand.\n"), 2235 opindex); 2236 abort (); 2237 } 2238 } 2239 2240 /* Function to call before using the instruction builder tables. */ 2241 2242 void 2243 frv_cgen_init_ibld_table (CGEN_CPU_DESC cd) 2244 { 2245 cd->insert_handlers = & frv_cgen_insert_handlers[0]; 2246 cd->extract_handlers = & frv_cgen_extract_handlers[0]; 2247 2248 cd->insert_operand = frv_cgen_insert_operand; 2249 cd->extract_operand = frv_cgen_extract_operand; 2250 2251 cd->get_int_operand = frv_cgen_get_int_operand; 2252 cd->set_int_operand = frv_cgen_set_int_operand; 2253 cd->get_vma_operand = frv_cgen_get_vma_operand; 2254 cd->set_vma_operand = frv_cgen_set_vma_operand; 2255 } 2256