Mercurial > hg > CbC > CbC_gcc
comparison gcc/calls.c @ 73:ce75bd9117e4
merge calls.c, cfgexpand.c, gcc.c, gimple.c, gimple.h and gimplify.c
author | Nobuyasu Oshiro <dimolto@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Mon, 22 Aug 2011 01:54:47 +0900 |
parents | b81903832de2 |
children | 895e19fe9c22 |
comparison
equal
deleted
inserted
replaced
72:20c18990c3e4 | 73:ce75bd9117e4 |
---|---|
97 copy in smaller-sized pieces into pseudos. These are stored in a | 97 copy in smaller-sized pieces into pseudos. These are stored in a |
98 block pointed to by this field. The next field says how many | 98 block pointed to by this field. The next field says how many |
99 word-sized pseudos we made. */ | 99 word-sized pseudos we made. */ |
100 rtx *aligned_regs; | 100 rtx *aligned_regs; |
101 int n_aligned_regs; | 101 int n_aligned_regs; |
102 #ifndef noCbC | |
103 rtx exprs; | |
104 #endif | |
102 }; | 105 }; |
103 | 106 |
104 /* A vector of one char per byte of stack space. A byte if nonzero if | 107 /* A vector of one char per byte of stack space. A byte if nonzero if |
105 the corresponding stack location has been used. | 108 the corresponding stack location has been used. |
106 This vector is used to prevent a function call within an argument from | 109 This vector is used to prevent a function call within an argument from |
1891 value, GEN_INT (shift), value, 1, OPTAB_WIDEN)) | 1894 value, GEN_INT (shift), value, 1, OPTAB_WIDEN)) |
1892 gcc_unreachable (); | 1895 gcc_unreachable (); |
1893 return true; | 1896 return true; |
1894 } | 1897 } |
1895 | 1898 |
1899 #ifndef noCbC | |
1900 #include "cbc-tree.h" | |
1901 #endif | |
1902 | |
1896 /* If X is a likely-spilled register value, copy it to a pseudo | 1903 /* If X is a likely-spilled register value, copy it to a pseudo |
1897 register and return that register. Return X otherwise. */ | 1904 register and return that register. Return X otherwise. */ |
1898 | 1905 |
1899 static rtx | 1906 static rtx |
1900 avoid_likely_spilled_reg (rtx x) | 1907 avoid_likely_spilled_reg (rtx x) |
2294 /* Tail calls can make things harder to debug, and we've traditionally | 2301 /* Tail calls can make things harder to debug, and we've traditionally |
2295 pushed these optimizations into -O2. Don't try if we're already | 2302 pushed these optimizations into -O2. Don't try if we're already |
2296 expanding a call, as that means we're an argument. Don't try if | 2303 expanding a call, as that means we're an argument. Don't try if |
2297 there's cleanups, as we know there's code to follow the call. */ | 2304 there's cleanups, as we know there's code to follow the call. */ |
2298 | 2305 |
2306 // -O2オプションがないときも末尾最適化が行われるように(Code Segmentのみ) | |
2299 if (currently_expanding_call++ != 0 | 2307 if (currently_expanding_call++ != 0 |
2308 #ifndef noCbC | |
2309 || ((!fndecl || !CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl))) && !flag_optimize_sibling_calls) | |
2310 #else | |
2300 || !flag_optimize_sibling_calls | 2311 || !flag_optimize_sibling_calls |
2312 #endif | |
2301 || args_size.var | 2313 || args_size.var |
2302 || dbg_cnt (tail_call) == false) | 2314 || dbg_cnt (tail_call) == false) |
2303 try_tail_call = 0; | 2315 try_tail_call = 0; |
2304 | 2316 |
2305 /* Rest of purposes for tail call optimizations to fail. */ | 2317 /* Rest of purposes for tail call optimizations to fail. */ |
2386 else | 2398 else |
2387 preferred_stack_boundary = crtl->preferred_stack_boundary; | 2399 preferred_stack_boundary = crtl->preferred_stack_boundary; |
2388 | 2400 |
2389 preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT; | 2401 preferred_unit_stack_boundary = preferred_stack_boundary / BITS_PER_UNIT; |
2390 | 2402 |
2403 #ifndef noCbC | |
2404 if ( fntype | |
2405 && CbC_IS_CbC_GOTO (exp) // it's better? than CALL_EXPR_TAILCALL() | |
2406 && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl)) | |
2407 ) | |
2408 { | |
2409 | |
2410 args_size.constant = CbC_PRETENDED_STACK_SIZE; | |
2411 // try_tail_callを矯正的に立たせて末尾最適化を必ずうように変更 | |
2412 // -> expand_cbc_gotは不要に。 | |
2413 /* return expand_cbc_goto(exp, target, fndecl, funtype, fntype, | |
2414 * addr, ignore, flags, num_actuals, args, &args_size, | |
2415 * args_so_far, | |
2416 * old_stack_level, reg_parm_stack_space, old_pending_adj, | |
2417 * preferred_stack_boundary, preferred_unit_stack_boundary, | |
2418 * structure_value_addr, old_inhibit_defer_pop); */ | |
2419 } | |
2420 else if ( CbC_IS_CbC_GOTO (exp) ) | |
2421 { | |
2422 // TODO: 関数からコードセグメントへの遷移 | |
2423 /* | |
2424 if (fndecl) | |
2425 { | |
2426 char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl)); | |
2427 warning(0, "no warning: code segment `%s' has been called from a function.", name_callee); | |
2428 } | |
2429 else | |
2430 { | |
2431 warning(0, "no warning: unnamed code segment has been called from a function."); | |
2432 } | |
2433 */ | |
2434 args_size.constant = CbC_PRETENDED_STACK_SIZE; | |
2435 } | |
2436 else if ( fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) ) | |
2437 { | |
2438 // 警告コードセグメントを関数呼び出し | |
2439 //char *name= IDENTIFIER_POINTER(DECL_NAME(fndecl)); | |
2440 //warning (0, "code segment `%s' has been \"called\" instead \"goto\".", name); | |
2441 } | |
2442 else if (CbC_IS_CODE_SEGMENT(TREE_TYPE (current_function_decl)) ) | |
2443 { | |
2444 // code segment内部からの関数呼び出し。なんも問題ない。 | |
2445 //warning (0, "no warning: normal call from a code segment."); | |
2446 } | |
2447 #endif | |
2448 | |
2449 // when tail call optimization flag was down, warn about them. | |
2450 // and flag it to force a tail call optimize. | |
2451 #ifndef noCbC | |
2452 if (fndecl && CbC_IS_CODE_SEGMENT (TREE_TYPE (fndecl)) | |
2453 && CbC_IS_CODE_SEGMENT (TREE_TYPE (current_function_decl)) | |
2454 && try_tail_call == 0) | |
2455 { | |
2456 location_t loc = EXPR_LOCATION (exp); | |
2457 char *name_callee = IDENTIFIER_POINTER(DECL_NAME(fndecl)); | |
2458 warning_at (loc, 0, "transition to code segment \"%s\" with CbC goto, but tail call optimization was cut.", | |
2459 name_callee); | |
2460 try_tail_call = 1; | |
2461 } | |
2462 #endif | |
2463 | |
2391 /* We want to make two insn chains; one for a sibling call, the other | 2464 /* We want to make two insn chains; one for a sibling call, the other |
2392 for a normal call. We will select one of the two chains after | 2465 for a normal call. We will select one of the two chains after |
2393 initial RTL generation is complete. */ | 2466 initial RTL generation is complete. */ |
2394 for (pass = try_tail_call ? 0 : 1; pass < 2; pass++) | 2467 for (pass = try_tail_call ? 0 : 1; pass < 2; pass++) |
2395 { | 2468 { |
2452 if (pass == 0 && crtl->stack_protect_guard) | 2525 if (pass == 0 && crtl->stack_protect_guard) |
2453 stack_protect_epilogue (); | 2526 stack_protect_epilogue (); |
2454 | 2527 |
2455 adjusted_args_size = args_size; | 2528 adjusted_args_size = args_size; |
2456 /* Compute the actual size of the argument block required. The variable | 2529 /* Compute the actual size of the argument block required. The variable |
2457 and constant sizes must be combined, the size may have to be rounded, | 2530 and constant sizes must be combined, the size may have to be rounded, |
2458 and there may be a minimum required size. When generating a sibcall | 2531 and there may be a minimum required size. When generating a sibcall |
2459 pattern, do not round up, since we'll be re-using whatever space our | 2532 pattern, do not round up, since we'll be re-using whatever space our |
2460 caller provided. */ | 2533 caller provided. */ |
2534 #ifndef noCbC | |
2535 if ( fntype && CbC_IS_CODE_SEGMENT(fntype) ) | |
2536 { | |
2537 unadjusted_args_size = args_size.constant; | |
2538 adjusted_args_size.constant = CbC_PRETENDED_STACK_SIZE; | |
2539 compute_argument_block_size (reg_parm_stack_space, | |
2540 &adjusted_args_size, | |
2541 fndecl, fntype, | |
2542 (pass == 0 ? 0 | |
2543 : preferred_stack_boundary)); | |
2544 } | |
2545 else | |
2546 #endif | |
2547 { | |
2461 unadjusted_args_size | 2548 unadjusted_args_size |
2462 = compute_argument_block_size (reg_parm_stack_space, | 2549 = compute_argument_block_size (reg_parm_stack_space, |
2463 &adjusted_args_size, | 2550 &adjusted_args_size, |
2464 fndecl, fntype, | 2551 fndecl, fntype, |
2465 (pass == 0 ? 0 | 2552 (pass == 0 ? 0 |
2466 : preferred_stack_boundary)); | 2553 : preferred_stack_boundary)); |
2554 } | |
2467 | 2555 |
2468 old_stack_allocated = stack_pointer_delta - pending_stack_adjust; | 2556 old_stack_allocated = stack_pointer_delta - pending_stack_adjust; |
2469 | 2557 |
2470 /* The argument block when performing a sibling call is the | 2558 /* The argument block when performing a sibling call is the |
2471 incoming argument block. */ | 2559 incoming argument block. */ |