extra_vsx_asm.c 945 B

123456789101112131415161718192021222324252627282930313233343536
  1. /**
  2. * Testing ASM VSX register number fixer '%x<n>'
  3. *
  4. * old versions of CLANG doesn't support %x<n> in the inline asm template
  5. * which fixes register number when using any of the register constraints wa, wd, wf.
  6. *
  7. * xref:
  8. * - https://bugs.llvm.org/show_bug.cgi?id=31837
  9. * - https://gcc.gnu.org/onlinedocs/gcc/Machine-Constraints.html
  10. */
  11. #ifndef __VSX__
  12. #error "VSX is not supported"
  13. #endif
  14. #include <altivec.h>
  15. #if (defined(__GNUC__) && !defined(vec_xl)) || (defined(__clang__) && !defined(__IBMC__))
  16. #define vsx_ld vec_vsx_ld
  17. #define vsx_st vec_vsx_st
  18. #else
  19. #define vsx_ld vec_xl
  20. #define vsx_st vec_xst
  21. #endif
  22. int main(void)
  23. {
  24. float z4[] = {0, 0, 0, 0};
  25. signed int zout[] = {0, 0, 0, 0};
  26. __vector float vz4 = vsx_ld(0, z4);
  27. __vector signed int asm_ret = vsx_ld(0, zout);
  28. __asm__ ("xvcvspsxws %x0,%x1" : "=wa" (vz4) : "wa" (asm_ret));
  29. vsx_st(asm_ret, 0, zout);
  30. return zout[0];
  31. }