From cf2c96b0f69ae4f00985761c89fd10a1fd8d3468 Mon Sep 17 00:00:00 2001 From: Bill Seurer Date: Mon, 12 Jan 2015 19:35:51 +0000 Subject: [PATCH] [PowerPC]To provide better compatibility with gcc I added the __bool keyword to the Alitivec support in clang. __bool is functionally identical to using bool when declaring vector types. For example: vector bool char v_bc; vector __bool char v___bc; clang already supported vector/__vector and pixel/__pixel but was missing __bool. http://llvm.org/bugs/show_bug.cgi?id=19220 For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html http://reviews.llvm.org/D6882 llvm-svn: 225664 --- clang/include/clang/Basic/TokenKinds.def | 1 + clang/lib/Parse/ParseDecl.cpp | 5 +++++ clang/lib/Parse/ParseTentative.cpp | 1 + clang/test/Parser/altivec.c | 14 ++++++++++++++ 4 files changed, 21 insertions(+) diff --git a/clang/include/clang/Basic/TokenKinds.def b/clang/include/clang/Basic/TokenKinds.def index da10622..3319d4e 100644 --- a/clang/include/clang/Basic/TokenKinds.def +++ b/clang/include/clang/Basic/TokenKinds.def @@ -495,6 +495,7 @@ KEYWORD(__pascal , KEYALL) // Altivec Extension. KEYWORD(__vector , KEYALTIVEC) KEYWORD(__pixel , KEYALTIVEC) +KEYWORD(__bool , KEYALTIVEC) // ARM NEON extensions. ALIAS("__fp16", half , KEYALL) diff --git a/clang/lib/Parse/ParseDecl.cpp b/clang/lib/Parse/ParseDecl.cpp index 66366d9..c4ab713 100644 --- a/clang/lib/Parse/ParseDecl.cpp +++ b/clang/lib/Parse/ParseDecl.cpp @@ -3200,6 +3200,9 @@ void Parser::ParseDeclarationSpecifiers(DeclSpec &DS, case tok::kw___pixel: isInvalid = DS.SetTypeAltiVecPixel(true, Loc, PrevSpec, DiagID, Policy); break; + case tok::kw___bool: + isInvalid = DS.SetTypeAltiVecBool(true, Loc, PrevSpec, DiagID, Policy); + break; case tok::kw___unknown_anytype: isInvalid = DS.SetTypeSpecType(TST_unknown_anytype, Loc, PrevSpec, DiagID, Policy); @@ -6036,6 +6039,7 @@ bool Parser::TryAltiVecVectorTokenOutOfLine() { case tok::kw_float: case tok::kw_double: case tok::kw_bool: + case tok::kw___bool: case tok::kw___pixel: Tok.setKind(tok::kw___vector); return true; @@ -6069,6 +6073,7 @@ bool Parser::TryAltiVecTokenOutOfLine(DeclSpec &DS, SourceLocation Loc, case tok::kw_float: case tok::kw_double: case tok::kw_bool: + case tok::kw___bool: case tok::kw___pixel: isInvalid = DS.SetTypeAltiVecVector(true, Loc, PrevSpec, DiagID, Policy); return true; diff --git a/clang/lib/Parse/ParseTentative.cpp b/clang/lib/Parse/ParseTentative.cpp index 929242f..abf16fa 100644 --- a/clang/lib/Parse/ParseTentative.cpp +++ b/clang/lib/Parse/ParseTentative.cpp @@ -992,6 +992,7 @@ Parser::isExpressionOrTypeSpecifierSimple(tok::TokenKind Kind) { case tok::kw___unaligned: case tok::kw___vector: case tok::kw___pixel: + case tok::kw___bool: case tok::kw__Atomic: case tok::kw___unknown_anytype: return TPResult::False; diff --git a/clang/test/Parser/altivec.c b/clang/test/Parser/altivec.c index 7adca61..d852511 100644 --- a/clang/test/Parser/altivec.c +++ b/clang/test/Parser/altivec.c @@ -18,6 +18,9 @@ __vector float vv_f; __vector bool char vv_bc; __vector bool short vv_bs; __vector bool int vv_bi; +__vector __bool char vv___bc; +__vector __bool short vv___bs; +__vector __bool int vv_bi; __vector __pixel vv_p; __vector pixel vv__p; __vector int vf__r(); @@ -40,6 +43,9 @@ vector float v_f; vector bool char v_bc; vector bool short v_bs; vector bool int v_bi; +vector __bool char v___bc; +vector __bool short v___bs; +vector __bool int v___bi; vector __pixel v_p; vector pixel v__p; vector int f__r(); @@ -64,6 +70,7 @@ vector unsigned long int v_uli; // expected-warning {{Use of 'long' with '__ __vector long double vv_ld; // expected-error {{cannot use 'long double' with '__vector'}} vector long double v_ld; // expected-error {{cannot use 'long double' with '__vector'}} vector bool v_b; // expected-warning {{type specifier missing, defaults to 'int'}} +vector __bool v___b; // expected-warning {{type specifier missing, defaults to 'int'}} // These should have errors. __vector double vv_d1; // expected-error {{use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)}} @@ -77,6 +84,13 @@ vector bool signed char v_bsc; // expected-error {{cannot use 'signed' wit vector bool unsigned int v_bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}} vector bool long v_bl; // expected-error {{cannot use 'long' with '__vector bool'}} vector bool long long v_bll; // expected-error {{cannot use 'long long' with '__vector bool'}} +vector __bool float v___bf; // expected-error {{cannot use 'float' with '__vector bool'}} +vector __bool double v___bd; // expected-error {{cannot use 'double' with '__vector bool'}} +vector __bool pixel v___bp; // expected-error {{cannot use '__pixel' with '__vector bool'}} +vector __bool signed char v___bsc; // expected-error {{cannot use 'signed' with '__vector bool'}} +vector __bool unsigned int v___bsc2; // expected-error {{cannot use 'unsigned' with '__vector bool'}} +vector __bool long v___bl; // expected-error {{cannot use 'long' with '__vector bool'}} +vector __bool long long v___bll; // expected-error {{cannot use 'long long' with '__vector bool'}} // vector long is deprecated, but vector long long is not. vector long long v_ll; -- 2.7.4