This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: patch: vector initializers
- From: Jason Merrill <jason at redhat dot com>
- To: Aldy Hernandez <aldyh at redhat dot com>
- Cc: gcc-patches at gcc dot gnu dot org, shebs at apple dot com
- Date: Mon, 11 Feb 2002 13:05:46 +0000
- Subject: Re: patch: vector initializers
- References: <20020211035139.GA3625@redhat.com>
>>>>> "Aldy" == Aldy Hernandez <aldyh@redhat.com> writes:
> hi guys!
> finally, the last piece of the altivec puzzle. this patch allows the
> use of vector initializers, ala:
> vector int foo = (vector int) { 1, 2, 3, 4 };
> stan wrote most of the code, but didn't have time to fix a few ICEs
> related to vector initializers. i fixed the remaining problems.
> here is the entire patch.
And here's the C++ piece.
2002-02-11 Jason Merrill <jason@redhat.com>
* typeck2.c (digest_init, process_init_constructor): Treat vectors
like arrays.
*** typeck2.c.~1~ Mon Feb 11 12:26:34 2002
--- typeck2.c Wed Feb 6 16:06:13 2002
*************** digest_init (type, init, tail)
*** 544,550 ****
if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
|| code == ENUMERAL_TYPE || code == REFERENCE_TYPE
! || code == BOOLEAN_TYPE || code == COMPLEX_TYPE || code == VECTOR_TYPE
|| TYPE_PTRMEMFUNC_P (type))
{
if (raw_constructor)
--- 544,550 ----
if (code == INTEGER_TYPE || code == REAL_TYPE || code == POINTER_TYPE
|| code == ENUMERAL_TYPE || code == REFERENCE_TYPE
! || code == BOOLEAN_TYPE || code == COMPLEX_TYPE
|| TYPE_PTRMEMFUNC_P (type))
{
if (raw_constructor)
*************** digest_init (type, init, tail)
*** 578,584 ****
return error_mark_node;
}
! if (code == ARRAY_TYPE || IS_AGGR_TYPE_CODE (code))
{
if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type)
&& TREE_HAS_CONSTRUCTOR (init))
--- 578,584 ----
return error_mark_node;
}
! if (code == ARRAY_TYPE || code == VECTOR_TYPE || IS_AGGR_TYPE_CODE (code))
{
if (raw_constructor && TYPE_NON_AGGREGATE_CLASS (type)
&& TREE_HAS_CONSTRUCTOR (init))
*************** digest_init (type, init, tail)
*** 598,604 ****
return process_init_constructor (type, 0, tail);
}
! if (code != ARRAY_TYPE)
{
int flags = LOOKUP_NORMAL;
/* Initialization from { } is copy-initialization. */
--- 598,604 ----
return process_init_constructor (type, 0, tail);
}
! if (CLASS_TYPE_P (type))
{
int flags = LOOKUP_NORMAL;
/* Initialization from { } is copy-initialization. */
*************** process_init_constructor (type, init, el
*** 659,676 ****
for each element of this aggregate. Chain them together in result.
If there are too few, use 0 for each scalar ultimate component. */
! if (TREE_CODE (type) == ARRAY_TYPE)
{
- tree domain = TYPE_DOMAIN (type);
register long len;
register int i;
! if (domain)
! len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
! + 1);
else
! len = -1; /* Take as many as there are */
for (i = 0; len < 0 || i < len; i++)
{
--- 659,684 ----
for each element of this aggregate. Chain them together in result.
If there are too few, use 0 for each scalar ultimate component. */
! if (TREE_CODE (type) == ARRAY_TYPE || TREE_CODE (type) == VECTOR_TYPE)
{
register long len;
register int i;
! if (TREE_CODE (type) == ARRAY_TYPE)
! {
! tree domain = TYPE_DOMAIN (type);
! if (domain)
! len = (TREE_INT_CST_LOW (TYPE_MAX_VALUE (domain))
! - TREE_INT_CST_LOW (TYPE_MIN_VALUE (domain))
! + 1);
! else
! len = -1; /* Take as many as there are */
! }
else
! {
! /* Vectors are like simple fixed-size arrays. */
! len = TYPE_VECTOR_SUBPARTS (type);
! }
for (i = 0; len < 0 || i < len; i++)
{