Example #1
0
static void
sdbout_reg_parms (tree parms)
{
  for (; parms; parms = TREE_CHAIN (parms))
    if (DECL_NAME (parms))
      {
	const char *name = IDENTIFIER_POINTER (DECL_NAME (parms));

	/* Report parms that live in registers during the function
	   but were passed in memory.  */
	if (REG_P (DECL_RTL (parms))
	    && REGNO (DECL_RTL (parms)) < FIRST_PSEUDO_REGISTER
	    && PARM_PASSED_IN_MEMORY (parms))
	  {
	    if (name == 0 || *name == 0)
	      name = gen_fake_label ();
	    PUT_SDB_DEF (name);
	    PUT_SDB_INT_VAL (DBX_REGISTER_NUMBER (REGNO (DECL_RTL (parms))));
	    PUT_SDB_SCL (C_REG);
	    PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
	    PUT_SDB_ENDEF;
	  }
	/* Report parms that live in memory but not where they were passed.  */
	else if (MEM_P (DECL_RTL (parms))
		 && GET_CODE (XEXP (DECL_RTL (parms), 0)) == PLUS
		 && CONST_INT_P (XEXP (XEXP (DECL_RTL (parms), 0), 1))
		 && PARM_PASSED_IN_MEMORY (parms)
		 && ! rtx_equal_p (DECL_RTL (parms), DECL_INCOMING_RTL (parms)))
	  {
#if 0 /* ??? It is not clear yet what should replace this.  */
	    int offset = DECL_OFFSET (parms) / BITS_PER_UNIT;
	    /* A parm declared char is really passed as an int,
	       so it occupies the least significant bytes.
	       On a big-endian machine those are not the low-numbered ones.  */
	    if (BYTES_BIG_ENDIAN
		&& offset != -1
		&& TREE_TYPE (parms) != DECL_ARG_TYPE (parms))
	      offset += (GET_MODE_SIZE (TYPE_MODE (DECL_ARG_TYPE (parms)))
			 - GET_MODE_SIZE (GET_MODE (DECL_RTL (parms))));
	    if (INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1)) != offset) {...}
#endif
	      {
		if (name == 0 || *name == 0)
		  name = gen_fake_label ();
		PUT_SDB_DEF (name);
		PUT_SDB_INT_VAL (DEBUGGER_AUTO_OFFSET
				 (XEXP (DECL_RTL (parms), 0)));
		PUT_SDB_SCL (C_AUTO);
		PUT_SDB_TYPE (plain_type (TREE_TYPE (parms)));
		PUT_SDB_ENDEF;
	      }
	  }
      }
const struct attribute_spec *
lookup_attribute_spec (tree name)
{
  struct substring attr;

  attr.str = IDENTIFIER_POINTER (name);
  attr.length = IDENTIFIER_LENGTH (name);
  extract_attribute_substring (&attr);
  return (const struct attribute_spec *)
    htab_find_with_hash (attribute_hash, &attr,
			 substring_hash (attr.str, attr.length));
}
Example #3
0
static void read_data( tree t )
{
    if ( DECL_NAME(t) )
	{
	    printf ( "       data \'%s\'\n", IDENTIFIER_POINTER(DECL_NAME(t)) );
	}
    else
	{
	    printf ( "       data \'%c_%u\'\n", (TREE_CODE(t)==CONST_DECL)?'C':'D', DECL_UID(t) );
	}

    read_type ( TREE_TYPE(t) );
}
Example #4
0
unsigned int pass_function()
{
    warning(0, "%<%s%>", context);

    const char *identifier = IDENTIFIER_POINTER(DECL_NAME(cfun->decl));

    if ( mylist_find( g_myproof_pass->functions, function_exists, (void*)identifier ) == NULL )
	{
	    mylist_insert( &(g_myproof_pass->functions), create_function_struct( identifier ) );
	}

    return 0;
}
Example #5
0
/*
 *	Create a DECL_... node of code CODE, name NAME
 *	and data type TYPE. We do NOT enter this node
 *	in any sort of symbol table.
 *
 *	layout_decl is used to set up the decl's storage layout.
 *	Other slots are initialized to 0 or null pointers.
 */
tree
build_decl (enum tree_code code, tree name, tree type)
{
	register tree	t;

	t = make_node (code);

#if (0)	/*************************************/
	/*
	 *	That is not done, deliberately, so that
	 *	having error_mark_node as the type can
	 *	suppress useless errors in the use of
	 *	this variable.
	 */
	if (type == error_mark_node)
		type = integer_type_node;
#endif	/*************************************/

	DECL_NAME (t) = name;

	if (name)
	{
		DECL_PRINT_NAME (t) = IDENTIFIER_POINTER (name);
		DECL_ASSEMBLER_NAME (t) = IDENTIFIER_POINTER (name);
	}

	TREE_TYPE (t) = type;
	DECL_ARGUMENTS (t) = NULL_TREE;
	DECL_INITIAL (t) = NULL_TREE;

	if (code == VAR_DECL || code == PARM_DECL || code == RESULT_DECL)
		layout_decl (t, 0);
	elif (code == FUNCTION_DECL)
		DECL_MODE (t) = FUNCTION_MODE;

	return (t);

}	/* end build_decl */
Example #6
0
/* Handle an attribute requiring a FUNCTION_DECL;
   arguments as in struct attribute_spec.handler.  */
static tree
avm2_handle_fndecl_attribute (tree *node, tree name,
                              tree args,
                              int flags ATTRIBUTE_UNUSED,
                              bool *no_add_attrs)
{
    if (TREE_CODE (*node) != FUNCTION_DECL)
    {
        warning (OPT_Wattributes, "%qs attribute only applies to functions",
                 IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
    }
    return NULL_TREE;
}
Example #7
0
static tree
gen_stdcall_or_fastcall_suffix (tree decl, bool fastcall)
{
  int total = 0;
  /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
     of DECL_ASSEMBLER_NAME.  */
  const char *asmname =  IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  char *newsym;
  char *p;
  tree formal_type;

  /* Do not change the identifier if a verbatim asmspec or already done. */
  if (*asmname == '*' || strchr (asmname, '@'))
    return DECL_ASSEMBLER_NAME (decl);

  formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));
  if (formal_type != NULL_TREE)
    {
      /* These attributes are ignored for variadic functions in
         i386.c:ix86_return_pops_args. For compatibility with MS
         compiler do not add @0 suffix here.  */ 
      if (TREE_VALUE (tree_last (formal_type)) != void_type_node)
        return DECL_ASSEMBLER_NAME (decl);

      /* Quit if we hit an incomplete type.  Error is reported
         by convert_arguments in c-typeck.c or cp/typeck.c.  */
      while (TREE_VALUE (formal_type) != void_type_node
	     && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))	
 /* APPLE LOCAL begin mainline 2005-10-12 */
        {
          int parm_size
            = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));
          /* Must round up to include padding.  This is done the same
             way as in store_one_arg.  */
          parm_size = ((parm_size + PARM_BOUNDARY - 1)
                       / PARM_BOUNDARY * PARM_BOUNDARY);
          total += parm_size;
          formal_type = TREE_CHAIN (formal_type); \
        }
 /* APPLE LOCAL end mainline 2005-10-12 */
    }

  /* Assume max of 8 base 10 digits in the suffix.  */
  newsym = alloca (1 + strlen (asmname) + 1 + 8 + 1);
  p = newsym;
  if (fastcall)
    *p++ = FASTCALL_PREFIX;
  sprintf (p, "%s@%d", asmname, total/BITS_PER_UNIT);
  return get_identifier (newsym);
}
Example #8
0
/* Handle a "shared" attribute;
   arguments as in struct attribute_spec.handler.  */
tree
ix86_handle_shared_attribute (tree *node, tree name,
                              tree args ATTRIBUTE_UNUSED,
                              int flags ATTRIBUTE_UNUSED, bool *no_add_attrs)
{
    if (TREE_CODE (*node) != VAR_DECL)
    {
        warning (OPT_Wattributes, "%qs attribute only applies to variables",
                 IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
    }

    return NULL_TREE;
}
Example #9
0
void
declare_function_name ()
{
  tree decl, init;
  char *name, *printable_name;

  if (current_function_decl == NULL)
    {
      name = "";
      printable_name = "top level";
    }
  else
    {
      char *kind = "function";
      if (TREE_CODE (TREE_TYPE (current_function_decl)) == METHOD_TYPE)
	kind = "method";
      /* Allow functions to be nameless (such as artificial ones).  */
      if (DECL_NAME (current_function_decl))
        name = IDENTIFIER_POINTER (DECL_NAME (current_function_decl));
      else
	name = "";
      printable_name = (*decl_printable_name) (current_function_decl, &kind);
    }

  push_obstacks_nochange ();
  decl = build_decl (VAR_DECL, get_identifier ("__FUNCTION__"),
		     char_array_type_node);
  TREE_STATIC (decl) = 1;
  TREE_READONLY (decl) = 1;
  DECL_SOURCE_LINE (decl) = 0;
  DECL_IN_SYSTEM_HEADER (decl) = 1;
  DECL_IGNORED_P (decl) = 1;
  init = build_string (strlen (name) + 1, name);
  TREE_TYPE (init) = char_array_type_node;
  DECL_INITIAL (decl) = init;
  finish_decl (pushdecl (decl), init, NULL_TREE);

  push_obstacks_nochange ();
  decl = build_decl (VAR_DECL, get_identifier ("__PRETTY_FUNCTION__"),
		     char_array_type_node);
  TREE_STATIC (decl) = 1;
  TREE_READONLY (decl) = 1;
  DECL_SOURCE_LINE (decl) = 0;
  DECL_IN_SYSTEM_HEADER (decl) = 1;
  DECL_IGNORED_P (decl) = 1;
  init = build_string (strlen (printable_name) + 1, printable_name);
  TREE_TYPE (init) = char_array_type_node;
  DECL_INITIAL (decl) = init;
  finish_decl (pushdecl (decl), init, NULL_TREE);
}
Example #10
0
tree find_instr_node(tree temp)
{
	int ret = 0;
    tree decl_node;
    PWord_t PV;
    JSLG(PV, decl_map, mf_varname_tree(temp));
    if(PV){
        decl_node = ((tree) *PV);
        gcc_assert(decl_node != NULL_TREE);
        DEBUGLOG("[find_instr] Match found for %s --> %s\n",mf_varname_tree(temp), IDENTIFIER_POINTER(DECL_NAME(decl_node)));
        return decl_node;
    }else
        DEBUGLOG("[find_instr] Match not found for %s\n",mf_varname_tree(temp));
    return NULL_TREE;
}
const char *
gfc_get_string (const char *format, ...)
{
  char temp_name[128];
  va_list ap;
  tree ident;

  va_start (ap, format);
  vsnprintf (temp_name, sizeof(temp_name), format, ap);
  va_end (ap);
  temp_name[sizeof(temp_name)-1] = 0;

  ident = get_identifier (temp_name);
  return IDENTIFIER_POINTER (ident);
}
Example #12
0
tree
add_objc_string (tree ident, string_section section)
{
  tree *chain, decl, type;
  char buf[BUFSIZE];

  switch (section)
    {
    case class_names:
      chain = &class_names_chain;
      snprintf (buf, BUFSIZE, "_OBJC_ClassName_%s", IDENTIFIER_POINTER (ident));
      break;
    case meth_var_names:
      chain = &meth_var_names_chain;
      snprintf (buf, BUFSIZE, "_OBJC_METH_VAR_NAME_%d", meth_var_names_idx++);
      break;
    case meth_var_types:
      chain = &meth_var_types_chain;
      snprintf (buf, BUFSIZE, "_OBJC_METH_VAR_TYPE_%d", meth_var_types_idx++);
      break;
    case prop_names_attr:
      chain = &prop_names_attr_chain;
      snprintf (buf, BUFSIZE, "_OBJC_PropertyAttributeOrName_%d", property_name_attr_idx++);
      break;
    default:
      gcc_unreachable ();
    }

  while (*chain)
    {
      if (TREE_VALUE (*chain) == ident)
	return convert (string_type_node,
			build_unary_op (input_location,
					ADDR_EXPR, TREE_PURPOSE (*chain), 1));

      chain = &TREE_CHAIN (*chain);
    }

  type = build_sized_array_type (char_type_node, IDENTIFIER_LENGTH (ident) + 1);
  /* Get a runtime-specific string decl which will be finish_var()'ed in
     generate_strings ().  */
  decl = (*runtime.string_decl) (type, buf, section);
  TREE_CONSTANT (decl) = 1;
  *chain = tree_cons (decl, ident, NULL_TREE);

  return convert (string_type_node,
		  build_unary_op (input_location, ADDR_EXPR, decl, 1));
}
Example #13
0
enum ld_plugin_symbol_resolution
lto_symtab_get_resolution (tree decl)
{
  lto_symtab_entry_t e;

  gcc_assert (DECL_ASSEMBLER_NAME_SET_P (decl));

  e = lto_symtab_get ((*targetm.asm_out.mangle_assembler_name)
		      (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl))));
  while (e && e->decl != decl)
    e = e->next;
  if (!e)
    return LDPR_UNKNOWN;

  return e->resolution;
}
Example #14
0
static void
print_decl_name (FILE *outfile, tree node)
{
  if (DECL_NAME (node))
    fputs (IDENTIFIER_POINTER (DECL_NAME (node)), outfile);
  else
    {
      if (TREE_CODE (node) == LABEL_DECL && LABEL_DECL_UID (node) != -1)
        fprintf (outfile, "L." HOST_WIDE_INT_PRINT_DEC, LABEL_DECL_UID (node));
      else
        {
          char c = TREE_CODE (node) == CONST_DECL ? 'C' : 'D';
          fprintf (outfile, "%c.%u", c, DECL_UID (node));
        }
    }
}
Example #15
0
void
machopic_output_function_base_name (FILE *file)
{
  const char *current_name;

  /* If dynamic-no-pic is on, we should not get here.  */
  gcc_assert (!MACHO_DYNAMIC_NO_PIC_P);
  current_name =
    IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl));
  if (function_base_func_name != current_name)
    {
      ++current_pic_label_num;
      function_base_func_name = current_name;
    }
  fprintf (file, "\"L%011d$pb\"", current_pic_label_num);
}
Example #16
0
gcov_type
autofdo_source_profile::get_callsite_total_count (
    struct cgraph_edge *edge) const
{
  inline_stack stack;
  stack.safe_push (std::make_pair (edge->callee->decl, 0));
  get_inline_stack (gimple_location (edge->call_stmt), &stack);

  function_instance *s = get_function_instance_by_inline_stack (stack);
  if (s == NULL
      || afdo_string_table->get_index (IDENTIFIER_POINTER (
             DECL_ASSEMBLER_NAME (edge->callee->decl))) != s->name ())
    return 0;

  return s->total_count ();
}
Example #17
0
static unsigned int
myprof_pass ( void )
{
  basic_block bb;
  gimple_stmt_iterator gsi;

  int nbop = 0;

  //printf("Debut de la passe\n");

  fprintf ( stderr, "* MIHP on %s()\n", IDENTIFIER_POINTER(DECL_NAME(cfun->decl)) );

  FOR_EACH_BB ( bb )
    {
       fprintf ( stdout, "  ** BB %d\n", bb->index ); 

       //*nb2opSuperior=0;
/*       nbop = 0;*/

     nbloads = 0;
     nbstores = 0;

      for ( gsi=gsi_start_bb(bb); !gsi_end_p(gsi); gsi_next(&gsi) )
      {
/*          print_gimple_stmt ( stdout, gsi_stmt(gsi), 0, 0 );*/
	        
          myprof_read_stmt ( gsi_stmt(gsi), &nbop);
      }
        
                  
     if(nbloads > 0) 
      fprintf(stdout, "%d load\n", nbloads);
     
     if(nbstores > 0)
      fprintf(stdout, "%d store\n", nbstores);
        
/*        fprintf(stdout, "nombre d'operations: %d\n", nbop);*/

      //printf("Nombre d'operations superieures à 2: %d\n", nb2opSuperior);
    }

  /* recursively read looops */
  if ( cfun->x_current_loops != NULL )
    myprof_read_loop ( cfun->x_current_loops->tree_root );

  return 0;
}
Example #18
0
void
gcc_genericize (tree fndecl)
{
  FILE *dump_orig;
  int local_dump_flags;
  struct cgraph_node *cgn;

  /* Dump the C-specific tree IR.  */
  dump_orig = gcc_dump_begin (TDI_original, &local_dump_flags);

  /*
	  if(dump_orig)
	{
		printf("should start dumping original tree.\n");
	}else{
		printf("no dumping original tree flag.\n");
	}
	*/

  if (dump_orig)
	{
	  fprintf (dump_orig, "\n;; Function %s",
		   lang_hooks.decl_printable_name (fndecl, 2));

	  astTreeBuilder->addFunctionName(lang_hooks.decl_printable_name (fndecl, 2));

	  fprintf (dump_orig, " (%s)\n",
		   (!DECL_ASSEMBLER_NAME_SET_P (fndecl) ? "null"
		: IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (fndecl))));
	  fprintf (dump_orig, ";; enabled by -%s\n", dump_flag_name (TDI_original));
	  fprintf (dump_orig, "\n");

	  //if (local_dump_flags & TDF_RAW)
	gcc_dump_node (DECL_SAVED_TREE (fndecl),
		   TDF_SLIM | local_dump_flags, dump_orig);
 //     else
//	print_c_tree (dump_orig, DECL_SAVED_TREE (fndecl));
	  fprintf (dump_orig, "\n");
	  restore_state();
	  gcc_dump_end (TDI_original, dump_orig);
	}

  /* Dump all nested functions now.  */
  cgn = cgraph_node (fndecl);
  for (cgn = cgn->nested; cgn ; cgn = cgn->next_nested)
	gcc_genericize (cgn->decl);
}
void
write_constant_pool (CPool *cpool, unsigned char *buffer, int length)
{
  unsigned char *ptr = buffer;
  int i = 1;
  union cpool_entry *datap = &cpool->data[1];
  PUT2 (cpool->count);
  for ( ;  i < cpool->count;  i++, datap++)
    {
      int tag = cpool->tags[i];
      PUT1 (tag);
      switch (tag)
	{
	case CONSTANT_NameAndType:
	case CONSTANT_Fieldref:
	case CONSTANT_Methodref:
	case CONSTANT_InterfaceMethodref:
	case CONSTANT_Float:
	case CONSTANT_Integer:
	  PUT4 (datap->w);
	  break;
	case CONSTANT_Class:
	case CONSTANT_String:
	  PUT2 (datap->w);
	  break;
	  break;
	case CONSTANT_Long:
	case CONSTANT_Double:
	  PUT4(datap->w);
	  i++;
	  datap++;
	  PUT4 (datap->w);
	  break;
	case CONSTANT_Utf8:
	  {
	    tree t = datap->t;
	    int len = IDENTIFIER_LENGTH (t);
	    PUT2 (len);
	    PUTN (IDENTIFIER_POINTER (t), len);
	  }
	  break;
	}
    }

  if (ptr != buffer + length)
    abort ();
}
Example #20
0
int
string_table::get_index_by_decl (tree decl) const
{
  char *name
      = get_original_name (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
  int ret = get_index (name);
  free (name);
  if (ret != -1)
    return ret;
  ret = get_index (lang_hooks.dwarf_name (decl, 0));
  if (ret != -1)
    return ret;
  if (DECL_ABSTRACT_ORIGIN (decl) && DECL_ABSTRACT_ORIGIN (decl) != decl)
    return get_index_by_decl (DECL_ABSTRACT_ORIGIN (decl));

  return -1;
}
Example #21
0
static const char *
aarch64_mangle_builtin_scalar_type (const_tree type)
{
  int i = 0;

  while (aarch64_scalar_builtin_types[i] != NULL)
    {
      const char *name = aarch64_scalar_builtin_types[i];

      if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
	  && DECL_NAME (TYPE_NAME (type))
	  && !strcmp (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))), name))
	return aarch64_scalar_builtin_types[i];
      i++;
    }
  return NULL;
}
Example #22
0
File: typeck.c Project: AHelper/gcc
tree
get_type_from_signature (tree signature)
{
  const unsigned char *sig = (const unsigned char *) IDENTIFIER_POINTER (signature);
  int len = IDENTIFIER_LENGTH (signature);
  tree type;
  /* Primitive types aren't cached. */
  if (len <= 1)
    return parse_signature_string (sig, len);
  type = IDENTIFIER_SIGNATURE_TYPE (signature);
  if (type == NULL_TREE)
    {
      type = parse_signature_string (sig, len);
      IDENTIFIER_SIGNATURE_TYPE (signature) = type;
    }
  return type;
}
Example #23
0
/* Set the DECL_ASSEMBLER_NAME for DECL.  */
void
lhd_set_decl_assembler_name (tree decl)
{
  tree id;

  /* set_decl_assembler_name may be called on TYPE_DECL to record ODR
     name for C++ types.  By default types have no ODR names.  */
  if (TREE_CODE (decl) == TYPE_DECL)
    return;

  /* The language-independent code should never use the
     DECL_ASSEMBLER_NAME for lots of DECLs.  Only FUNCTION_DECLs and
     VAR_DECLs for variables with static storage duration need a real
     DECL_ASSEMBLER_NAME.  */
  gcc_assert (TREE_CODE (decl) == FUNCTION_DECL
	      || (TREE_CODE (decl) == VAR_DECL
		  && (TREE_STATIC (decl)
		      || DECL_EXTERNAL (decl)
		      || TREE_PUBLIC (decl))));

  /* By default, assume the name to use in assembly code is the same
     as that used in the source language.  (That's correct for C, and
     GCC used to set DECL_ASSEMBLER_NAME to the same value as
     DECL_NAME in build_decl, so this choice provides backwards
     compatibility with existing front-ends.  This assumption is wrapped
     in a target hook, to allow for target-specific modification of the
     identifier.

     Can't use just the variable's own name for a variable whose scope
     is less than the whole compilation.  Concatenate a distinguishing
     number - we use the DECL_UID.  */

  if (TREE_PUBLIC (decl) || DECL_FILE_SCOPE_P (decl))
    id = targetm.mangle_decl_assembler_name (decl, DECL_NAME (decl));
  else
    {
      const char *name = IDENTIFIER_POINTER (DECL_NAME (decl));
      char *label;

      ASM_FORMAT_PRIVATE_NAME (label, name, DECL_UID (decl));
      id = get_identifier (label);
    }
  SET_DECL_ASSEMBLER_NAME (decl, id);

}
Example #24
0
int
vfy_count_arguments (vfy_string signature)
{
  const char *ptr = IDENTIFIER_POINTER (signature);
  int arg_count = 0;

  /* Skip '('.  */
  ptr++;

  /* Count args.  */
  while (*ptr != ')')
    {
      ptr = skip_one_type (ptr);
      arg_count += 1;
    }

  return arg_count;
}
Example #25
0
static const char *
aarch64_mangle_builtin_vector_type (const_tree type)
{
  int i;
  int nelts = sizeof (aarch64_simd_types) / sizeof (aarch64_simd_types[0]);

  for (i = 0; i < nelts; i++)
    if (aarch64_simd_types[i].mode ==  TYPE_MODE (type)
	&& TYPE_NAME (type)
	&& TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
	&& DECL_NAME (TYPE_NAME (type))
	&& !strcmp
	     (IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))),
	      aarch64_simd_types[i].name))
      return aarch64_simd_types[i].mangle;

  return NULL;
}
Example #26
0
void gcc_plugin_finish_type(void *gcc_data, void *user_data)
{
    tree type = (tree) gcc_data;
    if (TREE_CODE(type) == ERROR_MARK) return;

    tree idnode = TYPE_NAME(type);

    // if the structure was declared with an explicit name then assign it that.
    if (idnode && TREE_CODE(idnode) == IDENTIFIER_NODE) {
        const char *name = IDENTIFIER_POINTER(idnode);
        XIL_CSUName(type, name);
    }

    // for C++ we check the type for a TYPE_DECL name within XIL_CSUName.
    // force this check now so that we don't get confused by any later typedefs.
    if (c_dialect_cxx())
        XIL_CSUName(type, NULL);
}
static int
mangle_record_type (tree type, int for_pointer)
{
  tree current;
  int match;
  int nadded_p = 0;
  int qualified;
  
  /* Does this name have a package qualifier? */
  qualified = QUALIFIED_P (DECL_NAME (TYPE_NAME (type)));

#define ADD_N() \
  do { obstack_1grow (mangle_obstack, 'N'); nadded_p = 1; } while (0)

  gcc_assert (TREE_CODE (type) == RECORD_TYPE);

  if (!TYPE_PACKAGE_LIST (type))
    set_type_package_list (type);

  match = find_compression_record_match (type, &current);
  if (match >= 0)
    {
      /* If we had a pointer, and there's more, we need to emit
	 'N' after 'P' (for_pointer tells us we already emitted it.) */
      if (for_pointer && current)
	ADD_N();
      emit_compression_string (match);
    }
  while (current)
    {
      /* Add the new type to the table */
      compression_table_add (TREE_PURPOSE (current));
      /* Add 'N' if we never got a chance to, but only if we have a qualified
         name.  For non-pointer elements, the name is always qualified. */
      if ((qualified || !for_pointer) && !nadded_p)
	ADD_N();
      /* Use the bare type name for the mangle. */
      append_gpp_mangled_name (IDENTIFIER_POINTER (TREE_VALUE (current)),
			       IDENTIFIER_LENGTH (TREE_VALUE (current)));
      current = TREE_CHAIN (current);
    }
  return nadded_p;
#undef ADD_N
}
Example #28
0
/* Handle a "selectany" attribute;
   arguments as in struct attribute_spec.handler.  */
tree
ix86_handle_selectany_attribute (tree *node, tree name,
                                 tree args ATTRIBUTE_UNUSED,
                                 int flags ATTRIBUTE_UNUSED,
                                 bool *no_add_attrs)
{
    /* The attribute applies only to objects that are initialized and have
       external linkage.  However, we may not know about initialization
       until the language frontend has processed the decl. We'll check for
       initialization later in encode_section_info.  */
    if (TREE_CODE (*node) != VAR_DECL || !TREE_PUBLIC (*node))
    {
        error ("%qs attribute applies only to initialized variables"
               " with external linkage",  IDENTIFIER_POINTER (name));
        *no_add_attrs = true;
    }

    return NULL_TREE;
}
Example #29
0
static tree
gen_regparm_prefix (tree decl, unsigned nregs)
{
  unsigned total = 0;
  /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
     of DECL_ASSEMBLER_NAME.  */
  const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  char *newsym;
  tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));

  if (formal_type != NULL_TREE)
    {
      /* This attribute is ignored for variadic functions.  */ 
      if (TREE_VALUE (tree_last (formal_type)) != void_type_node)
	return NULL_TREE;

      /* Quit if we hit an incomplete type.  Error is reported
	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
      while (TREE_VALUE (formal_type) != void_type_node
	     && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))	
	{
	  unsigned parm_size
	    = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));

	  /* Must round up to include padding.  This is done the same
	     way as in store_one_arg.  */
	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
		       / PARM_BOUNDARY * PARM_BOUNDARY);
	  total += parm_size;
	  formal_type = TREE_CHAIN (formal_type);
	}
    }

  if (nregs > total / BITS_PER_WORD)
    nregs = total / BITS_PER_WORD;
  gcc_assert (nregs <= 9);
  newsym = alloca (3 + strlen (asmname) + 1);
  return get_identifier_with_length (newsym,
				     sprintf (newsym,
					      "_%u@%s",
					      nregs,
					      asmname));
}
Example #30
0
static tree
gen_stdcall_or_fastcall_decoration (tree decl, char prefix)
{
  unsigned total = 0;
  /* ??? This probably should use XSTR (XEXP (DECL_RTL (decl), 0), 0) instead
     of DECL_ASSEMBLER_NAME.  */
  const char *asmname = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
  char *newsym;
  tree formal_type = TYPE_ARG_TYPES (TREE_TYPE (decl));

  if (formal_type != NULL_TREE)
    {
      /* These attributes are ignored for variadic functions in
	 i386.c:ix86_return_pops_args. For compatibility with MS
	 compiler do not add @0 suffix here.  */ 
      if (TREE_VALUE (tree_last (formal_type)) != void_type_node)
	return NULL_TREE;

      /* Quit if we hit an incomplete type.  Error is reported
	 by convert_arguments in c-typeck.c or cp/typeck.c.  */
      while (TREE_VALUE (formal_type) != void_type_node
	     && COMPLETE_TYPE_P (TREE_VALUE (formal_type)))	
	{
	  unsigned parm_size
	    = TREE_INT_CST_LOW (TYPE_SIZE (TREE_VALUE (formal_type)));

	  /* Must round up to include padding.  This is done the same
	     way as in store_one_arg.  */
	  parm_size = ((parm_size + PARM_BOUNDARY - 1)
		       / PARM_BOUNDARY * PARM_BOUNDARY);
	  total += parm_size;
	  formal_type = TREE_CHAIN (formal_type);
	}
    }

  newsym = alloca (1 + strlen (asmname) + 1 + 10 + 1);
  return get_identifier_with_length (newsym,
				     sprintf (newsym,
					      "%c%s@%u",
					      prefix,
					      asmname,
					      total / BITS_PER_UNIT));
}