aboutsummaryrefslogtreecommitdiff
path: root/gcc/ada/gcc-interface/utils.c
diff options
context:
space:
mode:
authorEric Botcazou <ebotcazou@adacore.com>2016-01-18 11:29:00 +0000
committerEric Botcazou <ebotcazou@gcc.gnu.org>2016-01-18 11:29:00 +0000
commit9a1bdc314ba086904861838838bc2e0743476dcd (patch)
tree9b5a32fc16b8443b82e93e51c4c082d86cb64a11 /gcc/ada/gcc-interface/utils.c
parentf5460595a488ce9c131815016d0c89dc0d17ca14 (diff)
downloadgcc-9a1bdc314ba086904861838838bc2e0743476dcd.zip
gcc-9a1bdc314ba086904861838838bc2e0743476dcd.tar.gz
gcc-9a1bdc314ba086904861838838bc2e0743476dcd.tar.bz2
gigi.h (build_call_raise_column): Adjust prototype.
* gcc-interface/gigi.h (build_call_raise_column): Adjust prototype. (build_call_raise_range): Likewise. (gnat_unsigned_type): Delete. (gnat_signed_type): Likewise. (gnat_signed_or_unsigned_type_for): New prototype. (gnat_unsigned_type_for): New inline function. (gnat_signed_type_for): Likewise. * gcc-interface/cuintp.c (build_cst_from_int): Call build_int_cst. * gcc-interface/decl.c (gnat_to_gnu_entity): Likewise. (gnat_to_gnu_entity) <E_Array_Type>: Always translate the index types and compute their base type from that. <E_Array_Subtype>: Remove duplicate declaration. * gcc-interface/misc.c (get_array_bit_stride): Call build_int_cst. * gcc-interface/trans.c (get_type_length): Likewise. (Attribute_to_gnu): Likewise. (Loop_Statement_to_gnu): Likewise. (Call_to_gnu): Likewise. (gnat_to_gnu): Call build_real, build_int_cst, gnat_unsigned_type_for and gnat_signed_type_for. Minor tweaks. (build_binary_op_trapv): Likewise. (emit_check): Likewise. (convert_with_check): Likewise. (Raise_Error_to_gnu): Adjust calls to the build_call_raise family of functions. Minor tweaks. (Case_Statement_to_gnu): Remove dead code. (gnat_to_gnu): Call gnat_unsigned_type_for and gnat_signed_type_for. (init_code_table): Minor reordering. * gcc-interface/utils.c (gnat_unsigned_type): Delete. (gnat_signed_type): Likewise. (gnat_signed_or_unsigned_type_for): New function. (unchecked_convert): Use directly the size in the test for precision vs size adjustments. (install_builtin_elementary_types): Call gnat_signed_type_for. * gcc-interface/utils2.c (nonbinary_modular_operation): Call build_int_cst. (build_goto_raise): New function taken from... (build_call_raise): ...here. Call it. (build_call_raise_column): Add KIND parameter and call it. (build_call_raise_range): Likewise. From-SVN: r232503
Diffstat (limited to 'gcc/ada/gcc-interface/utils.c')
-rw-r--r--gcc/ada/gcc-interface/utils.c63
1 files changed, 20 insertions, 43 deletions
diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c
index aac39db..95886f7 100644
--- a/gcc/ada/gcc-interface/utils.c
+++ b/gcc/ada/gcc-interface/utils.c
@@ -3354,35 +3354,13 @@ gnat_type_for_mode (machine_mode mode, int unsignedp)
return NULL_TREE;
}
-/* Return the unsigned version of a TYPE_NODE, a scalar type. */
+/* Return the signed or unsigned version of TYPE_NODE, a scalar type, the
+ signedness being specified by UNSIGNEDP. */
tree
-gnat_unsigned_type (tree type_node)
+gnat_signed_or_unsigned_type_for (int unsignedp, tree type_node)
{
- tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 1);
-
- if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
- {
- type = copy_node (type);
- TREE_TYPE (type) = type_node;
- }
- else if (TREE_TYPE (type_node)
- && TREE_CODE (TREE_TYPE (type_node)) == INTEGER_TYPE
- && TYPE_MODULAR_P (TREE_TYPE (type_node)))
- {
- type = copy_node (type);
- TREE_TYPE (type) = TREE_TYPE (type_node);
- }
-
- return type;
-}
-
-/* Return the signed version of a TYPE_NODE, a scalar type. */
-
-tree
-gnat_signed_type (tree type_node)
-{
- tree type = gnat_type_for_size (TYPE_PRECISION (type_node), 0);
+ tree type = gnat_type_for_size (TYPE_PRECISION (type_node), unsignedp);
if (TREE_CODE (type_node) == INTEGER_TYPE && TYPE_MODULAR_P (type_node))
{
@@ -4936,8 +4914,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
are no considerations of precision or size involved. */
else if (INTEGRAL_TYPE_P (type)
&& TYPE_RM_SIZE (type)
- && (0 != compare_tree_int (TYPE_RM_SIZE (type),
- GET_MODE_BITSIZE (TYPE_MODE (type)))
+ && (tree_int_cst_compare (TYPE_RM_SIZE (type),
+ TYPE_SIZE (type)) < 0
|| (AGGREGATE_TYPE_P (etype)
&& TYPE_REVERSE_STORAGE_ORDER (etype))))
{
@@ -4973,8 +4951,8 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
type with reverse storage order and we also proceed similarly. */
else if (INTEGRAL_TYPE_P (etype)
&& TYPE_RM_SIZE (etype)
- && (0 != compare_tree_int (TYPE_RM_SIZE (etype),
- GET_MODE_BITSIZE (TYPE_MODE (etype)))
+ && (tree_int_cst_compare (TYPE_RM_SIZE (etype),
+ TYPE_SIZE (etype)) < 0
|| (AGGREGATE_TYPE_P (type)
&& TYPE_REVERSE_STORAGE_ORDER (type))))
{
@@ -5094,26 +5072,25 @@ unchecked_convert (tree type, tree expr, bool notrunc_p)
is an integral type of the same precision and signedness or if the output
is a biased type or if both the input and output are unsigned. */
if (!notrunc_p
- && INTEGRAL_TYPE_P (type) && TYPE_RM_SIZE (type)
- && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
- && 0 != compare_tree_int (TYPE_RM_SIZE (type),
- GET_MODE_BITSIZE (TYPE_MODE (type)))
+ && INTEGRAL_TYPE_P (type)
+ && TYPE_RM_SIZE (type)
+ && tree_int_cst_compare (TYPE_RM_SIZE (type), TYPE_SIZE (type)) < 0
&& !(INTEGRAL_TYPE_P (etype)
&& TYPE_UNSIGNED (type) == TYPE_UNSIGNED (etype)
- && operand_equal_p (TYPE_RM_SIZE (type),
- (TYPE_RM_SIZE (etype) != 0
- ? TYPE_RM_SIZE (etype) : TYPE_SIZE (etype)),
- 0))
+ && tree_int_cst_compare (TYPE_RM_SIZE (type),
+ TYPE_RM_SIZE (etype)
+ ? TYPE_RM_SIZE (etype)
+ : TYPE_SIZE (etype)) == 0)
+ && !(code == INTEGER_TYPE && TYPE_BIASED_REPRESENTATION_P (type))
&& !(TYPE_UNSIGNED (type) && TYPE_UNSIGNED (etype)))
{
tree base_type
- = gnat_type_for_mode (TYPE_MODE (type), TYPE_UNSIGNED (type));
+ = gnat_type_for_size (TREE_INT_CST_LOW (TYPE_SIZE (type)),
+ TYPE_UNSIGNED (type));
tree shift_expr
= convert (base_type,
size_binop (MINUS_EXPR,
- bitsize_int
- (GET_MODE_BITSIZE (TYPE_MODE (type))),
- TYPE_RM_SIZE (type)));
+ TYPE_SIZE (type), TYPE_RM_SIZE (type)));
expr
= convert (type,
build_binary_op (RSHIFT_EXPR, base_type,
@@ -5434,7 +5411,7 @@ builtin_type_for_size (int size, bool unsignedp)
static void
install_builtin_elementary_types (void)
{
- signed_size_type_node = gnat_signed_type (size_type_node);
+ signed_size_type_node = gnat_signed_type_for (size_type_node);
pid_type_node = integer_type_node;
void_list_node = build_void_list_node ();