diff mbox

[m68k] Fix option handling for -m68020-40 and -m68020-60

Message ID 5086DD70.3010603@users.sourceforge.net
State New
Headers show

Commit Message

Gunther Nikl Oct. 23, 2012, 6:09 p.m. UTC
Hello,

While working with GCC 4.7, I noticed that the -m68020-40 and -m68020-60
options are broken. This bug was introduced in May 2011 with the patch
at <http://gcc.gnu.org/ml/gcc-patches/2011-04/msg02278.html>. The code
in m68k_option_override to set cpu and tune doesn't trigger when using
-m68020-40 and -m68020-60 since global_options_set is not touched by
the evaluation code for -m68020-40 and -m68020-60 in m68k_handle_option.
This patch was tested by checking the -dM output of a patched cc1 for
the present __mc680X0__ macros.


Regards,
Gunther Nikl

-- cut --
2012-10-23  Gunther Nikl  <gnikl@users.sourceforge.net>

	* common/config/m68k/m68k-common.c (m68k_handle_option): Set
	gcc_options fields of opts_set for -m68020-40 and -m68020-60.

-- cut --
-- cut --

Comments

Andreas Schwab Oct. 23, 2012, 8:02 p.m. UTC | #1
Gunther Nikl <gnikl@users.sourceforge.net> writes:

> While working with GCC 4.7, I noticed that the -m68020-40 and -m68020-60
> options are broken.

Broken in which way?

Andreas.
Gunther Nikl Oct. 25, 2012, 3:33 p.m. UTC | #2
Andreas Schwab wrote:
> Gunther Nikl <gnikl@users.sourceforge.net> writes:
> 
>> While working with GCC 4.7, I noticed that the -m68020-40 and -m68020-60
>> options are broken.
> 
> Broken in which way?

These compound options are supposed to cause m68k.c/m68k_option_override
to set m68k_cpu_entry and m68k_tune_entry. However that code does only
trigger if cpu/tune fields in global_options_set are nonzero which only
happens if -mcpu=/-mtune= are used. My patch for m68k_handle_option
simply sets cpu and tune fields in the provided opts_set function
argument.

The bug is more visible with a compiler configured for a plain 68000
because such a compiler will generate normal 68000 code despite
requesting 68020 code with -m68020-40 or -m68020-60. The bug can also
be seen with a compiler defaulting to 68020 code because the expected
mc680x0 macros are not present. eg.

  m68k-elf-gcc -m68020-40 -x c /dev/null -E -dM -o - | grep mc68

will only show __mc68020__, but __mc680[34]0__ should be defined
as well, see m68k.h/TARGET_CPU_CPP_BUILTINS.

The patch should be installed on trunk and on the 4.7 branch.


Regards,
Gunther
Andreas Schwab Oct. 26, 2012, 7:13 p.m. UTC | #3
Gunther Nikl <gnikl@users.sourceforge.net> writes:

> The patch should be installed on trunk and on the 4.7 branch.

Thanks, done.  The 4.7 branch required some adjustment, since it's not
compiled as C++.

Andreas.
Gunther Nikl Oct. 28, 2012, 11:56 a.m. UTC | #4
Andreas Schwab wrote:
> Gunther Nikl <gnikl@users.sourceforge.net> writes:
> 
>> The patch should be installed on trunk and on the 4.7 branch.
> 
> Thanks, done.  The 4.7 branch required some adjustment, since it's not
> compiled as C++.

Right. Maybe a better solution would have been then to only change
m68k.c/m68k_option_override to additionally check for -m68020-[46]0
in global_options_set when setting cpu and tune entries.

Thank you for taking care of the patch. Sorry that I didn't remember
to adjust the copyright year.

Regards,
Gunther Nikl
diff mbox

Patch

Index: common/config/m68k/m68k-common.c
===================================================================
--- common/config/m68k/m68k-common.c	(revision 192718)
+++ common/config/m68k/m68k-common.c	(working copy)
@@ -33,7 +33,7 @@ 

 static bool
 m68k_handle_option (struct gcc_options *opts,
-		    struct gcc_options *opts_set ATTRIBUTE_UNUSED,
+		    struct gcc_options *opts_set,
 		    const struct cl_decoded_option *decoded,
 		    location_t loc)
 {
@@ -45,12 +45,16 @@ 
     {
     case OPT_m68020_40:
       opts->x_m68k_tune_option = u68020_40;
+      opts_set->x_m68k_tune_option = (uarch_type) 1;
       opts->x_m68k_cpu_option = m68020;
+      opts_set->x_m68k_cpu_option = (target_device) 1;
       return true;

     case OPT_m68020_60:
       opts->x_m68k_tune_option = u68020_60;
+      opts_set->x_m68k_tune_option = (uarch_type) 1;
       opts->x_m68k_cpu_option = m68020;
+      opts_set->x_m68k_cpu_option = (target_device) 1;
       return true;

     case OPT_mshared_library_id_: