mediaop.isa (6603:b3333ef98685) | mediaop.isa (6605:e16cf917dcec) |
---|---|
1/// Copyright (c) 2009 The Regents of The University of Michigan 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: redistributions of source code must retain the above copyright 7// notice, this list of conditions and the following disclaimer; 8// redistributions in binary form must reproduce the above copyright --- 1162 unchanged lines hidden (view full) --- 1171 resBits = (arg1Bits << shiftAmt); 1172 } 1173 1174 result = insertBits(result, hiIndex, loIndex, resBits); 1175 } 1176 FpDestReg.uqw = result; 1177 ''' 1178 | 1/// Copyright (c) 2009 The Regents of The University of Michigan 2// All rights reserved. 3// 4// Redistribution and use in source and binary forms, with or without 5// modification, are permitted provided that the following conditions are 6// met: redistributions of source code must retain the above copyright 7// notice, this list of conditions and the following disclaimer; 8// redistributions in binary form must reproduce the above copyright --- 1162 unchanged lines hidden (view full) --- 1171 resBits = (arg1Bits << shiftAmt); 1172 } 1173 1174 result = insertBits(result, hiIndex, loIndex, resBits); 1175 } 1176 FpDestReg.uqw = result; 1177 ''' 1178 |
1179 class Cvtf2i(MediaOp): 1180 def __init__(self, dest, src, \ 1181 size = None, destSize = None, srcSize = None, ext = None): 1182 super(Cvtf2i, self).__init__(dest, src,\ 1183 "InstRegIndex(0)", size, destSize, srcSize, ext) 1184 code = ''' 1185 union floatInt 1186 { 1187 float f; 1188 uint32_t i; 1189 }; 1190 union doubleInt 1191 { 1192 double d; 1193 uint64_t i; 1194 }; 1195 1196 assert(destSize == 4 || destSize == 8); 1197 assert(srcSize == 4 || srcSize == 8); 1198 int srcSizeBits = srcSize * 8; 1199 int destSizeBits = destSize * 8; 1200 int items; 1201 int srcStart = 0; 1202 int destStart = 0; 1203 if (srcSize == 2 * destSize) { 1204 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / srcSize; 1205 if (ext & 0x2) 1206 destStart = destSizeBits * items; 1207 } else if (destSize == 2 * srcSize) { 1208 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / destSize; 1209 if (ext & 0x2) 1210 srcStart = srcSizeBits * items; 1211 } else { 1212 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / destSize; 1213 } 1214 uint64_t result = FpDestReg.uqw; 1215 1216 for (int i = 0; i < items; i++) { 1217 int srcHiIndex = srcStart + (i + 1) * srcSizeBits - 1; 1218 int srcLoIndex = srcStart + (i + 0) * srcSizeBits; 1219 uint64_t argBits = bits(FpSrcReg1.uqw, srcHiIndex, srcLoIndex); 1220 double arg; 1221 1222 if (srcSize == 4) { 1223 floatInt fi; 1224 fi.i = argBits; 1225 arg = fi.f; 1226 } else { 1227 doubleInt di; 1228 di.i = argBits; 1229 arg = di.d; 1230 } 1231 1232 if (ext & 0x4) { 1233 if (arg >= 0) 1234 arg += 0.5; 1235 else 1236 arg -= 0.5; 1237 } 1238 1239 if (destSize == 4) { 1240 argBits = (uint32_t)(float)arg; 1241 } else { 1242 argBits = (uint64_t)arg; 1243 } 1244 int destHiIndex = destStart + (i + 1) * destSizeBits - 1; 1245 int destLoIndex = destStart + (i + 0) * destSizeBits; 1246 result = insertBits(result, destHiIndex, destLoIndex, argBits); 1247 } 1248 FpDestReg.uqw = result; 1249 ''' 1250 |
|
1179 class Cvti2f(MediaOp): 1180 def __init__(self, dest, src, \ 1181 size = None, destSize = None, srcSize = None, ext = None): 1182 super(Cvti2f, self).__init__(dest, src,\ 1183 "InstRegIndex(0)", size, destSize, srcSize, ext) 1184 code = ''' 1185 union floatInt 1186 { --- 296 unchanged lines hidden --- | 1251 class Cvti2f(MediaOp): 1252 def __init__(self, dest, src, \ 1253 size = None, destSize = None, srcSize = None, ext = None): 1254 super(Cvti2f, self).__init__(dest, src,\ 1255 "InstRegIndex(0)", size, destSize, srcSize, ext) 1256 code = ''' 1257 union floatInt 1258 { --- 296 unchanged lines hidden --- |