diff options
author | Jakub Jelinek <jakub@redhat.com> | 2008-09-10 23:06:25 +0200 |
---|---|---|
committer | Jakub Jelinek <jakub@gcc.gnu.org> | 2008-09-10 23:06:25 +0200 |
commit | a76ddc7bda84d17ddc6577c60daf95897a2de515 (patch) | |
tree | 089a54f99fe72026286048a049f61df57d71ec60 /gcc | |
parent | 1011d8a2ffdba31d8b9d43be43daa69ac8fb56a3 (diff) | |
download | gcc-a76ddc7bda84d17ddc6577c60daf95897a2de515.zip gcc-a76ddc7bda84d17ddc6577c60daf95897a2de515.tar.gz gcc-a76ddc7bda84d17ddc6577c60daf95897a2de515.tar.bz2 |
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
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/rs6000/rs6000-c.c | 39 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 5 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/powerpc/altivec-27.c | 32 |
4 files changed, 70 insertions, 14 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index c24b2e8..48e59e6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -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. diff --git a/gcc/config/rs6000/rs6000-c.c b/gcc/config/rs6000/rs6000-c.c index 8cbace8..da1cb78 100644 --- a/gcc/config/rs6000/rs6000-c.c +++ b/gcc/config/rs6000/rs6000-c.c @@ -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; diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index f4fca18..88463e9 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -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 diff --git a/gcc/testsuite/gcc.target/powerpc/altivec-27.c b/gcc/testsuite/gcc.target/powerpc/altivec-27.c new file mode 100644 index 0000000..7db0ea0 --- /dev/null +++ b/gcc/testsuite/gcc.target/powerpc/altivec-27.c @@ -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) |