diff gcc/calls.c @ 21:959d4c8c8abc

add conv.c conv1.c
author kent <kent@cr.ie.u-ryukyu.ac.jp>
date Tue, 29 Sep 2009 20:15:16 +0900
parents d43292db8c8c
children 3f5886e153cb
line wrap: on
line diff
--- a/gcc/calls.c	Thu Sep 24 14:29:28 2009 +0900
+++ b/gcc/calls.c	Tue Sep 29 20:15:16 2009 +0900
@@ -2384,17 +2384,12 @@
 
 #ifndef noCbC
   if ( fntype
-       //&& CbC_IS_CODE_SEGMENT (fntype)
-       //&& fndecl
-       //&& CbC_IS_CODE_SEGMENT (fndecl)
-       //&& CbC_IS_CODE_SEGMENT(TREE_TYPE(fndecl))
-       //&& CALL_EXPR_TAILCALL (exp)
        && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL()
+       && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))
      )
     {
 
-      // fprintf(stderr, "\n\tgoto code segment.\n");
-      args_size.constant = CbC_ARGS_SIZE;
+      args_size.constant = CbC_PRETENDED_STACK_SIZE;
       return expand_cbc_goto(exp, target, fndecl, funtype, fntype,
 	      addr, ignore, flags, num_actuals, args, &args_size,
 	      args_so_far,
@@ -2402,16 +2397,23 @@
 	      preferred_stack_boundary, preferred_unit_stack_boundary,
 	      structure_value_addr, old_inhibit_defer_pop);
     }
-  else if ( fndecl&&CbC_HAVE_CbC_GOTO(fndecl) )
+  else if ( CbC_IS_CbC_GOTO (exp) )
+    {
+      // TODO: 関数からコードセグメントへの遷移
+      char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl));
+      warning(0, "no warning: code segment `%s' has been called from a function.", name_callee);
+      args_size.constant = CbC_PRETENDED_STACK_SIZE;
+    }
+  else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) )
     {
-      char *name = IDENTIFIER_POINTER(DECL_NAME(fndecl));
-      fprintf(stderr, "\nCbC: function %s having CbCgoto statement has been `CALLED'.\n", name);
-      //args_size.constant = CbC_ARGS_SIZE;
+      // 警告コードセグメントを関数呼び出し
+      char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl));
+      warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name);
     }
-  else if ( fntype&&CbC_IS_CODE_SEGMENT(fntype) )
+  else if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) )
     {
-      char *name = IDENTIFIER_POINTER(DECL_NAME(fndecl));
-      fprintf(stderr, "\nCbC error: codesegment %s has been `CALLED!'.\n", name);
+      // code segment内部からの関数呼び出し。なんも問題ない。
+      warning (0, "no warning: normal call from a code segment.");
     }
 #endif
 
@@ -2486,17 +2488,16 @@
 	 pattern, do not round up, since we'll be re-using whatever space our
 	 caller provided.  */
 #ifndef noCbC
-      if ( ( fntype && CbC_IS_CODE_SEGMENT(fntype) )
-         || ( fndecl && CbC_HAVE_CbC_GOTO(fndecl) ) )
+      if ( fntype && CbC_IS_CODE_SEGMENT(fntype) )
         {
-        unadjusted_args_size = args_size.constant;
-        adjusted_args_size.constant = CbC_ARGS_SIZE;
-        compute_argument_block_size (reg_parm_stack_space,
-                                     &adjusted_args_size,
-									 fndecl, fntype,
-                                     (pass == 0 ? 0
-                                      : preferred_stack_boundary));
-      }
+	  unadjusted_args_size = args_size.constant;
+	  adjusted_args_size.constant = CbC_PRETENDED_STACK_SIZE;
+	  compute_argument_block_size (reg_parm_stack_space,
+	      &adjusted_args_size,
+	      fndecl, fntype,
+	      (pass == 0 ? 0
+	       : preferred_stack_boundary));
+        }
       else
 #endif
       {