[PATCH v3] MIPS: add .module mipsREV to all output asm file

YunQiang Su yunqiang.su@cipunited.com
Fri Aug 27 09:21:49 GMT 2021


Currently, the asm output file for MIPS has no rev info.
It can make some trouble, for example:
  assembler is mips1 by default,
  gcc is fpxx by default.
To assemble the output of gcc -S, we have to pass -mips2
to assembler.

gcc/ChangeLog:

    * gcc/config/mips/mips.c (mips_module_isa_name): New.
        mips_file_start: add .module mipsREV to all asm output
---
 gcc/config/mips/mips.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/gcc/config/mips/mips.c b/gcc/config/mips/mips.c
index 2f7ffe846..47c149eac 100644
--- a/gcc/config/mips/mips.c
+++ b/gcc/config/mips/mips.c
@@ -9841,6 +9841,32 @@ mips_mdebug_abi_name (void)
     }
 }
 
+static const char *
+mips_module_isa_name ()
+{
+  switch (mips_isa)
+    {
+    case 1:	return "mips1";
+    case 2:	return "mips2";
+    case 3:	return "mips3";
+    case 4:	return "mips4";
+    case 32:	return "mips32";
+    case 33:	return "mips32r2";
+    case 34:	return "mips32r3";
+    /* 35:r4 is skipped */
+    case 36:	return "mips32r5";
+    case 37:	return "mips32r6";
+    case 64:	return "mips64";
+    case 65:	return "mips64r2";
+    case 66:	return "mips64r3";
+    case 67:	return "mips64r5";
+    /* 68:r4 is skipped */
+    case 69:	return "mips64r6";
+    default:
+      gcc_unreachable ();
+    }
+}
+
 /* Implement TARGET_ASM_FILE_START.  */
 
 static void
@@ -9872,6 +9898,9 @@ mips_file_start (void)
     fprintf (asm_out_file, "\t.nan\t%s\n",
 	     mips_nan == MIPS_IEEE_754_2008 ? "2008" : "legacy");
 
+  fprintf (asm_out_file, "\t.module\t%s\n",
+	   mips_module_isa_name ());
+
 #ifdef HAVE_AS_DOT_MODULE
   /* Record the FP ABI.  See below for comments.  */
   if (TARGET_NO_FLOAT)
-- 
2.30.2



More information about the Gcc-patches mailing list