comparison 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
comparison
equal deleted inserted replaced
41:c6e0df09b86f 42:ca0f0223a62d
111 }; 111 };
112 112
113 #define UPSIGN(x) ((x) ? "" : "U") 113 #define UPSIGN(x) ((x) ? "" : "U")
114 #define LOSIGN(x) ((x) ? "" : "u") 114 #define LOSIGN(x) ((x) ? "" : "u")
115 115
116 #define LOAVSIGN(x) ((x) ? "s" : "u")
117
116 static void print_gcc_op(enum op op, int is_signed, int bits, int size) 118 static void print_gcc_op(enum op op, int is_signed, int bits, int size)
117 { 119 {
118 int i; 120 int i;
119 121
120 /* compatibility with ancient gcc */ 122 /* compatibility with ancient gcc */
121 switch (op) { 123 switch (op) {
122 case OP_MUL: 124 case OP_MUL:
123 puts("#ifdef vec_mul"); 125 puts("#ifdef vec_mul");
124 break; 126 break;
125 case OP_SPLAT: 127 case OP_SPLAT:
126 puts("#ifdef vec_splats"); 128 printf("#if defined(vec_splats) || defined(vec_splat_%s%d)\n", (is_signed) ? "s" : "u", bits);
127 break; 129 break;
128 default: 130 default:
129 break; 131 break;
130 } 132 }
131 133
213 puts(")\n{"); 215 puts(")\n{");
214 216
215 switch (op) { 217 switch (op) {
216 case OP_SPLAT: 218 case OP_SPLAT:
217 printf("\tv%sint%dx%d vec;\n", LOSIGN(is_signed), bits, size); 219 printf("\tv%sint%dx%d vec;\n", LOSIGN(is_signed), bits, size);
218 printf("\tvec.altivec = vec_splats(x);\n"); 220 puts("#ifdef vec_splats");
221 puts("\tvec.altivec = vec_splats(x);");
222 printf("#elif defined(vec_splat_%s%d)\n", LOAVSIGN(is_signed), bits);
223 printf("\tvec.altivec = vec_splat_%s%d(x);\n", LOAVSIGN(is_signed), bits);
224 puts("#else");
225 puts("# error logic error");
226 puts("#endif");
219 printf("\treturn vec;\n"); 227 printf("\treturn vec;\n");
220 break; 228 break;
221 case OP_LOAD_ALIGNED: 229 case OP_LOAD_ALIGNED:
222 printf("\tv%sint%dx%d vec;\n", LOSIGN(is_signed), bits, size); 230 printf("\tv%sint%dx%d vec;\n", LOSIGN(is_signed), bits, size);
223 puts("\tvec.altivec = vec_ld(0, x);"); 231 puts("\tvec.altivec = vec_ld(0, x);");