GCC Wikia
Advertisement

このページを編集する際は,編集に関する方針に従ってください.[]

概要[]

  • gcc-4.1.0/gcc/cfgexpand.cにて定義

CFGがふくまれた形の中間コードをGimple 木から RTLへ 訳す。

コメント


引数[]

実装[]

1575: static void
1576: tree_expand_cfg (void)
1577: {
1578:   basic_block bb, init_block;
1579:   sbitmap blocks;
1580: 
1581:   /* Some backends want to know that we are expanding to RTL.  */
1582:   currently_expanding_to_rtl = 1;
1583: 
1584:   /* Prepare the rtl middle end to start recording block changes.  */
1585:   reset_block_changes ();
1586: 
1587:   /* Mark arrays indexed with non-constant indices with TREE_ADDRESSABLE.  */
1588:   discover_nonconstant_array_refs ();
1589: 
1590:   /* Expand the variables recorded during gimple lowering.  */
1591:   expand_used_vars ();
1592: 
1593:   /* Honor stack protection warnings.  */
1594:   if (warn_stack_protect)
1595:     {
1596:       if (current_function_calls_alloca)
1597:         warning (0, "not protecting local variables: variable length buffer");
1598:       if (has_short_buffer && !cfun->stack_protect_guard)
1599:         warning (0, "not protecting function: no buffer at least %d bytes long",
1600:                  (int) PARAM_VALUE (PARAM_SSP_BUFFER_SIZE));
1601:     }
1602: 
1603:   /* Set up parameters and prepare for return, for the function.  */
1604:   expand_function_start (current_function_decl);
1605: 
1606:   /* If this function is `main', emit a call to `__main'
1607:      to run global initializers, etc.  */
1608:   if (DECL_NAME (current_function_decl)
1609:       && MAIN_NAME_P (DECL_NAME (current_function_decl))
1610:       && DECL_FILE_SCOPE_P (current_function_decl))
1611:     expand_main_function ();
1612: 
1613:   /* Initialize the stack_protect_guard field.  This must happen after the
1614:      call to __main (if any) so that the external decl is initialized.  */
1615:   if (cfun->stack_protect_guard)
1616:     stack_protect_prologue ();
1617: 
1618:   /* Register rtl specific functions for cfg.  */
1619:   rtl_register_cfg_hooks ();
1620: 
1621:   init_block = construct_init_block ();
1622: 
1623:   FOR_BB_BETWEEN (bb, init_block->next_bb, EXIT_BLOCK_PTR, next_bb)
1624:     bb = expand_gimple_basic_block (bb, dump_file);
1625: 
1626:   construct_exit_block ();
1627: 
1628:   /* We're done expanding trees to RTL.  */
1629:   currently_expanding_to_rtl = 0;
1630: 
1631:   /* Convert tree EH labels to RTL EH labels, and clean out any unreachable
1632:      EH regions.  */
1633:   convert_from_eh_region_ranges ();
1634: 
1635:   rebuild_jump_labels (get_insns ());
1636:   find_exception_handler_labels ();
1637: 
1638:   blocks = sbitmap_alloc (last_basic_block);
1639:   sbitmap_ones (blocks);
1640:   find_many_sub_basic_blocks (blocks);
1641:   purge_all_dead_edges ();
1642:   sbitmap_free (blocks);
1643: 
1644:   compact_blocks ();
1645: #ifdef ENABLE_CHECKING
1646:   verify_flow_info();
1647: #endif
1648: 
1649:   /* There's no need to defer outputting this function any more; we
1650:      know we want to output it.  */
1651:   DECL_DEFER_OUTPUT (current_function_decl) = 0;
1652: 
1653:   /* Now that we're done expanding trees to RTL, we shouldn't have any
1654:      more CONCATs anywhere.  */
1655:   generating_concat_p = 0;
1656: 
1657:   finalize_block_changes ();
1658: 
1659:   if (dump_file)
1660:     {
1661:       fprintf (dump_file,
1662:                "\n\n;;\n;; Full RTL generated for this function:\n;;\n");
1663:       /* And the pass manager will dump RTL for us.  */
1664:     }
1665: 
1666:   /* If we're emitting a nested function, make sure its parent gets
1667:      emitted as well.  Doing otherwise confuses debug info.  */
1668:   {   
1669:     tree parent;
1670:     for (parent = DECL_CONTEXT (current_function_decl);
1671:          parent != NULL_TREE;
1672:          parent = get_containing_scope (parent))
1673:       if (TREE_CODE (parent) == FUNCTION_DECL)
1674:         TREE_SYMBOL_REFERENCED (DECL_ASSEMBLER_NAME (parent)) = 1;
1675:   }
1676:     
1677:   /* We are now committed to emitting code for this function.  Do any
1678:      preparation, such as emitting abstract debug info for the inline
1679:      before it gets mangled by optimization.  */
1680:   if (cgraph_function_possibly_inlined_p (current_function_decl))
1681:     (*debug_hooks->outlining_inline_function) (current_function_decl);
1682: 
1683:   TREE_ASM_WRITTEN (current_function_decl) = 1;
1684: 
1685:   /* After expanding, the return labels are no longer needed. */
1686:   return_label = NULL;
1687:   naked_return_label = NULL;
1688: }
1689: 



リンク元

Advertisement