This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

PATCH: MIPS option parsing [dmj+@andrew.cmu.edu: Re: option stuff]


After talking with Thiemo and Eric off-list, I've committed this patch
for pre-gcc-3.1 command line compatibility.  Eric approved it (groaning
and wincing all the while).

----- Forwarded message from Daniel Jacobowitz <dmj+@andrew.cmu.edu> -----

Date: Sun, 9 Dec 2001 19:36:46 -0500
From: Daniel Jacobowitz <dmj+@andrew.cmu.edu>
Subject: Re: option stuff
To: Eric Christopher <echristo@redhat.com>
Cc: Thiemo Seufer <ica2_ts@csv.ica.uni-stuttgart.de>

On Wed, Nov 28, 2001 at 10:16:44PM -0800, Eric Christopher wrote:
> 
> 
> > 
> > 2001-11-29  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
> > 	    Daniel Jacobowitz <drow@mvista.com>
> > 
> > 	/gas/ChangeLog
> > 	* config/tc-mips.c (file_mips_gp32): Initialize to invalid value.
> > 	(file_mips_gp32): Likewise.
> > 	(HAVE_32BIT_GPRS): Remove check for o32 ABI.
> > 	(HAVE_32BIT_FPRS): Likewise.
> > 	(md_begin): Register width compatibility handling for -mipsN option.
> > 	Restrict register width to 32bit for o32 ABI.
> > 	(s_mipsset): Remove check for o32 ABI.
> 
> Looks better.It only solves the register width problem though. We still
> need to solve the ISA incompatibilities. We need cpu to set tune and
> arch, with -mipsX overriding arch.

So close...

I hit an inconsistency.  MIPS32 is marked !ISA_HAS_64BIT_REGS.  But
they normally run with file_mips_gp32 == 0.  The patch will default it
to 1.  This should (I hope) make no difference, because of
HAVE_32BIT_GPRS also checking the ISA.  Also, testsuite entries start
failing, because the file is tagged as O32 rather than as noabi.

Similarly if I default to O64 for MIPS64 I have a problem.

If I include the bits of that patch which remove checks for o32 ABI, I
run in to another problem.

So here's another try.  This is what it does:
  - If -mipsN is not specified, behaviour unchanged.
  - If it is specified:
    - Default gp32/fp32 according to ISA_HAS_64BIT_REGS
    - Default -march= to that matching -mipsN (-mcpu will still set
      -march, but only if -mipsN didn't)
    - Default -mtune to -mcpu or -march, not -mipsN
    - If the ISA is mips1 or mips2, default to o32.  If the ISA is
      mips3 or mips4, default to o64.  Otherwise default to NO_ABI.

Thoughts?

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer

2001-12-09  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>
	    Daniel Jacobowitz <drow@mvista.com>

	* config/tc-mips.c (file_mips_gp32): Initialize to invalid value.
	(file_mips_fp32): Likewise.
	(md_begin): Compatibility handling for -mipsN option.

Index: tc-mips.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-mips.c,v
retrieving revision 1.102
diff -p -u -r1.102 tc-mips.c
--- tc-mips.c	2001/12/04 14:38:48	1.102
+++ tc-mips.c	2001/12/10 00:33:53
@@ -174,10 +174,10 @@ struct mips_set_options
 };
 
 /* True if -mgp32 was passed.  */
-static int file_mips_gp32 = 0;
+static int file_mips_gp32 = -1;
 
 /* True if -mfp32 was passed.  */
-static int file_mips_fp32 = 0;
+static int file_mips_fp32 = -1;
 
 /* This is the struct we use to hold the current set of options.  Note
    that we must set the isa field to ISA_UNKNOWN and the mips16 field to
@@ -1056,6 +1056,46 @@ md_begin ()
 		  "Use -march instead of -mcpu."));
     }
 
+#if 1
+  /* For backward compatibility, let -mipsN set various defaults.  */
+  /* This code should go away, to be replaced with something rather more
+     draconian.  Until GCC 3.1 has been released for some reasonable
+     amount of time, however, we need to support this.  */
+  if (mips_opts.isa != ISA_UNKNOWN)
+    {
+      /* Translate -mipsN to the appropriate settings of file_mips_gp32
+	 and file_mips_fp32.  Tag binaries as using the mipsN ISA.  */
+      if (file_mips_gp32 < 0)
+	{
+	  if (ISA_HAS_64BIT_REGS (mips_opts.isa))
+	    file_mips_gp32 = 0;
+	  else
+	    file_mips_gp32 = 1;
+	}
+      if (file_mips_fp32 < 0)
+	{
+	  if (ISA_HAS_64BIT_REGS (mips_opts.isa))
+	    file_mips_fp32 = 0;
+	  else
+	    file_mips_fp32 = 1;
+	}
+
+      ci = mips_cpu_info_from_isa (mips_opts.isa);
+      assert (ci != NULL);
+      /* -mipsN has higher priority than -mcpu but lower than -march.  */
+      if (mips_arch == CPU_UNKNOWN)
+	mips_arch = ci->cpu;
+
+      /* Default mips_abi.  */
+      if (mips_opts.abi == NO_ABI)
+	{
+	  if (mips_opts.isa == ISA_MIPS1 || mips_opts.isa == ISA_MIPS2)
+	    mips_opts.abi = O32_ABI;
+	  else if (mips_opts.isa == ISA_MIPS3 || mips_opts.isa == ISA_MIPS4)
+	    mips_opts.abi = O64_ABI;
+	}
+    }
+
   if (mips_arch == CPU_UNKNOWN && mips_cpu != CPU_UNKNOWN)
     {
       ci = mips_cpu_info_from_cpu (mips_cpu);
@@ -1065,11 +1105,37 @@ md_begin ()
 		 "-mtune instead."));
     }
 
+  /* Set tune from -mcpu, not from -mipsN.  */
+  if (mips_tune == CPU_UNKNOWN && mips_cpu != CPU_UNKNOWN)
+    {
+      ci = mips_cpu_info_from_cpu (mips_cpu);
+      assert (ci != NULL);
+      mips_tune = ci->cpu;
+    }
+
   /* At this point, mips_arch will either be CPU_UNKNOWN if no ARCH was
      specified on the command line, or some other value if one was.
      Similarly, mips_opts.isa will be ISA_UNKNOWN if not specified on
      the command line, or will be set otherwise if one was.  */
+
   if (mips_arch != CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
+    /* Handled above.  */;
+#else
+  if (mips_arch == CPU_UNKNOWN && mips_cpu != CPU_UNKNOWN)
+    {
+      ci = mips_cpu_info_from_cpu (mips_cpu);
+      assert (ci != NULL);
+      mips_arch = ci->cpu;
+      as_warn (_("The -mcpu option is deprecated.  Please use -march and "
+		 "-mtune instead."));
+    }
+
+  /* At this point, mips_arch will either be CPU_UNKNOWN if no ARCH was
+     specified on the command line, or some other value if one was.
+     Similarly, mips_opts.isa will be ISA_UNKNOWN if not specified on
+     the command line, or will be set otherwise if one was.  */
+
+  if (mips_arch != CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
     {
       /* We have to check if the isa is the default isa of arch.  Otherwise
          we'll get invalid object file headers.  */
@@ -1089,6 +1155,7 @@ md_begin ()
 	  mips_arch = ci->cpu;
 	}
     }
+#endif
   else if (mips_arch != CPU_UNKNOWN && mips_opts.isa == ISA_UNKNOWN)
     {
       /* We have ARCH, we need ISA.  */
@@ -1149,6 +1216,11 @@ md_begin ()
 
   if (! bfd_set_arch_mach (stdoutput, bfd_arch_mips, mips_arch))
     as_warn (_("Could not set architecture and machine"));
+
+  if (file_mips_gp32 < 0)
+    file_mips_gp32 = 0;
+  if (file_mips_fp32 < 0)
+    file_mips_fp32 = 0;
 
   file_mips_isa = mips_opts.isa;
   file_mips_abi = mips_opts.abi;

----- End forwarded message -----

-- 
Daniel Jacobowitz                           Carnegie Mellon University
MontaVista Software                         Debian GNU/Linux Developer


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]