[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-22 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate added a comment.



> Thanks @aaron.ballman for the detailed explanation! I have learnt it. 
> @lygstate maybe include Aaron's explanation in commit message?

The commit message is updated, is that ready for merge?


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-16 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D157297#4592851 , @aaron.ballman 
wrote:

> In D157297#4590886 , @pengfei wrote:
>
>> BTW, maybe @aaron.ballman knows why we don't support such syntax in C++.
>
> The return statement expects an expression or braced init list: 
> http://eel.is/c++draft/stmt.jump#general-1 but we really only need to care 
> about the expression form (there's no braces in sight).
> Grammatically, the leading `::` will parse as a qualified-id because it 
> matches the production for nested-name-specifier: 
> http://eel.is/c++draft/expr.prim.id.qual#nt:qualified-id
> That needs to be followed by an unqualified-id 
> (http://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id), but the open 
> paren does not match any of the grammar productions, so this is a syntax 
> error.

Thanks @aaron.ballman for the detailed explanation! I have learnt it. @lygstate 
maybe include Aaron's explanation in commit message?


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-16 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D157297#4590886 , @pengfei wrote:

> BTW, maybe @aaron.ballman knows why we don't support such syntax in C++.

The return statement expects an expression or braced init list: 
http://eel.is/c++draft/stmt.jump#general-1 but we really only need to care 
about the expression form (there's no braces in sight).
Grammatically, the leading `::` will parse as a qualified-id because it matches 
the production for nested-name-specifier: 
http://eel.is/c++draft/expr.prim.id.qual#nt:qualified-id
That needs to be followed by an unqualified-id 
(http://eel.is/c++draft/expr.prim.id.unqual#nt:unqualified-id), but the open 
paren does not match any of the grammar productions, so this is a syntax error.


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a subscriber: aaron.ballman.
pengfei added a comment.

BTW, maybe @aaron.ballman knows why we don't support such syntax in C++.


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei accepted this revision.
pengfei added a comment.
This revision is now accepted and ready to land.

LGTM.


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate updated this revision to Diff 550587.
lygstate added a comment.

Revert to version 1


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

https://reviews.llvm.org/D157297

Files:
  clang/lib/Headers/bmiintrin.h


Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,7 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
+#define _tzcnt_u16 __tzcnt_u16
 
 /// Counts the number of trailing zero bits in the operand.
 ///
@@ -71,7 +71,7 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
+#define _tzcnt_u32 __tzcnt_u32
 
 #ifdef __x86_64__
 
@@ -109,7 +109,7 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
+#define _tzcnt_u64 __tzcnt_u64
 
 #endif /* __x86_64__ */
 
@@ -121,14 +121,14 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 
__target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
+#define _andn_u32 __andn_u32
 
 /* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
+#define _blsi_u32 __blsi_u32
 
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
+#define _blsmsk_u32 __blsmsk_u32
 
-#define _blsr_u32(a)  (__blsr_u32((a)))
+#define _blsr_u32 __blsr_u32
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
@@ -272,14 +272,14 @@
 
 #ifdef __x86_64__
 
-#define _andn_u64(a, b)   (__andn_u64((a), (b)))
+#define _andn_u64 __andn_u64
 
 /* _bextr_u64 != __bextr_u64 */
-#define _blsi_u64(a)  (__blsi_u64((a)))
+#define _blsi_u64 __blsi_u64
 
-#define _blsmsk_u64(a)(__blsmsk_u64((a)))
+#define _blsmsk_u64 __blsmsk_u64
 
-#define _blsr_u64(a)  (__blsr_u64((a)))
+#define _blsr_u64 __blsr_u64
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.


Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,7 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
+#define _tzcnt_u16 __tzcnt_u16
 
 /// Counts the number of trailing zero bits in the operand.
 ///
@@ -71,7 +71,7 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
+#define _tzcnt_u32 __tzcnt_u32
 
 #ifdef __x86_64__
 
@@ -109,7 +109,7 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
+#define _tzcnt_u64 __tzcnt_u64
 
 #endif /* __x86_64__ */
 
@@ -121,14 +121,14 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
+#define _andn_u32 __andn_u32
 
 /* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
+#define _blsi_u32 __blsi_u32
 
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
+#define _blsmsk_u32 __blsmsk_u32
 
-#define _blsr_u32(a)  (__blsr_u32((a)))
+#define _blsr_u32 __blsr_u32
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
@@ -272,14 +272,14 @@
 
 #ifdef __x86_64__
 
-#define _andn_u64(a, b)   (__andn_u64((a), (b)))
+#define _andn_u64 __andn_u64
 
 /* _bextr_u64 != __bextr_u64 */
-#define _blsi_u64(a)  (__blsi_u64((a)))
+#define _blsi_u64 __blsi_u64
 
-#define _blsmsk_u64(a)(__blsmsk_u64((a)))
+#define _blsmsk_u64 __blsmsk_u64
 
-#define _blsr_u64(a)  (__blsr_u64((a)))
+#define _blsr_u64 __blsr_u64
 
 /// Performs a bitwise AND of the second operand with the one's
 ///complement of the first operand.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

In D157297#4590692 , @lygstate wrote:

> In D157297#4590580 , @pengfei wrote:
>
>> 
>
>
>
>> I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
>> https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994
>
> Do you means revert to the first version?

Yes.

>> Besides, you should update the summary as well.
>
> I don't know what kind of summary you want, I can give me that so I can 
> update it

A reliable source about double colon operator cannot resolve function with 
parentheses in C++ is the best I expect, however I haven't find one so far.
Maybe a short description about the phenomenon on GCC/Clang is better than just 
giving error message. I don't have strong request for this.


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate added a comment.

In D157297#4590580 , @pengfei wrote:

> 



> I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
> https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994

Do you means revert to the first version?

> Besides, you should update the summary as well.

I don't know what kind of summary you want, I can give me that so I can update 
it


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

I'd prefer macro to duplicated definitions. We have such precedents, e.g., 
https://github.com/llvm/llvm-project/blob/main/clang/lib/Headers/xmmintrin.h#L2994
Besides, you should update the summary as well.


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

https://reviews.llvm.org/D157297

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D157297: [clang] Fixes compile error that double colon operator cannot resolve macro with parentheses.

2023-08-15 Thread Yonggang Luo via Phabricator via cfe-commits
lygstate updated this revision to Diff 550413.
lygstate added a comment.

creating proper function definitions instead of macro define


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

https://reviews.llvm.org/D157297

Files:
  clang/lib/Headers/bmiintrin.h

Index: clang/lib/Headers/bmiintrin.h
===
--- clang/lib/Headers/bmiintrin.h
+++ clang/lib/Headers/bmiintrin.h
@@ -19,8 +19,7 @@
to use it as a potentially faster version of BSF. */
 #define __RELAXED_FN_ATTRS __attribute__((__always_inline__, __nodebug__))
 
-#define _tzcnt_u16(a) (__tzcnt_u16((a)))
-
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -31,12 +30,32 @@
 ///An unsigned 16-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 16-bit integer containing the number of trailing zero
 ///bits in the operand.
+/// \see _tzcnt_u16
 static __inline__ unsigned short __RELAXED_FN_ATTRS
 __tzcnt_u16(unsigned short __X)
 {
   return __builtin_ia32_tzcnt_u16(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 16-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 16-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u16
+static __inline__ unsigned short __RELAXED_FN_ATTRS
+_tzcnt_u16(unsigned short __X)
+{
+  return __builtin_ia32_tzcnt_u16(__X);
+}
+
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -47,13 +66,31 @@
 ///An unsigned 32-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 32-bit integer containing the number of trailing zero
 ///bits in the operand.
-/// \see _mm_tzcnt_32
+/// \see _tzcnt_u32
 static __inline__ unsigned int __RELAXED_FN_ATTRS
 __tzcnt_u32(unsigned int __X)
 {
   return __builtin_ia32_tzcnt_u32(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 32-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 32-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u32
+static __inline__ unsigned int __RELAXED_FN_ATTRS
+_tzcnt_u32(unsigned int __X)
+{
+  return __builtin_ia32_tzcnt_u32(__X);
+}
+
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -71,10 +108,9 @@
   return (int)__builtin_ia32_tzcnt_u32(__X);
 }
 
-#define _tzcnt_u32(a) (__tzcnt_u32((a)))
-
 #ifdef __x86_64__
 
+/* AMD-specified, double-leading-underscore version of TZCNT */
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -85,13 +121,31 @@
 ///An unsigned 64-bit integer whose trailing zeros are to be counted.
 /// \returns An unsigned 64-bit integer containing the number of trailing zero
 ///bits in the operand.
-/// \see _mm_tzcnt_64
+/// \see _tzcnt_u64
 static __inline__ unsigned long long __RELAXED_FN_ATTRS
 __tzcnt_u64(unsigned long long __X)
 {
   return __builtin_ia32_tzcnt_u64(__X);
 }
 
+/* Intel-specified, single-leading-underscore version of TZCNT */
+/// Counts the number of trailing zero bits in the operand.
+///
+/// \headerfile 
+///
+/// This intrinsic corresponds to the  TZCNT  instruction.
+///
+/// \param __X
+///An unsigned 64-bit integer whose trailing zeros are to be counted.
+/// \returns An unsigned 64-bit integer containing the number of trailing zero
+///bits in the operand.
+/// \see __tzcnt_u64
+static __inline__ unsigned long long __RELAXED_FN_ATTRS
+_tzcnt_u64(unsigned long long __X)
+{
+  return __builtin_ia32_tzcnt_u64(__X);
+}
+
 /// Counts the number of trailing zero bits in the operand.
 ///
 /// \headerfile 
@@ -109,8 +163,6 @@
   return (long long)__builtin_ia32_tzcnt_u64(__X);
 }
 
-#define _tzcnt_u64(a) (__tzcnt_u64((a)))
-
 #endif /* __x86_64__ */
 
 #undef __RELAXED_FN_ATTRS
@@ -121,15 +173,7 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("bmi")))
 
-#define _andn_u32(a, b)   (__andn_u32((a), (b)))
-
-/* _bextr_u32 != __bextr_u32 */
-#define _blsi_u32(a)  (__blsi_u32((a)))
-
-#define _blsmsk_u32(a)(__blsmsk_u32((a)))
-
-#define _blsr_u32(a)  (__blsr_u32((a)))
-
+/* AMD-specified, double-leading-underscore version of ANDN */
 /// Performs a bitwise AND of the second operand with the one's
 //