Exemplo n.º 1
0
void
emit_local_var (tree decl)
{
    /* Create RTL for this variable.  */
    if (!DECL_RTL_SET_P (decl))
    {
        if (DECL_C_HARD_REGISTER (decl))
            /* The user specified an assembler name for this variable.
               Set that up now.  */
            rest_of_decl_compilation
            (decl, IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
             /*top_level=*/0, /*at_end=*/0);
        else
            expand_decl (decl);
    }

    if (DECL_INITIAL (decl))
    {
        /* Actually do the initialization.  */
        if (stmts_are_full_exprs_p ())
            expand_start_target_temps ();

        expand_decl_init (decl);

        if (stmts_are_full_exprs_p ())
            expand_end_target_temps ();
    }
}
Exemplo n.º 2
0
void
emit_local_var (tree decl)
{
  /* Create RTL for this variable.  */
  if (!DECL_RTL_SET_P (decl))
    {
      if (DECL_HARD_REGISTER (decl))
	/* The user specified an assembler name for this variable.
	   Set that up now.  */
	rest_of_decl_compilation (decl, 0, 0);
      else
	expand_decl (decl);
    }
}
Exemplo n.º 3
0
tree 
tree_code_create_variable (unsigned int storage_class,
                               unsigned char* chars,
                               unsigned int length,
                               unsigned int expression_type,
                               tree init,
                               unsigned char* filename,
                               int lineno)
{
  tree var_type;
  tree var_id;
  tree var_decl;

  /* 1. Build the type.  */
  var_type = get_type_for_numeric_type (expression_type);

  /* 2. Build the name.  */
  if (chars[length] != 0)
    abort (); /* Should be null terminated.  */

  var_id = get_identifier ((const char*)chars);

  /* 3. Build the decl and set up init.  */
  var_decl = build_decl (VAR_DECL, var_id, var_type);

  /* 3a. Initialization.  */
  if (init)
    DECL_INITIAL (var_decl) = build1 (CONVERT_EXPR, var_type, init);
  else
    DECL_INITIAL (var_decl) = NULL_TREE;
      
  /* 4. Compute size etc.  */
  layout_decl (var_decl, 0);
      
  if (TYPE_SIZE (var_type) == 0)
    abort (); /* Did not calculate size.  */

  DECL_CONTEXT (var_decl) = current_function_decl;

  DECL_SOURCE_FILE (var_decl) = (const char *)filename;
  DECL_SOURCE_LINE (var_decl) = lineno;

  /* Set the storage mode and whether only visible in the same file.  */
  switch (storage_class)
    {
    case STATIC_STORAGE:
      TREE_STATIC (var_decl) = 1;
      TREE_PUBLIC (var_decl) = 0;
      break;

    case AUTOMATIC_STORAGE:
      TREE_STATIC (var_decl) = 0;
      TREE_PUBLIC (var_decl) = 0;
      break;
      
    case EXTERNAL_DEFINITION_STORAGE:
      TREE_STATIC (var_decl) = 0; 
      TREE_PUBLIC (var_decl) = 1;
      break;
      
    case EXTERNAL_REFERENCE_STORAGE:
      DECL_EXTERNAL (var_decl) = 1;
      TREE_PUBLIC (var_decl) = 0;
      break;
      
    default:
      abort ();
    }
      
  /* This should really only be set if the variable is used.  */
  TREE_USED (var_decl) = 1;
      
  /* Expand declaration and initial value if any.  */
  
  if (TREE_STATIC (var_decl)) 
    rest_of_decl_compilation (var_decl, 0, 0, 0);
  else
    {
      expand_decl (var_decl);
      if (DECL_INITIAL (var_decl))
        expand_decl_init (var_decl);
    }
  
  return pushdecl (copy_node (var_decl));
  
}