1ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 2ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*---------------------------------------------------------------*/ 3ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--- begin host_generic_simd64.c ---*/ 4ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*---------------------------------------------------------------*/ 5ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 6ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* 7ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This file is part of Valgrind, a dynamic binary instrumentation 8ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown framework. 9ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 10663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Copyright (C) 2004-2012 OpenWorks LLP 11ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown info@open-works.net 12ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 13ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This program is free software; you can redistribute it and/or 14ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown modify it under the terms of the GNU General Public License as 15ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown published by the Free Software Foundation; either version 2 of the 16ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown License, or (at your option) any later version. 17ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 18ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown This program is distributed in the hope that it will be useful, but 19ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown WITHOUT ANY WARRANTY; without even the implied warranty of 20ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 21ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown General Public License for more details. 22ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 23ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown You should have received a copy of the GNU General Public License 24ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown along with this program; if not, write to the Free Software 25ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 26ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 02110-1301, USA. 27ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 28ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown The GNU General Public License is contained in the file COPYING. 29ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 30ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Neither the names of the U.S. Department of Energy nor the 31ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown University of California nor the names of its contributors may be 32ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown used to endorse or promote products derived from this software 33ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown without prior written permission. 34ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/ 35ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 36ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Generic helper functions for doing 64-bit SIMD arithmetic in cases 37ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown where the instruction selectors cannot generate code in-line. 38ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown These are purely back-end entities and cannot be seen/referenced 39ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown from IR. */ 40ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 41ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include "libvex_basictypes.h" 42ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown#include "host_generic_simd64.h" 43ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 44ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 45ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 46ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Tuple/select functions for 32x2 vectors. */ 47ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 48ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline ULong mk32x2 ( UInt w1, UInt w0 ) { 49ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (((ULong)w1) << 32) | ((ULong)w0); 50ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 51ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 52ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt sel32x2_1 ( ULong w64 ) { 53ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return 0xFFFFFFFF & toUInt(w64 >> 32); 54ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 55ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt sel32x2_0 ( ULong w64 ) { 56ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return 0xFFFFFFFF & toUInt(w64); 57ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 58ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 59ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 60ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Tuple/select functions for 16x4 vectors. gcc is pretty hopeless 61ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown with 64-bit shifts so we give it a hand. */ 62ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 63ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline ULong mk16x4 ( UShort w3, UShort w2, 64ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort w1, UShort w0 ) { 65ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = (((UInt)w3) << 16) | ((UInt)w2); 66ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (((UInt)w1) << 16) | ((UInt)w0); 67ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2(hi32, lo32); 68ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 69ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 70ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x4_3 ( ULong w64 ) { 71ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 72ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(0xFFFF & (hi32 >> 16)); 73ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 74ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x4_2 ( ULong w64 ) { 75ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 76ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(0xFFFF & hi32); 77ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 78ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x4_1 ( ULong w64 ) { 79ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 80ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(0xFFFF & (lo32 >> 16)); 81ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 82ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x4_0 ( ULong w64 ) { 83ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 84ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(0xFFFF & lo32); 85ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 86ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 87ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 88ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Tuple/select functions for 8x8 vectors. */ 89ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 90ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline ULong mk8x8 ( UChar w7, UChar w6, 91ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UChar w5, UChar w4, 92ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UChar w3, UChar w2, 93ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UChar w1, UChar w0 ) { 94ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = (((UInt)w7) << 24) | (((UInt)w6) << 16) 95ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown | (((UInt)w5) << 8) | (((UInt)w4) << 0); 96ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (((UInt)w3) << 24) | (((UInt)w2) << 16) 97ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown | (((UInt)w1) << 8) | (((UInt)w0) << 0); 98ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2(hi32, lo32); 99ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_7 ( ULong w64 ) { 102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (hi32 >> 24)); 104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_6 ( ULong w64 ) { 106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (hi32 >> 16)); 108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 109ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_5 ( ULong w64 ) { 110ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 111ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (hi32 >> 8)); 112ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 113ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_4 ( ULong w64 ) { 114ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt hi32 = toUInt(w64 >> 32); 115ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (hi32 >> 0)); 116ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 117ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_3 ( ULong w64 ) { 118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (lo32 >> 24)); 120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_2 ( ULong w64 ) { 122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (lo32 >> 16)); 124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_1 ( ULong w64 ) { 126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (lo32 >> 8)); 128ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 129ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x8_0 ( ULong w64 ) { 130ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt lo32 = (UInt)w64; 131ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (lo32 >> 0)); 132ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 133ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 134ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar index8x8 ( ULong w64, UChar ix ) { 135ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ix &= 7; 136ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar((w64 >> (8*ix)) & 0xFF); 137ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 138ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 139ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 140ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Scalar helpers. */ 141ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 142663860b1408516d02ebfcb3a9999a134e6cfb223Ben Chengstatic inline Int qadd32S ( Int xx, Int yy ) 143663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 144663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Long t = ((Long)xx) + ((Long)yy); 145663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng const Long loLim = -0x80000000LL; 146663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng const Long hiLim = 0x7FFFFFFFLL; 147663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng if (t < loLim) t = loLim; 148663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng if (t > hiLim) t = hiLim; 149663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return (Int)t; 150663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 151663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 152ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short qadd16S ( Short xx, Short yy ) 153ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 154ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) + ((Int)yy); 155ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < -32768) t = -32768; 156ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 32767) t = 32767; 157ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)t; 158ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 159ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 160ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Char qadd8S ( Char xx, Char yy ) 161ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 162ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) + ((Int)yy); 163ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < -128) t = -128; 164ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 127) t = 127; 165ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Char)t; 166ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 167ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 168ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort qadd16U ( UShort xx, UShort yy ) 169ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 170ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt t = ((UInt)xx) + ((UInt)yy); 171ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 0xFFFF) t = 0xFFFF; 172ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)t; 173ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 174ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 175ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar qadd8U ( UChar xx, UChar yy ) 176ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 177ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt t = ((UInt)xx) + ((UInt)yy); 178ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 0xFF) t = 0xFF; 179ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)t; 180ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 181ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 182663860b1408516d02ebfcb3a9999a134e6cfb223Ben Chengstatic inline Int qsub32S ( Int xx, Int yy ) 183663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 184663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Long t = ((Long)xx) - ((Long)yy); 185663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng const Long loLim = -0x80000000LL; 186663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng const Long hiLim = 0x7FFFFFFFLL; 187663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng if (t < loLim) t = loLim; 188663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng if (t > hiLim) t = hiLim; 189663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return (Int)t; 190663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 191663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 192ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short qsub16S ( Short xx, Short yy ) 193ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 194ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) - ((Int)yy); 195ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < -32768) t = -32768; 196ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 32767) t = 32767; 197ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)t; 198ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 199ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 200ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Char qsub8S ( Char xx, Char yy ) 201ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 202ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) - ((Int)yy); 203ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < -128) t = -128; 204ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 127) t = 127; 205ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Char)t; 206ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 207ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 208ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort qsub16U ( UShort xx, UShort yy ) 209ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 210ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) - ((Int)yy); 211ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < 0) t = 0; 212ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 0xFFFF) t = 0xFFFF; 213ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)t; 214ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 215ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 216ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar qsub8U ( UChar xx, UChar yy ) 217ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 218ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) - ((Int)yy); 219ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t < 0) t = 0; 220ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (t > 0xFF) t = 0xFF; 221ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)t; 222ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 223ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 224ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short mul16 ( Short xx, Short yy ) 225ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 226ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) * ((Int)yy); 227ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)t; 228ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 229ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 230ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Int mul32 ( Int xx, Int yy ) 231ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 232ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) * ((Int)yy); 233ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Int)t; 234ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 235ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 236ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short mulhi16S ( Short xx, Short yy ) 237ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 238ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int t = ((Int)xx) * ((Int)yy); 239ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown t >>=/*s*/ 16; 240ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)t; 241ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 242ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 243ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort mulhi16U ( UShort xx, UShort yy ) 244ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 245ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt t = ((UInt)xx) * ((UInt)yy); 246ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown t >>=/*u*/ 16; 247ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)t; 248ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 249ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 250ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt cmpeq32 ( UInt xx, UInt yy ) 251ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 252ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return xx==yy ? 0xFFFFFFFF : 0; 253ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 254ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 255ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort cmpeq16 ( UShort xx, UShort yy ) 256ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 257ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(xx==yy ? 0xFFFF : 0); 258ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 259ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 260ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar cmpeq8 ( UChar xx, UChar yy ) 261ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 262ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(xx==yy ? 0xFF : 0); 263ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 264ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 265ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt cmpgt32S ( Int xx, Int yy ) 266ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 267ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return xx>yy ? 0xFFFFFFFF : 0; 268ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 269ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 270ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort cmpgt16S ( Short xx, Short yy ) 271ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 272ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(xx>yy ? 0xFFFF : 0); 273ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 274ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 275ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar cmpgt8S ( Char xx, Char yy ) 276ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 277ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(xx>yy ? 0xFF : 0); 278ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 279ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 280ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt cmpnez32 ( UInt xx ) 281ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 282ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return xx==0 ? 0 : 0xFFFFFFFF; 283ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 284ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 285ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort cmpnez16 ( UShort xx ) 286ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 287ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(xx==0 ? 0 : 0xFFFF); 288ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 289ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 290ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar cmpnez8 ( UChar xx ) 291ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 292ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(xx==0 ? 0 : 0xFF); 293ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 294ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 295b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstatic inline Short qnarrow32Sto16S ( UInt xx0 ) 296ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 297ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int xx = (Int)xx0; 298ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx < -32768) xx = -32768; 299ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx > 32767) xx = 32767; 300ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)xx; 301ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 302ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 303b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstatic inline Char qnarrow16Sto8S ( UShort xx0 ) 304ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 305ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Short xx = (Short)xx0; 306ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx < -128) xx = -128; 307ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx > 127) xx = 127; 308ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Char)xx; 309ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 310ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 311b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstatic inline UChar qnarrow16Sto8U ( UShort xx0 ) 312ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 313ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Short xx = (Short)xx0; 314ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx < 0) xx = 0; 315ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown if (xx > 255) xx = 255; 316ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)xx; 317ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 318ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 319b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstatic inline UShort narrow32to16 ( UInt xx ) 320b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov{ 321b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov return (UShort)xx; 322b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov} 323b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 324b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanovstatic inline UChar narrow16to8 ( UShort xx ) 325b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov{ 326b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov return (UChar)xx; 327b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov} 328b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 329ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* shifts: we don't care about out-of-range ones, since 330ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown that is dealt with at a higher level. */ 331ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 332ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar shl8 ( UChar v, UInt n ) 333ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 334ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(v << n); 335ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 336ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 337ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sar8 ( UChar v, UInt n ) 338ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 339ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(((Char)v) >> n); 340ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 341ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 342ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort shl16 ( UShort v, UInt n ) 343ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 344ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(v << n); 345ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 346ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 347ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort shr16 ( UShort v, UInt n ) 348ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 349ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort((((UShort)v) >> n)); 350ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 351ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 352ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sar16 ( UShort v, UInt n ) 353ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 354ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort(((Short)v) >> n); 355ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 356ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 357ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt shl32 ( UInt v, UInt n ) 358ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 359ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return v << n; 360ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 361ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 362ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt shr32 ( UInt v, UInt n ) 363ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 364ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (((UInt)v) >> n); 365ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 366ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 367ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt sar32 ( UInt v, UInt n ) 368ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 369ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return ((Int)v) >> n; 370ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 371ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 372ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar avg8U ( UChar xx, UChar yy ) 373ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 374ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 375ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 376ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi + yyi + 1) >> 1; 377ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)r; 378ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 379ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 380ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort avg16U ( UShort xx, UShort yy ) 381ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 382ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 383ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 384ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi + yyi + 1) >> 1; 385ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)r; 386ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 387ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 388ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short max16S ( Short xx, Short yy ) 389ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 390ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort((xx > yy) ? xx : yy); 391ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 392ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 393ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar max8U ( UChar xx, UChar yy ) 394ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 395ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar((xx > yy) ? xx : yy); 396ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 397ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 398ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short min16S ( Short xx, Short yy ) 399ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 400ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUShort((xx < yy) ? xx : yy); 401ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 402ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 403ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar min8U ( UChar xx, UChar yy ) 404ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 405ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar((xx < yy) ? xx : yy); 406ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 407ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 408ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort hadd16U ( UShort xx, UShort yy ) 409ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 410ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 411ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 412ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi + yyi) >> 1; 413ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)r; 414ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 415ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 416ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short hadd16S ( Short xx, Short yy ) 417ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 418ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int xxi = (Int)xx; 419ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int yyi = (Int)yy; 420ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int r = (xxi + yyi) >> 1; 421ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)r; 422ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 423ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 424ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort hsub16U ( UShort xx, UShort yy ) 425ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 426ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 427ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 428ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi - yyi) >> 1; 429ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UShort)r; 430ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 431ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 432ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Short hsub16S ( Short xx, Short yy ) 433ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 434ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int xxi = (Int)xx; 435ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int yyi = (Int)yy; 436ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int r = (xxi - yyi) >> 1; 437ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Short)r; 438ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 439ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 440ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar hadd8U ( UChar xx, UChar yy ) 441ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 442ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 443ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 444ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi + yyi) >> 1; 445ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)r; 446ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 447ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 448ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Char hadd8S ( Char xx, Char yy ) 449ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 450ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int xxi = (Int)xx; 451ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int yyi = (Int)yy; 452ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int r = (xxi + yyi) >> 1; 453ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Char)r; 454ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 455ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 456ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar hsub8U ( UChar xx, UChar yy ) 457ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 458ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxi = (UInt)xx; 459ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyi = (UInt)yy; 460ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt r = (xxi - yyi) >> 1; 461ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (UChar)r; 462ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 463ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 464ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline Char hsub8S ( Char xx, Char yy ) 465ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 466ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int xxi = (Int)xx; 467ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int yyi = (Int)yy; 468ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown Int r = (xxi - yyi) >> 1; 469ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (Char)r; 470ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 471ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 472ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt absdiff8U ( UChar xx, UChar yy ) 473ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 474ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt xxu = (UChar)xx; 475ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt yyu = (UChar)yy; 476ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return xxu >= yyu ? xxu - yyu : yyu - xxu; 477ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 478ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 479ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ----------------------------------------------------- */ 480ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Start of the externally visible functions. These simply 481ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown implement the corresponding IR primops. */ 482ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ----------------------------------------------------- */ 483ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 484ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Normal addition ------------ */ 485ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 486ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Add32x2 ( ULong xx, ULong yy ) 487ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 488ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 489ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_1(xx) + sel32x2_1(yy), 490ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_0(xx) + sel32x2_0(yy) 491ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 492ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 493ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 494ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Add16x4 ( ULong xx, ULong yy ) 495ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 496ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 497ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_3(xx) + sel16x4_3(yy) ), 498ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_2(xx) + sel16x4_2(yy) ), 499ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_1(xx) + sel16x4_1(yy) ), 500ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_0(xx) + sel16x4_0(yy) ) 501ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 502ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 503ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 504ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Add8x8 ( ULong xx, ULong yy ) 505ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 506ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 507ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_7(xx) + sel8x8_7(yy) ), 508ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_6(xx) + sel8x8_6(yy) ), 509ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_5(xx) + sel8x8_5(yy) ), 510ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_4(xx) + sel8x8_4(yy) ), 511ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_3(xx) + sel8x8_3(yy) ), 512ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_2(xx) + sel8x8_2(yy) ), 513ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_1(xx) + sel8x8_1(yy) ), 514ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_0(xx) + sel8x8_0(yy) ) 515ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 516ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 517ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 518ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Saturating addition ------------ */ 519ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 520ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QAdd16Sx4 ( ULong xx, ULong yy ) 521ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 522ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 523ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16S( sel16x4_3(xx), sel16x4_3(yy) ), 524ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16S( sel16x4_2(xx), sel16x4_2(yy) ), 525ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16S( sel16x4_1(xx), sel16x4_1(yy) ), 526ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16S( sel16x4_0(xx), sel16x4_0(yy) ) 527ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 528ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 529ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 530ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QAdd8Sx8 ( ULong xx, ULong yy ) 531ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 532ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 533ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_7(xx), sel8x8_7(yy) ), 534ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_6(xx), sel8x8_6(yy) ), 535ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_5(xx), sel8x8_5(yy) ), 536ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_4(xx), sel8x8_4(yy) ), 537ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_3(xx), sel8x8_3(yy) ), 538ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_2(xx), sel8x8_2(yy) ), 539ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_1(xx), sel8x8_1(yy) ), 540ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x8_0(xx), sel8x8_0(yy) ) 541ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 542ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 543ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 544ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QAdd16Ux4 ( ULong xx, ULong yy ) 545ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 546ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 547ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16U( sel16x4_3(xx), sel16x4_3(yy) ), 548ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16U( sel16x4_2(xx), sel16x4_2(yy) ), 549ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16U( sel16x4_1(xx), sel16x4_1(yy) ), 550ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16U( sel16x4_0(xx), sel16x4_0(yy) ) 551ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 552ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 553ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 554ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QAdd8Ux8 ( ULong xx, ULong yy ) 555ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 556ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 557ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_7(xx), sel8x8_7(yy) ), 558ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_6(xx), sel8x8_6(yy) ), 559ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_5(xx), sel8x8_5(yy) ), 560ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_4(xx), sel8x8_4(yy) ), 561ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_3(xx), sel8x8_3(yy) ), 562ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_2(xx), sel8x8_2(yy) ), 563ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_1(xx), sel8x8_1(yy) ), 564ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x8_0(xx), sel8x8_0(yy) ) 565ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 566ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 567ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 568ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Normal subtraction ------------ */ 569ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 570ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Sub32x2 ( ULong xx, ULong yy ) 571ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 572ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 573ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_1(xx) - sel32x2_1(yy), 574ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_0(xx) - sel32x2_0(yy) 575ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 576ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 577ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 578ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Sub16x4 ( ULong xx, ULong yy ) 579ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 580ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 581ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_3(xx) - sel16x4_3(yy) ), 582ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_2(xx) - sel16x4_2(yy) ), 583ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_1(xx) - sel16x4_1(yy) ), 584ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUShort( sel16x4_0(xx) - sel16x4_0(yy) ) 585ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 586ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 587ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 588ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Sub8x8 ( ULong xx, ULong yy ) 589ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 590ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 591ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_7(xx) - sel8x8_7(yy) ), 592ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_6(xx) - sel8x8_6(yy) ), 593ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_5(xx) - sel8x8_5(yy) ), 594ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_4(xx) - sel8x8_4(yy) ), 595ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_3(xx) - sel8x8_3(yy) ), 596ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_2(xx) - sel8x8_2(yy) ), 597ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_1(xx) - sel8x8_1(yy) ), 598ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown toUChar( sel8x8_0(xx) - sel8x8_0(yy) ) 599ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 600ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 601ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 602ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Saturating subtraction ------------ */ 603ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 604ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QSub16Sx4 ( ULong xx, ULong yy ) 605ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 606ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 607ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16S( sel16x4_3(xx), sel16x4_3(yy) ), 608ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16S( sel16x4_2(xx), sel16x4_2(yy) ), 609ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16S( sel16x4_1(xx), sel16x4_1(yy) ), 610ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16S( sel16x4_0(xx), sel16x4_0(yy) ) 611ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 612ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 613ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 614ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QSub8Sx8 ( ULong xx, ULong yy ) 615ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 616ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 617ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_7(xx), sel8x8_7(yy) ), 618ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_6(xx), sel8x8_6(yy) ), 619ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_5(xx), sel8x8_5(yy) ), 620ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_4(xx), sel8x8_4(yy) ), 621ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_3(xx), sel8x8_3(yy) ), 622ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_2(xx), sel8x8_2(yy) ), 623ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_1(xx), sel8x8_1(yy) ), 624ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x8_0(xx), sel8x8_0(yy) ) 625ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 626ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 627ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 628ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QSub16Ux4 ( ULong xx, ULong yy ) 629ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 630ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 631ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16U( sel16x4_3(xx), sel16x4_3(yy) ), 632ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16U( sel16x4_2(xx), sel16x4_2(yy) ), 633ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16U( sel16x4_1(xx), sel16x4_1(yy) ), 634ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16U( sel16x4_0(xx), sel16x4_0(yy) ) 635ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 636ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 637ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 638ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_QSub8Ux8 ( ULong xx, ULong yy ) 639ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 640ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 641ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_7(xx), sel8x8_7(yy) ), 642ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_6(xx), sel8x8_6(yy) ), 643ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_5(xx), sel8x8_5(yy) ), 644ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_4(xx), sel8x8_4(yy) ), 645ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_3(xx), sel8x8_3(yy) ), 646ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_2(xx), sel8x8_2(yy) ), 647ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_1(xx), sel8x8_1(yy) ), 648ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x8_0(xx), sel8x8_0(yy) ) 649ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 650ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 651ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 652ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Multiplication ------------ */ 653ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 654ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Mul16x4 ( ULong xx, ULong yy ) 655ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 656ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 657ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul16( sel16x4_3(xx), sel16x4_3(yy) ), 658ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul16( sel16x4_2(xx), sel16x4_2(yy) ), 659ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul16( sel16x4_1(xx), sel16x4_1(yy) ), 660ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul16( sel16x4_0(xx), sel16x4_0(yy) ) 661ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 662ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 663ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 664ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Mul32x2 ( ULong xx, ULong yy ) 665ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 666ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 667ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul32( sel32x2_1(xx), sel32x2_1(yy) ), 668ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mul32( sel32x2_0(xx), sel32x2_0(yy) ) 669ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 670ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 671ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 672ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_MulHi16Sx4 ( ULong xx, ULong yy ) 673ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 674ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 675ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16S( sel16x4_3(xx), sel16x4_3(yy) ), 676ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16S( sel16x4_2(xx), sel16x4_2(yy) ), 677ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16S( sel16x4_1(xx), sel16x4_1(yy) ), 678ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16S( sel16x4_0(xx), sel16x4_0(yy) ) 679ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 680ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 681ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 682ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_MulHi16Ux4 ( ULong xx, ULong yy ) 683ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 684ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 685ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16U( sel16x4_3(xx), sel16x4_3(yy) ), 686ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16U( sel16x4_2(xx), sel16x4_2(yy) ), 687ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16U( sel16x4_1(xx), sel16x4_1(yy) ), 688ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown mulhi16U( sel16x4_0(xx), sel16x4_0(yy) ) 689ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 690ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 691ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 692ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Comparison ------------ */ 693ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 694ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpEQ32x2 ( ULong xx, ULong yy ) 695ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 696ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 697ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq32( sel32x2_1(xx), sel32x2_1(yy) ), 698ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq32( sel32x2_0(xx), sel32x2_0(yy) ) 699ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 700ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 701ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 702ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpEQ16x4 ( ULong xx, ULong yy ) 703ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 704ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 705ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq16( sel16x4_3(xx), sel16x4_3(yy) ), 706ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq16( sel16x4_2(xx), sel16x4_2(yy) ), 707ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq16( sel16x4_1(xx), sel16x4_1(yy) ), 708ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq16( sel16x4_0(xx), sel16x4_0(yy) ) 709ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 710ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 711ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 712ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpEQ8x8 ( ULong xx, ULong yy ) 713ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 714ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 715ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_7(xx), sel8x8_7(yy) ), 716ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_6(xx), sel8x8_6(yy) ), 717ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_5(xx), sel8x8_5(yy) ), 718ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_4(xx), sel8x8_4(yy) ), 719ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_3(xx), sel8x8_3(yy) ), 720ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_2(xx), sel8x8_2(yy) ), 721ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_1(xx), sel8x8_1(yy) ), 722ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpeq8( sel8x8_0(xx), sel8x8_0(yy) ) 723ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 724ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 725ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 726ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpGT32Sx2 ( ULong xx, ULong yy ) 727ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 728ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 729ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt32S( sel32x2_1(xx), sel32x2_1(yy) ), 730ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt32S( sel32x2_0(xx), sel32x2_0(yy) ) 731ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 732ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 733ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 734ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpGT16Sx4 ( ULong xx, ULong yy ) 735ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 736ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 737ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt16S( sel16x4_3(xx), sel16x4_3(yy) ), 738ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt16S( sel16x4_2(xx), sel16x4_2(yy) ), 739ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt16S( sel16x4_1(xx), sel16x4_1(yy) ), 740ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt16S( sel16x4_0(xx), sel16x4_0(yy) ) 741ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 742ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 743ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 744ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpGT8Sx8 ( ULong xx, ULong yy ) 745ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 746ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 747ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_7(xx), sel8x8_7(yy) ), 748ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_6(xx), sel8x8_6(yy) ), 749ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_5(xx), sel8x8_5(yy) ), 750ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_4(xx), sel8x8_4(yy) ), 751ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_3(xx), sel8x8_3(yy) ), 752ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_2(xx), sel8x8_2(yy) ), 753ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_1(xx), sel8x8_1(yy) ), 754ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpgt8S( sel8x8_0(xx), sel8x8_0(yy) ) 755ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 756ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 757ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 758ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpNEZ32x2 ( ULong xx ) 759ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 760ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 761ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez32( sel32x2_1(xx) ), 762ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez32( sel32x2_0(xx) ) 763ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 764ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 765ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 766ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpNEZ16x4 ( ULong xx ) 767ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 768ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 769ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x4_3(xx) ), 770ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x4_2(xx) ), 771ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x4_1(xx) ), 772ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x4_0(xx) ) 773ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 774ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 775ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 776ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CmpNEZ8x8 ( ULong xx ) 777ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 778ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 779ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_7(xx) ), 780ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_6(xx) ), 781ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_5(xx) ), 782ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_4(xx) ), 783ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_3(xx) ), 784ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_2(xx) ), 785ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_1(xx) ), 786ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x8_0(xx) ) 787ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 788ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 789ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 790ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Saturating narrowing ------------ */ 791ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 792b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy StepanovULong h_generic_calc_QNarrowBin32Sto16Sx4 ( ULong aa, ULong bb ) 793ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 794ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt d = sel32x2_1(aa); 795ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt c = sel32x2_0(aa); 796ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt b = sel32x2_1(bb); 797ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt a = sel32x2_0(bb); 798ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 799b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow32Sto16S(d), 800b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow32Sto16S(c), 801b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow32Sto16S(b), 802b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow32Sto16S(a) 803b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov ); 804b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov} 805b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 806b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy StepanovULong h_generic_calc_QNarrowBin16Sto8Sx8 ( ULong aa, ULong bb ) 807b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov{ 808b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort h = sel16x4_3(aa); 809b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort g = sel16x4_2(aa); 810b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort f = sel16x4_1(aa); 811b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort e = sel16x4_0(aa); 812b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort d = sel16x4_3(bb); 813b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort c = sel16x4_2(bb); 814b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort b = sel16x4_1(bb); 815b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UShort a = sel16x4_0(bb); 816b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov return mk8x8( 817b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(h), 818b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(g), 819b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(f), 820b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(e), 821b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(d), 822b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(c), 823b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(b), 824b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8S(a) 825ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 826ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 827ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 828b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy StepanovULong h_generic_calc_QNarrowBin16Sto8Ux8 ( ULong aa, ULong bb ) 829ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 830ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort h = sel16x4_3(aa); 831ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort g = sel16x4_2(aa); 832ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort f = sel16x4_1(aa); 833ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort e = sel16x4_0(aa); 834ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort d = sel16x4_3(bb); 835ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort c = sel16x4_2(bb); 836ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort b = sel16x4_1(bb); 837ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort a = sel16x4_0(bb); 838ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 839b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(h), 840b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(g), 841b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(f), 842b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(e), 843b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(d), 844b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(c), 845b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(b), 846b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov qnarrow16Sto8U(a) 847b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov ); 848b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov} 849b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 850b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov/* ------------ Truncating narrowing ------------ */ 851b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov 852b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy StepanovULong h_generic_calc_NarrowBin32to16x4 ( ULong aa, ULong bb ) 853b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov{ 854b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UInt d = sel32x2_1(aa); 855b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UInt c = sel32x2_0(aa); 856b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UInt b = sel32x2_1(bb); 857b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov UInt a = sel32x2_0(bb); 858b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov return mk16x4( 859b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow32to16(d), 860b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow32to16(c), 861b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow32to16(b), 862b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow32to16(a) 863ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 864ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 865ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 866b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy StepanovULong h_generic_calc_NarrowBin16to8x8 ( ULong aa, ULong bb ) 867ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 868ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort h = sel16x4_3(aa); 869ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort g = sel16x4_2(aa); 870ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort f = sel16x4_1(aa); 871ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort e = sel16x4_0(aa); 872ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort d = sel16x4_3(bb); 873ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort c = sel16x4_2(bb); 874ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort b = sel16x4_1(bb); 875ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UShort a = sel16x4_0(bb); 876ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 877b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(h), 878b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(g), 879b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(f), 880b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(e), 881b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(d), 882b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(c), 883b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(b), 884b32f58018498ea2225959b0ba11c18f0c433deefEvgeniy Stepanov narrow16to8(a) 885ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 886ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 887ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 888ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Interleaving ------------ */ 889ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 890ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveHI8x8 ( ULong aa, ULong bb ) 891ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 892ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 893ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_7(aa), 894ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_7(bb), 895ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_6(aa), 896ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_6(bb), 897ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_5(aa), 898ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_5(bb), 899ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_4(aa), 900ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_4(bb) 901ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 902ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 903ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 904ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveLO8x8 ( ULong aa, ULong bb ) 905ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 906ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 907ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_3(aa), 908ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_3(bb), 909ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_2(aa), 910ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_2(bb), 911ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_1(aa), 912ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_1(bb), 913ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_0(aa), 914ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x8_0(bb) 915ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 916ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 917ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 918ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveHI16x4 ( ULong aa, ULong bb ) 919ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 920ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 921ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_3(aa), 922ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_3(bb), 923ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_2(aa), 924ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_2(bb) 925ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 926ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 927ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 928ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveLO16x4 ( ULong aa, ULong bb ) 929ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 930ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 931ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_1(aa), 932ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_1(bb), 933ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_0(aa), 934ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_0(bb) 935ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 936ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 937ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 938ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveHI32x2 ( ULong aa, ULong bb ) 939ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 940ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 941ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_1(aa), 942ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_1(bb) 943ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 944ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 945ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 946ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_InterleaveLO32x2 ( ULong aa, ULong bb ) 947ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 948ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 949ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_0(aa), 950ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel32x2_0(bb) 951ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 952ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 953ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 954ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Concatenation ------------ */ 955ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 956ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CatOddLanes16x4 ( ULong aa, ULong bb ) 957ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 958ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 959ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_3(aa), 960ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_1(aa), 961ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_3(bb), 962ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_1(bb) 963ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 964ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 965ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 966ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_CatEvenLanes16x4 ( ULong aa, ULong bb ) 967ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 968ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 969ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_2(aa), 970ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_0(aa), 971ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_2(bb), 972ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x4_0(bb) 973ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 974ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 975ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 976ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* misc hack looking for a proper home */ 977ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Perm8x8 ( ULong aa, ULong bb ) 978ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 979ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 980ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_7(bb)), 981ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_6(bb)), 982ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_5(bb)), 983ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_4(bb)), 984ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_3(bb)), 985ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_2(bb)), 986ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_1(bb)), 987ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown index8x8(aa, sel8x8_0(bb)) 988ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 989ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 990ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 991ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Shifting ------------ */ 992ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Note that because these primops are undefined if the shift amount 993ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown equals or exceeds the lane width, the shift amount is masked so 994ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown that the scalar shifts are always in range. In fact, given the 995ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown semantics of these primops (ShlN16x4, etc) it is an error if in 996ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown fact we are ever given an out-of-range shift amount. 997ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown*/ 998ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_ShlN32x2 ( ULong xx, UInt nn ) 999ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1000ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 32); */ 1001ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 31; 1002ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 1003ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl32( sel32x2_1(xx), nn ), 1004ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl32( sel32x2_0(xx), nn ) 1005ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1006ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1007ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1008ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_ShlN16x4 ( ULong xx, UInt nn ) 1009ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1010ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 16); */ 1011ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 15; 1012ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1013ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl16( sel16x4_3(xx), nn ), 1014ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl16( sel16x4_2(xx), nn ), 1015ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl16( sel16x4_1(xx), nn ), 1016ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl16( sel16x4_0(xx), nn ) 1017ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1018ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1019ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1020ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_ShlN8x8 ( ULong xx, UInt nn ) 1021ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1022ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 8); */ 1023ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 7; 1024ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 1025ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_7(xx), nn ), 1026ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_6(xx), nn ), 1027ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_5(xx), nn ), 1028ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_4(xx), nn ), 1029ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_3(xx), nn ), 1030ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_2(xx), nn ), 1031ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_1(xx), nn ), 1032ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shl8( sel8x8_0(xx), nn ) 1033ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1034ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1035ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1036ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_ShrN32x2 ( ULong xx, UInt nn ) 1037ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1038ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 32); */ 1039ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 31; 1040ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 1041ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr32( sel32x2_1(xx), nn ), 1042ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr32( sel32x2_0(xx), nn ) 1043ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1044ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1045ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1046ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_ShrN16x4 ( ULong xx, UInt nn ) 1047ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1048ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 16); */ 1049ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 15; 1050ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1051ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr16( sel16x4_3(xx), nn ), 1052ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr16( sel16x4_2(xx), nn ), 1053ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr16( sel16x4_1(xx), nn ), 1054ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown shr16( sel16x4_0(xx), nn ) 1055ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1056ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1057ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1058ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_SarN32x2 ( ULong xx, UInt nn ) 1059ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1060ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 32); */ 1061ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 31; 1062ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk32x2( 1063ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar32( sel32x2_1(xx), nn ), 1064ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar32( sel32x2_0(xx), nn ) 1065ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1066ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1067ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1068ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_SarN16x4 ( ULong xx, UInt nn ) 1069ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1070ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 16); */ 1071ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 15; 1072ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1073ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar16( sel16x4_3(xx), nn ), 1074ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar16( sel16x4_2(xx), nn ), 1075ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar16( sel16x4_1(xx), nn ), 1076ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar16( sel16x4_0(xx), nn ) 1077ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1078ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1079ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1080ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_SarN8x8 ( ULong xx, UInt nn ) 1081ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1082ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown /* vassert(nn < 8); */ 1083ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown nn &= 7; 1084ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 1085ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_7(xx), nn ), 1086ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_6(xx), nn ), 1087ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_5(xx), nn ), 1088ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_4(xx), nn ), 1089ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_3(xx), nn ), 1090ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_2(xx), nn ), 1091ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_1(xx), nn ), 1092ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sar8( sel8x8_0(xx), nn ) 1093ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1094ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1095ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1096ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ Averaging ------------ */ 1097ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1098ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Avg8Ux8 ( ULong xx, ULong yy ) 1099ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1100ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 1101ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_7(xx), sel8x8_7(yy) ), 1102ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_6(xx), sel8x8_6(yy) ), 1103ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_5(xx), sel8x8_5(yy) ), 1104ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_4(xx), sel8x8_4(yy) ), 1105ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_3(xx), sel8x8_3(yy) ), 1106ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_2(xx), sel8x8_2(yy) ), 1107ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_1(xx), sel8x8_1(yy) ), 1108ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg8U( sel8x8_0(xx), sel8x8_0(yy) ) 1109ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1110ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1111ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1112ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Avg16Ux4 ( ULong xx, ULong yy ) 1113ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1114ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1115ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg16U( sel16x4_3(xx), sel16x4_3(yy) ), 1116ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg16U( sel16x4_2(xx), sel16x4_2(yy) ), 1117ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg16U( sel16x4_1(xx), sel16x4_1(yy) ), 1118ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown avg16U( sel16x4_0(xx), sel16x4_0(yy) ) 1119ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1120ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1121ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1122ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ max/min ------------ */ 1123ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1124ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Max16Sx4 ( ULong xx, ULong yy ) 1125ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1126ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1127ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max16S( sel16x4_3(xx), sel16x4_3(yy) ), 1128ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max16S( sel16x4_2(xx), sel16x4_2(yy) ), 1129ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max16S( sel16x4_1(xx), sel16x4_1(yy) ), 1130ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max16S( sel16x4_0(xx), sel16x4_0(yy) ) 1131ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1132ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1133ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1134ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Max8Ux8 ( ULong xx, ULong yy ) 1135ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1136ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 1137ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_7(xx), sel8x8_7(yy) ), 1138ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_6(xx), sel8x8_6(yy) ), 1139ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_5(xx), sel8x8_5(yy) ), 1140ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_4(xx), sel8x8_4(yy) ), 1141ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_3(xx), sel8x8_3(yy) ), 1142ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_2(xx), sel8x8_2(yy) ), 1143ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_1(xx), sel8x8_1(yy) ), 1144ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown max8U( sel8x8_0(xx), sel8x8_0(yy) ) 1145ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1146ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1147ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1148ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Min16Sx4 ( ULong xx, ULong yy ) 1149ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1150ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x4( 1151ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min16S( sel16x4_3(xx), sel16x4_3(yy) ), 1152ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min16S( sel16x4_2(xx), sel16x4_2(yy) ), 1153ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min16S( sel16x4_1(xx), sel16x4_1(yy) ), 1154ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min16S( sel16x4_0(xx), sel16x4_0(yy) ) 1155ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1156ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1157ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1158ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownULong h_generic_calc_Min8Ux8 ( ULong xx, ULong yy ) 1159ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1160ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x8( 1161ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_7(xx), sel8x8_7(yy) ), 1162ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_6(xx), sel8x8_6(yy) ), 1163ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_5(xx), sel8x8_5(yy) ), 1164ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_4(xx), sel8x8_4(yy) ), 1165ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_3(xx), sel8x8_3(yy) ), 1166ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_2(xx), sel8x8_2(yy) ), 1167ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_1(xx), sel8x8_1(yy) ), 1168ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown min8U( sel8x8_0(xx), sel8x8_0(yy) ) 1169ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1170ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1171ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1172ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------------ SOME 32-bit SIMD HELPERS TOO ------------ */ 1173ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1174ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* Tuple/select functions for 16x2 vectors. */ 1175ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt mk16x2 ( UShort w1, UShort w2 ) { 1176ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return (((UInt)w1) << 16) | ((UInt)w2); 1177ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1178ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1179ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x2_1 ( UInt w32 ) { 1180ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return 0xFFFF & (UShort)(w32 >> 16); 1181ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1182ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UShort sel16x2_0 ( UInt w32 ) { 1183ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return 0xFFFF & (UShort)(w32); 1184ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1185ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1186ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UInt mk8x4 ( UChar w3, UChar w2, 1187ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UChar w1, UChar w0 ) { 1188ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown UInt w32 = (((UInt)w3) << 24) | (((UInt)w2) << 16) 1189ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown | (((UInt)w1) << 8) | (((UInt)w0) << 0); 1190ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return w32; 1191ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1192ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1193ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x4_3 ( UInt w32 ) { 1194ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (w32 >> 24)); 1195ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1196ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x4_2 ( UInt w32 ) { 1197ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (w32 >> 16)); 1198ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1199ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x4_1 ( UInt w32 ) { 1200ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (w32 >> 8)); 1201ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1202ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brownstatic inline UChar sel8x4_0 ( UInt w32 ) { 1203ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return toUChar(0xFF & (w32 >> 0)); 1204ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1205ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1206ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1207ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ----------------------------------------------------- */ 1208ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* More externally visible functions. These simply 1209ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown implement the corresponding IR primops. */ 1210ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ----------------------------------------------------- */ 1211ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1212ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------ 16x2 ------ */ 1213ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1214ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_Add16x2 ( UInt xx, UInt yy ) 1215ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1216ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( sel16x2_1(xx) + sel16x2_1(yy), 1217ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x2_0(xx) + sel16x2_0(yy) ); 1218ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1219ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1220ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_Sub16x2 ( UInt xx, UInt yy ) 1221ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1222ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( sel16x2_1(xx) - sel16x2_1(yy), 1223ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel16x2_0(xx) - sel16x2_0(yy) ); 1224ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1225ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1226ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HAdd16Ux2 ( UInt xx, UInt yy ) 1227ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1228ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( hadd16U( sel16x2_1(xx), sel16x2_1(yy) ), 1229ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd16U( sel16x2_0(xx), sel16x2_0(yy) ) ); 1230ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1231ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1232ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HAdd16Sx2 ( UInt xx, UInt yy ) 1233ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1234ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( hadd16S( sel16x2_1(xx), sel16x2_1(yy) ), 1235ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd16S( sel16x2_0(xx), sel16x2_0(yy) ) ); 1236ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1237ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1238ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HSub16Ux2 ( UInt xx, UInt yy ) 1239ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1240ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( hsub16U( sel16x2_1(xx), sel16x2_1(yy) ), 1241ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub16U( sel16x2_0(xx), sel16x2_0(yy) ) ); 1242ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1243ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1244ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HSub16Sx2 ( UInt xx, UInt yy ) 1245ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1246ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( hsub16S( sel16x2_1(xx), sel16x2_1(yy) ), 1247ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub16S( sel16x2_0(xx), sel16x2_0(yy) ) ); 1248ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1249ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1250ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QAdd16Ux2 ( UInt xx, UInt yy ) 1251ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1252ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( qadd16U( sel16x2_1(xx), sel16x2_1(yy) ), 1253ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16U( sel16x2_0(xx), sel16x2_0(yy) ) ); 1254ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1255ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1256ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QAdd16Sx2 ( UInt xx, UInt yy ) 1257ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1258ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( qadd16S( sel16x2_1(xx), sel16x2_1(yy) ), 1259ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd16S( sel16x2_0(xx), sel16x2_0(yy) ) ); 1260ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1261ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1262ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QSub16Ux2 ( UInt xx, UInt yy ) 1263ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1264ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( qsub16U( sel16x2_1(xx), sel16x2_1(yy) ), 1265ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16U( sel16x2_0(xx), sel16x2_0(yy) ) ); 1266ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1267ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1268ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QSub16Sx2 ( UInt xx, UInt yy ) 1269ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1270ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( qsub16S( sel16x2_1(xx), sel16x2_1(yy) ), 1271ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub16S( sel16x2_0(xx), sel16x2_0(yy) ) ); 1272ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1273ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1274ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/* ------ 8x4 ------ */ 1275ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1276ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_Add8x4 ( UInt xx, UInt yy ) 1277ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1278ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1279ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_3(xx) + sel8x4_3(yy), 1280ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_2(xx) + sel8x4_2(yy), 1281ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_1(xx) + sel8x4_1(yy), 1282ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_0(xx) + sel8x4_0(yy) 1283ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1284ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1285ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1286ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_Sub8x4 ( UInt xx, UInt yy ) 1287ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1288ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1289ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_3(xx) - sel8x4_3(yy), 1290ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_2(xx) - sel8x4_2(yy), 1291ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_1(xx) - sel8x4_1(yy), 1292ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown sel8x4_0(xx) - sel8x4_0(yy) 1293ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1294ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1295ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1296ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HAdd8Ux4 ( UInt xx, UInt yy ) 1297ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1298ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1299ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8U( sel8x4_3(xx), sel8x4_3(yy) ), 1300ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8U( sel8x4_2(xx), sel8x4_2(yy) ), 1301ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8U( sel8x4_1(xx), sel8x4_1(yy) ), 1302ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8U( sel8x4_0(xx), sel8x4_0(yy) ) 1303ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1304ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1305ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1306ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HAdd8Sx4 ( UInt xx, UInt yy ) 1307ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1308ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1309ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8S( sel8x4_3(xx), sel8x4_3(yy) ), 1310ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8S( sel8x4_2(xx), sel8x4_2(yy) ), 1311ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8S( sel8x4_1(xx), sel8x4_1(yy) ), 1312ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hadd8S( sel8x4_0(xx), sel8x4_0(yy) ) 1313ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1314ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1315ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1316ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HSub8Ux4 ( UInt xx, UInt yy ) 1317ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1318ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1319ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8U( sel8x4_3(xx), sel8x4_3(yy) ), 1320ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8U( sel8x4_2(xx), sel8x4_2(yy) ), 1321ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8U( sel8x4_1(xx), sel8x4_1(yy) ), 1322ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8U( sel8x4_0(xx), sel8x4_0(yy) ) 1323ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1324ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1325ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1326ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_HSub8Sx4 ( UInt xx, UInt yy ) 1327ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1328ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1329ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8S( sel8x4_3(xx), sel8x4_3(yy) ), 1330ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8S( sel8x4_2(xx), sel8x4_2(yy) ), 1331ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8S( sel8x4_1(xx), sel8x4_1(yy) ), 1332ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown hsub8S( sel8x4_0(xx), sel8x4_0(yy) ) 1333ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1334ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1335ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1336ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QAdd8Ux4 ( UInt xx, UInt yy ) 1337ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1338ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1339ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x4_3(xx), sel8x4_3(yy) ), 1340ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x4_2(xx), sel8x4_2(yy) ), 1341ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x4_1(xx), sel8x4_1(yy) ), 1342ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8U( sel8x4_0(xx), sel8x4_0(yy) ) 1343ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1344ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1345ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1346ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QAdd8Sx4 ( UInt xx, UInt yy ) 1347ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1348ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1349ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x4_3(xx), sel8x4_3(yy) ), 1350ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x4_2(xx), sel8x4_2(yy) ), 1351ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x4_1(xx), sel8x4_1(yy) ), 1352ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qadd8S( sel8x4_0(xx), sel8x4_0(yy) ) 1353ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1354ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1355ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1356ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QSub8Ux4 ( UInt xx, UInt yy ) 1357ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1358ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1359ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x4_3(xx), sel8x4_3(yy) ), 1360ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x4_2(xx), sel8x4_2(yy) ), 1361ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x4_1(xx), sel8x4_1(yy) ), 1362ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8U( sel8x4_0(xx), sel8x4_0(yy) ) 1363ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1364ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1365ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1366ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_QSub8Sx4 ( UInt xx, UInt yy ) 1367ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1368ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1369ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x4_3(xx), sel8x4_3(yy) ), 1370ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x4_2(xx), sel8x4_2(yy) ), 1371ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x4_1(xx), sel8x4_1(yy) ), 1372ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown qsub8S( sel8x4_0(xx), sel8x4_0(yy) ) 1373ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1374ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1375ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1376ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_CmpNEZ16x2 ( UInt xx ) 1377ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1378ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk16x2( 1379ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x2_1(xx) ), 1380ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez16( sel16x2_0(xx) ) 1381ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1382ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1383ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1384ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_CmpNEZ8x4 ( UInt xx ) 1385ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1386ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return mk8x4( 1387ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x4_3(xx) ), 1388ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x4_2(xx) ), 1389ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x4_1(xx) ), 1390ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown cmpnez8( sel8x4_0(xx) ) 1391ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown ); 1392ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1393ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1394ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff BrownUInt h_generic_calc_Sad8Ux4 ( UInt xx, UInt yy ) 1395ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown{ 1396ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown return absdiff8U( sel8x4_3(xx), sel8x4_3(yy) ) 1397ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown + absdiff8U( sel8x4_2(xx), sel8x4_2(yy) ) 1398ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown + absdiff8U( sel8x4_1(xx), sel8x4_1(yy) ) 1399ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown + absdiff8U( sel8x4_0(xx), sel8x4_0(yy) ); 1400ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown} 1401ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1402663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengUInt h_generic_calc_QAdd32S ( UInt xx, UInt yy ) 1403663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1404663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return qadd32S( xx, yy ); 1405663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1406663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1407663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengUInt h_generic_calc_QSub32S ( UInt xx, UInt yy ) 1408663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1409663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return qsub32S( xx, yy ); 1410663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1411663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1412663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1413663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng/*------------------------------------------------------------------*/ 1414663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng/* Decimal Floating Point (DFP) externally visible helper functions */ 1415663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng/* that implement Iop_BCDtoDPB and Iop_DPBtoBCD */ 1416663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng/*------------------------------------------------------------------*/ 1417663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1418663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#define NOT( x ) ( ( ( x ) == 0) ? 1 : 0) 1419663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#define GET( x, y ) ( ( ( x ) & ( 0x1UL << ( y ) ) ) >> ( y ) ) 1420663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#define PUT( x, y ) ( ( x )<< ( y ) ) 1421663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1422663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengULong dpb_to_bcd( ULong chunk ) 1423663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1424663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Short a, b, c, d, e, f, g, h, i, j, k, m; 1425663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Short p, q, r, s, t, u, v, w, x, y; 1426663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong value; 1427663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1428663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng /* convert 10 bit densely packed BCD to BCD */ 1429663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng p = GET( chunk, 9 ); 1430663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng q = GET( chunk, 8 ); 1431663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng r = GET( chunk, 7 ); 1432663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng s = GET( chunk, 6 ); 1433663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng t = GET( chunk, 5 ); 1434663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng u = GET( chunk, 4 ); 1435663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng v = GET( chunk, 3 ); 1436663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng w = GET( chunk, 2 ); 1437663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng x = GET( chunk, 1 ); 1438663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng y = GET( chunk, 0 ); 1439663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1440663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng /* The BCD bit values are given by the following boolean equations.*/ 1441663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng a = ( NOT(s) & v & w ) | ( t & v & w & s ) | ( v & w & NOT(x) ); 1442663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng b = ( p & s & x & NOT(t) ) | ( p & NOT(w) ) | ( p & NOT(v) ); 1443663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng c = ( q & s & x & NOT(t) ) | ( q & NOT(w) ) | ( q & NOT(v) ); 1444663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng d = r; 1445663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng e = ( v & NOT(w) & x ) | ( s & v & w & x ) | ( NOT(t) & v & x & w ); 1446663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng f = ( p & t & v & w & x & NOT(s) ) | ( s & NOT(x) & v ) | ( s & NOT(v) ); 1447663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng g = ( q & t & w & v & x & NOT(s) ) | ( t & NOT(x) & v ) | ( t & NOT(v) ); 1448663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng h = u; 1449663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng i = ( t & v & w & x ) | ( s & v & w & x ) | ( v & NOT(w) & NOT(x) ); 1450663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng j = ( p & NOT(s) & NOT(t) & w & v ) | ( s & v & NOT(w) & x ) 1451663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | ( p & w & NOT(x) & v ) | ( w & NOT(v) ); 1452663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng k = ( q & NOT(s) & NOT(t) & v & w ) | ( t & v & NOT(w) & x ) 1453663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | ( q & v & w & NOT(x) ) | ( x & NOT(v) ); 1454663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng m = y; 1455663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1456663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng value = PUT(a, 11) | PUT(b, 10) | PUT(c, 9) | PUT(d, 8) | PUT(e, 7) 1457663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | PUT(f, 6) | PUT(g, 5) | PUT(h, 4) | PUT(i, 3) | PUT(j, 2) 1458663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | PUT(k, 1) | PUT(m, 0); 1459663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return value; 1460663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1461663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1462663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengULong bcd_to_dpb( ULong chunk ) 1463663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1464663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Short a, b, c, d, e, f, g, h, i, j, k, m; 1465663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Short p, q, r, s, t, u, v, w, x, y; 1466663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong value; 1467663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng /* Convert a 3 digit BCD value to a 10 bit Densely Packed Binary (DPD) value 1468663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng The boolean equations to calculate the value of each of the DPD bit 1469663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng is given in Appendix B of Book 1: Power ISA User Instruction set. The 1470663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng bits for the DPD number are [abcdefghijkm]. The bits for the BCD value 1471663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng are [pqrstuvwxy]. The boolean logic equations in psuedo C code are: 1472663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng */ 1473663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng a = GET( chunk, 11 ); 1474663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng b = GET( chunk, 10 ); 1475663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng c = GET( chunk, 9 ); 1476663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng d = GET( chunk, 8 ); 1477663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng e = GET( chunk, 7 ); 1478663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng f = GET( chunk, 6 ); 1479663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng g = GET( chunk, 5 ); 1480663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng h = GET( chunk, 4 ); 1481663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng i = GET( chunk, 3 ); 1482663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng j = GET( chunk, 2 ); 1483663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng k = GET( chunk, 1 ); 1484663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng m = GET( chunk, 0 ); 1485663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1486663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng p = ( f & a & i & NOT(e) ) | ( j & a & NOT(i) ) | ( b & NOT(a) ); 1487663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng q = ( g & a & i & NOT(e) ) | ( k & a & NOT(i) ) | ( c & NOT(a) ); 1488663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng r = d; 1489663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng s = ( j & NOT(a) & e & NOT(i) ) | ( f & NOT(i) & NOT(e) ) 1490663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | ( f & NOT(a) & NOT(e) ) | ( e & i ); 1491663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng t = ( k & NOT(a) & e & NOT(i) ) | ( g & NOT(i) & NOT(e) ) 1492663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | ( g & NOT(a) & NOT(e) ) | ( a & i ); 1493663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng u = h; 1494663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng v = a | e | i; 1495663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng w = ( NOT(e) & j & NOT(i) ) | ( e & i ) | a; 1496663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng x = ( NOT(a) & k & NOT(i) ) | ( a & i ) | e; 1497663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng y = m; 1498663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1499663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng value = PUT(p, 9) | PUT(q, 8) | PUT(r, 7) | PUT(s, 6) | PUT(t, 5) 1500663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng | PUT(u, 4) | PUT(v, 3) | PUT(w, 2) | PUT(x, 1) | y; 1501663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1502663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return value; 1503663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1504663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1505663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengULong h_DPBtoBCD( ULong dpb ) 1506663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1507663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong result, chunk; 1508663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Int i; 1509663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1510663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result = 0; 1511663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1512663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng for (i = 0; i < 5; i++) { 1513663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng chunk = dpb >> ( 4 - i ) * 10; 1514663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result = result << 12; 1515663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result |= dpb_to_bcd( chunk & 0x3FF ); 1516663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng } 1517663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return result; 1518663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1519663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1520663860b1408516d02ebfcb3a9999a134e6cfb223Ben ChengULong h_BCDtoDPB( ULong bcd ) 1521663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng{ 1522663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng ULong result, chunk; 1523663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng Int i; 1524663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1525663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result = 0; 1526663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1527663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng for (i = 0; i < 5; i++) { 1528663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng chunk = bcd >> ( 4 - i ) * 12; 1529663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result = result << 10; 1530663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng result |= bcd_to_dpb( chunk & 0xFFF ); 1531663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng } 1532663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng return result; 1533663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng} 1534663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#undef NOT 1535663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#undef GET 1536663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng#undef PUT 1537ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown 1538ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*---------------------------------------------------------------*/ 1539ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*--- end host_generic_simd64.c ---*/ 1540ed07e00d438c74b7a23c01bfffde77e3968305e4Jeff Brown/*---------------------------------------------------------------*/ 1541663860b1408516d02ebfcb3a9999a134e6cfb223Ben Cheng 1542