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]

[Patch] H8/300 : Add target specific option -mpush-no-exr for H8S


Hi,

Please refer to following link,
http://gcc.gnu.org/ml/gcc-patches/2004-09/msg02744.html

The current implementation is, extended register EXR is saved on stack
by default for function with monitor attribute 
in case of H8S and H8SX targets.
Following patch adds an option "mpush-no-exr". If this option is passed
then extended register (EXR) 
will not be pushed on stack for function with monitor attribute in case
of H8S and H8SX targets.
This option will be ignored for targets other than H8S and H8SX.

No new regressions found.

========================Start Of Patch==================================
ChangeLog
2005-06-15  Anil Paranjpe <anilp1@kpitcummins.com>
	* config/h8300/h8300-protos.h : Add a prototype for 
	h8300_current_function_monitor_function_p
	* config/h8300/h8300.c
(h8300_current_function_monitor_function_p): New function.
	* config/h8300/h8300.md (monitor_prologue): Change in
monitor_prologue.
	(return_h8sx): Change in return_h8sx.
	(*return_1): Change in *return_1.
	* config/h8300/h8300.opt (PUSH_NO_EXR): Add "push-no-exr"
option.
	* doc/invoke.texi (H8/300 Options): Document "mpush-no-exr"
option.

========================================================================
--- gcc-4.1-20050611/gcc/config/h8300/h8300-protos.h.orig
2005-06-13 17:51:41.000000000 +0530
+++ gcc-4.1-20050611/gcc/config/h8300/h8300-protos.h	2005-06-13
17:59:06.000000000 +0530
@@ -101,6 +101,7 @@ extern int h8300_can_use_return_insn_p (
 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-4.1-20050611/gcc/config/h8300/h8300.c.orig	2005-06-13
17:52:03.000000000 +0530
+++ gcc-4.1-20050611/gcc/config/h8300/h8300.c	2005-06-13
18:25:46.000000000 +0530
@@ -810,9 +810,9 @@ h8300_expand_prologue (void)
     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 function, which means it
+       can accept parameters and return values. In addition to this, 
+       interrupts are masked in prologueand return with "rte" in
epilogue. */
     emit_insn (gen_monitor_prologue ());
 
   if (frame_pointer_needed)
@@ -940,8 +940,13 @@ h8300_expand_epilogue (void)
 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 (void)
+{
+  return (h8300_monitor_function_p (current_function_decl));
 }
 
 /* Output assembly code for the start of the file.  */
--- gcc-4.1-20050611/gcc/config/h8300/h8300.md.orig	2005-06-13
17:52:43.000000000 +0530
+++ gcc-4.1-20050611/gcc/config/h8300/h8300.md	2005-06-13
18:34:04.000000000 +0530
@@ -2555,7 +2555,8 @@
   {
     operands[3] = SET_DEST (XVECEXP (operands[0], 0,
 				     XVECLEN (operands[0], 0) - 2));
-    if (h8300_current_function_interrupt_function_p ())
+    if (h8300_current_function_interrupt_function_p ()
+	|| h8300_current_function_monitor_function_p ())
       return "rte/l\t%S1-%S3";
     else
       return "rts/l\t%S1-%S3";
@@ -2574,7 +2575,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\";
@@ -2600,8 +2602,16 @@
 {
   if (TARGET_H8300)
     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 && TARGET_NORMAL_MODE)
+    return
\"subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\\tccr,r0l\;mov.b\\tr0l,@(4,er7)\
;mov.l\\t@er7+,er0\;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_PUSH_NO_EXR && TARGET_NORMAL_MODE)
+    return
\"subs\\t#2,er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;m
ov.l\\t@er7+,er0\;orc\t#128,ccr\";
+  else if (TARGET_H8300S && TARGET_PUSH_NO_EXR )
+    return
\"mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\tr0l,@(4,er7)\;mov.l\\t@er7+,er
0\;orc\t#128,ccr\";
+  else if (TARGET_H8300S && TARGET_NORMAL_MODE)
+    return
\"subs\\t#2,er7\;stc\texr,@-er7\;mov.l\\ter0,@-er7\;stc\tccr,r0l\;mov.b\
tr0l,@(6,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\";
   gcc_unreachable ();
--- gcc-4.1-20050611/gcc/config/h8300/h8300.opt.orig	2005-06-13
17:52:21.000000000 +0530
+++ gcc-4.1-20050611/gcc/config/h8300/h8300.opt	2005-06-13
18:26:20.000000000 +0530
@@ -61,3 +61,7 @@ Enable the normal mode
 malign-300
 Target RejectNegative Mask(ALIGN_300)
 Use H8/300 alignment rules
+
+mpush-no-exr
+Target RejectNegative Mask(PUSH_NO_EXR)
+Donot push EXR on stack
--- gcc-4.1-20050611/gcc/doc/invoke.texi.orig	2005-06-13
18:41:07.000000000 +0530
+++ gcc-4.1-20050611/gcc/doc/invoke.texi	2005-06-13
18:44:03.000000000 +0530
@@ -485,7 +485,7 @@ Objective-C and Objective-C++ Dialects}.
 -mcpu=@var{cpu}}
 
 @emph{H8/300 Options}
-@gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
+@gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300 -mpush-no-exr}
 
 @emph{HPPA Options}
 @gccoptlist{-march=@var{architecture-type} @gol
@@ -8470,6 +8470,11 @@ The default for the H8/300H and H8S is t
 byte boundaries.
 @option{-malign-300} causes them to be aligned on 2 byte boundaries.
 This option has no effect on the H8/300.
+
+@item -mpush-no-exr
+@opindex mpush-no-exr
+Extended register is not pushed on stack before execution of function
with
+monitor attribute. Default is to save EXR in case of H8S and H8SX
targets.
 @end table
 
 @node HPPA Options

==============================End Of Patch==============================
Regards,
Anil Paranjpe
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 were released on June 1, 2005.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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