Coverage Report

Created: 2026-07-12 09:22

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/kvx-dis.c
Line
Count
Source
1
/* kvx-dis.c -- Kalray MPPA generic disassembler.
2
   Copyright (C) 2009-2026 Free Software Foundation, Inc.
3
   Contributed by Kalray SA.
4
5
   This file is part of the GNU opcodes library.
6
7
   This library is free software; you can redistribute it and/or modify
8
   it under the terms of the GNU General Public License as published by
9
   the Free Software Foundation; either version 3, or (at your option)
10
   any later version.
11
12
   It is distributed in the hope that it will be useful, but WITHOUT
13
   ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14
   or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public
15
   License for more details.
16
17
   You should have received a copy of the GNU General Public License
18
   along with this program; see the file COPYING3. If not,
19
   see <http://www.gnu.org/licenses/>.  */
20
21
#define STATIC_TABLE
22
#define DEFINE_TABLE
23
24
#include "sysdep.h"
25
#include "disassemble.h"
26
#include "libiberty.h"
27
#include "opintl.h"
28
#include <assert.h>
29
#include "elf-bfd.h"
30
#include "kvx-dis.h"
31
32
#include "elf/kvx.h"
33
#include "opcode/kvx.h"
34
35
/* Steering values for the kvx VLIW architecture.  */
36
37
typedef enum
38
{
39
  Steering_BCU,
40
  Steering_LSU,
41
  Steering_MAU,
42
  Steering_ALU,
43
  Steering__
44
} enum_Steering;
45
typedef uint8_t Steering;
46
47
/* BundleIssue enumeration.  */
48
49
typedef enum
50
{
51
  BundleIssue_BCU,
52
  BundleIssue_TCA,
53
  BundleIssue_ALU0,
54
  BundleIssue_ALU1,
55
  BundleIssue_MAU,
56
  BundleIssue_LSU,
57
  BundleIssue__,
58
} enum_BundleIssue;
59
typedef uint8_t BundleIssue;
60
61
/* An IMMX syllable is associated with the BundleIssue Extension_BundleIssue[extension].  */
62
static const BundleIssue Extension_BundleIssue[] = {
63
  BundleIssue_ALU0,
64
  BundleIssue_ALU1,
65
  BundleIssue_MAU,
66
  BundleIssue_LSU
67
};
68
69
static inline int
70
kvx_steering (uint32_t x)
71
487k
{
72
487k
  return (((x) & 0x60000000) >> 29);
73
487k
}
74
75
static inline int
76
kvx_extension (uint32_t x)
77
66.6k
{
78
66.6k
  return (((x) & 0x18000000) >> 27);
79
66.6k
}
80
81
static inline int
82
kvx_has_parallel_bit (uint32_t x)
83
630k
{
84
630k
  return (((x) & 0x80000000) == 0x80000000);
85
630k
}
86
87
static inline int
88
kvx_is_tca_opcode (uint32_t x)
89
152k
{
90
152k
  unsigned major = ((x) >> 24) & 0x1F;
91
152k
  return (major > 1) && (major < 8);
92
152k
}
93
94
static inline int
95
kvx_is_nop_opcode (uint32_t x)
96
7.65k
{
97
7.65k
  return ((x) << 1) == 0xFFFFFFFE;
98
7.65k
}
99
100
/* A raw instruction.  */
101
102
struct insn_s
103
{
104
  uint32_t syllables[KVXMAXSYLLABLES];
105
  int len;
106
};
107
typedef struct insn_s insn_t;
108
109
110
static uint32_t bundle_words[KVXMAXBUNDLEWORDS];
111
112
static insn_t bundle_insn[KVXMAXBUNDLEISSUE];
113
114
/* A re-interpreted instruction.  */
115
116
struct instr_s
117
{
118
  int valid;
119
  int opcode;
120
  int immx[2];
121
  int immx_valid[2];
122
  int immx_count;
123
  int nb_syllables;
124
};
125
126
/* Option for "pretty printing", ie, not the usual little endian objdump output.  */
127
static int opt_pretty = 0;
128
/* Option for not emiting a new line between all bundles.  */
129
static int opt_compact_assembly = 0;
130
131
void
132
parse_kvx_dis_option (const char *option)
133
0
{
134
  /* Try to match options that are simple flags.  */
135
0
  if (startswith (option, "pretty"))
136
0
    {
137
0
      opt_pretty = 1;
138
0
      return;
139
0
    }
140
141
0
  if (startswith (option, "compact-assembly"))
142
0
    {
143
0
      opt_compact_assembly = 1;
144
0
      return;
145
0
    }
146
147
0
  if (startswith (option, "no-compact-assembly"))
148
0
    {
149
0
      opt_compact_assembly = 0;
150
0
      return;
151
0
    }
152
153
  /* Invalid option.  */
154
0
  opcodes_error_handler (_("unrecognised disassembler option: %s"), option);
155
0
}
156
157
static void
158
parse_kvx_dis_options (const char *options)
159
0
{
160
0
  const char *option_end;
161
162
0
  if (options == NULL)
163
0
    return;
164
165
0
  while (*options != '\0')
166
0
    {
167
      /* Skip empty options.  */
168
0
      if (*options == ',')
169
0
  {
170
0
    options++;
171
0
    continue;
172
0
  }
173
174
      /* We know that *options is neither NUL or a comma.  */
175
0
      option_end = options + 1;
176
0
      while (*option_end != ',' && *option_end != '\0')
177
0
  option_end++;
178
179
0
      parse_kvx_dis_option (options);
180
181
      /* Go on to the next one.  If option_end points to a comma, it
182
         will be skipped above.  */
183
0
      options = option_end;
184
0
    }
185
0
}
186
187
struct kvx_dis_env
188
{
189
  int kvx_arch_size;
190
  struct kvxopc *opc_table;
191
  struct kvx_Register *kvx_registers;
192
  const char ***kvx_modifiers;
193
  int *kvx_dec_registers;
194
  int *kvx_regfiles;
195
  unsigned int kvx_max_dec_registers;
196
  int initialized_p;
197
};
198
199
static struct kvx_dis_env env = {
200
  .kvx_arch_size = 0,
201
  .opc_table = NULL,
202
  .kvx_registers = NULL,
203
  .kvx_modifiers = NULL,
204
  .kvx_dec_registers = NULL,
205
  .kvx_regfiles = NULL,
206
  .initialized_p = 0,
207
  .kvx_max_dec_registers = 0
208
};
209
210
static void
211
kvx_dis_init (struct disassemble_info *info)
212
2
{
213
2
  env.kvx_arch_size = 32;
214
2
  switch (info->mach)
215
2
    {
216
0
    case bfd_mach_kv3_1_64:
217
0
      env.kvx_arch_size = 64;
218
      /* fallthrough */
219
0
    case bfd_mach_kv3_1_usr:
220
1
    case bfd_mach_kv3_1:
221
1
    default:
222
1
      env.opc_table = kvx_kv3_v1_optab;
223
1
      env.kvx_regfiles = kvx_kv3_v1_regfiles;
224
1
      env.kvx_registers = kvx_kv3_v1_registers;
225
1
      env.kvx_modifiers = kvx_kv3_v1_modifiers;
226
1
      env.kvx_dec_registers = kvx_kv3_v1_dec_registers;
227
1
      break;
228
0
    case bfd_mach_kv3_2_64:
229
0
      env.kvx_arch_size = 64;
230
      /* fallthrough */
231
0
    case bfd_mach_kv3_2_usr:
232
0
    case bfd_mach_kv3_2:
233
0
      env.opc_table = kvx_kv3_v2_optab;
234
0
      env.kvx_regfiles = kvx_kv3_v2_regfiles;
235
0
      env.kvx_registers = kvx_kv3_v2_registers;
236
0
      env.kvx_modifiers = kvx_kv3_v2_modifiers;
237
0
      env.kvx_dec_registers = kvx_kv3_v2_dec_registers;
238
0
      break;
239
0
    case bfd_mach_kv4_1_64:
240
0
      env.kvx_arch_size = 64;
241
      /* fallthrough */
242
1
    case bfd_mach_kv4_1_usr:
243
1
    case bfd_mach_kv4_1:
244
1
      env.opc_table = kvx_kv4_v1_optab;
245
1
      env.kvx_regfiles = kvx_kv4_v1_regfiles;
246
1
      env.kvx_registers = kvx_kv4_v1_registers;
247
1
      env.kvx_modifiers = kvx_kv4_v1_modifiers;
248
1
      env.kvx_dec_registers = kvx_kv4_v1_dec_registers;
249
1
      break;
250
2
    }
251
252
2
  env.kvx_max_dec_registers = env.kvx_regfiles[KVX_REGFILE_DEC_REGISTERS];
253
254
2
  if (info->disassembler_options)
255
0
    parse_kvx_dis_options (info->disassembler_options);
256
257
2
  env.initialized_p = 1;
258
2
}
259
260
static bool
261
kvx_reassemble_bundle (int wordcount, int *_insncount)
262
308k
{
263
264
  /* Debugging flag.  */
265
308k
  int debug = 0;
266
267
  /* Available resources.  */
268
308k
  int bcu_taken = 0;
269
308k
  int tca_taken = 0;
270
308k
  int alu0_taken = 0;
271
308k
  int alu1_taken = 0;
272
308k
  int mau_taken = 0;
273
308k
  int lsu_taken = 0;
274
275
308k
  if (debug)
276
0
    fprintf (stderr, "kvx_reassemble_bundle: wordcount = %d\n", wordcount);
277
278
308k
  if (wordcount > KVXMAXBUNDLEWORDS)
279
12.8k
    {
280
12.8k
      if (debug)
281
0
  fprintf (stderr, "bundle exceeds maximum size\n");
282
12.8k
      return false;
283
12.8k
    }
284
285
296k
  struct instr_s instr[KVXMAXBUNDLEISSUE];
286
296k
  memset (instr, 0, sizeof (instr));
287
296k
  assert (KVXMAXBUNDLEISSUE >= BundleIssue__);
288
289
296k
  int i;
290
296k
  unsigned int j;
291
292
756k
  for (i = 0; i < wordcount; i++)
293
487k
    {
294
487k
      uint32_t syllable = bundle_words[i];
295
487k
      switch (kvx_steering (syllable))
296
487k
  {
297
209k
  case Steering_BCU:
298
    /* BCU or TCA instruction.  */
299
209k
    if (i == 0)
300
141k
      {
301
141k
        if (kvx_is_tca_opcode (syllable))
302
22.5k
    {
303
22.5k
      if (tca_taken)
304
0
        {
305
0
          if (debug)
306
0
      fprintf (stderr, "Too many TCA instructions");
307
0
          return false;
308
0
        }
309
22.5k
      if (debug)
310
0
        fprintf (stderr,
311
0
           "Syllable 0: Set valid on TCA for instr %d with 0x%x\n",
312
0
           BundleIssue_TCA, syllable);
313
22.5k
      instr[BundleIssue_TCA].valid = 1;
314
22.5k
      instr[BundleIssue_TCA].opcode = syllable;
315
22.5k
      instr[BundleIssue_TCA].nb_syllables = 1;
316
22.5k
      tca_taken = 1;
317
22.5k
    }
318
118k
        else
319
118k
    {
320
118k
      if (debug)
321
0
        fprintf (stderr,
322
0
           "Syllable 0: Set valid on BCU for instr %d with 0x%x\n",
323
0
           BundleIssue_BCU, syllable);
324
325
118k
      instr[BundleIssue_BCU].valid = 1;
326
118k
      instr[BundleIssue_BCU].opcode = syllable;
327
118k
      instr[BundleIssue_BCU].nb_syllables = 1;
328
118k
      bcu_taken = 1;
329
118k
    }
330
141k
      }
331
68.0k
    else
332
68.0k
      {
333
68.0k
        if (i == 1 && bcu_taken && kvx_is_tca_opcode (syllable))
334
1.45k
    {
335
1.45k
      if (tca_taken)
336
0
        {
337
0
          if (debug)
338
0
      fprintf (stderr, "Too many TCA instructions");
339
0
          return false;
340
0
        }
341
1.45k
      if (debug)
342
0
        fprintf (stderr,
343
0
           "Syllable 0: Set valid on TCA for instr %d with 0x%x\n",
344
0
           BundleIssue_TCA, syllable);
345
1.45k
      instr[BundleIssue_TCA].valid = 1;
346
1.45k
      instr[BundleIssue_TCA].opcode = syllable;
347
1.45k
      instr[BundleIssue_TCA].nb_syllables = 1;
348
1.45k
      tca_taken = 1;
349
1.45k
    }
350
66.6k
        else
351
66.6k
    {
352
      /* Not first syllable in bundle, IMMX.  */
353
66.6k
      struct instr_s *instr_p =
354
66.6k
        &(instr[Extension_BundleIssue[kvx_extension (syllable)]]);
355
66.6k
      int immx_count = instr_p->immx_count;
356
66.6k
      if (immx_count > 1)
357
2.68k
        {
358
2.68k
          if (debug)
359
0
      fprintf (stderr, "Too many IMMX syllables");
360
2.68k
          return false;
361
2.68k
        }
362
63.9k
      instr_p->immx[immx_count] = syllable;
363
63.9k
      instr_p->immx_valid[immx_count] = 1;
364
63.9k
      instr_p->nb_syllables++;
365
63.9k
      if (debug)
366
0
        fprintf (stderr,
367
0
           "Set IMMX[%d] on instr %d for extension %d @ %d\n",
368
0
           immx_count,
369
0
           Extension_BundleIssue[kvx_extension (syllable)],
370
0
           kvx_extension (syllable), i);
371
63.9k
      instr_p->immx_count = immx_count + 1;
372
63.9k
    }
373
68.0k
      }
374
206k
    break;
375
376
206k
  case Steering_ALU:
377
147k
    if (alu0_taken == 0)
378
89.6k
      {
379
89.6k
        if (debug)
380
0
    fprintf (stderr, "Set valid on ALU0 for instr %d with 0x%x\n",
381
0
       BundleIssue_ALU0, syllable);
382
89.6k
        instr[BundleIssue_ALU0].valid = 1;
383
89.6k
        instr[BundleIssue_ALU0].opcode = syllable;
384
89.6k
        instr[BundleIssue_ALU0].nb_syllables = 1;
385
89.6k
        alu0_taken = 1;
386
89.6k
      }
387
57.8k
    else if (alu1_taken == 0)
388
28.6k
      {
389
28.6k
        if (debug)
390
0
    fprintf (stderr, "Set valid on ALU1 for instr %d with 0x%x\n",
391
0
       BundleIssue_ALU1, syllable);
392
28.6k
        instr[BundleIssue_ALU1].valid = 1;
393
28.6k
        instr[BundleIssue_ALU1].opcode = syllable;
394
28.6k
        instr[BundleIssue_ALU1].nb_syllables = 1;
395
28.6k
        alu1_taken = 1;
396
28.6k
      }
397
29.2k
    else if (mau_taken == 0)
398
12.5k
      {
399
12.5k
        if (debug)
400
0
    fprintf (stderr,
401
0
       "Set valid on MAU (ALU) for instr %d with 0x%x\n",
402
0
       BundleIssue_MAU, syllable);
403
12.5k
        instr[BundleIssue_MAU].valid = 1;
404
12.5k
        instr[BundleIssue_MAU].opcode = syllable;
405
12.5k
        instr[BundleIssue_MAU].nb_syllables = 1;
406
12.5k
        mau_taken = 1;
407
12.5k
      }
408
16.6k
    else if (lsu_taken == 0)
409
9.02k
      {
410
9.02k
        if (debug)
411
0
    fprintf (stderr,
412
0
       "Set valid on LSU (ALU) for instr %d with 0x%x\n",
413
0
       BundleIssue_LSU, syllable);
414
9.02k
        instr[BundleIssue_LSU].valid = 1;
415
9.02k
        instr[BundleIssue_LSU].opcode = syllable;
416
9.02k
        instr[BundleIssue_LSU].nb_syllables = 1;
417
9.02k
        lsu_taken = 1;
418
9.02k
      }
419
7.65k
    else if (kvx_is_nop_opcode (syllable))
420
3.68k
      {
421
3.68k
        if (debug)
422
0
    fprintf (stderr, "Ignoring NOP (ALU) syllable\n");
423
3.68k
      }
424
3.96k
    else
425
3.96k
      {
426
3.96k
        if (debug)
427
0
    fprintf (stderr, "Too many ALU instructions");
428
3.96k
        return false;
429
3.96k
      }
430
143k
    break;
431
432
143k
  case Steering_MAU:
433
63.4k
    if (mau_taken == 1)
434
11.1k
      {
435
11.1k
        if (debug)
436
0
    fprintf (stderr, "Too many MAU instructions");
437
11.1k
        return false;
438
11.1k
      }
439
52.3k
    else
440
52.3k
      {
441
52.3k
        if (debug)
442
0
    fprintf (stderr, "Set valid on MAU for instr %d with 0x%x\n",
443
0
       BundleIssue_MAU, syllable);
444
52.3k
        instr[BundleIssue_MAU].valid = 1;
445
52.3k
        instr[BundleIssue_MAU].opcode = syllable;
446
52.3k
        instr[BundleIssue_MAU].nb_syllables = 1;
447
52.3k
        mau_taken = 1;
448
52.3k
      }
449
52.3k
    break;
450
451
66.7k
  case Steering_LSU:
452
66.7k
    if (lsu_taken == 1)
453
9.39k
      {
454
9.39k
        if (debug)
455
0
    fprintf (stderr, "Too many LSU instructions");
456
9.39k
        return false;
457
9.39k
      }
458
57.3k
    else
459
57.3k
      {
460
57.3k
        if (debug)
461
0
    fprintf (stderr, "Set valid on LSU for instr %d with 0x%x\n",
462
0
       BundleIssue_LSU, syllable);
463
57.3k
        instr[BundleIssue_LSU].valid = 1;
464
57.3k
        instr[BundleIssue_LSU].opcode = syllable;
465
57.3k
        instr[BundleIssue_LSU].nb_syllables = 1;
466
57.3k
        lsu_taken = 1;
467
57.3k
      }
468
487k
  }
469
460k
      if (debug)
470
0
  fprintf (stderr, "Continue %d < %d?\n", i, wordcount);
471
460k
    }
472
473
  /* Fill bundle_insn and count read syllables.  */
474
268k
  int instr_idx = 0;
475
1.88M
  for (i = 0; i < KVXMAXBUNDLEISSUE; i++)
476
1.61M
    {
477
1.61M
      if (instr[i].valid == 1)
478
335k
  {
479
335k
    int syllable_idx = 0;
480
481
    /* First copy opcode.  */
482
335k
    bundle_insn[instr_idx].syllables[syllable_idx++] = instr[i].opcode;
483
335k
    bundle_insn[instr_idx].len = 1;
484
485
1.00M
    for (j = 0; j < 2; j++)
486
671k
      {
487
671k
        if (instr[i].immx_valid[j])
488
26.3k
    {
489
26.3k
      if (debug)
490
0
        fprintf (stderr, "Instr %d valid immx[%d] is valid\n", i,
491
0
           j);
492
26.3k
      bundle_insn[instr_idx].syllables[syllable_idx++] =
493
26.3k
        instr[i].immx[j];
494
26.3k
      bundle_insn[instr_idx].len++;
495
26.3k
    }
496
671k
      }
497
498
335k
    if (debug)
499
0
      fprintf (stderr,
500
0
         "Instr %d valid, copying in bundle_insn (%d syllables <-> %d)\n",
501
0
         i, bundle_insn[instr_idx].len, instr[i].nb_syllables);
502
335k
    instr_idx++;
503
335k
  }
504
1.61M
    }
505
506
268k
  if (debug)
507
0
    fprintf (stderr, "End => %d instructions\n", instr_idx);
508
509
268k
  *_insncount = instr_idx;
510
268k
  return true;
511
296k
}
512
513
struct decoded_insn
514
{
515
  /* The entry in the opc_table. */
516
  struct kvxopc *opc;
517
  /* The number of operands.  */
518
  int nb_ops;
519
  /* The content of an operands.  */
520
  struct
521
  {
522
    enum
523
    {
524
      CAT_REGISTER,
525
      CAT_MODIFIER,
526
      CAT_IMMEDIATE,
527
    } type;
528
    /* The value of the operands.  */
529
    uint64_t val;
530
    /* If it is an immediate, its sign.  */
531
    int sign;
532
    /* If it is an immediate, is it pc relative.  */
533
    int pcrel;
534
    /* The width of the operand.  */
535
    int width;
536
    /* If it is a modifier, the modifier category.
537
       An index in the modifier table.  */
538
    int mod_idx;
539
  } operands[KVXMAXOPERANDS];
540
};
541
542
static int
543
decode_insn (bfd_vma memaddr, insn_t * insn, struct decoded_insn *res)
544
315k
{
545
546
315k
  int found = 0;
547
315k
  int idx = 0;
548
315k
  for (struct kvxopc * op = env.opc_table;
549
232M
       op->as_op && (((char) op->as_op[0]) != 0); op++)
550
232M
    {
551
      /* Find the format of this insn.  */
552
232M
      int opcode_match = 1;
553
554
232M
      if (op->wordcount != insn->len)
555
93.9M
  continue;
556
557
282M
      for (int i = 0; i < op->wordcount; i++)
558
143M
  if ((op->codewords[i].mask & insn->syllables[i]) !=
559
143M
      op->codewords[i].opcode)
560
138M
    opcode_match = 0;
561
562
138M
      int encoding_space_flags = env.kvx_arch_size == 32
563
138M
  ? kvxOPCODE_FLAG_MODE32 : kvxOPCODE_FLAG_MODE64;
564
565
282M
      for (int i = 0; i < op->wordcount; i++)
566
143M
  if (!(op->codewords[i].flags & encoding_space_flags))
567
0
    opcode_match = 0;
568
569
138M
      if (opcode_match)
570
235k
  {
571
235k
    res->opc = op;
572
573
882k
    for (int i = 0; op->format[i]; i++)
574
658k
      {
575
658k
        struct kvx_bitfield *bf = op->format[i]->bfield;
576
658k
        int bf_nb = op->format[i]->bitfields;
577
658k
        int width = op->format[i]->width;
578
658k
        int type = op->format[i]->type;
579
658k
        const char *type_name = op->format[i]->tname;
580
658k
        int flags = op->format[i]->flags;
581
658k
        int shift = op->format[i]->shift;
582
658k
        int bias = op->format[i]->bias;
583
658k
        uint64_t value = 0;
584
585
1.33M
        for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
586
681k
    {
587
681k
      int insn_idx = (int) bf[bf_idx].to_offset / 32;
588
681k
      int to_offset = bf[bf_idx].to_offset % 32;
589
681k
      uint64_t encoded_value =
590
681k
        insn->syllables[insn_idx] >> to_offset;
591
681k
      encoded_value &= (1LL << bf[bf_idx].size) - 1;
592
681k
      value |= encoded_value << bf[bf_idx].from_offset;
593
681k
    }
594
658k
        if (flags & kvxSIGNED)
595
105k
    {
596
105k
      uint64_t signbit = 1LL << (width - 1);
597
105k
      value = (value ^ signbit) - signbit;
598
105k
    }
599
658k
        value = (value << shift) + bias;
600
601
658k
#define KVX_PRINT_REG(regfile,value) \
602
658k
    if(env.kvx_regfiles[regfile]+value < env.kvx_max_dec_registers) { \
603
378k
        res->operands[idx].val = env.kvx_dec_registers[env.kvx_regfiles[regfile]+value]; \
604
378k
        res->operands[idx].type = CAT_REGISTER; \
605
378k
  idx++; \
606
378k
    } else { \
607
0
        res->operands[idx].val = ~0; \
608
0
        res->operands[idx].type = CAT_REGISTER; \
609
0
  idx++; \
610
0
    }
611
612
658k
        if (env.opc_table == kvx_kv3_v1_optab)
613
140k
    {
614
140k
      switch (type)
615
140k
        {
616
59.0k
        case RegClass_kv3_v1_singleReg:
617
59.0k
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
618
59.0k
          break;
619
2.70k
        case RegClass_kv3_v1_pairedReg:
620
2.70k
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
621
2.70k
          break;
622
853
        case RegClass_kv3_v1_quadReg:
623
853
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
624
853
          break;
625
0
        case RegClass_kv3_v1_systemReg:
626
52
        case RegClass_kv3_v1_aloneReg:
627
52
        case RegClass_kv3_v1_onlyraReg:
628
64
        case RegClass_kv3_v1_onlygetReg:
629
64
        case RegClass_kv3_v1_onlysetReg:
630
64
        case RegClass_kv3_v1_onlyfxReg:
631
64
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
632
64
          break;
633
221
        case RegClass_kv3_v1_coproReg0M4:
634
268
        case RegClass_kv3_v1_coproReg1M4:
635
347
        case RegClass_kv3_v1_coproReg2M4:
636
383
        case RegClass_kv3_v1_coproReg3M4:
637
383
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
638
383
          break;
639
273
        case RegClass_kv3_v1_blockRegE:
640
421
        case RegClass_kv3_v1_blockRegO:
641
1.07k
        case RegClass_kv3_v1_blockReg0M4:
642
1.38k
        case RegClass_kv3_v1_blockReg1M4:
643
1.65k
        case RegClass_kv3_v1_blockReg2M4:
644
1.88k
        case RegClass_kv3_v1_blockReg3M4:
645
1.88k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
646
1.88k
          break;
647
9.53k
        case RegClass_kv3_v1_vectorReg:
648
11.6k
        case RegClass_kv3_v1_vectorRegE:
649
13.8k
        case RegClass_kv3_v1_vectorRegO:
650
13.8k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
651
13.8k
          break;
652
3.44k
        case RegClass_kv3_v1_tileReg:
653
3.44k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
654
3.44k
          break;
655
3.30k
        case RegClass_kv3_v1_matrixReg:
656
3.30k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
657
3.30k
          break;
658
3
        case Immediate_kv3_v1_sysnumber:
659
13.8k
        case Immediate_kv3_v1_signed10:
660
14.2k
        case Immediate_kv3_v1_signed16:
661
14.2k
        case Immediate_kv3_v1_signed27:
662
14.6k
        case Immediate_kv3_v1_wrapped32:
663
15.8k
        case Immediate_kv3_v1_signed37:
664
15.8k
        case Immediate_kv3_v1_signed43:
665
15.9k
        case Immediate_kv3_v1_signed54:
666
15.9k
        case Immediate_kv3_v1_wrapped64:
667
21.5k
        case Immediate_kv3_v1_unsigned6:
668
21.5k
          res->operands[idx].val = value;
669
21.5k
          res->operands[idx].sign = flags & kvxSIGNED;
670
21.5k
          res->operands[idx].width = width;
671
21.5k
          res->operands[idx].type = CAT_IMMEDIATE;
672
21.5k
          res->operands[idx].pcrel = 0;
673
21.5k
          idx++;
674
21.5k
          break;
675
3.84k
        case Immediate_kv3_v1_pcrel17:
676
8.46k
        case Immediate_kv3_v1_pcrel27:
677
8.46k
          res->operands[idx].val = value + memaddr;
678
8.46k
          res->operands[idx].sign = flags & kvxSIGNED;
679
8.46k
          res->operands[idx].width = width;
680
8.46k
          res->operands[idx].type = CAT_IMMEDIATE;
681
8.46k
          res->operands[idx].pcrel = 1;
682
8.46k
          idx++;
683
8.46k
          break;
684
0
        case Modifier_kv3_v1_column:
685
1.66k
        case Modifier_kv3_v1_comparison:
686
2.03k
        case Modifier_kv3_v1_doscale:
687
2.03k
        case Modifier_kv3_v1_exunum:
688
2.73k
        case Modifier_kv3_v1_floatcomp:
689
2.88k
        case Modifier_kv3_v1_qindex:
690
3.22k
        case Modifier_kv3_v1_rectify:
691
6.42k
        case Modifier_kv3_v1_rounding:
692
7.49k
        case Modifier_kv3_v1_roundint:
693
8.27k
        case Modifier_kv3_v1_saturate:
694
16.1k
        case Modifier_kv3_v1_scalarcond:
695
19.3k
        case Modifier_kv3_v1_silent:
696
19.4k
        case Modifier_kv3_v1_simplecond:
697
20.0k
        case Modifier_kv3_v1_speculate:
698
20.1k
        case Modifier_kv3_v1_splat32:
699
24.7k
        case Modifier_kv3_v1_variant:
700
24.7k
          {
701
24.7k
      int sz = 0;
702
24.7k
      int mod_idx = type - Modifier_kv3_v1_column;
703
224k
      for (sz = 0; env.kvx_modifiers[mod_idx][sz]; ++sz);
704
24.7k
      const char *mod = value < (unsigned) sz
705
24.7k
        ? env.kvx_modifiers[mod_idx][value] : NULL;
706
24.7k
      if (!mod) goto retry;
707
23.3k
      res->operands[idx].val = value;
708
23.3k
      res->operands[idx].type = CAT_MODIFIER;
709
23.3k
      res->operands[idx].mod_idx = mod_idx;
710
23.3k
      idx++;
711
23.3k
          }
712
0
          break;
713
0
        default:
714
0
          fprintf (stderr, "error: unexpected operand type (%s)\n",
715
0
             type_name);
716
0
          exit (-1);
717
140k
        };
718
138k
    }
719
517k
        else if (env.opc_table == kvx_kv3_v2_optab)
720
0
    {
721
0
      switch (type)
722
0
        {
723
0
        case RegClass_kv3_v2_singleReg:
724
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
725
0
          break;
726
0
        case RegClass_kv3_v2_pairedReg:
727
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
728
0
          break;
729
0
        case RegClass_kv3_v2_quadReg:
730
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
731
0
          break;
732
0
        case RegClass_kv3_v2_systemReg:
733
0
        case RegClass_kv3_v2_aloneReg:
734
0
        case RegClass_kv3_v2_onlyraReg:
735
0
        case RegClass_kv3_v2_onlygetReg:
736
0
        case RegClass_kv3_v2_onlysetReg:
737
0
        case RegClass_kv3_v2_onlyfxReg:
738
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
739
0
          break;
740
0
        case RegClass_kv3_v2_coproReg:
741
0
        case RegClass_kv3_v2_coproReg0M4:
742
0
        case RegClass_kv3_v2_coproReg1M4:
743
0
        case RegClass_kv3_v2_coproReg2M4:
744
0
        case RegClass_kv3_v2_coproReg3M4:
745
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
746
0
          break;
747
0
        case RegClass_kv3_v2_blockReg:
748
0
        case RegClass_kv3_v2_blockRegE:
749
0
        case RegClass_kv3_v2_blockRegO:
750
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
751
0
          break;
752
0
        case RegClass_kv3_v2_vectorReg:
753
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
754
0
          break;
755
0
        case RegClass_kv3_v2_tileReg:
756
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
757
0
          break;
758
0
        case RegClass_kv3_v2_matrixReg:
759
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
760
0
          break;
761
0
        case RegClass_kv3_v2_buffer2Reg:
762
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X2R, value)
763
0
          break;
764
0
        case RegClass_kv3_v2_buffer4Reg:
765
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X4R, value)
766
0
          break;
767
0
        case RegClass_kv3_v2_buffer8Reg:
768
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X8R, value)
769
0
          break;
770
0
        case RegClass_kv3_v2_buffer16Reg:
771
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X16R, value)
772
0
          break;
773
0
        case RegClass_kv3_v2_buffer32Reg:
774
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X32R, value)
775
0
          break;
776
0
        case RegClass_kv3_v2_buffer64Reg:
777
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X64R, value)
778
0
          break;
779
0
        case Immediate_kv3_v2_brknumber:
780
0
        case Immediate_kv3_v2_sysnumber:
781
0
        case Immediate_kv3_v2_signed10:
782
0
        case Immediate_kv3_v2_signed16:
783
0
        case Immediate_kv3_v2_signed27:
784
0
        case Immediate_kv3_v2_wrapped32:
785
0
        case Immediate_kv3_v2_signed37:
786
0
        case Immediate_kv3_v2_signed43:
787
0
        case Immediate_kv3_v2_signed54:
788
0
        case Immediate_kv3_v2_wrapped64:
789
0
        case Immediate_kv3_v2_unsigned6:
790
0
          res->operands[idx].val = value;
791
0
          res->operands[idx].sign = flags & kvxSIGNED;
792
0
          res->operands[idx].width = width;
793
0
          res->operands[idx].type = CAT_IMMEDIATE;
794
0
          res->operands[idx].pcrel = 0;
795
0
          idx++;
796
0
          break;
797
0
        case Immediate_kv3_v2_pcrel27:
798
0
        case Immediate_kv3_v2_pcrel17:
799
0
          res->operands[idx].val = value + memaddr;
800
0
          res->operands[idx].sign = flags & kvxSIGNED;
801
0
          res->operands[idx].width = width;
802
0
          res->operands[idx].type = CAT_IMMEDIATE;
803
0
          res->operands[idx].pcrel = 1;
804
0
          idx++;
805
0
          break;
806
0
        case Modifier_kv3_v2_accesses:
807
0
        case Modifier_kv3_v2_boolcas:
808
0
        case Modifier_kv3_v2_cachelev:
809
0
        case Modifier_kv3_v2_channel:
810
0
        case Modifier_kv3_v2_coherency:
811
0
        case Modifier_kv3_v2_comparison:
812
0
        case Modifier_kv3_v2_conjugate:
813
0
        case Modifier_kv3_v2_doscale:
814
0
        case Modifier_kv3_v2_exunum:
815
0
        case Modifier_kv3_v2_floatcomp:
816
0
        case Modifier_kv3_v2_hindex:
817
0
        case Modifier_kv3_v2_lsomask:
818
0
        case Modifier_kv3_v2_lsumask:
819
0
        case Modifier_kv3_v2_lsupack:
820
0
        case Modifier_kv3_v2_qindex:
821
0
        case Modifier_kv3_v2_rounding:
822
0
        case Modifier_kv3_v2_scalarcond:
823
0
        case Modifier_kv3_v2_shuffleV:
824
0
        case Modifier_kv3_v2_shuffleX:
825
0
        case Modifier_kv3_v2_silent:
826
0
        case Modifier_kv3_v2_simplecond:
827
0
        case Modifier_kv3_v2_speculate:
828
0
        case Modifier_kv3_v2_splat32:
829
0
        case Modifier_kv3_v2_transpose:
830
0
        case Modifier_kv3_v2_variant:
831
0
          {
832
0
      int sz = 0;
833
0
      int mod_idx = type - Modifier_kv3_v2_accesses;
834
0
      for (sz = 0; env.kvx_modifiers[mod_idx][sz];
835
0
           ++sz);
836
0
      const char *mod = value < (unsigned) sz
837
0
        ? env.kvx_modifiers[mod_idx][value] : NULL;
838
0
      if (!mod) goto retry;
839
0
      res->operands[idx].val = value;
840
0
      res->operands[idx].type = CAT_MODIFIER;
841
0
      res->operands[idx].mod_idx = mod_idx;
842
0
      idx++;
843
0
          };
844
0
          break;
845
0
        default:
846
0
          fprintf (stderr,
847
0
             "error: unexpected operand type (%s)\n",
848
0
             type_name);
849
0
          exit (-1);
850
0
        };
851
0
    }
852
517k
        else if (env.opc_table == kvx_kv4_v1_optab)
853
517k
    {
854
517k
      switch (type)
855
517k
        {
856
857
233k
        case RegClass_kv4_v1_singleReg:
858
233k
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
859
233k
          break;
860
17.9k
        case RegClass_kv4_v1_pairedReg:
861
17.9k
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
862
17.9k
          break;
863
3.16k
        case RegClass_kv4_v1_quadReg:
864
3.16k
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
865
3.16k
          break;
866
0
        case RegClass_kv4_v1_systemReg:
867
114
        case RegClass_kv4_v1_aloneReg:
868
114
        case RegClass_kv4_v1_onlyraReg:
869
281
        case RegClass_kv4_v1_onlygetReg:
870
281
        case RegClass_kv4_v1_onlysetReg:
871
281
        case RegClass_kv4_v1_onlyfxReg:
872
281
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
873
281
          break;
874
2.51k
        case RegClass_kv4_v1_coproReg:
875
2.78k
        case RegClass_kv4_v1_coproReg0M4:
876
2.88k
        case RegClass_kv4_v1_coproReg1M4:
877
2.94k
        case RegClass_kv4_v1_coproReg2M4:
878
3.38k
        case RegClass_kv4_v1_coproReg3M4:
879
3.38k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
880
3.38k
          break;
881
785
        case RegClass_kv4_v1_blockReg:
882
853
        case RegClass_kv4_v1_blockRegE:
883
907
        case RegClass_kv4_v1_blockRegO:
884
907
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
885
907
          break;
886
23.1k
        case RegClass_kv4_v1_vectorReg:
887
23.1k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
888
23.1k
          break;
889
6.04k
        case RegClass_kv4_v1_tileReg:
890
6.04k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
891
6.04k
          break;
892
2.97k
        case RegClass_kv4_v1_matrixReg:
893
2.97k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
894
2.97k
          break;
895
353
        case RegClass_kv4_v1_buffer2Reg:
896
353
          KVX_PRINT_REG (KVX_REGFILE_DEC_X2R, value)
897
353
          break;
898
179
        case RegClass_kv4_v1_buffer4Reg:
899
179
          KVX_PRINT_REG (KVX_REGFILE_DEC_X4R, value)
900
179
          break;
901
189
        case RegClass_kv4_v1_buffer8Reg:
902
189
          KVX_PRINT_REG (KVX_REGFILE_DEC_X8R, value)
903
189
          break;
904
29
        case RegClass_kv4_v1_buffer16Reg:
905
29
          KVX_PRINT_REG (KVX_REGFILE_DEC_X16R, value)
906
29
          break;
907
464
        case RegClass_kv4_v1_buffer32Reg:
908
464
          KVX_PRINT_REG (KVX_REGFILE_DEC_X32R, value)
909
464
          break;
910
221
        case RegClass_kv4_v1_buffer64Reg:
911
221
          KVX_PRINT_REG (KVX_REGFILE_DEC_X64R, value)
912
221
          break;
913
110
        case Immediate_kv4_v1_brknumber:
914
1.08k
        case Immediate_kv4_v1_sysnumber:
915
40.7k
        case Immediate_kv4_v1_signed10:
916
42.7k
        case Immediate_kv4_v1_signed16:
917
43.2k
        case Immediate_kv4_v1_signed27:
918
45.8k
        case Immediate_kv4_v1_wrapped32:
919
51.3k
        case Immediate_kv4_v1_signed37:
920
51.8k
        case Immediate_kv4_v1_signed43:
921
52.2k
        case Immediate_kv4_v1_signed54:
922
52.5k
        case Immediate_kv4_v1_wrapped64:
923
66.7k
        case Immediate_kv4_v1_unsigned6:
924
66.7k
          res->operands[idx].val = value;
925
66.7k
          res->operands[idx].sign = flags & kvxSIGNED;
926
66.7k
          res->operands[idx].width = width;
927
66.7k
          res->operands[idx].type = CAT_IMMEDIATE;
928
66.7k
          res->operands[idx].pcrel = 0;
929
66.7k
          idx++;
930
66.7k
          break;
931
21.2k
        case Immediate_kv4_v1_pcrel27:
932
33.1k
        case Immediate_kv4_v1_pcrel17:
933
33.1k
          res->operands[idx].val = value + memaddr;
934
33.1k
          res->operands[idx].sign = flags & kvxSIGNED;
935
33.1k
          res->operands[idx].width = width;
936
33.1k
          res->operands[idx].type = CAT_IMMEDIATE;
937
33.1k
          res->operands[idx].pcrel = 1;
938
33.1k
          idx++;
939
33.1k
          break;
940
41
        case Modifier_kv4_v1_accesses:
941
697
        case Modifier_kv4_v1_boolcas:
942
738
        case Modifier_kv4_v1_cachelev:
943
1.41k
        case Modifier_kv4_v1_channel:
944
2.41k
        case Modifier_kv4_v1_coherency:
945
12.1k
        case Modifier_kv4_v1_comparison:
946
14.0k
        case Modifier_kv4_v1_conjugate:
947
15.4k
        case Modifier_kv4_v1_doscale:
948
15.4k
        case Modifier_kv4_v1_exunum:
949
18.6k
        case Modifier_kv4_v1_floatcomp:
950
18.6k
        case Modifier_kv4_v1_hindex:
951
18.9k
        case Modifier_kv4_v1_lsomask:
952
21.4k
        case Modifier_kv4_v1_lsumask:
953
23.5k
        case Modifier_kv4_v1_lsupack:
954
25.1k
        case Modifier_kv4_v1_qindex:
955
47.5k
        case Modifier_kv4_v1_rounding:
956
73.4k
        case Modifier_kv4_v1_scalarcond:
957
74.0k
        case Modifier_kv4_v1_shuffleV:
958
74.3k
        case Modifier_kv4_v1_shuffleX:
959
96.9k
        case Modifier_kv4_v1_silent:
960
97.7k
        case Modifier_kv4_v1_simplecond:
961
97.7k
        case Modifier_kv4_v1_speculate:
962
99.7k
        case Modifier_kv4_v1_splat32:
963
100k
        case Modifier_kv4_v1_transpose:
964
125k
        case Modifier_kv4_v1_variant:
965
125k
          {
966
125k
      int sz = 0;
967
125k
      int mod_idx = type - Modifier_kv4_v1_accesses;
968
1.04M
      for (sz = 0; env.kvx_modifiers[mod_idx][sz]; ++sz);
969
125k
      const char *mod = value < (unsigned) sz
970
125k
        ? env.kvx_modifiers[mod_idx][value] : NULL;
971
125k
      if (!mod) goto retry;
972
115k
      res->operands[idx].val = value;
973
115k
      res->operands[idx].type = CAT_MODIFIER;
974
115k
      res->operands[idx].mod_idx = mod_idx;
975
115k
      idx++;
976
115k
          }
977
0
          break;
978
0
        default:
979
0
          fprintf (stderr, "error: unexpected operand type (%s)\n",
980
0
             type_name);
981
0
          exit (-1);
982
517k
        };
983
508k
    }
984
985
658k
#undef KVX_PRINT_REG
986
658k
      }
987
988
224k
    found = 1;
989
224k
    break;
990
11.1k
  retry:;
991
11.1k
    idx = 0;
992
11.1k
    continue;
993
235k
  }
994
138M
 }
995
315k
  res->nb_ops = idx;
996
315k
  return found;
997
315k
}
998
999
int
1000
print_insn_kvx (bfd_vma memaddr, struct disassemble_info *info)
1001
356k
{
1002
356k
  static int insnindex = 0;
1003
356k
  static int insncount = 0;
1004
356k
  insn_t *insn;
1005
356k
  int readsofar = 0;
1006
356k
  int found = 0;
1007
356k
  int invalid_bundle = 0;
1008
1009
356k
  if (!env.initialized_p)
1010
2
    kvx_dis_init (info);
1011
1012
  /* Clear instruction information field.  */
1013
356k
  info->insn_info_valid = 0;
1014
356k
  info->branch_delay_insns = 0;
1015
356k
  info->data_size = 0;
1016
356k
  info->insn_type = dis_noninsn;
1017
356k
  info->target = 0;
1018
356k
  info->target2 = 0;
1019
1020
  /* Set line length.  */
1021
356k
  info->bytes_per_line = 16;
1022
1023
1024
  /* If this is the beginning of the bundle, read BUNDLESIZE words and apply
1025
     decentrifugate function.  */
1026
356k
  if (insnindex == 0)
1027
309k
    {
1028
309k
      int wordcount;
1029
643k
      for (wordcount = 0; wordcount < KVXMAXBUNDLEWORDS; wordcount++)
1030
630k
  {
1031
630k
    int status;
1032
630k
    status =
1033
630k
      (*info->read_memory_func) (memaddr + 4 * wordcount,
1034
630k
               (bfd_byte *) (bundle_words +
1035
630k
                 wordcount), 4, info);
1036
630k
    if (status != 0)
1037
452
      {
1038
452
        (*info->memory_error_func) (status, memaddr + 4 * wordcount,
1039
452
            info);
1040
452
        return -1;
1041
452
      }
1042
630k
    if (!kvx_has_parallel_bit (bundle_words[wordcount]))
1043
296k
      break;
1044
630k
  }
1045
308k
      wordcount++;
1046
308k
      invalid_bundle = !kvx_reassemble_bundle (wordcount, &insncount);
1047
308k
    }
1048
1049
356k
  assert (insnindex < KVXMAXBUNDLEISSUE);
1050
355k
  insn = &(bundle_insn[insnindex]);
1051
355k
  readsofar = insn->len * 4;
1052
355k
  insnindex++;
1053
1054
355k
  if (opt_pretty)
1055
0
    {
1056
0
      (*info->fprintf_func) (info->stream, "[ ");
1057
0
      for (int i = 0; i < insn->len; i++)
1058
0
  (*info->fprintf_func) (info->stream, "%08x ", insn->syllables[i]);
1059
0
      (*info->fprintf_func) (info->stream, "] ");
1060
0
    }
1061
1062
  /* Check for extension to right iff this is not the end of bundle.  */
1063
1064
355k
  struct decoded_insn dec;
1065
355k
  memset (&dec, 0, sizeof dec);
1066
355k
  if (!invalid_bundle && (found = decode_insn (memaddr, insn, &dec)))
1067
224k
    {
1068
224k
      int ch;
1069
224k
      (*info->fprintf_func) (info->stream, "%s", dec.opc->as_op);
1070
224k
      const char *fmtp = dec.opc->fmtstring;
1071
869k
      for (int i = 0; i < dec.nb_ops; ++i)
1072
644k
  {
1073
    /* Print characters in the format string up to the following % or nul.  */
1074
1.61M
    while ((ch = *fmtp) && ch != '%')
1075
966k
      {
1076
966k
        (*info->fprintf_func) (info->stream, "%c", ch);
1077
966k
        fmtp++;
1078
966k
      }
1079
1080
    /* Skip past %s.  */
1081
644k
    if (ch == '%')
1082
644k
      {
1083
644k
        ch = *fmtp++;
1084
644k
        fmtp++;
1085
644k
      }
1086
1087
644k
    switch (dec.operands[i].type)
1088
644k
      {
1089
378k
      case CAT_REGISTER:
1090
378k
        (*info->fprintf_func) (info->stream, "%s",
1091
378k
             env.kvx_registers[dec.operands[i].val].name);
1092
378k
        break;
1093
136k
      case CAT_MODIFIER:
1094
136k
        {
1095
136k
    const char *mod = env.kvx_modifiers[dec.operands[i].mod_idx][dec.operands[i].val];
1096
136k
    (*info->fprintf_func) (info->stream, "%s", !mod || !strcmp (mod, ".") ? "" : mod);
1097
136k
        }
1098
136k
        break;
1099
129k
      case CAT_IMMEDIATE:
1100
129k
        {
1101
129k
    if (dec.operands[i].pcrel)
1102
41.5k
      {
1103
        /* Fill in instruction information.  */
1104
41.5k
        info->insn_info_valid = 1;
1105
41.5k
        info->insn_type =
1106
41.5k
          dec.operands[i].width ==
1107
41.5k
          17 ? dis_condbranch : dis_branch;
1108
41.5k
        info->target = dec.operands[i].val;
1109
1110
41.5k
        info->print_address_func (dec.operands[i].val, info);
1111
41.5k
      }
1112
88.2k
    else if (dec.operands[i].sign)
1113
64.0k
      {
1114
64.0k
        if (dec.operands[i].width <= 32)
1115
56.4k
          {
1116
56.4k
      (*info->fprintf_func) (info->stream, "%" PRId32 " (0x%" PRIx32 ")",
1117
56.4k
                 (int32_t) dec.operands[i].val,
1118
56.4k
                 (int32_t) dec.operands[i].val);
1119
56.4k
          }
1120
7.59k
        else
1121
7.59k
          {
1122
7.59k
      (*info->fprintf_func) (info->stream, "%" PRId64 " (0x%" PRIx64 ")",
1123
7.59k
                 dec.operands[i].val,
1124
7.59k
                 dec.operands[i].val);
1125
7.59k
          }
1126
64.0k
      }
1127
24.2k
    else
1128
24.2k
      {
1129
24.2k
        if (dec.operands[i].width <= 32)
1130
23.8k
          {
1131
23.8k
      (*info->fprintf_func) (info->stream, "%" PRIu32 " (0x%" PRIx32 ")",
1132
23.8k
                 (uint32_t) dec.operands[i].
1133
23.8k
                 val,
1134
23.8k
                 (uint32_t) dec.operands[i].
1135
23.8k
                 val);
1136
23.8k
          }
1137
438
        else
1138
438
          {
1139
438
      (*info->fprintf_func) (info->stream, "%" PRIu64 " (0x%" PRIx64 ")",
1140
438
                 (uint64_t) dec.
1141
438
                 operands[i].val,
1142
438
                 (uint64_t) dec.
1143
438
                 operands[i].val);
1144
438
          }
1145
24.2k
      }
1146
129k
        }
1147
129k
        break;
1148
0
      default:
1149
0
        break;
1150
1151
644k
      }
1152
644k
  }
1153
1154
252k
      while ((ch = *fmtp))
1155
28.1k
  {
1156
28.1k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "%c",
1157
28.1k
          ch);
1158
28.1k
    fmtp++;
1159
28.1k
  }
1160
224k
    }
1161
131k
  else
1162
131k
    {
1163
131k
      (*info->fprintf_func) (info->stream, "*** invalid opcode ***\n");
1164
131k
      insnindex = 0;
1165
131k
      readsofar = 4;
1166
131k
    }
1167
1168
355k
  if (found && (insnindex == insncount))
1169
177k
    {
1170
177k
      (*info->fprintf_func) (info->stream, ";;");
1171
177k
      if (!opt_compact_assembly)
1172
177k
  (*info->fprintf_func) (info->stream, "\n");
1173
177k
      insnindex = 0;
1174
177k
    }
1175
1176
355k
  return readsofar;
1177
355k
}
1178
1179
/* This function searches in the current bundle for the instructions required
1180
   by unwinding. For prologue:
1181
     (1) addd $r12 = $r12, <res_stack>
1182
     (2) get <gpr_ra_reg> = $ra
1183
     (3) sd <ofs>[$r12] = <gpr_ra_reg> or sq/so containing <gpr_ra_reg>
1184
     (4) sd <ofs>[$r12] = $r14 or sq/so containing r14
1185
     (5) addd $r14 = $r12, <fp_ofs> or copyd $r14 = $r12
1186
   The only difference seen between the code generated by gcc and clang
1187
   is the setting/resetting r14. gcc could also generate copyd $r14=$r12
1188
   instead of add addd $r14 = $r12, <ofs> when <ofs> is 0.
1189
   Vice-versa, <ofs> is not guaranteed to be 0 for clang, so, clang
1190
   could also generate addd instead of copyd
1191
     (6) call, icall, goto, igoto, cb., ret
1192
  For epilogue:
1193
     (1) addd $r12 = $r12, <res_stack>
1194
     (2) addd $r12 = $r14, <offset> or copyd $r12 = $r14
1195
   Same comment as prologue (5).
1196
     (3) ret, goto
1197
     (4) call, icall, igoto, cb.  */
1198
1199
int
1200
decode_prologue_epilogue_bundle (bfd_vma memaddr,
1201
         struct disassemble_info *info,
1202
         struct kvx_prologue_epilogue_bundle *peb)
1203
0
{
1204
0
  int i, nb_insn, nb_syl;
1205
1206
0
  peb->nb_insn = 0;
1207
1208
0
  if (info->arch != bfd_arch_kvx)
1209
0
    return -1;
1210
1211
0
  if (!env.initialized_p)
1212
0
    kvx_dis_init (info);
1213
1214
  /* Read the bundle.  */
1215
0
  for (nb_syl = 0; nb_syl < KVXMAXBUNDLEWORDS; nb_syl++)
1216
0
    {
1217
0
      if ((*info->read_memory_func) (memaddr + 4 * nb_syl,
1218
0
             (bfd_byte *) &bundle_words[nb_syl], 4,
1219
0
             info))
1220
0
  return -1;
1221
0
      if (!kvx_has_parallel_bit (bundle_words[nb_syl]))
1222
0
  break;
1223
0
    }
1224
0
  nb_syl++;
1225
0
  if (!kvx_reassemble_bundle (nb_syl, &nb_insn))
1226
0
    return -1;
1227
1228
  /* Check for extension to right if this is not the end of bundle
1229
     find the format of this insn.  */
1230
0
  for (int idx_insn = 0; idx_insn < nb_insn; idx_insn++)
1231
0
    {
1232
0
      insn_t *insn = &bundle_insn[idx_insn];
1233
0
      int is_add = 0, is_get = 0, is_a_peb_insn = 0, is_copyd = 0;
1234
1235
0
      struct decoded_insn dec;
1236
0
      memset (&dec, 0, sizeof dec);
1237
0
      if (!decode_insn (memaddr, insn, &dec))
1238
0
  continue;
1239
1240
0
      const char *op_name = dec.opc->as_op;
1241
0
      struct kvx_prologue_epilogue_insn *crt_peb_insn;
1242
1243
0
      crt_peb_insn = &peb->insn[peb->nb_insn];
1244
0
      crt_peb_insn->nb_gprs = 0;
1245
1246
0
      if (!strcmp (op_name, "addd"))
1247
0
  is_add = 1;
1248
0
      else if (!strcmp (op_name, "copyd"))
1249
0
  is_copyd = 1;
1250
0
      else if (!strcmp (op_name, "get"))
1251
0
  is_get = 1;
1252
0
      else if (!strcmp (op_name, "sd"))
1253
0
  {
1254
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SD;
1255
0
    is_a_peb_insn = 1;
1256
0
  }
1257
0
      else if (!strcmp (op_name, "sq"))
1258
0
  {
1259
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SQ;
1260
0
    is_a_peb_insn = 1;
1261
0
  }
1262
0
      else if (!strcmp (op_name, "so"))
1263
0
  {
1264
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SO;
1265
0
    is_a_peb_insn = 1;
1266
0
  }
1267
0
      else if (!strcmp (op_name, "ret"))
1268
0
  {
1269
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_RET;
1270
0
    is_a_peb_insn = 1;
1271
0
  }
1272
0
      else if (!strcmp (op_name, "goto"))
1273
0
  {
1274
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_GOTO;
1275
0
    is_a_peb_insn = 1;
1276
0
  }
1277
0
      else if (!strcmp (op_name, "igoto"))
1278
0
  {
1279
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_IGOTO;
1280
0
    is_a_peb_insn = 1;
1281
0
  }
1282
0
      else if (!strcmp (op_name, "call") || !strcmp (op_name, "icall"))
1283
0
  {
1284
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_CALL;
1285
0
    is_a_peb_insn = 1;
1286
0
  }
1287
0
      else if (!strncmp (op_name, "cb", 2))
1288
0
  {
1289
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_CB;
1290
0
    is_a_peb_insn = 1;
1291
0
  }
1292
0
      else
1293
0
  continue;
1294
1295
0
      for (i = 0; dec.opc->format[i]; i++)
1296
0
  {
1297
0
    struct kvx_operand *fmt = dec.opc->format[i];
1298
0
    struct kvx_bitfield *bf = fmt->bfield;
1299
0
    int bf_nb = fmt->bitfields;
1300
0
    int width = fmt->width;
1301
0
    int type = fmt->type;
1302
0
    int flags = fmt->flags;
1303
0
    int shift = fmt->shift;
1304
0
    int bias = fmt->bias;
1305
0
    uint64_t encoded_value, value = 0;
1306
1307
0
    for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
1308
0
      {
1309
0
        int insn_idx = (int) bf[bf_idx].to_offset / 32;
1310
0
        int to_offset = bf[bf_idx].to_offset % 32;
1311
0
        encoded_value = insn->syllables[insn_idx] >> to_offset;
1312
0
        encoded_value &= (1LL << bf[bf_idx].size) - 1;
1313
0
        value |= encoded_value << bf[bf_idx].from_offset;
1314
0
      }
1315
0
    if (flags & kvxSIGNED)
1316
0
      {
1317
0
        uint64_t signbit = 1LL << (width - 1);
1318
0
        value = (value ^ signbit) - signbit;
1319
0
      }
1320
0
    value = (value << shift) + bias;
1321
1322
0
#define chk_type(core_, val_) \
1323
0
      (env.opc_table == kvx_## core_ ##_optab && type == (val_))
1324
1325
0
    if (chk_type (kv3_v1, RegClass_kv3_v1_singleReg)
1326
0
        || chk_type (kv3_v2, RegClass_kv3_v2_singleReg)
1327
0
        || chk_type (kv4_v1, RegClass_kv4_v1_singleReg))
1328
0
      {
1329
0
        if (env.kvx_regfiles[KVX_REGFILE_DEC_GPR] + value
1330
0
      >= env.kvx_max_dec_registers)
1331
0
    return -1;
1332
0
        if (is_add && i < 2)
1333
0
    {
1334
0
      if (i == 0)
1335
0
        {
1336
0
          if (value == KVX_GPR_REG_SP)
1337
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_SP;
1338
0
          else if (value == KVX_GPR_REG_FP)
1339
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_FP;
1340
0
          else
1341
0
      is_add = 0;
1342
0
        }
1343
0
      else if (i == 1)
1344
0
        {
1345
0
          if (value == KVX_GPR_REG_SP)
1346
0
      is_a_peb_insn = 1;
1347
0
          else if (value == KVX_GPR_REG_FP
1348
0
             && crt_peb_insn->insn_type
1349
0
             == KVX_PROL_EPIL_INSN_ADD_SP)
1350
0
      {
1351
0
        crt_peb_insn->insn_type
1352
0
          = KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP;
1353
0
        is_a_peb_insn = 1;
1354
0
      }
1355
0
          else
1356
0
      is_add = 0;
1357
0
        }
1358
0
    }
1359
0
        else if (is_copyd && i < 2)
1360
0
    {
1361
0
      if (i == 0)
1362
0
        {
1363
0
          if (value == KVX_GPR_REG_FP)
1364
0
      {
1365
0
        crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_FP;
1366
0
        crt_peb_insn->immediate = 0;
1367
0
      }
1368
0
          else if (value == KVX_GPR_REG_SP)
1369
0
      {
1370
0
        crt_peb_insn->insn_type
1371
0
          = KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP;
1372
0
        crt_peb_insn->immediate = 0;
1373
0
      }
1374
0
          else
1375
0
      is_copyd = 0;
1376
0
        }
1377
0
      else if (i == 1)
1378
0
        {
1379
0
          if (value == KVX_GPR_REG_SP
1380
0
        && crt_peb_insn->insn_type
1381
0
        == KVX_PROL_EPIL_INSN_ADD_FP)
1382
0
      is_a_peb_insn = 1;
1383
0
          else if (value == KVX_GPR_REG_FP
1384
0
             && crt_peb_insn->insn_type
1385
0
             == KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP)
1386
0
      is_a_peb_insn = 1;
1387
0
          else
1388
0
      is_copyd = 0;
1389
0
        }
1390
0
    }
1391
0
        else
1392
0
    crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value;
1393
0
      }
1394
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_pairedReg)
1395
0
       || chk_type (kv3_v2, RegClass_kv3_v2_pairedReg)
1396
0
       || chk_type (kv4_v1, RegClass_kv4_v1_pairedReg))
1397
0
      crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value * 2;
1398
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_quadReg)
1399
0
       || chk_type (kv3_v2, RegClass_kv3_v2_quadReg)
1400
0
       || chk_type (kv4_v1, RegClass_kv4_v1_quadReg))
1401
0
      crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value * 4;
1402
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_systemReg)
1403
0
       || chk_type (kv3_v2, RegClass_kv3_v2_systemReg)
1404
0
       || chk_type (kv4_v1, RegClass_kv4_v1_systemReg)
1405
0
       || chk_type (kv3_v1, RegClass_kv3_v1_aloneReg)
1406
0
       || chk_type (kv3_v2, RegClass_kv3_v2_aloneReg)
1407
0
       || chk_type (kv4_v1, RegClass_kv4_v1_aloneReg)
1408
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlyraReg)
1409
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlyraReg)
1410
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlygetReg)
1411
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlygetReg)
1412
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlygetReg)
1413
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlygetReg)
1414
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlysetReg)
1415
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlysetReg)
1416
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlysetReg)
1417
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlyfxReg)
1418
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlyfxReg)
1419
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlyfxReg))
1420
0
      {
1421
0
        if (env.kvx_regfiles[KVX_REGFILE_DEC_GPR] + value
1422
0
      >= env.kvx_max_dec_registers)
1423
0
    return -1;
1424
0
        if (is_get && !strcmp (env.kvx_registers[env.kvx_dec_registers[env.kvx_regfiles[KVX_REGFILE_DEC_SFR] + value]].name, "$ra"))
1425
0
    {
1426
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_GET_RA;
1427
0
      is_a_peb_insn = 1;
1428
0
    }
1429
0
      }
1430
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_coproReg)
1431
0
       || chk_type (kv3_v2, RegClass_kv3_v2_coproReg)
1432
0
       || chk_type (kv4_v1, RegClass_kv4_v1_coproReg)
1433
0
       || chk_type (kv3_v1, RegClass_kv3_v1_blockReg)
1434
0
       || chk_type (kv3_v2, RegClass_kv3_v2_blockReg)
1435
0
       || chk_type (kv4_v1, RegClass_kv4_v1_blockReg)
1436
0
       || chk_type (kv3_v1, RegClass_kv3_v1_vectorReg)
1437
0
       || chk_type (kv3_v2, RegClass_kv3_v2_vectorReg)
1438
0
       || chk_type (kv4_v1, RegClass_kv4_v1_vectorReg)
1439
0
       || chk_type (kv3_v1, RegClass_kv3_v1_tileReg)
1440
0
       || chk_type (kv3_v2, RegClass_kv3_v2_tileReg)
1441
0
       || chk_type (kv4_v1, RegClass_kv4_v1_tileReg)
1442
0
       || chk_type (kv3_v1, RegClass_kv3_v1_matrixReg)
1443
0
       || chk_type (kv3_v2, RegClass_kv3_v2_matrixReg)
1444
0
       || chk_type (kv4_v1, RegClass_kv4_v1_matrixReg)
1445
0
       || chk_type (kv3_v1, Modifier_kv3_v1_scalarcond)
1446
0
       || chk_type (kv3_v1, Modifier_kv3_v1_column)
1447
0
       || chk_type (kv3_v1, Modifier_kv3_v1_comparison)
1448
0
       || chk_type (kv3_v1, Modifier_kv3_v1_doscale)
1449
0
       || chk_type (kv3_v1, Modifier_kv3_v1_exunum)
1450
0
       || chk_type (kv3_v1, Modifier_kv3_v1_floatcomp)
1451
0
       || chk_type (kv3_v1, Modifier_kv3_v1_qindex)
1452
0
       || chk_type (kv3_v1, Modifier_kv3_v1_rectify)
1453
0
       || chk_type (kv3_v1, Modifier_kv3_v1_rounding)
1454
0
       || chk_type (kv3_v1, Modifier_kv3_v1_roundint)
1455
0
       || chk_type (kv3_v1, Modifier_kv3_v1_saturate)
1456
0
       || chk_type (kv3_v1, Modifier_kv3_v1_scalarcond)
1457
0
       || chk_type (kv3_v1, Modifier_kv3_v1_silent)
1458
0
       || chk_type (kv3_v1, Modifier_kv3_v1_simplecond)
1459
0
       || chk_type (kv3_v1, Modifier_kv3_v1_speculate)
1460
0
       || chk_type (kv3_v1, Modifier_kv3_v1_splat32)
1461
0
       || chk_type (kv3_v1, Modifier_kv3_v1_variant)
1462
0
       || chk_type (kv3_v2, Modifier_kv3_v2_accesses)
1463
0
       || chk_type (kv3_v2, Modifier_kv3_v2_boolcas)
1464
0
       || chk_type (kv3_v2, Modifier_kv3_v2_cachelev)
1465
0
       || chk_type (kv3_v2, Modifier_kv3_v2_channel)
1466
0
       || chk_type (kv3_v2, Modifier_kv3_v2_coherency)
1467
0
       || chk_type (kv3_v2, Modifier_kv3_v2_comparison)
1468
0
       || chk_type (kv3_v2, Modifier_kv3_v2_conjugate)
1469
0
       || chk_type (kv3_v2, Modifier_kv3_v2_doscale)
1470
0
       || chk_type (kv3_v2, Modifier_kv3_v2_exunum)
1471
0
       || chk_type (kv3_v2, Modifier_kv3_v2_floatcomp)
1472
0
       || chk_type (kv3_v2, Modifier_kv3_v2_hindex)
1473
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsomask)
1474
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsumask)
1475
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsupack)
1476
0
       || chk_type (kv3_v2, Modifier_kv3_v2_qindex)
1477
0
       || chk_type (kv3_v2, Modifier_kv3_v2_rounding)
1478
0
       || chk_type (kv3_v2, Modifier_kv3_v2_scalarcond)
1479
0
       || chk_type (kv3_v2, Modifier_kv3_v2_shuffleV)
1480
0
       || chk_type (kv3_v2, Modifier_kv3_v2_shuffleX)
1481
0
       || chk_type (kv3_v2, Modifier_kv3_v2_silent)
1482
0
       || chk_type (kv3_v2, Modifier_kv3_v2_simplecond)
1483
0
       || chk_type (kv3_v2, Modifier_kv3_v2_speculate)
1484
0
       || chk_type (kv3_v2, Modifier_kv3_v2_splat32)
1485
0
       || chk_type (kv3_v2, Modifier_kv3_v2_transpose)
1486
0
       || chk_type (kv3_v2, Modifier_kv3_v2_variant)
1487
0
       || chk_type (kv4_v1, Modifier_kv4_v1_accesses)
1488
0
       || chk_type (kv4_v1, Modifier_kv4_v1_boolcas)
1489
0
       || chk_type (kv4_v1, Modifier_kv4_v1_cachelev)
1490
0
       || chk_type (kv4_v1, Modifier_kv4_v1_channel)
1491
0
       || chk_type (kv4_v1, Modifier_kv4_v1_coherency)
1492
0
       || chk_type (kv4_v1, Modifier_kv4_v1_comparison)
1493
0
       || chk_type (kv4_v1, Modifier_kv4_v1_conjugate)
1494
0
       || chk_type (kv4_v1, Modifier_kv4_v1_doscale)
1495
0
       || chk_type (kv4_v1, Modifier_kv4_v1_exunum)
1496
0
       || chk_type (kv4_v1, Modifier_kv4_v1_floatcomp)
1497
0
       || chk_type (kv4_v1, Modifier_kv4_v1_hindex)
1498
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsomask)
1499
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsumask)
1500
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsupack)
1501
0
       || chk_type (kv4_v1, Modifier_kv4_v1_qindex)
1502
0
       || chk_type (kv4_v1, Modifier_kv4_v1_rounding)
1503
0
       || chk_type (kv4_v1, Modifier_kv4_v1_scalarcond)
1504
0
       || chk_type (kv4_v1, Modifier_kv4_v1_shuffleV)
1505
0
       || chk_type (kv4_v1, Modifier_kv4_v1_shuffleX)
1506
0
       || chk_type (kv4_v1, Modifier_kv4_v1_silent)
1507
0
       || chk_type (kv4_v1, Modifier_kv4_v1_simplecond)
1508
0
       || chk_type (kv4_v1, Modifier_kv4_v1_speculate)
1509
0
       || chk_type (kv4_v1, Modifier_kv4_v1_splat32)
1510
0
       || chk_type (kv4_v1, Modifier_kv4_v1_transpose)
1511
0
       || chk_type (kv4_v1, Modifier_kv4_v1_variant))
1512
0
      {
1513
        /* Do nothing.  */
1514
0
      }
1515
0
    else if (chk_type (kv3_v1, Immediate_kv3_v1_sysnumber)
1516
0
       || chk_type (kv3_v2, Immediate_kv3_v2_sysnumber)
1517
0
       || chk_type (kv4_v1, Immediate_kv4_v1_sysnumber)
1518
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped8)
1519
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped8)
1520
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed10)
1521
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed10)
1522
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed10)
1523
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed16)
1524
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed16)
1525
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed16)
1526
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed27)
1527
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed27)
1528
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed27)
1529
0
       || chk_type (kv3_v1, Immediate_kv3_v1_wrapped32)
1530
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped32)
1531
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped32)
1532
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed37)
1533
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed37)
1534
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed37)
1535
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed43)
1536
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed43)
1537
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed43)
1538
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed54)
1539
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed54)
1540
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed54)
1541
0
       || chk_type (kv3_v1, Immediate_kv3_v1_wrapped64)
1542
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped64)
1543
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped64)
1544
0
       || chk_type (kv3_v1, Immediate_kv3_v1_unsigned6)
1545
0
       || chk_type (kv3_v2, Immediate_kv3_v2_unsigned6)
1546
0
       || chk_type (kv4_v1, Immediate_kv4_v1_unsigned6))
1547
0
      crt_peb_insn->immediate = value;
1548
0
    else if (chk_type (kv3_v1, Immediate_kv3_v1_pcrel17)
1549
0
       || chk_type (kv3_v2, Immediate_kv3_v2_pcrel17)
1550
0
       || chk_type (kv4_v1, Immediate_kv4_v1_pcrel17)
1551
0
       || chk_type (kv3_v1, Immediate_kv3_v1_pcrel27)
1552
0
       || chk_type (kv3_v2, Immediate_kv3_v2_pcrel27)
1553
0
       || chk_type (kv4_v1, Immediate_kv4_v1_pcrel27))
1554
0
      crt_peb_insn->immediate = value + memaddr;
1555
0
    else
1556
0
      return -1;
1557
0
  }
1558
1559
0
      if (is_a_peb_insn)
1560
0
  peb->nb_insn++;
1561
0
      continue;
1562
0
    }
1563
1564
0
  return nb_syl * 4;
1565
0
#undef chk_type
1566
0
}
1567
1568
void
1569
print_kvx_disassembler_options (FILE * stream)
1570
0
{
1571
0
  fprintf (stream, _("\n\
1572
0
The following KVX specific disassembler options are supported for use\n\
1573
0
with the -M switch (multiple options should be separated by commas):\n"));
1574
1575
0
  fprintf (stream, _("\n\
1576
0
  pretty               Print 32-bit words in natural order corresponding to \
1577
0
re-ordered instruction.\n"));
1578
1579
0
  fprintf (stream, _("\n\
1580
0
  compact-assembly     Do not emit a new line between bundles of instructions.\
1581
0
\n"));
1582
1583
0
  fprintf (stream, _("\n\
1584
0
  no-compact-assembly  Emit a new line between bundles of instructions.\n"));
1585
1586
  fprintf (stream, _("\n"));
1587
0
}