Skip to content

[PowerPC] Update altivec.h to use __inline__ for c89 compatibility #134430

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025

Conversation

lei137
Copy link
Contributor

@lei137 lei137 commented Apr 4, 2025

No description provided.

@lei137 lei137 self-assigned this Apr 4, 2025
@llvmbot llvmbot added clang Clang issues not falling into any other category backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics labels Apr 4, 2025
@lei137 lei137 linked an issue Apr 4, 2025 that may be closed by this pull request
@llvmbot
Copy link
Member

llvmbot commented Apr 4, 2025

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-backend-x86

Author: Lei Huang (lei137)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/134430.diff

2 Files Affected:

  • (modified) clang/lib/Headers/altivec.h (+46-46)
  • (modified) clang/test/Headers/altivec-header.c (+1)
diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 8da65055012f1..4b1b13aadf135 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17525,70 +17525,70 @@ vec_bperm(vector unsigned long long __a, vector unsigned char __b) {
 
 /* vec_reve */
 
-static inline __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) {
+static __inline__ __ATTRS_o_ai vector bool char vec_reve(vector bool char __a) {
   return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
                                  5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector signed char vec_reve(vector signed char __a) {
+static __inline__ __ATTRS_o_ai vector signed char vec_reve(vector signed char __a) {
   return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
                                  5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector unsigned char
+static __inline__ __ATTRS_o_ai vector unsigned char
 vec_reve(vector unsigned char __a) {
   return __builtin_shufflevector(__a, __a, 15, 14, 13, 12, 11, 10, 9, 8, 7, 6,
                                  5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) {
+static __inline__ __ATTRS_o_ai vector bool int vec_reve(vector bool int __a) {
   return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector signed int vec_reve(vector signed int __a) {
+static __inline__ __ATTRS_o_ai vector signed int vec_reve(vector signed int __a) {
   return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector unsigned int
+static __inline__ __ATTRS_o_ai vector unsigned int
 vec_reve(vector unsigned int __a) {
   return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector bool short vec_reve(vector bool short __a) {
+static __inline__ __ATTRS_o_ai vector bool short vec_reve(vector bool short __a) {
   return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector signed short
+static __inline__ __ATTRS_o_ai vector signed short
 vec_reve(vector signed short __a) {
   return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector unsigned short
+static __inline__ __ATTRS_o_ai vector unsigned short
 vec_reve(vector unsigned short __a) {
   return __builtin_shufflevector(__a, __a, 7, 6, 5, 4, 3, 2, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector float vec_reve(vector float __a) {
+static __inline__ __ATTRS_o_ai vector float vec_reve(vector float __a) {
   return __builtin_shufflevector(__a, __a, 3, 2, 1, 0);
 }
 
 #ifdef __VSX__
-static inline __ATTRS_o_ai vector bool long long
+static __inline__ __ATTRS_o_ai vector bool long long
 vec_reve(vector bool long long __a) {
   return __builtin_shufflevector(__a, __a, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector signed long long
+static __inline__ __ATTRS_o_ai vector signed long long
 vec_reve(vector signed long long __a) {
   return __builtin_shufflevector(__a, __a, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector unsigned long long
+static __inline__ __ATTRS_o_ai vector unsigned long long
 vec_reve(vector unsigned long long __a) {
   return __builtin_shufflevector(__a, __a, 1, 0);
 }
 
-static inline __ATTRS_o_ai vector double vec_reve(vector double __a) {
+static __inline__ __ATTRS_o_ai vector double vec_reve(vector double __a) {
   return __builtin_shufflevector(__a, __a, 1, 0);
 }
 #endif
@@ -17721,41 +17721,41 @@ typedef vector signed int unaligned_vec_sint __attribute__((aligned(1)));
 typedef vector unsigned int unaligned_vec_uint __attribute__((aligned(1)));
 typedef vector float unaligned_vec_float __attribute__((aligned(1)));
 
-static inline __ATTRS_o_ai vector signed char vec_xl(ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai vector signed char vec_xl(ptrdiff_t __offset,
                                                      const signed char *__ptr) {
   return *(unaligned_vec_schar *)(__ptr + __offset);
 }
 
-static inline __ATTRS_o_ai vector unsigned char
+static __inline__ __ATTRS_o_ai vector unsigned char
 vec_xl(ptrdiff_t __offset, const unsigned char *__ptr) {
   return *(unaligned_vec_uchar*)(__ptr + __offset);
 }
 
-static inline __ATTRS_o_ai vector signed short
+static __inline__ __ATTRS_o_ai vector signed short
 vec_xl(ptrdiff_t __offset, const signed short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sshort *)__addr;
 }
 
-static inline __ATTRS_o_ai vector unsigned short
+static __inline__ __ATTRS_o_ai vector unsigned short
 vec_xl(ptrdiff_t __offset, const unsigned short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_ushort *)__addr;
 }
 
-static inline __ATTRS_o_ai vector signed int vec_xl(ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai vector signed int vec_xl(ptrdiff_t __offset,
                                                     const signed int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sint *)__addr;
 }
 
-static inline __ATTRS_o_ai vector unsigned int
+static __inline__ __ATTRS_o_ai vector unsigned int
 vec_xl(ptrdiff_t __offset, const unsigned int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_uint *)__addr;
 }
 
-static inline __ATTRS_o_ai vector float vec_xl(ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai vector float vec_xl(ptrdiff_t __offset,
                                                const float *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_float *)__addr;
@@ -17766,19 +17766,19 @@ typedef vector signed long long unaligned_vec_sll __attribute__((aligned(1)));
 typedef vector unsigned long long unaligned_vec_ull __attribute__((aligned(1)));
 typedef vector double unaligned_vec_double __attribute__((aligned(1)));
 
-static inline __ATTRS_o_ai vector signed long long
+static __inline__ __ATTRS_o_ai vector signed long long
 vec_xl(ptrdiff_t __offset, const signed long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_sll *)__addr;
 }
 
-static inline __ATTRS_o_ai vector unsigned long long
+static __inline__ __ATTRS_o_ai vector unsigned long long
 vec_xl(ptrdiff_t __offset, const unsigned long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_ull *)__addr;
 }
 
-static inline __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset,
                                                 const double *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_double *)__addr;
@@ -17790,13 +17790,13 @@ static inline __ATTRS_o_ai vector double vec_xl(ptrdiff_t __offset,
 typedef vector signed __int128 unaligned_vec_si128 __attribute__((aligned(1)));
 typedef vector unsigned __int128 unaligned_vec_ui128
     __attribute__((aligned(1)));
-static inline __ATTRS_o_ai vector signed __int128
+static __inline__ __ATTRS_o_ai vector signed __int128
 vec_xl(ptrdiff_t __offset, const signed __int128 *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_si128 *)__addr;
 }
 
-static inline __ATTRS_o_ai vector unsigned __int128
+static __inline__ __ATTRS_o_ai vector unsigned __int128
 vec_xl(ptrdiff_t __offset, const unsigned __int128 *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   return *(unaligned_vec_ui128 *)__addr;
@@ -17991,63 +17991,63 @@ vec_load_splats(unsigned long long __offset, const float *__ptr) {
 
 #define vec_xstd2 vec_xst
 #define vec_xstw4 vec_xst
-static inline __ATTRS_o_ai void
+static __inline__ __ATTRS_o_ai void
 vec_xst(vector signed char __vec, ptrdiff_t __offset, signed char *__ptr) {
   *(unaligned_vec_schar *)(__ptr + __offset) = __vec;
 }
 
-static inline __ATTRS_o_ai void
+static __inline__ __ATTRS_o_ai void
 vec_xst(vector unsigned char __vec, ptrdiff_t __offset, unsigned char *__ptr) {
   *(unaligned_vec_uchar *)(__ptr + __offset) = __vec;
 }
 
-static inline __ATTRS_o_ai void
+static __inline__ __ATTRS_o_ai void
 vec_xst(vector signed short __vec, ptrdiff_t __offset, signed short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_sshort *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
                                         ptrdiff_t __offset,
                                         unsigned short *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_ushort *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector signed int __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector signed int __vec,
                                         ptrdiff_t __offset, signed int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_sint *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void
+static __inline__ __ATTRS_o_ai void
 vec_xst(vector unsigned int __vec, ptrdiff_t __offset, unsigned int *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_uint *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector float __vec, ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai void vec_xst(vector float __vec, ptrdiff_t __offset,
                                         float *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_float *)__addr = __vec;
 }
 
 #ifdef __VSX__
-static inline __ATTRS_o_ai void vec_xst(vector signed long long __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector signed long long __vec,
                                         ptrdiff_t __offset,
                                         signed long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_sll *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector unsigned long long __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned long long __vec,
                                         ptrdiff_t __offset,
                                         unsigned long long *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_ull *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector double __vec, ptrdiff_t __offset,
+static __inline__ __ATTRS_o_ai void vec_xst(vector double __vec, ptrdiff_t __offset,
                                         double *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_double *)__addr = __vec;
@@ -18056,14 +18056,14 @@ static inline __ATTRS_o_ai void vec_xst(vector double __vec, ptrdiff_t __offset,
 
 #if defined(__POWER8_VECTOR__) && defined(__powerpc64__) &&                    \
     defined(__SIZEOF_INT128__)
-static inline __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
                                         ptrdiff_t __offset,
                                         signed __int128 *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
   *(unaligned_vec_si128 *)__addr = __vec;
 }
 
-static inline __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
                                         ptrdiff_t __offset,
                                         unsigned __int128 *__ptr) {
   signed char *__addr = (signed char *)__ptr + __offset;
@@ -18075,49 +18075,49 @@ static inline __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
 
 #if defined(__POWER10_VECTOR__) && defined(__VSX__) &&                         \
     defined(__SIZEOF_INT128__)
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
                                               ptrdiff_t __offset,
                                               signed char *__ptr) {
   *(__ptr + __offset) = (signed char)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
                                               ptrdiff_t __offset,
                                               unsigned char *__ptr) {
   *(__ptr + __offset) = (unsigned char)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
                                               ptrdiff_t __offset,
                                               signed short *__ptr) {
   *(__ptr + __offset) = (signed short)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
                                               ptrdiff_t __offset,
                                               unsigned short *__ptr) {
   *(__ptr + __offset) = (unsigned short)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
                                               ptrdiff_t __offset,
                                               signed int *__ptr) {
   *(__ptr + __offset) = (signed int)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
                                               ptrdiff_t __offset,
                                               unsigned int *__ptr) {
   *(__ptr + __offset) = (unsigned int)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
                                               ptrdiff_t __offset,
                                               signed long long *__ptr) {
   *(__ptr + __offset) = (signed long long)__vec[0];
 }
 
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
                                               ptrdiff_t __offset,
                                               unsigned long long *__ptr) {
   *(__ptr + __offset) = (unsigned long long)__vec[0];
diff --git a/clang/test/Headers/altivec-header.c b/clang/test/Headers/altivec-header.c
index 00e5f444de7cc..2b57c640d9542 100644
--- a/clang/test/Headers/altivec-header.c
+++ b/clang/test/Headers/altivec-header.c
@@ -1,6 +1,7 @@
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec -ffreestanding -emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec -ffreestanding -emit-llvm -flax-vector-conversions=none -o - %s | FileCheck %s
 // RUN: %clang_cc1 -triple powerpc64-unknown-unknown -target-feature +altivec -ffreestanding -emit-llvm -x c++ -o - %s | FileCheck %s
+// RUN: %clang_cc1 -std=c89 -triple powerpc64-unknown-unknown -target-feature +altivec -ffreestanding -emit-llvm -o - %s | FileCheck %s
 
 #include <altivec.h>
 

Copy link

github-actions bot commented Apr 4, 2025

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Collaborator

@hubert-reinterpretcast hubert-reinterpretcast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM with a suggestion.

@lei137 lei137 merged commit c22586a into llvm:main Apr 4, 2025
6 of 10 checks passed
@AaronBallman
Copy link
Collaborator

Thank you for the quick fix to that issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 clang:headers Headers provided by Clang, e.g. for intrinsics clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

POWER8 and "error: unknown type name 'inline'" when using -std=c89
4 participants