Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1 | /*===---- altivec.h - Standard header for type generic math ---------------===*\ |
| 2 | * |
| 3 | * Permission is hereby granted, free of charge, to any person obtaining a copy |
| 4 | * of this software and associated documentation files (the "Software"), to deal |
| 5 | * in the Software without restriction, including without limitation the rights |
| 6 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 7 | * copies of the Software, and to permit persons to whom the Software is |
| 8 | * furnished to do so, subject to the following conditions: |
| 9 | * |
| 10 | * The above copyright notice and this permission notice shall be included in |
| 11 | * all copies or substantial portions of the Software. |
| 12 | * |
| 13 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 14 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 15 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 16 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 17 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 18 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN |
| 19 | * THE SOFTWARE. |
| 20 | * |
| 21 | \*===----------------------------------------------------------------------===*/ |
| 22 | |
| 23 | #ifndef __ALTIVEC_H |
| 24 | #define __ALTIVEC_H |
| 25 | |
| 26 | #ifndef __ALTIVEC__ |
| 27 | #error "AltiVec support not enabled" |
| 28 | #endif |
| 29 | |
| 30 | /* constants for mapping CR6 bits to predicate result. */ |
| 31 | |
| 32 | #define __CR6_EQ 0 |
| 33 | #define __CR6_EQ_REV 1 |
| 34 | #define __CR6_LT 2 |
| 35 | #define __CR6_LT_REV 3 |
| 36 | |
| 37 | #define _ATTRS_o_ai __attribute__((__overloadable__, __always_inline__)) |
| 38 | |
| 39 | /* vec_abs */ |
| 40 | |
| 41 | #define __builtin_vec_abs vec_abs |
| 42 | #define __builtin_altivec_abs_v16qi vec_abs |
| 43 | #define __builtin_altivec_abs_v8hi vec_abs |
| 44 | #define __builtin_altivec_abs_v4si vec_abs |
| 45 | |
| 46 | static vector signed char _ATTRS_o_ai |
| 47 | vec_abs(vector signed char a) |
| 48 | { |
| 49 | return __builtin_altivec_vmaxsb(a, -a); |
| 50 | } |
| 51 | |
| 52 | static vector signed short _ATTRS_o_ai |
| 53 | vec_abs(vector signed short a) |
| 54 | { |
| 55 | return __builtin_altivec_vmaxsh(a, -a); |
| 56 | } |
| 57 | |
| 58 | static vector signed int _ATTRS_o_ai |
| 59 | vec_abs(vector signed int a) |
| 60 | { |
| 61 | return __builtin_altivec_vmaxsw(a, -a); |
| 62 | } |
| 63 | |
| 64 | static vector float _ATTRS_o_ai |
| 65 | vec_abs(vector float a) |
| 66 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 67 | vector unsigned int res = (vector unsigned int)a & |
| 68 | (vector unsigned int)(0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF, 0x7FFFFFFF); |
| 69 | return (vector float)res; |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 70 | } |
| 71 | |
| 72 | /* vec_abss */ |
| 73 | |
| 74 | #define __builtin_vec_abss vec_abss |
| 75 | #define __builtin_altivec_abss_v16qi vec_abss |
| 76 | #define __builtin_altivec_abss_v8hi vec_abss |
| 77 | #define __builtin_altivec_abss_v4si vec_abss |
| 78 | |
| 79 | static vector signed char _ATTRS_o_ai |
| 80 | vec_abss(vector signed char a) |
| 81 | { |
| 82 | return __builtin_altivec_vmaxsb(a, __builtin_altivec_vsubsbs( |
| 83 | (vector signed char)(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0), a)); |
| 84 | } |
| 85 | |
| 86 | static vector signed short _ATTRS_o_ai |
| 87 | vec_abss(vector signed short a) |
| 88 | { |
| 89 | return __builtin_altivec_vmaxsh(a, __builtin_altivec_vsubshs( |
| 90 | (vector signed short)(0, 0, 0, 0, 0, 0, 0, 0), a)); |
| 91 | } |
| 92 | |
| 93 | static vector signed int _ATTRS_o_ai |
| 94 | vec_abss(vector signed int a) |
| 95 | { |
| 96 | return __builtin_altivec_vmaxsw(a, __builtin_altivec_vsubsws( |
| 97 | (vector signed int)(0, 0, 0, 0), a)); |
| 98 | } |
| 99 | |
| 100 | /* vec_add */ |
| 101 | |
| 102 | #define __builtin_altivec_vaddubm vec_add |
| 103 | #define __builtin_altivec_vadduhm vec_add |
| 104 | #define __builtin_altivec_vadduwm vec_add |
| 105 | #define __builtin_altivec_vaddfp vec_add |
| 106 | #define __builtin_vec_vaddubm vec_add |
| 107 | #define __builtin_vec_vadduhm vec_add |
| 108 | #define __builtin_vec_vadduwm vec_add |
| 109 | #define __builtin_vec_vaddfp vec_add |
| 110 | #define vec_vaddubm vec_add |
| 111 | #define vec_vadduhm vec_add |
| 112 | #define vec_vadduwm vec_add |
| 113 | #define vec_vaddfp vec_add |
| 114 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 115 | static vector signed char _ATTRS_o_ai |
| 116 | vec_add(vector signed char a, vector signed char b) |
| 117 | { |
| 118 | return a + b; |
| 119 | } |
| 120 | |
| 121 | static vector unsigned char _ATTRS_o_ai |
| 122 | vec_add(vector unsigned char a, vector unsigned char b) |
| 123 | { |
| 124 | return a + b; |
| 125 | } |
| 126 | |
| 127 | static vector short _ATTRS_o_ai |
| 128 | vec_add(vector short a, vector short b) |
| 129 | { |
| 130 | return a + b; |
| 131 | } |
| 132 | |
| 133 | static vector unsigned short _ATTRS_o_ai |
| 134 | vec_add(vector unsigned short a, vector unsigned short b) |
| 135 | { |
| 136 | return a + b; |
| 137 | } |
| 138 | |
| 139 | static vector int _ATTRS_o_ai |
| 140 | vec_add(vector int a, vector int b) |
| 141 | { |
| 142 | return a + b; |
| 143 | } |
| 144 | |
| 145 | static vector unsigned int _ATTRS_o_ai |
| 146 | vec_add(vector unsigned int a, vector unsigned int b) |
| 147 | { |
| 148 | return a + b; |
| 149 | } |
| 150 | |
| 151 | static vector float _ATTRS_o_ai |
| 152 | vec_add(vector float a, vector float b) |
| 153 | { |
| 154 | return a + b; |
| 155 | } |
| 156 | |
| 157 | /* vec_addc */ |
| 158 | |
| 159 | #define __builtin_vec_addc __builtin_altivec_vaddcuw |
| 160 | #define vec_vaddcuw __builtin_altivec_vaddcuw |
| 161 | #define vec_addc __builtin_altivec_vaddcuw |
| 162 | |
| 163 | /* vec_adds */ |
| 164 | |
| 165 | #define __builtin_vec_vaddsbs __builtin_altivec_vaddsbs |
| 166 | #define __builtin_vec_vaddubs __builtin_altivec_vaddubs |
| 167 | #define __builtin_vec_vaddshs __builtin_altivec_vaddshs |
| 168 | #define __builtin_vec_vadduhs __builtin_altivec_vadduhs |
| 169 | #define __builtin_vec_vaddsws __builtin_altivec_vaddsws |
| 170 | #define __builtin_vec_vadduws __builtin_altivec_vadduws |
| 171 | #define vec_vaddsbs __builtin_altivec_vaddsbs |
| 172 | #define vec_vaddubs __builtin_altivec_vaddubs |
| 173 | #define vec_vaddshs __builtin_altivec_vaddshs |
| 174 | #define vec_vadduhs __builtin_altivec_vadduhs |
| 175 | #define vec_vaddsws __builtin_altivec_vaddsws |
| 176 | #define vec_vadduws __builtin_altivec_vadduws |
| 177 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 178 | static vector signed char _ATTRS_o_ai |
| 179 | vec_adds(vector signed char a, vector signed char b) |
| 180 | { |
| 181 | return __builtin_altivec_vaddsbs(a, b); |
| 182 | } |
| 183 | |
| 184 | static vector unsigned char _ATTRS_o_ai |
| 185 | vec_adds(vector unsigned char a, vector unsigned char b) |
| 186 | { |
| 187 | return __builtin_altivec_vaddubs(a, b); |
| 188 | } |
| 189 | |
| 190 | static vector short _ATTRS_o_ai |
| 191 | vec_adds(vector short a, vector short b) |
| 192 | { |
| 193 | return __builtin_altivec_vaddshs(a, b); |
| 194 | } |
| 195 | |
| 196 | static vector unsigned short _ATTRS_o_ai |
| 197 | vec_adds(vector unsigned short a, vector unsigned short b) |
| 198 | { |
| 199 | return __builtin_altivec_vadduhs(a, b); |
| 200 | } |
| 201 | |
| 202 | static vector int _ATTRS_o_ai |
| 203 | vec_adds(vector int a, vector int b) |
| 204 | { |
| 205 | return __builtin_altivec_vaddsws(a, b); |
| 206 | } |
| 207 | |
| 208 | static vector unsigned int _ATTRS_o_ai |
| 209 | vec_adds(vector unsigned int a, vector unsigned int b) |
| 210 | { |
| 211 | return __builtin_altivec_vadduws(a, b); |
| 212 | } |
| 213 | |
| 214 | /* vec_sub */ |
| 215 | |
| 216 | #define __builtin_altivec_vsububm vec_sub |
| 217 | #define __builtin_altivec_vsubuhm vec_sub |
| 218 | #define __builtin_altivec_vsubuwm vec_sub |
| 219 | #define __builtin_altivec_vsubfp vec_sub |
| 220 | #define __builtin_vec_vsububm vec_sub |
| 221 | #define __builtin_vec_vsubuhm vec_sub |
| 222 | #define __builtin_vec_vsubuwm vec_sub |
| 223 | #define __builtin_vec_vsubfp vec_sub |
| 224 | #define vec_vsububm vec_sub |
| 225 | #define vec_vsubuhm vec_sub |
| 226 | #define vec_vsubuwm vec_sub |
| 227 | #define vec_vsubfp vec_sub |
| 228 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 229 | static vector signed char _ATTRS_o_ai |
| 230 | vec_sub(vector signed char a, vector signed char b) |
| 231 | { |
| 232 | return a - b; |
| 233 | } |
| 234 | |
| 235 | static vector unsigned char _ATTRS_o_ai |
| 236 | vec_sub(vector unsigned char a, vector unsigned char b) |
| 237 | { |
| 238 | return a - b; |
| 239 | } |
| 240 | |
| 241 | static vector short _ATTRS_o_ai |
| 242 | vec_sub(vector short a, vector short b) |
| 243 | { |
| 244 | return a - b; |
| 245 | } |
| 246 | |
| 247 | static vector unsigned short _ATTRS_o_ai |
| 248 | vec_sub(vector unsigned short a, vector unsigned short b) |
| 249 | { |
| 250 | return a - b; |
| 251 | } |
| 252 | |
| 253 | static vector int _ATTRS_o_ai |
| 254 | vec_sub(vector int a, vector int b) |
| 255 | { |
| 256 | return a - b; |
| 257 | } |
| 258 | |
| 259 | static vector unsigned int _ATTRS_o_ai |
| 260 | vec_sub(vector unsigned int a, vector unsigned int b) |
| 261 | { |
| 262 | return a - b; |
| 263 | } |
| 264 | |
| 265 | static vector float _ATTRS_o_ai |
| 266 | vec_sub(vector float a, vector float b) |
| 267 | { |
| 268 | return a - b; |
| 269 | } |
| 270 | |
| 271 | /* vec_subs */ |
| 272 | |
| 273 | #define __builtin_vec_vsubsbs __builtin_altivec_vsubsbs |
| 274 | #define __builtin_vec_vsububs __builtin_altivec_vsububs |
| 275 | #define __builtin_vec_vsubshs __builtin_altivec_vsubshs |
| 276 | #define __builtin_vec_vsubuhs __builtin_altivec_vsubuhs |
| 277 | #define __builtin_vec_vsubsws __builtin_altivec_vsubsws |
| 278 | #define __builtin_vec_vsubuws __builtin_altivec_vsubuws |
| 279 | #define vec_vsubsbs __builtin_altivec_vsubsbs |
| 280 | #define vec_vsububs __builtin_altivec_vsububs |
| 281 | #define vec_vsubshs __builtin_altivec_vsubshs |
| 282 | #define vec_vsubuhs __builtin_altivec_vsubuhs |
| 283 | #define vec_vsubsws __builtin_altivec_vsubsws |
| 284 | #define vec_vsubuws __builtin_altivec_vsubuws |
| 285 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 286 | static vector signed char _ATTRS_o_ai |
| 287 | vec_subs(vector signed char a, vector signed char b) |
| 288 | { |
| 289 | return __builtin_altivec_vsubsbs(a, b); |
| 290 | } |
| 291 | |
| 292 | static vector unsigned char _ATTRS_o_ai |
| 293 | vec_subs(vector unsigned char a, vector unsigned char b) |
| 294 | { |
| 295 | return __builtin_altivec_vsububs(a, b); |
| 296 | } |
| 297 | |
| 298 | static vector short _ATTRS_o_ai |
| 299 | vec_subs(vector short a, vector short b) |
| 300 | { |
| 301 | return __builtin_altivec_vsubshs(a, b); |
| 302 | } |
| 303 | |
| 304 | static vector unsigned short _ATTRS_o_ai |
| 305 | vec_subs(vector unsigned short a, vector unsigned short b) |
| 306 | { |
| 307 | return __builtin_altivec_vsubuhs(a, b); |
| 308 | } |
| 309 | |
| 310 | static vector int _ATTRS_o_ai |
| 311 | vec_subs(vector int a, vector int b) |
| 312 | { |
| 313 | return __builtin_altivec_vsubsws(a, b); |
| 314 | } |
| 315 | |
| 316 | static vector unsigned int _ATTRS_o_ai |
| 317 | vec_subs(vector unsigned int a, vector unsigned int b) |
| 318 | { |
| 319 | return __builtin_altivec_vsubuws(a, b); |
| 320 | } |
| 321 | |
| 322 | /* vec_avg */ |
| 323 | |
| 324 | #define __builtin_vec_vavgsb __builtin_altivec_vavgsb |
| 325 | #define __builtin_vec_vavgub __builtin_altivec_vavgub |
| 326 | #define __builtin_vec_vavgsh __builtin_altivec_vavgsh |
| 327 | #define __builtin_vec_vavguh __builtin_altivec_vavguh |
| 328 | #define __builtin_vec_vavgsw __builtin_altivec_vavgsw |
| 329 | #define __builtin_vec_vavguw __builtin_altivec_vavguw |
| 330 | #define vec_vavgsb __builtin_altivec_vavgsb |
| 331 | #define vec_vavgub __builtin_altivec_vavgub |
| 332 | #define vec_vavgsh __builtin_altivec_vavgsh |
| 333 | #define vec_vavguh __builtin_altivec_vavguh |
| 334 | #define vec_vavgsw __builtin_altivec_vavgsw |
| 335 | #define vec_vavguw __builtin_altivec_vavguw |
| 336 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 337 | static vector signed char _ATTRS_o_ai |
| 338 | vec_avg(vector signed char a, vector signed char b) |
| 339 | { |
| 340 | return __builtin_altivec_vavgsb(a, b); |
| 341 | } |
| 342 | |
| 343 | static vector unsigned char _ATTRS_o_ai |
| 344 | vec_avg(vector unsigned char a, vector unsigned char b) |
| 345 | { |
| 346 | return __builtin_altivec_vavgub(a, b); |
| 347 | } |
| 348 | |
| 349 | static vector short _ATTRS_o_ai |
| 350 | vec_avg(vector short a, vector short b) |
| 351 | { |
| 352 | return __builtin_altivec_vavgsh(a, b); |
| 353 | } |
| 354 | |
| 355 | static vector unsigned short _ATTRS_o_ai |
| 356 | vec_avg(vector unsigned short a, vector unsigned short b) |
| 357 | { |
| 358 | return __builtin_altivec_vavguh(a, b); |
| 359 | } |
| 360 | |
| 361 | static vector int _ATTRS_o_ai |
| 362 | vec_avg(vector int a, vector int b) |
| 363 | { |
| 364 | return __builtin_altivec_vavgsw(a, b); |
| 365 | } |
| 366 | |
| 367 | static vector unsigned int _ATTRS_o_ai |
| 368 | vec_avg(vector unsigned int a, vector unsigned int b) |
| 369 | { |
| 370 | return __builtin_altivec_vavguw(a, b); |
| 371 | } |
| 372 | |
| 373 | /* vec_st */ |
| 374 | |
| 375 | #define __builtin_vec_st vec_st |
| 376 | #define vec_stvx vec_st |
| 377 | |
| 378 | static void _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 379 | vec_st(vector signed char a, int b, vector signed char *c) |
| 380 | { |
| 381 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 382 | } |
| 383 | |
| 384 | static void _ATTRS_o_ai |
| 385 | vec_st(vector unsigned char a, int b, vector unsigned char *c) |
| 386 | { |
| 387 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 388 | } |
| 389 | |
| 390 | static void _ATTRS_o_ai |
| 391 | vec_st(vector short a, int b, vector short *c) |
| 392 | { |
| 393 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 394 | } |
| 395 | |
| 396 | static void _ATTRS_o_ai |
| 397 | vec_st(vector unsigned short a, int b, vector unsigned short *c) |
| 398 | { |
| 399 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 400 | } |
| 401 | |
| 402 | static void _ATTRS_o_ai |
| 403 | vec_st(vector int a, int b, vector int *c) |
| 404 | { |
| 405 | __builtin_altivec_stvx(a, b, (void *)c); |
| 406 | } |
| 407 | |
| 408 | static void _ATTRS_o_ai |
| 409 | vec_st(vector unsigned int a, int b, vector unsigned int *c) |
| 410 | { |
| 411 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 412 | } |
| 413 | |
| 414 | static void _ATTRS_o_ai |
| 415 | vec_st(vector float a, int b, vector float *c) |
| 416 | { |
| 417 | __builtin_altivec_stvx((vector int)a, b, (void *)c); |
| 418 | } |
| 419 | |
| 420 | /* vec_stl */ |
| 421 | |
| 422 | #define __builtin_vec_stl vec_stl |
| 423 | #define vec_stvxl vec_stl |
| 424 | |
| 425 | static void _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 426 | vec_stl(vector signed char a, int b, vector signed char *c) |
| 427 | { |
| 428 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 429 | } |
| 430 | |
| 431 | static void _ATTRS_o_ai |
| 432 | vec_stl(vector unsigned char a, int b, vector unsigned char *c) |
| 433 | { |
| 434 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 435 | } |
| 436 | |
| 437 | static void _ATTRS_o_ai |
| 438 | vec_stl(vector short a, int b, vector short *c) |
| 439 | { |
| 440 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 441 | } |
| 442 | |
| 443 | static void _ATTRS_o_ai |
| 444 | vec_stl(vector unsigned short a, int b, vector unsigned short *c) |
| 445 | { |
| 446 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 447 | } |
| 448 | |
| 449 | static void _ATTRS_o_ai |
| 450 | vec_stl(vector int a, int b, vector int *c) |
| 451 | { |
| 452 | __builtin_altivec_stvxl(a, b, (void *)c); |
| 453 | } |
| 454 | |
| 455 | static void _ATTRS_o_ai |
| 456 | vec_stl(vector unsigned int a, int b, vector unsigned int *c) |
| 457 | { |
| 458 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 459 | } |
| 460 | |
| 461 | static void _ATTRS_o_ai |
| 462 | vec_stl(vector float a, int b, vector float *c) |
| 463 | { |
| 464 | __builtin_altivec_stvxl((vector int)a, b, (void *)c); |
| 465 | } |
| 466 | |
| 467 | /* vec_ste */ |
| 468 | |
| 469 | #define __builtin_vec_stvebx __builtin_altivec_stvebx |
| 470 | #define __builtin_vec_stvehx __builtin_altivec_stvehx |
| 471 | #define __builtin_vec_stvewx __builtin_altivec_stvewx |
| 472 | #define vec_stvebx __builtin_altivec_stvebx |
| 473 | #define vec_stvehx __builtin_altivec_stvehx |
| 474 | #define vec_stvewx __builtin_altivec_stvewx |
| 475 | |
| 476 | static void _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 477 | vec_ste(vector signed char a, int b, vector signed char *c) |
| 478 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 479 | __builtin_altivec_stvebx((vector char)a, b, (void *)c); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 480 | } |
| 481 | |
| 482 | static void _ATTRS_o_ai |
| 483 | vec_ste(vector unsigned char a, int b, vector unsigned char *c) |
| 484 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 485 | __builtin_altivec_stvebx((vector char)a, b, (void *)c); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 486 | } |
| 487 | |
| 488 | static void _ATTRS_o_ai |
| 489 | vec_ste(vector short a, int b, vector short *c) |
| 490 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 491 | __builtin_altivec_stvehx(a, b, (void *)c); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 492 | } |
| 493 | |
| 494 | static void _ATTRS_o_ai |
| 495 | vec_ste(vector unsigned short a, int b, vector unsigned short *c) |
| 496 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 497 | __builtin_altivec_stvehx((vector short)a, b, (void *)c); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | static void _ATTRS_o_ai |
| 501 | vec_ste(vector int a, int b, vector int *c) |
| 502 | { |
| 503 | __builtin_altivec_stvewx(a, b, (void *)c); |
| 504 | } |
| 505 | |
| 506 | static void _ATTRS_o_ai |
| 507 | vec_ste(vector unsigned int a, int b, vector unsigned int *c) |
| 508 | { |
| 509 | __builtin_altivec_stvewx((vector int)a, b, (void *)c); |
| 510 | } |
| 511 | |
| 512 | static void _ATTRS_o_ai |
| 513 | vec_ste(vector float a, int b, vector float *c) |
| 514 | { |
| 515 | __builtin_altivec_stvewx((vector int)a, b, (void *)c); |
| 516 | } |
| 517 | |
| 518 | /* vec_cmpb */ |
| 519 | |
| 520 | #define vec_cmpb __builtin_altivec_vcmpbfp |
| 521 | #define vec_vcmpbfp __builtin_altivec_vcmpbfp |
| 522 | #define __builtin_vec_cmpb __builtin_altivec_vcmpbfp |
| 523 | |
| 524 | /* vec_cmpeq */ |
| 525 | |
| 526 | #define __builtin_vec_cmpeq vec_cmpeq |
| 527 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 528 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 529 | vec_cmpeq(vector signed char a, vector signed char b) |
| 530 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 531 | return __builtin_altivec_vcmpequb((vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 532 | } |
| 533 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 534 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 535 | vec_cmpeq(vector unsigned char a, vector unsigned char b) |
| 536 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 537 | return __builtin_altivec_vcmpequb((vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 538 | } |
| 539 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 540 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 541 | vec_cmpeq(vector short a, vector short b) |
| 542 | { |
| 543 | return __builtin_altivec_vcmpequh(a, b); |
| 544 | } |
| 545 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 546 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 547 | vec_cmpeq(vector unsigned short a, vector unsigned short b) |
| 548 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 549 | return __builtin_altivec_vcmpequh((vector short)a, (vector short)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 550 | } |
| 551 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 552 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 553 | vec_cmpeq(vector int a, vector int b) |
| 554 | { |
| 555 | return __builtin_altivec_vcmpequw(a, b); |
| 556 | } |
| 557 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 558 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 559 | vec_cmpeq(vector unsigned int a, vector unsigned int b) |
| 560 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 561 | return __builtin_altivec_vcmpequw((vector int)a, (vector int)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 562 | } |
| 563 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 564 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 565 | vec_cmpeq(vector float a, vector float b) |
| 566 | { |
| 567 | return __builtin_altivec_vcmpeqfp(a, b); |
| 568 | } |
| 569 | |
| 570 | /* vec_cmpge */ |
| 571 | |
| 572 | #define vec_cmpge __builtin_altivec_vcmpgefp |
| 573 | #define vec_vcmpgefp __builtin_altivec_vcmpgefp |
| 574 | #define __builtin_vec_cmpge __builtin_altivec_vcmpgefp |
| 575 | |
| 576 | /* vec_cmpgt */ |
| 577 | |
| 578 | #define vec_vcmpgtsb __builtin_altivec_vcmpgtsb |
| 579 | #define vec_vcmpgtub __builtin_altivec_vcmpgtub |
| 580 | #define vec_vcmpgtsh __builtin_altivec_vcmpgtsh |
| 581 | #define vec_vcmpgtuh __builtin_altivec_vcmpgtuh |
| 582 | #define vec_vcmpgtsw __builtin_altivec_vcmpgtsw |
| 583 | #define vec_vcmpgtuw __builtin_altivec_vcmpgtuw |
| 584 | #define vec_vcmpgtfp __builtin_altivec_vcmpgtfp |
| 585 | #define __builtin_vec_vcmpgtsb __builtin_altivec_vcmpgtsb |
| 586 | #define __builtin_vec_vcmpgtub __builtin_altivec_vcmpgtub |
| 587 | #define __builtin_vec_vcmpgtsh __builtin_altivec_vcmpgtsh |
| 588 | #define __builtin_vec_vcmpgtuh __builtin_altivec_vcmpgtuh |
| 589 | #define __builtin_vec_vcmpgtsw __builtin_altivec_vcmpgtsw |
| 590 | #define __builtin_vec_vcmpgtuw __builtin_altivec_vcmpgtuw |
| 591 | #define __builtin_vec_vcmpgtfp __builtin_altivec_vcmpgtfp |
| 592 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 593 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 594 | vec_cmpgt(vector signed char a, vector signed char b) |
| 595 | { |
| 596 | return __builtin_altivec_vcmpgtsb(a, b); |
| 597 | } |
| 598 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 599 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 600 | vec_cmpgt(vector unsigned char a, vector unsigned char b) |
| 601 | { |
| 602 | return __builtin_altivec_vcmpgtub(a, b); |
| 603 | } |
| 604 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 605 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 606 | vec_cmpgt(vector short a, vector short b) |
| 607 | { |
| 608 | return __builtin_altivec_vcmpgtsh(a, b); |
| 609 | } |
| 610 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 611 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 612 | vec_cmpgt(vector unsigned short a, vector unsigned short b) |
| 613 | { |
| 614 | return __builtin_altivec_vcmpgtuh(a, b); |
| 615 | } |
| 616 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 617 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 618 | vec_cmpgt(vector int a, vector int b) |
| 619 | { |
| 620 | return __builtin_altivec_vcmpgtsw(a, b); |
| 621 | } |
| 622 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 623 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 624 | vec_cmpgt(vector unsigned int a, vector unsigned int b) |
| 625 | { |
| 626 | return __builtin_altivec_vcmpgtuw(a, b); |
| 627 | } |
| 628 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 629 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 630 | vec_cmpgt(vector float a, vector float b) |
| 631 | { |
| 632 | return __builtin_altivec_vcmpgtfp(a, b); |
| 633 | } |
| 634 | |
| 635 | /* vec_cmple */ |
| 636 | |
| 637 | #define __builtin_vec_cmple vec_cmple |
| 638 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 639 | static vector /*bool*/ int __attribute__((__always_inline__)) |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 640 | vec_cmple(vector float a, vector float b) |
| 641 | { |
| 642 | return __builtin_altivec_vcmpgefp(b, a); |
| 643 | } |
| 644 | |
| 645 | /* vec_cmplt */ |
| 646 | |
| 647 | #define __builtin_vec_cmplt vec_cmplt |
| 648 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 649 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 650 | vec_cmplt(vector signed char a, vector signed char b) |
| 651 | { |
| 652 | return __builtin_altivec_vcmpgtsb(b, a); |
| 653 | } |
| 654 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 655 | static vector /*bool*/ char _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 656 | vec_cmplt(vector unsigned char a, vector unsigned char b) |
| 657 | { |
| 658 | return __builtin_altivec_vcmpgtub(b, a); |
| 659 | } |
| 660 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 661 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 662 | vec_cmplt(vector short a, vector short b) |
| 663 | { |
| 664 | return __builtin_altivec_vcmpgtsh(b, a); |
| 665 | } |
| 666 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 667 | static vector /*bool*/ short _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 668 | vec_cmplt(vector unsigned short a, vector unsigned short b) |
| 669 | { |
| 670 | return __builtin_altivec_vcmpgtuh(b, a); |
| 671 | } |
| 672 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 673 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 674 | vec_cmplt(vector int a, vector int b) |
| 675 | { |
| 676 | return __builtin_altivec_vcmpgtsw(b, a); |
| 677 | } |
| 678 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 679 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 680 | vec_cmplt(vector unsigned int a, vector unsigned int b) |
| 681 | { |
| 682 | return __builtin_altivec_vcmpgtuw(b, a); |
| 683 | } |
| 684 | |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 685 | static vector /*bool*/ int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 686 | vec_cmplt(vector float a, vector float b) |
| 687 | { |
| 688 | return __builtin_altivec_vcmpgtfp(b, a); |
| 689 | } |
| 690 | |
| 691 | /* vec_max */ |
| 692 | |
| 693 | #define __builtin_vec_vmaxsb __builtin_altivec_vmaxsb |
| 694 | #define __builtin_vec_vmaxub __builtin_altivec_vmaxub |
| 695 | #define __builtin_vec_vmaxsh __builtin_altivec_vmaxsh |
| 696 | #define __builtin_vec_vmaxuh __builtin_altivec_vmaxuh |
| 697 | #define __builtin_vec_vmaxsw __builtin_altivec_vmaxsw |
| 698 | #define __builtin_vec_vmaxuw __builtin_altivec_vmaxuw |
| 699 | #define __builtin_vec_vmaxfp __builtin_altivec_vmaxfp |
| 700 | #define vec_vmaxsb __builtin_altivec_vmaxsb |
| 701 | #define vec_vmaxub __builtin_altivec_vmaxub |
| 702 | #define vec_vmaxsh __builtin_altivec_vmaxsh |
| 703 | #define vec_vmaxuh __builtin_altivec_vmaxuh |
| 704 | #define vec_vmaxsw __builtin_altivec_vmaxsw |
| 705 | #define vec_vmaxuw __builtin_altivec_vmaxuw |
| 706 | #define vec_vmaxfp __builtin_altivec_vmaxfp |
| 707 | #define __builtin_vec_max vec_max |
| 708 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 709 | static vector signed char _ATTRS_o_ai |
| 710 | vec_max(vector signed char a, vector signed char b) |
| 711 | { |
| 712 | return __builtin_altivec_vmaxsb(a, b); |
| 713 | } |
| 714 | |
| 715 | static vector unsigned char _ATTRS_o_ai |
| 716 | vec_max(vector unsigned char a, vector unsigned char b) |
| 717 | { |
| 718 | return __builtin_altivec_vmaxub(a, b); |
| 719 | } |
| 720 | |
| 721 | static vector short _ATTRS_o_ai |
| 722 | vec_max(vector short a, vector short b) |
| 723 | { |
| 724 | return __builtin_altivec_vmaxsh(a, b); |
| 725 | } |
| 726 | |
| 727 | static vector unsigned short _ATTRS_o_ai |
| 728 | vec_max(vector unsigned short a, vector unsigned short b) |
| 729 | { |
| 730 | return __builtin_altivec_vmaxuh(a, b); |
| 731 | } |
| 732 | |
| 733 | static vector int _ATTRS_o_ai |
| 734 | vec_max(vector int a, vector int b) |
| 735 | { |
| 736 | return __builtin_altivec_vmaxsw(a, b); |
| 737 | } |
| 738 | |
| 739 | static vector unsigned int _ATTRS_o_ai |
| 740 | vec_max(vector unsigned int a, vector unsigned int b) |
| 741 | { |
| 742 | return __builtin_altivec_vmaxuw(a, b); |
| 743 | } |
| 744 | |
| 745 | static vector float _ATTRS_o_ai |
| 746 | vec_max(vector float a, vector float b) |
| 747 | { |
| 748 | return __builtin_altivec_vmaxfp(a, b); |
| 749 | } |
| 750 | |
| 751 | /* vec_mfvscr */ |
| 752 | |
| 753 | #define __builtin_vec_mfvscr __builtin_altivec_mfvscr |
| 754 | #define vec_mfvscr __builtin_altivec_mfvscr |
| 755 | |
| 756 | /* vec_min */ |
| 757 | |
| 758 | #define __builtin_vec_vminsb __builtin_altivec_vminsb |
| 759 | #define __builtin_vec_vminub __builtin_altivec_vminub |
| 760 | #define __builtin_vec_vminsh __builtin_altivec_vminsh |
| 761 | #define __builtin_vec_vminuh __builtin_altivec_vminuh |
| 762 | #define __builtin_vec_vminsw __builtin_altivec_vminsw |
| 763 | #define __builtin_vec_vminuw __builtin_altivec_vminuw |
| 764 | #define __builtin_vec_vminfp __builtin_altivec_vminfp |
| 765 | #define vec_vminsb __builtin_altivec_vminsb |
| 766 | #define vec_vminub __builtin_altivec_vminub |
| 767 | #define vec_vminsh __builtin_altivec_vminsh |
| 768 | #define vec_vminuh __builtin_altivec_vminuh |
| 769 | #define vec_vminsw __builtin_altivec_vminsw |
| 770 | #define vec_vminuw __builtin_altivec_vminuw |
| 771 | #define vec_vminfp __builtin_altivec_vminfp |
| 772 | #define __builtin_vec_min vec_min |
| 773 | |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 774 | static vector signed char _ATTRS_o_ai |
| 775 | vec_min(vector signed char a, vector signed char b) |
| 776 | { |
| 777 | return __builtin_altivec_vminsb(a, b); |
| 778 | } |
| 779 | |
| 780 | static vector unsigned char _ATTRS_o_ai |
| 781 | vec_min(vector unsigned char a, vector unsigned char b) |
| 782 | { |
| 783 | return __builtin_altivec_vminub(a, b); |
| 784 | } |
| 785 | |
| 786 | static vector short _ATTRS_o_ai |
| 787 | vec_min(vector short a, vector short b) |
| 788 | { |
| 789 | return __builtin_altivec_vminsh(a, b); |
| 790 | } |
| 791 | |
| 792 | static vector unsigned short _ATTRS_o_ai |
| 793 | vec_min(vector unsigned short a, vector unsigned short b) |
| 794 | { |
| 795 | return __builtin_altivec_vminuh(a, b); |
| 796 | } |
| 797 | |
| 798 | static vector int _ATTRS_o_ai |
| 799 | vec_min(vector int a, vector int b) |
| 800 | { |
| 801 | return __builtin_altivec_vminsw(a, b); |
| 802 | } |
| 803 | |
| 804 | static vector unsigned int _ATTRS_o_ai |
| 805 | vec_min(vector unsigned int a, vector unsigned int b) |
| 806 | { |
| 807 | return __builtin_altivec_vminuw(a, b); |
| 808 | } |
| 809 | |
| 810 | static vector float _ATTRS_o_ai |
| 811 | vec_min(vector float a, vector float b) |
| 812 | { |
| 813 | return __builtin_altivec_vminfp(a, b); |
| 814 | } |
| 815 | |
| 816 | /* vec_mtvscr */ |
| 817 | |
| 818 | #define __builtin_vec_mtvscr __builtin_altivec_mtvscr |
| 819 | #define vec_mtvscr __builtin_altivec_mtvscr |
| 820 | |
| 821 | /* ------------------------------ predicates ------------------------------------ */ |
| 822 | |
| 823 | static int __attribute__((__always_inline__)) |
| 824 | __builtin_vec_vcmpeq_p(char CR6_param, vector float a, vector float b) |
| 825 | { |
| 826 | return __builtin_altivec_vcmpeqfp_p(CR6_param, a, b); |
| 827 | } |
| 828 | |
| 829 | static int __attribute__((__always_inline__)) |
| 830 | __builtin_vec_vcmpge_p(char CR6_param, vector float a, vector float b) |
| 831 | { |
| 832 | return __builtin_altivec_vcmpgefp_p(CR6_param, a, b); |
| 833 | } |
| 834 | |
| 835 | static int __attribute__((__always_inline__)) |
| 836 | __builtin_vec_vcmpgt_p(char CR6_param, vector float a, vector float b) |
| 837 | { |
| 838 | return __builtin_altivec_vcmpgtfp_p(CR6_param, a, b); |
| 839 | } |
| 840 | |
| 841 | /* vec_all_eq */ |
| 842 | |
| 843 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 844 | vec_all_eq(vector signed char a, vector signed char b) |
| 845 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 846 | return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 847 | } |
| 848 | |
| 849 | static int _ATTRS_o_ai |
| 850 | vec_all_eq(vector unsigned char a, vector unsigned char b) |
| 851 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 852 | return __builtin_altivec_vcmpequb_p(__CR6_LT, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 853 | } |
| 854 | |
| 855 | static int _ATTRS_o_ai |
| 856 | vec_all_eq(vector short a, vector short b) |
| 857 | { |
| 858 | return __builtin_altivec_vcmpequh_p(__CR6_LT, a, b); |
| 859 | } |
| 860 | |
| 861 | static int _ATTRS_o_ai |
| 862 | vec_all_eq(vector unsigned short a, vector unsigned short b) |
| 863 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 864 | return __builtin_altivec_vcmpequh_p(__CR6_LT, (vector short)a, (vector short)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 865 | } |
| 866 | |
| 867 | static int _ATTRS_o_ai |
| 868 | vec_all_eq(vector int a, vector int b) |
| 869 | { |
| 870 | return __builtin_altivec_vcmpequw_p(__CR6_LT, a, b); |
| 871 | } |
| 872 | |
| 873 | static int _ATTRS_o_ai |
| 874 | vec_all_eq(vector unsigned int a, vector unsigned int b) |
| 875 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 876 | return __builtin_altivec_vcmpequw_p(__CR6_LT, (vector int)a, (vector int)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 877 | } |
| 878 | |
| 879 | static int _ATTRS_o_ai |
| 880 | vec_all_eq(vector float a, vector float b) |
| 881 | { |
| 882 | return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, b); |
| 883 | } |
| 884 | |
| 885 | /* vec_all_ge */ |
| 886 | |
| 887 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 888 | vec_all_ge(vector signed char a, vector signed char b) |
| 889 | { |
| 890 | return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); |
| 891 | } |
| 892 | |
| 893 | static int _ATTRS_o_ai |
| 894 | vec_all_ge(vector unsigned char a, vector unsigned char b) |
| 895 | { |
| 896 | return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a); |
| 897 | } |
| 898 | |
| 899 | static int _ATTRS_o_ai |
| 900 | vec_all_ge(vector short a, vector short b) |
| 901 | { |
| 902 | return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a); |
| 903 | } |
| 904 | |
| 905 | static int _ATTRS_o_ai |
| 906 | vec_all_ge(vector unsigned short a, vector unsigned short b) |
| 907 | { |
| 908 | return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a); |
| 909 | } |
| 910 | |
| 911 | static int _ATTRS_o_ai |
| 912 | vec_all_ge(vector int a, vector int b) |
| 913 | { |
| 914 | return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a); |
| 915 | } |
| 916 | |
| 917 | static int _ATTRS_o_ai |
| 918 | vec_all_ge(vector unsigned int a, vector unsigned int b) |
| 919 | { |
| 920 | return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a); |
| 921 | } |
| 922 | |
| 923 | static int _ATTRS_o_ai |
| 924 | vec_all_ge(vector float a, vector float b) |
| 925 | { |
| 926 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a); |
| 927 | } |
| 928 | |
| 929 | /* vec_all_gt */ |
| 930 | |
| 931 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 932 | vec_all_gt(vector signed char a, vector signed char b) |
| 933 | { |
| 934 | return __builtin_altivec_vcmpgtsb_p(__CR6_LT, a, b); |
| 935 | } |
| 936 | |
| 937 | static int _ATTRS_o_ai |
| 938 | vec_all_gt(vector unsigned char a, vector unsigned char b) |
| 939 | { |
| 940 | return __builtin_altivec_vcmpgtub_p(__CR6_LT, a, b); |
| 941 | } |
| 942 | |
| 943 | static int _ATTRS_o_ai |
| 944 | vec_all_gt(vector short a, vector short b) |
| 945 | { |
| 946 | return __builtin_altivec_vcmpgtsh_p(__CR6_LT, a, b); |
| 947 | } |
| 948 | |
| 949 | static int _ATTRS_o_ai |
| 950 | vec_all_gt(vector unsigned short a, vector unsigned short b) |
| 951 | { |
| 952 | return __builtin_altivec_vcmpgtuh_p(__CR6_LT, a, b); |
| 953 | } |
| 954 | |
| 955 | static int _ATTRS_o_ai |
| 956 | vec_all_gt(vector int a, vector int b) |
| 957 | { |
| 958 | return __builtin_altivec_vcmpgtsw_p(__CR6_LT, a, b); |
| 959 | } |
| 960 | |
| 961 | static int _ATTRS_o_ai |
| 962 | vec_all_gt(vector unsigned int a, vector unsigned int b) |
| 963 | { |
| 964 | return __builtin_altivec_vcmpgtuw_p(__CR6_LT, a, b); |
| 965 | } |
| 966 | |
| 967 | static int _ATTRS_o_ai |
| 968 | vec_all_gt(vector float a, vector float b) |
| 969 | { |
| 970 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT, a, b); |
| 971 | } |
| 972 | |
| 973 | /* vec_all_in */ |
| 974 | |
| 975 | static int __attribute__((__always_inline__)) |
| 976 | vec_all_in(vector float a, vector float b) |
| 977 | { |
| 978 | return __builtin_altivec_vcmpbfp_p(__CR6_EQ, a, b); |
| 979 | } |
| 980 | |
| 981 | /* vec_all_le */ |
| 982 | |
| 983 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 984 | vec_all_le(vector signed char a, vector signed char b) |
| 985 | { |
| 986 | return __builtin_altivec_vcmpgtsb_p(__CR6_EQ, a, b); |
| 987 | } |
| 988 | |
| 989 | static int _ATTRS_o_ai |
| 990 | vec_all_le(vector unsigned char a, vector unsigned char b) |
| 991 | { |
| 992 | return __builtin_altivec_vcmpgtub_p(__CR6_EQ, a, b); |
| 993 | } |
| 994 | |
| 995 | static int _ATTRS_o_ai |
| 996 | vec_all_le(vector short a, vector short b) |
| 997 | { |
| 998 | return __builtin_altivec_vcmpgtsh_p(__CR6_EQ, a, b); |
| 999 | } |
| 1000 | |
| 1001 | static int _ATTRS_o_ai |
| 1002 | vec_all_le(vector unsigned short a, vector unsigned short b) |
| 1003 | { |
| 1004 | return __builtin_altivec_vcmpgtuh_p(__CR6_EQ, a, b); |
| 1005 | } |
| 1006 | |
| 1007 | static int _ATTRS_o_ai |
| 1008 | vec_all_le(vector int a, vector int b) |
| 1009 | { |
| 1010 | return __builtin_altivec_vcmpgtsw_p(__CR6_EQ, a, b); |
| 1011 | } |
| 1012 | |
| 1013 | static int _ATTRS_o_ai |
| 1014 | vec_all_le(vector unsigned int a, vector unsigned int b) |
| 1015 | { |
| 1016 | return __builtin_altivec_vcmpgtuw_p(__CR6_EQ, a, b); |
| 1017 | } |
| 1018 | |
| 1019 | static int _ATTRS_o_ai |
| 1020 | vec_all_le(vector float a, vector float b) |
| 1021 | { |
| 1022 | return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b); |
| 1023 | } |
| 1024 | |
| 1025 | /* vec_all_lt */ |
| 1026 | |
| 1027 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1028 | vec_all_lt(vector signed char a, vector signed char b) |
| 1029 | { |
| 1030 | return __builtin_altivec_vcmpgtsb_p(__CR6_LT, b, a); |
| 1031 | } |
| 1032 | |
| 1033 | static int _ATTRS_o_ai |
| 1034 | vec_all_lt(vector unsigned char a, vector unsigned char b) |
| 1035 | { |
| 1036 | return __builtin_altivec_vcmpgtub_p(__CR6_LT, b, a); |
| 1037 | } |
| 1038 | |
| 1039 | static int _ATTRS_o_ai |
| 1040 | vec_all_lt(vector short a, vector short b) |
| 1041 | { |
| 1042 | return __builtin_altivec_vcmpgtsh_p(__CR6_LT, b, a); |
| 1043 | } |
| 1044 | |
| 1045 | static int _ATTRS_o_ai |
| 1046 | vec_all_lt(vector unsigned short a, vector unsigned short b) |
| 1047 | { |
| 1048 | return __builtin_altivec_vcmpgtuh_p(__CR6_LT, b, a); |
| 1049 | } |
| 1050 | |
| 1051 | static int _ATTRS_o_ai |
| 1052 | vec_all_lt(vector int a, vector int b) |
| 1053 | { |
| 1054 | return __builtin_altivec_vcmpgtsw_p(__CR6_LT, b, a); |
| 1055 | } |
| 1056 | |
| 1057 | static int _ATTRS_o_ai |
| 1058 | vec_all_lt(vector unsigned int a, vector unsigned int b) |
| 1059 | { |
| 1060 | return __builtin_altivec_vcmpgtuw_p(__CR6_LT, b, a); |
| 1061 | } |
| 1062 | |
| 1063 | static int _ATTRS_o_ai |
| 1064 | vec_all_lt(vector float a, vector float b) |
| 1065 | { |
| 1066 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT, b, a); |
| 1067 | } |
| 1068 | |
| 1069 | /* vec_all_nan */ |
| 1070 | |
| 1071 | static int __attribute__((__always_inline__)) |
| 1072 | vec_all_nan(vector float a) |
| 1073 | { |
| 1074 | return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, a); |
| 1075 | } |
| 1076 | |
| 1077 | /* vec_all_ne */ |
| 1078 | |
| 1079 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1080 | vec_all_ne(vector signed char a, vector signed char b) |
| 1081 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1082 | return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1083 | } |
| 1084 | |
| 1085 | static int _ATTRS_o_ai |
| 1086 | vec_all_ne(vector unsigned char a, vector unsigned char b) |
| 1087 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1088 | return __builtin_altivec_vcmpequb_p(__CR6_EQ, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1089 | } |
| 1090 | |
| 1091 | static int _ATTRS_o_ai |
| 1092 | vec_all_ne(vector short a, vector short b) |
| 1093 | { |
| 1094 | return __builtin_altivec_vcmpequh_p(__CR6_EQ, a, b); |
| 1095 | } |
| 1096 | |
| 1097 | static int _ATTRS_o_ai |
| 1098 | vec_all_ne(vector unsigned short a, vector unsigned short b) |
| 1099 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1100 | return __builtin_altivec_vcmpequh_p(__CR6_EQ, (vector short)a, (vector short)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1101 | } |
| 1102 | |
| 1103 | static int _ATTRS_o_ai |
| 1104 | vec_all_ne(vector int a, vector int b) |
| 1105 | { |
| 1106 | return __builtin_altivec_vcmpequw_p(__CR6_EQ, a, b); |
| 1107 | } |
| 1108 | |
| 1109 | static int _ATTRS_o_ai |
| 1110 | vec_all_ne(vector unsigned int a, vector unsigned int b) |
| 1111 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1112 | return __builtin_altivec_vcmpequw_p(__CR6_EQ, (vector int)a, (vector int)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1113 | } |
| 1114 | |
| 1115 | static int _ATTRS_o_ai |
| 1116 | vec_all_ne(vector float a, vector float b) |
| 1117 | { |
| 1118 | return __builtin_altivec_vcmpeqfp_p(__CR6_EQ, a, b); |
| 1119 | } |
| 1120 | |
| 1121 | /* vec_all_nge */ |
| 1122 | |
| 1123 | static int __attribute__((__always_inline__)) |
| 1124 | vec_all_nge(vector float a, vector float b) |
| 1125 | { |
| 1126 | return __builtin_altivec_vcmpgefp_p(__CR6_EQ, a, b); |
| 1127 | } |
| 1128 | |
| 1129 | /* vec_all_ngt */ |
| 1130 | |
| 1131 | static int __attribute__((__always_inline__)) |
| 1132 | vec_all_ngt(vector float a, vector float b) |
| 1133 | { |
| 1134 | return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, a, b); |
| 1135 | } |
| 1136 | |
| 1137 | /* vec_all_nle */ |
| 1138 | |
| 1139 | static int __attribute__((__always_inline__)) |
| 1140 | vec_all_nle(vector float a, vector float b) |
| 1141 | { |
| 1142 | return __builtin_altivec_vcmpgefp_p(__CR6_EQ, b, a); |
| 1143 | } |
| 1144 | |
| 1145 | /* vec_all_nlt */ |
| 1146 | |
| 1147 | static int __attribute__((__always_inline__)) |
| 1148 | vec_all_nlt(vector float a, vector float b) |
| 1149 | { |
| 1150 | return __builtin_altivec_vcmpgtfp_p(__CR6_EQ, b, a); |
| 1151 | } |
| 1152 | |
| 1153 | /* vec_all_numeric */ |
| 1154 | |
| 1155 | static int __attribute__((__always_inline__)) |
| 1156 | vec_all_numeric(vector float a) |
| 1157 | { |
| 1158 | return __builtin_altivec_vcmpeqfp_p(__CR6_LT, a, a); |
| 1159 | } |
| 1160 | |
| 1161 | /* vec_any_eq */ |
| 1162 | |
| 1163 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1164 | vec_any_eq(vector signed char a, vector signed char b) |
| 1165 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1166 | return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1167 | } |
| 1168 | |
| 1169 | static int _ATTRS_o_ai |
| 1170 | vec_any_eq(vector unsigned char a, vector unsigned char b) |
| 1171 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1172 | return __builtin_altivec_vcmpequb_p(__CR6_EQ_REV, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1173 | } |
| 1174 | |
| 1175 | static int _ATTRS_o_ai |
| 1176 | vec_any_eq(vector short a, vector short b) |
| 1177 | { |
| 1178 | return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, a, b); |
| 1179 | } |
| 1180 | |
| 1181 | static int _ATTRS_o_ai |
| 1182 | vec_any_eq(vector unsigned short a, vector unsigned short b) |
| 1183 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1184 | return __builtin_altivec_vcmpequh_p(__CR6_EQ_REV, (vector short)a, (vector short)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1185 | } |
| 1186 | |
| 1187 | static int _ATTRS_o_ai |
| 1188 | vec_any_eq(vector int a, vector int b) |
| 1189 | { |
| 1190 | return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, a, b); |
| 1191 | } |
| 1192 | |
| 1193 | static int _ATTRS_o_ai |
| 1194 | vec_any_eq(vector unsigned int a, vector unsigned int b) |
| 1195 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1196 | return __builtin_altivec_vcmpequw_p(__CR6_EQ_REV, (vector int)a, (vector int)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1197 | } |
| 1198 | |
| 1199 | static int _ATTRS_o_ai |
| 1200 | vec_any_eq(vector float a, vector float b) |
| 1201 | { |
| 1202 | return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, b); |
| 1203 | } |
| 1204 | |
| 1205 | /* vec_any_ge */ |
| 1206 | |
| 1207 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1208 | vec_any_ge(vector signed char a, vector signed char b) |
| 1209 | { |
| 1210 | return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, b, a); |
| 1211 | } |
| 1212 | |
| 1213 | static int _ATTRS_o_ai |
| 1214 | vec_any_ge(vector unsigned char a, vector unsigned char b) |
| 1215 | { |
| 1216 | return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, b, a); |
| 1217 | } |
| 1218 | |
| 1219 | static int _ATTRS_o_ai |
| 1220 | vec_any_ge(vector short a, vector short b) |
| 1221 | { |
| 1222 | return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, b, a); |
| 1223 | } |
| 1224 | |
| 1225 | static int _ATTRS_o_ai |
| 1226 | vec_any_ge(vector unsigned short a, vector unsigned short b) |
| 1227 | { |
| 1228 | return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, b, a); |
| 1229 | } |
| 1230 | |
| 1231 | static int _ATTRS_o_ai |
| 1232 | vec_any_ge(vector int a, vector int b) |
| 1233 | { |
| 1234 | return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, b, a); |
| 1235 | } |
| 1236 | |
| 1237 | static int _ATTRS_o_ai |
| 1238 | vec_any_ge(vector unsigned int a, vector unsigned int b) |
| 1239 | { |
| 1240 | return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, b, a); |
| 1241 | } |
| 1242 | |
| 1243 | static int _ATTRS_o_ai |
| 1244 | vec_any_ge(vector float a, vector float b) |
| 1245 | { |
| 1246 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a); |
| 1247 | } |
| 1248 | |
| 1249 | /* vec_any_gt */ |
| 1250 | |
| 1251 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1252 | vec_any_gt(vector signed char a, vector signed char b) |
| 1253 | { |
| 1254 | return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, a, b); |
| 1255 | } |
| 1256 | |
| 1257 | static int _ATTRS_o_ai |
| 1258 | vec_any_gt(vector unsigned char a, vector unsigned char b) |
| 1259 | { |
| 1260 | return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, a, b); |
| 1261 | } |
| 1262 | |
| 1263 | static int _ATTRS_o_ai |
| 1264 | vec_any_gt(vector short a, vector short b) |
| 1265 | { |
| 1266 | return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, a, b); |
| 1267 | } |
| 1268 | |
| 1269 | static int _ATTRS_o_ai |
| 1270 | vec_any_gt(vector unsigned short a, vector unsigned short b) |
| 1271 | { |
| 1272 | return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, a, b); |
| 1273 | } |
| 1274 | |
| 1275 | static int _ATTRS_o_ai |
| 1276 | vec_any_gt(vector int a, vector int b) |
| 1277 | { |
| 1278 | return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, a, b); |
| 1279 | } |
| 1280 | |
| 1281 | static int _ATTRS_o_ai |
| 1282 | vec_any_gt(vector unsigned int a, vector unsigned int b) |
| 1283 | { |
| 1284 | return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, a, b); |
| 1285 | } |
| 1286 | |
| 1287 | static int _ATTRS_o_ai |
| 1288 | vec_any_gt(vector float a, vector float b) |
| 1289 | { |
| 1290 | return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, a, b); |
| 1291 | } |
| 1292 | |
| 1293 | /* vec_any_le */ |
| 1294 | |
| 1295 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1296 | vec_any_le(vector signed char a, vector signed char b) |
| 1297 | { |
| 1298 | return __builtin_altivec_vcmpgtsb_p(__CR6_LT_REV, a, b); |
| 1299 | } |
| 1300 | |
| 1301 | static int _ATTRS_o_ai |
| 1302 | vec_any_le(vector unsigned char a, vector unsigned char b) |
| 1303 | { |
| 1304 | return __builtin_altivec_vcmpgtub_p(__CR6_LT_REV, a, b); |
| 1305 | } |
| 1306 | |
| 1307 | static int _ATTRS_o_ai |
| 1308 | vec_any_le(vector short a, vector short b) |
| 1309 | { |
| 1310 | return __builtin_altivec_vcmpgtsh_p(__CR6_LT_REV, a, b); |
| 1311 | } |
| 1312 | |
| 1313 | static int _ATTRS_o_ai |
| 1314 | vec_any_le(vector unsigned short a, vector unsigned short b) |
| 1315 | { |
| 1316 | return __builtin_altivec_vcmpgtuh_p(__CR6_LT_REV, a, b); |
| 1317 | } |
| 1318 | |
| 1319 | static int _ATTRS_o_ai |
| 1320 | vec_any_le(vector int a, vector int b) |
| 1321 | { |
| 1322 | return __builtin_altivec_vcmpgtsw_p(__CR6_LT_REV, a, b); |
| 1323 | } |
| 1324 | |
| 1325 | static int _ATTRS_o_ai |
| 1326 | vec_any_le(vector unsigned int a, vector unsigned int b) |
| 1327 | { |
| 1328 | return __builtin_altivec_vcmpgtuw_p(__CR6_LT_REV, a, b); |
| 1329 | } |
| 1330 | |
| 1331 | static int _ATTRS_o_ai |
| 1332 | vec_any_le(vector float a, vector float b) |
| 1333 | { |
| 1334 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b); |
| 1335 | } |
| 1336 | |
| 1337 | /* vec_any_lt */ |
| 1338 | |
| 1339 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1340 | vec_any_lt(vector signed char a, vector signed char b) |
| 1341 | { |
| 1342 | return __builtin_altivec_vcmpgtsb_p(__CR6_EQ_REV, b, a); |
| 1343 | } |
| 1344 | |
| 1345 | static int _ATTRS_o_ai |
| 1346 | vec_any_lt(vector unsigned char a, vector unsigned char b) |
| 1347 | { |
| 1348 | return __builtin_altivec_vcmpgtub_p(__CR6_EQ_REV, b, a); |
| 1349 | } |
| 1350 | |
| 1351 | static int _ATTRS_o_ai |
| 1352 | vec_any_lt(vector short a, vector short b) |
| 1353 | { |
| 1354 | return __builtin_altivec_vcmpgtsh_p(__CR6_EQ_REV, b, a); |
| 1355 | } |
| 1356 | |
| 1357 | static int _ATTRS_o_ai |
| 1358 | vec_any_lt(vector unsigned short a, vector unsigned short b) |
| 1359 | { |
| 1360 | return __builtin_altivec_vcmpgtuh_p(__CR6_EQ_REV, b, a); |
| 1361 | } |
| 1362 | |
| 1363 | static int _ATTRS_o_ai |
| 1364 | vec_any_lt(vector int a, vector int b) |
| 1365 | { |
| 1366 | return __builtin_altivec_vcmpgtsw_p(__CR6_EQ_REV, b, a); |
| 1367 | } |
| 1368 | |
| 1369 | static int _ATTRS_o_ai |
| 1370 | vec_any_lt(vector unsigned int a, vector unsigned int b) |
| 1371 | { |
| 1372 | return __builtin_altivec_vcmpgtuw_p(__CR6_EQ_REV, b, a); |
| 1373 | } |
| 1374 | |
| 1375 | static int _ATTRS_o_ai |
| 1376 | vec_any_lt(vector float a, vector float b) |
| 1377 | { |
| 1378 | return __builtin_altivec_vcmpgtfp_p(__CR6_EQ_REV, b, a); |
| 1379 | } |
| 1380 | |
| 1381 | /* vec_any_nan */ |
| 1382 | |
| 1383 | static int __attribute__((__always_inline__)) |
| 1384 | vec_any_nan(vector float a) |
| 1385 | { |
| 1386 | return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, a); |
| 1387 | } |
| 1388 | |
| 1389 | /* vec_any_ne */ |
| 1390 | |
| 1391 | static int _ATTRS_o_ai |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1392 | vec_any_ne(vector signed char a, vector signed char b) |
| 1393 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1394 | return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1395 | } |
| 1396 | |
| 1397 | static int _ATTRS_o_ai |
| 1398 | vec_any_ne(vector unsigned char a, vector unsigned char b) |
| 1399 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1400 | return __builtin_altivec_vcmpequb_p(__CR6_LT_REV, (vector char)a, (vector char)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1401 | } |
| 1402 | |
| 1403 | static int _ATTRS_o_ai |
| 1404 | vec_any_ne(vector short a, vector short b) |
| 1405 | { |
| 1406 | return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, a, b); |
| 1407 | } |
| 1408 | |
| 1409 | static int _ATTRS_o_ai |
| 1410 | vec_any_ne(vector unsigned short a, vector unsigned short b) |
| 1411 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1412 | return __builtin_altivec_vcmpequh_p(__CR6_LT_REV, (vector short)a, (vector short)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1413 | } |
| 1414 | |
| 1415 | static int _ATTRS_o_ai |
| 1416 | vec_any_ne(vector int a, vector int b) |
| 1417 | { |
| 1418 | return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, a, b); |
| 1419 | } |
| 1420 | |
| 1421 | static int _ATTRS_o_ai |
| 1422 | vec_any_ne(vector unsigned int a, vector unsigned int b) |
| 1423 | { |
Chris Lattner | ab866b4 | 2010-04-14 20:35:39 +0000 | [diff] [blame^] | 1424 | return __builtin_altivec_vcmpequw_p(__CR6_LT_REV, (vector int)a, (vector int)b); |
Chris Lattner | dd17394 | 2010-04-14 03:54:58 +0000 | [diff] [blame] | 1425 | } |
| 1426 | |
| 1427 | static int _ATTRS_o_ai |
| 1428 | vec_any_ne(vector float a, vector float b) |
| 1429 | { |
| 1430 | return __builtin_altivec_vcmpeqfp_p(__CR6_LT_REV, a, b); |
| 1431 | } |
| 1432 | |
| 1433 | /* vec_any_nge */ |
| 1434 | |
| 1435 | static int __attribute__((__always_inline__)) |
| 1436 | vec_any_nge(vector float a, vector float b) |
| 1437 | { |
| 1438 | return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, a, b); |
| 1439 | } |
| 1440 | |
| 1441 | /* vec_any_ngt */ |
| 1442 | |
| 1443 | static int __attribute__((__always_inline__)) |
| 1444 | vec_any_ngt(vector float a, vector float b) |
| 1445 | { |
| 1446 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, a, b); |
| 1447 | } |
| 1448 | |
| 1449 | /* vec_any_nle */ |
| 1450 | |
| 1451 | static int __attribute__((__always_inline__)) |
| 1452 | vec_any_nle(vector float a, vector float b) |
| 1453 | { |
| 1454 | return __builtin_altivec_vcmpgefp_p(__CR6_LT_REV, b, a); |
| 1455 | } |
| 1456 | |
| 1457 | /* vec_any_nlt */ |
| 1458 | |
| 1459 | static int __attribute__((__always_inline__)) |
| 1460 | vec_any_nlt(vector float a, vector float b) |
| 1461 | { |
| 1462 | return __builtin_altivec_vcmpgtfp_p(__CR6_LT_REV, b, a); |
| 1463 | } |
| 1464 | |
| 1465 | /* vec_any_numeric */ |
| 1466 | |
| 1467 | static int __attribute__((__always_inline__)) |
| 1468 | vec_any_numeric(vector float a) |
| 1469 | { |
| 1470 | return __builtin_altivec_vcmpeqfp_p(__CR6_EQ_REV, a, a); |
| 1471 | } |
| 1472 | |
| 1473 | /* vec_any_out */ |
| 1474 | |
| 1475 | static int __attribute__((__always_inline__)) |
| 1476 | vec_any_out(vector float a, vector float b) |
| 1477 | { |
| 1478 | return __builtin_altivec_vcmpbfp_p(__CR6_EQ_REV, a, b); |
| 1479 | } |
| 1480 | |
| 1481 | #undef _ATTRS_o_ai |
| 1482 | |
| 1483 | #endif /* __ALTIVEC_H */ |