From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082065781349.2097694911214; Thu, 25 May 2023 23:21:05 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2Qo4-0007w6-0J; Fri, 26 May 2023 02:20:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2Qo1-0007v9-FJ for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:05 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2Qnz-00088v-IR for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:05 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sSEC4tMHHWH7ZVkDW7fso8UTCwNNNdfZhVSYgacCI98=; b=AIApH/m+TNrsqEY0Vc1Y8YAXNQ TunCiGFWv331DRr2sVG/b5e87ga0xPU++DtH+SK0uktM2lJ3r3cgHGjlv9gNSPvzN4ZELB6WXrWGM Yxu2kcAF6osVqUJgkg6HAX+B0Ux689qXSWEVStxnMDb7r6T5VswWJt1oJ9aOWMwYP2sc=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 1/6] tests/tcg/tricore: Move asm tests into 'asm' directory Date: Fri, 26 May 2023 08:19:41 +0200 Message-Id: <20230526061946.54514-2-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.60617, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.16.600001 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405225, da=172691065, mc=3, sc=0, hc=3, sp=0, fso=405225, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082067112100003 Content-Type: text/plain; charset="utf-8" this seperates these tests from the upcoming tests written in C. Also rename the compiled test to 'test_.asm.tst'. Signed-off-by: Bastian Koppelmann --- tests/tcg/tricore/Makefile.softmmu-target | 35 ++++++++++++----------- tests/tcg/tricore/{ =3D> asm}/macros.h | 0 tests/tcg/tricore/{ =3D> asm}/test_abs.S | 0 tests/tcg/tricore/{ =3D> asm}/test_bmerge.S | 0 tests/tcg/tricore/{ =3D> asm}/test_clz.S | 0 tests/tcg/tricore/{ =3D> asm}/test_dextr.S | 0 tests/tcg/tricore/{ =3D> asm}/test_dvstep.S | 0 tests/tcg/tricore/{ =3D> asm}/test_fadd.S | 0 tests/tcg/tricore/{ =3D> asm}/test_fmul.S | 0 tests/tcg/tricore/{ =3D> asm}/test_ftoi.S | 0 tests/tcg/tricore/{ =3D> asm}/test_imask.S | 0 tests/tcg/tricore/{ =3D> asm}/test_insert.S | 0 tests/tcg/tricore/{ =3D> asm}/test_ld_bu.S | 0 tests/tcg/tricore/{ =3D> asm}/test_ld_h.S | 0 tests/tcg/tricore/{ =3D> asm}/test_madd.S | 0 tests/tcg/tricore/{ =3D> asm}/test_msub.S | 0 tests/tcg/tricore/{ =3D> asm}/test_muls.S | 0 17 files changed, 18 insertions(+), 17 deletions(-) rename tests/tcg/tricore/{ =3D> asm}/macros.h (100%) rename tests/tcg/tricore/{ =3D> asm}/test_abs.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_bmerge.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_clz.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_dextr.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_dvstep.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_fadd.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_fmul.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_ftoi.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_imask.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_insert.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_ld_bu.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_ld_h.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_madd.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_msub.S (100%) rename tests/tcg/tricore/{ =3D> asm}/test_muls.S (100%) diff --git a/tests/tcg/tricore/Makefile.softmmu-target b/tests/tcg/tricore/= Makefile.softmmu-target index 49e573bc3b..29c75acfb3 100644 --- a/tests/tcg/tricore/Makefile.softmmu-target +++ b/tests/tcg/tricore/Makefile.softmmu-target @@ -1,33 +1,34 @@ TESTS_PATH =3D $(SRC_PATH)/tests/tcg/tricore +ASM_TESTS_PATH =3D $(TESTS_PATH)/asm =20 LDFLAGS =3D -T$(TESTS_PATH)/link.ld --mcpu=3Dtc162 ASFLAGS =3D -mtc162 =20 -TESTS +=3D test_abs.tst -TESTS +=3D test_bmerge.tst -TESTS +=3D test_clz.tst -TESTS +=3D test_dextr.tst -TESTS +=3D test_dvstep.tst -TESTS +=3D test_fadd.tst -TESTS +=3D test_fmul.tst -TESTS +=3D test_ftoi.tst -TESTS +=3D test_imask.tst -TESTS +=3D test_insert.tst -TESTS +=3D test_ld_bu.tst -TESTS +=3D test_ld_h.tst -TESTS +=3D test_madd.tst -TESTS +=3D test_msub.tst -TESTS +=3D test_muls.tst +TESTS +=3D test_abs.asm.tst +TESTS +=3D test_bmerge.asm.tst +TESTS +=3D test_clz.asm.tst +TESTS +=3D test_dextr.asm.tst +TESTS +=3D test_dvstep.asm.tst +TESTS +=3D test_fadd.asm.tst +TESTS +=3D test_fmul.asm.tst +TESTS +=3D test_ftoi.asm.tst +TESTS +=3D test_imask.asm.tst +TESTS +=3D test_insert.asm.tst +TESTS +=3D test_ld_bu.asm.tst +TESTS +=3D test_ld_h.asm.tst +TESTS +=3D test_madd.asm.tst +TESTS +=3D test_msub.asm.tst +TESTS +=3D test_muls.asm.tst =20 QEMU_OPTS +=3D -M tricore_testboard -cpu tc27x -nographic -kernel =20 -%.pS: $(TESTS_PATH)/%.S +%.pS: $(ASM_TESTS_PATH)/%.S $(HOST_CC) -E -o $@ $< =20 %.o: %.pS $(AS) $(ASFLAGS) -o $@ $< =20 -%.tst: %.o +%.asm.tst: %.o $(LD) $(LDFLAGS) $< -o $@ =20 # We don't currently support the multiarch system tests diff --git a/tests/tcg/tricore/macros.h b/tests/tcg/tricore/asm/macros.h similarity index 100% rename from tests/tcg/tricore/macros.h rename to tests/tcg/tricore/asm/macros.h diff --git a/tests/tcg/tricore/test_abs.S b/tests/tcg/tricore/asm/test_abs.S similarity index 100% rename from tests/tcg/tricore/test_abs.S rename to tests/tcg/tricore/asm/test_abs.S diff --git a/tests/tcg/tricore/test_bmerge.S b/tests/tcg/tricore/asm/test_b= merge.S similarity index 100% rename from tests/tcg/tricore/test_bmerge.S rename to tests/tcg/tricore/asm/test_bmerge.S diff --git a/tests/tcg/tricore/test_clz.S b/tests/tcg/tricore/asm/test_clz.S similarity index 100% rename from tests/tcg/tricore/test_clz.S rename to tests/tcg/tricore/asm/test_clz.S diff --git a/tests/tcg/tricore/test_dextr.S b/tests/tcg/tricore/asm/test_de= xtr.S similarity index 100% rename from tests/tcg/tricore/test_dextr.S rename to tests/tcg/tricore/asm/test_dextr.S diff --git a/tests/tcg/tricore/test_dvstep.S b/tests/tcg/tricore/asm/test_d= vstep.S similarity index 100% rename from tests/tcg/tricore/test_dvstep.S rename to tests/tcg/tricore/asm/test_dvstep.S diff --git a/tests/tcg/tricore/test_fadd.S b/tests/tcg/tricore/asm/test_fad= d.S similarity index 100% rename from tests/tcg/tricore/test_fadd.S rename to tests/tcg/tricore/asm/test_fadd.S diff --git a/tests/tcg/tricore/test_fmul.S b/tests/tcg/tricore/asm/test_fmu= l.S similarity index 100% rename from tests/tcg/tricore/test_fmul.S rename to tests/tcg/tricore/asm/test_fmul.S diff --git a/tests/tcg/tricore/test_ftoi.S b/tests/tcg/tricore/asm/test_fto= i.S similarity index 100% rename from tests/tcg/tricore/test_ftoi.S rename to tests/tcg/tricore/asm/test_ftoi.S diff --git a/tests/tcg/tricore/test_imask.S b/tests/tcg/tricore/asm/test_im= ask.S similarity index 100% rename from tests/tcg/tricore/test_imask.S rename to tests/tcg/tricore/asm/test_imask.S diff --git a/tests/tcg/tricore/test_insert.S b/tests/tcg/tricore/asm/test_i= nsert.S similarity index 100% rename from tests/tcg/tricore/test_insert.S rename to tests/tcg/tricore/asm/test_insert.S diff --git a/tests/tcg/tricore/test_ld_bu.S b/tests/tcg/tricore/asm/test_ld= _bu.S similarity index 100% rename from tests/tcg/tricore/test_ld_bu.S rename to tests/tcg/tricore/asm/test_ld_bu.S diff --git a/tests/tcg/tricore/test_ld_h.S b/tests/tcg/tricore/asm/test_ld_= h.S similarity index 100% rename from tests/tcg/tricore/test_ld_h.S rename to tests/tcg/tricore/asm/test_ld_h.S diff --git a/tests/tcg/tricore/test_madd.S b/tests/tcg/tricore/asm/test_mad= d.S similarity index 100% rename from tests/tcg/tricore/test_madd.S rename to tests/tcg/tricore/asm/test_madd.S diff --git a/tests/tcg/tricore/test_msub.S b/tests/tcg/tricore/asm/test_msu= b.S similarity index 100% rename from tests/tcg/tricore/test_msub.S rename to tests/tcg/tricore/asm/test_msub.S diff --git a/tests/tcg/tricore/test_muls.S b/tests/tcg/tricore/asm/test_mul= s.S similarity index 100% rename from tests/tcg/tricore/test_muls.S rename to tests/tcg/tricore/asm/test_muls.S --=20 2.40.1 From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082045744893.2794924269898; Thu, 25 May 2023 23:20:45 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2QoA-00082t-W3; Fri, 26 May 2023 02:20:15 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2Qo7-0007yk-VY for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:11 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2Qo5-0008Av-FW for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=wvwDbaa8YrxTAWuX98sJ0aAQayZEqQjCW2QqYnaBvGo=; b=Jx4swuMvZpLBYrePQxGU9I7xfy ACkSmT0Dj9mqLmaomDLEr/axtogZrmoCSUa+EjnRCVjgHn9e9/T1D6mfachwCi+7l4Qn6RtVlEMvY hYJPuwdiDisI+8B6RHd5bf/GytumRDS1hMx9ty1VvFHEGE4IMwoEiI4cZ2IFKAvAjYuY=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 2/6] tests/tcg/tricore: Uses label for memory addresses Date: Fri, 26 May 2023 08:19:42 +0200 Message-Id: <20230526061946.54514-3-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.60617, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.16.600001 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405231, da=172691071, mc=5, sc=0, hc=5, sp=0, fso=405231, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082046874100001 Content-Type: text/plain; charset="utf-8" the linker might rearrange sections, so lets reference memory by label name instead of addr + off. Signed-off-by: Bastian Koppelmann --- tests/tcg/tricore/asm/macros.h | 1 - tests/tcg/tricore/asm/test_ld_bu.S | 4 ++-- tests/tcg/tricore/asm/test_ld_h.S | 8 ++++---- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/tests/tcg/tricore/asm/macros.h b/tests/tcg/tricore/asm/macros.h index 3df2e0de82..b5087b5c97 100644 --- a/tests/tcg/tricore/asm/macros.h +++ b/tests/tcg/tricore/asm/macros.h @@ -25,7 +25,6 @@ =20 #define AREG_ADDR %a0 #define AREG_CORRECT_RESULT %a3 -#define MEM_BASE_ADDR 0xd0000000 =20 #define DREG_DEV_ADDR %a15 =20 diff --git a/tests/tcg/tricore/asm/test_ld_bu.S b/tests/tcg/tricore/asm/tes= t_ld_bu.S index ff9dac128b..4a1f40c37b 100644 --- a/tests/tcg/tricore/asm/test_ld_bu.S +++ b/tests/tcg/tricore/asm/test_ld_bu.S @@ -9,7 +9,7 @@ _start: # expect. addr reg val after load # insn num expect. load value | pattern for loading # | | | | | - TEST_LD(ld.bu, 1, 0xff, MEM_BASE_ADDR + 4, [+AREG_ADDR]4) # pre_inc - TEST_LD(ld.bu, 2, 0xad, MEM_BASE_ADDR + 4, [AREG_ADDR+]4) # post_inc + TEST_LD(ld.bu, 1, 0xff, test_data + 4, [+AREG_ADDR]4) # pre_inc + TEST_LD(ld.bu, 2, 0xad, test_data + 4, [AREG_ADDR+]4) # post_inc =20 TEST_PASSFAIL diff --git a/tests/tcg/tricore/asm/test_ld_h.S b/tests/tcg/tricore/asm/test= _ld_h.S index d3c157a046..f5e4959198 100644 --- a/tests/tcg/tricore/asm/test_ld_h.S +++ b/tests/tcg/tricore/asm/test_ld_h.S @@ -7,9 +7,9 @@ test_data: .global _start _start: # expect. addr reg val after load -# insn num expect. load value | pattern for loading -# | | | | | - TEST_LD (ld.h, 1, 0xffffaffe, MEM_BASE_ADDR, [AREG_ADDR]2) - TEST_LD_SRO(ld.h, 2, 0x000022ff, MEM_BASE_ADDR, [AREG_ADDR]4) +# insn num expect. load value | pattern for loading +# | | | | | + TEST_LD (ld.h, 1, 0xffffaffe, test_data, [AREG_ADDR]2) + TEST_LD_SRO(ld.h, 2, 0x000022ff, test_data, [AREG_ADDR]4) =20 TEST_PASSFAIL --=20 2.40.1 From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082092931495.04324859872736; Thu, 25 May 2023 23:21:32 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2QoJ-0008GQ-4C; Fri, 26 May 2023 02:20:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoH-0008FM-4c for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:21 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoD-0008M8-CK for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:20 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=omCdOhFHnUw+9yCsu1jst9MrfPbhvtaiiSHFwS/SyzA=; b=SqtLnbT1HKMp6uDFEe54jO44yV RYAcS2WJUviP35wfngd2h+U55nmmGl9+pfaDtHVQCY0wVQ/p1scZn05lom4UXXrjWAQ1KOlHV86ir enXs9Ht0bjCKaWfTEDa7z5SAZVEs88TYmn6oSxmwN2TxYgHklJKaxyEYPnktaTd5e/QY=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 3/6] tests/tcg/tricore: Add first C program Date: Fri, 26 May 2023 08:19:43 +0200 Message-Id: <20230526061946.54514-4-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.60617, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.16.600001 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405237, da=172691077, mc=7, sc=0, hc=7, sp=0, fso=405237, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082094844100003 Content-Type: text/plain; charset="utf-8" this allows us to exercise the startup code used by GCC to call main(). Signed-off-by: Bastian Koppelmann --- configure | 1 + tests/tcg/tricore/Makefile.softmmu-target | 13 + tests/tcg/tricore/c/crt0-tc2x.S | 335 ++++++++++++++++++++++ tests/tcg/tricore/c/test_boot_to_main.c | 13 + tests/tcg/tricore/c/testdev_assert.h | 18 ++ tests/tcg/tricore/link.ld | 16 ++ 6 files changed, 396 insertions(+) create mode 100644 tests/tcg/tricore/c/crt0-tc2x.S create mode 100644 tests/tcg/tricore/c/test_boot_to_main.c create mode 100644 tests/tcg/tricore/c/testdev_assert.h diff --git a/configure b/configure index 80ca1c9221..2743977469 100755 --- a/configure +++ b/configure @@ -1451,6 +1451,7 @@ probe_target_compiler() { container_cross_prefix=3Dtricore- container_cross_as=3Dtricore-as container_cross_ld=3Dtricore-ld + container_cross_cc=3Dtricore-gcc break ;; x86_64) diff --git a/tests/tcg/tricore/Makefile.softmmu-target b/tests/tcg/tricore/= Makefile.softmmu-target index 29c75acfb3..f051444991 100644 --- a/tests/tcg/tricore/Makefile.softmmu-target +++ b/tests/tcg/tricore/Makefile.softmmu-target @@ -1,8 +1,10 @@ TESTS_PATH =3D $(SRC_PATH)/tests/tcg/tricore ASM_TESTS_PATH =3D $(TESTS_PATH)/asm +C_TESTS_PATH =3D $(TESTS_PATH)/c =20 LDFLAGS =3D -T$(TESTS_PATH)/link.ld --mcpu=3Dtc162 ASFLAGS =3D -mtc162 +CFLAGS =3D -mtc162 -c =20 TESTS +=3D test_abs.asm.tst TESTS +=3D test_bmerge.asm.tst @@ -20,6 +22,8 @@ TESTS +=3D test_madd.asm.tst TESTS +=3D test_msub.asm.tst TESTS +=3D test_muls.asm.tst =20 +TESTS +=3D test_boot_to_main.c.tst + QEMU_OPTS +=3D -M tricore_testboard -cpu tc27x -nographic -kernel =20 %.pS: $(ASM_TESTS_PATH)/%.S @@ -31,5 +35,14 @@ QEMU_OPTS +=3D -M tricore_testboard -cpu tc27x -nographi= c -kernel %.asm.tst: %.o $(LD) $(LDFLAGS) $< -o $@ =20 +crt0-tc2x.o: $(C_TESTS_PATH)/crt0-tc2x.S + $(AS) $(ASFLAGS) -o $@ $< + +%.o: $(C_TESTS_PATH)/%.c + $(CC) $(CFLAGS) -o $@ $< + +%.c.tst: %.o crt0-tc2x.o + $(LD) $(LDFLAGS) -o $@ $^ + # We don't currently support the multiarch system tests undefine MULTIARCH_TESTS diff --git a/tests/tcg/tricore/c/crt0-tc2x.S b/tests/tcg/tricore/c/crt0-tc2= x.S new file mode 100644 index 0000000000..3100da123c --- /dev/null +++ b/tests/tcg/tricore/c/crt0-tc2x.S @@ -0,0 +1,335 @@ +/* + * crt0-tc2x.S -- Startup code for GNU/TriCore applications. + * + * Copyright (C) 1998-2014 HighTec EDV-Systeme GmbH. + * + * This file is part of GCC. + * + * GCC is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3, or (at your option) + * any later version. + * + * GCC is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * Under Section 7 of GPL version 3, you are granted additional + * permissions described in the GCC Runtime Library Exception, version + * 3.1, as published by the Free Software Foundation. + * + * You should have received a copy of the GNU General Public License and + * a copy of the GCC Runtime Library Exception along with this program; + * see the files COPYING3 and COPYING.RUNTIME respectively. If not, see + * . */ + +/* Define the Derivate Name as a hexvalue. This value + * is built-in defined in tricore-c.c (from tricore-devices.c) + * the derivate number as a hexvalue (e.g. TC1796 =3D> 0x1796 + * This name will be used in the memory.x Memory description to + * to confirm that the crt0.o and the memory.x will be get from + * same directory + */ + .section ".startup_code", "ax", @progbits + .global _start + .type _start,@function + +/* default BMI header (only TC2xxx devices) */ + .word 0x00000000 + .word 0xb3590070 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x00000000 + .word 0x791eb864 + .word 0x86e1479b + +_start: + .code32 + j _startaddr + .align 2 + +_startaddr: + /* + * initialize user and interrupt stack pointers + */ + movh.a %sp,hi:__USTACK # load %sp + lea %sp,[%sp]lo:__USTACK + movh %d0,hi:__ISTACK # load $isp + addi %d0,%d0,lo:__ISTACK + mtcr $isp,%d0 + isync + +#; install trap handlers + + movh %d0,hi:first_trap_table #; load $btv + addi %d0,%d0,lo:first_trap_table + mtcr $btv,%d0 + isync + + /* + * initialize call depth counter + */ + + mfcr %d0,$psw + or %d0,%d0,0x7f # disable call depth counting + andn %d0,%d0,0x80 # clear CDE bit + mtcr $psw,%d0 + isync + + /* + * initialize access to system global registers + */ + + mfcr %d0,$psw + or %d0,%d0,0x100 # set GW bit + mtcr $psw,%d0 + isync + + /* + * initialize SDA base pointers + */ + .global _SMALL_DATA_,_SMALL_DATA2_,_SMALL_DATA3_,_SMALL_DATA4_ + .weak _SMALL_DATA_,_SMALL_DATA2_,_SMALL_DATA3_,_SMALL_DATA4_ + + movh.a %a0,hi:_SMALL_DATA_ # %a0 addresses .sdata/.sbss + lea %a0,[%a0]lo:_SMALL_DATA_ + movh.a %a1,hi:_SMALL_DATA2_ # %a1 addresses .sdata2/.sbss2 + lea %a1,[%a1]lo:_SMALL_DATA2_ + movh.a %a8,hi:_SMALL_DATA3_ # %a8 addresses .sdata3/.sbss3 + lea %a8,[%a8]lo:_SMALL_DATA3_ + movh.a %a9,hi:_SMALL_DATA4_ # %a9 addresses .sdata4/.sbss4 + lea %a9,[%a9]lo:_SMALL_DATA4_ + + /* + * reset access to system global registers + */ + + mfcr %d0,$psw + andn %d0,%d0,0x100 # clear GW bit + mtcr $psw,%d0 + isync + + /* + * initialize context save areas + */ + + jl __init_csa + + + + /* + * handle clear table (i.e., fill BSS with zeros) + */ + + jl __clear_table_func + + + /* + * handle copy table (support for romable code) + */ + + jl __copy_table_func + + + /* + * _exit (main (0, NULL)); + */ + mov %d4,0 # argc =3D 0 + sub.a %sp,8 + st.w [%sp]0,%d4 + st.w [%sp]4,%d4 + mov.aa %a4,%sp # argv + + call main # int retval =3D main (0, NULL); + mov.a %a14,%d2 # move exit code to match trap handler + j _exit # _exit (retval); + + debug # should never come here + + + /* + * initialize context save areas (CSAs), PCXI, LCX and FCX + */ + + .global __init_csa + .type __init_csa,function + +__init_csa: + movh %d0,0 + mtcr $pcxi,%d0 + isync + movh %d0,hi:__CSA_BEGIN #; %d0 =3D begin of CSA + addi %d0,%d0,lo:__CSA_BEGIN + addi %d0,%d0,63 #; force alignment (2^6) + andn %d0,%d0,63 + movh %d2,hi:__CSA_END #; %d2 =3D end of CSA + addi %d2,%d2,lo:__CSA_END + andn %d2,%d2,63 #; force alignment (2^6) + sub %d2,%d2,%d0 + sh %d2,%d2,-6 #; %d2 =3D number of CSAs + mov.a %a3,%d0 #; %a3 =3D address of first CSA + extr.u %d0,%d0,28,4 #; %d0 =3D segment << 16 + sh %d0,%d0,16 + lea %a4,0 #; %a4 =3D previous CSA =3D 0 + st.a [%a3],%a4 #; store it in 1st CSA + mov.aa %a4,%a3 #; %a4 =3D current CSA + lea %a3,[%a3]64 #; %a3 =3D %a3->nextCSA + mov.d %d1,%a3 + extr.u %d1,%d1,6,16 #; get CSA index + or %d1,%d1,%d0 #; add segment number + mtcr $lcx,%d1 #; initialize LCX + add %d2,%d2,-2 #; CSAs to initialize -=3D 2 + mov.a %a5,%d2 #; %a5 =3D loop counter +csa_loop: + mov.d %d1,%a4 #; %d1 =3D current CSA address + extr.u %d1,%d1,6,16 #; get CSA index + or %d1,%d1,%d0 #; add segment number + st.w [%a3],%d1 #; store "nextCSA" pointer + mov.aa %a4,%a3 #; %a4 =3D current CSA address + lea %a3,[%a3]64 #; %a3 =3D %a3->nextCSA + loop %a5,csa_loop #; repeat until done + + mov.d %d1,%a4 #; %d1 =3D current CSA address + extr.u %d1,%d1,6,16 #; get CSA index + or %d1,%d1,%d0 #; add segment number + mtcr $fcx,%d1 #; initialize FCX + isync + ji %a11 + + + + + /* + * handle clear table (i.e., fill BSS with zeros) + */ + .global __clear_table_func + .type __clear_table_func,@function + +__clear_table_func: + mov %d14,0 # %e14 =3D 0 + mov %d15,0 + movh.a %a13,hi:__clear_table # %a13 =3D &first table entry + lea %a13,[%a13]lo:__clear_table + +__clear_table_next: + ld.a %a15,[%a13+]4 # %a15 =3D current block base + ld.w %d3,[%a13+]4 # %d3 =3D current block length + jeq %d3,-1,__clear_table_done # length =3D=3D -1 =3D> end of table + sh %d0,%d3,-3 # %d0 =3D length / 8 (doublewords) + and %d1,%d3,7 # %d1 =3D length % 8 (rem. bytes) + jz %d0,__clear_word # block size < 8 =3D> clear word + addi %d0,%d0,-1 # else doublewords -=3D 1 + mov.a %a2,%d0 # %a2 =3D loop counter +__clear_dword: + st.d [%a15+]8,%e14 # clear one doubleword + loop %a2,__clear_dword +__clear_word: + jz %d1,__clear_table_next + sh %d0,%d1,-2 # %d0 =3D length / 4 (words) + and %d1,%d1,3 # %d1 =3D length % 4 (rem. bytes) + jz %d0,__clear_hword # block size < 4 =3D> clear hword + st.w [%a15+]4,%d15 # clear one word +__clear_hword: + jz %d1,__clear_table_next + sh %d0,%d1,-1 # %d0 =3D length / 2 (halfwords) + and %d1,%d1,1 # %d1 =3D length % 2 (rem. bytes) + jz %d0,__clear_byte # block size < 2 =3D> clear byte + st.h [%a15+]2,%d15 # clear one halfword +__clear_byte: + jz %d1,__clear_table_next + st.b [%a15],%d15 # clear one byte + j __clear_table_next # handle next clear table entry +__clear_table_done: + + ji %a11 + + + + /* + * handle copy table (support for romable code) + */ + .global __copy_table_func + .type __copy_table_func,@function + +__copy_table_func: + movh.a %a13,hi:__copy_table # %a13 =3D &first table entry + lea %a13,[%a13]lo:__copy_table + +__copy_table_next: + ld.a %a15,[%a13+]4 # %a15 =3D src address + ld.a %a14,[%a13+]4 # %a14 =3D dst address + ld.w %d3,[%a13+]4 # %d3 =3D block length + jeq %d3,-1,__copy_table_done # length =3D=3D -1 =3D> end of table + sh %d0,%d3,-3 # %d0 =3D length / 8 (doublewords) + and %d1,%d3,7 # %d1 =3D lenght % 8 (rem. bytes) + jz %d0,__copy_word # block size < 8 =3D> copy word + addi %d0,%d0,-1 # else doublewords -=3D 1 + mov.a %a2,%d0 # %a2 =3D loop counter +__copy_dword: + ld.d %e14,[%a15+]8 # copy one doubleword + st.d [%a14+]8,%e14 + loop %a2,__copy_dword +__copy_word: + jz %d1,__copy_table_next + sh %d0,%d1,-2 # %d0 =3D length / 4 (words) + and %d1,%d1,3 # %d1 =3D lenght % 4 (rem. bytes) + jz %d0,__copy_hword # block size < 4 =3D> copy hword + ld.w %d14,[%a15+]4 # copy one word + st.w [%a14+]4,%d14 +__copy_hword: + jz %d1,__copy_table_next + sh %d0,%d1,-1 # %d0 =3D length / 2 (halfwords) + and %d1,%d1,1 # %d1 =3D length % 2 (rem. bytes) + jz %d0,__copy_byte # block size < 2 =3D> copy byte + ld.h %d14,[%a15+]2 # copy one halfword + st.h [%a14+]2,%d14 +__copy_byte: + jz %d1,__copy_table_next + ld.b %d14,[%a15]0 # copy one byte + st.b [%a14],%d14 + j __copy_table_next # handle next copy table entry +__copy_table_done: + + ji %a11 + +_exit: + movh.a %a15, hi:__TESTDEVICE + lea %a15,[%a15]lo:__TESTDEVICE + mov.d %d2, %a14 + st.w [%a15], %d2 # write exit code to testdevice + debug + +/*=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D* + * Exception handlers (exceptions in startup code) + * + * This is a minimal trap vector table, which consists of eight + * entries, each consisting of eight words (32 bytes). + *=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D*/ + + +#; .section .traptab, "ax", @progbits + +.macro trapentry from=3D0, to=3D7 + mov.u %d14, \from << 8 + add %d14,%d14,%d15 + mov.a %a14,%d14 + addih.a %a14,%a14,0 # if we trap, we fail + j _exit +0: + j 0b + nop + rfe + .align 5 + + .if \to-\from + trapentry "(\from+1)",\to + .endif +.endm + + .align 8 + .global first_trap_table +first_trap_table: + trapentry 0, 7 + diff --git a/tests/tcg/tricore/c/test_boot_to_main.c b/tests/tcg/tricore/c/= test_boot_to_main.c new file mode 100644 index 0000000000..fa28a5b433 --- /dev/null +++ b/tests/tcg/tricore/c/test_boot_to_main.c @@ -0,0 +1,13 @@ +/* + * Copyright (C) 2023 Bastian Koppelmann + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + */ + +#include "testdev_assert.h" +int main(int argc, char **argv) +{ + testdev_assert(1); + return 0; +} diff --git a/tests/tcg/tricore/c/testdev_assert.h b/tests/tcg/tricore/c/tes= tdev_assert.h new file mode 100644 index 0000000000..ccd14f5025 --- /dev/null +++ b/tests/tcg/tricore/c/testdev_assert.h @@ -0,0 +1,18 @@ +/* + * Copyright (C) 2023 Bastian Koppelmann + * + * This code is licensed under the GPL version 2 or later. See the + * COPYING file in the top-level directory. + */ + +int *testdev =3D (int *)0xf0000000; + +#define FAIL 1 +static inline void testdev_assert(int condition) +{ + if (!condition) { + *testdev =3D FAIL; + asm("debug"); + } +} + diff --git a/tests/tcg/tricore/link.ld b/tests/tcg/tricore/link.ld index 364bcdc00a..acc1758c41 100644 --- a/tests/tcg/tricore/link.ld +++ b/tests/tcg/tricore/link.ld @@ -12,6 +12,7 @@ MEMORY /* * Define the sizes of the user and system stacks. */ +__ISTACK_SIZE =3D DEFINED (__ISTACK_SIZE) ? __ISTACK_SIZE : 256 ; __USTACK_SIZE =3D DEFINED (__USTACK_SIZE) ? __USTACK_SIZE : 1K ; /* * Define the start address and the size of the context save area. @@ -20,6 +21,8 @@ __CSA_BEGIN =3D 0xd0000000 ; __CSA_SIZE =3D 8k ; __CSA_END =3D __CSA_BEGIN + __CSA_SIZE ; =20 +__TESTDEVICE =3D 0xf0000000 ; + SECTIONS { .text : @@ -32,6 +35,18 @@ SECTIONS { *(.rodata) *(.rodata1) + /* + * Create the clear and copy tables that tell the startup code + * which memory areas to clear and to copy, respectively. + */ + . =3D ALIGN(4) ; + PROVIDE(__clear_table =3D .) ; + LONG(0 + ADDR(.bss)); LONG(SIZEOF(.bss)); + LONG(-1); LONG(-1); + PROVIDE(__copy_table =3D .) ; + LONG(LOADADDR(.data)); LONG(0 + ADDR(.data)); LONG(SIZEOF(.data)= ); + LONG(-1); LONG(-1); LONG(-1); + . =3D ALIGN(8); } > data_ram =20 .data : @@ -40,6 +55,7 @@ SECTIONS *(.data) *(.data.*) . =3D ALIGN(8) ; + __ISTACK =3D . + __ISTACK_SIZE ; __USTACK =3D . + __USTACK_SIZE -768; =20 } > data_ram --=20 2.40.1 From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082100091870.9034495969065; Thu, 25 May 2023 23:21:40 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2QoP-0008N9-79; Fri, 26 May 2023 02:20:29 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoL-0008Jl-DX for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:25 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoH-0008NS-OS for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:25 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ILMhcvw1NAt63EGrBEZ272z0+3BV/di4/2AC5226mFY=; b=lyoKdNdsV43ePY8L8lGcHXMNSs D7MG/kvyYzMlTnc4j77k2DNJB7Slf2g32VdYRFgh0Qs/nJ8OabS1amxYTL5witHI90NmDDGL/HXPq W/4cs2vxxhf8NjqZWbjDEq58kqFsMqpey1/ktiISX/UoNjHY7094etLxNSDTTr5HOPQU=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 4/6] target/tricore: Refactor PCXI/ICR register fields Date: Fri, 26 May 2023 08:19:44 +0200 Message-Id: <20230526061946.54514-5-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.60617, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.16.600001 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405243, da=172691083, mc=9, sc=0, hc=9, sp=0, fso=405243, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082102060100003 Content-Type: text/plain; charset="utf-8" starting from ISA version 1.6.1 (previously known as 1.6P/E), some bitfields in PCXI and ICR have changed. We also refactor these registers using the register fields API. Signed-off-by: Bastian Koppelmann Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1453 --- v1 -> v2: - Created ice_ie_mask for DisasCtx to simplify SYS_ENABLE and SYS_DISAB= LE insn translation. target/tricore/cpu.h | 39 ++++++++++++----- target/tricore/helper.c | 45 ++++++++++++++++++++ target/tricore/op_helper.c | 85 +++++++++++++++++++------------------- target/tricore/translate.c | 10 ++++- 4 files changed, 123 insertions(+), 56 deletions(-) diff --git a/target/tricore/cpu.h b/target/tricore/cpu.h index 47d0ffb745..d98a3fb671 100644 --- a/target/tricore/cpu.h +++ b/target/tricore/cpu.h @@ -21,6 +21,7 @@ #define TRICORE_CPU_H =20 #include "cpu-qom.h" +#include "hw/registerfields.h" #include "exec/cpu-defs.h" #include "qemu/cpu-float.h" #include "tricore-defs.h" @@ -199,13 +200,33 @@ struct ArchCPU { hwaddr tricore_cpu_get_phys_page_debug(CPUState *cpu, vaddr addr); void tricore_cpu_dump_state(CPUState *cpu, FILE *f, int flags); =20 - -#define MASK_PCXI_PCPN 0xff000000 -#define MASK_PCXI_PIE_1_3 0x00800000 -#define MASK_PCXI_PIE_1_6 0x00200000 -#define MASK_PCXI_UL 0x00400000 -#define MASK_PCXI_PCXS 0x000f0000 -#define MASK_PCXI_PCXO 0x0000ffff +FIELD(PCXI, PCPN_13, 24, 8) +FIELD(PCXI, PCPN_161, 22, 8) +FIELD(PCXI, PIE_13, 23, 1) +FIELD(PCXI, PIE_161, 21, 1) +FIELD(PCXI, UL_13, 22, 1) +FIELD(PCXI, UL_161, 20, 1) +FIELD(PCXI, PCXS, 16, 4) +FIELD(PCXI, PCXO, 0, 16) +uint32_t pcxi_get_ul(CPUTriCoreState *env); +uint32_t pcxi_get_pie(CPUTriCoreState *env); +uint32_t pcxi_get_pcpn(CPUTriCoreState *env); +uint32_t pcxi_get_pcxs(CPUTriCoreState *env); +uint32_t pcxi_get_pcxo(CPUTriCoreState *env); +void pcxi_set_ul(CPUTriCoreState *env, uint32_t val); +void pcxi_set_pie(CPUTriCoreState *env, uint32_t val); +void pcxi_set_pcpn(CPUTriCoreState *env, uint32_t val); + +FIELD(ICR, IE_161, 15, 1) +FIELD(ICR, IE_13, 8, 1) +FIELD(ICR, PIPN, 16, 8) +FIELD(ICR, CCPN, 0, 8) + +uint32_t icr_get_ie(CPUTriCoreState *env); +uint32_t icr_get_ccpn(CPUTriCoreState *env); + +void icr_set_ccpn(CPUTriCoreState *env, uint32_t val); +void icr_set_ie(CPUTriCoreState *env, uint32_t val); =20 #define MASK_PSW_USB 0xff000000 #define MASK_USB_C 0x80000000 @@ -228,10 +249,6 @@ void tricore_cpu_dump_state(CPUState *cpu, FILE *f, in= t flags); #define MASK_CPUID_MOD_32B 0x0000ff00 #define MASK_CPUID_REV 0x000000ff =20 -#define MASK_ICR_PIPN 0x00ff0000 -#define MASK_ICR_IE_1_3 0x00000100 -#define MASK_ICR_IE_1_6 0x00008000 -#define MASK_ICR_CCPN 0x000000ff =20 #define MASK_FCX_FCXS 0x000f0000 #define MASK_FCX_FCXO 0x0000ffff diff --git a/target/tricore/helper.c b/target/tricore/helper.c index 114685cce4..284a749e50 100644 --- a/target/tricore/helper.c +++ b/target/tricore/helper.c @@ -17,6 +17,7 @@ =20 #include "qemu/osdep.h" #include "qemu/log.h" +#include "hw/registerfields.h" #include "cpu.h" #include "exec/exec-all.h" #include "fpu/softfloat-helpers.h" @@ -152,3 +153,47 @@ void psw_write(CPUTriCoreState *env, uint32_t val) =20 fpu_set_state(env); } + +#define FIELD_GETTER_WITH_FEATURE(NAME, REG, FIELD, FEATURE) \ +uint32_t NAME(CPUTriCoreState *env) \ +{ \ + if (tricore_feature(env, TRICORE_FEATURE_##FEATURE)) { \ + return FIELD_EX32(env->REG, REG, FIELD ## _ ## FEATURE); \ + } \ + return FIELD_EX32(env->REG, REG, FIELD ## _13); \ +} + +#define FIELD_GETTER(NAME, REG, FIELD) \ +uint32_t NAME(CPUTriCoreState *env) \ +{ \ + return FIELD_EX32(env->REG, REG, FIELD); \ +} + +#define FIELD_SETTER_WITH_FEATURE(NAME, REG, FIELD, FEATURE) \ +void NAME(CPUTriCoreState *env, uint32_t val) \ +{ \ + if (tricore_feature(env, TRICORE_FEATURE_##FEATURE)) { \ + env->REG =3D FIELD_DP32(env->REG, REG, FIELD ## _ ## FEATURE, val)= ; \ + } \ + env->REG =3D FIELD_DP32(env->REG, REG, FIELD ## _13, val); = \ +} + +#define FIELD_SETTER(NAME, REG, FIELD) \ +void NAME(CPUTriCoreState *env, uint32_t val) \ +{ \ + env->REG =3D FIELD_DP32(env->REG, REG, FIELD, val); \ +} + +FIELD_GETTER_WITH_FEATURE(pcxi_get_pcpn, PCXI, PCPN, 161) +FIELD_SETTER_WITH_FEATURE(pcxi_set_pcpn, PCXI, PCPN, 161) +FIELD_GETTER_WITH_FEATURE(pcxi_get_pie, PCXI, PIE, 161) +FIELD_SETTER_WITH_FEATURE(pcxi_set_pie, PCXI, PIE, 161) +FIELD_GETTER_WITH_FEATURE(pcxi_get_ul, PCXI, UL, 161) +FIELD_SETTER_WITH_FEATURE(pcxi_set_ul, PCXI, UL, 161) +FIELD_GETTER(pcxi_get_pcxs, PCXI, PCXS) +FIELD_GETTER(pcxi_get_pcxo, PCXI, PCXO) + +FIELD_GETTER_WITH_FEATURE(icr_get_ie, ICR, IE, 161) +FIELD_SETTER_WITH_FEATURE(icr_set_ie, ICR, IE, 161) +FIELD_GETTER(icr_get_ccpn, ICR, CCPN) +FIELD_SETTER(icr_set_ccpn, ICR, CCPN) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index 532ae6b74c..6fd2cbe20f 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -84,11 +84,10 @@ void raise_exception_sync_internal(CPUTriCoreState *env= , uint32_t class, int tin ICR.IE and ICR.CCPN are saved */ =20 /* PCXI.PIE =3D ICR.IE */ - env->PCXI =3D ((env->PCXI & ~MASK_PCXI_PIE_1_3) + - ((env->ICR & MASK_ICR_IE_1_3) << 15)); + pcxi_set_pie(env, icr_get_ie(env)); + /* PCXI.PCPN =3D ICR.CCPN */ - env->PCXI =3D (env->PCXI & 0xffffff) + - ((env->ICR & MASK_ICR_CCPN) << 24); + pcxi_set_pcpn(env, icr_get_ccpn(env)); /* Update PC using the trap vector table */ env->PC =3D env->BTV | (class << 5); =20 @@ -2461,13 +2460,11 @@ void helper_call(CPUTriCoreState *env, uint32_t nex= t_pc) save_context_upper(env, ea); =20 /* PCXI.PCPN =3D ICR.CCPN; */ - env->PCXI =3D (env->PCXI & 0xffffff) + - ((env->ICR & MASK_ICR_CCPN) << 24); + pcxi_set_pcpn(env, icr_get_ccpn(env)); /* PCXI.PIE =3D ICR.IE; */ - env->PCXI =3D ((env->PCXI & ~MASK_PCXI_PIE_1_3) + - ((env->ICR & MASK_ICR_IE_1_3) << 15)); + pcxi_set_pie(env, icr_get_ie(env)); /* PCXI.UL =3D 1; */ - env->PCXI |=3D MASK_PCXI_UL; + pcxi_set_ul(env, 1); =20 /* PCXI[19: 0] =3D FCX[19: 0]; */ env->PCXI =3D (env->PCXI & 0xfff00000) + (env->FCX & 0xfffff); @@ -2506,7 +2503,7 @@ void helper_ret(CPUTriCoreState *env) raise_exception_sync_helper(env, TRAPC_CTX_MNG, TIN3_CSU, GETPC()); } /* if (PCXI.UL =3D=3D 0) then trap(CTYP); */ - if ((env->PCXI & MASK_PCXI_UL) =3D=3D 0) { + if (pcxi_get_ul(env) =3D=3D 0) { /* CTYP trap */ cdc_increment(&psw); /* restore to the start of helper */ psw_write(env, psw); @@ -2516,8 +2513,8 @@ void helper_ret(CPUTriCoreState *env) env->PC =3D env->gpr_a[11] & 0xfffffffe; =20 /* EA =3D {PCXI.PCXS, 6'b0, PCXI.PCXO, 6'b0}; */ - ea =3D ((env->PCXI & MASK_PCXI_PCXS) << 12) + - ((env->PCXI & MASK_PCXI_PCXO) << 6); + ea =3D (pcxi_get_pcxs(env) << 28) | + (pcxi_get_pcxo(env) << 6); /* {new_PCXI, new_PSW, A[10], A[11], D[8], D[9], D[10], D[11], A[12], A[13], A[14], A[15], D[12], D[13], D[14], D[15]} =3D M(EA, 16 * wo= rd); */ restore_context_upper(env, ea, &new_PCXI, &new_PSW); @@ -2559,21 +2556,21 @@ void helper_bisr(CPUTriCoreState *env, uint32_t con= st9) =20 =20 /* PCXI.PCPN =3D ICR.CCPN */ - env->PCXI =3D (env->PCXI & 0xffffff) + - ((env->ICR & MASK_ICR_CCPN) << 24); + pcxi_set_pcpn(env, icr_get_ccpn(env)); /* PCXI.PIE =3D ICR.IE */ - env->PCXI =3D ((env->PCXI & ~MASK_PCXI_PIE_1_3) + - ((env->ICR & MASK_ICR_IE_1_3) << 15)); + pcxi_set_pie(env, icr_get_ie(env)); /* PCXI.UL =3D 0 */ - env->PCXI &=3D ~(MASK_PCXI_UL); + pcxi_set_ul(env, 0); + /* PCXI[19: 0] =3D FCX[19: 0] */ env->PCXI =3D (env->PCXI & 0xfff00000) + (env->FCX & 0xfffff); /* FXC[19: 0] =3D new_FCX[19: 0] */ env->FCX =3D (env->FCX & 0xfff00000) + (new_FCX & 0xfffff); + /* ICR.IE =3D 1 */ - env->ICR |=3D MASK_ICR_IE_1_3; + icr_set_ie(env, 1); =20 - env->ICR |=3D const9; /* ICR.CCPN =3D const9[7: 0];*/ + icr_set_ccpn(env, const9); =20 if (tmp_FCX =3D=3D env->LCX) { /* FCD trap */ @@ -2592,7 +2589,7 @@ void helper_rfe(CPUTriCoreState *env) raise_exception_sync_helper(env, TRAPC_CTX_MNG, TIN3_CSU, GETPC()); } /* if (PCXI.UL =3D=3D 0) then trap(CTYP); */ - if ((env->PCXI & MASK_PCXI_UL) =3D=3D 0) { + if (pcxi_get_ul(env) =3D=3D 0) { /* raise CTYP trap */ raise_exception_sync_helper(env, TRAPC_CTX_MNG, TIN3_CTYP, GETPC()= ); } @@ -2603,14 +2600,15 @@ void helper_rfe(CPUTriCoreState *env) } env->PC =3D env->gpr_a[11] & ~0x1; /* ICR.IE =3D PCXI.PIE; */ - env->ICR =3D (env->ICR & ~MASK_ICR_IE_1_3) - + ((env->PCXI & MASK_PCXI_PIE_1_3) >> 15); + icr_set_ie(env, pcxi_get_pie(env)); + /* ICR.CCPN =3D PCXI.PCPN; */ - env->ICR =3D (env->ICR & ~MASK_ICR_CCPN) + - ((env->PCXI & MASK_PCXI_PCPN) >> 24); + icr_set_ccpn(env, pcxi_get_pcpn(env)); + /*EA =3D {PCXI.PCXS, 6'b0, PCXI.PCXO, 6'b0};*/ - ea =3D ((env->PCXI & MASK_PCXI_PCXS) << 12) + - ((env->PCXI & MASK_PCXI_PCXO) << 6); + ea =3D (pcxi_get_pcxs(env) << 28) | + (pcxi_get_pcxo(env) << 6); + /*{new_PCXI, PSW, A[10], A[11], D[8], D[9], D[10], D[11], A[12], A[13], A[14], A[15], D[12], D[13], D[14], D[15]} =3D M(EA, 16 * word= ); */ restore_context_upper(env, ea, &new_PCXI, &new_PSW); @@ -2628,11 +2626,10 @@ void helper_rfm(CPUTriCoreState *env) { env->PC =3D (env->gpr_a[11] & ~0x1); /* ICR.IE =3D PCXI.PIE; */ - env->ICR =3D (env->ICR & ~MASK_ICR_IE_1_3) - | ((env->PCXI & MASK_PCXI_PIE_1_3) >> 15); + icr_set_ie(env, pcxi_get_pie(env)); /* ICR.CCPN =3D PCXI.PCPN; */ - env->ICR =3D (env->ICR & ~MASK_ICR_CCPN) | - ((env->PCXI & MASK_PCXI_PCPN) >> 24); + icr_set_ccpn(env, pcxi_get_pcpn(env)); + /* {PCXI, PSW, A[10], A[11]} =3D M(DCX, 4 * word); */ env->PCXI =3D cpu_ldl_data(env, env->DCX); psw_write(env, cpu_ldl_data(env, env->DCX+4)); @@ -2691,13 +2688,13 @@ void helper_svlcx(CPUTriCoreState *env) save_context_lower(env, ea); =20 /* PCXI.PCPN =3D ICR.CCPN; */ - env->PCXI =3D (env->PCXI & 0xffffff) + - ((env->ICR & MASK_ICR_CCPN) << 24); + pcxi_set_pcpn(env, icr_get_ccpn(env)); + /* PCXI.PIE =3D ICR.IE; */ - env->PCXI =3D ((env->PCXI & ~MASK_PCXI_PIE_1_3) + - ((env->ICR & MASK_ICR_IE_1_3) << 15)); + pcxi_set_pie(env, icr_get_ie(env)); + /* PCXI.UL =3D 0; */ - env->PCXI &=3D ~MASK_PCXI_UL; + pcxi_set_ul(env, 0); =20 /* PCXI[19: 0] =3D FCX[19: 0]; */ env->PCXI =3D (env->PCXI & 0xfff00000) + (env->FCX & 0xfffff); @@ -2734,13 +2731,13 @@ void helper_svucx(CPUTriCoreState *env) save_context_upper(env, ea); =20 /* PCXI.PCPN =3D ICR.CCPN; */ - env->PCXI =3D (env->PCXI & 0xffffff) + - ((env->ICR & MASK_ICR_CCPN) << 24); + pcxi_set_pcpn(env, icr_get_ccpn(env)); + /* PCXI.PIE =3D ICR.IE; */ - env->PCXI =3D ((env->PCXI & ~MASK_PCXI_PIE_1_3) + - ((env->ICR & MASK_ICR_IE_1_3) << 15)); + pcxi_set_pie(env, icr_get_ie(env)); + /* PCXI.UL =3D 1; */ - env->PCXI |=3D MASK_PCXI_UL; + pcxi_set_ul(env, 1); =20 /* PCXI[19: 0] =3D FCX[19: 0]; */ env->PCXI =3D (env->PCXI & 0xfff00000) + (env->FCX & 0xfffff); @@ -2764,13 +2761,15 @@ void helper_rslcx(CPUTriCoreState *env) raise_exception_sync_helper(env, TRAPC_CTX_MNG, TIN3_CSU, GETPC()); } /* if (PCXI.UL =3D=3D 1) then trap(CTYP); */ - if ((env->PCXI & MASK_PCXI_UL) !=3D 0) { + if (pcxi_get_ul(env) =3D=3D 1) { /* CTYP trap */ raise_exception_sync_helper(env, TRAPC_CTX_MNG, TIN3_CTYP, GETPC()= ); } /* EA =3D {PCXI.PCXS, 6'b0, PCXI.PCXO, 6'b0}; */ - ea =3D ((env->PCXI & MASK_PCXI_PCXS) << 12) + - ((env->PCXI & MASK_PCXI_PCXO) << 6); + /* EA =3D {PCXI.PCXS, 6'b0, PCXI.PCXO, 6'b0}; */ + ea =3D (pcxi_get_pcxs(env) << 28) | + (pcxi_get_pcxo(env) << 6); + /* {new_PCXI, A[11], A[10], A[11], D[8], D[9], D[10], D[11], A[12], A[13], A[14], A[15], D[12], D[13], D[14], D[15]} =3D M(EA, 16 * wo= rd); */ restore_context_lower(env, ea, &env->gpr_a[11], &new_PCXI); diff --git a/target/tricore/translate.c b/target/tricore/translate.c index 2646cb3eb5..e7bbfb062d 100644 --- a/target/tricore/translate.c +++ b/target/tricore/translate.c @@ -72,6 +72,7 @@ typedef struct DisasContext { int mem_idx; uint32_t hflags, saved_hflags; uint64_t features; + uint32_t icr_ie_mask; } DisasContext; =20 static int has_feature(DisasContext *ctx, int feature) @@ -7847,12 +7848,12 @@ static void decode_sys_interrupts(DisasContext *ctx) /* raise EXCP_DEBUG */ break; case OPC2_32_SYS_DISABLE: - tcg_gen_andi_tl(cpu_ICR, cpu_ICR, ~MASK_ICR_IE_1_3); + tcg_gen_andi_tl(cpu_ICR, cpu_ICR, ~ctx->icr_ie_mask); break; case OPC2_32_SYS_DSYNC: break; case OPC2_32_SYS_ENABLE: - tcg_gen_ori_tl(cpu_ICR, cpu_ICR, MASK_ICR_IE_1_3); + tcg_gen_ori_tl(cpu_ICR, cpu_ICR, ctx->icr_ie_mask); break; case OPC2_32_SYS_ISYNC: break; @@ -8256,6 +8257,11 @@ static void tricore_tr_init_disas_context(DisasConte= xtBase *dcbase, ctx->mem_idx =3D cpu_mmu_index(env, false); ctx->hflags =3D (uint32_t)ctx->base.tb->flags; ctx->features =3D env->features; + if (has_feature(ctx, TRICORE_FEATURE_161)) { + ctx->icr_ie_mask =3D R_ICR_IE_161_MASK; + } else { + ctx->icr_ie_mask =3D R_ICR_IE_13_MASK; + } } =20 static void tricore_tr_tb_start(DisasContextBase *db, CPUState *cpu) --=20 2.40.1 From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082112484521.2097588162306; Thu, 25 May 2023 23:21:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2Qoi-0000Hm-MW; Fri, 26 May 2023 02:20:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoP-0008QG-32 for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:29 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoN-0008Q7-Go for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:28 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=3q0t2gakp1qQAsQa1aszmIce4e8Xa6xdkt46NhrHDhE=; b=KA35J4hS2gog7lW2bgr7JEL+Tz nsMO7JBdvXmoOQrrMM29av4IKScakMDpbr7KZgLbAwWSJD/89GD6AWpflKn/qSjuU5DH0bRV8jYDj GamRfMLXMMhpK8KF0Hgq/lLBTk46WEDm6zQQrLh1MSRhqWSGhCarrxcOqRwgPqT+Nm48=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 5/6] target/tricore: Fix wrong PSW for call insns Date: Fri, 26 May 2023 08:19:45 +0200 Message-Id: <20230526061946.54514-6-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.60617, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.25.600000 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405250, da=172691090, mc=11, sc=0, hc=11, sp=0, fso=405250, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082113990100003 Content-Type: text/plain; charset="utf-8" we were copying PSW into a local variable, updated PSW.CDE in the local and never wrote it back. So when we called save_context_upper() we were using the non-local version of PSW which did not contain the updated PSW.CDE. Signed-off-by: Bastian Koppelmann --- target/tricore/op_helper.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/target/tricore/op_helper.c b/target/tricore/op_helper.c index 6fd2cbe20f..54f54811d9 100644 --- a/target/tricore/op_helper.c +++ b/target/tricore/op_helper.c @@ -2447,6 +2447,8 @@ void helper_call(CPUTriCoreState *env, uint32_t next_= pc) } /* PSW.CDE =3D 1;*/ psw |=3D MASK_PSW_CDE; + psw_write(env, psw); + /* tmp_FCX =3D FCX; */ tmp_FCX =3D env->FCX; /* EA =3D {FCX.FCXS, 6'b0, FCX.FCXO, 6'b0}; */ --=20 2.40.1 From nobody Fri Apr 26 21:28:19 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=mail.uni-paderborn.de Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1685082131627750.2576341113485; Thu, 25 May 2023 23:22:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q2Qox-0000Xq-9h; Fri, 26 May 2023 02:21:03 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2Qod-0000I8-IS for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:45 -0400 Received: from hoth.uni-paderborn.de ([2001:638:502:c003::19]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q2QoT-0008TU-6Y for qemu-devel@nongnu.org; Fri, 26 May 2023 02:20:43 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mail.uni-paderborn.de; s=20170601; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=6dS65BHceE/gk9tf87DHKXirrrBzDS/IfWiY+wR9vZ0=; b=L202/95f69L8Y32nI0s46NnUoy 4W61AlAFVsShqT9Ee6Qnxs9kiCQB06Op2MydQvJLGVmXhzdYWPlNpu6oo5/bESfcek48XbEEiVRx0 +5LZUFicrs4KDmBPEJsv5hKq3a8tFkD90LkS0ukplXORBAYbMSMaDLqmguXZctQACI00=; X-Envelope-From: From: Bastian Koppelmann To: qemu-devel@nongnu.org Cc: kbastian@mail.uni-paderborn.de Subject: [PATCH v2 6/6] tests/tcg/tricore: Add recursion test for CSAs Date: Fri, 26 May 2023 08:19:46 +0200 Message-Id: <20230526061946.54514-7-kbastian@mail.uni-paderborn.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> References: <20230526061946.54514-1-kbastian@mail.uni-paderborn.de> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-PMX-Version: 6.4.9.2830568, Antispam-Engine: 2.7.2.2107409, Antispam-Data: 2023.5.26.61217, AntiVirus-Engine: 6.0.0, AntiVirus-Data: 2023.5.16.600001 X-Sophos-SenderHistory: ip=84.184.48.71, fs=405255, da=172691095, mc=13, sc=0, hc=13, sp=0, fso=405255, re=0, sd=0, hd=0 X-IMT-Source: Intern X-IMT-Spam-Score: 0.0 () X-IMT-Authenticated-Sender: uid=kbastian,ou=People,o=upb,c=de Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2001:638:502:c003::19; envelope-from=kbastian@mail.uni-paderborn.de; helo=hoth.uni-paderborn.de X-Spam_score_int: -19 X-Spam_score: -2.0 X-Spam_bar: -- X-Spam_report: (-2.0 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1685082132388100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Bastian Koppelmann --- tests/tcg/tricore/Makefile.softmmu-target | 3 ++- tests/tcg/tricore/c/test_context_save_areas.c | 15 +++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 tests/tcg/tricore/c/test_context_save_areas.c diff --git a/tests/tcg/tricore/Makefile.softmmu-target b/tests/tcg/tricore/= Makefile.softmmu-target index f051444991..aff7c1b580 100644 --- a/tests/tcg/tricore/Makefile.softmmu-target +++ b/tests/tcg/tricore/Makefile.softmmu-target @@ -4,7 +4,7 @@ C_TESTS_PATH =3D $(TESTS_PATH)/c =20 LDFLAGS =3D -T$(TESTS_PATH)/link.ld --mcpu=3Dtc162 ASFLAGS =3D -mtc162 -CFLAGS =3D -mtc162 -c +CFLAGS =3D -mtc162 -c -I$(TESTS_PATH) =20 TESTS +=3D test_abs.asm.tst TESTS +=3D test_bmerge.asm.tst @@ -23,6 +23,7 @@ TESTS +=3D test_msub.asm.tst TESTS +=3D test_muls.asm.tst =20 TESTS +=3D test_boot_to_main.c.tst +TESTS +=3D test_context_save_areas.c.tst =20 QEMU_OPTS +=3D -M tricore_testboard -cpu tc27x -nographic -kernel =20 diff --git a/tests/tcg/tricore/c/test_context_save_areas.c b/tests/tcg/tric= ore/c/test_context_save_areas.c new file mode 100644 index 0000000000..a300ee2f9c --- /dev/null +++ b/tests/tcg/tricore/c/test_context_save_areas.c @@ -0,0 +1,15 @@ +#include "testdev_assert.h" + +static int fib(int n) +{ + if (n =3D=3D 1 || n =3D=3D 2) { + return 1; + } + return fib(n - 2) + fib(n - 1); +} + +int main(int argc, char **argv) +{ + testdev_assert(fib(10) =3D=3D 55); + return 0; +} --=20 2.40.1