Delete unnecessary code from kill_command
[deliverable/binutils-gdb.git] / gas / config / tc-metag.c
index d5e603aa0fd0f3c82b653e9b2c159646e6fefc4e..2816640b29e213eb48315aa728907f0b83ca9aa7 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-metag.c -- Assembler for the Imagination Technologies Meta.
 /* tc-metag.c -- Assembler for the Imagination Technologies Meta.
-   Copyright (C) 2013 Free Software Foundation, Inc.
+   Copyright (C) 2013-2020 Free Software Foundation, Inc.
    Contributed by Imagination Technologies Ltd.
 
    This file is part of GAS, the GNU Assembler.
    Contributed by Imagination Technologies Ltd.
 
    This file is part of GAS, the GNU Assembler.
@@ -24,7 +24,6 @@
 #include "symcat.h"
 #include "safe-ctype.h"
 #include "hashtab.h"
 #include "symcat.h"
 #include "safe-ctype.h"
 #include "hashtab.h"
-#include "libbfd.h"
 
 #include <stdio.h>
 
 
 #include <stdio.h>
 
@@ -636,7 +635,7 @@ parse_addr_op (const char *line, metag_addr *addr)
   return NULL;
 }
 
   return NULL;
 }
 
-/* Parse the immediate portion of an addrssing mode.  */
+/* Parse the immediate portion of an addressing mode.  */
 static const char *
 parse_imm_addr (const char *line, metag_addr *addr)
 {
 static const char *
 parse_imm_addr (const char *line, metag_addr *addr)
 {
@@ -2026,11 +2025,38 @@ parse_swap (const char *line, metag_insn *insn,
   if (l == NULL)
     return NULL;
 
   if (l == NULL)
     return NULL;
 
-  insn->bits = (template->meta_opcode |
-               (regs[1]->no << 19) |
-               (regs[0]->no << 14) |
-               (regs[1]->unit << 10) |
-               (regs[0]->unit << 5));
+  /* PC.r | CT.r | TR.r | TT.r are treated as if they are a single unit.  */
+  switch (regs[0]->unit)
+    {
+    case UNIT_PC:
+    case UNIT_CT:
+    case UNIT_TR:
+    case UNIT_TT:
+      if (regs[1]->unit == UNIT_PC
+         || regs[1]->unit == UNIT_CT
+         || regs[1]->unit == UNIT_TR
+         || regs[1]->unit == UNIT_TT)
+       {
+         as_bad (_("PC, CT, TR and TT are treated as if they are a single unit but operands must be in different units"));
+         return NULL;
+       }
+      break;
+
+    default:
+      /* Registers must be in different units.  */
+      if (regs[0]->unit == regs[1]->unit)
+       {
+         as_bad (_("source and destination register must be in different units"));
+         return NULL;
+       }
+      break;
+    }
+
+  insn->bits = (template->meta_opcode
+               | (regs[1]->no << 19)
+               | (regs[0]->no << 14)
+               | (regs[1]->unit << 10)
+               | (regs[0]->unit << 5));
 
   insn->len = 4;
   return l;
 
   insn->len = 4;
   return l;
@@ -2657,6 +2683,7 @@ parse_alu (const char *line, metag_insn *insn,
              insn->bits |= (1 << 7);
              break;
            }
              insn->bits |= (1 << 7);
              break;
            }
+         /* Fall through.  */
        default:
          as_bad (_("invalid quickrot register specified"));
          return NULL;
        default:
          as_bad (_("invalid quickrot register specified"));
          return NULL;
@@ -4072,7 +4099,7 @@ __parse_dsp_reg (const char *line, const metag_reg **reg, htab_t dsp_regtab)
   /* We don't entirely strip the register name because we might
      actually want to match whole string in the register table,
      e.g. "D0AW.1++" not just "D0AW.1". The string length of the table
   /* We don't entirely strip the register name because we might
      actually want to match whole string in the register table,
      e.g. "D0AW.1++" not just "D0AW.1". The string length of the table
-     entry limits our comaprison to a reasonable bound anyway.  */
+     entry limits our comparison to a reasonable bound anyway.  */
   while (is_register_char (*l) || *l == PLUS)
     {
       name[len] = *l;
   while (is_register_char (*l) || *l == PLUS)
     {
       name[len] = *l;
@@ -4690,7 +4717,7 @@ parse_dtemplate (const char *line, metag_insn *insn,
   return l;
 }
 
   return l;
 }
 
-/* Parse a DSP Template definiton memory reference, e.g
+/* Parse a DSP Template definition memory reference, e.g
    [A0.7+A0.5++]. DSPRAM is set to true by this function if this
    template definition is a DSP RAM template definition.  */
 static const char *
    [A0.7+A0.5++]. DSPRAM is set to true by this function if this
    template definition is a DSP RAM template definition.  */
 static const char *
@@ -4712,7 +4739,7 @@ template_mem_ref(const char *line, metag_addr *addr,
   return l;
 }
 
   return l;
 }
 
-/* Sets LOAD to TRUE if this is a Template load definiton (otherwise
+/* Sets LOAD to TRUE if this is a Template load definition (otherwise
    it's a store). Fills out ADDR, TEMPLATE_REG and ADDR_UNIT.  */
 static const char *
 parse_template_regs (const char *line, bfd_boolean *load,
    it's a store). Fills out ADDR, TEMPLATE_REG and ADDR_UNIT.  */
 static const char *
 parse_template_regs (const char *line, bfd_boolean *load,
@@ -5313,7 +5340,7 @@ parse_dalu (const char *line, metag_insn *insn,
              /* Only MOV instructions have a DSP register as a
                 destination. Set the MOV DSPe.r opcode. The simple
                 OR'ing is OK because the usual MOV opcode is 0x00.  */
              /* Only MOV instructions have a DSP register as a
                 destination. Set the MOV DSPe.r opcode. The simple
                 OR'ing is OK because the usual MOV opcode is 0x00.  */
-             insn->bits = (0x91 << 24);
+             insn->bits = 0x91u << 24;
              du_shift = 0;
              l1_shift = 2;
              regs_shift[0] = 19;
              du_shift = 0;
              l1_shift = 2;
              regs_shift[0] = 19;
@@ -5428,7 +5455,7 @@ parse_dalu (const char *line, metag_insn *insn,
                          du_shift = 0;
                          l1_shift = 2;
                          regs_shift[1] = 14;
                          du_shift = 0;
                          l1_shift = 2;
                          regs_shift[1] = 14;
-                         insn->bits = (0x92 << 24); /* Set opcode.  */
+                         insn->bits = 0x92u << 24; /* Set opcode.  */
                        }
                    }
                }
                        }
                    }
                }
@@ -5479,7 +5506,7 @@ parse_dalu (const char *line, metag_insn *insn,
          insn->bits |= (1 << 2);
        }
 
          insn->bits |= (1 << 2);
        }
 
-      /* Check for template definitons.  */
+      /* Check for template definitions.  */
       if (IS_TEMPLATE_DEF (insn))
        {
          l = interpret_template_regs(l, insn, regs, regs_shift, &load,
       if (IS_TEMPLATE_DEF (insn))
        {
          l = interpret_template_regs(l, insn, regs, regs_shift, &load,
@@ -5599,7 +5626,7 @@ parse_dalu (const char *line, metag_insn *insn,
   if ((template->meta_opcode >> 26) & 0x1)
     ls_shift = INVALID_SHIFT;
 
   if ((template->meta_opcode >> 26) & 0x1)
     ls_shift = INVALID_SHIFT;
 
-  /* The Condition Is Always (CA) bit must be set if we're targetting a
+  /* The Condition Is Always (CA) bit must be set if we're targeting a
      Ux.r register as the destination. This means that we can't have
      any other condition bits set.  */
   if (!is_same_data_unit (regs[1]->unit, regs[0]->unit))
      Ux.r register as the destination. This means that we can't have
      any other condition bits set.  */
   if (!is_same_data_unit (regs[1]->unit, regs[0]->unit))
@@ -5765,7 +5792,7 @@ static const insn_parser insn_parsers[ENC_MAX] =
 
 struct metag_core_option
 {
 
 struct metag_core_option
 {
-  char *name;
+  const char *name;
   unsigned int value;
 };
 
   unsigned int value;
 };
 
@@ -5795,7 +5822,7 @@ static const struct metag_core_option metag_dsps[] =
 
 /* Parse a CPU command line option.  */
 static int
 
 /* Parse a CPU command line option.  */
 static int
-metag_parse_cpu (char * str)
+metag_parse_cpu (const char * str)
 {
   const struct metag_core_option * opt;
   int optlen;
 {
   const struct metag_core_option * opt;
   int optlen;
@@ -5821,7 +5848,7 @@ metag_parse_cpu (char * str)
 
 /* Parse an FPU command line option.  */
 static int
 
 /* Parse an FPU command line option.  */
 static int
-metag_parse_fpu (char * str)
+metag_parse_fpu (const char * str)
 {
   const struct metag_core_option * opt;
   int optlen;
 {
   const struct metag_core_option * opt;
   int optlen;
@@ -5847,7 +5874,7 @@ metag_parse_fpu (char * str)
 
 /* Parse a DSP command line option.  */
 static int
 
 /* Parse a DSP command line option.  */
 static int
-metag_parse_dsp (char * str)
+metag_parse_dsp (const char * str)
 {
   const struct metag_core_option * opt;
   int optlen;
 {
   const struct metag_core_option * opt;
   int optlen;
@@ -5873,10 +5900,10 @@ metag_parse_dsp (char * str)
 
 struct metag_long_option
 {
 
 struct metag_long_option
 {
-  char * option;                /* Substring to match.  */
-  char * help;                  /* Help information.  */
-  int (* func) (char * subopt); /* Function to decode sub-option.  */
-  char * deprecated;            /* If non-null, print this message.  */
+  const char * option;                /* Substring to match.  */
+  const char * help;                  /* Help information.  */
+  int (* func) (const char * subopt); /* Function to decode sub-option.  */
+  const char * deprecated;            /* If non-null, print this message.  */
 };
 
 struct metag_long_option metag_long_opts[] =
 };
 
 struct metag_long_option metag_long_opts[] =
@@ -5891,7 +5918,7 @@ struct metag_long_option metag_long_opts[] =
   };
 
 int
   };
 
 int
-md_parse_option (int c, char * arg)
+md_parse_option (int c, const char * arg)
 {
   struct metag_long_option *lopt;
 
 {
   struct metag_long_option *lopt;
 
@@ -6305,7 +6332,7 @@ create_mnemonic_htab (void)
       insn_templates **slot = NULL;
       insn_templates *new_entry;
 
       insn_templates **slot = NULL;
       insn_templates *new_entry;
 
-      new_entry = xmalloc (sizeof (insn_templates));
+      new_entry = XNEW (insn_templates);
 
       new_entry->template = template;
       new_entry->next = NULL;
 
       new_entry->template = template;
       new_entry->next = NULL;
@@ -6390,7 +6417,7 @@ create_dspreg_htabs (void)
 
       /* Make sure there are no hash table collisions, which would
         require chaining entries.  */
 
       /* Make sure there are no hash table collisions, which would
         require chaining entries.  */
-      BFD_ASSERT (*slot == NULL);
+      gas_assert (*slot == NULL);
       *slot = reg;
     }
 
       *slot = reg;
     }
 
@@ -6413,7 +6440,7 @@ create_dspreg_htabs (void)
 
          /* Make sure there are no hash table collisions, which would
             require chaining entries.  */
 
          /* Make sure there are no hash table collisions, which would
             require chaining entries.  */
-         BFD_ASSERT (*slot == NULL);
+         gas_assert (*slot == NULL);
          *slot = reg;
        }
     }
          *slot = reg;
        }
     }
@@ -6460,7 +6487,7 @@ create_scond_htab (void)
                                                        scond, INSERT);
       /* Make sure there are no hash table collisions, which would
         require chaining entries.  */
                                                        scond, INSERT);
       /* Make sure there are no hash table collisions, which would
         require chaining entries.  */
-      BFD_ASSERT (*slot == NULL);
+      gas_assert (*slot == NULL);
       *slot = scond;
     }
 }
       *slot = scond;
     }
 }
@@ -6678,10 +6705,7 @@ md_number_to_chars (char * buf, valueT val, int n)
    emitted is stored in *sizeP .  An error message is returned, or NULL on OK.
 */
 
    emitted is stored in *sizeP .  An error message is returned, or NULL on OK.
 */
 
-/* Equal to MAX_PRECISION in atof-ieee.c */
-#define MAX_LITTLENUMS 6
-
-char *
+const char *
 md_atof (int type, char * litP, int * sizeP)
 {
   int              i;
 md_atof (int type, char * litP, int * sizeP)
 {
   int              i;
@@ -6821,7 +6845,7 @@ md_convert_frag (bfd * abfd ATTRIBUTE_UNUSED, segT sec ATTRIBUTE_UNUSED,
 void
 metag_handle_align (fragS * fragP)
 {
 void
 metag_handle_align (fragS * fragP)
 {
-  static char const noop[4] = { 0xfe, 0xff, 0xff, 0xa0 };
+  static unsigned char const noop[4] = { 0xfe, 0xff, 0xff, 0xa0 };
   int bytes, fix;
   char *p;
 
   int bytes, fix;
   char *p;
 
@@ -6853,7 +6877,7 @@ metag_handle_align (fragS * fragP)
 }
 
 static char *
 }
 
 static char *
-metag_end_of_match (char * cont, char * what)
+metag_end_of_match (char * cont, const char * what)
 {
   int len = strlen (what);
 
 {
   int len = strlen (what);
 
@@ -6976,14 +7000,12 @@ metag_parse_name (char const * name, expressionS * exprP, enum expr_mode mode,
    then it is done here.  */
 
 arelent *
    then it is done here.  */
 
 arelent *
-tc_gen_reloc (seg, fixp)
-     asection *seg ATTRIBUTE_UNUSED;
-     fixS *fixp;
+tc_gen_reloc (asection *seg ATTRIBUTE_UNUSED, fixS *fixp)
 {
   arelent *reloc;
 
 {
   arelent *reloc;
 
-  reloc                      = (arelent *) xmalloc (sizeof (arelent));
-  reloc->sym_ptr_ptr  = (asymbol **) xmalloc (sizeof (asymbol *));
+  reloc                      = XNEW (arelent);
+  reloc->sym_ptr_ptr  = XNEW (asymbol *);
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
 
   *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
   reloc->address      = fixp->fx_frag->fr_address + fixp->fx_where;
 
@@ -7086,6 +7108,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg ATTRIBUTE_UNUSED)
       break;
     case BFD_RELOC_64:
       md_number_to_chars (buf, value, 8);
       break;
     case BFD_RELOC_64:
       md_number_to_chars (buf, value, 8);
+      break;
 
     case BFD_RELOC_METAG_RELBRANCH:
       if (!value)
 
     case BFD_RELOC_METAG_RELBRANCH:
       if (!value)
This page took 0.029987 seconds and 4 git commands to generate.