1fcf5ef2aSThomas Huth /* 2fcf5ef2aSThomas Huth * VIS op helpers 3fcf5ef2aSThomas Huth * 4fcf5ef2aSThomas Huth * Copyright (c) 2003-2005 Fabrice Bellard 5fcf5ef2aSThomas Huth * 6fcf5ef2aSThomas Huth * This library is free software; you can redistribute it and/or 7fcf5ef2aSThomas Huth * modify it under the terms of the GNU Lesser General Public 8fcf5ef2aSThomas Huth * License as published by the Free Software Foundation; either 95650b549SChetan Pant * version 2.1 of the License, or (at your option) any later version. 10fcf5ef2aSThomas Huth * 11fcf5ef2aSThomas Huth * This library is distributed in the hope that it will be useful, 12fcf5ef2aSThomas Huth * but WITHOUT ANY WARRANTY; without even the implied warranty of 13fcf5ef2aSThomas Huth * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14fcf5ef2aSThomas Huth * Lesser General Public License for more details. 15fcf5ef2aSThomas Huth * 16fcf5ef2aSThomas Huth * You should have received a copy of the GNU Lesser General Public 17fcf5ef2aSThomas Huth * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18fcf5ef2aSThomas Huth */ 19fcf5ef2aSThomas Huth 20fcf5ef2aSThomas Huth #include "qemu/osdep.h" 21fcf5ef2aSThomas Huth #include "cpu.h" 22fcf5ef2aSThomas Huth #include "exec/helper-proto.h" 23fcf5ef2aSThomas Huth 24fcf5ef2aSThomas Huth /* This function uses non-native bit order */ 25fcf5ef2aSThomas Huth #define GET_FIELD(X, FROM, TO) \ 26fcf5ef2aSThomas Huth ((X) >> (63 - (TO)) & ((1ULL << ((TO) - (FROM) + 1)) - 1)) 27fcf5ef2aSThomas Huth 28fcf5ef2aSThomas Huth /* This function uses the order in the manuals, i.e. bit 0 is 2^0 */ 29fcf5ef2aSThomas Huth #define GET_FIELD_SP(X, FROM, TO) \ 30fcf5ef2aSThomas Huth GET_FIELD(X, 63 - (TO), 63 - (FROM)) 31fcf5ef2aSThomas Huth 32fcf5ef2aSThomas Huth target_ulong helper_array8(target_ulong pixel_addr, target_ulong cubesize) 33fcf5ef2aSThomas Huth { 34fcf5ef2aSThomas Huth return (GET_FIELD_SP(pixel_addr, 60, 63) << (17 + 2 * cubesize)) | 35fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 39, 39 + cubesize - 1) << (17 + cubesize)) | 36fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 17 + cubesize - 1, 17) << 17) | 37fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 56, 59) << 13) | 38fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 35, 38) << 9) | 39fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 13, 16) << 5) | 40fcf5ef2aSThomas Huth (((pixel_addr >> 55) & 1) << 4) | 41fcf5ef2aSThomas Huth (GET_FIELD_SP(pixel_addr, 33, 34) << 2) | 42fcf5ef2aSThomas Huth GET_FIELD_SP(pixel_addr, 11, 12); 43fcf5ef2aSThomas Huth } 44fcf5ef2aSThomas Huth 45e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN 46fcf5ef2aSThomas Huth #define VIS_B64(n) b[7 - (n)] 47fcf5ef2aSThomas Huth #define VIS_W64(n) w[3 - (n)] 48fcf5ef2aSThomas Huth #define VIS_SW64(n) sw[3 - (n)] 49fcf5ef2aSThomas Huth #define VIS_L64(n) l[1 - (n)] 50fcf5ef2aSThomas Huth #define VIS_B32(n) b[3 - (n)] 51fcf5ef2aSThomas Huth #define VIS_W32(n) w[1 - (n)] 52fcf5ef2aSThomas Huth #else 53fcf5ef2aSThomas Huth #define VIS_B64(n) b[n] 54fcf5ef2aSThomas Huth #define VIS_W64(n) w[n] 55fcf5ef2aSThomas Huth #define VIS_SW64(n) sw[n] 56fcf5ef2aSThomas Huth #define VIS_L64(n) l[n] 57fcf5ef2aSThomas Huth #define VIS_B32(n) b[n] 58fcf5ef2aSThomas Huth #define VIS_W32(n) w[n] 59fcf5ef2aSThomas Huth #endif 60fcf5ef2aSThomas Huth 61fcf5ef2aSThomas Huth typedef union { 62fcf5ef2aSThomas Huth uint8_t b[8]; 63fcf5ef2aSThomas Huth uint16_t w[4]; 64fcf5ef2aSThomas Huth int16_t sw[4]; 65fcf5ef2aSThomas Huth uint32_t l[2]; 66fcf5ef2aSThomas Huth uint64_t ll; 67fcf5ef2aSThomas Huth float64 d; 68fcf5ef2aSThomas Huth } VIS64; 69fcf5ef2aSThomas Huth 70fcf5ef2aSThomas Huth typedef union { 71fcf5ef2aSThomas Huth uint8_t b[4]; 72fcf5ef2aSThomas Huth uint16_t w[2]; 73fcf5ef2aSThomas Huth uint32_t l; 74fcf5ef2aSThomas Huth float32 f; 75fcf5ef2aSThomas Huth } VIS32; 76fcf5ef2aSThomas Huth 77*d3ef26afSRichard Henderson uint64_t helper_fpmerge(uint32_t src1, uint32_t src2) 78fcf5ef2aSThomas Huth { 79*d3ef26afSRichard Henderson VIS32 s1, s2; 80*d3ef26afSRichard Henderson VIS64 d; 81fcf5ef2aSThomas Huth 82*d3ef26afSRichard Henderson s1.l = src1; 83*d3ef26afSRichard Henderson s2.l = src2; 84*d3ef26afSRichard Henderson d.ll = 0; 85fcf5ef2aSThomas Huth 86*d3ef26afSRichard Henderson d.VIS_B64(7) = s1.VIS_B32(3); 87*d3ef26afSRichard Henderson d.VIS_B64(6) = s2.VIS_B32(3); 88*d3ef26afSRichard Henderson d.VIS_B64(5) = s1.VIS_B32(2); 89*d3ef26afSRichard Henderson d.VIS_B64(4) = s2.VIS_B32(2); 90*d3ef26afSRichard Henderson d.VIS_B64(3) = s1.VIS_B32(1); 91*d3ef26afSRichard Henderson d.VIS_B64(2) = s2.VIS_B32(1); 92*d3ef26afSRichard Henderson d.VIS_B64(1) = s1.VIS_B32(0); 93*d3ef26afSRichard Henderson d.VIS_B64(0) = s2.VIS_B32(0); 94fcf5ef2aSThomas Huth 95fcf5ef2aSThomas Huth return d.ll; 96fcf5ef2aSThomas Huth } 97fcf5ef2aSThomas Huth 989157dcccSRichard Henderson uint64_t helper_fmul8x16(uint32_t src1, uint64_t src2) 99fcf5ef2aSThomas Huth { 1009157dcccSRichard Henderson VIS64 d; 1019157dcccSRichard Henderson VIS32 s; 102fcf5ef2aSThomas Huth uint32_t tmp; 103fcf5ef2aSThomas Huth 1049157dcccSRichard Henderson s.l = src1; 105fcf5ef2aSThomas Huth d.ll = src2; 106fcf5ef2aSThomas Huth 107fcf5ef2aSThomas Huth #define PMUL(r) \ 1089157dcccSRichard Henderson tmp = (int32_t)d.VIS_SW64(r) * (int32_t)s.VIS_B32(r); \ 109fcf5ef2aSThomas Huth if ((tmp & 0xff) > 0x7f) { \ 110fcf5ef2aSThomas Huth tmp += 0x100; \ 111fcf5ef2aSThomas Huth } \ 112fcf5ef2aSThomas Huth d.VIS_W64(r) = tmp >> 8; 113fcf5ef2aSThomas Huth 114fcf5ef2aSThomas Huth PMUL(0); 115fcf5ef2aSThomas Huth PMUL(1); 116fcf5ef2aSThomas Huth PMUL(2); 117fcf5ef2aSThomas Huth PMUL(3); 118fcf5ef2aSThomas Huth #undef PMUL 119fcf5ef2aSThomas Huth 120fcf5ef2aSThomas Huth return d.ll; 121fcf5ef2aSThomas Huth } 122fcf5ef2aSThomas Huth 123a859602cSRichard Henderson uint64_t helper_fmul8x16a(uint32_t src1, int32_t src2) 124fcf5ef2aSThomas Huth { 125a859602cSRichard Henderson VIS32 s; 126a859602cSRichard Henderson VIS64 d; 127fcf5ef2aSThomas Huth uint32_t tmp; 128fcf5ef2aSThomas Huth 129a859602cSRichard Henderson s.l = src1; 130a859602cSRichard Henderson d.ll = 0; 131fcf5ef2aSThomas Huth 132fcf5ef2aSThomas Huth #define PMUL(r) \ 133a859602cSRichard Henderson do { \ 134a859602cSRichard Henderson tmp = src2 * (int32_t)s.VIS_B32(r); \ 135fcf5ef2aSThomas Huth if ((tmp & 0xff) > 0x7f) { \ 136fcf5ef2aSThomas Huth tmp += 0x100; \ 137fcf5ef2aSThomas Huth } \ 138a859602cSRichard Henderson d.VIS_W64(r) = tmp >> 8; \ 139a859602cSRichard Henderson } while (0) 140fcf5ef2aSThomas Huth 141fcf5ef2aSThomas Huth PMUL(0); 142fcf5ef2aSThomas Huth PMUL(1); 143fcf5ef2aSThomas Huth PMUL(2); 144fcf5ef2aSThomas Huth PMUL(3); 145fcf5ef2aSThomas Huth #undef PMUL 146fcf5ef2aSThomas Huth 147fcf5ef2aSThomas Huth return d.ll; 148fcf5ef2aSThomas Huth } 149fcf5ef2aSThomas Huth 150fcf5ef2aSThomas Huth uint64_t helper_fmul8sux16(uint64_t src1, uint64_t src2) 151fcf5ef2aSThomas Huth { 152fcf5ef2aSThomas Huth VIS64 s, d; 153fcf5ef2aSThomas Huth uint32_t tmp; 154fcf5ef2aSThomas Huth 155fcf5ef2aSThomas Huth s.ll = src1; 156fcf5ef2aSThomas Huth d.ll = src2; 157fcf5ef2aSThomas Huth 158fcf5ef2aSThomas Huth #define PMUL(r) \ 159fcf5ef2aSThomas Huth tmp = (int32_t)d.VIS_SW64(r) * ((int32_t)s.VIS_SW64(r) >> 8); \ 160fcf5ef2aSThomas Huth if ((tmp & 0xff) > 0x7f) { \ 161fcf5ef2aSThomas Huth tmp += 0x100; \ 162fcf5ef2aSThomas Huth } \ 163fcf5ef2aSThomas Huth d.VIS_W64(r) = tmp >> 8; 164fcf5ef2aSThomas Huth 165fcf5ef2aSThomas Huth PMUL(0); 166fcf5ef2aSThomas Huth PMUL(1); 167fcf5ef2aSThomas Huth PMUL(2); 168fcf5ef2aSThomas Huth PMUL(3); 169fcf5ef2aSThomas Huth #undef PMUL 170fcf5ef2aSThomas Huth 171fcf5ef2aSThomas Huth return d.ll; 172fcf5ef2aSThomas Huth } 173fcf5ef2aSThomas Huth 174fcf5ef2aSThomas Huth uint64_t helper_fmul8ulx16(uint64_t src1, uint64_t src2) 175fcf5ef2aSThomas Huth { 176fcf5ef2aSThomas Huth VIS64 s, d; 177fcf5ef2aSThomas Huth uint32_t tmp; 178fcf5ef2aSThomas Huth 179fcf5ef2aSThomas Huth s.ll = src1; 180fcf5ef2aSThomas Huth d.ll = src2; 181fcf5ef2aSThomas Huth 182fcf5ef2aSThomas Huth #define PMUL(r) \ 183fcf5ef2aSThomas Huth tmp = (int32_t)d.VIS_SW64(r) * ((uint32_t)s.VIS_B64(r * 2)); \ 184fcf5ef2aSThomas Huth if ((tmp & 0xff) > 0x7f) { \ 185fcf5ef2aSThomas Huth tmp += 0x100; \ 186fcf5ef2aSThomas Huth } \ 187fcf5ef2aSThomas Huth d.VIS_W64(r) = tmp >> 8; 188fcf5ef2aSThomas Huth 189fcf5ef2aSThomas Huth PMUL(0); 190fcf5ef2aSThomas Huth PMUL(1); 191fcf5ef2aSThomas Huth PMUL(2); 192fcf5ef2aSThomas Huth PMUL(3); 193fcf5ef2aSThomas Huth #undef PMUL 194fcf5ef2aSThomas Huth 195fcf5ef2aSThomas Huth return d.ll; 196fcf5ef2aSThomas Huth } 197fcf5ef2aSThomas Huth 1987b616f36SRichard Henderson uint64_t helper_fexpand(uint32_t src2) 199fcf5ef2aSThomas Huth { 200fcf5ef2aSThomas Huth VIS32 s; 201fcf5ef2aSThomas Huth VIS64 d; 202fcf5ef2aSThomas Huth 2037b616f36SRichard Henderson s.l = src2; 2047b616f36SRichard Henderson d.ll = 0; 205fcf5ef2aSThomas Huth d.VIS_W64(0) = s.VIS_B32(0) << 4; 206fcf5ef2aSThomas Huth d.VIS_W64(1) = s.VIS_B32(1) << 4; 207fcf5ef2aSThomas Huth d.VIS_W64(2) = s.VIS_B32(2) << 4; 208fcf5ef2aSThomas Huth d.VIS_W64(3) = s.VIS_B32(3) << 4; 209fcf5ef2aSThomas Huth 210fcf5ef2aSThomas Huth return d.ll; 211fcf5ef2aSThomas Huth } 212fcf5ef2aSThomas Huth 213fcf5ef2aSThomas Huth #define VIS_CMPHELPER(name, F) \ 214fcf5ef2aSThomas Huth uint64_t name##16(uint64_t src1, uint64_t src2) \ 215fcf5ef2aSThomas Huth { \ 216fcf5ef2aSThomas Huth VIS64 s, d; \ 217fcf5ef2aSThomas Huth \ 218fcf5ef2aSThomas Huth s.ll = src1; \ 219fcf5ef2aSThomas Huth d.ll = src2; \ 220fcf5ef2aSThomas Huth \ 221fcf5ef2aSThomas Huth d.VIS_W64(0) = F(s.VIS_W64(0), d.VIS_W64(0)) ? 1 : 0; \ 222fcf5ef2aSThomas Huth d.VIS_W64(0) |= F(s.VIS_W64(1), d.VIS_W64(1)) ? 2 : 0; \ 223fcf5ef2aSThomas Huth d.VIS_W64(0) |= F(s.VIS_W64(2), d.VIS_W64(2)) ? 4 : 0; \ 224fcf5ef2aSThomas Huth d.VIS_W64(0) |= F(s.VIS_W64(3), d.VIS_W64(3)) ? 8 : 0; \ 225fcf5ef2aSThomas Huth d.VIS_W64(1) = d.VIS_W64(2) = d.VIS_W64(3) = 0; \ 226fcf5ef2aSThomas Huth \ 227fcf5ef2aSThomas Huth return d.ll; \ 228fcf5ef2aSThomas Huth } \ 229fcf5ef2aSThomas Huth \ 230fcf5ef2aSThomas Huth uint64_t name##32(uint64_t src1, uint64_t src2) \ 231fcf5ef2aSThomas Huth { \ 232fcf5ef2aSThomas Huth VIS64 s, d; \ 233fcf5ef2aSThomas Huth \ 234fcf5ef2aSThomas Huth s.ll = src1; \ 235fcf5ef2aSThomas Huth d.ll = src2; \ 236fcf5ef2aSThomas Huth \ 237fcf5ef2aSThomas Huth d.VIS_L64(0) = F(s.VIS_L64(0), d.VIS_L64(0)) ? 1 : 0; \ 238fcf5ef2aSThomas Huth d.VIS_L64(0) |= F(s.VIS_L64(1), d.VIS_L64(1)) ? 2 : 0; \ 239fcf5ef2aSThomas Huth d.VIS_L64(1) = 0; \ 240fcf5ef2aSThomas Huth \ 241fcf5ef2aSThomas Huth return d.ll; \ 242fcf5ef2aSThomas Huth } 243fcf5ef2aSThomas Huth 244fcf5ef2aSThomas Huth #define FCMPGT(a, b) ((a) > (b)) 245fcf5ef2aSThomas Huth #define FCMPEQ(a, b) ((a) == (b)) 246fcf5ef2aSThomas Huth #define FCMPLE(a, b) ((a) <= (b)) 247fcf5ef2aSThomas Huth #define FCMPNE(a, b) ((a) != (b)) 248fcf5ef2aSThomas Huth 249fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpgt, FCMPGT) 250fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpeq, FCMPEQ) 251fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmple, FCMPLE) 252fcf5ef2aSThomas Huth VIS_CMPHELPER(helper_fcmpne, FCMPNE) 253fcf5ef2aSThomas Huth 254fcf5ef2aSThomas Huth uint64_t helper_pdist(uint64_t sum, uint64_t src1, uint64_t src2) 255fcf5ef2aSThomas Huth { 256fcf5ef2aSThomas Huth int i; 257fcf5ef2aSThomas Huth for (i = 0; i < 8; i++) { 258fcf5ef2aSThomas Huth int s1, s2; 259fcf5ef2aSThomas Huth 260fcf5ef2aSThomas Huth s1 = (src1 >> (56 - (i * 8))) & 0xff; 261fcf5ef2aSThomas Huth s2 = (src2 >> (56 - (i * 8))) & 0xff; 262fcf5ef2aSThomas Huth 263fcf5ef2aSThomas Huth /* Absolute value of difference. */ 264fcf5ef2aSThomas Huth s1 -= s2; 265fcf5ef2aSThomas Huth if (s1 < 0) { 266fcf5ef2aSThomas Huth s1 = -s1; 267fcf5ef2aSThomas Huth } 268fcf5ef2aSThomas Huth 269fcf5ef2aSThomas Huth sum += s1; 270fcf5ef2aSThomas Huth } 271fcf5ef2aSThomas Huth 272fcf5ef2aSThomas Huth return sum; 273fcf5ef2aSThomas Huth } 274fcf5ef2aSThomas Huth 275fcf5ef2aSThomas Huth uint32_t helper_fpack16(uint64_t gsr, uint64_t rs2) 276fcf5ef2aSThomas Huth { 277fcf5ef2aSThomas Huth int scale = (gsr >> 3) & 0xf; 278fcf5ef2aSThomas Huth uint32_t ret = 0; 279fcf5ef2aSThomas Huth int byte; 280fcf5ef2aSThomas Huth 281fcf5ef2aSThomas Huth for (byte = 0; byte < 4; byte++) { 282fcf5ef2aSThomas Huth uint32_t val; 283fcf5ef2aSThomas Huth int16_t src = rs2 >> (byte * 16); 284fcf5ef2aSThomas Huth int32_t scaled = src << scale; 285fcf5ef2aSThomas Huth int32_t from_fixed = scaled >> 7; 286fcf5ef2aSThomas Huth 287fcf5ef2aSThomas Huth val = (from_fixed < 0 ? 0 : 288fcf5ef2aSThomas Huth from_fixed > 255 ? 255 : from_fixed); 289fcf5ef2aSThomas Huth 290fcf5ef2aSThomas Huth ret |= val << (8 * byte); 291fcf5ef2aSThomas Huth } 292fcf5ef2aSThomas Huth 293fcf5ef2aSThomas Huth return ret; 294fcf5ef2aSThomas Huth } 295fcf5ef2aSThomas Huth 296fcf5ef2aSThomas Huth uint64_t helper_fpack32(uint64_t gsr, uint64_t rs1, uint64_t rs2) 297fcf5ef2aSThomas Huth { 298fcf5ef2aSThomas Huth int scale = (gsr >> 3) & 0x1f; 299fcf5ef2aSThomas Huth uint64_t ret = 0; 300fcf5ef2aSThomas Huth int word; 301fcf5ef2aSThomas Huth 302fcf5ef2aSThomas Huth ret = (rs1 << 8) & ~(0x000000ff000000ffULL); 303fcf5ef2aSThomas Huth for (word = 0; word < 2; word++) { 304fcf5ef2aSThomas Huth uint64_t val; 305fcf5ef2aSThomas Huth int32_t src = rs2 >> (word * 32); 306fcf5ef2aSThomas Huth int64_t scaled = (int64_t)src << scale; 307fcf5ef2aSThomas Huth int64_t from_fixed = scaled >> 23; 308fcf5ef2aSThomas Huth 309fcf5ef2aSThomas Huth val = (from_fixed < 0 ? 0 : 310fcf5ef2aSThomas Huth (from_fixed > 255) ? 255 : from_fixed); 311fcf5ef2aSThomas Huth 312fcf5ef2aSThomas Huth ret |= val << (32 * word); 313fcf5ef2aSThomas Huth } 314fcf5ef2aSThomas Huth 315fcf5ef2aSThomas Huth return ret; 316fcf5ef2aSThomas Huth } 317fcf5ef2aSThomas Huth 318fcf5ef2aSThomas Huth uint32_t helper_fpackfix(uint64_t gsr, uint64_t rs2) 319fcf5ef2aSThomas Huth { 320fcf5ef2aSThomas Huth int scale = (gsr >> 3) & 0x1f; 321fcf5ef2aSThomas Huth uint32_t ret = 0; 322fcf5ef2aSThomas Huth int word; 323fcf5ef2aSThomas Huth 324fcf5ef2aSThomas Huth for (word = 0; word < 2; word++) { 325fcf5ef2aSThomas Huth uint32_t val; 326fcf5ef2aSThomas Huth int32_t src = rs2 >> (word * 32); 327fcf5ef2aSThomas Huth int64_t scaled = (int64_t)src << scale; 328fcf5ef2aSThomas Huth int64_t from_fixed = scaled >> 16; 329fcf5ef2aSThomas Huth 330fcf5ef2aSThomas Huth val = (from_fixed < -32768 ? -32768 : 331fcf5ef2aSThomas Huth from_fixed > 32767 ? 32767 : from_fixed); 332fcf5ef2aSThomas Huth 333fcf5ef2aSThomas Huth ret |= (val & 0xffff) << (word * 16); 334fcf5ef2aSThomas Huth } 335fcf5ef2aSThomas Huth 336fcf5ef2aSThomas Huth return ret; 337fcf5ef2aSThomas Huth } 338fcf5ef2aSThomas Huth 339fcf5ef2aSThomas Huth uint64_t helper_bshuffle(uint64_t gsr, uint64_t src1, uint64_t src2) 340fcf5ef2aSThomas Huth { 341fcf5ef2aSThomas Huth union { 342fcf5ef2aSThomas Huth uint64_t ll[2]; 343fcf5ef2aSThomas Huth uint8_t b[16]; 344fcf5ef2aSThomas Huth } s; 345fcf5ef2aSThomas Huth VIS64 r; 346fcf5ef2aSThomas Huth uint32_t i, mask, host; 347fcf5ef2aSThomas Huth 348fcf5ef2aSThomas Huth /* Set up S such that we can index across all of the bytes. */ 349e03b5686SMarc-André Lureau #if HOST_BIG_ENDIAN 350fcf5ef2aSThomas Huth s.ll[0] = src1; 351fcf5ef2aSThomas Huth s.ll[1] = src2; 352fcf5ef2aSThomas Huth host = 0; 353fcf5ef2aSThomas Huth #else 354fcf5ef2aSThomas Huth s.ll[1] = src1; 355fcf5ef2aSThomas Huth s.ll[0] = src2; 356fcf5ef2aSThomas Huth host = 15; 357fcf5ef2aSThomas Huth #endif 358fcf5ef2aSThomas Huth mask = gsr >> 32; 359fcf5ef2aSThomas Huth 360fcf5ef2aSThomas Huth for (i = 0; i < 8; ++i) { 361fcf5ef2aSThomas Huth unsigned e = (mask >> (28 - i*4)) & 0xf; 362fcf5ef2aSThomas Huth r.VIS_B64(i) = s.b[e ^ host]; 363fcf5ef2aSThomas Huth } 364fcf5ef2aSThomas Huth 365fcf5ef2aSThomas Huth return r.ll; 366fcf5ef2aSThomas Huth } 367