CVS: gcc/gcc-3.3/gcc/config/msp430 msp430.c, 1.99.2.4, 1.99.2.5

"Sergey A. Borshch" <[email protected]> Thu, 12 Feb 2009 13:51:45 +0000
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430
In directory 23jxhf1.ch3.sourceforge.com:/tmp/cvs-serv9452

Modified Files:
      Tag: MSP430X
	msp430.c 
Log Message:
no registers saved in prologue and no epilogue if function never returns


Index: msp430.c
===================================================================
RCS file: /cvsroot/mspgcc/gcc/gcc-3.3/gcc/config/msp430/msp430.c,v
retrieving revision 1.99.2.4
retrieving revision 1.99.2.5
diff -u -w -d -r1.99.2.4 -r1.99.2.5
--- msp430.c	5 Feb 2009 01:44:44 -0000	1.99.2.4
+++ msp430.c	12 Feb 2009 13:51:42 -0000	1.99.2.5
@@ -23,6 +23,7 @@
 #include "rtl.h"
 #include "regs.h"
 #include "hard-reg-set.h"
+#include "basic-block.h"
 #include "real.h"
 #include "insn-config.h"
 #include "conditions.h"
@@ -83,6 +84,7 @@
 static int msp430_task_function_p PARAMS ((tree func));
 static int signal_function_p PARAMS ((tree func));
 static int wakeup_function_p PARAMS ((tree func));
+static int noreturn_function_p (void);
 static int msp430_num_arg_regs PARAMS ((enum machine_mode mode, tree type));
 static int msp430_critical_function_p PARAMS ((tree func));
 static int msp430_reentrant_function_p PARAMS ((tree func));
@@ -545,6 +547,12 @@
 }
 
 static int
+noreturn_function_p ()
+{
+  return EXIT_BLOCK_PTR->pred == NULL;
+}
+
+static int
 msp430_far_object_p (node)
      tree node;
 {
@@ -555,8 +563,8 @@
   a = lookup_attribute ("far", DECL_ATTRIBUTES (node));
   return a != NULL_TREE;
 }
-/* Encode section information about tree DECL */
   
+/* Encode section information about tree DECL */
 void
 encode_section_info (decl)
      tree decl;
@@ -893,7 +901,6 @@
   int wup = wakeup_function_p (current_function_decl);
   int size = msp430_saved_regs_frame ();
   int fs = get_frame_size ();
-
   if (cfp && ree)
     ree = 0;
 
@@ -927,6 +934,7 @@
   int signal_func_p = signal_function_p (current_function_decl);
   int leaf_func_p = leaf_function_p ();
   int main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
+  int noreturn_func_p = noreturn_function_p();
   int stack_reserve = 0;
   tree ss = 0;
   rtx x = DECL_RTL (current_function_decl);
@@ -1032,7 +1040,7 @@
     }
   else 
     {
-      if (!tfp)
+      if (!tfp && !noreturn_func_p)
         {
           if (MCU_CORE_X)
             {
@@ -1224,6 +1232,7 @@
   int leaf_func_p = leaf_function_p ();
   int main_p = MAIN_NAME_P (DECL_NAME (current_function_decl));
   int wakeup_func_p = wakeup_function_p (current_function_decl);
+  int noreturn_func_p = noreturn_function_p();
   int cfp = msp430_critical_function_p (current_function_decl);
   int ree = msp430_reentrant_function_p (current_function_decl);
   int save_prologue_p =
@@ -1243,6 +1252,12 @@
       return;
     }
 
+  if ( noreturn_func_p )
+    {
+      fprintf (file, "\n\t/* epilogue: empty, noreturn function*/\n");
+      return;
+    }
+
   if (msp430_naked_function_p (current_function_decl))
     {
       fprintf (file, "\n\t/* epilogue: naked */\n");
@@ -1273,11 +1288,16 @@
       if (size)
         {
 	  fprintf (file, "\tadd\t#%d, r1\n", size);
+          if (size == 1 || size == 2 || size == 4 || size == 8)
+	        epilogue_size += 1;
+          else
+            epilogue_size += 2;
         }
+      if ( !noreturn_func_p )
+        {
       fprintf (file, CHECK_JUMP_SIZE("\tbr\t#%s\n","\tbra\t#%s\n"), msp430_endup);
       epilogue_size += 4;
-      if (size == 1 || size == 2 || size == 4 || size == 8)
-	epilogue_size--;
+        }
     }
   else
     {


------------------------------------------------------------------------------
Create and Deploy Rich Internet Apps outside the browser with Adobe(R)AIR(TM)
software. With Adobe AIR, Ajax developers can use existing skills and code to
build responsive, highly engaging applications that combine the power of local
resources and data with the reach of the web. Download the Adobe AIR SDK and
Ajax docs to start building applications today-http://p.sf.net/sfu/adobe-com