diff gcc/calls.c @ 140:4e440907fcbf

copy CbC goto flang in cfgexpand remove some CbC unnecessary code
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 14 Nov 2018 00:24:45 +0900
parents 420680fc7707
children 351920fa3827
line wrap: on
line diff
--- a/gcc/calls.c	Thu Nov 08 14:17:14 2018 +0900
+++ b/gcc/calls.c	Wed Nov 14 00:24:45 2018 +0900
@@ -119,9 +119,6 @@
      word-sized pseudos we made.  */
   rtx *aligned_regs;
   int n_aligned_regs;
-#ifndef noCbC
-rtx exprs;
-#endif
 };
 
 /* A vector of one char per byte of stack space.  A byte if nonzero if
@@ -3618,7 +3615,7 @@
      expanding a call, as that means we're an argument.  Don't try if
      there's cleanups, as we know there's code to follow the call.  */
 
-  // -O2オプションがないときも末尾最適化が行われるように(Code Segmentのみ)
+  // in case of __code do tail call even if no -O2
 
   if (currently_expanding_call++ != 0
 #ifndef noCbC
@@ -3695,53 +3692,23 @@
   preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
 
 #ifndef noCbC
-  if ( fntype
-       && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL()
-       //&& CALL_EXPR_TAILCALL(exp)
-       && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))
-     )
-    {
-
-      args_size.constant = CbC_PRETENDED_STACK_SIZE;
-      // try_tail_callを矯正的に立たせて末尾最適化を必ずうように変更
-      // -> expand_cbc_gotは不要に。
-      /* return expand_cbc_goto(exp, target, fndecl, funtype, fntype,
-       *         addr, ignore, flags, num_actuals, args, &args_size,
-       *         args_so_far,
-       *         old_stack_level, reg_parm_stack_space, old_pending_adj,
-       *         preferred_stack_boundary, preferred_unit_stack_boundary,
-       *         structure_value_addr, old_inhibit_defer_pop); */
-    }
-  else if ( CbC_IS_CbC_GOTO (exp) )
-    {
-      // TODO: 関数からコードセグメントへの遷移
-      /*
-      if (fndecl)
-        {
-          char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl));
-          warning(0, "no warning: code segment `%s' has been called from a function.", name_callee);
-        }
-      else
-        {
-          warning(0, "no warning: unnamed code segment has been called from a function.");
-        }
-        */
-      // treat goto codesegments in normall function call as a function call
-      // this behavale same as llvm
-      //args_size.constant = CbC_PRETENDED_STACK_SIZE;
-	try_tail_call = 0;
-    }
-  else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) )
-    {
-      // 警告コードセグメントを関数呼び出し
-      //char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl));
-      //warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name);
-    }
-  else if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) )
-    {
-      // code segment内部からの関数呼び出し。なんも問題ない。
-      //warning (0, "no warning: normal call from a code segment.");
-    }
+  if (CbC_IS_CbC_GOTO (exp)) {
+       if (CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))) {
+         // fix stack size to force tail call
+         args_size.constant = CbC_PRETENDED_STACK_SIZE;
+       } else {
+          // treat goto codesegments in normall function call as a function call
+          // this behavale same as llvm
+          //args_size.constant = CbC_PRETENDED_STACK_SIZE;
+          try_tail_call = 0;
+       }
+  } else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) ) {
+      // __code is called as function 
+      if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) ) {
+          const char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl));
+          warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name);
+      }
+  }
 #endif
 
   // when tail call optimization flag was down, warn about them.