码迷,mamicode.com
首页 > 其他好文 > 详细

gcc源代码分析,build_pointer_type ()函数分析

时间:2015-01-11 11:04:20      阅读:177      评论:0      收藏:0      [点我收藏+]

标签:gcc   源代码   分析   


      function = build (ADDR_EXPR, build_pointer_type (TREE_TYPE (function)),
            function);

继续分析上篇文章的这句。



/* Constructors for pointer, array and function types.
   (RECORD_TYPE, UNION_TYPE and ENUMERAL_TYPE nodes are
   constructed by language-dependent code, not here.)  */

/* Construct, lay out and return the type of pointers to TO_TYPE.
   If such a type has already been constructed, reuse it.  */

tree
build_pointer_type (to_type)
     tree to_type;
{
  register tree t = TYPE_POINTER_TO (to_type);

/* 下面是debug_tree(to_type);的结果

 <function_type 956e8
    type <integer_type 824d0 int permanent SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
        max <integer_cst 82534 literal permanent 2147483647
        pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
    permanent EP
    size <integer_cst 82dd8 type <integer_type 82848* unsigned int> literal permanent 8
    align 32 size_unit 8 sep_unit 0 symtab 0
    arg-types <tree_list 95698 permanent
        value <pointer_type 9117c type <integer_type 91130* char>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <function_type 912c0>
    chain <function_type 959b0>
*/


  register struct obstack *ambient_obstack = current_obstack;
  register struct obstack *ambient_saveable_obstack = saveable_obstack;

  /* First, if we already have a type for pointers to TO_TYPE, use it.  */

  if (t)
    return t;

  /* We need a new one.  If TO_TYPE is permanent, make this permanent too.  */
  if (TREE_PERMANENT (to_type))
    {
      current_obstack = &permanent_obstack;
      saveable_obstack = &permanent_obstack;
    }

  t = make_node (POINTER_TYPE);

/*下面是debug_tree(t);的结果

 <pointer_type 98f48 permanent VOID
    align 1 size_unit 1 sep_unit 0 symtab 0
*/

  TREE_TYPE (t) = to_type;

/*下面是debug_tree(t);的结果

 <pointer_type 98f48
    type <function_type 956e8
        type <integer_type 824d0 int permanent SI
            size <integer_cst 8254c literal permanent 4
            align 32 size_unit 8 sep_unit 32 symtab 0
            sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
            max <integer_cst 82534 literal permanent 2147483647
            pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
        permanent EP
        size <integer_cst 82dd8 literal permanent 8
        align 32 size_unit 8 sep_unit 0 symtab 0
        arg-types <tree_list 95698 permanent value <pointer_type 9117c>
        chain <function_type 959b0>

    permanent VOID
    align 1 size_unit 1 sep_unit 0 symtab 0


*/
  /* Record this type as the pointer to TO_TYPE.  */
  TYPE_POINTER_TO (to_type) = t;

/*

 <function_type 956e8
    type <integer_type 824d0 int permanent SI
        size <integer_cst 8254c literal permanent 4
        align 32 size_unit 8 sep_unit 32 symtab 0
        sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
        max <integer_cst 82534 literal permanent 2147483647
        pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
    permanent EP
    size <integer_cst 82dd8 type <integer_type 82848* unsigned int> literal permanent 8
    align 32 size_unit 8 sep_unit 0 symtab 0
    arg-types <tree_list 95698 permanent
        value <pointer_type 9117c type <integer_type 91130* char>
            permanent unsigned SI size <integer_cst 8254c 4>
            align 32 size_unit 8 sep_unit 32 symtab 0
            chain <function_type 912c0>
    pointer_to_this <pointer_type 98f48> chain <function_type 959b0>

*/



  /* Lay out the type.  This function has many callers that are concerned
     with expression-construction, and this simplifies them all.
     Also, it guarantees the TYPE_SIZE is permanent if the type is.  */
  layout_type (t);

  current_obstack = ambient_obstack;
  saveable_obstack = ambient_saveable_obstack;
  return t;
}


 <pointer_type 98f48
    type <function_type 956e8
        type <integer_type 824d0 int permanent SI
            size <integer_cst 8254c literal permanent 4
            align 32 size_unit 8 sep_unit 32 symtab 0
            sep <integer_cst 8251c literal permanent -2147483648 precision 32 min <integer_cst 8251c -2147483648>
            max <integer_cst 82534 literal permanent 2147483647
            pointer_to_this <pointer_type 88b4c> chain <integer_type 825bc* char>
        permanent EP
        size <integer_cst 82dd8 literal permanent 8
        align 32 size_unit 8 sep_unit 0 symtab 0
        arg-types <tree_list 95698 permanent value <pointer_type 9117c>
        pointer_to_this <pointer_type 98f48> chain <function_type 959b0>
    permanent unsigned SI size <integer_cst 8254c 4>
    align 32 size_unit 8 sep_unit 32 symtab 0


gcc源代码分析,build_pointer_type ()函数分析

标签:gcc   源代码   分析   

原文地址:http://blog.csdn.net/oldlinux/article/details/42607771

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!