Re : Re : Re : Tr : Re : Re : Re : add a new gcc fe based on gcalc or sample_fe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 






----- Message d'origine ----
De : Philip Herron <redbrain@xxxxxxxxxxx>
À : charfi asma <charfiasma@xxxxxxxx>
Cc : gcc-help@xxxxxxxxxxx
Envoyé le : Mar 5 octobre 2010, 23h 25min 37s
Objet : Re: Re : Re : Tr : Re : Re : Re : add a new gcc fe based on gcalc or 
sample_fe

> I debugged manually the functions calls: toplev_main --> do_compile-->
> compile_file--> parse_file() --> until cgraph_mark_rechable_node(node) in
> cgrpah.c
> the problem comes from the instruction
> cgraph_mark_reachable_node (struct cgraph_node *node)
> {
>  if (!node->reachable && node->local.finalized)
>    {
>      printf("not reachable node and local.finalize=true \n");
>      if (cgraph_global_info_ready)
>        {
>       printf("global_info_ready are true \n");
>      /* Verify that function does not appear to be needed out of blue
>         during the optimization process.  This can happen for extern
>         inlines when bodies was removed after inlining.  */
>      gcc_assert ((node->analyzed || node->in_other_partition
>               || DECL_EXTERNAL (node->decl)));
>      printf("end of gcc assert \n");
>    }
> ...
> }
> the last printf is not printed, so the problem comes from the gcc_assert.
>

Its best to avoid tracking code into the middle end, from what i have
read you have a test.uml which contains some dummy code which you want
to GENERIC'ise it. I remember you said you dont have a parser, i
havent had time to look over your code but you need to great the
GENERIC tree's yourself then pass this to the middlend. Have you
looked at our preliminary documentation in docs/languages.texi in the
gcalc branch? It might help.

I may be missing something since i havent looked at your code yet but
i wll tomorrow :) see if i can help.

--Phil

Hello,

My code is not so hard it is only a main function int main() { return 0;} that I 
want to pass to the middle end.
I followed the gclac fe and the sample_fe and I only put the Generic 
representation of this function in the getdecls langhook :
the error comes from cgraph_finalize_function(main_fn_decl, false) call and 
specially from the cgraph_mark_rechable_node(node) call.

tree uml_getdecls (void)
{
  /* Create the main function as base frame: the gcc middle-end only knows about 
functions */

  tree main_fn_type = build_function_type_list(integer_type_node, NULL_TREE);
  tree main_fn_decl = build_decl(BUILTINS_LOCATION, 
FUNCTION_DECL,get_identifier("main"), main_fn_type);

  DECL_CONTEXT(main_fn_decl) = NULL_TREE;
  TREE_STATIC(main_fn_decl) = true;
  TREE_PUBLIC(main_fn_decl) = true;
  DECL_ARGUMENTS(main_fn_decl) = NULL_TREE;

  /* Define the return type (represented by RESULT_DECL) for the main functin */
  tree main_ret = build_decl(BUILTINS_LOCATION, RESULT_DECL, NULL_TREE, 
TREE_TYPE(main_fn_type));
  DECL_CONTEXT(main_ret) = main_fn_decl;
  DECL_ARTIFICIAL(main_ret) = true;
  DECL_IGNORED_P(main_ret) = true;
  DECL_RESULT(main_fn_decl) = main_ret;

  /* This is usually used for debugging purpose. this is currently unused */
  tree main_art_block = build_block(NULL_TREE, NULL_TREE, NULL_TREE, NULL_TREE);
  DECL_INITIAL(main_fn_decl) = main_art_block;

  /* add the final return statement,basically just a 'return 0'. 
   * This is not perfect because optimization would then optimize away all 
instructions */

  tree main_stmts = alloc_stmt_list ();
  tree main_set_ret = build2(MODIFY_EXPR, TREE_TYPE(main_ret), main_ret, 
build_int_cst(integer_type_node, 0));
  TREE_USED(main_set_ret) = true;
  tree main_ret_expr = build1(RETURN_EXPR, void_type_node, main_set_ret);
  append_to_statement_list(main_ret_expr, &main_stmts);

  /* function binding */
  DECL_SAVED_TREE(main_fn_decl) = build3(BIND_EXPR, void_type_node, NULL_TREE, 
main_stmts, main_art_block);

  /* Prepare the function for the GCC middle-end */
  gimplify_function_tree(main_fn_decl);
  cgraph_finalize_function(main_fn_decl, false);

  /* finalize and optimize the code */
  cgraph_finalize_compilation_unit( );
  cgraph_optimize();
  return main_fn_decl;
}
    

thanks

Asma







[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux