/ lib / numpy / distutils / checks / extra_vsx_asm.c
extra_vsx_asm.c
 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  
16  #if (defined(__GNUC__) && !defined(vec_xl)) || (defined(__clang__) && !defined(__IBMC__))
17      #define vsx_ld  vec_vsx_ld
18      #define vsx_st  vec_vsx_st
19  #else
20      #define vsx_ld  vec_xl
21      #define vsx_st  vec_xst
22  #endif
23  
24  int main(void)
25  {
26      float z4[] = {0, 0, 0, 0};
27      signed int zout[] = {0, 0, 0, 0};
28  
29      __vector float vz4 = vsx_ld(0, z4);
30      __vector signed int asm_ret = vsx_ld(0, zout);
31  
32      __asm__ ("xvcvspsxws %x0,%x1" : "=wa" (vz4) : "wa" (asm_ret));
33  
34      vsx_st(asm_ret, 0, zout);
35      return zout[0];
36  }