1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
|
// Copyright 2016 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef THIRD_PARTY_BLINK_RENDERER_PLATFORM_CPU_MIPS_COMMON_MACROS_MSA_H_
#define THIRD_PARTY_BLINK_RENDERER_PLATFORM_CPU_MIPS_COMMON_MACROS_MSA_H_
#include <msa.h>
#include <stdint.h>
#if defined(__clang__)
#define CLANG_BUILD
#endif
typedef union {
int32_t intVal;
float floatVal;
} FloatInt;
#ifdef CLANG_BUILD
#define SRLI_B(a, b) __msa_srli_b((v16i8)a, b)
#define SRLI_H(a, b) __msa_srli_h((v8i16)a, b)
#define SLLI_B(a, b) __msa_slli_b((v16i8)a, b)
#define SLLI_H(a, b) __msa_slli_h((v8i16)a, b)
#define CEQI_B(a, b) __msa_ceqi_b((v16i8)a, b)
#define CEQI_H(a, b) __msa_ceqi_h((v8i16)a, b)
#define ANDI_B(a, b) __msa_andi_b((v16u8)a, b)
#else
#define SRLI_B(a, b) ((v16u8)a >> b)
#define SRLI_H(a, b) ((v8u16)a >> b)
#define SLLI_B(a, b) ((v16i8)a << b)
#define SLLI_H(a, b) ((v8i16)a << b)
#define CEQI_B(a, b) (a == b)
#define CEQI_H(a, b) (a == b)
#define ANDI_B(a, b) ((v16u8)a & b)
#endif
#define LD_V(RTYPE, psrc) *((RTYPE*)(psrc))
#define LD_UB(...) LD_V(v16u8, __VA_ARGS__)
#define LD_UH(...) LD_V(v8u16, __VA_ARGS__)
#define LD_SP(...) LD_V(v4f32, __VA_ARGS__)
#define LD_DP(...) LD_V(v2f64, __VA_ARGS__)
#define ST_V(RTYPE, in, pdst) *((RTYPE*)(pdst)) = in
#define ST_UB(...) ST_V(v16u8, __VA_ARGS__)
#define ST_UH(...) ST_V(v8u16, __VA_ARGS__)
#define ST_SP(...) ST_V(v4f32, __VA_ARGS__)
#define ST_DP(...) ST_V(v2f64, __VA_ARGS__)
#ifdef CLANG_BUILD
#define COPY_DOUBLE_TO_VECTOR(a) \
({ \
v2f64 out; \
out = (v2f64)__msa_fill_d(*(int64_t*)(&a)); \
out; \
})
#else
#define COPY_DOUBLE_TO_VECTOR(a) \
({ \
v2f64 out; \
out = __msa_cast_to_vector_double(a); \
out = (v2f64)__msa_splati_d((v2i64)out, 0); \
out; \
})
#endif
#define MSA_STORE_FUNC(TYPE, INSTR, FUNCNAME) \
static inline void FUNCNAME(TYPE val, void* const pdst) { \
uint8_t* const pdstm = (uint8_t*)pdst; \
TYPE valm = val; \
asm volatile(" " #INSTR " %[valm], %[pdstm] \n\t" \
: [pdstm] "=m"(*pdstm) \
: [valm] "r"(valm)); \
}
#define MSA_STORE(val, pdst, FUNCNAME) FUNCNAME(val, pdst)
#ifdef CLANG_BUILD
MSA_STORE_FUNC(uint32_t, sw, msa_sw);
#define SW(val, pdst) MSA_STORE(val, pdst, msa_sw)
#if (__mips == 64)
MSA_STORE_FUNC(uint64_t, sd, msa_sd);
#define SD(val, pdst) MSA_STORE(val, pdst, msa_sd)
#else
#define SD(val, pdst) \
{ \
uint8_t* const pdstsd = (uint8_t*)(pdst); \
const uint32_t val0m = (uint32_t)(val & 0x00000000FFFFFFFF); \
const uint32_t val1m = (uint32_t)((val >> 32) & 0x00000000FFFFFFFF); \
SW(val0m, pdstsd); \
SW(val1m, pdstsd + 4); \
}
#endif
#else
#if (__mips_isa_rev >= 6)
MSA_STORE_FUNC(uint32_t, sw, msa_sw);
#define SW(val, pdst) MSA_STORE(val, pdst, msa_sw)
MSA_STORE_FUNC(uint64_t, sd, msa_sd);
#define SD(val, pdst) MSA_STORE(val, pdst, msa_sd)
#else // !(__mips_isa_rev >= 6)
MSA_STORE_FUNC(uint32_t, usw, msa_usw);
#define SW(val, pdst) MSA_STORE(val, pdst, msa_usw)
#define SD(val, pdst) \
{ \
uint8_t* const pdstsd = (uint8_t*)(pdst); \
const uint32_t val0m = (uint32_t)(val & 0x00000000FFFFFFFF); \
const uint32_t val1m = (uint32_t)((val >> 32) & 0x00000000FFFFFFFF); \
SW(val0m, pdstsd); \
SW(val1m, pdstsd + 4); \
}
#endif // (__mips_isa_rev >= 6)
#endif
/* Description : Load vectors with elements with stride
* Arguments : Inputs - psrc, stride
* Outputs - out0, out1
* Return Type - as per RTYPE
* Details : Load elements in 'out0' from (psrc)
* Load elements in 'out1' from (psrc + stride)
*/
#define LD_V2(RTYPE, psrc, stride, out0, out1) \
{ \
out0 = LD_V(RTYPE, psrc); \
psrc += stride; \
out1 = LD_V(RTYPE, psrc); \
psrc += stride; \
}
#define LD_UB2(...) LD_V2(v16u8, __VA_ARGS__)
#define LD_UH2(...) LD_V2(v8u16, __VA_ARGS__)
#define LD_SP2(...) LD_V2(v4f32, __VA_ARGS__)
#define LD_V3(RTYPE, psrc, stride, out0, out1, out2) \
{ \
LD_V2(RTYPE, psrc, stride, out0, out1); \
out2 = LD_V(RTYPE, psrc); \
psrc += stride; \
}
#define LD_UB3(...) LD_V3(v16u8, __VA_ARGS__)
#define LD_UH3(...) LD_V3(v8u16, __VA_ARGS__)
#define LD_V4(RTYPE, psrc, stride, out0, out1, out2, out3) \
{ \
LD_V2(RTYPE, psrc, stride, out0, out1); \
LD_V2(RTYPE, psrc, stride, out2, out3); \
}
#define LD_UB4(...) LD_V4(v16u8, __VA_ARGS__)
#define LD_UH4(...) LD_V4(v8u16, __VA_ARGS__)
#define LD_SP4(...) LD_V4(v4f32, __VA_ARGS__)
#define LD_V5(RTYPE, psrc, stride, out0, out1, out2, out3, out4) \
{ \
LD_V4(RTYPE, psrc, stride, out0, out1, out2, out3); \
out4 = LD_V(RTYPE, psrc); \
psrc += stride; \
}
#define LD_UB5(...) LD_V5(v16u8, __VA_ARGS__)
#define LD_V6(RTYPE, psrc, stride, out0, out1, out2, out3, out4, out5) \
{ \
LD_V4(RTYPE, psrc, stride, out0, out1, out2, out3); \
LD_V2(RTYPE, psrc, stride, out4, out5); \
}
#define LD_UB6(...) LD_V6(v16u8, __VA_ARGS__)
#define LD_UH6(...) LD_V6(v8u16, __VA_ARGS__)
#define LD_SP6(...) LD_V6(v4f32, __VA_ARGS__)
#define LD_V7(RTYPE, psrc, stride, out0, out1, out2, out3, out4, out5, out6) \
{ \
LD_V5(RTYPE, psrc, stride, out0, out1, out2, out3, out4); \
LD_V2(RTYPE, psrc, stride, out5, out6); \
}
#define LD_UB7(...) LD_V7(v16u8, __VA_ARGS__)
#define LD_V8(RTYPE, psrc, stride, out0, out1, out2, out3, out4, out5, out6, \
out7) \
{ \
LD_V4(RTYPE, psrc, stride, out0, out1, out2, out3); \
LD_V4(RTYPE, psrc, stride, out4, out5, out6, out7); \
}
#define LD_UB8(...) LD_V8(v16u8, __VA_ARGS__)
#define LD_UH8(...) LD_V8(v8u16, __VA_ARGS__)
#define LD_SP8(...) LD_V8(v4f32, __VA_ARGS__)
#define LD_DP8(...) LD_V8(v2f64, __VA_ARGS__)
/* Description : Store vectors of elements with stride
* Arguments : Inputs - in0, in1, pdst, stride
* Details : Store elements from 'in0' to (pdst)
* Store elements from 'in1' to (pdst + stride)
*/
#define ST_V2(RTYPE, in0, in1, pdst, stride) \
{ \
ST_V(RTYPE, in0, pdst); \
pdst += stride; \
ST_V(RTYPE, in1, pdst); \
pdst += stride; \
}
#define ST_UB2(...) ST_V2(v16u8, __VA_ARGS__)
#define ST_UH2(...) ST_V2(v8u16, __VA_ARGS__)
#define ST_SP2(...) ST_V2(v4f32, __VA_ARGS__)
#define ST_V3(RTYPE, in0, in1, in2, pdst, stride) \
{ \
ST_V2(RTYPE, in0, in1, pdst, stride); \
ST_V(RTYPE, in2, pdst); \
pdst += stride; \
}
#define ST_UB3(...) ST_V3(v16u8, __VA_ARGS__)
#define ST_UH3(...) ST_V3(v8u16, __VA_ARGS__)
#define ST_V4(RTYPE, in0, in1, in2, in3, pdst, stride) \
{ \
ST_V2(RTYPE, in0, in1, pdst, stride); \
ST_V2(RTYPE, in2, in3, pdst, stride); \
}
#define ST_UB4(...) ST_V4(v16u8, __VA_ARGS__)
#define ST_UH4(...) ST_V4(v8u16, __VA_ARGS__)
#define ST_SP4(...) ST_V4(v4f32, __VA_ARGS__)
#define ST_V6(RTYPE, in0, in1, in2, in3, in4, in5, pdst, stride) \
{ \
ST_V3(RTYPE, in0, in1, in2, pdst, stride); \
ST_V3(RTYPE, in3, in4, in5, pdst, stride); \
}
#define ST_UB6(...) ST_V6(v16u8, __VA_ARGS__)
#define ST_SP6(...) ST_V6(v4f32, __VA_ARGS__)
#define ST_V8(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, pdst, stride) \
{ \
ST_V4(RTYPE, in0, in1, in2, in3, pdst, stride); \
ST_V4(RTYPE, in4, in5, in6, in7, pdst, stride); \
}
#define ST_UB8(...) ST_V8(v16u8, __VA_ARGS__)
#define ST_SP8(...) ST_V8(v4f32, __VA_ARGS__)
/* Description : Store 8x1 byte block to destination memory from input vector
Arguments : Inputs - in, pdst
Details : Index 0 double word element from 'in' vector is copied to the
GP register and stored to (pdst)
*/
#define ST8x1_UB(in, pdst) \
{ \
const uint64_t out0m = __msa_copy_s_d((v2i64)in, 0); \
SD(out0m, pdst); \
}
/* Description : Logical and in0 and in1.
Arguments : Inputs - in0, in1, in2, in3,
Outputs - out0, out1, out2, out3
Return Type - as per RTYPE
Details : Each unsigned word element from 'in0' vector is added with
each unsigned word element from 'in1' vector. Then the average
is calculated and written to 'out0'
*/
#define AND_V2(RTYPE, in0, in1, mask, out0, out1) \
{ \
out0 = (RTYPE)__msa_and_v((v16u8)in0, (v16u8)mask); \
out1 = (RTYPE)__msa_and_v((v16u8)in1, (v16u8)mask); \
}
#define AND_V2_UB(...) AND_V2(v16u8, __VA_ARGS__)
#define AND_V4(RTYPE, in0, in1, in2, in3, mask, out0, out1, out2, out3) \
{ \
AND_V2(RTYPE, in0, in1, mask, out0, out1); \
AND_V2(RTYPE, in2, in3, mask, out2, out3); \
}
#define AND_V4_UB(...) AND_V4(v16u8, __VA_ARGS__)
/* Description : Logical equate of input vectors with immediate value
Arguments : Inputs - in0, in1, val
Outputs - in place operation
Return Type - as per RTYPE
Details : Each unsigned byte element from input vector 'in0' & 'in1' is
logically and'ed with immediate mask and the result
is stored in-place.
*/
#define CEQI_B2(RTYPE, in0, in1, val, out0, out1) \
{ \
out0 = CEQI_B(in0, val); \
out1 = CEQI_B(in1, val); \
}
#define CEQI_B2_UB(...) CEQI_B2(v16u8, __VA_ARGS__)
#define CEQI_B4(RTYPE, in0, in1, in2, in3, val, out0, out1, out2, out3) \
{ \
CEQI_B2(RTYPE, in0, in1, val, out0, out1); \
CEQI_B2(RTYPE, in2, in3, val, out2, out3); \
}
#define CEQI_B4_UB(...) CEQI_B4(v16u8, __VA_ARGS__)
/* Description : Immediate number of elements to slide
* Arguments : Inputs - in0, in1, slide_val
* Outputs - out
* Return Type - as per RTYPE
* Details : Byte elements from 'in1' vector are slid into 'in0' by
* value specified in the 'slide_val'
*/
#define SLDI_B(RTYPE, in0, in1, slide_val) \
(RTYPE) __msa_sldi_b((v16i8)in0, (v16i8)in1, slide_val)
#define SLDI_UB(...) SLDI_B(v16u8, __VA_ARGS__)
#define SLDI_D(...) SLDI_B(v2f64, __VA_ARGS__)
/* Description : Immediate number of elements to slide
Arguments : Inputs - in0_0, in0_1, in1_0, in1_1, slide_val
Outputs - out0, out1
Return Type - as per RTYPE
Details : Byte elements from 'in0_0' vector are slid into 'in1_0' by
value specified in the 'slide_val'
*/
#define SLDI_B2(RTYPE, in0_0, in0_1, in1_0, in1_1, out0, out1, slide_val) \
{ \
out0 = SLDI_B(RTYPE, in0_0, in1_0, slide_val); \
out1 = SLDI_B(RTYPE, in0_1, in1_1, slide_val); \
}
#define SLDI_B2_UB(...) SLDI_B2(v16u8, __VA_ARGS__)
/* Description : Shuffle byte vector elements as per variable
Arguments : Inputs - in0, in1, shf_val
Outputs - out0, out1
Return Type - as per RTYPE
Details : Byte elements from 'in0' & 'in1' are copied selectively to
'out0' as per control variable 'shf_val'.
*/
#define SHF_B2(RTYPE, in0, in1, shf_val) \
{ \
in0 = (RTYPE)__msa_shf_b((v16i8)in0, shf_val); \
in1 = (RTYPE)__msa_shf_b((v16i8)in1, shf_val); \
}
#define SHF_B2_UB(...) SHF_B2(v16u8, __VA_ARGS__)
#define SHF_B2_UH(...) SHF_B2(v8u16, __VA_ARGS__)
#define SHF_B3(RTYPE, in0, in1, in2, shf_val) \
{ \
SHF_B2(RTYPE, in0, in1, shf_val); \
in2 = (RTYPE)__msa_shf_b((v16i8)in2, shf_val); \
}
#define SHF_B3_UB(...) SHF_B3(v16u8, __VA_ARGS__)
#define SHF_B3_UH(...) SHF_B3(v8u16, __VA_ARGS__)
#define SHF_B4(RTYPE, in0, in1, in2, in3, shf_val) \
{ \
SHF_B2(RTYPE, in0, in1, shf_val); \
SHF_B2(RTYPE, in2, in3, shf_val); \
}
#define SHF_B4_UB(...) SHF_B4(v16u8, __VA_ARGS__)
#define SHF_B4_UH(...) SHF_B4(v8u16, __VA_ARGS__)
/* Description : Shuffle byte vector elements as per mask vector
Arguments : Inputs - in0, in1, in2, in3, mask0, mask1
Outputs - out0, out1
Return Type - as per RTYPE
Details : Byte elements from 'in0' & 'in1' are copied selectively to
'out0' as per control vector 'mask0'
*/
#define VSHF_B(RTYPE, in0, in1, mask) \
(RTYPE) __msa_vshf_b((v16i8)mask, (v16i8)in1, (v16i8)in0);
#define VSHF_UB(...) VSHF_B(v16u8, __VA_ARGS__)
/* Description : Interleave even byte elements from vectors
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Return Type - as per RTYPE
Details : Even byte elements of 'in0' and 'in1' are interleaved
and written to 'out0'
*/
#define ILVEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvev_b((v16i8)in1, (v16i8)in0); \
out1 = (RTYPE)__msa_ilvev_b((v16i8)in3, (v16i8)in2); \
}
#define ILVEV_B2_UB(...) ILVEV_B2(v16u8, __VA_ARGS__)
#define ILVEV_B2_UH(...) ILVEV_B2(v8u16, __VA_ARGS__)
#define ILVEV_B3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2) \
{ \
ILVEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) \
out2 = (RTYPE)__msa_ilvev_b((v16i8)in5, (v16i8)in4); \
}
#define ILVEV_B3_UH(...) ILVEV_B3(v8u16, __VA_ARGS__)
/* Description : Interleave even halfword elements from vectors
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Return Type - as per RTYPE
Details : Even halfword elements of 'in0' and 'in1' are interleaved
and written to 'out0'
*/
#define ILVEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvev_h((v8i16)in1, (v8i16)in0); \
out1 = (RTYPE)__msa_ilvev_h((v8i16)in3, (v8i16)in2); \
}
#define ILVEV_H2_UB(...) ILVEV_H2(v16u8, __VA_ARGS__)
/* Description : Interleave right half of double word elements from vectors
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1
* Return Type - as per RTYPE
* Details : Right half of double word elements of 'in0' and 'in1' are
* interleaved and written to 'out0'.
*/
#define ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvr_d((v2i64)in0, (v2i64)in1); \
out1 = (RTYPE)__msa_ilvr_d((v2i64)in2, (v2i64)in3); \
}
#define ILVR_D2_UB(...) ILVR_D2(v16u8, __VA_ARGS__)
#define ILVR_D3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2) \
{ \
ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1); \
out2 = (RTYPE)__msa_ilvr_d((v2i64)in4, (v2i64)in5); \
}
#define ILVR_D3_UB(...) ILVR_D3(v16u8, __VA_ARGS__)
#define ILVR_D4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, \
out2, out3) \
{ \
ILVR_D2(RTYPE, in0, in1, in2, in3, out0, out1); \
ILVR_D2(RTYPE, in4, in5, in6, in7, out2, out3); \
}
#define ILVR_D4_UB(...) ILVR_D4(v16u8, __VA_ARGS__)
/* Description : Interleave both left and right half of input vectors
Arguments : Inputs - in0, in1
Outputs - out0, out1
Return Type - as per RTYPE
Details : Right half of byte elements from 'in0' and 'in1' are
interleaved and written to 'out0'
*/
#define ILVRL_B2(RTYPE, in0, in1, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvr_b((v16i8)in0, (v16i8)in1); \
out1 = (RTYPE)__msa_ilvl_b((v16i8)in0, (v16i8)in1); \
}
#define ILVRL_B2_UB(...) ILVRL_B2(v16u8, __VA_ARGS__)
#define ILVRL_H2(RTYPE, in0, in1, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvr_h((v8i16)in0, (v8i16)in1); \
out1 = (RTYPE)__msa_ilvl_h((v8i16)in0, (v8i16)in1); \
}
#define ILVRL_H2_UB(...) ILVRL_H2(v16u8, __VA_ARGS__)
/* Description : Interleave both odd and even half of input vectors
Arguments : Inputs - in0, in1
Outputs - out0, out1
Return Type - as per RTYPE
Details : Odd half of byte elements from 'in0' and 'in1' are
interleaved and written to 'out0'
*/
#define ILVODEV_B2(RTYPE, in0, in1, out0, out1) \
{ \
out0 = (RTYPE)__msa_ilvod_b((v16i8)in0, (v16i8)in1); \
out1 = (RTYPE)__msa_ilvev_b((v16i8)in0, (v16i8)in1); \
}
#define ILVODEV_B2_UB(...) ILVODEV_B2(v16u8, __VA_ARGS__)
/* Description : Pack even byte elements of vector pairs
* Arguments : Inputs - in0, in1, in2, in3
* Outputs - out0, out1
* Return Type - as per RTYPE
* Details : Even byte elements of 'in0' are copied to the left half of
* 'out0' & even byte elements of 'in1' are copied to the right
* half of 'out0'.
*/
#define PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_pckev_b((v16i8)in0, (v16i8)in1); \
out1 = (RTYPE)__msa_pckev_b((v16i8)in2, (v16i8)in3); \
}
#define PCKEV_B2_UB(...) PCKEV_B2(v16u8, __VA_ARGS__)
#define PCKEV_B2_UH(...) PCKEV_B2(v8u16, __VA_ARGS__)
#define PCKEV_B3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2) \
{ \
PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
out2 = (RTYPE)__msa_pckev_b((v16i8)in4, (v16i8)in5); \
}
#define PCKEV_B3_UH(...) PCKEV_B3(v8u16, __VA_ARGS__)
#define PCKEV_B4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, \
out2, out3) \
{ \
PCKEV_B2(RTYPE, in0, in1, in2, in3, out0, out1); \
PCKEV_B2(RTYPE, in4, in5, in6, in7, out2, out3); \
}
#define PCKEV_B4_UH(...) PCKEV_B4(v8u16, __VA_ARGS__)
/* Description : Pack even halfword elements of vector pairs
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Return Type - as per RTYPE
Details : Even halfword elements of 'in0' are copied to the left half of
'out0' & even halfword elements of 'in1' are copied to the
right half of 'out0'.
*/
#define PCKEV_H2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_pckev_h((v8i16)in0, (v8i16)in1); \
out1 = (RTYPE)__msa_pckev_h((v8i16)in2, (v8i16)in3); \
}
#define PCKEV_H2_UB(...) PCKEV_H2(v16u8, __VA_ARGS__)
#define PCKEV_H3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2) \
{ \
PCKEV_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
out2 = (RTYPE)__msa_pckev_h((v8i16)in4, (v8i16)in5); \
}
#define PCKEV_H3_UB(...) PCKEV_H3(v16u8, __VA_ARGS__)
#define PCKEV_H4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, \
out2, out3) \
{ \
PCKEV_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
PCKEV_H2(RTYPE, in4, in5, in6, in7, out2, out3); \
}
#define PCKEV_H4_UB(...) PCKEV_H4(v16u8, __VA_ARGS__)
/* Description : Pack odd halfword elements of vector pairs
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Return Type - as per RTYPE
Details : Odd halfword elements of 'in0' are copied to the left half of
'out0' & odd halfword elements of 'in1' are copied to the
right half of 'out0'.
*/
#define PCKOD_H2(RTYPE, in0, in1, in2, in3, out0, out1) \
{ \
out0 = (RTYPE)__msa_pckod_h((v8i16)in0, (v8i16)in1); \
out1 = (RTYPE)__msa_pckod_h((v8i16)in2, (v8i16)in3); \
}
#define PCKOD_H2_UB(...) PCKOD_H2(v16u8, __VA_ARGS__)
#define PCKOD_H3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2) \
{ \
PCKOD_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
out2 = (RTYPE)__msa_pckod_h((v8i16)in4, (v8i16)in5); \
}
#define PCKOD_H3_UB(...) PCKOD_H3(v16u8, __VA_ARGS__)
#define PCKOD_H4(RTYPE, in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, \
out2, out3) \
{ \
PCKOD_H2(RTYPE, in0, in1, in2, in3, out0, out1); \
PCKOD_H2(RTYPE, in4, in5, in6, in7, out2, out3); \
}
#define PCKOD_H4_UB(...) PCKOD_H4(v16u8, __VA_ARGS__)
/* Description : Logical shift right all elements of half-word vector
Arguments : Inputs - in0, in1, shift
Outputs - in place operation
Return Type - as per input vector RTYPE
Details : Each element of vector 'in0' is right shifted by 'shift' and
the result is written in-place. 'shift' is a GP variable.
*/
#define SRLI_B2(RTYPE, in0, in1, shift_val) \
{ \
in0 = (RTYPE)SRLI_B(in0, shift_val); \
in1 = (RTYPE)SRLI_B(in1, shift_val); \
}
#define SRLI_B2_UB(...) SRLI_B2(v16u8, __VA_ARGS__)
#define SRLI_B3(RTYPE, in0, in1, in2, shift_val) \
{ \
SRLI_B2(RTYPE, in0, in1, shift_val); \
in2 = (RTYPE)SRLI_B(in2, shift_val); \
}
#define SRLI_B3_UB(...) SRLI_B3(v16u8, __VA_ARGS__)
#define SRLI_B4(RTYPE, in0, in1, in2, in3, shift_val) \
{ \
SRLI_B2(RTYPE, in0, in1, shift_val); \
SRLI_B2(RTYPE, in2, in3, shift_val); \
}
#define SRLI_B4_UB(...) SRLI_B4(v16u8, __VA_ARGS__)
/* Description : Logical shift right all elements of vector (immediate)
Arguments : Inputs - in0, in1, in2, in3, shift
Outputs - out0, out1, out2, out3
Return Type - as per RTYPE
Details : Each element of vector 'in0' is right shifted by 'shift' and
the result is written in 'out0'. 'shift' is an immediate value.
*/
#define SRLI_H2(RTYPE, in0, in1, out0, out1, shift) \
{ \
out0 = (RTYPE)SRLI_H((v8i16)in0, shift); \
out1 = (RTYPE)SRLI_H((v8i16)in1, shift); \
}
#define SRLI_H2_UB(...) SRLI_H2(v16u8, __VA_ARGS__)
#define SRLI_H4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3, shift) \
{ \
SRLI_H2(RTYPE, in0, in1, out0, out1, shift); \
SRLI_H2(RTYPE, in2, in3, out2, out3, shift); \
}
#define SRLI_H4_UB(...) SRLI_H4(v16u8, __VA_ARGS__)
/* Description : Immediate Bit Insert Left (immediate)
Arguments : Inputs - in0, in1, in2, in3, shift
Outputs - out0, out1
Return Type - as per RTYPE
Details : Copy most significant (left) bits in each element of vector
'in1' to elements in vector in0 while preserving the least
significant (right) bits. The number of bits to copy is given
by the immediate 'shift + 1'.
*/
#define BINSLI_B2(RTYPE, in0, in1, in2, in3, out0, out1, shift) \
{ \
out0 = (RTYPE)__msa_binsli_b((v16u8)in0, (v16u8)in1, shift); \
out1 = (RTYPE)__msa_binsli_b((v16u8)in2, (v16u8)in3, shift); \
}
#define BINSLI_B2_UB(...) BINSLI_B2(v16u8, __VA_ARGS__)
/* Description : Immediate Bit Insert Right (immediate)
Arguments : Inputs - in0, in1, in2, in3, shift
Outputs - out0, out1
Return Type - as per RTYPE
Details : Copy least significant (right) bits in each element of vector
'in1' to elements in vector in0 while preserving the most
significant (left) bits. The number of bits to copy is given
by the immediate 'shift + 1'.
*/
#define BINSRI_B2(RTYPE, in0, in1, in2, in3, out0, out1, shift) \
{ \
out0 = (RTYPE)__msa_binsri_b((v16u8)in0, (v16u8)in1, shift); \
out1 = (RTYPE)__msa_binsri_b((v16u8)in2, (v16u8)in3, shift); \
}
#define BINSRI_B2_UB(...) BINSRI_B2(v16u8, __VA_ARGS__)
#define BINSRI_B3(RTYPE, in0, in1, in2, in3, in4, in5, out0, out1, out2, \
shift) \
{ \
BINSRI_B2(RTYPE, in0, in1, in2, in3, out0, out1, shift); \
out2 = (RTYPE)__msa_binsri_b((v16u8)in4, (v16u8)in5, shift); \
}
#define BINSRI_B3_UB(...) BINSRI_B3(v16u8, __VA_ARGS__)
/* Description : Multiplication of pairs of vectors
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Details : Each element from 'in0' is multiplied with elements from 'in1'
and the result is written to 'out0'
*/
#define MUL2(in0, in1, in2, in3, out0, out1) \
{ \
out0 = in0 * in1; \
out1 = in2 * in3; \
}
#define MUL4(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3) \
{ \
MUL2(in0, in1, in2, in3, out0, out1); \
MUL2(in4, in5, in6, in7, out2, out3); \
}
/* Description : Division of pairs of vectors
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Details : Each element from 'in0' is divided by elements from 'in1'
and the result is written to 'out0'
*/
#define DIV2(in0, in1, in2, in3, out0, out1) \
{ \
out0 = in0 / in1; \
out1 = in2 / in3; \
}
#define DIV4(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3) \
{ \
DIV2(in0, in1, in2, in3, out0, out1); \
DIV2(in4, in5, in6, in7, out2, out3); \
}
/* Description : Logical AND of 4 pairs of vectors with mask
Arguments : Inputs - in0, in1, in2, in3, mask
Outputs - in0, in1, in2, in3
Details : Each element in 'in0' is logically AND'ed with mask
Each element in 'in1' is logically AND'ed with mask
Each element in 'in2' is logically AND'ed with mask
Each element in 'in3' is logically AND'ed with mask
*/
#define AND_W4(RTYPE, in0, in1, in2, in3, mask) \
{ \
in0 = (RTYPE)((v16i8)in0 & (v16i8)mask); \
in1 = (RTYPE)((v16i8)in1 & (v16i8)mask); \
in2 = (RTYPE)((v16i8)in2 & (v16i8)mask); \
in3 = (RTYPE)((v16i8)in3 & (v16i8)mask); \
}
#define AND_W4_SP(...) AND_W4(v4f32, __VA_ARGS__)
/* Description : Addition of 2 pairs of vectors
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1
Details : Each element in 'in0' is added to 'in1' and result is written
to 'out0'
Each element in 'in2' is added to 'in3' and result is written
to 'out1'
*/
#define ADD2(in0, in1, in2, in3, out0, out1) \
{ \
out0 = in0 + in1; \
out1 = in2 + in3; \
}
/* Description : Addition of 4 pairs of vectors
Arguments : Inputs - in0, in1, in2, in3, in4, in5, in6, in7
Outputs - out0, out1
Details : Each element in 'in0' is added to 'in1' and result is written
to 'out0'
Each element in 'in2' is added to 'in3' and result is written
to 'out1'
Each element in 'in4' is added to 'in5' and result is written
to 'out2'
Each element in 'in6' is added to 'in7' and result is written
to 'out3'
*/
#define ADD4(in0, in1, in2, in3, in4, in5, in6, in7, out0, out1, out2, out3) \
{ \
ADD2(in0, in1, in2, in3, out0, out1); \
ADD2(in4, in5, in6, in7, out2, out3); \
}
/* Description : Vector Floating-Point Convert from Unsigned Integer
Arguments : Inputs - in0, in1
Outputs - out0, out1
*/
#define FFINTU_W2(RTYPE, in0, in1, out0, out1) \
{ \
out0 = (RTYPE)__msa_ffint_u_w((v4u32)in0); \
out1 = (RTYPE)__msa_ffint_u_w((v4u32)in1); \
}
#define FFINTU_W2_SP(...) FFINTU_W2(v4f32, __VA_ARGS__)
/* Description : Vector Floating-Point Convert from Unsigned Integer
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1, out2, out3
*/
#define FFINTU_W4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \
{ \
FFINTU_W2(RTYPE, in0, in1, out0, out1); \
FFINTU_W2(RTYPE, in2, in3, out2, out3); \
}
#define FFINTU_W4_SP(...) FFINTU_W4(v4f32, __VA_ARGS__)
/* Description : Vector Floating-Point Truncate and Convert to Unsigned Integer
Arguments : Inputs - in0, in1
Outputs - out0, out1
*/
#define FTRUNCU_W2(RTYPE, in0, in1, out0, out1) \
{ \
out0 = (RTYPE)__msa_ftrunc_u_w((v4f32)in0); \
out1 = (RTYPE)__msa_ftrunc_u_w((v4f32)in1); \
}
#define FTRUNCU_W2_UB(...) FTRUNCU_W2(v16u8, __VA_ARGS__)
/* Description : Vector Floating-Point Truncate and Convert to Unsigned Integer
Arguments : Inputs - in0, in1, in2, in3
Outputs - out0, out1, out2, out3
*/
#define FTRUNCU_W4(RTYPE, in0, in1, in2, in3, out0, out1, out2, out3) \
{ \
FTRUNCU_W2(RTYPE, in0, in1, out0, out1); \
FTRUNCU_W2(RTYPE, in2, in3, out2, out3); \
}
#define FTRUNCU_W4_UB(...) FTRUNCU_W4(v16u8, __VA_ARGS__)
/* Description : Vector Floating-Point multiply with scale and accumulate
Arguments : Inputs - in0, in1, in2, in3, out0, out1, out2, out3, scale
Outputs - out0, out1, out2, out3
*/
#define VSMA4(in0, in1, in2, in3, out0, out1, out2, out3, scale) \
{ \
out0 += in0 * scale; \
out1 += in1 * scale; \
out2 += in2 * scale; \
out3 += in3 * scale; \
}
/* Description : Vector Floating-Point multiply with scale
Arguments : Inputs - in0, in1, in2, in3, scale
Outputs - out0, out1, out2, out3
*/
#define VSMUL4(in0, in1, in2, in3, out0, out1, out2, out3, scale) \
{ \
out0 = in0 * scale; \
out1 = in1 * scale; \
out2 = in2 * scale; \
out3 = in3 * scale; \
}
/* Description : Vector Floating-Point max value
Arguments : Inputs - in0, in1, in2, in3, max
Output - max
*/
#define VMAX_W4(RTYPE, in0, in1, in2, in3, max) \
{ \
max = (RTYPE)__msa_fmax_w((v4f32)max, (v4f32)in0); \
max = (RTYPE)__msa_fmax_w((v4f32)max, (v4f32)in1); \
max = (RTYPE)__msa_fmax_w((v4f32)max, (v4f32)in2); \
max = (RTYPE)__msa_fmax_w((v4f32)max, (v4f32)in3); \
}
#define VMAX_W4_SP(...) VMAX_W4(v4f32, __VA_ARGS__)
/* Description : Vector Floating-Point clip to min max
Arguments : Inputs - in0, in1, in2, in3, min, max
Outputs - out0, out1, out2, out3
*/
#define VCLIP4(in0, in1, in2, in3, min, max, out0, out1, out2, out3) \
{ \
out0 = __msa_fmax_w(__msa_fmin_w(in0, max), min); \
out1 = __msa_fmax_w(__msa_fmin_w(in1, max), min); \
out2 = __msa_fmax_w(__msa_fmin_w(in2, max), min); \
out3 = __msa_fmax_w(__msa_fmin_w(in3, max), min); \
}
#endif // THIRD_PARTY_BLINK_RENDERER_PLATFORM_CPU_MIPS_COMMON_MACROS_MSA_H_
|