Coverage Report

Created: 2026-11-21 09:00

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/binutils-gdb/opcodes/csky-dis.c
Line
Count
Source
1
/* C-SKY disassembler.
2
   Copyright (C) 1988-2026 Free Software Foundation, Inc.
3
   Contributed by C-SKY Microsystems and Mentor Graphics.
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; if not, write to the Free Software
19
   Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
20
   MA 02110-1301, USA.  */
21
22
#include "sysdep.h"
23
#include "config.h"
24
#include <stdio.h>
25
#include <stdint.h>
26
#include <elf/csky.h>
27
#include "disassemble.h"
28
#include "elf-bfd.h"
29
#include "opcode/csky.h"
30
#include "libiberty.h"
31
#include "csky-opc.h"
32
#include "floatformat.h"
33
34
843k
#define CSKY_INST_TYPE unsigned long
35
210M
#define HAS_SUB_OPERAND (unsigned int)0xffffffff
36
1.08k
#define CSKY_DEFAULT_ISA 0xffffffff
37
38
enum sym_type
39
{
40
  CUR_TEXT,
41
  CUR_DATA
42
};
43
44
struct csky_dis_info
45
{
46
  /* Mem to disassemble.  */
47
  bfd_vma mem;
48
  /* Disassemble info.  */
49
  disassemble_info *info;
50
  /* Opcode information.  */
51
  struct csky_opcode_info const *opinfo;
52
  uint64_t isa;
53
  /* The value of operand to show.  */
54
  int value;
55
  /* Whether to look up/print a symbol name.  */
56
  int need_output_symbol;
57
} dis_info;
58
59
60
enum sym_type last_type;
61
int last_map_sym = 1;
62
bfd_vma last_map_addr = 0;
63
int using_abi = 0;
64
65
/* Only for objdump tool.  */
66
1.99M
#define INIT_MACH_FLAG  0xffffffff
67
2.53M
#define BINARY_MACH_FLAG 0x0
68
69
static unsigned int mach_flag = INIT_MACH_FLAG;
70
71
static void
72
print_insn_data (bfd_vma pc ATTRIBUTE_UNUSED,
73
     struct disassemble_info *info,
74
     long given)
75
0
{
76
0
  switch (info->bytes_per_chunk)
77
0
    {
78
0
    case 1:
79
0
      info->fprintf_func (info->stream, ".byte\t0x%02lx", given);
80
0
      break;
81
0
    case 2:
82
0
      info->fprintf_func (info->stream, ".short\t0x%04lx", given);
83
0
      break;
84
0
    case 4:
85
0
      info->fprintf_func (info->stream, ".long\t0x%08lx", given);
86
0
      break;
87
0
    default:
88
0
      abort ();
89
0
    }
90
0
}
91
92
static int
93
get_sym_code_type (struct disassemble_info *info,
94
       int n,
95
       enum sym_type *sym_type)
96
1.31k
{
97
1.31k
  const char *name;
98
1.31k
  name = bfd_asymbol_name (info->symtab[n]);
99
1.31k
  if (name[0] == '$' && (name[1] == 't' || name[1] == 'd')
100
0
      && (name[2] == 0 || name[2] == '.'))
101
0
    {
102
0
      *sym_type = ((name[1] == 't') ? CUR_TEXT : CUR_DATA);
103
0
      return true;
104
0
    }
105
1.31k
  return false;
106
1.31k
}
107
108
static int
109
csky_get_operand_mask (struct operand const *oprnd)
110
208M
{
111
208M
  int mask = 0;
112
208M
  if (oprnd->mask == HAS_SUB_OPERAND)
113
10.0M
    {
114
10.0M
      struct soperand *sop = (struct soperand *)oprnd;
115
10.0M
      mask |= csky_get_operand_mask (&sop->subs[0]);
116
10.0M
      mask |= csky_get_operand_mask (&sop->subs[1]);
117
10.0M
      return mask;
118
10.0M
    }
119
198M
  return oprnd->mask;
120
208M
}
121
122
static int
123
csky_get_mask (struct csky_opcode_info const *pinfo)
124
475M
{
125
475M
  int i = 0;
126
475M
  int mask = 0;
127
  /* List type.  */
128
475M
  if (pinfo->operand_num == -1)
129
1.40M
    mask |= csky_get_operand_mask (&pinfo->oprnd.oprnds[i]);
130
473M
  else
131
661M
    for (; i < pinfo->operand_num; i++)
132
187M
      mask |= csky_get_operand_mask (&pinfo->oprnd.oprnds[i]);
133
134
475M
  mask = ~mask;
135
475M
  return mask;
136
475M
}
137
138
static unsigned int
139
csky_chars_to_number (unsigned char * buf, int n)
140
75.8k
{
141
75.8k
  int i;
142
75.8k
  unsigned int val = 0;
143
144
75.8k
  if (dis_info.info->endian == BFD_ENDIAN_BIG)
145
231k
    for (i = 0; i < n; i++)
146
185k
      val = val << 8 | buf[i];
147
29.5k
  else
148
147k
    for (i = n - 1; i >= 0; i--)
149
118k
      val = val << 8 | buf[i];
150
75.8k
  return val;
151
75.8k
}
152
153
static struct csky_opcode const *g_opcodeP;
154
155
static struct csky_opcode const *
156
csky_find_inst_info (struct csky_opcode_info const **pinfo,
157
         CSKY_INST_TYPE inst, int length)
158
844k
{
159
844k
  int i;
160
844k
  unsigned int mask;
161
844k
  struct csky_opcode const *p;
162
163
844k
  p = g_opcodeP;
164
273M
  while (p->mnemonic)
165
273M
    {
166
273M
  if (!(p->isa_flag16 & dis_info.isa)
167
220M
        && !(p->isa_flag32 & dis_info.isa))
168
35.4M
  {
169
35.4M
    p++;
170
35.4M
    continue;
171
35.4M
  }
172
173
      /* Get the opcode mask.  */
174
712M
      for (i = 0; i < OP_TABLE_NUM; i++)
175
475M
  if (length == 2)
176
426M
    {
177
426M
      mask =  csky_get_mask (&p->op16[i]);
178
426M
      if (mask != 0 && (inst & mask) == p->op16[i].opcode)
179
721k
        {
180
721k
    *pinfo = &p->op16[i];
181
721k
    g_opcodeP = p;
182
721k
    return p;
183
721k
        }
184
426M
    }
185
49.2M
  else if (length == 4)
186
49.2M
    {
187
49.2M
      mask =  csky_get_mask (&p->op32[i]);
188
49.2M
      if (mask != 0
189
49.2M
    && ((unsigned long)(inst & mask)
190
49.2M
        == (unsigned long)p->op32[i].opcode))
191
21.6k
        {
192
21.6k
    *pinfo = &p->op32[i];
193
21.6k
    g_opcodeP = p;
194
21.6k
    return p;
195
21.6k
        }
196
49.2M
    }
197
237M
      p++;
198
237M
    }
199
200
101k
  return NULL;
201
844k
}
202
203
static bool
204
is_extern_symbol (struct disassemble_info *info, bfd_vma addr)
205
70.6k
{
206
70.6k
  if (info->section != NULL && info->section->relocation != NULL)
207
137
    {
208
137
      unsigned int rel_count = 0;
209
137
      struct reloc_cache_entry *pt = info->section->relocation;
210
6.72k
      for (; rel_count < info->section->reloc_count; rel_count++, pt++)
211
6.66k
  if (addr == pt->address)
212
68
    return true;
213
137
    }
214
70.6k
  return false;
215
70.6k
}
216
217
218
/* Suppress printing of mapping symbols emitted by the assembler to mark
219
   the beginning of code and data sequences.  */
220
221
bool
222
csky_symbol_is_valid (asymbol *sym,
223
          struct disassemble_info *info ATTRIBUTE_UNUSED)
224
712
{
225
712
  const char *name;
226
227
712
  if (sym == NULL)
228
0
    return false;
229
712
  name = bfd_asymbol_name (sym);
230
712
  return name && *name != '$';
231
712
}
232
233
disassembler_ftype
234
csky_get_disassembler (bfd *abfd)
235
1.08k
{
236
1.08k
  obj_attribute *attr;
237
1.08k
  const char *sec_name = NULL;
238
1.08k
  if (!abfd || bfd_get_flavour (abfd) != bfd_target_elf_flavour)
239
878
    dis_info.isa = CSKY_DEFAULT_ISA;
240
207
  else
241
207
    {
242
207
      mach_flag = elf_elfheader (abfd)->e_flags;
243
244
207
      sec_name = get_elf_backend_data (abfd)->obj_attrs_section;
245
      /* Skip any input that hasn't attribute section.
246
         This enables to link object files without attribute section with
247
         any others.  */
248
207
      if (bfd_get_section_by_name (abfd, sec_name) != NULL)
249
0
        {
250
0
          attr = elf_known_obj_attributes_proc (abfd);
251
0
          dis_info.isa = attr[Tag_CSKY_ISA_EXT_FLAGS].i;
252
0
          dis_info.isa <<= 32;
253
0
          dis_info.isa |= attr[Tag_CSKY_ISA_FLAGS].i;
254
0
        }
255
207
      else
256
207
        dis_info.isa = CSKY_DEFAULT_ISA;
257
207
    }
258
259
1.08k
   return print_insn_csky;
260
1.08k
}
261
262
/* Parse a disassembler option.  */
263
static bool
264
parse_csky_option (const char *opt, void *data ATTRIBUTE_UNUSED)
265
2.91k
{
266
2.91k
  if (strcmp (opt, "abi-names") == 0)
267
130
    using_abi = 1;
268
2.78k
  else
269
2.78k
    fprintf (stderr, "unrecognized disassembler option: %s", opt);
270
2.91k
  return true;
271
2.91k
}
272
273
/* Get general register name.  */
274
static const char *
275
get_gr_name (int regno)
276
874k
{
277
874k
  return csky_get_general_reg_name (mach_flag, regno, using_abi);
278
874k
}
279
280
/* Get control register name.  */
281
static const char *
282
get_cr_name (unsigned int regno, int bank)
283
2.56k
{
284
2.56k
  return csky_get_control_reg_name (mach_flag, bank, regno, using_abi);
285
2.56k
}
286
287
static int
288
csky_output_operand (char *str, struct operand const *oprnd,
289
         CSKY_INST_TYPE inst, int reloc ATTRIBUTE_UNUSED)
290
1.36M
{
291
1.36M
  int ret = 0;;
292
1.36M
  int bit = 0;
293
1.36M
  int result = 0;
294
1.36M
  bfd_vma value;
295
1.36M
  int mask = oprnd->mask;
296
1.36M
  int max = 0;
297
1.36M
  char buf[128];
298
299
  /* Get operand value with mask.  */
300
1.36M
  value = inst & mask;
301
12.6M
  for (; mask; mask >>= 1, value >>=1)
302
11.2M
    if (mask & 0x1)
303
6.29M
      {
304
6.29M
  result |= ((value & 0x1) << bit);
305
6.29M
  max |= (1 << bit);
306
6.29M
  bit++;
307
6.29M
      }
308
1.36M
  value = result;
309
310
  /* Here is general instructions that have no reloc.  */
311
1.36M
  switch (oprnd->type)
312
1.36M
    {
313
2.65k
    case OPRND_TYPE_CTRLREG:
314
2.65k
  if (IS_CSKY_V1(mach_flag) && ((value & 0x1f) == 0x1f))
315
94
    return -1;
316
2.56k
  strcat (str, get_cr_name((value & 0x1f), (value >> 5)));
317
2.56k
  break;
318
28.5k
    case OPRND_TYPE_DUMMY_REG:
319
28.5k
      mask = dis_info.opinfo->oprnd.oprnds[0].mask;
320
28.5k
      value = inst & mask;
321
142k
      for (; mask; mask >>= 1, value >>=1)
322
114k
  if (mask & 0x1)
323
114k
    {
324
114k
      result |= ((value & 0x1) << bit);
325
114k
      bit++;
326
114k
    }
327
28.5k
      value = result;
328
28.5k
      strcat (str, get_gr_name (value));
329
28.5k
      break;
330
423k
    case OPRND_TYPE_GREG0_7:
331
734k
    case OPRND_TYPE_GREG0_15:
332
734k
    case OPRND_TYPE_GREG16_31:
333
742k
    case OPRND_TYPE_REGnsplr:
334
759k
    case OPRND_TYPE_AREG:
335
759k
      strcat (str, get_gr_name (value));
336
759k
      break;
337
4.19k
    case OPRND_TYPE_CPREG:
338
4.19k
      sprintf (buf, "cpr%d", (int)value);
339
4.19k
      strcat (str, buf);
340
4.19k
      break;
341
259
    case OPRND_TYPE_FREG:
342
259
      sprintf (buf, "fr%d", (int)value);
343
259
      strcat (str, buf);
344
259
      break;
345
1.26k
    case OPRND_TYPE_VREG:
346
1.26k
      dis_info.value = value;
347
1.26k
      sprintf (buf, "vr%d", (int)value);
348
1.26k
      strcat (str, buf);
349
1.26k
      break;
350
872
    case OPRND_TYPE_CPCREG:
351
872
      sprintf (buf, "cpcr%d", (int)value);
352
872
      strcat (str, buf);
353
872
      break;
354
2.11k
    case OPRND_TYPE_CPIDX:
355
2.11k
      sprintf (buf, "cp%d", (int)value);
356
2.11k
      strcat (str, buf);
357
2.11k
      break;
358
2.25k
    case OPRND_TYPE_IMM2b_JMPIX:
359
2.25k
      value = (value + 2) << 3;
360
2.25k
      sprintf (buf, "%d", (int)value);
361
2.25k
      strcat (str, buf);
362
2.25k
      break;
363
135k
    case OPRND_TYPE_IMM_LDST:
364
135k
    case OPRND_TYPE_IMM_FLDST:
365
135k
      value <<= oprnd->shift;
366
135k
      sprintf (buf, "0x%x", (unsigned int)value);
367
135k
      strcat (str, buf);
368
135k
      break;
369
9.32k
    case OPRND_TYPE_IMM7b_LS2:
370
20.7k
    case OPRND_TYPE_IMM8b_LS2:
371
20.7k
      sprintf (buf, "%d", (int)(value << 2));
372
20.7k
      strcat (str, buf);
373
20.7k
      ret = 0;
374
20.7k
      break;
375
935
    case OPRND_TYPE_IMM5b_BMASKI:
376
935
      if ((value != 0) && (value > 31 || value < 8))
377
311
  {
378
311
    ret = -1;
379
311
    break;
380
311
  }
381
624
      sprintf (buf, "%d", (int)value);
382
624
      strcat (str, buf);
383
624
      ret = 0;
384
624
      break;
385
4.28k
    case OPRND_TYPE_IMM5b_1_31:
386
4.28k
      if (value > 31 || value < 1)
387
94
  {
388
94
    ret = -1;
389
94
    break;
390
94
  }
391
4.18k
      sprintf (buf, "%d", (int)value);
392
4.18k
      strcat (str, buf);
393
4.18k
      ret = 0;
394
4.18k
      break;
395
1.71k
    case OPRND_TYPE_IMM5b_7_31:
396
1.71k
      if (value > 31 || value < 7)
397
583
  {
398
583
    ret = -1;
399
583
    break;
400
583
  }
401
1.13k
      sprintf (buf, "%d", (int)value);
402
1.13k
      strcat (str, buf);
403
1.13k
      ret = 0;
404
1.13k
      break;
405
37
    case OPRND_TYPE_IMM5b_VSH:
406
37
      {
407
37
  char num[128];
408
37
  value = ((value & 0x1) << 4) | (value >> 1);
409
37
  sprintf (num, "%d", (int)value);
410
37
  strcat (str, num);
411
37
  ret = 0;
412
37
  break;
413
1.71k
      }
414
14
    case OPRND_TYPE_MSB2SIZE:
415
28
    case OPRND_TYPE_LSB2SIZE:
416
28
      {
417
28
  static int size;
418
28
  if (oprnd->type == OPRND_TYPE_MSB2SIZE)
419
14
    size = value;
420
14
  else
421
14
    {
422
14
      str[strlen (str) - 2] = '\0';
423
14
      sprintf (buf, "%d, %d", (int)(size + value), (int)value);
424
14
      strcat (str, buf);
425
14
    }
426
28
  break;
427
14
      }
428
0
    case OPRND_TYPE_IMM1b:
429
1.09k
    case OPRND_TYPE_IMM2b:
430
1.23k
    case OPRND_TYPE_IMM4b:
431
56.5k
    case OPRND_TYPE_IMM5b:
432
56.6k
    case OPRND_TYPE_IMM5b_LS:
433
61.1k
    case OPRND_TYPE_IMM7b:
434
89.2k
    case OPRND_TYPE_IMM8b:
435
92.6k
    case OPRND_TYPE_IMM12b:
436
98.8k
    case OPRND_TYPE_IMM15b:
437
98.9k
    case OPRND_TYPE_IMM16b:
438
99.0k
    case OPRND_TYPE_IMM16b_MOVIH:
439
101k
    case OPRND_TYPE_IMM16b_ORI:
440
101k
      sprintf (buf, "%d", (int)value);
441
101k
      strcat (str, buf);
442
101k
      ret = 0;
443
101k
      break;
444
1.91k
    case OPRND_TYPE_OFF8b:
445
1.91k
    case OPRND_TYPE_OFF16b:
446
1.91k
      {
447
1.91k
  unsigned char ibytes[4];
448
1.91k
  int shift = oprnd->shift;
449
1.91k
  int status;
450
1.91k
  unsigned int mem_val;
451
452
1.91k
  dis_info.info->stop_vma = 0;
453
454
1.91k
  value = ((dis_info.mem + (value << shift)
455
1.91k
      + ((IS_CSKY_V1 (mach_flag)) ? 2 : 0))
456
1.91k
     & 0xfffffffc);
457
1.91k
  status = dis_info.info->read_memory_func (value, ibytes, 4,
458
1.91k
              dis_info.info);
459
1.91k
  if (status != 0)
460
189
    {
461
189
      dis_info.info->memory_error_func (status, dis_info.mem,
462
189
                dis_info.info);
463
189
      return -1;
464
189
    }
465
1.72k
  mem_val = csky_chars_to_number (ibytes, 4);
466
  /* Remove [] around literal value to match ABI syntax.  */
467
1.72k
  sprintf (buf, "0x%X", mem_val);
468
1.72k
  strcat (str, buf);
469
  /* For jmpi/jsri, we'll try to get a symbol for the target.  */
470
1.72k
  if (dis_info.info->print_address_func && mem_val != 0)
471
1.52k
    {
472
1.52k
      dis_info.value = mem_val;
473
1.52k
      dis_info.need_output_symbol = 1;
474
1.52k
    }
475
201
  else
476
201
    {
477
201
      sprintf (buf, "\t// from address pool at 0x%x",
478
201
         (unsigned int)value);
479
201
      strcat (str, buf);
480
201
    }
481
1.72k
  break;
482
1.91k
      }
483
49
    case OPRND_TYPE_BLOOP_OFF4b:
484
98
    case OPRND_TYPE_BLOOP_OFF12b:
485
29.1k
    case OPRND_TYPE_OFF11b:
486
29.7k
    case OPRND_TYPE_OFF16b_LSL1:
487
30.3k
    case OPRND_TYPE_IMM_OFF18b:
488
33.4k
    case OPRND_TYPE_OFF26b:
489
33.4k
      {
490
33.4k
  int shift = oprnd->shift;
491
33.4k
  if (value & ((max >> 1) + 1))
492
22.2k
    value |= ~max;
493
33.4k
  if (is_extern_symbol (dis_info.info, dis_info.mem))
494
0
    value = 0;
495
33.4k
  else if (IS_CSKY_V1 (mach_flag))
496
29.0k
    value = dis_info.mem + 2 + (value << shift);
497
4.36k
  else
498
4.36k
    value = dis_info.mem + (value << shift);
499
33.4k
  dis_info.need_output_symbol = 1;
500
33.4k
  dis_info.value= value;
501
33.4k
  sprintf (buf, "0x%x", (unsigned int)value);
502
33.4k
  strcat (str, buf);
503
33.4k
  break;
504
30.3k
      }
505
24.9k
    case OPRND_TYPE_CONSTANT:
506
24.9k
    case OPRND_TYPE_FCONSTANT:
507
24.9k
      {
508
24.9k
  int shift = oprnd->shift;
509
24.9k
  bfd_byte ibytes[8];
510
24.9k
  int status;
511
24.9k
  bfd_vma addr;
512
24.9k
  int nbytes;
513
514
24.9k
  dis_info.info->stop_vma = 0;
515
24.9k
  value <<= shift;
516
517
24.9k
  if (IS_CSKY_V1 (mach_flag))
518
7.80k
    addr = (dis_info.mem + 2 + value) & 0xfffffffc;
519
17.1k
  else
520
17.1k
    addr = (dis_info.mem + value) & 0xfffffffc;
521
522
24.9k
  if (oprnd->type == OPRND_TYPE_FCONSTANT
523
0
      && dis_info.opinfo->opcode != CSKYV2_INST_FLRW)
524
0
    nbytes = 8;
525
24.9k
  else
526
24.9k
    nbytes = 4;
527
528
24.9k
  status = dis_info.info->read_memory_func (addr, ibytes,
529
24.9k
              nbytes, dis_info.info);
530
24.9k
  if (status != 0)
531
    /* Address out of bounds.  -> lrw rx, [pc, 0ffset]. */
532
4.24k
    sprintf (buf, "[pc, %d]\t// from address pool at %x", (int)value,
533
4.24k
       (unsigned int)addr);
534
20.7k
  else if (oprnd->type == OPRND_TYPE_FCONSTANT)
535
0
    {
536
0
      double f;
537
538
0
      if (dis_info.opinfo->opcode == CSKYV2_INST_FLRW)
539
        /* flrws.  */
540
0
        floatformat_to_double ((dis_info.info->endian == BFD_ENDIAN_BIG
541
0
              ? &floatformat_ieee_single_big
542
0
              : &floatformat_ieee_single_little),
543
0
             ibytes, &f);
544
0
      else
545
0
        floatformat_to_double ((dis_info.info->endian == BFD_ENDIAN_BIG
546
0
              ? &floatformat_ieee_double_big
547
0
              : &floatformat_ieee_double_little),
548
0
             ibytes, &f);
549
0
      sprintf (buf, "%.7g", f);
550
0
    }
551
20.7k
  else
552
20.7k
    {
553
20.7k
      dis_info.value = addr;
554
20.7k
      dis_info.need_output_symbol = 1;
555
20.7k
      value = csky_chars_to_number (ibytes, 4);
556
20.7k
      sprintf (buf, "0x%x", (unsigned int) value);
557
20.7k
    }
558
559
24.9k
  strcat (str, buf);
560
24.9k
  break;
561
24.9k
      }
562
74.2k
    case OPRND_TYPE_ELRW_CONSTANT:
563
74.2k
      {
564
74.2k
  int shift = oprnd->shift;
565
74.2k
  char ibytes[4];
566
74.2k
  int status;
567
74.2k
  bfd_vma addr;
568
74.2k
  dis_info.info->stop_vma = 0;
569
570
74.2k
  value = 0x80 + ((~value) & 0x7f);
571
572
74.2k
  value = value << shift;
573
74.2k
  addr = (dis_info.mem + value) & 0xfffffffc;
574
575
74.2k
  status = dis_info.info->read_memory_func (addr, (bfd_byte *)ibytes,
576
74.2k
              4, dis_info.info);
577
74.2k
  if (status != 0)
578
    /* Address out of bounds.  -> lrw rx, [pc, 0ffset]. */
579
20.9k
    sprintf (buf, "[pc, %d]\t// from address pool at %x", (int) value,
580
20.9k
       (unsigned int)addr);
581
53.3k
  else
582
53.3k
    {
583
53.3k
      dis_info.value = addr;
584
53.3k
      value = csky_chars_to_number ((unsigned char *)ibytes, 4);
585
53.3k
      dis_info.need_output_symbol = 1;
586
53.3k
      sprintf (buf, "0x%x", (unsigned int)value);
587
53.3k
    }
588
589
74.2k
  strcat (str, buf);
590
74.2k
  break;
591
24.9k
      }
592
2
    case OPRND_TYPE_SFLOAT:
593
7
    case OPRND_TYPE_DFLOAT:
594
7
      {
595
  /* This is for fmovis/fmovid, which have an internal 13-bit
596
     encoding that they convert to single/double precision
597
     (respectively).  We'll convert the 13-bit encoding to an IEEE
598
     double and then to host double format to print it.
599
     Sign bit: bit 20.
600
     4-bit exponent: bits 19:16, biased by 11.
601
     8-bit mantissa: split between 24:21 and 7:4.  */
602
7
  uint64_t imm4;
603
7
  uint64_t imm8;
604
7
  uint64_t dbnum;
605
7
  unsigned char valbytes[8];
606
7
  double fvalue;
607
608
7
  imm4 = ((inst >> 16) & 0xf);
609
7
  imm4 = (uint64_t)(1023 - (imm4 - 11)) << 52;
610
611
7
  imm8 = (uint64_t)((inst >> 4) & 0xf) << 44;
612
7
  imm8 |= (uint64_t)((inst >> 21) & 0xf) << 48;
613
614
7
  dbnum = (uint64_t)((inst >> 20) & 1) << 63;
615
7
  dbnum |= imm4 | imm8;
616
617
  /* Do this a byte at a time so we don't have to
618
     worry about the host's endianness.  */
619
7
  valbytes[0] = dbnum & 0xff;
620
7
  valbytes[1] = (dbnum >> 8) & 0xff;
621
7
  valbytes[2] = (dbnum >> 16) & 0xff;
622
7
  valbytes[3] = (dbnum >> 24) & 0xff;
623
7
  valbytes[4] = (dbnum >> 32) & 0xff;
624
7
  valbytes[5] = (dbnum >> 40) & 0xff;
625
7
  valbytes[6] = (dbnum >> 48) & 0xff;
626
7
  valbytes[7] = (dbnum >> 56) & 0xff;
627
628
7
  floatformat_to_double (&floatformat_ieee_double_little, valbytes,
629
7
             &fvalue);
630
631
7
  sprintf (buf, "%.7g", fvalue);
632
7
  strcat (str, buf);
633
7
  break;
634
2
      }
635
0
    case OPRND_TYPE_HFLOAT_FMOVI:
636
0
    case OPRND_TYPE_SFLOAT_FMOVI:
637
0
      {
638
0
  int imm4;
639
0
  int imm8;
640
0
  imm4 = ((inst >> 16) & 0xf);
641
0
  imm4 = (138 - imm4) << 23;
642
643
0
  imm8 = ((inst >> 8) & 0x3);
644
0
  imm8 |= (((inst >> 20) & 0x3f) << 2);
645
0
  imm8 <<= 15;
646
647
0
  value = ((inst >> 5) & 1) << 31;
648
0
  value |= imm4 | imm8;
649
650
0
  imm4 = 138 - (imm4 >> 23);
651
0
  imm8 >>= 15;
652
0
  if ((inst >> 5) & 1)
653
0
    {
654
0
      imm8 = 0 - imm8;
655
0
    }
656
657
0
  float f = 0;
658
0
  memcpy (&f, &value, sizeof (float));
659
0
  sprintf (buf, "%.7g\t// imm9:%4d, imm4:%2d", f, imm8, imm4);
660
0
  strcat (str, buf);
661
662
0
  break;
663
0
      }
664
665
0
    case OPRND_TYPE_DFLOAT_FMOVI:
666
0
      {
667
0
  uint64_t imm4;
668
0
  uint64_t imm8;
669
0
  uint64_t dvalue;
670
0
  imm4 = ((inst >> 16) & 0xf);
671
0
  imm4 = (1034 - imm4) << 52;
672
673
0
  imm8 = ((inst >> 8) & 0x3);
674
0
  imm8 |= (((inst >> 20) & 0x3f) << 2);
675
0
  imm8 <<= 44;
676
677
0
  dvalue = (((uint64_t)inst >> 5) & 1) << 63;
678
0
  dvalue |= imm4 | imm8;
679
680
0
  imm4 = 1034 - (imm4 >> 52);
681
0
  imm8 >>= 44;
682
0
  if (inst >> 5)
683
0
    {
684
0
      imm8 = 0 - imm8;
685
0
    }
686
0
  double d = 0;
687
0
  memcpy (&d, &dvalue, sizeof (double));
688
0
  sprintf (buf, "%.7g\t// imm9:%4ld, imm4:%2ld", d, (long) imm8, (long) imm4);
689
0
  strcat (str, buf);
690
691
0
  break;
692
0
      }
693
909
    case OPRND_TYPE_LABEL_WITH_BRACKET:
694
909
      sprintf (buf, "[0x%x]", (unsigned int)value);
695
909
      strcat (str, buf);
696
909
      strcat (str, "\t// the offset is based on .data");
697
909
      break;
698
4.57k
    case OPRND_TYPE_OIMM3b:
699
4.74k
    case OPRND_TYPE_OIMM4b:
700
19.7k
    case OPRND_TYPE_OIMM5b:
701
19.7k
    case OPRND_TYPE_OIMM5b_IDLY:
702
54.4k
    case OPRND_TYPE_OIMM8b:
703
54.9k
    case OPRND_TYPE_OIMM12b:
704
55.0k
    case OPRND_TYPE_OIMM16b:
705
55.2k
    case OPRND_TYPE_OIMM18b:
706
55.2k
      value += 1;
707
55.2k
      sprintf (buf, "%d", (int)value);
708
55.2k
      strcat (str, buf);
709
55.2k
      break;
710
0
    case OPRND_TYPE_OIMM5b_BMASKI:
711
0
      if (value > 32 || value < 16)
712
0
  {
713
0
    ret = -1;
714
0
    break;
715
0
  }
716
0
      sprintf (buf, "%d", (int)(value + 1));
717
0
      strcat (str, buf);
718
0
      ret = 0;
719
0
      break;
720
50
    case OPRND_TYPE_FREGLIST_DASH:
721
50
      if (IS_CSKY_V2 (mach_flag))
722
50
  {
723
50
    int vrx = 0;
724
50
    int vry = 0;
725
50
    if (dis_info.isa & CSKY_ISA_FLOAT_7E60
726
0
        && (strstr (str, "fstm") != NULL
727
0
      || strstr (str, "fldm") != NULL))
728
0
      {
729
0
        vrx = value & 0x1f;
730
0
        vry = vrx + (value >> 5);
731
0
      }
732
50
    else
733
50
      {
734
50
        vrx = value & 0xf;
735
50
        vry = vrx + (value >> 4);
736
50
      }
737
50
    sprintf (buf, "fr%d-fr%d", vrx, vry);
738
50
    strcat (str, buf);
739
50
  }
740
50
      break;
741
1.58k
    case OPRND_TYPE_REGLIST_DASH:
742
1.58k
      if (IS_CSKY_V1 (mach_flag))
743
1.57k
  {
744
1.57k
    sprintf (buf, "%s-r15", get_gr_name (value));
745
1.57k
    strcat (str, buf);
746
1.57k
  }
747
2
      else
748
2
  {
749
2
    if ((value & 0x1f) + (value >> 5) > 31)
750
0
      {
751
0
        ret = -1;
752
0
        break;
753
0
      }
754
2
    strcat (str, get_gr_name ((value >> 5)));
755
2
    strcat (str, "-");
756
2
    strcat (str, get_gr_name ((value & 0x1f) + (value >> 5)));
757
2
  }
758
1.58k
      break;
759
1.58k
    case OPRND_TYPE_PSR_BITS_LIST:
760
104
      {
761
104
  struct psrbit const *bits;
762
104
  int first_oprnd = true;
763
104
  int i = 0;
764
104
  if (IS_CSKY_V1 (mach_flag))
765
91
    {
766
91
      if (value == 0)
767
11
        {
768
11
    strcat (str, "af");
769
11
    break;
770
11
        }
771
80
      bits = cskyv1_psr_bits;
772
80
    }
773
13
  else
774
13
    bits = cskyv2_psr_bits;
775
307
  while (value != 0 && bits[i].name != NULL)
776
214
      {
777
214
        if (value & bits[i].value)
778
204
    {
779
204
      if (!first_oprnd)
780
124
        strcat (str, ", ");
781
204
      strcat (str, bits[i].name);
782
204
      value &= ~bits[i].value;
783
204
      first_oprnd = false;
784
204
    }
785
214
        i++;
786
214
      }
787
93
  break;
788
104
      }
789
1.57k
    case OPRND_TYPE_REGbsp:
790
1.57k
      if (IS_CSKY_V1 (mach_flag))
791
1.57k
  sprintf(buf, "(%s)", get_gr_name (0));
792
0
      else
793
0
  sprintf(buf, "(%s)", get_gr_name (14));
794
1.57k
      strcat (str, buf);
795
1.57k
      break;
796
46.0k
    case OPRND_TYPE_REGsp:
797
46.0k
      if (IS_CSKY_V1 (mach_flag))
798
0
  strcat (str, get_gr_name (0));
799
46.0k
      else
800
46.0k
  strcat (str, get_gr_name (14));
801
46.0k
      break;
802
1.63k
    case OPRND_TYPE_REGnr4_r7:
803
1.68k
    case OPRND_TYPE_AREG_WITH_BRACKET:
804
1.68k
      strcat (str, "(");
805
1.68k
      strcat (str, get_gr_name (value));
806
1.68k
      strcat (str, ")");
807
1.68k
      break;
808
948
    case OPRND_TYPE_AREG_WITH_LSHIFT:
809
948
      strcat (str, get_gr_name (value >> 5));
810
948
      strcat (str, " << ");
811
948
      if ((value & 0x1f) == 0x1)
812
62
  strcat (str, "0");
813
886
      else if ((value & 0x1f) == 0x2)
814
30
  strcat (str, "1");
815
856
      else if ((value & 0x1f) == 0x4)
816
131
  strcat (str, "2");
817
725
      else if ((value & 0x1f) == 0x8)
818
29
  strcat (str, "3");
819
948
      break;
820
67
    case OPRND_TYPE_AREG_WITH_LSHIFT_FPU:
821
67
      strcat (str, get_gr_name (value >> 2));
822
67
      strcat (str, " << ");
823
67
      if ((value & 0x3) == 0x0)
824
16
  strcat (str, "0");
825
51
      else if ((value & 0x3) == 0x1)
826
44
  strcat (str, "1");
827
7
      else if ((value & 0x3) == 0x2)
828
3
  strcat (str, "2");
829
4
      else if ((value & 0x3) == 0x3)
830
4
  strcat (str, "3");
831
67
      break;
832
15
    case OPRND_TYPE_VREG_WITH_INDEX:
833
15
      {
834
15
  unsigned freg_val = value & 0xf;
835
15
  unsigned index_val = (value >> 4) & 0xf;
836
15
  sprintf (buf, "vr%d[%d]", freg_val, index_val);
837
15
  strcat(str, buf);
838
15
  break;
839
1.63k
      }
840
0
    case OPRND_TYPE_FREG_WITH_INDEX:
841
0
      {
842
0
  unsigned freg_val = value & 0xf;
843
0
  unsigned index_val = (value >> 4) & 0xf;
844
0
  sprintf (buf, "fr%d[%d]", freg_val, index_val);
845
0
  strcat(str, buf);
846
0
  break;
847
1.63k
      }
848
1.63k
    case OPRND_TYPE_REGr4_r7:
849
1.63k
      if (IS_CSKY_V1 (mach_flag))
850
1.63k
  {
851
1.63k
    sprintf (buf, "%s-%s", get_gr_name (4), get_gr_name (7));
852
1.63k
    strcat (str, buf);
853
1.63k
  }
854
1.63k
      break;
855
2.28k
    case OPRND_TYPE_CONST1:
856
2.28k
      strcat (str, "1");
857
2.28k
      break;
858
4.03k
    case OPRND_TYPE_REG_r1a:
859
4.07k
    case OPRND_TYPE_REG_r1b:
860
4.07k
      strcat (str, get_gr_name (1));
861
4.07k
      break;
862
208
    case OPRND_TYPE_REG_r28:
863
208
      strcat (str, get_gr_name (28));
864
208
      break;
865
13.2k
    case OPRND_TYPE_REGLIST_DASH_COMMA:
866
      /* 16-bit reglist.  */
867
13.2k
      if (value & 0xf)
868
10.3k
  {
869
10.3k
    strcat (str, get_gr_name (4));
870
10.3k
    if ((value & 0xf) > 1)
871
6.87k
      {
872
6.87k
        strcat (str, "-");
873
6.87k
        strcat (str, get_gr_name ((value & 0xf) + 3));
874
6.87k
      }
875
10.3k
    if (value & ~0xf)
876
6.98k
      strcat (str, ", ");
877
10.3k
  }
878
13.2k
      if (value & 0x10)
879
9.14k
  {
880
    /* r15.  */
881
9.14k
    strcat (str, get_gr_name (15));
882
9.14k
    if (value & ~0x1f)
883
0
      strcat (str, ", ");
884
9.14k
  }
885
13.2k
      if (dis_info.opinfo->oprnd.oprnds[0].mask != OPRND_MASK_0_4)
886
1
  {
887
    /* 32bits reglist.  */
888
1
    value >>= 5;
889
1
    if (value & 0x3)
890
0
      {
891
0
        strcat (str, get_gr_name (16));
892
0
        if ((value & 0x7) > 1)
893
0
    {
894
0
      strcat (str, "-");
895
0
      strcat (str, get_gr_name ((value & 0x7) + 15));
896
0
    }
897
0
        if (value & ~0x7)
898
0
    strcat (str, ", ");
899
0
        }
900
1
    if (value & 0x8)
901
      /* r15.  */
902
0
      strcat (str, get_gr_name (28));
903
1
  }
904
13.2k
      break;
905
14.2k
    case OPRND_TYPE_UNCOND10b:
906
14.5k
    case OPRND_TYPE_UNCOND16b:
907
37.1k
    case OPRND_TYPE_COND10b:
908
37.2k
    case OPRND_TYPE_COND16b:
909
37.2k
      {
910
37.2k
  int shift = oprnd->shift;
911
912
37.2k
  if (value & ((max >> 1) + 1))
913
13.8k
    value |= ~max;
914
37.2k
  if (is_extern_symbol (dis_info.info, dis_info.mem))
915
68
    value = 0;
916
37.1k
  else
917
37.1k
    value = dis_info.mem + (value << shift);
918
37.2k
  sprintf (buf, "0x%x", (unsigned int)value);
919
37.2k
  strcat (str, buf);
920
37.2k
  dis_info.need_output_symbol = 1;
921
37.2k
  dis_info.value = value;
922
37.2k
      }
923
37.2k
      break;
924
925
48
    default:
926
48
      ret = -1;
927
48
      break;
928
1.36M
    }
929
1.36M
  return ret;
930
1.36M
}
931
932
static int
933
csky_print_operand (char *str, struct operand const *oprnd,
934
        CSKY_INST_TYPE inst, int reloc)
935
1.51M
{
936
1.51M
  int ret = -1;
937
1.51M
  char *lc = "";
938
1.51M
  char *rc = "";
939
1.51M
  if (oprnd->mask == HAS_SUB_OPERAND)
940
146k
    {
941
146k
      struct soperand *sop = (struct soperand *)oprnd;
942
146k
      if (oprnd->type == OPRND_TYPE_BRACKET)
943
136k
  {
944
136k
    lc = "(";
945
136k
    rc = ")";
946
136k
  }
947
9.34k
      else if (oprnd->type == OPRND_TYPE_ABRACKET)
948
9.34k
  {
949
9.34k
    lc = "<";
950
9.34k
    rc = ">";
951
9.34k
  }
952
146k
      strcat (str, lc);
953
146k
      ret = csky_print_operand (str, &sop->subs[0], inst, reloc);
954
146k
      if (ret)
955
0
  return ret;
956
146k
      strcat (str, ", ");
957
146k
      ret = csky_print_operand (str, &sop->subs[1], inst, reloc);
958
146k
      strcat (str, rc);
959
146k
      return ret;
960
146k
    }
961
1.36M
  return csky_output_operand (str, oprnd, inst, reloc);
962
1.51M
}
963
964
static int
965
csky_print_operands (char *str, struct csky_opcode_info const *pinfo,
966
         struct disassemble_info *info, CSKY_INST_TYPE inst,
967
         int reloc)
968
742k
{
969
742k
  int i = 0;
970
742k
  int ret = 0;
971
742k
  if (pinfo->operand_num)
972
610k
    strcat (str, "      \t");
973
742k
  if (pinfo->operand_num == -1)
974
13.3k
    {
975
13.3k
      ret = csky_print_operand (str, &pinfo->oprnd.oprnds[i], inst, reloc);
976
13.3k
      if (ret)
977
0
  return ret;
978
13.3k
    }
979
729k
  else
980
1.93M
    for (; i < pinfo->operand_num; i++)
981
1.20M
      {
982
1.20M
  if (i != 0)
983
611k
    strcat (str, ", ");
984
1.20M
  ret = csky_print_operand (str, &pinfo->oprnd.oprnds[i], inst, reloc);
985
1.20M
  if (ret)
986
1.31k
    return ret;
987
1.20M
      }
988
741k
  info->fprintf_func (info->stream, "%s", str);
989
741k
  if (dis_info.need_output_symbol)
990
146k
    {
991
146k
      info->fprintf_func (info->stream, "\t// ");
992
146k
      info->print_address_func (dis_info.value, dis_info.info);
993
146k
    }
994
741k
  return 0;
995
742k
}
996
997
static void
998
number_to_chars_littleendian (char *buf, CSKY_INST_TYPE val, int n)
999
22
{
1000
22
  if (n <= 0)
1001
0
    abort ();
1002
110
  while (n--)
1003
88
    {
1004
88
      *buf++ = val & 0xff;
1005
88
      val >>= 8;
1006
88
    }
1007
22
}
1008
1009
885k
#define CSKY_READ_DATA()                                        \
1010
885k
{                                                               \
1011
885k
  status = info->read_memory_func (memaddr, buf, 2, info);      \
1012
885k
  if (status)                                                   \
1013
885k
    {                                                           \
1014
441
      info->memory_error_func (status, memaddr, info);          \
1015
441
      return -1;                                                \
1016
441
    }                                                           \
1017
885k
  if (info->endian == BFD_ENDIAN_BIG)                           \
1018
884k
    inst |= (buf[0] << 8) | buf[1];                             \
1019
884k
  else if (info->endian == BFD_ENDIAN_LITTLE)                   \
1020
359k
    inst |= (buf[1] << 8) | buf[0];                             \
1021
359k
  else                                                          \
1022
359k
    abort();                                                    \
1023
884k
  info->bytes_per_chunk += 2;                                   \
1024
884k
  memaddr += 2;                                                 \
1025
884k
}
1026
1027
int
1028
print_insn_csky (bfd_vma memaddr, struct disassemble_info *info)
1029
843k
{
1030
843k
  unsigned char buf[4];
1031
843k
  CSKY_INST_TYPE inst = 0;
1032
843k
  int status;
1033
843k
  char str[256];
1034
843k
  unsigned long given;
1035
843k
  int is_data = false;
1036
843k
  void (*printer) (bfd_vma, struct disassemble_info *, long);
1037
843k
  unsigned int  size = 4;
1038
1039
843k
  memset (str, 0, sizeof (str));
1040
843k
  info->bytes_per_chunk = 0;
1041
843k
  info->bytes_per_chunk = 0;
1042
843k
  dis_info.mem = memaddr;
1043
843k
  dis_info.info = info;
1044
843k
  dis_info.need_output_symbol = 0;
1045
1046
843k
  if (info->disassembler_options)
1047
656
    {
1048
656
      for_each_disassembler_option (info, parse_csky_option, NULL);
1049
656
      info->disassembler_options = NULL;
1050
656
    }
1051
1052
843k
  if (mach_flag != INIT_MACH_FLAG && mach_flag != BINARY_MACH_FLAG)
1053
536k
    info->mach = mach_flag;
1054
307k
  else if (mach_flag == INIT_MACH_FLAG)
1055
2
    {
1056
2
      mach_flag = info->mach;
1057
2
      dis_info.isa = CSKY_DEFAULT_ISA;
1058
2
    }
1059
1060
843k
  if (mach_flag == BINARY_MACH_FLAG && info->endian == BFD_ENDIAN_UNKNOWN)
1061
0
    {
1062
0
      info->endian = BFD_ENDIAN_LITTLE;
1063
0
      dis_info.isa = CSKY_DEFAULT_ISA;
1064
0
    }
1065
1066
  /* First check the full symtab for a mapping symbol, even if there
1067
     are no usable non-mapping symbols for this address.  */
1068
843k
  if (info->symtab_size != 0
1069
1.66k
      && bfd_asymbol_flavour (*info->symtab) == bfd_target_elf_flavour)
1070
1.66k
    {
1071
1.66k
      bfd_vma addr;
1072
1.66k
      int n;
1073
1.66k
      int last_sym = -1;
1074
1.66k
      enum sym_type type = CUR_TEXT;
1075
1076
1.66k
      if (memaddr <= last_map_addr)
1077
9
  last_map_sym = -1;
1078
      /* Start scanning at the start of the function, or wherever
1079
   we finished last time.  */
1080
1.66k
      n = 0;
1081
1.66k
      if (n < last_map_sym)
1082
1
  n = last_map_sym;
1083
1084
      /* Scan up to the location being disassembled.  */
1085
5.36k
      for (; n < info->symtab_size; n++)
1086
3.99k
  {
1087
3.99k
    addr = bfd_asymbol_value (info->symtab[n]);
1088
3.99k
    if (addr > memaddr)
1089
286
      break;
1090
3.70k
    if ((info->section == NULL
1091
3.70k
         || info->section == info->symtab[n]->section)
1092
1.31k
        && get_sym_code_type (info, n, &type))
1093
0
      last_sym = n;
1094
3.70k
  }
1095
1.66k
      last_map_sym = last_sym;
1096
1.66k
      last_type = type;
1097
1.66k
      is_data = (last_type == CUR_DATA);
1098
1.66k
      if (is_data)
1099
0
  {
1100
0
    size = 4 - ( memaddr & 3);
1101
0
    for (n = last_sym + 1; n < info->symtab_size; n++)
1102
0
      {
1103
0
        addr = bfd_asymbol_value (info->symtab[n]);
1104
0
        if (addr > memaddr)
1105
0
    {
1106
0
      if (addr - memaddr < size)
1107
0
        size = addr - memaddr;
1108
0
      break;
1109
0
    }
1110
0
      }
1111
    /* If the next symbol is after three bytes, we need to
1112
       print only part of the data, so that we can use either
1113
       .byte or .short.  */
1114
0
    if (size == 3)
1115
0
      size = (memaddr & 1) ? 1 : 2;
1116
0
  }
1117
1.66k
    }
1118
843k
  info->bytes_per_line = 4;
1119
1120
843k
  if (is_data)
1121
0
    {
1122
0
      int i;
1123
1124
      /* Size was already set above.  */
1125
0
      info->bytes_per_chunk = size;
1126
0
      printer = print_insn_data;
1127
1128
0
      status = info->read_memory_func (memaddr, (bfd_byte *) buf, size, info);
1129
0
      given = 0;
1130
0
      if (info->endian == BFD_ENDIAN_LITTLE)
1131
0
  for (i = size - 1; i >= 0; i--)
1132
0
    given = buf[i] | (given << 8);
1133
0
      else
1134
0
  for (i = 0; i < (int) size; i++)
1135
0
    given = buf[i] | (given << 8);
1136
1137
0
      printer (memaddr, info, given);
1138
0
      return info->bytes_per_chunk;
1139
0
    }
1140
1141
  /* Handle instructions.  */
1142
2.53M
  CSKY_READ_DATA();
1143
2.53M
  if ((inst & 0xc000) == 0xc000 && IS_CSKY_V2 (mach_flag))
1144
41.2k
    {
1145
      /* It's a 32-bit instruction.  */
1146
41.2k
      inst <<= 16;
1147
82.5k
      CSKY_READ_DATA();
1148
82.5k
      if (info->buffer && (info->endian == BFD_ENDIAN_LITTLE))
1149
22
  {
1150
22
    char* src = (char *)(info->buffer
1151
22
             + ((memaddr - 4 - info->buffer_vma)
1152
22
          * info->octets_per_byte));
1153
22
    if (info->endian == BFD_ENDIAN_LITTLE)
1154
22
      number_to_chars_littleendian (src, inst, 4);
1155
22
  }
1156
82.5k
    }
1157
1158
843k
  if (IS_CSKY_V1 (mach_flag))
1159
203k
    g_opcodeP = csky_v1_opcodes;
1160
639k
  else
1161
639k
    g_opcodeP = csky_v2_opcodes;
1162
1163
843k
  do
1164
844k
    {
1165
844k
      struct csky_opcode const *op;
1166
844k
      struct csky_opcode_info const *pinfo = NULL;
1167
844k
      int reloc;
1168
1169
844k
      memset (str, 0, sizeof (str));
1170
844k
      op = csky_find_inst_info (&pinfo, inst, info->bytes_per_chunk);
1171
844k
      if (!op)
1172
101k
  {
1173
101k
    if (IS_CSKY_V1 (mach_flag))
1174
279
      info->fprintf_func (info->stream, ".short: 0x%04x",
1175
279
        (unsigned short)inst);
1176
101k
    else
1177
101k
      info->fprintf_func (info->stream, ".long: 0x%08x",
1178
101k
        (unsigned int)inst);
1179
101k
    return info->bytes_per_chunk;
1180
101k
  }
1181
1182
742k
      if (info->bytes_per_chunk == 2)
1183
721k
  reloc = op->reloc16;
1184
21.6k
      else
1185
21.6k
  reloc = op->reloc32;
1186
742k
      dis_info.opinfo = pinfo;
1187
742k
      strcat (str, op->mnemonic);
1188
1189
742k
      if (csky_print_operands (str, pinfo, info, inst, reloc))
1190
1.31k
  g_opcodeP++;
1191
741k
      else
1192
741k
  break;
1193
742k
    } while (1);
1194
1195
741k
  return info->bytes_per_chunk;
1196
843k
}