#ifdef __ALTIVEC__ #pragma altivec_model on #include // for vec_malloc, although we are not using it // the SIXTEENIZE macro can be used to INCREMENT (or leave the same) a pointer // to be on a 16-byte boundary, required for vector operations. Note // that all MSP signal buffers are 16-byte aligned so you don't need // to do this to them. Note also that if you use this routine on // a pointer you get back from, say, NewPtr or malloc, you should allocate // the pointer with 16 extra bytes than you will actually use. If // you use getbytes where you need to pass the original allocated // pointer, you then need to store the original pointer as well as // your vectorized pointer, for example: // struct myobject { // char *x_mem; // char *x_vecmem; // }; // x->x_mem = NewPtr(size + 16); // x->x_vecmem = SIXTEENIZE(x->x_mem); #define SIXTEENIZE(p) ((((unsigned long)(p)) + 16) & 0xFFFFFFF0L); typedef union { float flt[4]; vector float vFlt; } floatToVector; static floatToVector __vsf_temp; // this is what was needed to convince the compiler to copy a float to // the four float locations in a vector #define vec_splat_float(v,f) { \ __vsf_temp.flt[0] = f; \ v = vec_splat( vec_lde( 0, __vsf_temp.flt ), 0 ); } #define VRSAVE asm { li r0,-1 ; mtspr vrsave,r0 } #pragma altivec_model off #endif