diff options
author | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-06-15 10:46:12 +0000 |
---|---|---|
committer | ebotcazou <ebotcazou@138bc75d-0d04-0410-961f-82ee72b054a4> | 2012-06-15 10:46:12 +0000 |
commit | fc0d5ab8abcc7288cbf63c2b5c936843037603b5 (patch) | |
tree | 987f589d15db5b98923db64924df237e6cac9c29 | |
parent | 0cbb04c9e7353b7d8f101e4d5c1f216adae31ca5 (diff) | |
download | gcc-fc0d5ab8abcc7288cbf63c2b5c936843037603b5.tar.gz |
PR ada/53592
* gcc-interface/gigi.h (maybe_vector_array): Make static inline.
* gcc-interface/utils.c (maybe_vector_array): Delete.
* gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Mark the
array object as addressable if it has vector type and is on the LHS.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_7-branch@188654 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r-- | gcc/ada/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/gigi.h | 18 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/trans.c | 7 | ||||
-rw-r--r-- | gcc/ada/gcc-interface/utils.c | 14 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 4 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/vect8.adb | 11 | ||||
-rw-r--r-- | gcc/testsuite/gnat.dg/vect8.ads | 10 |
7 files changed, 53 insertions, 19 deletions
diff --git a/gcc/ada/ChangeLog b/gcc/ada/ChangeLog index 072a3f215b4..b336f03ddf0 100644 --- a/gcc/ada/ChangeLog +++ b/gcc/ada/ChangeLog @@ -1,3 +1,11 @@ +2012-06-15 Eric Botcazou <ebotcazou@adacore.com> + + PR ada/53592 + * gcc-interface/gigi.h (maybe_vector_array): Make static inline. + * gcc-interface/utils.c (maybe_vector_array): Delete. + * gcc-interface/trans.c (gnat_to_gnu) <N_Indexed_Component>: Mark the + array object as addressable if it has vector type and is on the LHS. + 2012-06-14 Jakub Jelinek <jakub@redhat.com> * gcc-interface/Makefile.in (gnatlib-shared-default): Append diff --git a/gcc/ada/gcc-interface/gigi.h b/gcc/ada/gcc-interface/gigi.h index 00f64651de1..9550b4a16a5 100644 --- a/gcc/ada/gcc-interface/gigi.h +++ b/gcc/ada/gcc-interface/gigi.h @@ -764,10 +764,6 @@ extern tree remove_conversions (tree exp, bool true_address); likewise return an expression pointing to the underlying array. */ extern tree maybe_unconstrained_array (tree exp); -/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated - TYPE_REPRESENTATIVE_ARRAY. */ -extern tree maybe_vector_array (tree exp); - /* Return an expression that does an unchecked conversion of EXPR to TYPE. If NOTRUNC_P is true, truncation operations should be suppressed. */ extern tree unchecked_convert (tree type, tree expr, bool notrunc_p); @@ -1013,3 +1009,17 @@ extern void enumerate_modes (void (*f) (const char *, int, int, int, int, int, /* Convenient shortcuts. */ #define VECTOR_TYPE_P(TYPE) (TREE_CODE (TYPE) == VECTOR_TYPE) + +/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated + TYPE_REPRESENTATIVE_ARRAY. */ + +static inline tree +maybe_vector_array (tree exp) +{ + tree etype = TREE_TYPE (exp); + + if (VECTOR_TYPE_P (etype)) + exp = convert (TYPE_REPRESENTATIVE_ARRAY (etype), exp); + + return exp; +} diff --git a/gcc/ada/gcc-interface/trans.c b/gcc/ada/gcc-interface/trans.c index eebe2a9a901..1c9da73f003 100644 --- a/gcc/ada/gcc-interface/trans.c +++ b/gcc/ada/gcc-interface/trans.c @@ -5218,7 +5218,12 @@ gnat_to_gnu (Node_Id gnat_node) /* Convert vector inputs to their representative array type, to fit what the code below expects. */ - gnu_array_object = maybe_vector_array (gnu_array_object); + if (VECTOR_TYPE_P (TREE_TYPE (gnu_array_object))) + { + if (present_in_lhs_or_actual_p (gnat_node)) + gnat_mark_addressable (gnu_array_object); + gnu_array_object = maybe_vector_array (gnu_array_object); + } gnu_array_object = maybe_unconstrained_array (gnu_array_object); diff --git a/gcc/ada/gcc-interface/utils.c b/gcc/ada/gcc-interface/utils.c index 4596c52f070..c87a7618573 100644 --- a/gcc/ada/gcc-interface/utils.c +++ b/gcc/ada/gcc-interface/utils.c @@ -4474,20 +4474,6 @@ maybe_unconstrained_array (tree exp) return exp; } - -/* If EXP's type is a VECTOR_TYPE, return EXP converted to the associated - TYPE_REPRESENTATIVE_ARRAY. */ - -tree -maybe_vector_array (tree exp) -{ - tree etype = TREE_TYPE (exp); - - if (VECTOR_TYPE_P (etype)) - exp = convert (TYPE_REPRESENTATIVE_ARRAY (etype), exp); - - return exp; -} /* Return true if EXPR is an expression that can be folded as an operand of a VIEW_CONVERT_EXPR. See ada-tree.h for a complete rationale. */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index cb6406e97dc..dfc86cd363d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2012-06-15 Eric Botcazou <ebotcazou@adacore.com> + + * gnat.dg/vect8.ad[sb]: New test. + 2012-06-14 Jakub Jelinek <jakub@redhat.com> Backported from mainline diff --git a/gcc/testsuite/gnat.dg/vect8.adb b/gcc/testsuite/gnat.dg/vect8.adb new file mode 100644 index 00000000000..b13555abd0f --- /dev/null +++ b/gcc/testsuite/gnat.dg/vect8.adb @@ -0,0 +1,11 @@ +package body Vect8 is + + function Foo (V : Vec) return Vec is + Ret : Vec; + begin + Ret (1) := V (1) + V (2); + Ret (2) := V (1) - V (2); + return Ret; + end; + +end Vect8; diff --git a/gcc/testsuite/gnat.dg/vect8.ads b/gcc/testsuite/gnat.dg/vect8.ads new file mode 100644 index 00000000000..5406c70f49f --- /dev/null +++ b/gcc/testsuite/gnat.dg/vect8.ads @@ -0,0 +1,10 @@ +-- { dg-do compile } + +package Vect8 is + + type Vec is array (1 .. 2) of Long_Float; + pragma Machine_Attribute (Vec, "vector_type"); + + function Foo (V : Vec) return Vec; + +end Vect8; |