From: Jordi Vaquero Date: Fri, 17 Apr 2020 14:29:53 +0000 (+0200) Subject: arch-arm: FCVTZS instruction returns sign extension X-Git-Tag: v20.1.0.0~668 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0860a91b11a27d7fb67e79037f4da60524e3df56;p=gem5.git arch-arm: FCVTZS instruction returns sign extension This patch fix Fcvtzs instruction adding sign extension instead of zero extension Change-Id: I28cdca432fa6baa8a524de4c431f492f23f0e9a6 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/28229 Reviewed-by: Giacomo Travaglini Maintainer: Giacomo Travaglini Tested-by: kokoro --- diff --git a/src/arch/arm/isa/insts/sve.isa b/src/arch/arm/isa/insts/sve.isa index aa4f194ee..16597d6d6 100644 --- a/src/arch/arm/isa/insts/sve.isa +++ b/src/arch/arm/isa/insts/sve.isa @@ -1516,27 +1516,49 @@ let {{ # Generates definitions for SVE floating-point conversions (always # unary, constructive, merging def sveCvtInst(name, Name, opClass, types, op, direction=CvtDir.Narrow, - decoder='Generic'): + decoder='Generic', signed=False): global header_output, exec_output, decoders + + if signed: + mask = "SElement msk = mask(sizeof(DElement)*8);" + assign_code = ''' + int sign_bit = bits(destElem, sizeof(DElement)*8 -1); + AA64FpDest_x%(bigElemSuffix)s[i] = + sign_bit? (destElem|~msk): destElem; + ''' % { + 'bigElemSuffix': 's' if direction == CvtDir.Narrow else 'd' + } + else: + mask = ""; + assign_code = ''' + AA64FpDest_x%(bigElemSuffix)s[i] = destElem; + ''' % { + 'bigElemSuffix': 's' if direction == CvtDir.Narrow else 'd' + } + code = sveEnabledCheckCode + ''' unsigned eCount = ArmStaticInst::getCurSveVecLen<%(bigElemType)s>( xc->tcBase()); + %(mask)s for (unsigned i = 0; i < eCount; i++) { SElement srcElem1 = AA64FpOp1_x%(bigElemSuffix)s[i] & mask(sizeof(SElement) * 8); DElement destElem = 0; if (GpOp_x%(bigElemSuffix)s[i]) { %(op)s - AA64FpDest_x%(bigElemSuffix)s[i] = destElem; + %(assign)s; } else { AA64FpDest_x%(bigElemSuffix)s[i] = AA64FpDestMerge_x%(bigElemSuffix)s[i]; } } - ''' % {'op': op, - 'bigElemType': 'SElement' if direction == CvtDir.Narrow + ''' % {'bigElemType': 'SElement' if direction == CvtDir.Narrow else 'DElement', - 'bigElemSuffix': 's' if direction == CvtDir.Narrow else 'd'} + 'op': op, 'mask': mask, + 'bigElemSuffix': 's' if direction == CvtDir.Narrow else 'd', + 'assign': assign_code + } + iop = InstObjParams(name, 'Sve' + Name, 'SveUnaryPredOp', {'code': code, 'op_class': opClass}, []) header_output += SveWideningUnaryPredOpDeclare.subst(iop) @@ -2743,6 +2765,7 @@ let {{ code = sveEnabledCheckCode + ''' unsigned eCount = ArmStaticInst::getCurSveVecLen( xc->tcBase()); + ArmISA::VecRegContainer tmpVecC; auto auxDest = tmpVecC.as(); int firstelem = -1, lastelem = -2; @@ -3596,7 +3619,7 @@ let {{ 'uint32_t, uint32_t', 'uint64_t, uint32_t', 'uint64_t, uint64_t'), - fcvtzsCode, CvtDir.Narrow) + fcvtzsCode, CvtDir.Narrow, signed=True) sveCvtInst('fcvtzs', 'FcvtzsWiden', 'SimdCvtOp', ('uint16_t, uint32_t', 'uint16_t, uint64_t',