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: Unreviewed Patch [H8/300] : Patch for -mno-exr option in case of function with "monitor" attribute


Hi Kazu Hirata,
I am extremely sorry for the error in patch. I missed out the call to 
"h8300_current_function_monitor_function_p ()" in the patch. 
 
Please review the complete patch which preserves the default behavior of saving EXR registers  
and also implements a switch "-mno-exr" which will not save EXR registers, in case of function
with monitor attribute for H8S targets. The regression testing has been conducted and there are no 
new regressions found.


******************CHANGELOG TEXT*******************************************************************
2004-07-20  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 ,NO-EXR  is added. Target switch is added.
	* h8300/h8300.c (h8300_init_once) : Error message in case of target EXR is added.
	* h8300/h8300.c : Monitor function definition rephrased.
	* 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-07-20 11:15:38.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-07-20 14:34:28.000000000 +0530
@@ -103,6 +103,9 @@
 #define MASK_RELAX		0x00000400
 #define MASK_H8300H		0x00001000
 #define MASK_ALIGN_300		0x00002000
+#define MASK_EXR		0x00004000
+#define MASK_NEXR		0x00008000
+
 
 /* Macros used in the machine description to test the flags.  */
 
@@ -135,6 +138,18 @@
    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)
+#define TARGET_NEXR ( target_flags & MASK_NEXR)
+
+
+
+
 /* 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 +174,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_NEXR, 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-07-20 15:36:35.000000000 +0530
@@ -295,6 +295,12 @@
       target_flags ^= MASK_NORMAL_MODE;
     }
 
+    if (! TARGET_H8300S &&  TARGET_EXR)
+	    {
+		error ("-mexr 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
@@ -507,9 +513,9 @@
     return;
 
   if (h8300_monitor_function_p (current_function_decl))
-    /* My understanding of monitor functions is they act just like
-       interrupt functions, except the prologue must mask
-       interrupts.  */
+    /* The monitor function act as normal functions, which means it
+    can accept parameters and return values. In addition to this, interrupts
+    are masked in prologue and return with "rte" in epilogue. */
     emit_insn (gen_monitor_prologue ());
 
   if (frame_pointer_needed)
@@ -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-07-20 12:54:29.000000000 +0530
@@ -2130,7 +2130,8 @@
   "reload_completed"
   "*
 {
-  if (h8300_current_function_interrupt_function_p ())
+  if (h8300_current_function_interrupt_function_p ()
+     	|| h8300_current_function_monitor_function_p () )
     return \"rte\";
   else
     return \"rts\";
@@ -2157,6 +2158,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_NEXR)
+     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-07-20 11:16:59.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: Thursday, July 15, 2004 5:32 AM
To: Sherry Samuel
Cc: gcc-patches@gcc.gnu.org
Subject: Re: Unreviewed Patch [H8/300] : Patch for -mno-exr option in
case of function with "monitor" attribute


Hi Sherry,

> The monitor function can accept parameters and return values. The
> monitor attribute requires the
> "h8300_current_function_monitor_function_p()" to be declared.

Why?  Neither the current source code nor your patch has a call to
h8300_current_function_monitor_function_p.  How is it called?  I am
wondering if you have missed a hunk or two when you submitted your
patch.

> If this is not done the monitor function will be treated similar to
> interrupt function which cannot accept parameters or return values.
> The patch http://gcc.gnu.org/ml/gcc-patches/2004-06/msg02495.html
> implements the behavior similar to IAR compiler. We have done the
> debugging in native gdb and it was found that it uses the
> "h8300_current_function_monitor_function_p()" whenever the monitor
> attribute is used.

Are you defining h8300_current_function_monitor_function_p so that you
can call it from gdb?

Kazu Hirata


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