From: Gabe Black Date: Tue, 18 Aug 2009 03:15:16 +0000 (-0700) Subject: X86: Implement a media average microop. X-Git-Tag: Calvin_Submission~66 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=f6b12bfa8dd9e3a0d7e84d59db2142cdda99e086;p=gem5.git X86: Implement a media average microop. --- diff --git a/src/arch/x86/isa/microops/mediaop.isa b/src/arch/x86/isa/microops/mediaop.isa index 7e7016368..b771cca83 100644 --- a/src/arch/x86/isa/microops/mediaop.isa +++ b/src/arch/x86/isa/microops/mediaop.isa @@ -955,6 +955,26 @@ let {{ FpDestReg.uqw = result; ''' + class Mavg(MediaOp): + code = ''' + assert(srcSize == destSize); + int size = srcSize; + int sizeBits = size * 8; + int items = (ext & 0x1) ? 1: (sizeof(FloatRegBits) / size); + uint64_t result = FpDestReg.uqw; + + for (int i = 0; i < items; i++) { + int hiIndex = (i + 1) * sizeBits - 1; + int loIndex = (i + 0) * sizeBits; + uint64_t arg1Bits = bits(FpSrcReg1.uqw, hiIndex, loIndex); + uint64_t arg2Bits = bits(FpSrcReg2.uqw, hiIndex, loIndex); + uint64_t resBits = (arg1Bits + arg2Bits + 1) / 2; + + result = insertBits(result, hiIndex, loIndex, resBits); + } + FpDestReg.uqw = result; + ''' + class Msad(MediaOp): code = ''' int srcBits = srcSize * 8;