diff options
author | Gabe Black <gblack@eecs.umich.edu> | 2009-08-17 20:25:13 -0700 |
---|---|---|
committer | Gabe Black <gblack@eecs.umich.edu> | 2009-08-17 20:25:13 -0700 |
commit | 1fed0161d94dc0bd89e1c682f1f5d8757bd252a2 (patch) | |
tree | 36a86a9ba764bd7720cc6917d0c6babba0fcece5 /src/arch | |
parent | d9970f139acfb2a3d19854d082cc30000bf09d35 (diff) | |
download | gem5-1fed0161d94dc0bd89e1c682f1f5d8757bd252a2.tar.xz |
X86: Implement a shuffle media microop.
Diffstat (limited to 'src/arch')
-rw-r--r-- | src/arch/x86/isa/microops/mediaop.isa | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/src/arch/x86/isa/microops/mediaop.isa b/src/arch/x86/isa/microops/mediaop.isa index 83962b0f2..1bd99db3a 100644 --- a/src/arch/x86/isa/microops/mediaop.isa +++ b/src/arch/x86/isa/microops/mediaop.isa @@ -365,6 +365,48 @@ let {{ FpDestReg.uqw = result; ''' + class shuffle(MediaOp): + code = ''' + assert(srcSize == destSize); + int size = srcSize; + int sizeBits = size * 8; + int items = sizeof(FloatRegBits) / size; + int options; + int optionBits; + if (size == 8) { + options = 2; + optionBits = 1; + } else { + options = 4; + optionBits = 2; + } + + uint64_t result = 0; + uint8_t sel = ext; + + for (int i = 0; i < items; i++) { + uint64_t resBits; + uint8_t lsel = sel & mask(optionBits); + if (lsel * size >= sizeof(FloatRegBits)) { + lsel -= options / 2; + resBits = bits(FpSrcReg2.uqw, + (lsel + 1) * sizeBits - 1, + (lsel + 0) * sizeBits); + } else { + resBits = bits(FpSrcReg1.uqw, + (lsel + 1) * sizeBits - 1, + (lsel + 0) * sizeBits); + } + + sel >>= optionBits; + + int hiIndex = (i + 1) * sizeBits - 1; + int loIndex = (i + 0) * sizeBits; + result = insertBits(result, hiIndex, loIndex, resBits); + } + FpDestReg.uqw = result; + ''' + class Unpack(MediaOp): code = ''' assert(srcSize == destSize); |