* h8300/h8300.c (h8300_current_function_monitor_function_p):
authorlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 17:09:53 +0000 (17:09 +0000)
committerlaw <law@138bc75d-0d04-0410-961f-82ee72b054a4>
Tue, 3 Apr 2012 17:09:53 +0000 (17:09 +0000)
New function. Added to check monitor functions.
(h8300_option_override): Modified to generate error/warning
messages for invalid combinations of different command line
options.
* h8300/h8300.md: Generate 'rte' for monitor functions. Do not
save EXR on stack for monitor function in case of H8S target
when "-mno-exr" is passed.
* h8300/h8300-protos.h
(h8300_current_function_monitor_function_p): Add prototype.
* doc/invoke.texi: Document H8S options.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@186109 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/config/h8300/h8300-protos.h
gcc/config/h8300/h8300.c
gcc/config/h8300/h8300.md
gcc/config/h8300/h8300.opt
gcc/doc/invoke.texi

index db51659..e1fc73b 100644 (file)
@@ -1,3 +1,17 @@
+2012-04-03  Sandeep Kumar Singh  <Sandeep.Singh2@kpitcummins.com>
+
+       * h8300/h8300.c (h8300_current_function_monitor_function_p):
+       New function. Added to check monitor functions. 
+       (h8300_option_override): Modified to generate error/warning 
+       messages for invalid combinations of different command line 
+       options.
+       * h8300/h8300.md: Generate 'rte' for monitor functions. Do not
+       save EXR on stack for monitor function in case of H8S target 
+       when "-mno-exr" is passed.
+       * h8300/h8300-protos.h 
+       (h8300_current_function_monitor_function_p): Add prototype.
+       * doc/invoke.texi: Document H8S options.
+
 2012-04-03  Tristan Gingold  <gingold@adacore.com>
 
        * configure.ac: Use GCC_AC_FUNC_MMAP_BLACKLIST instead
index aeac904..428a86a 100644 (file)
@@ -96,6 +96,7 @@ extern int h8300_can_use_return_insn_p (void);
 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);
index 3911cd4..7eaaf20 100644 (file)
@@ -316,6 +316,14 @@ h8300_option_override (void)
   static const char *const h8_pop_ops[2]  = { "pop"  , "pop.l"  };
   static const char *const h8_mov_ops[2]  = { "mov.w", "mov.l"  };
 
+#ifndef OBJECT_FORMAT_ELF
+  if (TARGET_H8300SX)
+    {
+      error ("-msx is not supported in coff");
+      target_flags |= MASK_H8300S;
+    }
+#endif
+
   if (TARGET_H8300)
     {
       cpu_type = (int) CPU_H8300;
@@ -339,10 +347,34 @@ h8300_option_override (void)
 
   if (TARGET_H8300 && TARGET_NORMAL_MODE)
     {
-      error ("-mn is used without -mh or -ms");
+      error ("-mn is used without -mh or -ms or -msx");
       target_flags ^= MASK_NORMAL_MODE;
     }
 
+  if (! TARGET_H8300S &&  TARGET_EXR)
+    {
+      error ("-mexr is used without -ms");
+      target_flags |= MASK_H8300S_1;
+    }
+
+  if (TARGET_H8300 && TARGET_INT32)
+   {
+      error ("-mint32 is not supported for H8300 and H8300L targets");
+      target_flags ^= MASK_INT32;
+   }
+
+ if ((!TARGET_H8300S  &&  TARGET_EXR) && (!TARGET_H8300SX && TARGET_EXR))
+   {
+      error ("-mexr is used without -ms or -msx");
+      target_flags |= MASK_H8300S_1;
+   }
+
+ if ((!TARGET_H8300S  &&  TARGET_NEXR) && (!TARGET_H8300SX && TARGET_NEXR))
+   {
+      warning (OPT_mno_exr, "-mno-exr valid only with -ms or -msx    \
+               - Option ignored!");
+   }
+
   /* 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
@@ -795,9 +827,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 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)
@@ -925,8 +957,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 ()
+{
+  return (h8300_monitor_function_p (current_function_decl));
 }
 
 /* Output assembly code for the start of the file.  */
index bf41e66..df983e1 100644 (file)
   {
     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";
   "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\";
 {
   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_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 && TARGET_NEXR && 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_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 ();
    && !reg_overlap_mentioned_p (operands[0], operands[2])"
   [(set (match_dup 2)
        (match_dup 1))])
+       
+
index 989375e..16c6ef5 100644 (file)
@@ -60,3 +60,12 @@ Enable the normal mode
 malign-300
 Target RejectNegative Mask(ALIGN_300)
 Use H8/300 alignment rules
+
+mexr
+Target Mask(EXR)
+Push extended registers on stack in monitor functions
+
+mno-exr
+Target Mask(NEXR)
+Do not push extended registers on stack in monitor functions
+
index 672e597..36d09cd 100644 (file)
@@ -596,7 +596,7 @@ Objective-C and Objective-C++ Dialects}.
 -tno-android-cc -tno-android-ld}
 
 @emph{H8/300 Options}
-@gccoptlist{-mrelax  -mh  -ms  -mn  -mint32  -malign-300}
+@gccoptlist{-mrelax  -mh  -ms  -mn  -mexr -mno-exr  -mint32  -malign-300}
 
 @emph{HPPA Options}
 @gccoptlist{-march=@var{architecture-type} @gol
@@ -12815,6 +12815,18 @@ must be used either with @option{-mh} or @option{-ms}.
 @opindex ms2600
 Generate code for the H8S/2600.  This switch must be used with @option{-ms}.
 
+@item -mexr
+@opindex mexr
+Extended registers are stored on stack before execution of function
+with monitor attribute. Default option is @option{-mexr}.
+This option is valid only for H8S targets.
+
+@item -mno-exr
+@opindex mno-exr
+Extended registers are not stored on stack before execution of function 
+with monitor attribute. Default option is @option{-mno-exr}. 
+This option is valid only for H8S targets.
+
 @item -mint32
 @opindex mint32
 Make @code{int} data 32 bits by default.