Add big-endian support for tilegx.
[deliverable/binutils-gdb.git] / gas / config / tc-tilegx.c
index 39e1907322d237baa4dfcf76ba24cce0d4b1f7d5..01237d1286365542dd9fb78f1af708a4c75595c6 100644 (file)
@@ -72,12 +72,18 @@ static int tilegx_arch_size = 64;
 const char *
 tilegx_target_format (void)
 {
-  return tilegx_arch_size == 64 ? "elf64-tilegx" : "elf32-tilegx";
+    if (target_big_endian) {
+        return tilegx_arch_size == 64 ? "elf64-tilegx-be" : "elf32-tilegx-be";
+    } else {
+        return tilegx_arch_size == 64 ? "elf64-tilegx-le" : "elf32-tilegx-le";
+    }
 }
 
 
 #define OPTION_32 (OPTION_MD_BASE + 0)
 #define OPTION_64 (OPTION_MD_BASE + 1)
+#define OPTION_EB (OPTION_MD_BASE + 2)
+#define OPTION_EL (OPTION_MD_BASE + 3)
 
 const char *md_shortopts = "VQ:";
 
@@ -85,6 +91,8 @@ struct option md_longopts[] =
 {
   {"32", no_argument, NULL, OPTION_32},
   {"64", no_argument, NULL, OPTION_64},
+  {"EB", no_argument, NULL, OPTION_EB },
+  {"EL", no_argument, NULL, OPTION_EL },
   {NULL, no_argument, NULL, 0}
 };
 
@@ -113,6 +121,14 @@ md_parse_option (int c, char *arg ATTRIBUTE_UNUSED)
       tilegx_arch_size = 64;
       break;
 
+    case OPTION_EB:
+      target_big_endian = 1;
+      break;
+
+    case OPTION_EL:
+      target_big_endian = 0;
+      break;
+
     default:
       return 0;
     }
@@ -126,6 +142,7 @@ md_show_usage (FILE *stream)
   fprintf (stream, _("\
   -Q                      ignored\n\
   -V                      print assembler version number\n\
+  -EB/-EL                 generate big-endian/little-endian code\n\
   --32/--64               generate 32bit/64bit code\n"));
 }
 
@@ -241,6 +258,10 @@ md_begin (void)
 {
   const struct tilegx_opcode *op;
   int i;
+  int mach = (tilegx_arch_size == 64) ? bfd_mach_tilegx : bfd_mach_tilegx32;
+
+  if (! bfd_set_arch_mach (stdoutput, bfd_arch_tilegx, mach))
+    as_warn (_("Could not set architecture and machine"));
 
   /* Guarantee text section is aligned.  */
   bfd_set_section_alignment (stdoutput, text_section,
@@ -1265,6 +1286,15 @@ const pseudo_typeS md_pseudo_table[] =
 /* Equal to MAX_PRECISION in atof-ieee.c  */
 #define MAX_LITTLENUMS 6
 
+void
+md_number_to_chars (char * buf, valueT val, int n)
+{
+  if (target_big_endian)
+    number_to_chars_bigendian (buf, val, n);
+  else
+    number_to_chars_littleendian (buf, val, n);
+}
+
 /* Turn the string pointed to by litP into a floating point constant
    of type TYPE, and emit the appropriate bytes.  The number of
    LITTLENUMS emitted is stored in *SIZEP.  An error message is
This page took 0.023956 seconds and 4 git commands to generate.