예제 #1
0
파일: treetree.c 프로젝트: aosm/gccfast
/* Wrapup a function contained in file FILENAME, ending at line LINENO.  */
void 
tree_code_create_function_wrapup (unsigned char* filename,
                                 int lineno)
{
  tree block;
  tree fn_decl;

  fn_decl = current_function_decl;
  
  emit_line_note ((const char *)filename, lineno); /* Output the line number information.  */

  /* Get completely built level from debugger symbol table.  */
  
  block = (*lang_hooks.decls.poplevel) (1, 0, 0);
  
  /* Emit rtl for end of scope.  */
  
  expand_end_bindings (block, 0, 1);
  
  /* Emit rtl for end of function.  */
  
  expand_function_end ((const char *)filename, lineno, 0, fn_decl);
  
  /* Pop the level.  */

  block = (*lang_hooks.decls.poplevel) (1, 0, 1);

  /* And attach it to the function.  */
  
  DECL_INITIAL (fn_decl) = block;
  
  /* Emit rtl for end of scope.  */
  
  expand_end_bindings (block, 0, 1);
  
  /* Call optimization and convert optimized rtl to assembly code.  */
  
  rest_of_compilation (fn_decl);
  
  /* We are not inside of any scope now.  */
  
  current_function_decl = NULL_TREE;
}
예제 #2
0
void
write_resource_constructor (void)
{
  tree init_name, init_type, init_decl;
  tree iter;
  location_t saved_loc = input_location;
  char *resource_ctor_name;

  /* Only do work if required.  */
  if (resources == NULL_TREE)
    return;

  resource_ctor_name = concat (IDENTIFIER_POINTER (get_file_function_name ('I')),
			       "_resource", NULL);
  init_name = get_identifier (resource_ctor_name);
  free (resource_ctor_name);
  init_type = build_function_type (void_type_node, end_params_node);

  init_decl = build_decl (FUNCTION_DECL, init_name, init_type);
  DECL_SOURCE_LINE (init_decl) = 0;
  SET_DECL_ASSEMBLER_NAME (init_decl, init_name);
  TREE_STATIC (init_decl) = 1;
  current_function_decl = init_decl;
  DECL_RESULT (init_decl) = build_decl (RESULT_DECL, 
					NULL_TREE, void_type_node);

  /* It can be a static function as long as collect2 does not have
     to scan the object file to find its ctor/dtor routine.  */
  TREE_PUBLIC (init_decl) = ! targetm.have_ctors_dtors;

  pushlevel (0);
  make_decl_rtl (init_decl, NULL);
  init_function_start (init_decl);
  expand_function_start (init_decl, 0);

  /* Write out entries in the same order in which they were defined.  */
  for (iter = nreverse (resources); iter != NULL_TREE;
       iter = TREE_CHAIN (iter))
    {
      emit_library_call (registerResource_libfunc, 0, VOIDmode, 1,
			 expand_expr (build_address_of (TREE_VALUE (iter)),
				      0, Pmode, 0),
			 Pmode);
    }

  input_location = DECL_SOURCE_LOCATION (init_decl);
  expand_function_end ();
  poplevel (1, 0, 1);
  { 
    /* Force generation, even with -O3 or deeper.  Gross hack.
       FIXME.  */
    int saved_flag = flag_inline_functions;
    flag_inline_functions = 0;	
    rest_of_compilation (init_decl);
    flag_inline_functions = saved_flag;
  }
  current_function_decl = NULL_TREE;
  (* targetm.asm_out.constructor) (XEXP (DECL_RTL (init_decl), 0),
				   DEFAULT_INIT_PRIORITY);
  input_location = saved_loc;
}