re PR target/36904 (vector context sensitive keyword vs macros)

PR target/36904
	* config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Return NULL
	instead of tok->val.node if not expanding to something else.  Handle
	intervening CPP_PADDING tokens.
	(altivec_categorize_keyword): Remove unneeded comparisons.

	* gcc.target/powerpc/altivec-27.c: New test.

From-SVN: r140247
This commit is contained in:
Jakub Jelinek 2008-09-10 23:06:25 +02:00 committed by Jakub Jelinek
parent 1011d8a2ff
commit a76ddc7bda
4 changed files with 70 additions and 14 deletions

View File

@ -1,3 +1,11 @@
2008-09-10 Jakub Jelinek <jakub@redhat.com>
PR target/36904
* config/rs6000/rs6000-c.c (rs6000_macro_to_expand): Return NULL
instead of tok->val.node if not expanding to something else. Handle
intervening CPP_PADDING tokens.
(altivec_categorize_keyword): Remove unneeded comparisons.
2008-09-10 Richard Guenther <rguenther@suse.de>
* tree-ssa-pre.c (phi_translate_1): Fix memory leak.

View File

@ -102,16 +102,13 @@ altivec_categorize_keyword (const cpp_token *tok)
{
cpp_hashnode *ident = tok->val.node;
if (ident == C_CPP_HASHNODE (vector_keyword)
|| ident == C_CPP_HASHNODE (__vector_keyword))
if (ident == C_CPP_HASHNODE (vector_keyword))
return C_CPP_HASHNODE (__vector_keyword);
if (ident == C_CPP_HASHNODE (pixel_keyword)
|| ident == C_CPP_HASHNODE (__pixel_keyword))
if (ident == C_CPP_HASHNODE (pixel_keyword))
return C_CPP_HASHNODE (__pixel_keyword);
if (ident == C_CPP_HASHNODE (bool_keyword)
|| ident == C_CPP_HASHNODE (__bool_keyword))
if (ident == C_CPP_HASHNODE (bool_keyword))
return C_CPP_HASHNODE (__bool_keyword);
return ident;
@ -158,12 +155,18 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
ident = altivec_categorize_keyword (tok);
if (ident != expand_this)
expand_this = NULL;
if (ident == C_CPP_HASHNODE (__vector_keyword))
{
tok = cpp_peek_token (pfile, 0);
int idx = 0;
do
tok = cpp_peek_token (pfile, idx++);
while (tok->type == CPP_PADDING);
ident = altivec_categorize_keyword (tok);
if (ident == C_CPP_HASHNODE (__pixel_keyword))
if (ident == C_CPP_HASHNODE (__pixel_keyword))
{
expand_this = C_CPP_HASHNODE (__vector_keyword);
expand_bool_pixel = __pixel_keyword;
@ -178,8 +181,12 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
enum rid rid_code = (enum rid)(ident->rid_code);
if (ident->type == NT_MACRO)
{
(void)cpp_get_token (pfile);
tok = cpp_peek_token (pfile, 0);
do
(void) cpp_get_token (pfile);
while (--idx > 0);
do
tok = cpp_peek_token (pfile, idx++);
while (tok->type == CPP_PADDING);
ident = altivec_categorize_keyword (tok);
if (ident)
rid_code = (enum rid)(ident->rid_code);
@ -193,19 +200,23 @@ rs6000_macro_to_expand (cpp_reader *pfile, const cpp_token *tok)
expand_this = C_CPP_HASHNODE (__vector_keyword);
/* If the next keyword is bool or pixel, it
will need to be expanded as well. */
tok = cpp_peek_token (pfile, 1);
do
tok = cpp_peek_token (pfile, idx++);
while (tok->type == CPP_PADDING);
ident = altivec_categorize_keyword (tok);
if (ident == C_CPP_HASHNODE (__pixel_keyword))
if (ident == C_CPP_HASHNODE (__pixel_keyword))
expand_bool_pixel = __pixel_keyword;
else if (ident == C_CPP_HASHNODE (__bool_keyword))
expand_bool_pixel = __bool_keyword;
else
{
/* Try two tokens down, too. */
tok = cpp_peek_token (pfile, 2);
do
tok = cpp_peek_token (pfile, idx++);
while (tok->type == CPP_PADDING);
ident = altivec_categorize_keyword (tok);
if (ident == C_CPP_HASHNODE (__pixel_keyword))
if (ident == C_CPP_HASHNODE (__pixel_keyword))
expand_bool_pixel = __pixel_keyword;
else if (ident == C_CPP_HASHNODE (__bool_keyword))
expand_bool_pixel = __bool_keyword;

View File

@ -1,3 +1,8 @@
2008-09-10 Jakub Jelinek <jakub@redhat.com>
PR target/36904
* gcc.target/powerpc/altivec-27.c: New test.
2008-09-10 Andrew Pinski <andrew_pinski@playstation.sony.com>
PR middle-end/37333

View File

@ -0,0 +1,32 @@
/* { dg-do compile { target powerpc*-*-* } } */
/* { dg-require-effective-target powerpc_altivec_ok } */
/* { dg-options "-maltivec" } */
#define f0() void x0 (vector float x) { }
f0 ()
#define f1(type) void x1##type (vector type x) { }
f1 (float)
#define f2(v, type) void x2##type (v type x) { }
f2 (vector, float)
#define f3(type) void x3##type (vector bool type x) { }
f3 (int)
#define f4(v, type) void x4##type (v bool type x) { }
f4 (vector, int)
#define f5(b, type) void x5##type (vector b type x) { }
f5 (bool, int)
#define f6(v, b, type) void x6##type (v b type x) { }
f6 (vector, bool, int)
#define f7(v, b, type) void x7##type (v type b x) { }
f7 (vector, bool, int)
int vector = 6;
#define v1(v) int x8 (int v) { return v; }
v1(vector)