This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch: c++ support for vector opaque types
> > >> Also, your testcase should test for proper overloading behavior. Define a
> > >> function g which overloads on both __ev64_fs__ and __ev64_opaque__, and
> > >> verify that the calls go to the right candidate.
> > >
> > > Could we delay on this? Partly because it's broken and partly because
> > > the only opaque type in any ABI does not allow for this-- or rather
> > > has it undefined.
> >
> > What does overload behavior have to do with the ABI? Please elaborate.
>
> Opaque types were added for the E500, and the API doesn't cover
> overloading. I'd like to get this stuff in first, since no one is
> going to use overloading in opaque types just yet, definitely not for
> the E500.
Meanwhile back at the ranch...more talking over IRC happens...
Ok, here's the proper fix for the overloaded problems.
srip_top_quals() suffered from the same TYPE_MAIN_VARIANT problem I
fixed in my last patch. Fixed.
The test now properly tests overloaded opaque and normal simd types.
This test is only tested on powerpc-eabispe now because it's an
execution test. I added a second test that is a compile test, to be
run on any powerpc-eabi* variant. It has the same test, but without
the bits testing overloaded behavior at execution.
Jason has pre-approved this.
I am committing to mainline and the e500 branch.
Cheers.
2003-08-07 Aldy Hernandez <aldyh@redhat.com>
* cp/Make-lang.in (cp/call.o): Add dependency for target.h.
* cp/call.c (standard_conversion): Support opaque types.
Include target.h.
(strip_top_quals): Use cp_build_qualified_type instead of
TYPE_MAIN_VARIANT.
* cp/typeck.c (convert_for_assignment): Support opaque types.
* testsuite/g++.dg/other/opaque-1.C: New.
* testsuite/g++.dg/other/opaque-2.C: New.
Index: cp/Make-lang.in
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/Make-lang.in,v
retrieving revision 1.160
diff -c -p -r1.160 Make-lang.in
*** cp/Make-lang.in 5 Aug 2003 19:23:14 -0000 1.160
--- cp/Make-lang.in 7 Aug 2003 12:39:37 -0000
*************** cp/typeck.o: cp/typeck.c $(CXX_TREE_H) $
*** 249,255 ****
diagnostic.h convert.h
cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H) convert.h
cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
! diagnostic.h intl.h gt-cp-call.h convert.h
cp/friend.o: cp/friend.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
except.h
--- 249,255 ----
diagnostic.h convert.h
cp/class.o: cp/class.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(TARGET_H) convert.h
cp/call.o: cp/call.c $(CXX_TREE_H) $(TM_H) flags.h toplev.h $(RTL_H) $(EXPR_H) \
! diagnostic.h intl.h gt-cp-call.h convert.h target.h
cp/friend.o: cp/friend.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) toplev.h $(EXPR_H)
cp/init.o: cp/init.c $(CXX_TREE_H) $(TM_H) flags.h $(RTL_H) $(EXPR_H) toplev.h \
except.h
Index: cp/call.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/call.c,v
retrieving revision 1.417
diff -c -p -r1.417 call.c
*** cp/call.c 29 Jul 2003 01:14:22 -0000 1.417
--- cp/call.c 7 Aug 2003 12:39:41 -0000
*************** Boston, MA 02111-1307, USA. */
*** 37,42 ****
--- 37,43 ----
#include "expr.h"
#include "diagnostic.h"
#include "intl.h"
+ #include "target.h"
#include "convert.h"
static tree build_field_call (tree, tree, tree);
*************** strip_top_quals (tree t)
*** 568,574 ****
{
if (TREE_CODE (t) == ARRAY_TYPE)
return t;
! return TYPE_MAIN_VARIANT (t);
}
/* Returns the standard conversion path (see [conv]) from type FROM to type
--- 569,575 ----
{
if (TREE_CODE (t) == ARRAY_TYPE)
return t;
! return cp_build_qualified_type (t, 0);
}
/* Returns the standard conversion path (see [conv]) from type FROM to type
*************** standard_conversion (tree to, tree from,
*** 792,797 ****
--- 793,802 ----
&& ICS_STD_RANK (TREE_OPERAND (conv, 0)) <= PROMO_RANK)
ICS_STD_RANK (conv) = PROMO_RANK;
}
+ else if (fcode == VECTOR_TYPE && tcode == VECTOR_TYPE
+ && ((*targetm.vector_opaque_p) (from)
+ || (*targetm.vector_opaque_p) (to)))
+ return build_conv (STD_CONV, to, conv);
else if (IS_AGGR_TYPE (to) && IS_AGGR_TYPE (from)
&& is_properly_derived_from (from, to))
{
Index: cp/typeck.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/typeck.c,v
retrieving revision 1.490
diff -c -p -r1.490 typeck.c
*** cp/typeck.c 3 Aug 2003 14:18:59 -0000 1.490
--- cp/typeck.c 7 Aug 2003 12:39:45 -0000
*************** convert_for_assignment (tree type, tree
*** 5533,5538 ****
--- 5533,5543 ----
rhstype = TREE_TYPE (rhs);
coder = TREE_CODE (rhstype);
+ if (TREE_CODE (type) == VECTOR_TYPE && coder == VECTOR_TYPE
+ && ((*targetm.vector_opaque_p) (type)
+ || (*targetm.vector_opaque_p) (rhstype)))
+ return convert (type, rhs);
+
if (rhs == error_mark_node || rhstype == error_mark_node)
return error_mark_node;
if (TREE_CODE (rhs) == TREE_LIST && TREE_VALUE (rhs) == error_mark_node)
Index: testsuite/g++.dg/other/opaque-1.C
===================================================================
RCS file: testsuite/g++.dg/other/opaque-1.C
diff -N testsuite/g++.dg/other/opaque-1.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/other/opaque-1.C 7 Aug 2003 12:39:45 -0000
***************
*** 0 ****
--- 1,29 ----
+ /* { dg-do run { target powerpc-*-eabispe* } } */
+
+ #define __vector __attribute__((vector_size(8)))
+ typedef float __vector __ev64_fs__;
+
+ __ev64_fs__ f;
+ __ev64_opaque__ o;
+
+ int here = 0;
+
+ void bar (__ev64_opaque__ x)
+ {
+ here = 0;
+ }
+
+ void bar (__ev64_fs__ x)
+ {
+ here = 888;
+ }
+
+ int main ()
+ {
+ f = o;
+ o = f;
+ bar (f);
+ if (here != 888)
+ return 1;
+ return 0;
+ }
Index: testsuite/g++.dg/other/opaque-2.C
===================================================================
RCS file: testsuite/g++.dg/other/opaque-2.C
diff -N testsuite/g++.dg/other/opaque-2.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/other/opaque-2.C 7 Aug 2003 12:39:45 -0000
***************
*** 0 ****
--- 1,18 ----
+ /* { dg-do compile { target powerpc-*-eabi* } } */
+ /* { dg-options "-mcpu=8540 -mabi=spe" } */
+
+ #define __vector __attribute__((vector_size(8)))
+ typedef float __vector __ev64_fs__;
+
+ __ev64_fs__ f;
+ __ev64_opaque__ o;
+
+ extern void bar (__ev64_opaque__);
+
+ int main ()
+ {
+ f = o;
+ o = f;
+ bar (f);
+ return 0;
+ }