This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: Handle vector modes in genopinit.c, c-typeck.c
- From: Daniel Berlin <dan at cgsoftware dot com>
- To: <gcc-patches at gcc dot gnu dot org>
- Date: Thu, 29 Nov 2001 12:19:39 -0500 (EST)
- Subject: Re: [PATCH]: Handle vector modes in genopinit.c, c-typeck.c
Whoops, i forgot to check the actual number of vector elements and
subtypes in c-typeck.c.
However, i'd still like to know whether it's even acceptable to allow
this, before i fix it.
On Thu, 29 Nov 2001, Daniel Berlin wrote:
> This patch changes c-typeck to allow us to build binary ops on vectors
> (assuming we have a handler in the backend), and changes genopinit to
> properly allow addv4sf3, etc, to be recognized as add handlers.
>
> With these two changes, you can now do:
>
> typedef float v4sf __attribute__((mode(V4SF)));
> int main(void)
> {
> v4sf a;
> float temp[4] = {1.0,2.0,3.0,4.0};
> a = __builtin_altivec_ld_internal_4f (&temp[0]);
> a = a + a;
> }
>
> and have it work (well, for altivec, you need my changes i'm about to
> submit to rs6000.c/rs6000.md/rs6000.h).
>
> The i386 backend has the approriate named/matching handlers for SSE.
>
> This means, except for the __builtin_altivec_ld_internal_4f, this code
> would be portable to both platforms.
>
> Regardless of whether you like adds of vector modes or not, i feel the
> genopinit change is still the right thing to do. Whether it really is or
> not, it just seems inconsistent to allow partial int and int, but not
> vector int, and float but not vector float.
> After all, (plus:v4si (reg:v4si 5) (reg:v4si 6)) is just as good as
> (plus:di (reg:di 5) (reg:di 7)).
>
> Maybe i'm just off.
>
> If these changes are allowed, i'll hunt down other places in the frontends
> that need to accept vector modes, if any.
>
> 2001-11-29 Daniel Berlin <dan@cgsoftware.com>
>
> * c-typeck.c (build_binary_op): Vector types are allowed, too.
>
> * genopinit.c (gen_insn): Handle MODE_VECTOR_INT and
> MODE_VECTOR_FLOAT as allowed.
> Index: c-typeck.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/c-typeck.c,v
> retrieving revision 1.152
> diff -c -3 -p -w -B -b -r1.152 c-typeck.c
> *** c-typeck.c 2001/11/07 22:52:30 1.152
> --- c-typeck.c 2001/11/29 16:57:25
> *************** build_binary_op (code, orig_op0, orig_op
> *** 2353,2361 ****
> break;
> }
>
> ! if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE)
> &&
> ! (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE))
> {
> int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
>
> --- 2353,2361 ----
> break;
> }
>
> ! if ((code0 == INTEGER_TYPE || code0 == REAL_TYPE || code0 == COMPLEX_TYPE || code0 == VECTOR_TYPE)
> &&
> ! (code1 == INTEGER_TYPE || code1 == REAL_TYPE || code1 == COMPLEX_TYPE || code1 == VECTOR_TYPE))
> {
> int none_complex = (code0 != COMPLEX_TYPE && code1 != COMPLEX_TYPE);
>
> Index: genopinit.c
> ===================================================================
> RCS file: /cvs/gcc/egcs/gcc/genopinit.c,v
> retrieving revision 1.49
> diff -c -3 -p -w -B -b -r1.49 genopinit.c
> *** genopinit.c 2001/11/14 20:17:07 1.49
> --- genopinit.c 2001/11/29 16:57:25
> *************** gen_insn (insn)
> *** 222,229 ****
> && (! force_int || mode_class[i] == MODE_INT)
> && (! force_partial_int
> || mode_class[i] == MODE_INT
> ! || mode_class[i] == MODE_PARTIAL_INT)
> ! && (! force_float || mode_class[i] == MODE_FLOAT))
> break;
> }
>
> --- 222,230 ----
> && (! force_int || mode_class[i] == MODE_INT)
> && (! force_partial_int
> || mode_class[i] == MODE_INT
> ! || mode_class[i] == MODE_PARTIAL_INT
> ! || mode_class[i] == MODE_VECTOR_INT)
> ! && (! force_float || mode_class[i] == MODE_FLOAT || mode_class[i] == MODE_VECTOR_FLOAT))
> break;
> }
>
>