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]

Re: Patch: mips gas reorg


Eric Christopher wrote:
[snip]
>     	(md_begin): Handle mips_arch, mips_tune and mips_cpu.  For
>     	backwards compatability mips_cpu generates arch and tune.

I'm not satisfied with the logic implemented here:

[snip]
> -  /* At this point, mips_cpu will either be CPU_UNKNOWN if no CPU was
> +  /* 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_cpu != CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
> +  if (mips_arch != CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
>      {
>        /* We have it all.  There's nothing to do.  */
>      }
> -  else if (mips_cpu != CPU_UNKNOWN && mips_opts.isa == ISA_UNKNOWN)
> +  else if (mips_arch != CPU_UNKNOWN && mips_opts.isa == ISA_UNKNOWN)
>      {
> -      /* We have CPU, we need ISA.  */
> -      ci = mips_cpu_info_from_cpu (mips_cpu);
> +      /* We have ARCH, we need ISA.  */
> +      ci = mips_cpu_info_from_cpu (mips_arch);
>        assert (ci != NULL);
>        mips_opts.isa = ci->isa;
>      }
> -  else if (mips_cpu == CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
> +  else if (mips_arch == CPU_UNKNOWN && mips_opts.isa != ISA_UNKNOWN)
>      {
> -      /* We have ISA, we need default CPU.  */
> +      /* We have ISA, we need default ARCH.  */
>        ci = mips_cpu_info_from_isa (mips_opts.isa);
> +      assert (ci != NULL);
> +      mips_arch = ci->cpu;
> +    }
> +  else if (mips_arch == CPU_UNKNOWN
> +	   && mips_opts.isa == ISA_UNKNOWN
> +	   && mips_cpu != CPU_UNKNOWN)
> +    {
> +      /* Historic -mcpu= option.  Warn.  */
> +      ci = mips_cpu_info_from_cpu (mips_cpu);
>        assert (ci != NULL);
> -      mips_cpu = ci->cpu;
> +      mips_arch = ci->cpu;
> +      mips_tune = ci->cpu;
> +      mips_opts.isa = ci->isa;
> +      as_warn (_("The -mcpu option is deprecated.  Please use -march and -mtune instead."));
> +
>      }
>    else
>      {
> -      /* We need to set both ISA and CPU from target cpu.  */
> +      /* We need to set both ISA and ARCH from target cpu.  */
>        ci = mips_cpu_info_from_name (cpu);
>        if (ci == NULL)
>  	ci = mips_cpu_info_from_cpu (CPU_R3000);
>        assert (ci != NULL);
>        mips_opts.isa = ci->isa;
> -      mips_cpu = ci->cpu;
> +      mips_arch = ci->cpu;
>      }

It results in silently ignoring the -mcpu switch if an isa is
specified. E.g. '-mips4 -mcpu=r10000' produces code for r8000
without a warning, which breaks backward compatibility.

A simple fix would be doing the check for -mcpu first, I did
so in the appended patch.


Thiemo


2001-07-02  Thiemo Seufer <seufer@csv.ica.uni-stuttgart.de>

	/gas/ChangeLog
	* config/tc-mips.c (md_begin): Take -mcpu value into account even when
	-mipsX is specified.


--- tc-mips.c.orig	Mon Jul  2 19:24:48 2001
+++ tc-mips.c	Mon Jul  2 19:39:06 2001
@@ -967,6 +967,16 @@
   if (mips_opts.mips16 < 0)
     mips_opts.mips16 = target_cpu_had_mips16;
 
+  /* Backward compatibility for historic -mcpu= option.  Warn.  */
+  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
@@ -988,19 +998,6 @@
       ci = mips_cpu_info_from_isa (mips_opts.isa);
       assert (ci != NULL);
       mips_arch = ci->cpu;
-    }
-  else if (mips_arch == CPU_UNKNOWN
-	   && mips_opts.isa == ISA_UNKNOWN
-	   && mips_cpu != CPU_UNKNOWN)
-    {
-      /* Historic -mcpu= option.  Warn.  */
-      ci = mips_cpu_info_from_cpu (mips_cpu);
-      assert (ci != NULL);
-      mips_arch = ci->cpu;
-      mips_tune = ci->cpu;
-      mips_opts.isa = ci->isa;
-      as_warn (_("The -mcpu option is deprecated.  Please use -march and -mtune instead."));
-
     }
   else
     {


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