FreeBSD/contrib/gcc/c-common.c
/* Return a data type that has machine mode MODE.
   If the mode is an integer,
   then UNSIGNEDP selects between signed and unsigned types.  */
Return a data type that has machine mode MODE.
If the mode is an integer,
then UNSIGNEDP selects between signed and unsigned types.
Return a data type that has machine mode MODE . If the mode is an integer then UNSIGNEDP selects between signed and unsigned types .
tree
c_common_type_for_mode (enum machine_mode mode, int unsignedp)
{
  tree t;
  if (mode == TYPE_MODE (integer_type_node))
    return unsignedp ? unsigned_type_node : integer_type_node;
  if (mode == TYPE_MODE (signed_char_type_node))
    return unsignedp ? unsigned_char_type_node : signed_char_type_node;
  if (mode == TYPE_MODE (short_integer_type_node))
    return unsignedp ? short_unsigned_type_node : short_integer_type_node;
  if (mode == TYPE_MODE (long_integer_type_node))
    return unsignedp ? long_unsigned_type_node : long_integer_type_node;
  if (mode == TYPE_MODE (long_long_integer_type_node))
    return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node;
  if (mode == TYPE_MODE (widest_integer_literal_type_node))
    return unsignedp ? widest_unsigned_literal_type_node
		     : widest_integer_literal_type_node;
  if (mode == QImode)
    return unsignedp ? unsigned_intQI_type_node : intQI_type_node;
  if (mode == HImode)
    return unsignedp ? unsigned_intHI_type_node : intHI_type_node;
  if (mode == SImode)
    return unsignedp ? unsigned_intSI_type_node : intSI_type_node;
  if (mode == DImode)
    return unsignedp ? unsigned_intDI_type_node : intDI_type_node;
#if HOST_BITS_PER_WIDE_INT >= 64
  if (mode == TYPE_MODE (intTI_type_node))
    return unsignedp ? unsigned_intTI_type_node : intTI_type_node;
#endif
  if (mode == TYPE_MODE (float_type_node))
    return float_type_node;
  if (mode == TYPE_MODE (double_type_node))
    return double_type_node;
  if (mode == TYPE_MODE (long_double_type_node))
    return long_double_type_node;
  if (mode == TYPE_MODE (void_type_node))
    return void_type_node;
  if (mode == TYPE_MODE (build_pointer_type (char_type_node)))
    return (unsignedp
	    ? make_unsigned_type (GET_MODE_PRECISION (mode))
	    : make_signed_type (GET_MODE_PRECISION (mode)));
  if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
    return (unsignedp
	    ? make_unsigned_type (GET_MODE_PRECISION (mode))
	    : make_signed_type (GET_MODE_PRECISION (mode)));
  if (COMPLEX_MODE_P (mode))
    {
      enum machine_mode inner_mode;
      tree inner_type;
      if (mode == TYPE_MODE (complex_float_type_node))
	return complex_float_type_node;
      if (mode == TYPE_MODE (complex_double_type_node))
	return complex_double_type_node;
      if (mode == TYPE_MODE (complex_long_double_type_node))
	return complex_long_double_type_node;
      if (mode == TYPE_MODE (complex_integer_type_node) && !unsignedp)
	return complex_integer_type_node;
      inner_mode = GET_MODE_INNER (mode);
      inner_type = c_common_type_for_mode (inner_mode, unsignedp);
      if (inner_type != NULL_TREE)
	return build_complex_type (inner_type);
    }
  else if (VECTOR_MODE_P (mode))
    {
      enum machine_mode inner_mode = GET_MODE_INNER (mode);
      tree inner_type = c_common_type_for_mode (inner_mode, unsignedp);
      if (inner_type != NULL_TREE)
	return build_vector_type_for_mode (inner_type, mode);
    }
  if (mode == TYPE_MODE (dfloat32_type_node))
    return dfloat32_type_node;
  if (mode == TYPE_MODE (dfloat64_type_node))
    return dfloat64_type_node;
  if (mode == TYPE_MODE (dfloat128_type_node))
    return dfloat128_type_node;
  for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
    if (TYPE_MODE (TREE_VALUE (t)) == mode)
      return TREE_VALUE (t);
  return 0;
}
tree c_common_type_for_mode ( enum machine_mode mode , int unsignedp ) { tree t ; if ( mode == TYPE_MODE ( integer_type_node ) ) return unsignedp ? unsigned_type_node : integer_type_node ; if ( mode == TYPE_MODE ( signed_char_type_node ) ) return unsignedp ? unsigned_char_type_node : signed_char_type_node ; if ( mode == TYPE_MODE ( short_integer_type_node ) ) return unsignedp ? short_unsigned_type_node : short_integer_type_node ; if ( mode == TYPE_MODE ( long_integer_type_node ) ) return unsignedp ? long_unsigned_type_node : long_integer_type_node ; if ( mode == TYPE_MODE ( long_long_integer_type_node ) ) return unsignedp ? long_long_unsigned_type_node : long_long_integer_type_node ; if ( mode == TYPE_MODE ( widest_integer_literal_type_node ) ) return unsignedp ? widest_unsigned_literal_type_node : widest_integer_literal_type_node ; if ( mode == QImode ) return unsignedp ? unsigned_intQI_type_node : intQI_type_node ; if ( mode == HImode ) return unsignedp ? unsigned_intHI_type_node : intHI_type_node ; if ( mode == SImode ) return unsignedp ? unsigned_intSI_type_node : intSI_type_node ; if ( mode == DImode ) return unsignedp ? unsigned_intDI_type_node : intDI_type_node ; #if HOST_BITS_PER_WIDE_INT >= 64 if ( mode == TYPE_MODE ( intTI_type_node ) ) return unsignedp ? unsigned_intTI_type_node : intTI_type_node ; #endif if ( mode == TYPE_MODE ( float_type_node ) ) return float_type_node ; if ( mode == TYPE_MODE ( double_type_node ) ) return double_type_node ; if ( mode == TYPE_MODE ( long_double_type_node ) ) return long_double_type_node ; if ( mode == TYPE_MODE ( void_type_node ) ) return void_type_node ; if ( mode == TYPE_MODE ( build_pointer_type ( char_type_node ) ) ) return ( unsignedp ? make_unsigned_type ( GET_MODE_PRECISION ( mode ) ) : make_signed_type ( GET_MODE_PRECISION ( mode ) ) ) ; if ( mode == TYPE_MODE ( build_pointer_type ( integer_type_node ) ) ) return ( unsignedp ? make_unsigned_type ( GET_MODE_PRECISION ( mode ) ) : make_signed_type ( GET_MODE_PRECISION ( mode ) ) ) ; if ( COMPLEX_MODE_P ( mode ) ) { enum machine_mode inner_mode ; tree inner_type ; if ( mode == TYPE_MODE ( complex_float_type_node ) ) return complex_float_type_node ; if ( mode == TYPE_MODE ( complex_double_type_node ) ) return complex_double_type_node ; if ( mode == TYPE_MODE ( complex_long_double_type_node ) ) return complex_long_double_type_node ; if ( mode == TYPE_MODE ( complex_integer_type_node ) && ! unsignedp ) return complex_integer_type_node ; inner_mode = GET_MODE_INNER ( mode ) ; inner_type = c_common_type_for_mode ( inner_mode , unsignedp ) ; if ( inner_type != NULL_TREE ) return build_complex_type ( inner_type ) ; } else if ( VECTOR_MODE_P ( mode ) ) { enum machine_mode inner_mode = GET_MODE_INNER ( mode ) ; tree inner_type = c_common_type_for_mode ( inner_mode , unsignedp ) ; if ( inner_type != NULL_TREE ) return build_vector_type_for_mode ( inner_type , mode ) ; } if ( mode == TYPE_MODE ( dfloat32_type_node ) ) return dfloat32_type_node ; if ( mode == TYPE_MODE ( dfloat64_type_node ) ) return dfloat64_type_node ; if ( mode == TYPE_MODE ( dfloat128_type_node ) ) return dfloat128_type_node ; for ( t = registered_builtin_types ; t ; t = TREE_CHAIN ( t ) ) if ( TYPE_MODE ( TREE_VALUE ( t ) ) == mode ) return TREE_VALUE ( t ) ; return 0 ; }
Return a data type that has machine mode MODE.
Return a data type that has machine mode MODE .