[PATCH] D71463: Implement VectorType conditional operator GNU extension.

Erich Keane via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri Dec 27 09:09:51 PST 2019


erichkeane marked 2 inline comments as done.
erichkeane added a comment.

In D71463#1797436 <https://reviews.llvm.org/D71463#1797436>, @Anastasia wrote:

> It looks good, I was just thinking whether it would be possible to share more common infrastructure. There is `Sema::CheckVectorOperands` that corresponding OpenCL methods are using internally. Do you think it is possible to share the code more?


I tried in my initial implementation.  Unfortunately CheckVectorOperands and the OpenCL vectors have significantly different semantic rules from this, these aren't even consistent with the normal GCC vector conversion rules. The similarities/differences between all of these are frustrating, any attempt I made at unifying the logic made both really difficult to follow.



================
Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:6880
+def err_conditional_vector_has_void : Error<
+  "GNU vector conditional operand cannot be %select{void|a throw expression}0">;
+def err_conditional_vector_operand_type
----------------
Anastasia wrote:
> Would this only apply to GNU extension? I am just wondering if this can be generalized.
To be honest, I limited the scope of this a bit since the ext_vector type isn't something I have a great knowledge of.  The OpenCL vector types end up having frustratingly similar/different behavior that it required significant differences in logic.

Does OpenCL prohibit void/throw expressions in their vector conditionals?


================
Comment at: clang/lib/Sema/SemaExprCXX.cpp:5797
+    // If both are vector types, they must be the same type.
+    if (!Context.hasSameType(LHSType, RHSType)) {
+      Diag(QuestionLoc, diag::err_conditional_vector_mismatched_vectors)
----------------
Anastasia wrote:
> Don't we already have a diagnostic for this used in OpenCL?
The one I found was less specific than just 'mismatched'.  It ended up containing info about not convertible.  I tried a set of 'selects' on it but it ended up getting hacked up more than I was comfortable with.  Unless you're referring to a different one that I missed?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D71463/new/

https://reviews.llvm.org/D71463





More information about the cfe-commits mailing list