[2/5] gas: xtensa: add endianness, loops, booleans options

Message ID 63f2699e6ef3e6d1ca415a6ed1187d4f64297521.camel@espressif.com
State Unresolved
Headers
Series Add Xtensa ESP chips support |

Checks

Context Check Description
snail/binutils-gdb-check warning Git am fail log

Commit Message

Alexey Lapshin Oct. 22, 2022, 12:55 p.m. UTC
  Added additional assembley options for a better flexibility.

---
 gas/config/tc-xtensa.c    | 53 ++++++++++++++++++++++++++++++++++++---
 gas/config/tc-xtensa.h    |  2 +-
 gas/config/xtensa-relax.c |  8 ++++--
 3 files changed, 57 insertions(+), 6 deletions(-)

-- 
2.34.1
  

Patch

diff --git a/gas/config/tc-xtensa.c b/gas/config/tc-xtensa.c
index df6a3cec8a1..630d147bf63 100644
--- a/gas/config/tc-xtensa.c
+++ b/gas/config/tc-xtensa.c
@@ -89,6 +89,9 @@  static vliw_insn cur_vinsn;
 unsigned xtensa_num_pipe_stages;
 unsigned xtensa_fetch_width;
 
+unsigned target_have_booleans = XCHAL_HAVE_LOOPS;
+unsigned target_have_loops = XCHAL_HAVE_BOOLEANS;
+
 static enum debug_info_type xt_saved_debug_type = DEBUG_NONE;
 
 /* Some functions are only valid in the front end.  This variable
@@ -746,6 +749,15 @@  enum
 
   option_abi_windowed,
   option_abi_call0,
+
+  option_eb,
+  option_el,
+
+  option_loops,
+  option_no_loops,
+
+  option_booleans,
+  option_no_booleans,
 };
 
 const char *md_shortopts = "";
@@ -830,6 +842,15 @@  struct option md_longopts[] =
   { "abi-windowed", no_argument, NULL, option_abi_windowed },
   { "abi-call0", no_argument, NULL, option_abi_call0 },
 
+  { "EL", no_argument, NULL, option_el },
+  { "EB", no_argument, NULL, option_eb },
+
+  { "loops", no_argument, NULL, option_loops },
+  { "no-loops", no_argument, NULL, option_no_loops },
+
+  { "booleans", no_argument, NULL, option_booleans },
+  { "no-booleans", no_argument, NULL, option_no_booleans },
+
   { NULL, no_argument, NULL, 0 }
 };
 
@@ -1066,6 +1087,30 @@  md_parse_option (int c, const char *arg)
       elf32xtensa_abi = XTHAL_ABI_CALL0;
       return 1;
 
+    case option_eb:
+      target_big_endian = 1;
+      return 1;
+
+    case option_el:
+      target_big_endian = 0;
+      return 1;
+
+    case option_loops:
+      target_have_loops = 1;
+      return 1;
+
+    case option_no_loops:
+      target_have_loops = 0;
+      return 1;
+
+    case option_booleans:
+      target_have_booleans = 1;
+      return 1;
+
+    case option_no_booleans:
+      target_have_booleans = 0;
+      return 1;
+
     default:
       return 0;
     }
@@ -1100,7 +1145,11 @@  Xtensa options:\n\
   --[no-]separate-prop-tables\n\
                           [Do not] place Xtensa property records into\n\
                           individual property sections for each section.\n\
-                          Default is to generate single property section.\n", stream);
+                          Default is to generate single property section.\n\
+  --EB                    Generate code for a big endian machine.\n\
+  --EL                    Generate code for a little endian machine.\n\
+  --[no-]booleans         [Do not] use boolean registers.\n\
+  --[no-]loops            [Do not] zero-overhead loops.\n", stream);
 }
 
 
@@ -5268,8 +5317,6 @@  md_number_to_chars (char *buf, valueT val, int n)
 static void
 xg_init_global_config (void)
 {
-  target_big_endian = XCHAL_HAVE_BE;
-
   density_supported = XCHAL_HAVE_DENSITY;
   absolute_literals_supported = XSHAL_USE_ABSOLUTE_LITERALS;
   xtensa_fetch_width = XCHAL_INST_FETCH_WIDTH;
diff --git a/gas/config/tc-xtensa.h b/gas/config/tc-xtensa.h
index 1887558ecf1..914f4565c52 100644
--- a/gas/config/tc-xtensa.h
+++ b/gas/config/tc-xtensa.h
@@ -30,7 +30,7 @@  struct fix;
 #include "xtensa-isa.h"
 #include "xtensa-config.h"
 
-#define TARGET_BYTES_BIG_ENDIAN 0
+#define TARGET_BYTES_BIG_ENDIAN XCHAL_HAVE_BE
 
 
 /* Maximum number of opcode slots in a VLIW instruction.  */
diff --git a/gas/config/xtensa-relax.c b/gas/config/xtensa-relax.c
index 0682b29f815..aad9ae7d348 100644
--- a/gas/config/xtensa-relax.c
+++ b/gas/config/xtensa-relax.c
@@ -102,6 +102,10 @@ 
 /* Imported from bfd.  */
 extern xtensa_isa xtensa_default_isa;
 
+/* Imported from tc-xtensa.  */
+extern unsigned target_have_booleans;
+extern unsigned target_have_loops;
+
 /* The opname_list is a small list of names that we use for opcode and
    operand variable names to simplify ownership of these commonly used
    strings.  Strings entered in the table can be compared by pointer
@@ -1569,7 +1573,7 @@  transition_applies (insn_pattern *initial_insn,
 	  else if (!strcmp (option_name, "Const16"))
 	    option_available = (XCHAL_HAVE_CONST16 == 1);
 	  else if (!strcmp (option_name, "Loops"))
-	    option_available = (XCHAL_HAVE_LOOPS == 1);
+	    option_available = (target_have_loops == 1);
 	  else if (!strcmp (option_name, "WideBranches"))
 	    option_available
 	      = (XCHAL_HAVE_WIDE_BRANCHES == 1 && produce_flix == FLIX_ALL);
@@ -1578,7 +1582,7 @@  transition_applies (insn_pattern *initial_insn,
 	      = (XCHAL_HAVE_PREDICTED_BRANCHES == 1
 		 && produce_flix == FLIX_ALL);
 	  else if (!strcmp (option_name, "Booleans"))
-	    option_available = (XCHAL_HAVE_BOOLEANS == 1);
+	    option_available = (target_have_booleans == 1);
 	  else
 	    as_warn (_("invalid configuration option '%s' in transition rule '%s'"),
 		     req_or_option->option_name, from_string);