Support Intel FRED LKGS
[binutils-gdb.git] / gas / config / tc-xtensa.c
index 978704e5c842b2957371684dfdf8b66baccd8c8c..550c8256e3f01df420276f70940aa3f59e25ce7d 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-xtensa.c -- Assemble Xtensa instructions.
-   Copyright (C) 2003-2021 Free Software Foundation, Inc.
+   Copyright (C) 2003-2023 Free Software Foundation, Inc.
 
    This file is part of GAS, the GNU Assembler.
 
 #include "xtensa-relax.h"
 #include "dwarf2dbg.h"
 #include "xtensa-istack.h"
-#include "xtensa-config.h"
+#include "xtensa-dynconfig.h"
 #include "elf/xtensa.h"
 
-/* Provide default values for new configuration settings.  */
-#ifndef XTHAL_ABI_WINDOWED
-#define XTHAL_ABI_WINDOWED 0
-#endif
-
-#ifndef XTHAL_ABI_CALL0
-#define XTHAL_ABI_CALL0 1
-#endif
-
-#ifndef XTENSA_MARCH_EARLIEST
-#define XTENSA_MARCH_EARLIEST 0
-#endif
-
 #ifndef uint32
 #define uint32 unsigned int
 #endif
@@ -94,7 +81,7 @@ static enum debug_info_type xt_saved_debug_type = DEBUG_NONE;
 /* Some functions are only valid in the front end.  This variable
    allows us to assert that we haven't crossed over into the
    back end.  */
-static bool past_xtensa_end = false;
+static bool past_xtensa_md_finish = false;
 
 /* Flags for properties of the last instruction in a segment.  */
 #define FLAG_IS_A0_WRITER      0x1
@@ -1189,9 +1176,9 @@ const pseudo_typeS md_pseudo_table[] =
 static bool
 use_transform (void)
 {
-  /* After md_end, you should be checking frag by frag, rather
+  /* After md_finish, you should be checking frag by frag, rather
      than state directives.  */
-  gas_assert (!past_xtensa_end);
+  gas_assert (!past_xtensa_md_finish);
   return directive_state[directive_transform];
 }
 
@@ -1199,10 +1186,10 @@ use_transform (void)
 static bool
 do_align_targets (void)
 {
-  /* Do not use this function after md_end; just look at align_targets
+  /* Do not use this function after md_finish; just look at align_targets
      instead.  There is no target-align directive, so alignment is either
      enabled for all frags or not done at all.  */
-  gas_assert (!past_xtensa_end);
+  gas_assert (!past_xtensa_md_finish);
   return align_targets && use_transform ();
 }
 
@@ -1293,7 +1280,7 @@ get_directive (directiveE *directive, bool *negated)
   unsigned i;
   const char *directive_string;
 
-  if (strncmp (input_line_pointer, "no-", 3) != 0)
+  if (!startswith (input_line_pointer, "no-"))
     *negated = false;
   else
     {
@@ -1308,12 +1295,12 @@ get_directive (directiveE *directive, bool *negated)
      equivalent to .begin [no-]transform.  We should remove it when
      we stop accepting those options.  */
 
-  if (strncmp (input_line_pointer, "generics", strlen ("generics")) == 0)
+  if (startswith (input_line_pointer, "generics"))
     {
       as_warn (_("[no-]generics is deprecated; use [no-]transform instead"));
       directive_string = "transform";
     }
-  else if (strncmp (input_line_pointer, "relax", strlen ("relax")) == 0)
+  else if (startswith (input_line_pointer, "relax"))
     {
       as_warn (_("[no-]relax is deprecated; use [no-]transform instead"));
       directive_string = "transform";
@@ -2893,7 +2880,7 @@ static bool
 xg_instruction_matches_option_term (TInsn *insn, const ReqOrOption *option)
 {
   if (strcmp (option->option_name, "realnop") == 0
-      || strncmp (option->option_name, "IsaUse", 6) == 0)
+      || startswith (option->option_name, "IsaUse"))
     {
       /* These conditions were evaluated statically when building the
         relaxation table.  There's no need to reevaluate them now.  */
@@ -4552,7 +4539,7 @@ is_unaligned_label (symbolS *sym)
       && (name[fake_size] == 'F'
          || name[fake_size] == 'L'
          || (name[fake_size] == 'e'
-             && strncmp ("endfunc", name+fake_size, 7) == 0)))
+             && startswith (name + fake_size, "endfunc"))))
     return true;
 
   return false;
@@ -4980,7 +4967,7 @@ xtensa_set_frag_assembly_state (fragS *fragP)
     fragP->tc_frag_data.is_no_density = true;
 
   /* This function is called from subsegs_finish, which is called
-     after xtensa_end, so we can't use "use_transform" or
+     after xtensa_md_finish, so we can't use "use_transform" or
      "use_schedule" here.  */
   if (!directive_state[directive_transform])
     fragP->tc_frag_data.is_no_transform = true;
@@ -6006,7 +5993,7 @@ md_apply_fix (fixS *fixP, valueT *valP, segT seg)
   if (fixP->fx_subsy && !(linkrelax && (fixP->fx_r_type == BFD_RELOC_32
                                        || fixP->fx_r_type == BFD_RELOC_16
                                        || fixP->fx_r_type == BFD_RELOC_8)))
-    as_bad_where (fixP->fx_file, fixP->fx_line, _("expression too complex"));
+    as_bad_subtract (fixP);
 
   switch (fixP->fx_r_type)
     {
@@ -6600,7 +6587,7 @@ find_vinsn_conflicts (vliw_insn *vinsn)
   int branches = 0;
   xtensa_isa isa = xtensa_default_isa;
 
-  gas_assert (!past_xtensa_end);
+  gas_assert (!past_xtensa_md_finish);
 
   for (i = 0 ; i < vinsn->num_slots; i++)
     {
@@ -7369,7 +7356,7 @@ xg_assemble_vliw_tokens (vliw_insn *vinsn)
 }
 
 \f
-/* xtensa_end and helper functions.  */
+/* xtensa_md_finish and helper functions.  */
 
 static void xtensa_cleanup_align_frags (void);
 static void xtensa_fix_target_frags (void);
@@ -7384,12 +7371,12 @@ static void xtensa_sanity_check (void);
 static void xtensa_add_config_info (void);
 
 void
-xtensa_end (void)
+xtensa_md_finish (void)
 {
   directive_balance ();
   xtensa_flush_pending_output ();
 
-  past_xtensa_end = true;
+  past_xtensa_md_finish = true;
 
   xtensa_move_literals ();
 
@@ -7927,7 +7914,7 @@ xtensa_maybe_create_literal_pool_frag (bool create, bool only_if_needed)
     {
       if (only_if_needed)
        {
-         if (past_xtensa_end || !use_transform() ||
+         if (past_xtensa_md_finish || !use_transform() ||
              frag_now->tc_frag_data.is_no_transform)
            {
              return;
@@ -8616,6 +8603,7 @@ unrelaxed_frag_max_size (fragS *fragP)
     case rs_leb128:
     case rs_cfa:
     case rs_dwarf2dbg:
+    case rs_sframe:
       /* No further adjustments needed.  */
       break;
     case rs_machine_dependent:
@@ -11690,11 +11678,11 @@ cache_literal_section (bool use_abs_literals)
       size_t len = strlen (text_name);
       if (len >= 5
          && (strcmp (text_name + len - 5, ".text") == 0
-             || strncmp (text_name, ".text", 5) == 0))
+             || startswith (text_name, ".text")))
        len -= 5;
 
       name = XNEWVEC (char, len + strlen (base_name) + 1);
-      if (strncmp (text_name, ".text", 5) == 0)
+      if (startswith (text_name, ".text"))
        {
          strcpy (name, base_name);
          strcat (name, text_name + 5);