r225664 - [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:

Bill Seurer seurer at linux.vnet.ibm.com
Mon Jan 12 11:35:51 PST 2015


Author: seurer
Date: Mon Jan 12 13:35:51 2015
New Revision: 225664

URL: http://llvm.org/viewvc/llvm-project?rev=225664&view=rev
Log:
[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

Modified:
    cfe/trunk/include/clang/Basic/TokenKinds.def
    cfe/trunk/lib/Parse/ParseDecl.cpp
    cfe/trunk/lib/Parse/ParseTentative.cpp
    cfe/trunk/test/Parser/altivec.c

Modified: cfe/trunk/include/clang/Basic/TokenKinds.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TokenKinds.def?rev=225664&r1=225663&r2=225664&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/TokenKinds.def (original)
+++ cfe/trunk/include/clang/Basic/TokenKinds.def Mon Jan 12 13:35:51 2015
@@ -495,6 +495,7 @@ KEYWORD(__pascal                    , KE
 // Altivec Extension.
 KEYWORD(__vector                    , KEYALTIVEC)
 KEYWORD(__pixel                     , KEYALTIVEC)
+KEYWORD(__bool                      , KEYALTIVEC)
 
 // ARM NEON extensions.
 ALIAS("__fp16", half                , KEYALL)

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=225664&r1=225663&r2=225664&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Mon Jan 12 13:35:51 2015
@@ -3200,6 +3200,9 @@ void Parser::ParseDeclarationSpecifiers(
     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::TryAltiVecVectorTokenOutOfL
   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(De
     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;

Modified: cfe/trunk/lib/Parse/ParseTentative.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseTentative.cpp?rev=225664&r1=225663&r2=225664&view=diff
==============================================================================
--- cfe/trunk/lib/Parse/ParseTentative.cpp (original)
+++ cfe/trunk/lib/Parse/ParseTentative.cpp Mon Jan 12 13:35:51 2015
@@ -992,6 +992,7 @@ Parser::isExpressionOrTypeSpecifierSimpl
   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;

Modified: cfe/trunk/test/Parser/altivec.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Parser/altivec.c?rev=225664&r1=225663&r2=225664&view=diff
==============================================================================
--- cfe/trunk/test/Parser/altivec.c (original)
+++ cfe/trunk/test/Parser/altivec.c Mon Jan 12 13:35:51 2015
@@ -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;     // e
 __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;       //
 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;





More information about the cfe-commits mailing list