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
- From: Aldy Hernandez <aldyh at redhat dot com>
- To: Jason Merrill <jason at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org
- Date: Wed, 6 Aug 2003 22:10:39 -0400
- Subject: Re: patch: c++ support for vector opaque types
- References: <20030627011711.GA30139@redhat.com> <wvlvfus5duu.fsf@prospero.boston.redhat.com>
Hi Jason.
My sincerest apologies for taking so long to iterate on this patch.
I've been avoiding looking at C++ again, but it has caught up with me
once more. It won't happen again-- well, on this patch ;-).
> > *************** standard_conversion (tree to, tree from,
> > *** 767,772 ****
> > --- 768,778 ----
> >
> > return conv;
> > }
> > +
> > + if (fcode == VECTOR_TYPE && tcode == VECTOR_TYPE
> > + && ((*targetm.vector_opaque_p) (from)
> > + || (*targetm.vector_opaque_p) (to)))
> > + return conv;
>
> This would give this conversion identity rank, which is wrong; it should be
> a STD_CONV, like conversions between arithmetic types.
Fixed.
> 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.
I've also added a function call to the testcase. This behavior was
broken, and was fixed by my previous patch today.
How does this look?
Aldy
2003-08-06 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.
* cp/typeck.c (convert_for_assignment): Support opaque types.
* testsuite/g++.dg/other/opaque.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 02:08:58 -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 02:09:01 -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);
*************** 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 02:09:05 -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.C
===================================================================
RCS file: testsuite/g++.dg/other/opaque.C
diff -N testsuite/g++.dg/other/opaque.C
*** /dev/null 1 Jan 1970 00:00:00 -0000
--- testsuite/g++.dg/other/opaque.C 7 Aug 2003 02:09:05 -0000
***************
*** 0 ****
--- 1,17 ----
+ /* { dg-do compile { target powerpc-*-eabi* } } */
+ /* { dg-options "-mcpu=8540 -mabi=spe -O0" } */
+
+ #define __vector __attribute__((vector_size(8)))
+ typedef float __vector __ev64_fs__;
+
+ __ev64_fs__ f;
+ __ev64_opaque__ o;
+
+ extern void bar (__ev64_opaque__);
+
+ void foo(void)
+ {
+ f = o;
+ o = f;
+ bar (f);
+ }