[clang] c22586a - [PowerPC] Update altivec.h to use __inline__ for c89 compatibility (#134430)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Apr 4 12:19:40 PDT 2025
Author: Lei Huang
Date: 2025-04-04T15:19:36-04:00
New Revision: c22586a9d18dd0f066e5660102f7de15fd239e2c
URL: https://github.com/llvm/llvm-project/commit/c22586a9d18dd0f066e5660102f7de15fd239e2c
DIFF: https://github.com/llvm/llvm-project/commit/c22586a9d18dd0f066e5660102f7de15fd239e2c.diff
LOG: [PowerPC] Update altivec.h to use __inline__ for c89 compatibility (#134430)
Added:
Modified:
clang/lib/Headers/altivec.h
clang/test/Headers/altivec-header.c
Removed:
################################################################################
diff --git a/clang/lib/Headers/altivec.h b/clang/lib/Headers/altivec.h
index 8da65055012f1..71d8d3c0c0771 100644
--- a/clang/lib/Headers/altivec.h
+++ b/clang/lib/Headers/altivec.h
@@ -17525,70 +17525,73 @@ 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,42 +17724,42 @@ 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(ptr
diff _t __offset,
- const signed char *__ptr) {
+static __inline__ __ATTRS_o_ai vector signed char
+vec_xl(ptr
diff _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(ptr
diff _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(ptr
diff _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(ptr
diff _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(ptr
diff _t __offset,
- const signed int *__ptr) {
+static __inline__ __ATTRS_o_ai vector signed int
+vec_xl(ptr
diff _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(ptr
diff _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(ptr
diff _t __offset,
- const float *__ptr) {
+static __inline__ __ATTRS_o_ai vector float vec_xl(ptr
diff _t __offset,
+ const float *__ptr) {
signed char *__addr = (signed char *)__ptr + __offset;
return *(unaligned_vec_float *)__addr;
}
@@ -17766,20 +17769,20 @@ 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(ptr
diff _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(ptr
diff _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(ptr
diff _t __offset,
- const double *__ptr) {
+static __inline__ __ATTRS_o_ai vector double vec_xl(ptr
diff _t __offset,
+ const double *__ptr) {
signed char *__addr = (signed char *)__ptr + __offset;
return *(unaligned_vec_double *)__addr;
}
@@ -17790,13 +17793,13 @@ static inline __ATTRS_o_ai vector double vec_xl(ptr
diff _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(ptr
diff _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(ptr
diff _t __offset, const unsigned __int128 *__ptr) {
signed char *__addr = (signed char *)__ptr + __offset;
return *(unaligned_vec_ui128 *)__addr;
@@ -17991,64 +17994,64 @@ 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, ptr
diff _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, ptr
diff _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, ptr
diff _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,
- ptr
diff _t __offset,
- unsigned short *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned short __vec,
+ ptr
diff _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,
- ptr
diff _t __offset, signed int *__ptr) {
+static __inline__ __ATTRS_o_ai void
+vec_xst(vector signed int __vec, ptr
diff _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, ptr
diff _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, ptr
diff _t __offset,
- float *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector float __vec,
+ ptr
diff _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,
- ptr
diff _t __offset,
- signed long long *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector signed long long __vec,
+ ptr
diff _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,
- ptr
diff _t __offset,
- unsigned long long *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned long long __vec,
+ ptr
diff _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, ptr
diff _t __offset,
- double *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector double __vec,
+ ptr
diff _t __offset, double *__ptr) {
signed char *__addr = (signed char *)__ptr + __offset;
*(unaligned_vec_double *)__addr = __vec;
}
@@ -18056,16 +18059,16 @@ static inline __ATTRS_o_ai void vec_xst(vector double __vec, ptr
diff _t __offset,
#if defined(__POWER8_VECTOR__) && defined(__powerpc64__) && \
defined(__SIZEOF_INT128__)
-static inline __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
- ptr
diff _t __offset,
- signed __int128 *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector signed __int128 __vec,
+ ptr
diff _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,
- ptr
diff _t __offset,
- unsigned __int128 *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst(vector unsigned __int128 __vec,
+ ptr
diff _t __offset,
+ unsigned __int128 *__ptr) {
signed char *__addr = (signed char *)__ptr + __offset;
*(unaligned_vec_ui128 *)__addr = __vec;
}
@@ -18075,51 +18078,51 @@ 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,
- ptr
diff _t __offset,
- signed char *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+ ptr
diff _t __offset,
+ signed char *__ptr) {
*(__ptr + __offset) = (signed char)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
- ptr
diff _t __offset,
- unsigned char *__ptr) {
+static __inline__ __ATTRS_o_ai void
+vec_xst_trunc(vector unsigned __int128 __vec, ptr
diff _t __offset,
+ unsigned char *__ptr) {
*(__ptr + __offset) = (unsigned char)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
- ptr
diff _t __offset,
- signed short *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+ ptr
diff _t __offset,
+ signed short *__ptr) {
*(__ptr + __offset) = (signed short)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
- ptr
diff _t __offset,
- unsigned short *__ptr) {
+static __inline__ __ATTRS_o_ai void
+vec_xst_trunc(vector unsigned __int128 __vec, ptr
diff _t __offset,
+ unsigned short *__ptr) {
*(__ptr + __offset) = (unsigned short)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
- ptr
diff _t __offset,
- signed int *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+ ptr
diff _t __offset,
+ signed int *__ptr) {
*(__ptr + __offset) = (signed int)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector unsigned __int128 __vec,
- ptr
diff _t __offset,
- unsigned int *__ptr) {
+static __inline__ __ATTRS_o_ai void
+vec_xst_trunc(vector unsigned __int128 __vec, ptr
diff _t __offset,
+ unsigned int *__ptr) {
*(__ptr + __offset) = (unsigned int)__vec[0];
}
-static inline __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
- ptr
diff _t __offset,
- signed long long *__ptr) {
+static __inline__ __ATTRS_o_ai void vec_xst_trunc(vector signed __int128 __vec,
+ ptr
diff _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,
- ptr
diff _t __offset,
- unsigned long long *__ptr) {
+static __inline__ __ATTRS_o_ai void
+vec_xst_trunc(vector unsigned __int128 __vec, ptr
diff _t __offset,
+ unsigned long long *__ptr) {
*(__ptr + __offset) = (unsigned long long)__vec[0];
}
#endif
diff --git a/clang/test/Headers/altivec-header.c b/clang/test/Headers/altivec-header.c
index 00e5f444de7cc..67aee4b270ca6 100644
--- a/clang/test/Headers/altivec-header.c
+++ b/clang/test/Headers/altivec-header.c
@@ -1,5 +1,6 @@
// 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 -std=c89 -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 -x c++ -o - %s | FileCheck %s
#include <altivec.h>
More information about the cfe-commits
mailing list