1*bc556c66SDavid Miller /* 2*bc556c66SDavid Miller * vxeh2_vs: vector-enhancements facility 2 vector shift 3*bc556c66SDavid Miller */ 4*bc556c66SDavid Miller #include <stdint.h> 5*bc556c66SDavid Miller #include "vx.h" 6*bc556c66SDavid Miller 7*bc556c66SDavid Miller #define vtst(v1, v2) \ 8*bc556c66SDavid Miller if (v1.d[0] != v2.d[0] || v1.d[1] != v2.d[1]) { \ 9*bc556c66SDavid Miller return 1; \ 10*bc556c66SDavid Miller } 11*bc556c66SDavid Miller 12*bc556c66SDavid Miller static inline void vsl(S390Vector *v1, S390Vector *v2, S390Vector *v3) 13*bc556c66SDavid Miller { 14*bc556c66SDavid Miller asm volatile("vsl %[v1], %[v2], %[v3]\n" 15*bc556c66SDavid Miller : [v1] "=v" (v1->v) 16*bc556c66SDavid Miller : [v2] "v" (v2->v) 17*bc556c66SDavid Miller , [v3] "v" (v3->v)); 18*bc556c66SDavid Miller } 19*bc556c66SDavid Miller 20*bc556c66SDavid Miller static inline void vsra(S390Vector *v1, S390Vector *v2, S390Vector *v3) 21*bc556c66SDavid Miller { 22*bc556c66SDavid Miller asm volatile("vsra %[v1], %[v2], %[v3]\n" 23*bc556c66SDavid Miller : [v1] "=v" (v1->v) 24*bc556c66SDavid Miller : [v2] "v" (v2->v) 25*bc556c66SDavid Miller , [v3] "v" (v3->v)); 26*bc556c66SDavid Miller } 27*bc556c66SDavid Miller 28*bc556c66SDavid Miller static inline void vsrl(S390Vector *v1, S390Vector *v2, S390Vector *v3) 29*bc556c66SDavid Miller { 30*bc556c66SDavid Miller asm volatile("vsrl %[v1], %[v2], %[v3]\n" 31*bc556c66SDavid Miller : [v1] "=v" (v1->v) 32*bc556c66SDavid Miller : [v2] "v" (v2->v) 33*bc556c66SDavid Miller , [v3] "v" (v3->v)); 34*bc556c66SDavid Miller } 35*bc556c66SDavid Miller 36*bc556c66SDavid Miller static inline void vsld(S390Vector *v1, S390Vector *v2, 37*bc556c66SDavid Miller S390Vector *v3, const uint8_t I) 38*bc556c66SDavid Miller { 39*bc556c66SDavid Miller asm volatile("vsld %[v1], %[v2], %[v3], %[I]\n" 40*bc556c66SDavid Miller : [v1] "=v" (v1->v) 41*bc556c66SDavid Miller : [v2] "v" (v2->v) 42*bc556c66SDavid Miller , [v3] "v" (v3->v) 43*bc556c66SDavid Miller , [I] "i" (I & 7)); 44*bc556c66SDavid Miller } 45*bc556c66SDavid Miller 46*bc556c66SDavid Miller static inline void vsrd(S390Vector *v1, S390Vector *v2, 47*bc556c66SDavid Miller S390Vector *v3, const uint8_t I) 48*bc556c66SDavid Miller { 49*bc556c66SDavid Miller asm volatile("vsrd %[v1], %[v2], %[v3], %[I]\n" 50*bc556c66SDavid Miller : [v1] "=v" (v1->v) 51*bc556c66SDavid Miller : [v2] "v" (v2->v) 52*bc556c66SDavid Miller , [v3] "v" (v3->v) 53*bc556c66SDavid Miller , [I] "i" (I & 7)); 54*bc556c66SDavid Miller } 55*bc556c66SDavid Miller 56*bc556c66SDavid Miller int main(int argc, char *argv[]) 57*bc556c66SDavid Miller { 58*bc556c66SDavid Miller const S390Vector vt_vsl = { .d[0] = 0x7FEDBB32D5AA311Dull, 59*bc556c66SDavid Miller .d[1] = 0xBB65AA10912220C0ull }; 60*bc556c66SDavid Miller const S390Vector vt_vsra = { .d[0] = 0xF1FE6E7399AA5466ull, 61*bc556c66SDavid Miller .d[1] = 0x0E762A5188221044ull }; 62*bc556c66SDavid Miller const S390Vector vt_vsrl = { .d[0] = 0x11FE6E7399AA5466ull, 63*bc556c66SDavid Miller .d[1] = 0x0E762A5188221044ull }; 64*bc556c66SDavid Miller const S390Vector vt_vsld = { .d[0] = 0x7F76EE65DD54CC43ull, 65*bc556c66SDavid Miller .d[1] = 0xBB32AA2199108838ull }; 66*bc556c66SDavid Miller const S390Vector vt_vsrd = { .d[0] = 0x0E060802040E000Aull, 67*bc556c66SDavid Miller .d[1] = 0x0C060802040E000Aull }; 68*bc556c66SDavid Miller S390Vector vs = { .d[0] = 0x8FEEDDCCBBAA9988ull, 69*bc556c66SDavid Miller .d[1] = 0x7766554433221107ull }; 70*bc556c66SDavid Miller S390Vector vd = { .d[0] = 0, .d[1] = 0 }; 71*bc556c66SDavid Miller S390Vector vsi = { .d[0] = 0, .d[1] = 0 }; 72*bc556c66SDavid Miller 73*bc556c66SDavid Miller for (int ix = 0; ix < 16; ix++) { 74*bc556c66SDavid Miller vsi.b[ix] = (1 + (5 ^ ~ix)) & 7; 75*bc556c66SDavid Miller } 76*bc556c66SDavid Miller 77*bc556c66SDavid Miller vsl(&vd, &vs, &vsi); 78*bc556c66SDavid Miller vtst(vd, vt_vsl); 79*bc556c66SDavid Miller 80*bc556c66SDavid Miller vsra(&vd, &vs, &vsi); 81*bc556c66SDavid Miller vtst(vd, vt_vsra); 82*bc556c66SDavid Miller 83*bc556c66SDavid Miller vsrl(&vd, &vs, &vsi); 84*bc556c66SDavid Miller vtst(vd, vt_vsrl); 85*bc556c66SDavid Miller 86*bc556c66SDavid Miller vsld(&vd, &vs, &vsi, 3); 87*bc556c66SDavid Miller vtst(vd, vt_vsld); 88*bc556c66SDavid Miller 89*bc556c66SDavid Miller vsrd(&vd, &vs, &vsi, 15); 90*bc556c66SDavid Miller vtst(vd, vt_vsrd); 91*bc556c66SDavid Miller 92*bc556c66SDavid Miller return 0; 93*bc556c66SDavid Miller } 94