FreeBSD/contrib/gcc/c-common.c
/* Build tree nodes and builtin functions common to both C and C++ language
   frontends.  */
Build tree nodes and builtin functions common to both C and C++ language
frontends.
Build tree nodes and builtin functions common to both C and C ++ language frontends .
void
c_common_nodes_and_builtins (void)
{
  int wchar_type_size;
  tree array_domain_type;
  tree va_list_ref_type_node;
  tree va_list_arg_type_node;
  record_builtin_type (RID_INT, NULL, integer_type_node);
  record_builtin_type (RID_CHAR, "char", char_type_node);
  if (c_dialect_cxx ())
    record_builtin_type (RID_SIGNED, NULL, integer_type_node);
  record_builtin_type (RID_LONG, "long int", long_integer_type_node);
  record_builtin_type (RID_UNSIGNED, "unsigned int", unsigned_type_node);
  record_builtin_type (RID_MAX, "long unsigned int",
		       long_unsigned_type_node);
  if (c_dialect_cxx ())
    record_builtin_type (RID_MAX, "unsigned long", long_unsigned_type_node);
  record_builtin_type (RID_MAX, "long long int",
		       long_long_integer_type_node);
  record_builtin_type (RID_MAX, "long long unsigned int",
		       long_long_unsigned_type_node);
  if (c_dialect_cxx ())
    record_builtin_type (RID_MAX, "long long unsigned",
			 long_long_unsigned_type_node);
  record_builtin_type (RID_SHORT, "short int", short_integer_type_node);
  record_builtin_type (RID_MAX, "short unsigned int",
		       short_unsigned_type_node);
  if (c_dialect_cxx ())
    record_builtin_type (RID_MAX, "unsigned short",
			 short_unsigned_type_node);
  record_builtin_type (RID_MAX, "signed char", signed_char_type_node);
  record_builtin_type (RID_MAX, "unsigned char", unsigned_char_type_node);
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 intQI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 intHI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 intSI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
  if (targetm.scalar_mode_supported_p (TImode))
    lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
					   get_identifier ("__int128_t"),
					   intTI_type_node));
#endif
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 unsigned_intQI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 unsigned_intHI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 unsigned_intSI_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 unsigned_intDI_type_node));
#if HOST_BITS_PER_WIDE_INT >= 64
  if (targetm.scalar_mode_supported_p (TImode))
    lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
					   get_identifier ("__uint128_t"),
					   unsigned_intTI_type_node));
#endif
  widest_integer_literal_type_node
    = make_signed_type (HOST_BITS_PER_WIDE_INT * 2);
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 widest_integer_literal_type_node));
  widest_unsigned_literal_type_node
    = make_unsigned_type (HOST_BITS_PER_WIDE_INT * 2);
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
					 widest_unsigned_literal_type_node));
  size_type_node =
    TREE_TYPE (identifier_global_value (get_identifier (SIZE_TYPE)));
  signed_size_type_node = c_common_signed_type (size_type_node);
  set_sizetype (size_type_node);
  pid_type_node =
    TREE_TYPE (identifier_global_value (get_identifier (PID_TYPE)));
  build_common_tree_nodes_2 (flag_short_double);
  record_builtin_type (RID_FLOAT, NULL, float_type_node);
  record_builtin_type (RID_DOUBLE, NULL, double_type_node);
  record_builtin_type (RID_MAX, "long double", long_double_type_node);
  if (targetm.scalar_mode_supported_p (SDmode) 
      && targetm.scalar_mode_supported_p (DDmode)
      && targetm.scalar_mode_supported_p (TDmode))
    {
      record_builtin_type (RID_DFLOAT32, NULL, dfloat32_type_node);
      record_builtin_type (RID_DFLOAT64, NULL, dfloat64_type_node);
      record_builtin_type (RID_DFLOAT128, NULL, dfloat128_type_node);
    }
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
					 get_identifier ("complex int"),
					 complex_integer_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
					 get_identifier ("complex float"),
					 complex_float_type_node));
  lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
					 get_identifier ("complex double"),
					 complex_double_type_node));
  lang_hooks.decls.pushdecl
    (build_decl (TYPE_DECL, get_identifier ("complex long double"),
		 complex_long_double_type_node));
  if (c_dialect_cxx ())
    fileptr_type_node = build_variant_type_copy (ptr_type_node);
  record_builtin_type (RID_VOID, NULL, void_type_node);
  void_zero_node = make_node (INTEGER_CST);
  TREE_TYPE (void_zero_node) = void_type_node;
  void_list_node = build_void_list_node ();
  array_domain_type = build_index_type (size_int (200));
  char_array_type_node
    = build_array_type (char_type_node, array_domain_type);
  int_array_type_node
    = build_array_type (integer_type_node, array_domain_type);
  string_type_node = build_pointer_type (char_type_node);
  const_string_type_node
    = build_pointer_type (build_qualified_type
			  (char_type_node, TYPE_QUAL_CONST));
  wchar_type_node = get_identifier (MODIFIED_WCHAR_TYPE);
  wchar_type_node = TREE_TYPE (identifier_global_value (wchar_type_node));
  wchar_type_size = TYPE_PRECISION (wchar_type_node);
  if (c_dialect_cxx ())
    {
      if (TYPE_UNSIGNED (wchar_type_node))
	wchar_type_node = make_unsigned_type (wchar_type_size);
      else
	wchar_type_node = make_signed_type (wchar_type_size);
      record_builtin_type (RID_WCHAR, "wchar_t", wchar_type_node);
    }
  else
    {
      signed_wchar_type_node = c_common_signed_type (wchar_type_node);
      unsigned_wchar_type_node = c_common_unsigned_type (wchar_type_node);
    }
  wchar_array_type_node
    = build_array_type (wchar_type_node, array_domain_type);
  wint_type_node =
    TREE_TYPE (identifier_global_value (get_identifier (WINT_TYPE)));
  intmax_type_node =
    TREE_TYPE (identifier_global_value (get_identifier (INTMAX_TYPE)));
  uintmax_type_node =
    TREE_TYPE (identifier_global_value (get_identifier (UINTMAX_TYPE)));
  default_function_type = build_function_type (integer_type_node, NULL_TREE);
  ptrdiff_type_node
    = TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
  unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
  lang_hooks.decls.pushdecl
    (build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
		 va_list_type_node));
  if (TREE_CODE (va_list_type_node) == ARRAY_TYPE)
    {
      va_list_arg_type_node = va_list_ref_type_node =
	build_pointer_type (TREE_TYPE (va_list_type_node));
    }
  else
    {
      va_list_arg_type_node = va_list_type_node;
      va_list_ref_type_node = build_reference_type (va_list_type_node);
    }
  if (!flag_preprocess_only)
    c_define_builtins (va_list_ref_type_node, va_list_arg_type_node);
  main_identifier_node = get_identifier ("main");
  null_node = make_node (INTEGER_CST);
  TREE_TYPE (null_node) = c_common_type_for_size (POINTER_SIZE, 0);
  memset (builtin_types, 0, sizeof (builtin_types));
}
void c_common_nodes_and_builtins ( void ) { int wchar_type_size ; tree array_domain_type ; tree va_list_ref_type_node ; tree va_list_arg_type_node ; record_builtin_type ( RID_INT , NULL , integer_type_node ) ; record_builtin_type ( RID_CHAR , " " , char_type_node ) ; if ( c_dialect_cxx ( ) ) record_builtin_type ( RID_SIGNED , NULL , integer_type_node ) ; record_builtin_type ( RID_LONG , " " , long_integer_type_node ) ; record_builtin_type ( RID_UNSIGNED , " " , unsigned_type_node ) ; record_builtin_type ( RID_MAX , " " , long_unsigned_type_node ) ; if ( c_dialect_cxx ( ) ) record_builtin_type ( RID_MAX , " " , long_unsigned_type_node ) ; record_builtin_type ( RID_MAX , " " , long_long_integer_type_node ) ; record_builtin_type ( RID_MAX , " " , long_long_unsigned_type_node ) ; if ( c_dialect_cxx ( ) ) record_builtin_type ( RID_MAX , " " , long_long_unsigned_type_node ) ; record_builtin_type ( RID_SHORT , " " , short_integer_type_node ) ; record_builtin_type ( RID_MAX , " " , short_unsigned_type_node ) ; if ( c_dialect_cxx ( ) ) record_builtin_type ( RID_MAX , " " , short_unsigned_type_node ) ; record_builtin_type ( RID_MAX , " " , signed_char_type_node ) ; record_builtin_type ( RID_MAX , " " , unsigned_char_type_node ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , intQI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , intHI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , intSI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , intDI_type_node ) ) ; #if HOST_BITS_PER_WIDE_INT >= 64 if ( targetm . scalar_mode_supported_p ( TImode ) ) lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , intTI_type_node ) ) ; #endif lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , unsigned_intQI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , unsigned_intHI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , unsigned_intSI_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , unsigned_intDI_type_node ) ) ; #if HOST_BITS_PER_WIDE_INT >= 64 if ( targetm . scalar_mode_supported_p ( TImode ) ) lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , unsigned_intTI_type_node ) ) ; #endif widest_integer_literal_type_node = make_signed_type ( HOST_BITS_PER_WIDE_INT * 2 ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , widest_integer_literal_type_node ) ) ; widest_unsigned_literal_type_node = make_unsigned_type ( HOST_BITS_PER_WIDE_INT * 2 ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , NULL_TREE , widest_unsigned_literal_type_node ) ) ; size_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( SIZE_TYPE ) ) ) ; signed_size_type_node = c_common_signed_type ( size_type_node ) ; set_sizetype ( size_type_node ) ; pid_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( PID_TYPE ) ) ) ; build_common_tree_nodes_2 ( flag_short_double ) ; record_builtin_type ( RID_FLOAT , NULL , float_type_node ) ; record_builtin_type ( RID_DOUBLE , NULL , double_type_node ) ; record_builtin_type ( RID_MAX , " " , long_double_type_node ) ; if ( targetm . scalar_mode_supported_p ( SDmode ) && targetm . scalar_mode_supported_p ( DDmode ) && targetm . scalar_mode_supported_p ( TDmode ) ) { record_builtin_type ( RID_DFLOAT32 , NULL , dfloat32_type_node ) ; record_builtin_type ( RID_DFLOAT64 , NULL , dfloat64_type_node ) ; record_builtin_type ( RID_DFLOAT128 , NULL , dfloat128_type_node ) ; } lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , complex_integer_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , complex_float_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , complex_double_type_node ) ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , complex_long_double_type_node ) ) ; if ( c_dialect_cxx ( ) ) fileptr_type_node = build_variant_type_copy ( ptr_type_node ) ; record_builtin_type ( RID_VOID , NULL , void_type_node ) ; void_zero_node = make_node ( INTEGER_CST ) ; TREE_TYPE ( void_zero_node ) = void_type_node ; void_list_node = build_void_list_node ( ) ; array_domain_type = build_index_type ( size_int ( 200 ) ) ; char_array_type_node = build_array_type ( char_type_node , array_domain_type ) ; int_array_type_node = build_array_type ( integer_type_node , array_domain_type ) ; string_type_node = build_pointer_type ( char_type_node ) ; const_string_type_node = build_pointer_type ( build_qualified_type ( char_type_node , TYPE_QUAL_CONST ) ) ; wchar_type_node = get_identifier ( MODIFIED_WCHAR_TYPE ) ; wchar_type_node = TREE_TYPE ( identifier_global_value ( wchar_type_node ) ) ; wchar_type_size = TYPE_PRECISION ( wchar_type_node ) ; if ( c_dialect_cxx ( ) ) { if ( TYPE_UNSIGNED ( wchar_type_node ) ) wchar_type_node = make_unsigned_type ( wchar_type_size ) ; else wchar_type_node = make_signed_type ( wchar_type_size ) ; record_builtin_type ( RID_WCHAR , " " , wchar_type_node ) ; } else { signed_wchar_type_node = c_common_signed_type ( wchar_type_node ) ; unsigned_wchar_type_node = c_common_unsigned_type ( wchar_type_node ) ; } wchar_array_type_node = build_array_type ( wchar_type_node , array_domain_type ) ; wint_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( WINT_TYPE ) ) ) ; intmax_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( INTMAX_TYPE ) ) ) ; uintmax_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( UINTMAX_TYPE ) ) ) ; default_function_type = build_function_type ( integer_type_node , NULL_TREE ) ; ptrdiff_type_node = TREE_TYPE ( identifier_global_value ( get_identifier ( PTRDIFF_TYPE ) ) ) ; unsigned_ptrdiff_type_node = c_common_unsigned_type ( ptrdiff_type_node ) ; lang_hooks . decls . pushdecl ( build_decl ( TYPE_DECL , get_identifier ( " " ) , va_list_type_node ) ) ; if ( TREE_CODE ( va_list_type_node ) == ARRAY_TYPE ) { va_list_arg_type_node = va_list_ref_type_node = build_pointer_type ( TREE_TYPE ( va_list_type_node ) ) ; } else { va_list_arg_type_node = va_list_type_node ; va_list_ref_type_node = build_reference_type ( va_list_type_node ) ; } if ( ! flag_preprocess_only ) c_define_builtins ( va_list_ref_type_node , va_list_arg_type_node ) ; main_identifier_node = get_identifier ( " " ) ; null_node = make_node ( INTEGER_CST ) ; TREE_TYPE ( null_node ) = c_common_type_for_size ( POINTER_SIZE , 0 ) ; memset ( builtin_types , 0 , sizeof ( builtin_types ) ) ; }
Build tree nodes and builtin functions common to both C and C++ language
frontends.
Build tree nodes and builtin functions common to both C and C ++ language frontends .
/* Define `int' and `char' first so that dbx will output them first.  */ /* `signed' is the same as `int'.  FIXME: the declarations of "signed",
     "unsigned long", "long long unsigned" and "unsigned short" were in C++
     but not C.  Are the conditionals here needed?  */ /* Define both `signed char' and `unsigned char'.  */ /* These are types that c_common_type_for_size and
     c_common_type_for_mode use.  */ /* Create the widest literal types.  */ /* `unsigned long' is the standard type for sizeof.
     Note that stddef.h uses `unsigned long',
     and this must agree, even if long and int are the same size.  */ /* Only supported decimal floating point extension if the target
     actually supports underlying modes. */ /* For C++, make fileptr_type_node a distinct void * type until
       FILE type is defined.  */ /* This node must not be shared.  */ /* Make a type to be the domain of a few array types
     whose domains don't really matter.
     200 is small enough that it always fits in size_t
     and large enough that it can hold most function names for the
     initializations of __FUNCTION__ and __PRETTY_FUNCTION__.  */ /* Make a type for arrays of characters.
     With luck nothing will ever really depend on the length of this
     array type.  */ /* Likewise for arrays of ints.  */ /* This is special for C++ so functions can be overloaded.  */ /* This is for wide string constants.  */ /* Create the built-in __null node.  It is important that this is
     not shared.  */ /* Since builtin_types isn't gc'ed, don't export these nodes.  */