This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

RE: Patch H8/300 : Patch for -mexr option in case of function with "monitor" attribute


Hi,
	
The current implementation is, EXR is saved on stack by default for monitor function in case of H8S target. 
Following patch adds an option "-mno-exr", if this option is passed then EXR will not be saved on stack for 
monitor function in case of H8S target. If "-mexr" is passed, EXR will be saved on stack as like default case.

After conducting the regression test with the following patch applied in gcc-3.5-20040620 it was found that 
there is a regression in the test case in the following location.
	gcc-3.5-20040620/gcc/testsuite/gcc.c-torture/compile/20001226-1.c
The options for compiling was "-c -Os  -w -DSTACK_SIZE=4096 -c   -ms2600 -ms".

The following error was generated.

WARNING: program timed out.
compiler exited with status 1
FAIL: gcc.c-torture/compile/20001226-1.c (test for excess errors)
Excess errors:
exit status is 1

But when compiled separately there was no error coming with and without the following patch, though it took too
much time to compile because of nesting of macros. 

******************CHANGELOG TEXT*******************************************************************
2004-06-24  Sherry Samuel  <SherryS@KPITCummins.com>

	* h8300/h8300-protos.h : Declaration for function "h8300_current_function_monitor_function_p" is added.
	* h8300/h8300.h : Mask for EXR and target with mask is added. Target switch is added.
	* h8300/h8300.c (h8300_init_once) : Error message in case of target EXR is added.
	* h8300/h8300.c : New function is added to check whether current function is monitor function.
	* h8300/h8300.md : Use "rte" in epilogue for interrupt handler or monitor function.
				 Do not save EXR on stack for monitor function in case of H8S target when 
				 "-mno-exr" is passed.
	* doc/invoke.texi : H8/300 options and its description are updated with option "-mno-exr".


Patch Text
***************************************************************************************************

--- gcc/config/h8300/h8300-protos.h.old	2004-02-19 03:42:55.000000000 +0530
+++ gcc/config/h8300/h8300-protos.h	2004-06-24 12:40:09.000000000 +0530
@@ -102,6 +102,7 @@
 extern void h8300_expand_prologue (void);
 extern void h8300_expand_epilogue (void);
 extern int h8300_current_function_interrupt_function_p (void);
+extern int h8300_current_function_monitor_function_p (void);
 extern int h8300_initial_elimination_offset (int, int);
 extern int h8300_regs_ok_for_stm (int, rtx[]);
 extern int h8300_hard_regno_rename_ok (unsigned int, unsigned int);

--- gcc/config/h8300/h8300.h.old	2004-03-08 01:53:28.000000000 +0530
+++ gcc/config/h8300/h8300.h	2004-06-24 13:16:39.000000000 +0530
@@ -103,6 +103,7 @@
 #define MASK_RELAX		0x00000400
 #define MASK_H8300H		0x00001000
 #define MASK_ALIGN_300		0x00002000
+#define MASK_EXR		0x00004000
 
 /* Macros used in the machine description to test the flags.  */
 
@@ -135,6 +136,15 @@
    alignment.  */
 #define TARGET_ALIGN_300 (target_flags & MASK_ALIGN_300)
 
+/*
+ * Behaviour of RTE instruction depends on H8S model and operation mode.
+ *
+ * This affects only the prologue code generated for functions with
+ * monitor attribute!
+ * */
+#define TARGET_EXR (target_flags & MASK_EXR)
+
+
 /* Macro to define tables used to set the flags.
    This is a list in braces of pairs in braces,
    each pair being { "NAME", VALUE }
@@ -159,6 +169,8 @@
   {"n",			 MASK_NORMAL_MODE, N_("Enable the normal mode")},   \
   {"no-h",		-MASK_H8300H, N_("Do not generate H8/300H code")},  \
   {"align-300",		 MASK_ALIGN_300, N_("Use H8/300 alignment rules")}, \
+  {"exr",		 -MASK_EXR, N_("Push exr on stack")}, \
+  {"no-exr",	        MASK_EXR, N_("Do not push exr on stack")}, \
   { "",			 TARGET_DEFAULT, NULL}}
 
 #ifdef IN_LIBGCC2

--- gcc/config/h8300/h8300.c.old	2004-05-13 12:09:58.000000000 +0530
+++ gcc/config/h8300/h8300.c	2004-06-25 11:08:48.000000000 +0530
@@ -295,6 +295,12 @@
       target_flags ^= MASK_NORMAL_MODE;
     }
 
+    if (!TARGET_H8300S && TARGET_EXR)
+    {
+	 error ("-mno-exr is used without -ms");
+	 target_flags |= MASK_H8300S;
+ 	}
+
   /* Some of the shifts are optimized for speed by default.
      See http://gcc.gnu.org/ml/gcc-patches/2002-07/msg01858.html
      If optimizing for size, change shift_alg for those shift to
@@ -661,8 +667,14 @@
 int
 h8300_current_function_interrupt_function_p (void)
 {
-  return (h8300_interrupt_function_p (current_function_decl)
-	  || h8300_monitor_function_p (current_function_decl));
+  return (h8300_interrupt_function_p (current_function_decl));
+}
+
+
+int
+h8300_current_function_monitor_function_p ()
+{
+	return (h8300_monitor_function_p (current_function_decl));
 }
 
 /* Output assembly code for the start of the file.  */

--- gcc/config/h8300/h8300.md.old	2004-06-09 22:14:31.000000000 +0530
+++ gcc/config/h8300/h8300.md	2004-06-24 12:52:06.000000000 +0530
@@ -2157,6 +2157,8 @@
     return \"subs\\t#2,r7\;mov.w\\tr0,@-r7\;stc\\tccr,r0l\;mov.b\tr0l,@(2,r7)\;mov.w\\t@r7+,r0\;orc\t#128,ccr\";
   else if (TARGET_H8300H)
     return \"mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\\t#128,ccr\";
+  else if (TARGET_H8300S && TARGET_EXR)
+     return \"mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr\";
   else if (TARGET_H8300S)
     return \"stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(6,er7)\;mov.l\\t@er7+,er0\;orc\t#128,ccr\";
     abort ();

--- gcc/doc/invoke.texi.old	2004-06-19 22:59:00.000000000 +0530
+++ gcc/doc/invoke.texi	2004-06-25 11:02:26.000000000 +0530
@@ -547,7 +547,7 @@
 @gccoptlist{-mvms-return-codes}
 
 @emph{H8/300 Options}
-@gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
+@gccoptlist{-mrelax  -mh  -ms  -mn  -mno-exr  -mint32  -malign-300}
 
 @emph{SH Options}
 @gccoptlist{-m1  -m2  -m2e  -m3  -m3e @gol
@@ -9539,10 +9539,17 @@
 @opindex ms2600
 Generate code for the H8S/2600.  This switch must be used with @option{-ms}.
 
+@item -mno-exr
+@opindex mno-exr
+Extended registers are not stored on stack before execution of function 
+with monitor attribute. Default option is @option{-mexr}. 
+This option is valid only for H8S targets.
+
 @item -mint32
 @opindex mint32
 Make @code{int} data 32 bits by default.
 
+
 @item -malign-300
 @opindex malign-300
 On the H8/300H and H8S, use the same alignment rules as for the H8/300.

 

 

***************************************************************************************

	
Regards,
Sherry Samuel,
KPIT Cummins InfoSystems Ltd.
Pune, India

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Free download of GNU based tool-chains for Renesas' SH and H8 Series.
The following site also offers free technical support to its users. 
Visit http://www.kpitgnutools.com for details. 
Latest versions of KPIT GNU tools are released on June 1, 2004.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 

-----Original Message-----
From: Kazu Hirata [mailto:kazu@cs.umass.edu]
Sent: Wednesday, June 09, 2004 2:51 PM
To: Anil Paranjape
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Patch H8/300 : Patch for -mexr option in case of function
with "monitor" attribute


Hi Anil,

> In GCC 3.4, monitor function by default saves EXR on stack in case
> of H8S target.  In some H8S controllers this implementation is not
> needed.  Whenever user is required to store EXR on stack for monitor
> function, user must pass "-mexr" option to compiler with "-ms"
> switch.

IIRC, the default is to save EXR on H8S.  Are you suggesting to change
the default behavior of -ms?  I would preserve the current behavior
and provide -mno-exr (and -mexr for completeness).

Kazu Hirata


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