diff utils/genaltivec.c @ 42:ca0f0223a62d

altivec: use vec_splat_* funcs if available
author Paper <paper@tflc.us>
date Tue, 29 Apr 2025 16:36:35 -0400
parents c6e0df09b86f
children b0a3f0248ecc
line wrap: on
line diff
--- a/utils/genaltivec.c	Mon Apr 28 16:31:59 2025 -0400
+++ b/utils/genaltivec.c	Tue Apr 29 16:36:35 2025 -0400
@@ -113,6 +113,8 @@
 #define UPSIGN(x) ((x) ? "" : "U")
 #define LOSIGN(x) ((x) ? "" : "u")
 
+#define LOAVSIGN(x) ((x) ? "s" : "u")
+
 static void print_gcc_op(enum op op, int is_signed, int bits, int size)
 {
 	int i;
@@ -123,7 +125,7 @@
 		puts("#ifdef vec_mul");
 		break;
 	case OP_SPLAT:
-		puts("#ifdef vec_splats");
+		printf("#if defined(vec_splats) || defined(vec_splat_%s%d)\n", (is_signed) ? "s" : "u", bits);
 		break;
 	default:
 		break;
@@ -215,7 +217,13 @@
 	switch (op) {
 	case OP_SPLAT:
 		printf("\tv%sint%dx%d vec;\n", LOSIGN(is_signed), bits, size);
-		printf("\tvec.altivec = vec_splats(x);\n");
+		puts("#ifdef vec_splats");
+		puts("\tvec.altivec = vec_splats(x);");
+		printf("#elif defined(vec_splat_%s%d)\n", LOAVSIGN(is_signed), bits);
+		printf("\tvec.altivec = vec_splat_%s%d(x);\n", LOAVSIGN(is_signed), bits);
+		puts("#else");
+		puts("# error logic error");
+		puts("#endif");
 		printf("\treturn vec;\n");
 		break;
 	case OP_LOAD_ALIGNED: