From ea52d565ac0c6f63290e2f5f2f73472085e6b354 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20K=C3=A4ll=C3=A9n?= Date: Mon, 19 Aug 2024 16:02:29 +0200 Subject: [PATCH] Enhancement: resolve some disabled unit tests. --- src/Arch/Arm/AArch32/ArmRewriter.cs | 2 ++ src/Arch/zSeries/zSeriesRewriter.Alu.cs | 16 +++++++++++ src/Arch/zSeries/zSeriesRewriter.cs | 4 +++ .../Arch/Arm/T32DisassemblerTests.cs | 1 - src/UnitTests/Arch/Arm/T32RewriterTests.cs | 3 +- .../Arch/zSeries/zSeriesRewriterTests.cs | 28 +++++++------------ 6 files changed, 33 insertions(+), 21 deletions(-) diff --git a/src/Arch/Arm/AArch32/ArmRewriter.cs b/src/Arch/Arm/AArch32/ArmRewriter.cs index 702b9af2a7..900cbc1142 100644 --- a/src/Arch/Arm/AArch32/ArmRewriter.cs +++ b/src/Arch/Arm/AArch32/ArmRewriter.cs @@ -479,6 +479,7 @@ public IEnumerator GetEnumerator() case Mnemonic.vqabs: RewriteVectorBinOp(vqabs_intrinsic); break; case Mnemonic.vqadd: RewriteVectorBinOp(vqadd_intrinsic); break; case Mnemonic.vqdmulh: RewriteVectorBinOp(vqdmulh_intrinsic); break; + case Mnemonic.vqrdmulh: RewriteVectorBinOp(vqrdmulh_intrinsic); break; case Mnemonic.vqrshl: RewriteVectorBinOp(vqrshl_intrinsic); break; case Mnemonic.vqrshrn: RewriteVectorBinOpNarrow(vqrshrn_intrinsic); break; case Mnemonic.vqsub: RewriteVectorBinOp(vqsub_intrinsic); break; @@ -1500,6 +1501,7 @@ protected virtual void EmitUnitTest(AArch32Instruction instr) private static readonly IntrinsicProcedure vqabs_intrinsic = IntrinsicBuilder.GenericUnary("__vqabs"); private static readonly IntrinsicProcedure vqadd_intrinsic = IntrinsicBuilder.GenericBinary("__vqadd"); private static readonly IntrinsicProcedure vqdmulh_intrinsic = IntrinsicBuilder.GenericBinary("__vqdmulh"); + private static readonly IntrinsicProcedure vqrdmulh_intrinsic = IntrinsicBuilder.GenericBinary("__vqrdmulh"); private static readonly IntrinsicProcedure vqshl_intrinsic = new IntrinsicBuilder("__vqshl", false) .GenericTypes("TArray") .Param("TArray") diff --git a/src/Arch/zSeries/zSeriesRewriter.Alu.cs b/src/Arch/zSeries/zSeriesRewriter.Alu.cs index 008ca1fa6f..e3e52cabec 100644 --- a/src/Arch/zSeries/zSeriesRewriter.Alu.cs +++ b/src/Arch/zSeries/zSeriesRewriter.Alu.cs @@ -384,6 +384,22 @@ private void RewriteLl(PrimitiveType dt) m.Assign(Reg(0), m.Convert(src, src.DataType, arch.WordWidth)); } + private void RewriteLlgt() + { + var tmp = binder.CreateTemporary(Word31); + m.Assign(tmp, m.Slice(Reg(1), tmp.DataType)); + m.Assign(Reg(0), m.ExtendZ(tmp, PrimitiveType.Word64)); + } + + private void RewriteLlhr() + { + var slice = Op(1, PrimitiveType.Word16); + var tmp = binder.CreateTemporary(PrimitiveType.Word32); + m.Assign(tmp, m.ExtendZ(slice, tmp.DataType)); + var dst = Reg(0); + m.Assign(dst, m.Dpb(dst, tmp, 0)); + } + private void RewriteLli(PrimitiveType dt, int bitOffset) { var imm = Imm(1, dt); diff --git a/src/Arch/zSeries/zSeriesRewriter.cs b/src/Arch/zSeries/zSeriesRewriter.cs index 5f182f1486..91c6c027ba 100644 --- a/src/Arch/zSeries/zSeriesRewriter.cs +++ b/src/Arch/zSeries/zSeriesRewriter.cs @@ -40,6 +40,7 @@ public partial class zSeriesRewriter : IEnumerable private static readonly PrimitiveType ShortHexFloat = PrimitiveType.Real32; private static readonly PrimitiveType LongHexFloat = PrimitiveType.Real64; private static readonly PrimitiveType ExtendedHexFloat = PrimitiveType.Real128; + private static readonly PrimitiveType Word31 = PrimitiveType.CreateWord(31); private readonly zSeriesArchitecture arch; private readonly zSeriesIntrinsics intrinsics; @@ -244,6 +245,9 @@ public IEnumerator GetEnumerator() case Mnemonic.llgcr: RewriteLr(PrimitiveType.Byte, PrimitiveType.Word64); break; case Mnemonic.llgfr: RewriteLr(PrimitiveType.Word32, PrimitiveType.Word64); break; case Mnemonic.llgfrl: RewriteLl(PrimitiveType.Word32); break; + case Mnemonic.llgtr: RewriteLlgt(); break; + case Mnemonic.llhr: RewriteLlhr(); break; + case Mnemonic.llhrl: RewriteLlhr(); break; case Mnemonic.llill: RewriteLli(PrimitiveType.Word16, 0); break; case Mnemonic.lmg: RewriteLmg(); break; case Mnemonic.lndr: RewriteFNegR(LongHexFloat); break; diff --git a/src/UnitTests/Arch/Arm/T32DisassemblerTests.cs b/src/UnitTests/Arch/Arm/T32DisassemblerTests.cs index 25b7195481..22b6c32f69 100644 --- a/src/UnitTests/Arch/Arm/T32DisassemblerTests.cs +++ b/src/UnitTests/Arch/Arm/T32DisassemblerTests.cs @@ -1595,7 +1595,6 @@ public void ThumbDis_vst4_sparse_writeback() } [Test] - [Ignore("New decoder needed?")] public void ThumbDis_vstmia() { AssertCode("@@@", "8AECCA1B"); diff --git a/src/UnitTests/Arch/Arm/T32RewriterTests.cs b/src/UnitTests/Arch/Arm/T32RewriterTests.cs index 9af8a19b6e..fefdfe1876 100644 --- a/src/UnitTests/Arch/Arm/T32RewriterTests.cs +++ b/src/UnitTests/Arch/Arm/T32RewriterTests.cs @@ -7200,13 +7200,12 @@ public void ThumbRw_vsra() } [Test] - [Ignore(Categories.FailedTests)] public void ThumbRw_vqrdmulh() { Given_HexString("1DFF099B"); // vqrdmulh.s16 d9, d13, d9 AssertCode( "0|L--|00100000(4): 1 instructions", - "1|L--|@@@"); + "1|L--|d9 = __vqrdmulh(d13, d9)"); } [Test] diff --git a/src/UnitTests/Arch/zSeries/zSeriesRewriterTests.cs b/src/UnitTests/Arch/zSeries/zSeriesRewriterTests.cs index f15b26e874..126bcd03d2 100644 --- a/src/UnitTests/Arch/zSeries/zSeriesRewriterTests.cs +++ b/src/UnitTests/Arch/zSeries/zSeriesRewriterTests.cs @@ -21,15 +21,7 @@ using NUnit.Framework; using Reko.Arch.zSeries; using Reko.Core; -using Reko.Core.Configuration; -using Reko.Core.Memory; -using Reko.Core.Rtl; -using System; using System.Collections.Generic; -using System.ComponentModel.Design; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace Reko.UnitTests.Arch.zSeries { @@ -1421,34 +1413,34 @@ public void zSeriesRw_llgfrl() } [Test] - [Ignore("S390 instr")] public void zSeriesRw_llgtr() { Given_HexString("B91700AA"); AssertCode( // llgtr r10,r10 - "0|L--|00100000(4): 1 instructions", - "1|L--|@@@"); + "0|L--|00100000(4): 2 instructions", + "1|L--|v3 = SLICE(r10, word31, 0)", + "2|L--|r10 = CONVERT(v3, word31, word64)"); } - [Test] - [Ignore("S390 instr")] public void zSeriesRw_llhr() { Given_HexString("B9950022"); AssertCode( // llhr r2,r2 - "0|L--|00100000(4): 1 instructions", - "1|L--|@@@"); + "0|L--|00100000(4): 3 instructions", + "1|L--|v4 = SLICE(r2, word16, 0)", + "2|L--|v5 = CONVERT(v4, word16, word32)", + "3|L--|r2 = SEQ(SLICE(r2, word32, 32), v5)"); } [Test] - [Ignore("S390 instr")] public void zSeriesRw_llhrl() { Given_HexString("C402E340B130"); AssertCode( // llhrl r0,FFFFFFFFC6817B40 - "0|L--|00100000(6): 1 instructions", - "1|L--|@@@"); + "0|L--|00100000(6): 2 instructions", + "1|L--|v3 = CONVERT(0xC6916260, ptr32, word32)", + "2|L--|r0 = SEQ(SLICE(r0, word32, 32), v3)"); } [Test]