comparison 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
comparison
equal deleted inserted replaced
138:fc828634a951 140:4e440907fcbf
117 copy in smaller-sized pieces into pseudos. These are stored in a 117 copy in smaller-sized pieces into pseudos. These are stored in a
118 block pointed to by this field. The next field says how many 118 block pointed to by this field. The next field says how many
119 word-sized pseudos we made. */ 119 word-sized pseudos we made. */
120 rtx *aligned_regs; 120 rtx *aligned_regs;
121 int n_aligned_regs; 121 int n_aligned_regs;
122 #ifndef noCbC
123 rtx exprs;
124 #endif
125 }; 122 };
126 123
127 /* A vector of one char per byte of stack space. A byte if nonzero if 124 /* A vector of one char per byte of stack space. A byte if nonzero if
128 the corresponding stack location has been used. 125 the corresponding stack location has been used.
129 This vector is used to prevent a function call within an argument from 126 This vector is used to prevent a function call within an argument from
3616 /* Tail calls can make things harder to debug, and we've traditionally 3613 /* Tail calls can make things harder to debug, and we've traditionally
3617 pushed these optimizations into -O2. Don't try if we're already 3614 pushed these optimizations into -O2. Don't try if we're already
3618 expanding a call, as that means we're an argument. Don't try if 3615 expanding a call, as that means we're an argument. Don't try if
3619 there's cleanups, as we know there's code to follow the call. */ 3616 there's cleanups, as we know there's code to follow the call. */
3620 3617
3621 // -O2オプションがないときも末尾最適化が行われるように(Code Segmentのみ) 3618 // in case of __code do tail call even if no -O2
3622 3619
3623 if (currently_expanding_call++ != 0 3620 if (currently_expanding_call++ != 0
3624 #ifndef noCbC 3621 #ifndef noCbC
3625 || ((!fntype|| !CbC_IS_CODE_SEGMENT (fntype)) && (!flag_optimize_sibling_calls && !CALL_FROM_THUNK_P (exp))) 3622 || ((!fntype|| !CbC_IS_CODE_SEGMENT (fntype)) && (!flag_optimize_sibling_calls && !CALL_FROM_THUNK_P (exp)))
3626 #else 3623 #else
3693 preferred_stack_boundary = crtl->preferred_stack_boundary; 3690 preferred_stack_boundary = crtl->preferred_stack_boundary;
3694 3691
3695 preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT; 3692 preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT;
3696 3693
3697 #ifndef noCbC 3694 #ifndef noCbC
3698 if ( fntype 3695 if (CbC_IS_CbC_GOTO (exp)) {
3699 && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL() 3696 if (CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl))) {
3700 //&& CALL_EXPR_TAILCALL(exp) 3697 // fix stack size to force tail call
3701 && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl)) 3698 args_size.constant = CbC_PRETENDED_STACK_SIZE;
3702 ) 3699 } else {
3703 { 3700 // treat goto codesegments in normall function call as a function call
3704 3701 // this behavale same as llvm
3705 args_size.constant = CbC_PRETENDED_STACK_SIZE; 3702 //args_size.constant = CbC_PRETENDED_STACK_SIZE;
3706 // try_tail_callを矯正的に立たせて末尾最適化を必ずうように変更 3703 try_tail_call = 0;
3707 // -> expand_cbc_gotは不要に。 3704 }
3708 /* return expand_cbc_goto(exp, target, fndecl, funtype, fntype, 3705 } else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) ) {
3709 * addr, ignore, flags, num_actuals, args, &args_size, 3706 // __code is called as function
3710 * args_so_far, 3707 if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) ) {
3711 * old_stack_level, reg_parm_stack_space, old_pending_adj, 3708 const char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl));
3712 * preferred_stack_boundary, preferred_unit_stack_boundary, 3709 warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name);
3713 * structure_value_addr, old_inhibit_defer_pop); */ 3710 }
3714 } 3711 }
3715 else if ( CbC_IS_CbC_GOTO (exp) )
3716 {
3717 // TODO: 関数からコードセグメントへの遷移
3718 /*
3719 if (fndecl)
3720 {
3721 char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl));
3722 warning(0, "no warning: code segment `%s' has been called from a function.", name_callee);
3723 }
3724 else
3725 {
3726 warning(0, "no warning: unnamed code segment has been called from a function.");
3727 }
3728 */
3729 // treat goto codesegments in normall function call as a function call
3730 // this behavale same as llvm
3731 //args_size.constant = CbC_PRETENDED_STACK_SIZE;
3732 try_tail_call = 0;
3733 }
3734 else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) )
3735 {
3736 // 警告コードセグメントを関数呼び出し
3737 //char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl));
3738 //warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name);
3739 }
3740 else if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) )
3741 {
3742 // code segment内部からの関数呼び出し。なんも問題ない。
3743 //warning (0, "no warning: normal call from a code segment.");
3744 }
3745 #endif 3712 #endif
3746 3713
3747 // when tail call optimization flag was down, warn about them. 3714 // when tail call optimization flag was down, warn about them.
3748 // and flag it to force a tail call optimize. 3715 // and flag it to force a tail call optimize.
3749 3716