Coverage Report

Created: 2023-08-28 06:23

/src/binutils-gdb/opcodes/hppa-dis.c
Line
Count
Source (jump to first uncovered line)
1
/* Disassembler for the PA-RISC. Somewhat derived from sparc-pinsn.c.
2
   Copyright (C) 1989-2023 Free Software Foundation, Inc.
3
4
   Contributed by the Center for Software Science at the
5
   University of Utah (pa-gdb-bugs@cs.utah.edu).
6
7
   This file is part of the GNU opcodes library.
8
9
   This library is free software; you can redistribute it and/or modify
10
   it under the terms of the GNU General Public License as published by
11
   the Free Software Foundation; either version 3, or (at your option)
12
   any later version.
13
14
   It is distributed in the hope that it will be useful, but WITHOUT
15
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
16
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
17
   License for more details.
18
19
   You should have received a copy of the GNU General Public License
20
   along with this program; if not, write to the Free Software
21
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
22
   MA 02110-1301, USA.  */
23
24
#include "sysdep.h"
25
#include "disassemble.h"
26
#include "libhppa.h"
27
#include "opcode/hppa.h"
28
29
/* Integer register names, indexed by the numbers which appear in the
30
   opcodes.  */
31
static const char *const reg_names[] =
32
{
33
  "flags", "r1", "rp", "r3", "r4", "r5", "r6", "r7", "r8", "r9",
34
  "r10", "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19",
35
  "r20", "r21", "r22", "r23", "r24", "r25", "r26", "dp", "ret0", "ret1",
36
  "sp", "r31"
37
};
38
39
/* Floating point register names, indexed by the numbers which appear in the
40
   opcodes.  */
41
static const char *const fp_reg_names[] =
42
{
43
  "fpsr", "fpe2", "fpe4", "fpe6",
44
  "fr4", "fr5", "fr6", "fr7", "fr8",
45
  "fr9", "fr10", "fr11", "fr12", "fr13", "fr14", "fr15",
46
  "fr16", "fr17", "fr18", "fr19", "fr20", "fr21", "fr22", "fr23",
47
  "fr24", "fr25", "fr26", "fr27", "fr28", "fr29", "fr30", "fr31"
48
};
49
50
typedef unsigned int CORE_ADDR;
51
52
/* Get at various relevent fields of an instruction word.  */
53
54
0
#define MASK_5  0x1f
55
0
#define MASK_10 0x3ff
56
0
#define MASK_11 0x7ff
57
0
#define MASK_14 0x3fff
58
#define MASK_16 0xffff
59
0
#define MASK_21 0x1fffff
60
61
/* These macros get bit fields using HP's numbering (MSB = 0).  */
62
63
#define GET_FIELD(X, FROM, TO) \
64
0
  ((X) >> (31 - (TO)) & ((1 << ((TO) - (FROM) + 1)) - 1))
65
66
#define GET_BIT(X, WHICH) \
67
0
  GET_FIELD (X, WHICH, WHICH)
68
69
/* Some of these have been converted to 2-d arrays because they
70
   consume less storage this way.  If the maintenance becomes a
71
   problem, convert them back to const 1-d pointer arrays.  */
72
static const char *const control_reg[] =
73
{
74
  "rctr", "cr1", "cr2", "cr3", "cr4", "cr5", "cr6", "cr7",
75
  "pidr1", "pidr2", "ccr", "sar", "pidr3", "pidr4",
76
  "iva", "eiem", "itmr", "pcsq", "pcoq", "iir", "isr",
77
  "ior", "ipsw", "eirr", "tr0", "tr1", "tr2", "tr3",
78
  "tr4", "tr5", "tr6", "tr7"
79
};
80
81
static const char *const compare_cond_names[] =
82
{
83
  "", ",=", ",<", ",<=", ",<<", ",<<=", ",sv", ",od",
84
  ",tr", ",<>", ",>=", ",>", ",>>=", ",>>", ",nsv", ",ev"
85
};
86
static const char *const compare_cond_64_names[] =
87
{
88
  ",*", ",*=", ",*<", ",*<=", ",*<<", ",*<<=", ",*sv", ",*od",
89
  ",*tr", ",*<>", ",*>=", ",*>", ",*>>=", ",*>>", ",*nsv", ",*ev"
90
};
91
static const char *const cmpib_cond_64_names[] =
92
{
93
  ",*<<", ",*=", ",*<", ",*<=", ",*>>=", ",*<>", ",*>=", ",*>"
94
};
95
static const char *const add_cond_names[] =
96
{
97
  "", ",=", ",<", ",<=", ",nuv", ",znv", ",sv", ",od",
98
  ",tr", ",<>", ",>=", ",>", ",uv", ",vnz", ",nsv", ",ev"
99
};
100
static const char *const add_cond_64_names[] =
101
{
102
  ",*", ",*=", ",*<", ",*<=", ",*nuv", ",*znv", ",*sv", ",*od",
103
  ",*tr", ",*<>", ",*>=", ",*>", ",*uv", ",*vnz", ",*nsv", ",*ev"
104
};
105
static const char *const wide_add_cond_names[] =
106
{
107
  "", ",=", ",<", ",<=", ",nuv", ",*=", ",*<", ",*<=",
108
  ",tr", ",<>", ",>=", ",>", ",uv", ",*<>", ",*>=", ",*>"
109
};
110
static const char *const logical_cond_names[] =
111
{
112
  "", ",=", ",<", ",<=", 0, 0, 0, ",od",
113
  ",tr", ",<>", ",>=", ",>", 0, 0, 0, ",ev"};
114
static const char *const logical_cond_64_names[] =
115
{
116
  ",*", ",*=", ",*<", ",*<=", 0, 0, 0, ",*od",
117
  ",*tr", ",*<>", ",*>=", ",*>", 0, 0, 0, ",*ev"};
118
static const char *const unit_cond_names[] =
119
{
120
  "", ",swz", ",sbz", ",shz", ",sdc", ",swc", ",sbc", ",shc",
121
  ",tr", ",nwz", ",nbz", ",nhz", ",ndc", ",nwc", ",nbc", ",nhc"
122
};
123
static const char *const unit_cond_64_names[] =
124
{
125
  ",*", ",*swz", ",*sbz", ",*shz", ",*sdc", ",*swc", ",*sbc", ",*shc",
126
  ",*tr", ",*nwz", ",*nbz", ",*nhz", ",*ndc", ",*nwc", ",*nbc", ",*nhc"
127
};
128
static const char *const shift_cond_names[] =
129
{
130
  "", ",=", ",<", ",od", ",tr", ",<>", ",>=", ",ev"
131
};
132
static const char *const shift_cond_64_names[] =
133
{
134
  ",*", ",*=", ",*<", ",*od", ",*tr", ",*<>", ",*>=", ",*ev"
135
};
136
static const char *const bb_cond_64_names[] =
137
{
138
  ",*<", ",*>="
139
};
140
static const char *const index_compl_names[] = {"", ",m", ",s", ",sm"};
141
static const char *const short_ldst_compl_names[] = {"", ",ma", "", ",mb"};
142
static const char *const short_bytes_compl_names[] =
143
{
144
  "", ",b,m", ",e", ",e,m"
145
};
146
static const char *const float_format_names[] = {",sgl", ",dbl", "", ",quad"};
147
static const char *const fcnv_fixed_names[] = {",w", ",dw", "", ",qw"};
148
static const char *const fcnv_ufixed_names[] = {",uw", ",udw", "", ",uqw"};
149
static const char *const float_comp_names[] =
150
{
151
  ",false?", ",false", ",?", ",!<=>", ",=", ",=t", ",?=", ",!<>",
152
  ",!?>=", ",<", ",?<", ",!>=", ",!?>", ",<=", ",?<=", ",!>",
153
  ",!?<=", ",>", ",?>", ",!<=", ",!?<", ",>=", ",?>=", ",!<",
154
  ",!?=", ",<>", ",!=", ",!=t", ",!?", ",<=>", ",true?", ",true"
155
};
156
static const char *const signed_unsigned_names[] = {",u", ",s"};
157
static const char *const mix_half_names[] = {",l", ",r"};
158
static const char *const saturation_names[] = {",us", ",ss", 0, ""};
159
static const char *const read_write_names[] = {",r", ",w"};
160
static const char *const add_compl_names[] = { 0, "", ",l", ",tsv" };
161
162
/* For a bunch of different instructions form an index into a
163
   completer name table.  */
164
0
#define GET_COMPL(insn) (GET_FIELD (insn, 26, 26) | \
165
0
       GET_FIELD (insn, 18, 18) << 1)
166
167
0
#define GET_COND(insn) (GET_FIELD ((insn), 16, 18) + \
168
0
      (GET_FIELD ((insn), 19, 19) ? 8 : 0))
169
170
/* Utility function to print registers.  Put these first, so gcc's function
171
   inlining can do its stuff.  */
172
173
0
#define fputs_filtered(STR,F) (*info->fprintf_func) (info->stream, "%s", STR)
174
175
static void
176
fput_reg (unsigned reg, disassemble_info *info)
177
0
{
178
0
  (*info->fprintf_func) (info->stream, "%s", reg ? reg_names[reg] : "r0");
179
0
}
180
181
static void
182
fput_fp_reg (unsigned reg, disassemble_info *info)
183
0
{
184
0
  (*info->fprintf_func) (info->stream, "%s", reg ? fp_reg_names[reg] : "fr0");
185
0
}
186
187
static void
188
fput_fp_reg_r (unsigned reg, disassemble_info *info)
189
0
{
190
  /* Special case floating point exception registers.  */
191
0
  if (reg < 4)
192
0
    (*info->fprintf_func) (info->stream, "fpe%d", reg * 2 + 1);
193
0
  else
194
0
    (*info->fprintf_func) (info->stream, "%sR",
195
0
         reg ? fp_reg_names[reg] : "fr0");
196
0
}
197
198
static void
199
fput_creg (unsigned reg, disassemble_info *info)
200
0
{
201
0
  (*info->fprintf_func) (info->stream, "%s", control_reg[reg]);
202
0
}
203
204
/* Print constants with sign.  */
205
206
static void
207
fput_const (unsigned num, disassemble_info *info)
208
0
{
209
0
  if ((int) num < 0)
210
0
    (*info->fprintf_func) (info->stream, "-%x", -num);
211
0
  else
212
0
    (*info->fprintf_func) (info->stream, "%x", num);
213
0
}
214
215
/* Routines to extract various sized constants out of hppa
216
   instructions.  */
217
218
/* Extract a 3-bit space register number from a be, ble, mtsp or mfsp.  */
219
static int
220
extract_3 (unsigned word)
221
0
{
222
0
  return GET_FIELD (word, 18, 18) << 2 | GET_FIELD (word, 16, 17);
223
0
}
224
225
static int
226
extract_5_load (unsigned word)
227
0
{
228
0
  return low_sign_extend (word >> 16 & MASK_5, 5);
229
0
}
230
231
/* Extract the immediate field from a st{bhw}s instruction.  */
232
233
static int
234
extract_5_store (unsigned word)
235
0
{
236
0
  return low_sign_extend (word & MASK_5, 5);
237
0
}
238
239
/* Extract the immediate field from a break instruction.  */
240
241
static unsigned
242
extract_5r_store (unsigned word)
243
0
{
244
0
  return (word & MASK_5);
245
0
}
246
247
/* Extract the immediate field from a {sr}sm instruction.  */
248
249
static unsigned
250
extract_5R_store (unsigned word)
251
0
{
252
0
  return (word >> 16 & MASK_5);
253
0
}
254
255
/* Extract the 10 bit immediate field from a {sr}sm instruction.  */
256
257
static unsigned
258
extract_10U_store (unsigned word)
259
0
{
260
0
  return (word >> 16 & MASK_10);
261
0
}
262
263
/* Extract the immediate field from a bb instruction.  */
264
265
static unsigned
266
extract_5Q_store (unsigned word)
267
0
{
268
0
  return (word >> 21 & MASK_5);
269
0
}
270
271
/* Extract an 11 bit immediate field.  */
272
273
static int
274
extract_11 (unsigned word)
275
0
{
276
0
  return low_sign_extend (word & MASK_11, 11);
277
0
}
278
279
/* Extract a 14 bit immediate field.  */
280
281
static int
282
extract_14 (unsigned word)
283
0
{
284
0
  return low_sign_extend (word & MASK_14, 14);
285
0
}
286
287
/* Extract a 16 bit immediate field (PA2.0 wide only).  */
288
289
static int
290
extract_16 (unsigned word)
291
0
{
292
0
  unsigned m15, m0, m1;
293
294
0
  m0 = GET_BIT (word, 16);
295
0
  m1 = GET_BIT (word, 17);
296
0
  m15 = GET_BIT (word, 31);
297
0
  word = (word >> 1) & 0x1fff;
298
0
  word = word | (m15 << 15) | ((m15 ^ m0) << 14) | ((m15 ^ m1) << 13);
299
0
  return sign_extend (word, 16);
300
0
}
301
302
/* Extract a 21 bit constant.  */
303
304
static int
305
extract_21 (unsigned word)
306
0
{
307
0
  unsigned val;
308
309
0
  word &= MASK_21;
310
0
  word <<= 11;
311
0
  val = GET_FIELD (word, 20, 20);
312
0
  val <<= 11;
313
0
  val |= GET_FIELD (word, 9, 19);
314
0
  val <<= 2;
315
0
  val |= GET_FIELD (word, 5, 6);
316
0
  val <<= 5;
317
0
  val |= GET_FIELD (word, 0, 4);
318
0
  val <<= 2;
319
0
  val |= GET_FIELD (word, 7, 8);
320
0
  return sign_extend (val, 21) << 11;
321
0
}
322
323
/* Extract a 12 bit constant from branch instructions.  */
324
325
static int
326
extract_12 (unsigned word)
327
0
{
328
0
  return sign_extend (GET_FIELD (word, 19, 28)
329
0
          | GET_FIELD (word, 29, 29) << 10
330
0
          | (word & 0x1) << 11, 12) << 2;
331
0
}
332
333
/* Extract a 17 bit constant from branch instructions, returning the
334
   19 bit signed value.  */
335
336
static int
337
extract_17 (unsigned word)
338
0
{
339
0
  return sign_extend (GET_FIELD (word, 19, 28)
340
0
          | GET_FIELD (word, 29, 29) << 10
341
0
          | GET_FIELD (word, 11, 15) << 11
342
0
          | (word & 0x1) << 16, 17) << 2;
343
0
}
344
345
static int
346
extract_22 (unsigned word)
347
0
{
348
0
  return sign_extend (GET_FIELD (word, 19, 28)
349
0
          | GET_FIELD (word, 29, 29) << 10
350
0
          | GET_FIELD (word, 11, 15) << 11
351
0
          | GET_FIELD (word, 6, 10) << 16
352
0
          | (word & 0x1) << 21, 22) << 2;
353
0
}
354
355
/* Print one instruction.  */
356
357
int
358
print_insn_hppa (bfd_vma memaddr, disassemble_info *info)
359
0
{
360
0
  bfd_byte buffer[4];
361
0
  unsigned int insn, i;
362
363
0
  {
364
0
    int status =
365
0
      (*info->read_memory_func) (memaddr, buffer, sizeof (buffer), info);
366
0
    if (status != 0)
367
0
      {
368
0
  (*info->memory_error_func) (status, memaddr, info);
369
0
  return -1;
370
0
      }
371
0
  }
372
373
0
  insn = bfd_getb32 (buffer);
374
375
0
  for (i = 0; i < NUMOPCODES; ++i)
376
0
    {
377
0
      const struct pa_opcode *opcode = &pa_opcodes[i];
378
379
0
      if ((insn & opcode->mask) == opcode->match)
380
0
  {
381
0
    const char *s;
382
#ifndef BFD64
383
    if (opcode->arch == pa20w)
384
      continue;
385
#endif
386
0
    (*info->fprintf_func) (info->stream, "%s", opcode->name);
387
388
0
    if (!strchr ("cfCY?-+nHNZFIuv{", opcode->args[0]))
389
0
      (*info->fprintf_func) (info->stream, " ");
390
0
    for (s = opcode->args; *s != '\0'; ++s)
391
0
      {
392
0
        switch (*s)
393
0
    {
394
0
    case 'x':
395
0
      fput_reg (GET_FIELD (insn, 11, 15), info);
396
0
      break;
397
0
    case 'a':
398
0
    case 'b':
399
0
      fput_reg (GET_FIELD (insn, 6, 10), info);
400
0
      break;
401
0
    case '^':
402
0
      fput_creg (GET_FIELD (insn, 6, 10), info);
403
0
      break;
404
0
    case 't':
405
0
      fput_reg (GET_FIELD (insn, 27, 31), info);
406
0
      break;
407
408
      /* Handle floating point registers.  */
409
0
    case 'f':
410
0
      switch (*++s)
411
0
        {
412
0
        case 't':
413
0
          fput_fp_reg (GET_FIELD (insn, 27, 31), info);
414
0
          break;
415
0
        case 'T':
416
0
          if (GET_FIELD (insn, 25, 25))
417
0
      fput_fp_reg_r (GET_FIELD (insn, 27, 31), info);
418
0
          else
419
0
      fput_fp_reg (GET_FIELD (insn, 27, 31), info);
420
0
          break;
421
0
        case 'a':
422
0
          if (GET_FIELD (insn, 25, 25))
423
0
      fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
424
0
          else
425
0
      fput_fp_reg (GET_FIELD (insn, 6, 10), info);
426
0
          break;
427
428
          /* 'fA' will not generate a space before the register
429
       name.  Normally that is fine.  Except that it
430
       causes problems with xmpyu which has no FP format
431
       completer.  */
432
0
        case 'X':
433
0
          fputs_filtered (" ", info);
434
          /* FALLTHRU */
435
436
0
        case 'A':
437
0
          if (GET_FIELD (insn, 24, 24))
438
0
      fput_fp_reg_r (GET_FIELD (insn, 6, 10), info);
439
0
          else
440
0
      fput_fp_reg (GET_FIELD (insn, 6, 10), info);
441
0
          break;
442
0
        case 'b':
443
0
          if (GET_FIELD (insn, 25, 25))
444
0
      fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
445
0
          else
446
0
      fput_fp_reg (GET_FIELD (insn, 11, 15), info);
447
0
          break;
448
0
        case 'B':
449
0
          if (GET_FIELD (insn, 19, 19))
450
0
      fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
451
0
          else
452
0
      fput_fp_reg (GET_FIELD (insn, 11, 15), info);
453
0
          break;
454
0
        case 'C':
455
0
          {
456
0
      int reg = GET_FIELD (insn, 21, 22);
457
0
      reg |= GET_FIELD (insn, 16, 18) << 2;
458
0
      if (GET_FIELD (insn, 23, 23) != 0)
459
0
        fput_fp_reg_r (reg, info);
460
0
      else
461
0
        fput_fp_reg (reg, info);
462
0
      break;
463
0
          }
464
0
        case 'i':
465
0
          {
466
0
      int reg = GET_FIELD (insn, 6, 10);
467
468
0
      reg |= (GET_FIELD (insn, 26, 26) << 4);
469
0
      fput_fp_reg (reg, info);
470
0
      break;
471
0
          }
472
0
        case 'j':
473
0
          {
474
0
      int reg = GET_FIELD (insn, 11, 15);
475
476
0
      reg |= (GET_FIELD (insn, 26, 26) << 4);
477
0
      fput_fp_reg (reg, info);
478
0
      break;
479
0
          }
480
0
        case 'k':
481
0
          {
482
0
      int reg = GET_FIELD (insn, 27, 31);
483
484
0
      reg |= (GET_FIELD (insn, 26, 26) << 4);
485
0
      fput_fp_reg (reg, info);
486
0
      break;
487
0
          }
488
0
        case 'l':
489
0
          {
490
0
      int reg = GET_FIELD (insn, 21, 25);
491
492
0
      reg |= (GET_FIELD (insn, 26, 26) << 4);
493
0
      fput_fp_reg (reg, info);
494
0
      break;
495
0
          }
496
0
        case 'm':
497
0
          {
498
0
      int reg = GET_FIELD (insn, 16, 20);
499
500
0
      reg |= (GET_FIELD (insn, 26, 26) << 4);
501
0
      fput_fp_reg (reg, info);
502
0
      break;
503
0
          }
504
505
          /* 'fe' will not generate a space before the register
506
       name.  Normally that is fine.  Except that it
507
       causes problems with fstw fe,y(b) which has no FP
508
       format completer.  */
509
0
        case 'E':
510
0
          fputs_filtered (" ", info);
511
          /* FALLTHRU */
512
513
0
        case 'e':
514
0
          if (GET_FIELD (insn, 30, 30))
515
0
      fput_fp_reg_r (GET_FIELD (insn, 11, 15), info);
516
0
          else
517
0
      fput_fp_reg (GET_FIELD (insn, 11, 15), info);
518
0
          break;
519
0
        case 'x':
520
0
          fput_fp_reg (GET_FIELD (insn, 11, 15), info);
521
0
          break;
522
0
        }
523
0
      break;
524
525
0
    case '5':
526
0
      fput_const (extract_5_load (insn), info);
527
0
      break;
528
0
    case 's':
529
0
      {
530
0
        int space = GET_FIELD (insn, 16, 17);
531
        /* Zero means implicit addressing, not use of sr0.  */
532
0
        if (space != 0)
533
0
          (*info->fprintf_func) (info->stream, "sr%d", space);
534
0
      }
535
0
      break;
536
537
0
    case 'S':
538
0
      (*info->fprintf_func) (info->stream, "sr%d",
539
0
           extract_3 (insn));
540
0
      break;
541
542
      /* Handle completers.  */
543
0
    case 'c':
544
0
      switch (*++s)
545
0
        {
546
0
        case 'x':
547
0
          (*info->fprintf_func)
548
0
      (info->stream, "%s",
549
0
       index_compl_names[GET_COMPL (insn)]);
550
0
          break;
551
0
        case 'X':
552
0
          (*info->fprintf_func)
553
0
      (info->stream, "%s ",
554
0
       index_compl_names[GET_COMPL (insn)]);
555
0
          break;
556
0
        case 'm':
557
0
          (*info->fprintf_func)
558
0
      (info->stream, "%s",
559
0
       short_ldst_compl_names[GET_COMPL (insn)]);
560
0
          break;
561
0
        case 'M':
562
0
          (*info->fprintf_func)
563
0
      (info->stream, "%s ",
564
0
       short_ldst_compl_names[GET_COMPL (insn)]);
565
0
          break;
566
0
        case 'A':
567
0
          (*info->fprintf_func)
568
0
      (info->stream, "%s ",
569
0
       short_bytes_compl_names[GET_COMPL (insn)]);
570
0
          break;
571
0
        case 's':
572
0
          (*info->fprintf_func)
573
0
      (info->stream, "%s",
574
0
       short_bytes_compl_names[GET_COMPL (insn)]);
575
0
          break;
576
0
        case 'c':
577
0
        case 'C':
578
0
          switch (GET_FIELD (insn, 20, 21))
579
0
      {
580
0
      case 1:
581
0
        (*info->fprintf_func) (info->stream, ",bc ");
582
0
        break;
583
0
      case 2:
584
0
        (*info->fprintf_func) (info->stream, ",sl ");
585
0
        break;
586
0
      default:
587
0
        (*info->fprintf_func) (info->stream, " ");
588
0
      }
589
0
          break;
590
0
        case 'd':
591
0
          switch (GET_FIELD (insn, 20, 21))
592
0
      {
593
0
      case 1:
594
0
        (*info->fprintf_func) (info->stream, ",co ");
595
0
        break;
596
0
      default:
597
0
        (*info->fprintf_func) (info->stream, " ");
598
0
      }
599
0
          break;
600
0
        case 'o':
601
0
          (*info->fprintf_func) (info->stream, ",o");
602
0
          break;
603
0
        case 'g':
604
0
          (*info->fprintf_func) (info->stream, ",gate");
605
0
          break;
606
0
        case 'p':
607
0
          (*info->fprintf_func) (info->stream, ",l,push");
608
0
          break;
609
0
        case 'P':
610
0
          (*info->fprintf_func) (info->stream, ",pop");
611
0
          break;
612
0
        case 'l':
613
0
        case 'L':
614
0
          (*info->fprintf_func) (info->stream, ",l");
615
0
          break;
616
0
        case 'w':
617
0
          (*info->fprintf_func)
618
0
      (info->stream, "%s ",
619
0
       read_write_names[GET_FIELD (insn, 25, 25)]);
620
0
          break;
621
0
        case 'W':
622
0
          (*info->fprintf_func) (info->stream, ",w ");
623
0
          break;
624
0
        case 'r':
625
0
          if (GET_FIELD (insn, 23, 26) == 5)
626
0
      (*info->fprintf_func) (info->stream, ",r");
627
0
          break;
628
0
        case 'Z':
629
0
          if (GET_FIELD (insn, 26, 26))
630
0
      (*info->fprintf_func) (info->stream, ",m ");
631
0
          else
632
0
      (*info->fprintf_func) (info->stream, " ");
633
0
          break;
634
0
        case 'i':
635
0
          if (GET_FIELD (insn, 25, 25))
636
0
      (*info->fprintf_func) (info->stream, ",i");
637
0
          break;
638
0
        case 'z':
639
0
          if (!GET_FIELD (insn, 21, 21))
640
0
      (*info->fprintf_func) (info->stream, ",z");
641
0
          break;
642
0
        case 'a':
643
0
          (*info->fprintf_func)
644
0
      (info->stream, "%s",
645
0
       add_compl_names[GET_FIELD (insn, 20, 21)]);
646
0
          break;
647
0
        case 'Y':
648
0
          (*info->fprintf_func)
649
0
      (info->stream, ",dc%s",
650
0
       add_compl_names[GET_FIELD (insn, 20, 21)]);
651
0
          break;
652
0
        case 'y':
653
0
          (*info->fprintf_func)
654
0
      (info->stream, ",c%s",
655
0
       add_compl_names[GET_FIELD (insn, 20, 21)]);
656
0
          break;
657
0
        case 'v':
658
0
          if (GET_FIELD (insn, 20, 20))
659
0
      (*info->fprintf_func) (info->stream, ",tsv");
660
0
          break;
661
0
        case 't':
662
0
          (*info->fprintf_func) (info->stream, ",tc");
663
0
          if (GET_FIELD (insn, 20, 20))
664
0
      (*info->fprintf_func) (info->stream, ",tsv");
665
0
          break;
666
0
        case 'B':
667
0
          (*info->fprintf_func) (info->stream, ",db");
668
0
          if (GET_FIELD (insn, 20, 20))
669
0
      (*info->fprintf_func) (info->stream, ",tsv");
670
0
          break;
671
0
        case 'b':
672
0
          (*info->fprintf_func) (info->stream, ",b");
673
0
          if (GET_FIELD (insn, 20, 20))
674
0
      (*info->fprintf_func) (info->stream, ",tsv");
675
0
          break;
676
0
        case 'T':
677
0
          if (GET_FIELD (insn, 25, 25))
678
0
      (*info->fprintf_func) (info->stream, ",tc");
679
0
          break;
680
0
        case 'S':
681
          /* EXTRD/W has a following condition.  */
682
0
          if (*(s + 1) == '?')
683
0
      (*info->fprintf_func)
684
0
        (info->stream, "%s",
685
0
         signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
686
0
          else
687
0
      (*info->fprintf_func)
688
0
        (info->stream, "%s ",
689
0
         signed_unsigned_names[GET_FIELD (insn, 21, 21)]);
690
0
          break;
691
0
        case 'h':
692
0
          (*info->fprintf_func)
693
0
      (info->stream, "%s",
694
0
       mix_half_names[GET_FIELD (insn, 17, 17)]);
695
0
          break;
696
0
        case 'H':
697
0
          (*info->fprintf_func)
698
0
      (info->stream, "%s ",
699
0
       saturation_names[GET_FIELD (insn, 24, 25)]);
700
0
          break;
701
0
        case '*':
702
0
          (*info->fprintf_func)
703
0
      (info->stream, ",%d%d%d%d ",
704
0
       GET_FIELD (insn, 17, 18), GET_FIELD (insn, 20, 21),
705
0
       GET_FIELD (insn, 22, 23), GET_FIELD (insn, 24, 25));
706
0
          break;
707
708
0
        case 'q':
709
0
          {
710
0
      int m, a;
711
712
0
      m = GET_FIELD (insn, 28, 28);
713
0
      a = GET_FIELD (insn, 29, 29);
714
715
0
      if (m && !a)
716
0
        fputs_filtered (",ma ", info);
717
0
      else if (m && a)
718
0
        fputs_filtered (",mb ", info);
719
0
      else
720
0
        fputs_filtered (" ", info);
721
0
      break;
722
0
          }
723
724
0
        case 'J':
725
0
          {
726
0
      int opc = GET_FIELD (insn, 0, 5);
727
728
0
      if (opc == 0x16 || opc == 0x1e)
729
0
        {
730
0
          if (GET_FIELD (insn, 29, 29) == 0)
731
0
            fputs_filtered (",ma ", info);
732
0
          else
733
0
            fputs_filtered (",mb ", info);
734
0
        }
735
0
      else
736
0
        fputs_filtered (" ", info);
737
0
      break;
738
0
          }
739
740
0
        case 'e':
741
0
          {
742
0
      int opc = GET_FIELD (insn, 0, 5);
743
744
0
      if (opc == 0x13 || opc == 0x1b)
745
0
        {
746
0
          if (GET_FIELD (insn, 18, 18) == 1)
747
0
            fputs_filtered (",mb ", info);
748
0
          else
749
0
            fputs_filtered (",ma ", info);
750
0
        }
751
0
      else if (opc == 0x17 || opc == 0x1f)
752
0
        {
753
0
          if (GET_FIELD (insn, 31, 31) == 1)
754
0
            fputs_filtered (",ma ", info);
755
0
          else
756
0
            fputs_filtered (",mb ", info);
757
0
        }
758
0
      else
759
0
        fputs_filtered (" ", info);
760
761
0
      break;
762
0
          }
763
0
        }
764
0
      break;
765
766
      /* Handle conditions.  */
767
0
    case '?':
768
0
      {
769
0
        s++;
770
0
        switch (*s)
771
0
          {
772
0
          case 'f':
773
0
      (*info->fprintf_func)
774
0
        (info->stream, "%s ",
775
0
         float_comp_names[GET_FIELD (insn, 27, 31)]);
776
0
      break;
777
778
      /* These four conditions are for the set of instructions
779
         which distinguish true/false conditions by opcode
780
         rather than by the 'f' bit (sigh): comb, comib,
781
         addb, addib.  */
782
0
          case 't':
783
0
      fputs_filtered
784
0
        (compare_cond_names[GET_FIELD (insn, 16, 18)], info);
785
0
      break;
786
0
          case 'n':
787
0
      fputs_filtered
788
0
        (compare_cond_names[GET_FIELD (insn, 16, 18)
789
0
                + GET_FIELD (insn, 4, 4) * 8],
790
0
         info);
791
0
      break;
792
0
          case 'N':
793
0
      fputs_filtered
794
0
        (compare_cond_64_names[GET_FIELD (insn, 16, 18)
795
0
             + GET_FIELD (insn, 2, 2) * 8],
796
0
         info);
797
0
      break;
798
0
          case 'Q':
799
0
      fputs_filtered
800
0
        (cmpib_cond_64_names[GET_FIELD (insn, 16, 18)],
801
0
         info);
802
0
      break;
803
0
          case '@':
804
0
      fputs_filtered
805
0
        (add_cond_names[GET_FIELD (insn, 16, 18)
806
0
            + GET_FIELD (insn, 4, 4) * 8],
807
0
         info);
808
0
      break;
809
0
          case 's':
810
0
      (*info->fprintf_func)
811
0
        (info->stream, "%s ",
812
0
         compare_cond_names[GET_COND (insn)]);
813
0
      break;
814
0
          case 'S':
815
0
      (*info->fprintf_func)
816
0
        (info->stream, "%s ",
817
0
         compare_cond_64_names[GET_COND (insn)]);
818
0
      break;
819
0
          case 'a':
820
0
      (*info->fprintf_func)
821
0
        (info->stream, "%s ",
822
0
         add_cond_names[GET_COND (insn)]);
823
0
      break;
824
0
          case 'A':
825
0
      (*info->fprintf_func)
826
0
        (info->stream, "%s ",
827
0
         add_cond_64_names[GET_COND (insn)]);
828
0
      break;
829
0
          case 'd':
830
0
      (*info->fprintf_func)
831
0
        (info->stream, "%s",
832
0
         add_cond_names[GET_FIELD (insn, 16, 18)]);
833
0
      break;
834
835
0
          case 'W':
836
0
      (*info->fprintf_func)
837
0
        (info->stream, "%s",
838
0
         wide_add_cond_names[GET_FIELD (insn, 16, 18) +
839
0
                 GET_FIELD (insn, 4, 4) * 8]);
840
0
      break;
841
842
0
          case 'l':
843
0
      (*info->fprintf_func)
844
0
        (info->stream, "%s ",
845
0
         logical_cond_names[GET_COND (insn)]);
846
0
      break;
847
0
          case 'L':
848
0
      (*info->fprintf_func)
849
0
        (info->stream, "%s ",
850
0
         logical_cond_64_names[GET_COND (insn)]);
851
0
      break;
852
0
          case 'u':
853
0
      (*info->fprintf_func)
854
0
        (info->stream, "%s ",
855
0
         unit_cond_names[GET_COND (insn)]);
856
0
      break;
857
0
          case 'U':
858
0
      (*info->fprintf_func)
859
0
        (info->stream, "%s ",
860
0
         unit_cond_64_names[GET_COND (insn)]);
861
0
      break;
862
0
          case 'y':
863
0
          case 'x':
864
0
          case 'b':
865
0
      (*info->fprintf_func)
866
0
        (info->stream, "%s",
867
0
         shift_cond_names[GET_FIELD (insn, 16, 18)]);
868
869
      /* If the next character in args is 'n', it will handle
870
         putting out the space.  */
871
0
      if (s[1] != 'n')
872
0
        (*info->fprintf_func) (info->stream, " ");
873
0
      break;
874
0
          case 'X':
875
0
      (*info->fprintf_func)
876
0
        (info->stream, "%s ",
877
0
         shift_cond_64_names[GET_FIELD (insn, 16, 18)]);
878
0
      break;
879
0
          case 'B':
880
0
      (*info->fprintf_func)
881
0
        (info->stream, "%s",
882
0
         bb_cond_64_names[GET_FIELD (insn, 16, 16)]);
883
884
      /* If the next character in args is 'n', it will handle
885
         putting out the space.  */
886
0
      if (s[1] != 'n')
887
0
        (*info->fprintf_func) (info->stream, " ");
888
0
      break;
889
0
          }
890
0
        break;
891
0
      }
892
893
0
    case 'V':
894
0
      fput_const (extract_5_store (insn), info);
895
0
      break;
896
0
    case 'r':
897
0
      fput_const (extract_5r_store (insn), info);
898
0
      break;
899
0
    case 'R':
900
0
      fput_const (extract_5R_store (insn), info);
901
0
      break;
902
0
    case 'U':
903
0
      fput_const (extract_10U_store (insn), info);
904
0
      break;
905
0
    case 'B':
906
0
    case 'Q':
907
0
      fput_const (extract_5Q_store (insn), info);
908
0
      break;
909
0
    case 'i':
910
0
      fput_const (extract_11 (insn), info);
911
0
      break;
912
0
    case 'j':
913
0
      fput_const (extract_14 (insn), info);
914
0
      break;
915
0
    case 'k':
916
0
      fputs_filtered ("L%", info);
917
0
      fput_const (extract_21 (insn), info);
918
0
      break;
919
0
    case '<':
920
0
    case 'l':
921
      /* 16-bit long disp., PA2.0 wide only.  */
922
0
      fput_const (extract_16 (insn), info);
923
0
      break;
924
0
    case 'n':
925
0
      if (insn & 0x2)
926
0
        (*info->fprintf_func) (info->stream, ",n ");
927
0
      else
928
0
        (*info->fprintf_func) (info->stream, " ");
929
0
      break;
930
0
    case 'N':
931
0
      if ((insn & 0x20) && s[1])
932
0
        (*info->fprintf_func) (info->stream, ",n ");
933
0
      else if (insn & 0x20)
934
0
        (*info->fprintf_func) (info->stream, ",n");
935
0
      else if (s[1])
936
0
        (*info->fprintf_func) (info->stream, " ");
937
0
      break;
938
0
    case 'w':
939
0
      (*info->print_address_func)
940
0
        (memaddr + 8 + extract_12 (insn), info);
941
0
      break;
942
0
    case 'W':
943
      /* 17 bit PC-relative branch.  */
944
0
      (*info->print_address_func)
945
0
        ((memaddr + 8 + extract_17 (insn)), info);
946
0
      break;
947
0
    case 'z':
948
      /* 17 bit displacement.  This is an offset from a register
949
         so it gets disasssembled as just a number, not any sort
950
         of address.  */
951
0
      fput_const (extract_17 (insn), info);
952
0
      break;
953
954
0
    case 'Z':
955
      /* addil %r1 implicit output.  */
956
0
      fputs_filtered ("r1", info);
957
0
      break;
958
959
0
    case 'Y':
960
      /* be,l %sr0,%r31 implicit output.  */
961
0
      fputs_filtered ("sr0,r31", info);
962
0
      break;
963
964
0
    case '@':
965
0
      (*info->fprintf_func) (info->stream, "0");
966
0
      break;
967
968
0
    case '.':
969
0
      (*info->fprintf_func) (info->stream, "%d",
970
0
           GET_FIELD (insn, 24, 25));
971
0
      break;
972
0
    case '*':
973
0
      (*info->fprintf_func) (info->stream, "%d",
974
0
           GET_FIELD (insn, 22, 25));
975
0
      break;
976
0
    case '!':
977
0
      fputs_filtered ("sar", info);
978
0
      break;
979
0
    case 'p':
980
0
      (*info->fprintf_func) (info->stream, "%d",
981
0
           31 - GET_FIELD (insn, 22, 26));
982
0
      break;
983
0
    case '~':
984
0
      {
985
0
        int num;
986
0
        num = GET_FIELD (insn, 20, 20) << 5;
987
0
        num |= GET_FIELD (insn, 22, 26);
988
0
        (*info->fprintf_func) (info->stream, "%d", 63 - num);
989
0
        break;
990
0
      }
991
0
    case 'P':
992
0
      (*info->fprintf_func) (info->stream, "%d",
993
0
           GET_FIELD (insn, 22, 26));
994
0
      break;
995
0
    case 'q':
996
0
      {
997
0
        int num;
998
0
        num = GET_FIELD (insn, 20, 20) << 5;
999
0
        num |= GET_FIELD (insn, 22, 26);
1000
0
        (*info->fprintf_func) (info->stream, "%d", num);
1001
0
        break;
1002
0
      }
1003
0
    case 'T':
1004
0
      (*info->fprintf_func) (info->stream, "%d",
1005
0
           32 - GET_FIELD (insn, 27, 31));
1006
0
      break;
1007
0
    case '%':
1008
0
      {
1009
0
        int num;
1010
0
        num = (GET_FIELD (insn, 23, 23) + 1) * 32;
1011
0
        num -= GET_FIELD (insn, 27, 31);
1012
0
        (*info->fprintf_func) (info->stream, "%d", num);
1013
0
        break;
1014
0
      }
1015
0
    case '|':
1016
0
      {
1017
0
        int num;
1018
0
        num = (GET_FIELD (insn, 19, 19) + 1) * 32;
1019
0
        num -= GET_FIELD (insn, 27, 31);
1020
0
        (*info->fprintf_func) (info->stream, "%d", num);
1021
0
        break;
1022
0
      }
1023
0
    case '$':
1024
0
      fput_const (GET_FIELD (insn, 20, 28), info);
1025
0
      break;
1026
0
    case 'A':
1027
0
      fput_const (GET_FIELD (insn, 6, 18), info);
1028
0
      break;
1029
0
    case 'D':
1030
0
      fput_const (GET_FIELD (insn, 6, 31), info);
1031
0
      break;
1032
0
    case 'v':
1033
0
      (*info->fprintf_func) (info->stream, ",%d",
1034
0
           GET_FIELD (insn, 23, 25));
1035
0
      break;
1036
0
    case 'O':
1037
0
      fput_const ((GET_FIELD (insn, 6,20) << 5 |
1038
0
             GET_FIELD (insn, 27, 31)), info);
1039
0
      break;
1040
0
    case 'o':
1041
0
      fput_const (GET_FIELD (insn, 6, 20), info);
1042
0
      break;
1043
0
    case '2':
1044
0
      fput_const ((GET_FIELD (insn, 6, 22) << 5 |
1045
0
             GET_FIELD (insn, 27, 31)), info);
1046
0
      break;
1047
0
    case '1':
1048
0
      fput_const ((GET_FIELD (insn, 11, 20) << 5 |
1049
0
             GET_FIELD (insn, 27, 31)), info);
1050
0
      break;
1051
0
    case '0':
1052
0
      fput_const ((GET_FIELD (insn, 16, 20) << 5 |
1053
0
             GET_FIELD (insn, 27, 31)), info);
1054
0
      break;
1055
0
    case 'u':
1056
0
      (*info->fprintf_func) (info->stream, ",%d",
1057
0
           GET_FIELD (insn, 23, 25));
1058
0
      break;
1059
0
    case 'F':
1060
      /* If no destination completer and not before a completer
1061
         for fcmp, need a space here.  */
1062
0
      if (s[1] == 'G' || s[1] == '?')
1063
0
        fputs_filtered
1064
0
          (float_format_names[GET_FIELD (insn, 19, 20)], info);
1065
0
      else
1066
0
        (*info->fprintf_func)
1067
0
          (info->stream, "%s ",
1068
0
           float_format_names[GET_FIELD (insn, 19, 20)]);
1069
0
      break;
1070
0
    case 'G':
1071
0
      (*info->fprintf_func)
1072
0
        (info->stream, "%s ",
1073
0
         float_format_names[GET_FIELD (insn, 17, 18)]);
1074
0
      break;
1075
0
    case 'H':
1076
0
      if (GET_FIELD (insn, 26, 26) == 1)
1077
0
        (*info->fprintf_func) (info->stream, "%s ",
1078
0
             float_format_names[0]);
1079
0
      else
1080
0
        (*info->fprintf_func) (info->stream, "%s ",
1081
0
             float_format_names[1]);
1082
0
      break;
1083
0
    case 'I':
1084
      /* If no destination completer and not before a completer
1085
         for fcmp, need a space here.  */
1086
0
      if (s[1] == '?')
1087
0
        fputs_filtered
1088
0
          (float_format_names[GET_FIELD (insn, 20, 20)], info);
1089
0
      else
1090
0
        (*info->fprintf_func)
1091
0
          (info->stream, "%s ",
1092
0
           float_format_names[GET_FIELD (insn, 20, 20)]);
1093
0
      break;
1094
1095
0
    case 'J':
1096
0
      fput_const (extract_14 (insn), info);
1097
0
      break;
1098
1099
0
    case '#':
1100
0
      {
1101
0
        unsigned sign = GET_FIELD (insn, 31, 31);
1102
0
        unsigned imm10 = GET_FIELD (insn, 18, 27);
1103
0
        unsigned disp;
1104
1105
0
        if (sign)
1106
0
          disp = (-1U << 10) | imm10;
1107
0
        else
1108
0
          disp = imm10;
1109
1110
0
        disp <<= 3;
1111
0
        fput_const (disp, info);
1112
0
        break;
1113
0
      }
1114
0
    case 'K':
1115
0
    case 'd':
1116
0
      {
1117
0
        unsigned sign = GET_FIELD (insn, 31, 31);
1118
0
        unsigned imm11 = GET_FIELD (insn, 18, 28);
1119
0
        unsigned disp;
1120
1121
0
        if (sign)
1122
0
          disp = (-1U << 11) | imm11;
1123
0
        else
1124
0
          disp = imm11;
1125
1126
0
        disp <<= 2;
1127
0
        fput_const (disp, info);
1128
0
        break;
1129
0
      }
1130
1131
0
    case '>':
1132
0
    case 'y':
1133
0
      {
1134
        /* 16-bit long disp., PA2.0 wide only.  */
1135
0
        int disp = extract_16 (insn);
1136
0
        disp &= ~3;
1137
0
        fput_const (disp, info);
1138
0
        break;
1139
0
      }
1140
1141
0
    case '&':
1142
0
      {
1143
        /* 16-bit long disp., PA2.0 wide only.  */
1144
0
        int disp = extract_16 (insn);
1145
0
        disp &= ~7;
1146
0
        fput_const (disp, info);
1147
0
        break;
1148
0
      }
1149
1150
0
    case '_':
1151
0
      break; /* Dealt with by '{' */
1152
1153
0
    case '{':
1154
0
      {
1155
0
        int sub = GET_FIELD (insn, 14, 16);
1156
0
        int df = GET_FIELD (insn, 17, 18);
1157
0
        int sf = GET_FIELD (insn, 19, 20);
1158
0
        const char * const * source = float_format_names;
1159
0
        const char * const * dest = float_format_names;
1160
0
        char *t = "";
1161
1162
0
        if (sub == 4)
1163
0
          {
1164
0
      fputs_filtered (",UND ", info);
1165
0
      break;
1166
0
          }
1167
0
        if ((sub & 3) == 3)
1168
0
          t = ",t";
1169
0
        if ((sub & 3) == 1)
1170
0
          source = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
1171
0
        if (sub & 2)
1172
0
          dest = sub & 4 ? fcnv_ufixed_names : fcnv_fixed_names;
1173
1174
0
        (*info->fprintf_func) (info->stream, "%s%s%s ",
1175
0
             t, source[sf], dest[df]);
1176
0
        break;
1177
0
      }
1178
1179
0
    case 'm':
1180
0
      {
1181
0
        int y = GET_FIELD (insn, 16, 18);
1182
1183
0
        if (y != 1)
1184
0
          fput_const ((y ^ 1) - 1, info);
1185
0
      }
1186
0
      break;
1187
1188
0
    case 'h':
1189
0
      {
1190
0
        int cbit;
1191
1192
0
        cbit = GET_FIELD (insn, 16, 18);
1193
1194
0
        if (cbit > 0)
1195
0
          (*info->fprintf_func) (info->stream, ",%d", cbit - 1);
1196
0
        break;
1197
0
      }
1198
1199
0
    case '=':
1200
0
      {
1201
0
        int cond = GET_FIELD (insn, 27, 31);
1202
1203
0
        switch (cond)
1204
0
          {
1205
0
          case  0: fputs_filtered (" ", info); break;
1206
0
          case  1: fputs_filtered ("acc ", info); break;
1207
0
          case  2: fputs_filtered ("rej ", info); break;
1208
0
          case  5: fputs_filtered ("acc8 ", info); break;
1209
0
          case  6: fputs_filtered ("rej8 ", info); break;
1210
0
          case  9: fputs_filtered ("acc6 ", info); break;
1211
0
          case 13: fputs_filtered ("acc4 ", info); break;
1212
0
          case 17: fputs_filtered ("acc2 ", info); break;
1213
0
          default: break;
1214
0
          }
1215
0
        break;
1216
0
      }
1217
1218
0
    case 'X':
1219
0
      (*info->print_address_func)
1220
0
        (memaddr + 8 + extract_22 (insn), info);
1221
0
      break;
1222
0
    case 'L':
1223
0
      fputs_filtered (",rp", info);
1224
0
      break;
1225
0
    default:
1226
0
      (*info->fprintf_func) (info->stream, "%c", *s);
1227
0
      break;
1228
0
    }
1229
0
      }
1230
0
    return sizeof (insn);
1231
0
  }
1232
0
    }
1233
0
  (*info->fprintf_func) (info->stream, "#%8x", insn);
1234
0
  return sizeof (insn);
1235
0
}