diff mbox

[SH] Pass --isa to assembler

Message ID 1385316317.2438.287.camel@yam-132-YW-E178-FTW
State New
Headers show

Commit Message

Oleg Endo Nov. 24, 2013, 6:05 p.m. UTC
Hello,

Currently GCC doesn't pass the --isa parameter to the assembler for SH
targets other than SH2A and SH5.  This makes the assembler accept any
kind of ISA and happily produce e.g. SH2A code even though the target is
SH4, which will then fail to link.
The attach patch fixes this by passing the --isa parameter also for -m1,
-m2*, -m3*, and -m4*.
It also caught a mistake in libgcc/crt1.S, where the SH3 / SH4 VBR setup
code was compiled for SH2E.

Tested with
 make -k -j4 check RUNTESTFLAGS="--target_board=sh-sim
\{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

and no new failures.
OK for trunk?

Cheers,
Oleg

gcc/ChangeLog:
	* config/sh/sh.h (SH_ASM_SPEC): Handle m1, m2*, m3* and m4* 
	cases.

libgcc/ChangeLog:
	* config/sh/crt1.S (start): Don't do VBR_SETUP for SH2E.

Comments

Kaz Kojima Nov. 25, 2013, 12:12 a.m. UTC | #1
Oleg Endo <oleg.endo@t-online.de> wrote:
> Currently GCC doesn't pass the --isa parameter to the assembler for SH
> targets other than SH2A and SH5.  This makes the assembler accept any
> kind of ISA and happily produce e.g. SH2A code even though the target is
> SH4, which will then fail to link.
> The attach patch fixes this by passing the --isa parameter also for -m1,
> -m2*, -m3*, and -m4*.
> It also caught a mistake in libgcc/crt1.S, where the SH3 / SH4 VBR setup
> code was compiled for SH2E.
> 
> Tested with
>  make -k -j4 check RUNTESTFLAGS="--target_board=sh-sim
> \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
> 
> and no new failures.
> OK for trunk?

libgcc fix should be an independent patch and is OK for trunk
as an obvious fix.  --isa part looks fine but is a new feature.
It's OK when trunk goes back to stage1.

Regards,
	kaz
Oleg Endo Nov. 25, 2013, 5:13 p.m. UTC | #2
On Mon, 2013-11-25 at 09:12 +0900, Kaz Kojima wrote:
> Oleg Endo <oleg.endo@t-online.de> wrote:
> > Currently GCC doesn't pass the --isa parameter to the assembler for SH
> > targets other than SH2A and SH5.  This makes the assembler accept any
> > kind of ISA and happily produce e.g. SH2A code even though the target is
> > SH4, which will then fail to link.
> > The attach patch fixes this by passing the --isa parameter also for -m1,
> > -m2*, -m3*, and -m4*.
> > It also caught a mistake in libgcc/crt1.S, where the SH3 / SH4 VBR setup
> > code was compiled for SH2E.
> > 
> > Tested with
> >  make -k -j4 check RUNTESTFLAGS="--target_board=sh-sim
> > \{-m2/-ml,-m2/-mb,-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"
> > 
> > and no new failures.
> > OK for trunk?
> 
> libgcc fix should be an independent patch and is OK for trunk
> as an obvious fix.  --isa part looks fine but is a new feature.
> It's OK when trunk goes back to stage1.

OK, I've committed the libgcc fix as rev 205360.

Cheers,
Oleg
diff mbox

Patch

Index: gcc/config/sh/sh.h
===================================================================
--- gcc/config/sh/sh.h	(revision 205315)
+++ gcc/config/sh/sh.h	(working copy)
@@ -267,9 +267,25 @@ 
 #define SUBTARGET_ASM_RELAX_SPEC "%{m4*:-isa=sh4-up}"
 #endif
 
+/* Define which ISA type to pass to the assembler.
+   For SH4 we pass SH4A to allow using some instructions that are available
+   on some SH4 variants, but officially are part of the SH4A ISA.  */
 #define SH_ASM_SPEC \
  "%(subtarget_asm_endian_spec) %{mrelax:-relax %(subtarget_asm_relax_spec)} \
 %(subtarget_asm_isa_spec) %(subtarget_asm_spec) \
+%{m1:--isa=sh} \
+%{m2:--isa=sh2} \
+%{m2e:--isa=sh2e} \
+%{m3:--isa=sh3} \
+%{m3e:--isa=sh3e} \
+%{m4:--isa=sh4a} \
+%{m4-single:--isa=sh4a} \
+%{m4-single-only:--isa=sh4a} \
+%{m4-nofpu:--isa=sh4a-nofpu} \
+%{m4a:--isa=sh4a} \
+%{m4a-single:--isa=sh4a} \
+%{m4a-single-only:--isa=sh4a} \
+%{m4a-nofpu:--isa=sh4a-nofpu} \
 %{m2a:--isa=sh2a} \
 %{m2a-single:--isa=sh2a} \
 %{m2a-single-only:--isa=sh2a} \
Index: libgcc/config/sh/crt1.S
===================================================================
--- libgcc/config/sh/crt1.S	(revision 205315)
+++ libgcc/config/sh/crt1.S	(working copy)
@@ -697,8 +697,9 @@ 
 start:
 	mov.l	stack_k,r15
 
-#if defined (__SH3__) || (defined (__SH_FPU_ANY__) && ! defined (__SH2A__)) || defined (__SH4_NOFPU__)
+#if defined (__SH3__) || (defined (__SH_FPU_ANY__) && ! defined (__SH2E__) && ! defined (__SH2A__)) || defined (__SH4_NOFPU__)
 #define VBR_SETUP
+
 	! before zeroing the bss ...
 	! if the vbr is already set to vbr_start then the program has been restarted
 	! (i.e. it is not the first time the program has been run since reset)