mediaop.isa (6560:323d48647000) | mediaop.isa (6562:571fd8d89903) |
---|---|
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 --- 744 unchanged lines hidden (view full) --- 753 res.d = arg1.d / arg2.d; 754 resBits = res.i; 755 } 756 757 result = insertBits(result, hiIndex, loIndex, resBits); 758 } 759 FpDestReg.uqw = result; 760 ''' | 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 --- 744 unchanged lines hidden (view full) --- 753 res.d = arg1.d / arg2.d; 754 resBits = res.i; 755 } 756 757 result = insertBits(result, hiIndex, loIndex, resBits); 758 } 759 FpDestReg.uqw = result; 760 ''' |
761 762 class Cvti2f(MediaOp): 763 def __init__(self, dest, src, \ 764 size = None, destSize = None, srcSize = None, ext = None): 765 super(Cvti2f, self).__init__(dest, src,\ 766 "InstRegIndex(0)", size, destSize, srcSize, ext) 767 code = ''' 768 union floatInt 769 { 770 float f; 771 uint32_t i; 772 }; 773 union doubleInt 774 { 775 double d; 776 uint64_t i; 777 }; 778 779 assert(destSize == 4 || destSize == 8); 780 assert(srcSize == 4 || srcSize == 8); 781 int srcSizeBits = srcSize * 8; 782 int destSizeBits = destSize * 8; 783 int items; 784 int srcStart = 0; 785 int destStart = 0; 786 if (srcSize == 2 * destSize) { 787 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / srcSize; 788 if (ext & 0x2) 789 destStart = destSizeBits * items; 790 } else if (destSize == 2 * srcSize) { 791 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / destSize; 792 if (ext & 0x2) 793 srcStart = srcSizeBits * items; 794 } else { 795 items = (ext & 0x1) ? 1: sizeof(FloatRegBits) / destSize; 796 } 797 uint64_t result = FpDestReg.uqw; 798 799 for (int i = 0; i < items; i++) { 800 int srcHiIndex = srcStart + (i + 1) * srcSizeBits - 1; 801 int srcLoIndex = srcStart + (i + 0) * srcSizeBits; 802 uint64_t argBits = bits(FpSrcReg1.uqw, srcHiIndex, srcLoIndex); 803 int64_t sArg = argBits | (0 - (argBits & (1 << srcHiIndex))); 804 double arg = sArg; 805 806 if (destSize == 4) { 807 floatInt fi; 808 fi.f = arg; 809 argBits = fi.i; 810 } else { 811 doubleInt di; 812 di.d = arg; 813 argBits = di.i; 814 } 815 int destHiIndex = destStart + (i + 1) * destSizeBits - 1; 816 int destLoIndex = destStart + (i + 0) * destSizeBits; 817 result = insertBits(result, destHiIndex, destLoIndex, argBits); 818 } 819 FpDestReg.uqw = result; 820 ''' |
|
761}}; | 821}}; |