}
if (current_function_decl)
- name = (*lang_hooks.decl_printable_name) (current_function_decl, vrb);
+ name = lang_hooks.decl_printable_name (current_function_decl, vrb);
return name;
}
if (TREE_CODE (operand) == INTEGER_CST
&& TREE_CODE (type) == INTEGER_TYPE
- && TREE_UNSIGNED (type)
+ && TYPE_UNSIGNED (type)
&& skip_evaluation == 0
&& !int_fits_type_p (operand, type))
{
TREE_CONSTANT_OVERFLOW (t) = TREE_CONSTANT_OVERFLOW (expr);
/* No warning for converting 0x80000000 to int. */
- if (!(TREE_UNSIGNED (type) < TREE_UNSIGNED (TREE_TYPE (expr))
+ if (!(TYPE_UNSIGNED (type) < TYPE_UNSIGNED (TREE_TYPE (expr))
&& TREE_CODE (TREE_TYPE (expr)) == INTEGER_TYPE
&& TYPE_PRECISION (type) == TYPE_PRECISION (TREE_TYPE (expr))))
/* If EXPR fits in the unsigned version of TYPE,
don't warn unless pedantic. */
if ((pedantic
- || TREE_UNSIGNED (type)
+ || TYPE_UNSIGNED (type)
|| ! constant_fits_type_p (expr,
c_common_unsigned_type (type)))
&& skip_evaluation == 0)
if (mode == TYPE_MODE (build_pointer_type (integer_type_node)))
return unsignedp ? make_unsigned_type (mode) : make_signed_type (mode);
- switch (mode)
- {
- case V16QImode:
- return unsignedp ? unsigned_V16QI_type_node : V16QI_type_node;
- case V8HImode:
- return unsignedp ? unsigned_V8HI_type_node : V8HI_type_node;
- case V4SImode:
- return unsignedp ? unsigned_V4SI_type_node : V4SI_type_node;
- case V2DImode:
- return unsignedp ? unsigned_V2DI_type_node : V2DI_type_node;
- case V2SImode:
- return unsignedp ? unsigned_V2SI_type_node : V2SI_type_node;
- case V2HImode:
- return unsignedp ? unsigned_V2HI_type_node : V2HI_type_node;
- case V4HImode:
- return unsignedp ? unsigned_V4HI_type_node : V4HI_type_node;
- case V8QImode:
- return unsignedp ? unsigned_V8QI_type_node : V8QI_type_node;
- case V1DImode:
- return unsignedp ? unsigned_V1DI_type_node : V1DI_type_node;
- case V16SFmode:
- return V16SF_type_node;
- case V4SFmode:
- return V4SF_type_node;
- case V2SFmode:
- return V2SF_type_node;
- case V2DFmode:
- return V2DF_type_node;
- case V4DFmode:
- return V4DF_type_node;
- default:
- break;
+ 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);
}
for (t = registered_builtin_types; t; t = TREE_CHAIN (t))
c_common_signed_or_unsigned_type (int unsignedp, tree type)
{
if (! INTEGRAL_TYPE_P (type)
- || TREE_UNSIGNED (type) == unsignedp)
+ || TYPE_UNSIGNED (type) == unsignedp)
return type;
/* Must check the mode of the types, not the precision. Enumeral types
but it *requires* conversion to FINAL_TYPE. */
if (op0 == primop0 && TREE_TYPE (op0) != *restype_ptr)
- unsignedp0 = TREE_UNSIGNED (TREE_TYPE (op0));
+ unsignedp0 = TYPE_UNSIGNED (TREE_TYPE (op0));
if (op1 == primop1 && TREE_TYPE (op1) != *restype_ptr)
- unsignedp1 = TREE_UNSIGNED (TREE_TYPE (op1));
+ unsignedp1 = TYPE_UNSIGNED (TREE_TYPE (op1));
/* If one of the operands must be floated, we cannot optimize. */
real1 = TREE_CODE (TREE_TYPE (primop0)) == REAL_TYPE;
int min_gt, max_gt, min_lt, max_lt;
tree maxval, minval;
/* 1 if comparison is nominally unsigned. */
- int unsignedp = TREE_UNSIGNED (*restype_ptr);
+ int unsignedp = TYPE_UNSIGNED (*restype_ptr);
tree val;
type = c_common_signed_or_unsigned_type (unsignedp0,
TREE_TYPE (primop0));
/* In C, if TYPE is an enumeration, then we need to get its
- min/max values from it's underlying integral type, not the
+ min/max values from its underlying integral type, not the
enumerated type itself. In C++, TYPE_MAX_VALUE and
TYPE_MIN_VALUE have already been set correctly on the
enumeration type. */
{
type = common_type (TREE_TYPE (primop0), TREE_TYPE (primop1));
type = c_common_signed_or_unsigned_type (unsignedp0
- || TREE_UNSIGNED (*restype_ptr),
+ || TYPE_UNSIGNED (*restype_ptr),
type);
/* Make sure shorter operand is extended the right way
to match the longer operand. */
primop1 = op1;
if (!real1 && !real2 && integer_zerop (primop1)
- && TREE_UNSIGNED (*restype_ptr))
+ && TYPE_UNSIGNED (*restype_ptr))
{
tree value = 0;
switch (code)
pedwarn ("pointer to member function used in arithmetic");
size_exp = integer_one_node;
}
- else if (TREE_CODE (TREE_TYPE (result_type)) == OFFSET_TYPE)
- {
- if (pedantic || warn_pointer_arith)
- pedwarn ("pointer to a member used in arithmetic");
- size_exp = integer_one_node;
- }
else
size_exp = size_in_bytes (TREE_TYPE (result_type));
/* If the constant is unsigned, and smaller than the pointer size,
then we must skip this optimization. This is because it could cause
an overflow error if the constant is negative but INTOP is not. */
- && (! TREE_UNSIGNED (TREE_TYPE (intop))
+ && (! TYPE_UNSIGNED (TREE_TYPE (intop))
|| (TYPE_PRECISION (TREE_TYPE (intop))
== TYPE_PRECISION (TREE_TYPE (ptrop)))))
{
so the multiply won't overflow spuriously. */
if (TYPE_PRECISION (TREE_TYPE (intop)) != TYPE_PRECISION (sizetype)
- || TREE_UNSIGNED (TREE_TYPE (intop)) != TREE_UNSIGNED (sizetype))
+ || TYPE_UNSIGNED (TREE_TYPE (intop)) != TYPE_UNSIGNED (sizetype))
intop = convert (c_common_type_for_size (TYPE_PRECISION (sizetype),
- TREE_UNSIGNED (sizetype)), intop);
+ TYPE_UNSIGNED (sizetype)), intop);
/* Replace the integer argument with a suitable product by the object size.
Do this multiplication as signed, then convert to the appropriate
case COMPLEX_EXPR:
return build_binary_op ((TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1))
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
- (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0)),
- (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 1)),
+ lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)),
+ lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 1)),
0);
case NEGATE_EXPR:
case ABS_EXPR:
case FLOAT_EXPR:
/* These don't change whether an object is nonzero or zero. */
- return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
+ return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
case LROTATE_EXPR:
case RROTATE_EXPR:
we can't ignore them if their second arg has side-effects. */
if (TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)))
return build (COMPOUND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 1),
- (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0)));
+ lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0)));
else
- return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
+ return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
case COND_EXPR:
/* Distribute the conversion into the arms of a COND_EXPR. */
return fold (build (COND_EXPR, truthvalue_type_node, TREE_OPERAND (expr, 0),
- (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 1)),
- (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 2))));
+ lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 1)),
+ lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 2))));
case CONVERT_EXPR:
/* Don't cancel the effect of a CONVERT_EXPR from a REFERENCE_TYPE,
/* If this is widening the argument, we can ignore it. */
if (TYPE_PRECISION (TREE_TYPE (expr))
>= TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (expr, 0))))
- return (*lang_hooks.truthvalue_conversion) (TREE_OPERAND (expr, 0));
+ return lang_hooks.truthvalue_conversion (TREE_OPERAND (expr, 0));
break;
case MINUS_EXPR:
return (build_binary_op
((TREE_SIDE_EFFECTS (expr)
? TRUTH_OR_EXPR : TRUTH_ORIF_EXPR),
- (*lang_hooks.truthvalue_conversion) (build_unary_op (REALPART_EXPR, t, 0)),
- (*lang_hooks.truthvalue_conversion) (build_unary_op (IMAGPART_EXPR, t, 0)),
+ lang_hooks.truthvalue_conversion (build_unary_op (REALPART_EXPR, t, 0)),
+ lang_hooks.truthvalue_conversion (build_unary_op (IMAGPART_EXPR, t, 0)),
0));
}
/* The C standard specifically allows aliasing between signed and
unsigned variants of the same type. We treat the signed
variant as canonical. */
- if (TREE_CODE (t) == INTEGER_TYPE && TREE_UNSIGNED (t))
+ if (TREE_CODE (t) == INTEGER_TYPE && TYPE_UNSIGNED (t))
{
tree t1 = c_common_signed_type (t);
/* These are types that c_common_type_for_size and
c_common_type_for_mode use. */
- (*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));
+ 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
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__int128_t"),
- intTI_type_node));
+ 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));
+ 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
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__uint128_t"),
- unsigned_intTI_type_node));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__uint128_t"),
+ unsigned_intTI_type_node));
#endif
/* Create the widest literal types. */
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));
+ 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));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL, NULL_TREE,
+ widest_unsigned_literal_type_node));
/* `unsigned long' is the standard type for sizeof.
Note that stddef.h uses `unsigned long',
record_builtin_type (RID_DOUBLE, NULL, double_type_node);
record_builtin_type (RID_MAX, "long double", long_double_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)
+ 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 (g77_integer_type_node != NULL_TREE)
{
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__g77_integer"),
- g77_integer_type_node));
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__g77_uinteger"),
- g77_uinteger_type_node));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__g77_integer"),
+ g77_integer_type_node));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__g77_uinteger"),
+ g77_uinteger_type_node));
}
if (TYPE_PRECISION (float_type_node) * 2
if (g77_longint_type_node != NULL_TREE)
{
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__g77_longint"),
- g77_longint_type_node));
- (*lang_hooks.decls.pushdecl) (build_decl (TYPE_DECL,
- get_identifier ("__g77_ulongint"),
- g77_ulongint_type_node));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__g77_longint"),
+ g77_longint_type_node));
+ lang_hooks.decls.pushdecl (build_decl (TYPE_DECL,
+ get_identifier ("__g77_ulongint"),
+ g77_ulongint_type_node));
}
record_builtin_type (RID_VOID, NULL, void_type_node);
wchar_type_size = TYPE_PRECISION (wchar_type_node);
if (c_dialect_cxx ())
{
- if (TREE_UNSIGNED (wchar_type_node))
+ 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);
= TREE_TYPE (identifier_global_value (get_identifier (PTRDIFF_TYPE)));
unsigned_ptrdiff_type_node = c_common_unsigned_type (ptrdiff_type_node);
- (*lang_hooks.decls.pushdecl)
+ lang_hooks.decls.pushdecl
(build_decl (TYPE_DECL, get_identifier ("__builtin_va_list"),
va_list_type_node));
- (*lang_hooks.decls.pushdecl)
+ lang_hooks.decls.pushdecl
(build_decl (TYPE_DECL, get_identifier ("__builtin_ptrdiff_t"),
ptrdiff_type_node));
- (*lang_hooks.decls.pushdecl)
+ lang_hooks.decls.pushdecl
(build_decl (TYPE_DECL, get_identifier ("__builtin_size_t"),
sizetype));
#include "builtins.def"
#undef DEF_BUILTIN
- (*targetm.init_builtins) ();
+ targetm.init_builtins ();
main_identifier_node = get_identifier ("main");
}
mode = (enum machine_mode) j;
if (mode == VOIDmode)
- error ("unknown machine mode `%s'", p);
- else if (0 == (typefm = (*lang_hooks.types.type_for_mode)
- (mode, TREE_UNSIGNED (type))))
+ {
+ error ("unknown machine mode `%s'", p);
+ return NULL_TREE;
+ }
+
+ if (VECTOR_MODE_P (mode))
+ {
+ warning ("specifying vector types with __attribute__ ((mode)) "
+ "is deprecated");
+ warning ("use __attribute__ ((vector_size)) instead");
+ }
+
+ typefm = lang_hooks.types.type_for_mode (mode, TYPE_UNSIGNED (type));
+ if (typefm == NULL_TREE)
error ("no data type for mode `%s'", p);
+
else if ((TREE_CODE (type) == POINTER_TYPE
|| TREE_CODE (type) == REFERENCE_TYPE)
- && !(*targetm.valid_pointer_mode) (mode))
+ && !targetm.valid_pointer_mode (mode))
error ("invalid pointer mode `%s'", p);
else
{
if (TREE_CODE (type) == POINTER_TYPE)
{
ptr_type = build_pointer_type_for_mode (TREE_TYPE (type),
- mode);
+ mode, false);
*node = ptr_type;
}
else if (TREE_CODE (type) == REFERENCE_TYPE)
{
ptr_type = build_reference_type_for_mode (TREE_TYPE (type),
- mode);
+ mode, false);
*node = ptr_type;
}
else
- *node = typefm;
+ *node = typefm;
/* No need to layout the type here. The caller should do this. */
}
}
return NULL_TREE;
}
-/* Keep a list of vector type nodes we created in handle_vector_size_attribute,
- to prevent us from duplicating type nodes unnecessarily.
- The normal mechanism to prevent duplicates is to use type_hash_canon, but
- since we want to distinguish types that are essentially identical (except
- for their debug representation), we use a local list here. */
-static GTY(()) tree vector_type_node_list = 0;
-
/* Handle a "vector_size" attribute; arguments as in
struct attribute_spec.handler. */
{
unsigned HOST_WIDE_INT vecsize, nunits;
enum machine_mode mode, orig_mode, new_mode;
- tree type = *node, new_type = NULL_TREE;
- tree type_list_node;
+ tree type = *node, new_type, size;
*no_add_attrs = true;
- if (! host_integerp (TREE_VALUE (args), 1))
+ /* Stripping NON_LVALUE_EXPR allows declarations such as
+ typedef short v4si __attribute__((vector_size (4 * sizeof(short)))). */
+ size = TREE_VALUE (args);
+ if (TREE_CODE (size) == NON_LVALUE_EXPR)
+ size = TREE_OPERAND (size, 0);
+
+ if (! host_integerp (size, 1))
{
warning ("`%s' attribute ignored", IDENTIFIER_POINTER (name));
return NULL_TREE;
}
/* Get the vector size (in bytes). */
- vecsize = tree_low_cst (TREE_VALUE (args), 1);
+ vecsize = tree_low_cst (size, 1);
/* We need to provide for vector pointers, vector arrays, and
functions returning vectors. For example:
break;
}
- if (new_mode == VOIDmode)
+ if (new_mode == VOIDmode)
{
error ("no vector mode with the size and type specified could be found");
return NULL_TREE;
}
- for (type_list_node = vector_type_node_list; type_list_node;
- type_list_node = TREE_CHAIN (type_list_node))
- {
- tree other_type = TREE_VALUE (type_list_node);
- tree record = TYPE_DEBUG_REPRESENTATION_TYPE (other_type);
- tree fields = TYPE_FIELDS (record);
- tree field_type = TREE_TYPE (fields);
- tree array_type = TREE_TYPE (field_type);
- if (TREE_CODE (fields) != FIELD_DECL
- || TREE_CODE (field_type) != ARRAY_TYPE)
- abort ();
-
- if (TYPE_MODE (other_type) == mode && type == array_type)
- {
- new_type = other_type;
- break;
- }
- }
-
- if (new_type == NULL_TREE)
- {
- tree index, array, rt, list_node;
-
- new_type = (*lang_hooks.types.type_for_mode) (new_mode,
- TREE_UNSIGNED (type));
-
- if (!new_type)
- {
- error ("no vector mode with the size and type specified could be found");
- return NULL_TREE;
- }
-
- new_type = build_type_copy (new_type);
-
- /* If this is a vector, make sure we either have hardware
- support, or we can emulate it. */
- if ((GET_MODE_CLASS (mode) == MODE_VECTOR_INT
- || GET_MODE_CLASS (mode) == MODE_VECTOR_FLOAT)
- && !vector_mode_valid_p (mode))
- {
- error ("unable to emulate '%s'", GET_MODE_NAME (mode));
- return NULL_TREE;
- }
-
- /* Set the debug information here, because this is the only
- place where we know the underlying type for a vector made
- with vector_size. For debugging purposes we pretend a vector
- is an array within a structure. */
- index = build_int_2 (TYPE_VECTOR_SUBPARTS (new_type) - 1, 0);
- array = build_array_type (type, build_index_type (index));
- rt = make_node (RECORD_TYPE);
-
- TYPE_FIELDS (rt) = build_decl (FIELD_DECL, get_identifier ("f"), array);
- DECL_CONTEXT (TYPE_FIELDS (rt)) = rt;
- layout_type (rt);
- TYPE_DEBUG_REPRESENTATION_TYPE (new_type) = rt;
-
- list_node = build_tree_list (NULL, new_type);
- TREE_CHAIN (list_node) = vector_type_node_list;
- vector_type_node_list = list_node;
- }
+ new_type = build_vector_type_for_mode (type, new_mode);
/* Build back pointers if needed. */
*node = reconstruct_complex_type (*node, new_type);