This is an archive of the discontinued LLVM Phabricator instance.

Add the Altivec __bool keyword for better gcc compatibility
ClosedPublic

Authored by seurer on Jan 8 2015, 12:28 PM.

Details

Summary

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 and pixel but was missing __bool for some reason.

For reference: https://gcc.gnu.org/onlinedocs/gcc-4.9.2/gcc/PowerPC-AltiVec_002fVSX-Built-in-Functions.html

Diff Detail

Event Timeline

seurer updated this revision to Diff 17905.Jan 8 2015, 12:28 PM
seurer retitled this revision from to Add the Altivec __bool keyword for better gcc compatibility.
seurer updated this object.
seurer edited the test plan for this revision. (Show Details)
seurer added reviewers: wschmidt, willschm, echristo, hfinkel.
seurer added a subscriber: Unknown Object (MLST).
wschmidt edited edge metadata.Jan 8 2015, 12:58 PM

FYI to other reviewers: This was noted as a deficiency in http://llvm.org/bugs/show_bug.cgi?id=19220.

hfinkel accepted this revision.Jan 8 2015, 2:46 PM
hfinkel edited edge metadata.

LGTM.

We should, however, as a follow-up, think about normalizing how we print these things in error messages. This example from the regression tests you're adding seems to be an amusing representative:

vector __bool pixel v___bp;          // expected-error {{cannot use '__pixel' with '__vector bool'}}

So the original source has vector and pixel without underscores, and bool with them. The error message prints vector and pixel with underscores, and bool without them. We should probably pick one, or the other, or record whether the original token had underscores or not and print them in a corresponding way. The latter is better, but perhaps more work.

This revision is now accepted and ready to land.Jan 8 2015, 2:46 PM
seurer added a comment.Jan 8 2015, 7:52 PM

The __vector bool is hardcoded in the message in DiagnosticParseKinds.td. Hmm, there are a whole bunch of other similar ones in there, too.

def err_invalid_vector_decl_spec_combination : Error<

"cannot combine with previous '%0' declaration specifier. "
"'__vector' must be first">;

def err_invalid_pixel_decl_spec_combination : Error<

"'__pixel' must be preceded by '__vector'.  "
"'%0' declaration specifier not allowed here">;

def err_invalid_vector_bool_decl_spec : Error<

"cannot use '%0' with '__vector bool'">;

def err_invalid_vector_double_decl_spec : Error <

"use of 'double' with '__vector' requires VSX support to be enabled (available on the POWER7 or later)">;

def err_invalid_vector_long_double_decl_spec : Error<

"cannot use 'long double' with '__vector'">;

def warn_vector_long_decl_spec_combination : Warning<

"Use of 'long' with '__vector' is deprecated">, InGroup<Deprecated>;