github.com/256dpi/max-go@v0.7.0/lib/msp/z_altivec.h (about)

     1  #ifdef __ALTIVEC__
     2  #pragma altivec_model on
     3  
     4  #ifdef __cplusplus
     5  #include <stdlib.h>		// for vec_malloc
     6  #endif
     7  
     8  typedef union 
     9  {
    10  	float			flt[4];
    11  	vector float	vFlt;
    12  } floatToVector;
    13  
    14  static floatToVector __vsf_temp;
    15  
    16  // this is what was needed to convince the compiler to copy a float to
    17  // the four float locations in a vector
    18  
    19  #define vec_splat_float(v,f) {							\
    20      __vsf_temp.flt[0] = f;								\
    21      v = vec_splat( vec_lde( 0, __vsf_temp.flt ), 0 );	}
    22  
    23  #define VRSAVE     asm { li r0,-1 ; mtspr vrsave,r0 }
    24      
    25  #pragma altivec_model off
    26  #endif