Automatic date update in version.in
[binutils-gdb.git] / opcodes / xtensa-dis.c
index 64c9a4ed4e054785545b0266f52ac3b2903dcc3a..760029418deaaaf29ed4e21bb5071f393d24360a 100644 (file)
@@ -1,5 +1,5 @@
 /* xtensa-dis.c.  Disassembly functions for Xtensa.
-   Copyright (C) 2003-2021 Free Software Foundation, Inc.
+   Copyright (C) 2003-2022 Free Software Foundation, Inc.
    Contributed by Bob Wilson at Tensilica, Inc. (bwilson@tensilica.com)
 
    This file is part of the GNU opcodes library.
@@ -194,7 +194,8 @@ print_xtensa_operand (bfd_vma memaddr,
                      unsigned operand_val)
 {
   xtensa_isa isa = xtensa_default_isa;
-  int signed_operand_val;
+  int signed_operand_val, status;
+  bfd_byte litbuf[4];
 
   if (show_raw_fields)
     {
@@ -216,6 +217,23 @@ print_xtensa_operand (bfd_vma memaddr,
                                            &operand_val, memaddr);
          info->target = operand_val;
          (*info->print_address_func) (info->target, info);
+         /*  Also display value loaded by L32R (but not if reloc exists,
+             those tend to be wrong):  */
+         if ((info->flags & INSN_HAS_RELOC) == 0
+             && !strcmp ("l32r", xtensa_opcode_name (isa, opc)))
+           status = (*info->read_memory_func) (operand_val, litbuf, 4, info);
+         else
+           status = -1;
+
+         if (status == 0)
+           {
+             unsigned literal = bfd_get_bits (litbuf, 32,
+                                              info->endian == BFD_ENDIAN_BIG);
+
+             (*info->fprintf_func) (info->stream, " (");
+             (*info->print_address_func) (literal, info);
+             (*info->fprintf_func) (info->stream, ")");
+           }
        }
       else
        {
@@ -381,6 +399,7 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
       if (insn_block && (insn_block->flags & XTENSA_PROP_LITERAL)
          && (memaddr & 3) == 0 && bytes_fetched >= 4)
        {
+         info->bytes_per_chunk = 4;
          return 4;
        }
       else
@@ -393,6 +412,9 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
   if (nslots > 1)
     (*info->fprintf_func) (info->stream, "{ ");
 
+  info->insn_type = dis_nonbranch;
+  info->insn_info_valid = 1;
+
   first_slot = 1;
   for (n = 0; n < nslots; n++)
     {
@@ -406,6 +428,13 @@ print_insn_xtensa (bfd_vma memaddr, struct disassemble_info *info)
       (*info->fprintf_func) (info->stream, "%s",
                             xtensa_opcode_name (isa, opc));
 
+      if (xtensa_opcode_is_branch (isa, opc))
+       info->insn_type = dis_condbranch;
+      else if (xtensa_opcode_is_jump (isa, opc))
+       info->insn_type = dis_branch;
+      else if (xtensa_opcode_is_call (isa, opc))
+       info->insn_type = dis_jsr;
+
       /* Print the operands (if any).  */
       noperands = xtensa_opcode_num_operands (isa, opc);
       first = 1;