Coverage Report

Created: 2023-08-28 06:31

/src/binutils-gdb/opcodes/kvx-dis.c
Line
Count
Source (jump to first uncovered line)
1
/* kvx-dis.c -- Kalray MPPA generic disassembler.
2
   Copyright (C) 2009-2023 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
135k
{
72
135k
  return (((x) & 0x60000000) >> 29);
73
135k
}
74
75
static inline int
76
kvx_extension (uint32_t x)
77
18.3k
{
78
18.3k
  return (((x) & 0x18000000) >> 27);
79
18.3k
}
80
81
static inline int
82
kvx_has_parallel_bit (uint32_t x)
83
356k
{
84
356k
  return (((x) & 0x80000000) == 0x80000000);
85
356k
}
86
87
static inline int
88
kvx_is_tca_opcode (uint32_t x)
89
32.4k
{
90
32.4k
  unsigned major = ((x) >> 24) & 0x1F;
91
32.4k
  return (major > 1) && (major < 8);
92
32.4k
}
93
94
static inline int
95
kvx_is_nop_opcode (uint32_t x)
96
3.04k
{
97
3.04k
  return ((x) << 1) == 0xFFFFFFFE;
98
3.04k
}
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
1
{
213
1
  env.kvx_arch_size = 32;
214
1
  switch (info->mach)
215
1
    {
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
0
    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
0
    case bfd_mach_kv4_1_usr:
243
0
    case bfd_mach_kv4_1:
244
0
      env.opc_table = kvx_kv4_v1_optab;
245
0
      env.kvx_regfiles = kvx_kv4_v1_regfiles;
246
0
      env.kvx_registers = kvx_kv4_v1_registers;
247
0
      env.kvx_modifiers = kvx_kv4_v1_modifiers;
248
0
      env.kvx_dec_registers = kvx_kv4_v1_dec_registers;
249
0
      break;
250
1
    }
251
252
1
  env.kvx_max_dec_registers = env.kvx_regfiles[KVX_REGFILE_DEC_REGISTERS];
253
254
1
  if (info->disassembler_options)
255
0
    parse_kvx_dis_options (info->disassembler_options);
256
257
1
  env.initialized_p = 1;
258
1
}
259
260
static int
261
kvx_reassemble_bundle (int wordcount, int *_insncount)
262
75.1k
{
263
264
  /* Debugging flag.  */
265
75.1k
  int debug = 0;
266
267
  /* Available resources.  */
268
75.1k
  int bcu_taken = 0;
269
75.1k
  int tca_taken = 0;
270
75.1k
  int alu0_taken = 0;
271
75.1k
  int alu1_taken = 0;
272
75.1k
  int mau_taken = 0;
273
75.1k
  int lsu_taken = 0;
274
275
75.1k
  int i;
276
75.1k
  unsigned int j;
277
278
75.1k
  struct instr_s instr[KVXMAXBUNDLEISSUE];
279
75.1k
  assert (KVXMAXBUNDLEISSUE >= BundleIssue__);
280
75.1k
  memset (instr, 0, sizeof (instr));
281
282
75.1k
  if (debug)
283
0
    fprintf (stderr, "kvx_reassemble_bundle: wordcount = %d\n", wordcount);
284
285
75.1k
  if (wordcount == 0)
286
0
    {
287
0
      if (debug)
288
0
  fprintf (stderr, "wordcount == 0\n");
289
0
      return 1;
290
0
    }
291
292
136k
  for (i = 0; i < wordcount; i++)
293
135k
    {
294
135k
      uint32_t syllable = bundle_words[i];
295
135k
      switch (kvx_steering (syllable))
296
135k
  {
297
47.7k
  case Steering_BCU:
298
    /* BCU or TCA instruction.  */
299
47.7k
    if (i == 0)
300
29.0k
      {
301
29.0k
        if (kvx_is_tca_opcode (syllable))
302
3.22k
    {
303
3.22k
      if (tca_taken)
304
0
        {
305
0
          if (debug)
306
0
      fprintf (stderr, "Too many TCA instructions");
307
0
          return 1;
308
0
        }
309
3.22k
      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
3.22k
      instr[BundleIssue_TCA].valid = 1;
314
3.22k
      instr[BundleIssue_TCA].opcode = syllable;
315
3.22k
      instr[BundleIssue_TCA].nb_syllables = 1;
316
3.22k
      tca_taken = 1;
317
3.22k
    }
318
25.8k
        else
319
25.8k
    {
320
25.8k
      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
25.8k
      instr[BundleIssue_BCU].valid = 1;
326
25.8k
      instr[BundleIssue_BCU].opcode = syllable;
327
25.8k
      instr[BundleIssue_BCU].nb_syllables = 1;
328
25.8k
      bcu_taken = 1;
329
25.8k
    }
330
29.0k
      }
331
18.6k
    else
332
18.6k
      {
333
18.6k
        if (i == 1 && bcu_taken && kvx_is_tca_opcode (syllable))
334
280
    {
335
280
      if (tca_taken)
336
0
        {
337
0
          if (debug)
338
0
      fprintf (stderr, "Too many TCA instructions");
339
0
          return 1;
340
0
        }
341
280
      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
280
      instr[BundleIssue_TCA].valid = 1;
346
280
      instr[BundleIssue_TCA].opcode = syllable;
347
280
      instr[BundleIssue_TCA].nb_syllables = 1;
348
280
      tca_taken = 1;
349
280
    }
350
18.3k
        else
351
18.3k
    {
352
      /* Not first syllable in bundle, IMMX.  */
353
18.3k
      struct instr_s *instr_p =
354
18.3k
        &(instr[Extension_BundleIssue[kvx_extension (syllable)]]);
355
18.3k
      int immx_count = instr_p->immx_count;
356
18.3k
      if (immx_count > 1)
357
1.57k
        {
358
1.57k
          if (debug)
359
0
      fprintf (stderr, "Too many IMMX syllables");
360
1.57k
          return 1;
361
1.57k
        }
362
16.7k
      instr_p->immx[immx_count] = syllable;
363
16.7k
      instr_p->immx_valid[immx_count] = 1;
364
16.7k
      instr_p->nb_syllables++;
365
16.7k
      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
16.7k
      instr_p->immx_count = immx_count + 1;
372
16.7k
    }
373
18.6k
      }
374
46.1k
    break;
375
376
46.1k
  case Steering_ALU:
377
39.2k
    if (alu0_taken == 0)
378
22.2k
      {
379
22.2k
        if (debug)
380
0
    fprintf (stderr, "Set valid on ALU0 for instr %d with 0x%x\n",
381
0
       BundleIssue_ALU0, syllable);
382
22.2k
        instr[BundleIssue_ALU0].valid = 1;
383
22.2k
        instr[BundleIssue_ALU0].opcode = syllable;
384
22.2k
        instr[BundleIssue_ALU0].nb_syllables = 1;
385
22.2k
        alu0_taken = 1;
386
22.2k
      }
387
17.0k
    else if (alu1_taken == 0)
388
7.39k
      {
389
7.39k
        if (debug)
390
0
    fprintf (stderr, "Set valid on ALU1 for instr %d with 0x%x\n",
391
0
       BundleIssue_ALU1, syllable);
392
7.39k
        instr[BundleIssue_ALU1].valid = 1;
393
7.39k
        instr[BundleIssue_ALU1].opcode = syllable;
394
7.39k
        instr[BundleIssue_ALU1].nb_syllables = 1;
395
7.39k
        alu1_taken = 1;
396
7.39k
      }
397
9.66k
    else if (mau_taken == 0)
398
3.79k
      {
399
3.79k
        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
3.79k
        instr[BundleIssue_MAU].valid = 1;
404
3.79k
        instr[BundleIssue_MAU].opcode = syllable;
405
3.79k
        instr[BundleIssue_MAU].nb_syllables = 1;
406
3.79k
        mau_taken = 1;
407
3.79k
      }
408
5.87k
    else if (lsu_taken == 0)
409
2.82k
      {
410
2.82k
        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
2.82k
        instr[BundleIssue_LSU].valid = 1;
415
2.82k
        instr[BundleIssue_LSU].opcode = syllable;
416
2.82k
        instr[BundleIssue_LSU].nb_syllables = 1;
417
2.82k
        lsu_taken = 1;
418
2.82k
      }
419
3.04k
    else if (kvx_is_nop_opcode (syllable))
420
1.60k
      {
421
1.60k
        if (debug)
422
0
    fprintf (stderr, "Ignoring NOP (ALU) syllable\n");
423
1.60k
      }
424
1.44k
    else
425
1.44k
      {
426
1.44k
        if (debug)
427
0
    fprintf (stderr, "Too many ALU instructions");
428
1.44k
        return 1;
429
1.44k
      }
430
37.8k
    break;
431
432
37.8k
  case Steering_MAU:
433
17.0k
    if (mau_taken == 1)
434
3.20k
      {
435
3.20k
        if (debug)
436
0
    fprintf (stderr, "Too many MAU instructions");
437
3.20k
        return 1;
438
3.20k
      }
439
13.8k
    else
440
13.8k
      {
441
13.8k
        if (debug)
442
0
    fprintf (stderr, "Set valid on MAU for instr %d with 0x%x\n",
443
0
       BundleIssue_MAU, syllable);
444
13.8k
        instr[BundleIssue_MAU].valid = 1;
445
13.8k
        instr[BundleIssue_MAU].opcode = syllable;
446
13.8k
        instr[BundleIssue_MAU].nb_syllables = 1;
447
13.8k
        mau_taken = 1;
448
13.8k
      }
449
13.8k
    break;
450
451
31.8k
  case Steering_LSU:
452
31.8k
    if (lsu_taken == 1)
453
9.28k
      {
454
9.28k
        if (debug)
455
0
    fprintf (stderr, "Too many LSU instructions");
456
9.28k
        return 1;
457
9.28k
      }
458
22.6k
    else
459
22.6k
      {
460
22.6k
        if (debug)
461
0
    fprintf (stderr, "Set valid on LSU for instr %d with 0x%x\n",
462
0
       BundleIssue_LSU, syllable);
463
22.6k
        instr[BundleIssue_LSU].valid = 1;
464
22.6k
        instr[BundleIssue_LSU].opcode = syllable;
465
22.6k
        instr[BundleIssue_LSU].nb_syllables = 1;
466
22.6k
        lsu_taken = 1;
467
22.6k
      }
468
135k
  }
469
120k
      if (!(kvx_has_parallel_bit (syllable)))
470
59.2k
  {
471
59.2k
    if (debug)
472
0
      fprintf (stderr, "Stop! stop bit is set 0x%x\n", syllable);
473
59.2k
    break;
474
59.2k
  }
475
61.1k
      if (debug)
476
0
  fprintf (stderr, "Continue %d < %d?\n", i, wordcount);
477
478
61.1k
    }
479
59.6k
  if (kvx_has_parallel_bit (bundle_words[i]))
480
0
    {
481
0
      if (debug)
482
0
  fprintf (stderr, "bundle exceeds maximum size");
483
0
      return 1;
484
0
    }
485
486
  /* Fill bundle_insn and count read syllables.  */
487
59.6k
  int instr_idx = 0;
488
417k
  for (i = 0; i < KVXMAXBUNDLEISSUE; i++)
489
358k
    {
490
358k
      if (instr[i].valid == 1)
491
77.0k
  {
492
77.0k
    int syllable_idx = 0;
493
494
    /* First copy opcode.  */
495
77.0k
    bundle_insn[instr_idx].syllables[syllable_idx++] = instr[i].opcode;
496
77.0k
    bundle_insn[instr_idx].len = 1;
497
498
231k
    for (j = 0; j < 2; j++)
499
154k
      {
500
154k
        if (instr[i].immx_valid[j])
501
5.71k
    {
502
5.71k
      if (debug)
503
0
        fprintf (stderr, "Instr %d valid immx[%d] is valid\n", i,
504
0
           j);
505
5.71k
      bundle_insn[instr_idx].syllables[syllable_idx++] =
506
5.71k
        instr[i].immx[j];
507
5.71k
      bundle_insn[instr_idx].len++;
508
5.71k
    }
509
154k
      }
510
511
77.0k
    if (debug)
512
0
      fprintf (stderr,
513
0
         "Instr %d valid, copying in bundle_insn (%d syllables <-> %d)\n",
514
0
         i, bundle_insn[instr_idx].len, instr[i].nb_syllables);
515
77.0k
    instr_idx++;
516
77.0k
  }
517
358k
    }
518
519
59.6k
  if (debug)
520
0
    fprintf (stderr, "End => %d instructions\n", instr_idx);
521
522
59.6k
  *_insncount = instr_idx;
523
59.6k
  return 0;
524
59.6k
}
525
526
struct decoded_insn
527
{
528
  /* The entry in the opc_table. */
529
  struct kvxopc *opc;
530
  /* The number of operands.  */
531
  int nb_ops;
532
  /* The content of an operands.  */
533
  struct
534
  {
535
    enum
536
    {
537
      CAT_REGISTER,
538
      CAT_MODIFIER,
539
      CAT_IMMEDIATE,
540
    } type;
541
    /* The value of the operands.  */
542
    uint64_t val;
543
    /* If it is an immediate, its sign.  */
544
    int sign;
545
    /* If it is an immediate, is it pc relative.  */
546
    int pcrel;
547
    /* The width of the operand.  */
548
    int width;
549
    /* If it is a modifier, the modifier category.
550
       An index in the modifier table.  */
551
    int mod_idx;
552
  } operands[KVXMAXOPERANDS];
553
};
554
555
static int
556
decode_insn (bfd_vma memaddr, insn_t * insn, struct decoded_insn *res)
557
71.8k
{
558
559
71.8k
  int found = 0;
560
71.8k
  int idx = 0;
561
71.8k
  for (struct kvxopc * op = env.opc_table;
562
46.5M
       op->as_op && (((char) op->as_op[0]) != 0); op++)
563
46.5M
    {
564
      /* Find the format of this insn.  */
565
46.5M
      int opcode_match = 1;
566
567
46.5M
      if (op->wordcount != insn->len)
568
20.0M
  continue;
569
570
54.1M
      for (int i = 0; i < op->wordcount; i++)
571
27.6M
  if ((op->codewords[i].mask & insn->syllables[i]) !=
572
27.6M
      op->codewords[i].opcode)
573
26.4M
    opcode_match = 0;
574
575
26.4M
      int encoding_space_flags = env.kvx_arch_size == 32
576
26.4M
  ? kvxOPCODE_FLAG_MODE32 : kvxOPCODE_FLAG_MODE64;
577
578
54.1M
      for (int i = 0; i < op->wordcount; i++)
579
27.6M
  if (!(op->codewords[i].flags & encoding_space_flags))
580
0
    opcode_match = 0;
581
582
26.4M
      if (opcode_match)
583
55.1k
  {
584
55.1k
    res->opc = op;
585
586
208k
    for (int i = 0; op->format[i]; i++)
587
154k
      {
588
154k
        struct kvx_bitfield *bf = op->format[i]->bfield;
589
154k
        int bf_nb = op->format[i]->bitfields;
590
154k
        int width = op->format[i]->width;
591
154k
        int type = op->format[i]->type;
592
154k
        const char *type_name = op->format[i]->tname;
593
154k
        int flags = op->format[i]->flags;
594
154k
        int shift = op->format[i]->shift;
595
154k
        int bias = op->format[i]->bias;
596
154k
        uint64_t value = 0;
597
598
314k
        for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
599
159k
    {
600
159k
      int insn_idx = (int) bf[bf_idx].to_offset / 32;
601
159k
      int to_offset = bf[bf_idx].to_offset % 32;
602
159k
      uint64_t encoded_value =
603
159k
        insn->syllables[insn_idx] >> to_offset;
604
159k
      encoded_value &= (1LL << bf[bf_idx].size) - 1;
605
159k
      value |= encoded_value << bf[bf_idx].from_offset;
606
159k
    }
607
154k
        if (flags & kvxSIGNED)
608
29.0k
    {
609
29.0k
      uint64_t signbit = 1LL << (width - 1);
610
29.0k
      value = (value ^ signbit) - signbit;
611
29.0k
    }
612
154k
        value = (value << shift) + bias;
613
614
154k
#define KVX_PRINT_REG(regfile,value) \
615
154k
    if(env.kvx_regfiles[regfile]+value < env.kvx_max_dec_registers) { \
616
90.0k
        res->operands[idx].val = env.kvx_dec_registers[env.kvx_regfiles[regfile]+value]; \
617
90.0k
        res->operands[idx].type = CAT_REGISTER; \
618
90.0k
  idx++; \
619
90.0k
    } else { \
620
0
        res->operands[idx].val = ~0; \
621
0
        res->operands[idx].type = CAT_REGISTER; \
622
0
  idx++; \
623
0
    }
624
625
154k
        if (env.opc_table == kvx_kv3_v1_optab)
626
154k
    {
627
154k
      switch (type)
628
154k
        {
629
72.9k
        case RegClass_kv3_v1_singleReg:
630
72.9k
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
631
72.9k
          break;
632
2.28k
        case RegClass_kv3_v1_pairedReg:
633
2.28k
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
634
2.28k
          break;
635
1.13k
        case RegClass_kv3_v1_quadReg:
636
1.13k
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
637
1.13k
          break;
638
0
        case RegClass_kv3_v1_systemReg:
639
8
        case RegClass_kv3_v1_aloneReg:
640
8
        case RegClass_kv3_v1_onlyraReg:
641
8
        case RegClass_kv3_v1_onlygetReg:
642
8
        case RegClass_kv3_v1_onlysetReg:
643
8
        case RegClass_kv3_v1_onlyfxReg:
644
8
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
645
8
          break;
646
103
        case RegClass_kv3_v1_coproReg0M4:
647
153
        case RegClass_kv3_v1_coproReg1M4:
648
229
        case RegClass_kv3_v1_coproReg2M4:
649
237
        case RegClass_kv3_v1_coproReg3M4:
650
237
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
651
237
          break;
652
132
        case RegClass_kv3_v1_blockRegE:
653
201
        case RegClass_kv3_v1_blockRegO:
654
400
        case RegClass_kv3_v1_blockReg0M4:
655
514
        case RegClass_kv3_v1_blockReg1M4:
656
596
        case RegClass_kv3_v1_blockReg2M4:
657
700
        case RegClass_kv3_v1_blockReg3M4:
658
700
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
659
700
          break;
660
5.62k
        case RegClass_kv3_v1_vectorReg:
661
7.44k
        case RegClass_kv3_v1_vectorRegE:
662
9.26k
        case RegClass_kv3_v1_vectorRegO:
663
9.26k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
664
9.26k
          break;
665
1.42k
        case RegClass_kv3_v1_tileReg:
666
1.42k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
667
1.42k
          break;
668
2.06k
        case RegClass_kv3_v1_matrixReg:
669
2.06k
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
670
2.06k
          break;
671
4
        case Immediate_kv3_v1_sysnumber:
672
17.0k
        case Immediate_kv3_v1_signed10:
673
17.3k
        case Immediate_kv3_v1_signed16:
674
17.5k
        case Immediate_kv3_v1_signed27:
675
17.9k
        case Immediate_kv3_v1_wrapped32:
676
19.4k
        case Immediate_kv3_v1_signed37:
677
19.4k
        case Immediate_kv3_v1_signed43:
678
19.5k
        case Immediate_kv3_v1_signed54:
679
19.5k
        case Immediate_kv3_v1_wrapped64:
680
26.9k
        case Immediate_kv3_v1_unsigned6:
681
26.9k
          res->operands[idx].val = value;
682
26.9k
          res->operands[idx].sign = flags & kvxSIGNED;
683
26.9k
          res->operands[idx].width = width;
684
26.9k
          res->operands[idx].type = CAT_IMMEDIATE;
685
26.9k
          res->operands[idx].pcrel = 0;
686
26.9k
          idx++;
687
26.9k
          break;
688
3.00k
        case Immediate_kv3_v1_pcrel17:
689
9.87k
        case Immediate_kv3_v1_pcrel27:
690
9.87k
          res->operands[idx].val = value + memaddr;
691
9.87k
          res->operands[idx].sign = flags & kvxSIGNED;
692
9.87k
          res->operands[idx].width = width;
693
9.87k
          res->operands[idx].type = CAT_IMMEDIATE;
694
9.87k
          res->operands[idx].pcrel = 1;
695
9.87k
          idx++;
696
9.87k
          break;
697
0
        case Modifier_kv3_v1_column:
698
2.68k
        case Modifier_kv3_v1_comparison:
699
3.02k
        case Modifier_kv3_v1_doscale:
700
3.02k
        case Modifier_kv3_v1_exunum:
701
3.58k
        case Modifier_kv3_v1_floatcomp:
702
3.74k
        case Modifier_kv3_v1_qindex:
703
4.11k
        case Modifier_kv3_v1_rectify:
704
7.76k
        case Modifier_kv3_v1_rounding:
705
8.34k
        case Modifier_kv3_v1_roundint:
706
8.73k
        case Modifier_kv3_v1_saturate:
707
16.9k
        case Modifier_kv3_v1_scalarcond:
708
20.6k
        case Modifier_kv3_v1_silent:
709
20.6k
        case Modifier_kv3_v1_simplecond:
710
21.3k
        case Modifier_kv3_v1_speculate:
711
21.4k
        case Modifier_kv3_v1_splat32:
712
27.9k
        case Modifier_kv3_v1_variant:
713
27.9k
          {
714
27.9k
      int sz = 0;
715
27.9k
      int mod_idx = type - Modifier_kv3_v1_column;
716
255k
      for (sz = 0; env.kvx_modifiers[mod_idx][sz]; ++sz);
717
27.9k
      const char *mod = value < (unsigned) sz
718
27.9k
        ? env.kvx_modifiers[mod_idx][value] : NULL;
719
27.9k
      if (!mod) goto retry;
720
26.6k
      res->operands[idx].val = value;
721
26.6k
      res->operands[idx].type = CAT_MODIFIER;
722
26.6k
      res->operands[idx].mod_idx = mod_idx;
723
26.6k
      idx++;
724
26.6k
          }
725
0
          break;
726
0
        default:
727
0
          fprintf (stderr, "error: unexpected operand type (%s)\n",
728
0
             type_name);
729
0
          exit (-1);
730
154k
        };
731
153k
    }
732
0
        else if (env.opc_table == kvx_kv3_v2_optab)
733
0
    {
734
0
      switch (type)
735
0
        {
736
0
        case RegClass_kv3_v2_singleReg:
737
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
738
0
          break;
739
0
        case RegClass_kv3_v2_pairedReg:
740
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
741
0
          break;
742
0
        case RegClass_kv3_v2_quadReg:
743
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
744
0
          break;
745
0
        case RegClass_kv3_v2_systemReg:
746
0
        case RegClass_kv3_v2_aloneReg:
747
0
        case RegClass_kv3_v2_onlyraReg:
748
0
        case RegClass_kv3_v2_onlygetReg:
749
0
        case RegClass_kv3_v2_onlysetReg:
750
0
        case RegClass_kv3_v2_onlyfxReg:
751
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
752
0
          break;
753
0
        case RegClass_kv3_v2_coproReg:
754
0
        case RegClass_kv3_v2_coproReg0M4:
755
0
        case RegClass_kv3_v2_coproReg1M4:
756
0
        case RegClass_kv3_v2_coproReg2M4:
757
0
        case RegClass_kv3_v2_coproReg3M4:
758
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
759
0
          break;
760
0
        case RegClass_kv3_v2_blockReg:
761
0
        case RegClass_kv3_v2_blockRegE:
762
0
        case RegClass_kv3_v2_blockRegO:
763
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
764
0
          break;
765
0
        case RegClass_kv3_v2_vectorReg:
766
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
767
0
          break;
768
0
        case RegClass_kv3_v2_tileReg:
769
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
770
0
          break;
771
0
        case RegClass_kv3_v2_matrixReg:
772
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
773
0
          break;
774
0
        case RegClass_kv3_v2_buffer2Reg:
775
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X2R, value)
776
0
          break;
777
0
        case RegClass_kv3_v2_buffer4Reg:
778
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X4R, value)
779
0
          break;
780
0
        case RegClass_kv3_v2_buffer8Reg:
781
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X8R, value)
782
0
          break;
783
0
        case RegClass_kv3_v2_buffer16Reg:
784
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X16R, value)
785
0
          break;
786
0
        case RegClass_kv3_v2_buffer32Reg:
787
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X32R, value)
788
0
          break;
789
0
        case RegClass_kv3_v2_buffer64Reg:
790
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X64R, value)
791
0
          break;
792
0
        case Immediate_kv3_v2_brknumber:
793
0
        case Immediate_kv3_v2_sysnumber:
794
0
        case Immediate_kv3_v2_signed10:
795
0
        case Immediate_kv3_v2_signed16:
796
0
        case Immediate_kv3_v2_signed27:
797
0
        case Immediate_kv3_v2_wrapped32:
798
0
        case Immediate_kv3_v2_signed37:
799
0
        case Immediate_kv3_v2_signed43:
800
0
        case Immediate_kv3_v2_signed54:
801
0
        case Immediate_kv3_v2_wrapped64:
802
0
        case Immediate_kv3_v2_unsigned6:
803
0
          res->operands[idx].val = value;
804
0
          res->operands[idx].sign = flags & kvxSIGNED;
805
0
          res->operands[idx].width = width;
806
0
          res->operands[idx].type = CAT_IMMEDIATE;
807
0
          res->operands[idx].pcrel = 0;
808
0
          idx++;
809
0
          break;
810
0
        case Immediate_kv3_v2_pcrel27:
811
0
        case Immediate_kv3_v2_pcrel17:
812
0
          res->operands[idx].val = value + memaddr;
813
0
          res->operands[idx].sign = flags & kvxSIGNED;
814
0
          res->operands[idx].width = width;
815
0
          res->operands[idx].type = CAT_IMMEDIATE;
816
0
          res->operands[idx].pcrel = 1;
817
0
          idx++;
818
0
          break;
819
0
        case Modifier_kv3_v2_accesses:
820
0
        case Modifier_kv3_v2_boolcas:
821
0
        case Modifier_kv3_v2_cachelev:
822
0
        case Modifier_kv3_v2_channel:
823
0
        case Modifier_kv3_v2_coherency:
824
0
        case Modifier_kv3_v2_comparison:
825
0
        case Modifier_kv3_v2_conjugate:
826
0
        case Modifier_kv3_v2_doscale:
827
0
        case Modifier_kv3_v2_exunum:
828
0
        case Modifier_kv3_v2_floatcomp:
829
0
        case Modifier_kv3_v2_hindex:
830
0
        case Modifier_kv3_v2_lsomask:
831
0
        case Modifier_kv3_v2_lsumask:
832
0
        case Modifier_kv3_v2_lsupack:
833
0
        case Modifier_kv3_v2_qindex:
834
0
        case Modifier_kv3_v2_rounding:
835
0
        case Modifier_kv3_v2_scalarcond:
836
0
        case Modifier_kv3_v2_shuffleV:
837
0
        case Modifier_kv3_v2_shuffleX:
838
0
        case Modifier_kv3_v2_silent:
839
0
        case Modifier_kv3_v2_simplecond:
840
0
        case Modifier_kv3_v2_speculate:
841
0
        case Modifier_kv3_v2_splat32:
842
0
        case Modifier_kv3_v2_transpose:
843
0
        case Modifier_kv3_v2_variant:
844
0
          {
845
0
      int sz = 0;
846
0
      int mod_idx = type - Modifier_kv3_v2_accesses;
847
0
      for (sz = 0; env.kvx_modifiers[mod_idx][sz];
848
0
           ++sz);
849
0
      const char *mod = value < (unsigned) sz
850
0
        ? env.kvx_modifiers[mod_idx][value] : NULL;
851
0
      if (!mod) goto retry;
852
0
      res->operands[idx].val = value;
853
0
      res->operands[idx].type = CAT_MODIFIER;
854
0
      res->operands[idx].mod_idx = mod_idx;
855
0
      idx++;
856
0
          };
857
0
          break;
858
0
        default:
859
0
          fprintf (stderr,
860
0
             "error: unexpected operand type (%s)\n",
861
0
             type_name);
862
0
          exit (-1);
863
0
        };
864
0
    }
865
0
        else if (env.opc_table == kvx_kv4_v1_optab)
866
0
    {
867
0
      switch (type)
868
0
        {
869
870
0
        case RegClass_kv4_v1_singleReg:
871
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_GPR, value)
872
0
          break;
873
0
        case RegClass_kv4_v1_pairedReg:
874
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_PGR, value)
875
0
          break;
876
0
        case RegClass_kv4_v1_quadReg:
877
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_QGR, value)
878
0
          break;
879
0
        case RegClass_kv4_v1_systemReg:
880
0
        case RegClass_kv4_v1_aloneReg:
881
0
        case RegClass_kv4_v1_onlyraReg:
882
0
        case RegClass_kv4_v1_onlygetReg:
883
0
        case RegClass_kv4_v1_onlysetReg:
884
0
        case RegClass_kv4_v1_onlyfxReg:
885
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_SFR, value)
886
0
          break;
887
0
        case RegClass_kv4_v1_coproReg:
888
0
        case RegClass_kv4_v1_coproReg0M4:
889
0
        case RegClass_kv4_v1_coproReg1M4:
890
0
        case RegClass_kv4_v1_coproReg2M4:
891
0
        case RegClass_kv4_v1_coproReg3M4:
892
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XCR, value)
893
0
          break;
894
0
        case RegClass_kv4_v1_blockReg:
895
0
        case RegClass_kv4_v1_blockRegE:
896
0
        case RegClass_kv4_v1_blockRegO:
897
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XBR, value)
898
0
          break;
899
0
        case RegClass_kv4_v1_vectorReg:
900
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XVR, value)
901
0
          break;
902
0
        case RegClass_kv4_v1_tileReg:
903
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XTR, value)
904
0
          break;
905
0
        case RegClass_kv4_v1_matrixReg:
906
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_XMR, value)
907
0
          break;
908
0
        case RegClass_kv4_v1_buffer2Reg:
909
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X2R, value)
910
0
          break;
911
0
        case RegClass_kv4_v1_buffer4Reg:
912
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X4R, value)
913
0
          break;
914
0
        case RegClass_kv4_v1_buffer8Reg:
915
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X8R, value)
916
0
          break;
917
0
        case RegClass_kv4_v1_buffer16Reg:
918
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X16R, value)
919
0
          break;
920
0
        case RegClass_kv4_v1_buffer32Reg:
921
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X32R, value)
922
0
          break;
923
0
        case RegClass_kv4_v1_buffer64Reg:
924
0
          KVX_PRINT_REG (KVX_REGFILE_DEC_X64R, value)
925
0
          break;
926
0
        case Immediate_kv4_v1_brknumber:
927
0
        case Immediate_kv4_v1_sysnumber:
928
0
        case Immediate_kv4_v1_signed10:
929
0
        case Immediate_kv4_v1_signed16:
930
0
        case Immediate_kv4_v1_signed27:
931
0
        case Immediate_kv4_v1_wrapped32:
932
0
        case Immediate_kv4_v1_signed37:
933
0
        case Immediate_kv4_v1_signed43:
934
0
        case Immediate_kv4_v1_signed54:
935
0
        case Immediate_kv4_v1_wrapped64:
936
0
        case Immediate_kv4_v1_unsigned6:
937
0
          res->operands[idx].val = value;
938
0
          res->operands[idx].sign = flags & kvxSIGNED;
939
0
          res->operands[idx].width = width;
940
0
          res->operands[idx].type = CAT_IMMEDIATE;
941
0
          res->operands[idx].pcrel = 0;
942
0
          idx++;
943
0
          break;
944
0
        case Immediate_kv4_v1_pcrel27:
945
0
        case Immediate_kv4_v1_pcrel17:
946
0
          res->operands[idx].val = value + memaddr;
947
0
          res->operands[idx].sign = flags & kvxSIGNED;
948
0
          res->operands[idx].width = width;
949
0
          res->operands[idx].type = CAT_IMMEDIATE;
950
0
          res->operands[idx].pcrel = 1;
951
0
          idx++;
952
0
          break;
953
0
        case Modifier_kv4_v1_accesses:
954
0
        case Modifier_kv4_v1_boolcas:
955
0
        case Modifier_kv4_v1_cachelev:
956
0
        case Modifier_kv4_v1_channel:
957
0
        case Modifier_kv4_v1_coherency:
958
0
        case Modifier_kv4_v1_comparison:
959
0
        case Modifier_kv4_v1_conjugate:
960
0
        case Modifier_kv4_v1_doscale:
961
0
        case Modifier_kv4_v1_exunum:
962
0
        case Modifier_kv4_v1_floatcomp:
963
0
        case Modifier_kv4_v1_hindex:
964
0
        case Modifier_kv4_v1_lsomask:
965
0
        case Modifier_kv4_v1_lsumask:
966
0
        case Modifier_kv4_v1_lsupack:
967
0
        case Modifier_kv4_v1_qindex:
968
0
        case Modifier_kv4_v1_rounding:
969
0
        case Modifier_kv4_v1_scalarcond:
970
0
        case Modifier_kv4_v1_shuffleV:
971
0
        case Modifier_kv4_v1_shuffleX:
972
0
        case Modifier_kv4_v1_silent:
973
0
        case Modifier_kv4_v1_simplecond:
974
0
        case Modifier_kv4_v1_speculate:
975
0
        case Modifier_kv4_v1_splat32:
976
0
        case Modifier_kv4_v1_transpose:
977
0
        case Modifier_kv4_v1_variant:
978
0
          {
979
0
      int sz = 0;
980
0
      int mod_idx = type - Modifier_kv4_v1_accesses;
981
0
      for (sz = 0; env.kvx_modifiers[mod_idx][sz]; ++sz);
982
0
      const char *mod = value < (unsigned) sz
983
0
        ? env.kvx_modifiers[mod_idx][value] : NULL;
984
0
      if (!mod) goto retry;
985
0
      res->operands[idx].val = value;
986
0
      res->operands[idx].type = CAT_MODIFIER;
987
0
      res->operands[idx].mod_idx = mod_idx;
988
0
      idx++;
989
0
          }
990
0
          break;
991
0
        default:
992
0
          fprintf (stderr, "error: unexpected operand type (%s)\n",
993
0
             type_name);
994
0
          exit (-1);
995
0
        };
996
0
    }
997
998
154k
#undef KVX_PRINT_REG
999
154k
      }
1000
1001
53.8k
    found = 1;
1002
53.8k
    break;
1003
1.26k
  retry:;
1004
1.26k
    idx = 0;
1005
1.26k
    continue;
1006
55.1k
  }
1007
26.4M
 }
1008
71.8k
  res->nb_ops = idx;
1009
71.8k
  return found;
1010
71.8k
}
1011
1012
int
1013
print_insn_kvx (bfd_vma memaddr, struct disassemble_info *info)
1014
87.4k
{
1015
87.4k
  static int insnindex = 0;
1016
87.4k
  static int insncount = 0;
1017
87.4k
  insn_t *insn;
1018
87.4k
  int readsofar = 0;
1019
87.4k
  int found = 0;
1020
87.4k
  int invalid_bundle = 0;
1021
1022
87.4k
  if (!env.initialized_p)
1023
1
    kvx_dis_init (info);
1024
1025
  /* Clear instruction information field.  */
1026
87.4k
  info->insn_info_valid = 0;
1027
87.4k
  info->branch_delay_insns = 0;
1028
87.4k
  info->data_size = 0;
1029
87.4k
  info->insn_type = dis_noninsn;
1030
87.4k
  info->target = 0;
1031
87.4k
  info->target2 = 0;
1032
1033
  /* Set line length.  */
1034
87.4k
  info->bytes_per_line = 16;
1035
1036
1037
  /* If this is the beginning of the bundle, read BUNDLESIZE words and apply
1038
     decentrifugate function.  */
1039
87.4k
  if (insnindex == 0)
1040
75.2k
    {
1041
75.2k
      int wordcount = 0;
1042
75.2k
      do
1043
176k
  {
1044
176k
    int status;
1045
176k
    assert (wordcount < KVXMAXBUNDLEWORDS);
1046
176k
    status =
1047
176k
      (*info->read_memory_func) (memaddr + 4 * wordcount,
1048
176k
               (bfd_byte *) (bundle_words +
1049
176k
                 wordcount), 4, info);
1050
176k
    if (status != 0)
1051
115
      {
1052
115
        (*info->memory_error_func) (status, memaddr + 4 * wordcount,
1053
115
            info);
1054
115
        return -1;
1055
115
      }
1056
176k
    wordcount++;
1057
176k
  }
1058
176k
      while (kvx_has_parallel_bit (bundle_words[wordcount - 1])
1059
176k
       && wordcount < KVXMAXBUNDLEWORDS - 1);
1060
75.1k
      invalid_bundle = kvx_reassemble_bundle (wordcount, &insncount);
1061
75.1k
    }
1062
1063
87.3k
  assert (insnindex < KVXMAXBUNDLEISSUE);
1064
87.3k
  insn = &(bundle_insn[insnindex]);
1065
87.3k
  readsofar = insn->len * 4;
1066
87.3k
  insnindex++;
1067
1068
87.3k
  if (opt_pretty)
1069
0
    {
1070
0
      (*info->fprintf_func) (info->stream, "[ ");
1071
0
      for (int i = 0; i < insn->len; i++)
1072
0
  (*info->fprintf_func) (info->stream, "%08x ", insn->syllables[i]);
1073
0
      (*info->fprintf_func) (info->stream, "] ");
1074
0
    }
1075
1076
  /* Check for extension to right iff this is not the end of bundle.  */
1077
1078
87.3k
  struct decoded_insn dec;
1079
87.3k
  memset (&dec, 0, sizeof dec);
1080
87.3k
  if (!invalid_bundle && (found = decode_insn (memaddr, insn, &dec)))
1081
53.8k
    {
1082
53.8k
      int ch;
1083
53.8k
      (*info->fprintf_func) (info->stream, "%s", dec.opc->as_op);
1084
53.8k
      const char *fmtp = dec.opc->fmtstring;
1085
207k
      for (int i = 0; i < dec.nb_ops; ++i)
1086
153k
  {
1087
    /* Print characters in the format string up to the following % or nul.  */
1088
395k
    while ((ch = *fmtp) && ch != '%')
1089
242k
      {
1090
242k
        (*info->fprintf_func) (info->stream, "%c", ch);
1091
242k
        fmtp++;
1092
242k
      }
1093
1094
    /* Skip past %s.  */
1095
153k
    if (ch == '%')
1096
153k
      {
1097
153k
        ch = *fmtp++;
1098
153k
        fmtp++;
1099
153k
      }
1100
1101
153k
    switch (dec.operands[i].type)
1102
153k
      {
1103
90.0k
      case CAT_REGISTER:
1104
90.0k
        (*info->fprintf_func) (info->stream, "%s",
1105
90.0k
             env.kvx_registers[dec.operands[i].val].name);
1106
90.0k
        break;
1107
26.6k
      case CAT_MODIFIER:
1108
26.6k
        {
1109
26.6k
    const char *mod = env.kvx_modifiers[dec.operands[i].mod_idx][dec.operands[i].val];
1110
26.6k
    (*info->fprintf_func) (info->stream, "%s", !mod || !strcmp (mod, ".") ? "" : mod);
1111
26.6k
        }
1112
26.6k
        break;
1113
36.8k
      case CAT_IMMEDIATE:
1114
36.8k
        {
1115
36.8k
    if (dec.operands[i].pcrel)
1116
9.87k
      {
1117
        /* Fill in instruction information.  */
1118
9.87k
        info->insn_info_valid = 1;
1119
9.87k
        info->insn_type =
1120
9.87k
          dec.operands[i].width ==
1121
9.87k
          17 ? dis_condbranch : dis_branch;
1122
9.87k
        info->target = dec.operands[i].val;
1123
1124
9.87k
        info->print_address_func (dec.operands[i].val, info);
1125
9.87k
      }
1126
26.9k
    else if (dec.operands[i].sign)
1127
19.1k
      {
1128
19.1k
        if (dec.operands[i].width <= 32)
1129
17.5k
          {
1130
17.5k
      (*info->fprintf_func) (info->stream, "%" PRId32 " (0x%" PRIx32 ")",
1131
17.5k
                 (int32_t) dec.operands[i].val,
1132
17.5k
                 (int32_t) dec.operands[i].val);
1133
17.5k
          }
1134
1.59k
        else
1135
1.59k
          {
1136
1.59k
      (*info->fprintf_func) (info->stream, "%" PRId64 " (0x%" PRIx64 ")",
1137
1.59k
                 dec.operands[i].val,
1138
1.59k
                 dec.operands[i].val);
1139
1.59k
          }
1140
19.1k
      }
1141
7.82k
    else
1142
7.82k
      {
1143
7.82k
        if (dec.operands[i].width <= 32)
1144
7.78k
          {
1145
7.78k
      (*info->fprintf_func) (info->stream, "%" PRIu32 " (0x%" PRIx32 ")",
1146
7.78k
                 (uint32_t) dec.operands[i].
1147
7.78k
                 val,
1148
7.78k
                 (uint32_t) dec.operands[i].
1149
7.78k
                 val);
1150
7.78k
          }
1151
41
        else
1152
41
          {
1153
41
      (*info->fprintf_func) (info->stream, "%" PRIu64 " (0x%" PRIx64 ")",
1154
41
                 (uint64_t) dec.
1155
41
                 operands[i].val,
1156
41
                 (uint64_t) dec.
1157
41
                 operands[i].val);
1158
41
          }
1159
7.82k
      }
1160
36.8k
        }
1161
36.8k
        break;
1162
0
      default:
1163
0
        break;
1164
1165
153k
      }
1166
153k
  }
1167
1168
61.0k
      while ((ch = *fmtp))
1169
7.22k
  {
1170
7.22k
    (*info->fprintf_styled_func) (info->stream, dis_style_text, "%c",
1171
7.22k
          ch);
1172
7.22k
    fmtp++;
1173
7.22k
  }
1174
53.8k
    }
1175
33.4k
  else
1176
33.4k
    {
1177
33.4k
      (*info->fprintf_func) (info->stream, "*** invalid opcode ***\n");
1178
33.4k
      insnindex = 0;
1179
33.4k
      readsofar = 4;
1180
33.4k
    }
1181
1182
87.3k
  if (found && (insnindex == insncount))
1183
41.6k
    {
1184
41.6k
      (*info->fprintf_func) (info->stream, ";;");
1185
41.6k
      if (!opt_compact_assembly)
1186
41.6k
  (*info->fprintf_func) (info->stream, "\n");
1187
41.6k
      insnindex = 0;
1188
41.6k
    }
1189
1190
87.3k
  return readsofar;
1191
87.3k
}
1192
1193
/* This function searches in the current bundle for the instructions required
1194
   by unwinding. For prologue:
1195
     (1) addd $r12 = $r12, <res_stack>
1196
     (2) get <gpr_ra_reg> = $ra
1197
     (3) sd <ofs>[$r12] = <gpr_ra_reg> or sq/so containing <gpr_ra_reg>
1198
     (4) sd <ofs>[$r12] = $r14 or sq/so containing r14
1199
     (5) addd $r14 = $r12, <fp_ofs> or copyd $r14 = $r12
1200
   The only difference seen between the code generated by gcc and clang
1201
   is the setting/resetting r14. gcc could also generate copyd $r14=$r12
1202
   instead of add addd $r14 = $r12, <ofs> when <ofs> is 0.
1203
   Vice-versa, <ofs> is not guaranteed to be 0 for clang, so, clang
1204
   could also generate addd instead of copyd
1205
     (6) call, icall, goto, igoto, cb., ret
1206
  For epilogue:
1207
     (1) addd $r12 = $r12, <res_stack>
1208
     (2) addd $r12 = $r14, <offset> or copyd $r12 = $r14
1209
   Same comment as prologue (5).
1210
     (3) ret, goto
1211
     (4) call, icall, igoto, cb.  */
1212
1213
int
1214
decode_prologue_epilogue_bundle (bfd_vma memaddr,
1215
         struct disassemble_info *info,
1216
         struct kvx_prologue_epilogue_bundle *peb)
1217
0
{
1218
0
  int i, nb_insn, nb_syl;
1219
1220
0
  peb->nb_insn = 0;
1221
1222
0
  if (info->arch != bfd_arch_kvx)
1223
0
    return -1;
1224
1225
0
  if (!env.initialized_p)
1226
0
    kvx_dis_init (info);
1227
1228
  /* Read the bundle.  */
1229
0
  nb_syl = 0;
1230
0
  do
1231
0
    {
1232
0
      if (nb_syl >= KVXMAXBUNDLEWORDS)
1233
0
  return -1;
1234
0
      if ((*info->read_memory_func) (memaddr + 4 * nb_syl,
1235
0
             (bfd_byte *) &bundle_words[nb_syl], 4,
1236
0
             info))
1237
0
  return -1;
1238
0
      nb_syl++;
1239
0
    }
1240
0
  while (kvx_has_parallel_bit (bundle_words[nb_syl - 1])
1241
0
   && nb_syl < KVXMAXBUNDLEWORDS - 1);
1242
0
  if (kvx_reassemble_bundle (nb_syl, &nb_insn))
1243
0
    return -1;
1244
1245
  /* Check for extension to right if this is not the end of bundle
1246
     find the format of this insn.  */
1247
0
  for (int idx_insn = 0; idx_insn < nb_insn; idx_insn++)
1248
0
    {
1249
0
      insn_t *insn = &bundle_insn[idx_insn];
1250
0
      int is_add = 0, is_get = 0, is_a_peb_insn = 0, is_copyd = 0;
1251
1252
0
      struct decoded_insn dec;
1253
0
      memset (&dec, 0, sizeof dec);
1254
0
      if (!decode_insn (memaddr, insn, &dec))
1255
0
  continue;
1256
1257
0
      const char *op_name = dec.opc->as_op;
1258
0
      struct kvx_prologue_epilogue_insn *crt_peb_insn;
1259
1260
0
      crt_peb_insn = &peb->insn[peb->nb_insn];
1261
0
      crt_peb_insn->nb_gprs = 0;
1262
1263
0
      if (!strcmp (op_name, "addd"))
1264
0
  is_add = 1;
1265
0
      else if (!strcmp (op_name, "copyd"))
1266
0
  is_copyd = 1;
1267
0
      else if (!strcmp (op_name, "get"))
1268
0
  is_get = 1;
1269
0
      else if (!strcmp (op_name, "sd"))
1270
0
  {
1271
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SD;
1272
0
    is_a_peb_insn = 1;
1273
0
  }
1274
0
      else if (!strcmp (op_name, "sq"))
1275
0
  {
1276
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SQ;
1277
0
    is_a_peb_insn = 1;
1278
0
  }
1279
0
      else if (!strcmp (op_name, "so"))
1280
0
  {
1281
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_SO;
1282
0
    is_a_peb_insn = 1;
1283
0
  }
1284
0
      else if (!strcmp (op_name, "ret"))
1285
0
  {
1286
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_RET;
1287
0
    is_a_peb_insn = 1;
1288
0
  }
1289
0
      else if (!strcmp (op_name, "goto"))
1290
0
  {
1291
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_GOTO;
1292
0
    is_a_peb_insn = 1;
1293
0
  }
1294
0
      else if (!strcmp (op_name, "igoto"))
1295
0
  {
1296
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_IGOTO;
1297
0
    is_a_peb_insn = 1;
1298
0
  }
1299
0
      else if (!strcmp (op_name, "call") || !strcmp (op_name, "icall"))
1300
0
  {
1301
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_CALL;
1302
0
    is_a_peb_insn = 1;
1303
0
  }
1304
0
      else if (!strncmp (op_name, "cb", 2))
1305
0
  {
1306
0
    crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_CB;
1307
0
    is_a_peb_insn = 1;
1308
0
  }
1309
0
      else
1310
0
  continue;
1311
1312
0
      for (i = 0; dec.opc->format[i]; i++)
1313
0
  {
1314
0
    struct kvx_operand *fmt = dec.opc->format[i];
1315
0
    struct kvx_bitfield *bf = fmt->bfield;
1316
0
    int bf_nb = fmt->bitfields;
1317
0
    int width = fmt->width;
1318
0
    int type = fmt->type;
1319
0
    int flags = fmt->flags;
1320
0
    int shift = fmt->shift;
1321
0
    int bias = fmt->bias;
1322
0
    uint64_t encoded_value, value = 0;
1323
1324
0
    for (int bf_idx = 0; bf_idx < bf_nb; bf_idx++)
1325
0
      {
1326
0
        int insn_idx = (int) bf[bf_idx].to_offset / 32;
1327
0
        int to_offset = bf[bf_idx].to_offset % 32;
1328
0
        encoded_value = insn->syllables[insn_idx] >> to_offset;
1329
0
        encoded_value &= (1LL << bf[bf_idx].size) - 1;
1330
0
        value |= encoded_value << bf[bf_idx].from_offset;
1331
0
      }
1332
0
    if (flags & kvxSIGNED)
1333
0
      {
1334
0
        uint64_t signbit = 1LL << (width - 1);
1335
0
        value = (value ^ signbit) - signbit;
1336
0
      }
1337
0
    value = (value << shift) + bias;
1338
1339
0
#define chk_type(core_, val_) \
1340
0
      (env.opc_table == kvx_## core_ ##_optab && type == (val_))
1341
1342
0
    if (chk_type (kv3_v1, RegClass_kv3_v1_singleReg)
1343
0
        || chk_type (kv3_v2, RegClass_kv3_v2_singleReg)
1344
0
        || chk_type (kv4_v1, RegClass_kv4_v1_singleReg))
1345
0
      {
1346
0
        if (env.kvx_regfiles[KVX_REGFILE_DEC_GPR] + value
1347
0
      >= env.kvx_max_dec_registers)
1348
0
    return -1;
1349
0
        if (is_add && i < 2)
1350
0
    {
1351
0
      if (i == 0)
1352
0
        {
1353
0
          if (value == KVX_GPR_REG_SP)
1354
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_SP;
1355
0
          else if (value == KVX_GPR_REG_FP)
1356
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_FP;
1357
0
          else
1358
0
      is_add = 0;
1359
0
        }
1360
0
      else if (i == 1)
1361
0
        {
1362
0
          if (value == KVX_GPR_REG_SP)
1363
0
      is_a_peb_insn = 1;
1364
0
          else if (value == KVX_GPR_REG_FP
1365
0
             && crt_peb_insn->insn_type
1366
0
             == KVX_PROL_EPIL_INSN_ADD_SP)
1367
0
      {
1368
0
        crt_peb_insn->insn_type
1369
0
          = KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP;
1370
0
        is_a_peb_insn = 1;
1371
0
      }
1372
0
          else
1373
0
      is_add = 0;
1374
0
        }
1375
0
    }
1376
0
        else if (is_copyd && i < 2)
1377
0
    {
1378
0
      if (i == 0)
1379
0
        {
1380
0
          if (value == KVX_GPR_REG_FP)
1381
0
      {
1382
0
        crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_ADD_FP;
1383
0
        crt_peb_insn->immediate = 0;
1384
0
      }
1385
0
          else if (value == KVX_GPR_REG_SP)
1386
0
      {
1387
0
        crt_peb_insn->insn_type
1388
0
          = KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP;
1389
0
        crt_peb_insn->immediate = 0;
1390
0
      }
1391
0
          else
1392
0
      is_copyd = 0;
1393
0
        }
1394
0
      else if (i == 1)
1395
0
        {
1396
0
          if (value == KVX_GPR_REG_SP
1397
0
        && crt_peb_insn->insn_type
1398
0
        == KVX_PROL_EPIL_INSN_ADD_FP)
1399
0
      is_a_peb_insn = 1;
1400
0
          else if (value == KVX_GPR_REG_FP
1401
0
             && crt_peb_insn->insn_type
1402
0
             == KVX_PROL_EPIL_INSN_RESTORE_SP_FROM_FP)
1403
0
      is_a_peb_insn = 1;
1404
0
          else
1405
0
      is_copyd = 0;
1406
0
        }
1407
0
    }
1408
0
        else
1409
0
    crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value;
1410
0
      }
1411
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_pairedReg)
1412
0
       || chk_type (kv3_v2, RegClass_kv3_v2_pairedReg)
1413
0
       || chk_type (kv4_v1, RegClass_kv4_v1_pairedReg))
1414
0
      crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value * 2;
1415
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_quadReg)
1416
0
       || chk_type (kv3_v2, RegClass_kv3_v2_quadReg)
1417
0
       || chk_type (kv4_v1, RegClass_kv4_v1_quadReg))
1418
0
      crt_peb_insn->gpr_reg[crt_peb_insn->nb_gprs++] = value * 4;
1419
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_systemReg)
1420
0
       || chk_type (kv3_v2, RegClass_kv3_v2_systemReg)
1421
0
       || chk_type (kv4_v1, RegClass_kv4_v1_systemReg)
1422
0
       || chk_type (kv3_v1, RegClass_kv3_v1_aloneReg)
1423
0
       || chk_type (kv3_v2, RegClass_kv3_v2_aloneReg)
1424
0
       || chk_type (kv4_v1, RegClass_kv4_v1_aloneReg)
1425
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlyraReg)
1426
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlyraReg)
1427
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlygetReg)
1428
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlygetReg)
1429
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlygetReg)
1430
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlygetReg)
1431
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlysetReg)
1432
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlysetReg)
1433
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlysetReg)
1434
0
       || chk_type (kv3_v1, RegClass_kv3_v1_onlyfxReg)
1435
0
       || chk_type (kv3_v2, RegClass_kv3_v2_onlyfxReg)
1436
0
       || chk_type (kv4_v1, RegClass_kv4_v1_onlyfxReg))
1437
0
      {
1438
0
        if (env.kvx_regfiles[KVX_REGFILE_DEC_GPR] + value
1439
0
      >= env.kvx_max_dec_registers)
1440
0
    return -1;
1441
0
        if (is_get && !strcmp (env.kvx_registers[env.kvx_dec_registers[env.kvx_regfiles[KVX_REGFILE_DEC_SFR] + value]].name, "$ra"))
1442
0
    {
1443
0
      crt_peb_insn->insn_type = KVX_PROL_EPIL_INSN_GET_RA;
1444
0
      is_a_peb_insn = 1;
1445
0
    }
1446
0
      }
1447
0
    else if (chk_type (kv3_v1, RegClass_kv3_v1_coproReg)
1448
0
       || chk_type (kv3_v2, RegClass_kv3_v2_coproReg)
1449
0
       || chk_type (kv4_v1, RegClass_kv4_v1_coproReg)
1450
0
       || chk_type (kv3_v1, RegClass_kv3_v1_blockReg)
1451
0
       || chk_type (kv3_v2, RegClass_kv3_v2_blockReg)
1452
0
       || chk_type (kv4_v1, RegClass_kv4_v1_blockReg)
1453
0
       || chk_type (kv3_v1, RegClass_kv3_v1_vectorReg)
1454
0
       || chk_type (kv3_v2, RegClass_kv3_v2_vectorReg)
1455
0
       || chk_type (kv4_v1, RegClass_kv4_v1_vectorReg)
1456
0
       || chk_type (kv3_v1, RegClass_kv3_v1_tileReg)
1457
0
       || chk_type (kv3_v2, RegClass_kv3_v2_tileReg)
1458
0
       || chk_type (kv4_v1, RegClass_kv4_v1_tileReg)
1459
0
       || chk_type (kv3_v1, RegClass_kv3_v1_matrixReg)
1460
0
       || chk_type (kv3_v2, RegClass_kv3_v2_matrixReg)
1461
0
       || chk_type (kv4_v1, RegClass_kv4_v1_matrixReg)
1462
0
       || chk_type (kv3_v1, Modifier_kv3_v1_scalarcond)
1463
0
       || chk_type (kv3_v1, Modifier_kv3_v1_column)
1464
0
       || chk_type (kv3_v1, Modifier_kv3_v1_comparison)
1465
0
       || chk_type (kv3_v1, Modifier_kv3_v1_doscale)
1466
0
       || chk_type (kv3_v1, Modifier_kv3_v1_exunum)
1467
0
       || chk_type (kv3_v1, Modifier_kv3_v1_floatcomp)
1468
0
       || chk_type (kv3_v1, Modifier_kv3_v1_qindex)
1469
0
       || chk_type (kv3_v1, Modifier_kv3_v1_rectify)
1470
0
       || chk_type (kv3_v1, Modifier_kv3_v1_rounding)
1471
0
       || chk_type (kv3_v1, Modifier_kv3_v1_roundint)
1472
0
       || chk_type (kv3_v1, Modifier_kv3_v1_saturate)
1473
0
       || chk_type (kv3_v1, Modifier_kv3_v1_scalarcond)
1474
0
       || chk_type (kv3_v1, Modifier_kv3_v1_silent)
1475
0
       || chk_type (kv3_v1, Modifier_kv3_v1_simplecond)
1476
0
       || chk_type (kv3_v1, Modifier_kv3_v1_speculate)
1477
0
       || chk_type (kv3_v1, Modifier_kv3_v1_splat32)
1478
0
       || chk_type (kv3_v1, Modifier_kv3_v1_variant)
1479
0
       || chk_type (kv3_v2, Modifier_kv3_v2_accesses)
1480
0
       || chk_type (kv3_v2, Modifier_kv3_v2_boolcas)
1481
0
       || chk_type (kv3_v2, Modifier_kv3_v2_cachelev)
1482
0
       || chk_type (kv3_v2, Modifier_kv3_v2_channel)
1483
0
       || chk_type (kv3_v2, Modifier_kv3_v2_coherency)
1484
0
       || chk_type (kv3_v2, Modifier_kv3_v2_comparison)
1485
0
       || chk_type (kv3_v2, Modifier_kv3_v2_conjugate)
1486
0
       || chk_type (kv3_v2, Modifier_kv3_v2_doscale)
1487
0
       || chk_type (kv3_v2, Modifier_kv3_v2_exunum)
1488
0
       || chk_type (kv3_v2, Modifier_kv3_v2_floatcomp)
1489
0
       || chk_type (kv3_v2, Modifier_kv3_v2_hindex)
1490
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsomask)
1491
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsumask)
1492
0
       || chk_type (kv3_v2, Modifier_kv3_v2_lsupack)
1493
0
       || chk_type (kv3_v2, Modifier_kv3_v2_qindex)
1494
0
       || chk_type (kv3_v2, Modifier_kv3_v2_rounding)
1495
0
       || chk_type (kv3_v2, Modifier_kv3_v2_scalarcond)
1496
0
       || chk_type (kv3_v2, Modifier_kv3_v2_shuffleV)
1497
0
       || chk_type (kv3_v2, Modifier_kv3_v2_shuffleX)
1498
0
       || chk_type (kv3_v2, Modifier_kv3_v2_silent)
1499
0
       || chk_type (kv3_v2, Modifier_kv3_v2_simplecond)
1500
0
       || chk_type (kv3_v2, Modifier_kv3_v2_speculate)
1501
0
       || chk_type (kv3_v2, Modifier_kv3_v2_splat32)
1502
0
       || chk_type (kv3_v2, Modifier_kv3_v2_transpose)
1503
0
       || chk_type (kv3_v2, Modifier_kv3_v2_variant)
1504
0
       || chk_type (kv4_v1, Modifier_kv4_v1_accesses)
1505
0
       || chk_type (kv4_v1, Modifier_kv4_v1_boolcas)
1506
0
       || chk_type (kv4_v1, Modifier_kv4_v1_cachelev)
1507
0
       || chk_type (kv4_v1, Modifier_kv4_v1_channel)
1508
0
       || chk_type (kv4_v1, Modifier_kv4_v1_coherency)
1509
0
       || chk_type (kv4_v1, Modifier_kv4_v1_comparison)
1510
0
       || chk_type (kv4_v1, Modifier_kv4_v1_conjugate)
1511
0
       || chk_type (kv4_v1, Modifier_kv4_v1_doscale)
1512
0
       || chk_type (kv4_v1, Modifier_kv4_v1_exunum)
1513
0
       || chk_type (kv4_v1, Modifier_kv4_v1_floatcomp)
1514
0
       || chk_type (kv4_v1, Modifier_kv4_v1_hindex)
1515
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsomask)
1516
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsumask)
1517
0
       || chk_type (kv4_v1, Modifier_kv4_v1_lsupack)
1518
0
       || chk_type (kv4_v1, Modifier_kv4_v1_qindex)
1519
0
       || chk_type (kv4_v1, Modifier_kv4_v1_rounding)
1520
0
       || chk_type (kv4_v1, Modifier_kv4_v1_scalarcond)
1521
0
       || chk_type (kv4_v1, Modifier_kv4_v1_shuffleV)
1522
0
       || chk_type (kv4_v1, Modifier_kv4_v1_shuffleX)
1523
0
       || chk_type (kv4_v1, Modifier_kv4_v1_silent)
1524
0
       || chk_type (kv4_v1, Modifier_kv4_v1_simplecond)
1525
0
       || chk_type (kv4_v1, Modifier_kv4_v1_speculate)
1526
0
       || chk_type (kv4_v1, Modifier_kv4_v1_splat32)
1527
0
       || chk_type (kv4_v1, Modifier_kv4_v1_transpose)
1528
0
       || chk_type (kv4_v1, Modifier_kv4_v1_variant))
1529
0
      {
1530
        /* Do nothing.  */
1531
0
      }
1532
0
    else if (chk_type (kv3_v1, Immediate_kv3_v1_sysnumber)
1533
0
       || chk_type (kv3_v2, Immediate_kv3_v2_sysnumber)
1534
0
       || chk_type (kv4_v1, Immediate_kv4_v1_sysnumber)
1535
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped8)
1536
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped8)
1537
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed10)
1538
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed10)
1539
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed10)
1540
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed16)
1541
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed16)
1542
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed16)
1543
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed27)
1544
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed27)
1545
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed27)
1546
0
       || chk_type (kv3_v1, Immediate_kv3_v1_wrapped32)
1547
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped32)
1548
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped32)
1549
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed37)
1550
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed37)
1551
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed37)
1552
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed43)
1553
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed43)
1554
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed43)
1555
0
       || chk_type (kv3_v1, Immediate_kv3_v1_signed54)
1556
0
       || chk_type (kv3_v2, Immediate_kv3_v2_signed54)
1557
0
       || chk_type (kv4_v1, Immediate_kv4_v1_signed54)
1558
0
       || chk_type (kv3_v1, Immediate_kv3_v1_wrapped64)
1559
0
       || chk_type (kv3_v2, Immediate_kv3_v2_wrapped64)
1560
0
       || chk_type (kv4_v1, Immediate_kv4_v1_wrapped64)
1561
0
       || chk_type (kv3_v1, Immediate_kv3_v1_unsigned6)
1562
0
       || chk_type (kv3_v2, Immediate_kv3_v2_unsigned6)
1563
0
       || chk_type (kv4_v1, Immediate_kv4_v1_unsigned6))
1564
0
      crt_peb_insn->immediate = value;
1565
0
    else if (chk_type (kv3_v1, Immediate_kv3_v1_pcrel17)
1566
0
       || chk_type (kv3_v2, Immediate_kv3_v2_pcrel17)
1567
0
       || chk_type (kv4_v1, Immediate_kv4_v1_pcrel17)
1568
0
       || chk_type (kv3_v1, Immediate_kv3_v1_pcrel27)
1569
0
       || chk_type (kv3_v2, Immediate_kv3_v2_pcrel27)
1570
0
       || chk_type (kv4_v1, Immediate_kv4_v1_pcrel27))
1571
0
      crt_peb_insn->immediate = value + memaddr;
1572
0
    else
1573
0
      return -1;
1574
0
  }
1575
1576
0
      if (is_a_peb_insn)
1577
0
  peb->nb_insn++;
1578
0
      continue;
1579
0
    }
1580
1581
0
  return nb_syl * 4;
1582
0
#undef chk_type
1583
0
}
1584
1585
void
1586
print_kvx_disassembler_options (FILE * stream)
1587
0
{
1588
0
  fprintf (stream, _("\n\
1589
0
The following KVX specific disassembler options are supported for use\n\
1590
0
with the -M switch (multiple options should be separated by commas):\n"));
1591
1592
0
  fprintf (stream, _("\n\
1593
0
  pretty               Print 32-bit words in natural order corresponding to \
1594
0
re-ordered instruction.\n"));
1595
1596
0
  fprintf (stream, _("\n\
1597
0
  compact-assembly     Do not emit a new line between bundles of instructions.\
1598
0
\n"));
1599
1600
0
  fprintf (stream, _("\n\
1601
0
  no-compact-assembly  Emit a new line between bundles of instructions.\n"));
1602
1603
0
  fprintf (stream, _("\n"));
1604
0
}