From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2098.outbound.protection.outlook.com [40.107.104.98]) by sourceware.org (Postfix) with ESMTPS id EA1733857011 for ; Wed, 14 Feb 2024 13:00:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org EA1733857011 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=Syrmia.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=Syrmia.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org EA1733857011 Authentication-Results: server2.sourceware.org; arc=pass smtp.remote-ip=40.107.104.98 ARC-Seal: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707915629; cv=pass; b=d2UaYM/2FyEUR2fHSsTqEBE6ON7mBYtbhCILU4GKPE11zdpYM/YUAMnXSmlfyyWn2q4NWQBnYbJxfwbngWLkkBSPzqzYxrCs7wk4QWZTv4yyTt/2o0skFs2xDoG/AxdTL7Uoa28c32Kb61uWc+WFIW4RQZlmv8jS9TS49T9jVsk= ARC-Message-Signature: i=2; a=rsa-sha256; d=sourceware.org; s=key; t=1707915629; c=relaxed/simple; bh=yz0RnGU8DI5MJyMhxULPbBEweqkr+i6WzyLV8uV2Was=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=ovCmu6lP9Uktn97ERF6dqVgBuGeVqUT2sRc+uLKrTHy4XLTysT3P9eYtj8cqR9vkuN4RDoUyKaKeMEZ3Sr9ep3ZD/pjLAz2tjUaK2rrXPu8I85YmiwSsaI7n/aLqoumRbBjGSF26THDvFEzbU/vsb+40wLthPVW/vUNL1Yt1XUo= ARC-Authentication-Results: i=2; server2.sourceware.org ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jh5wvZpFcGyllt+6mE5kMMybKZWBblYjLMSDwrDnQ9iQ7wQfZGS9DT/zvd0rgt8syv2Nh43rM7wo62bXuTXF3obw+pFcIGeK0YHeTohoBLZEzdrib+aHW7cHmIg8ZCv/oSAByXe90ouiCjubPZPhX/81BD6J+ffkg5jTnV7R8cFT/7Pnz+pCA9FhLWQp5MdOErgeDdMWmQRevxWcPlcHkmVyQsmJWJF7lEEzT6XOeWPUiYigJf2aELmfjKemJkipzJbMcP8LzIpR8SRZaXl3vY/YF8IbXi3/dTnRO0rxvJGj8ZxfVHqul5HlGqt+C4TGowr2D0tJPrprYyVdzp27uA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=C3L8RDuGL1i7iXt2m0/nZo98awhd369khOaxxSZucP8=; b=I1aIzD2rRFAIkZ/r604UbxO2rMdLMK6fih+pVa43+zG7oLzsh2L5nzjZlMbYKF3QsYAbh1x52X5o8Tllql8Ifs+vGbPaHAS6xsgQpgsddwvq5PMl5M2IY2Pkbx8H23PBdGRCX1YdjV0HLoM8qd4NIiT64uoHPPYv+fvdfOfwKtO/NEVaRTvYQ7GjFd7ozmNRTPGle3fwY6kLMYIjuQGh4NFF0tWY0whk5kwjZV2WvAu54SkrL1E/8EBjSuVRJz5fUAijime3FL58hjR6xSuFsPgyuMGgQsx4ISjCrbKWDViZNyUmi2oG2gHuQABFCwSKYgERTEliCf55kL6Mdg2h+w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=syrmia.com; dmarc=pass action=none header.from=syrmia.com; dkim=pass header.d=syrmia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=syrmia.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=C3L8RDuGL1i7iXt2m0/nZo98awhd369khOaxxSZucP8=; b=w5l+1sskGmupTD9OXqbeqAvCngnYwfnbfd4fnKJUIy3Eh1n5dbU+fGxPGoilFSssQuHfWy3/5Fq/XtamvTGKgacGkbwCyhi4gtLSZITdzXg1jjL+YyTSyokO++rdDN3pE0u3tUnCpfLPGX8R9MdibcwnXfxFdOAA5V0mL/mJNyI= Received: from AS8PR03MB9698.eurprd03.prod.outlook.com (2603:10a6:20b:61e::8) by AM9PR03MB8010.eurprd03.prod.outlook.com (2603:10a6:20b:43d::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7292.27; Wed, 14 Feb 2024 13:00:19 +0000 Received: from AS8PR03MB9698.eurprd03.prod.outlook.com ([fe80::f06b:6555:5f32:e5e7]) by AS8PR03MB9698.eurprd03.prod.outlook.com ([fe80::f06b:6555:5f32:e5e7%3]) with mapi id 15.20.7270.036; Wed, 14 Feb 2024 13:00:19 +0000 From: Milos Kalicanin To: "gdb-patches@sourceware.org" CC: Andrew Burgess , "Maciej W . Rozycki" , Chao-ying Fu , Simon Marchi , Djordje Todorovic , Dragan Mladjenovic Subject: [PATCH^4] gdb: mips: Add MIPSR6 support Thread-Topic: [PATCH^4] gdb: mips: Add MIPSR6 support Thread-Index: AQHaX0U+Yk0aMjt8OEOKRSlnpGmk9Q== Date: Wed, 14 Feb 2024 13:00:19 +0000 Message-ID: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: msip_labels: authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=Syrmia.com; x-ms-publictraffictype: Email x-ms-traffictypediagnostic: AS8PR03MB9698:EE_|AM9PR03MB8010:EE_ x-ms-office365-filtering-correlation-id: ca01cb1a-891a-4401-d8c3-08dc2d5ce5d2 x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: oYeKvsYq50dWkNMJvv/oiNuEvclNJWoqFEhZNXUohrPVUOjze9ft/sHmaUoSrP9FLF6ocSXCH+eVLVvDCW6KNNP37G4ieE8HH6JYDyi/i1iHX7qY74oZ6+XpJOcfZ/hvBACvvYy0xy02dXz/xcOK699WLR3wp2yeXsISr5xh7NwrqQSakf9S3lsrjXy8NZ0wfuytp0jyd2jOPkSZUQgTJYT1URCXF2/PQXDke2eNLRT1o2Wcn2f5neYn0+XVPMOV8MrcPjdOI2HnY1UGsXViyPNn0Dm4RVoU77zfsi2wHludL/gndoyhlKViyvgw6zP4kkXaGUxv7B1+AkpvoWJRFhq21HOfYME6iTHfSeQTaVY9LJStxbxLPdd4GCoOGoVCMcqtEwXTah6kQ3X71gEc0TXL+Zn19DgXhhFHVj2kDS1SrNBLnQHcBDfBoU0pJ/uiiiaRbHG5giEUPHXcLBZRsKUBf3KHoCAu2ak97aqQFOA0xGlQJGBcEbtsV/fZLBhzHOOiFZvd+trzb0kG/i74zF/K5XUc8v8i90LMFVJRv/JFw2NcjkIA0SWkKaXgf5KUA9R8MuPs2xdYEBYUo4ojSULocPMo/nyJeZ/qUcwIrlg= x-forefront-antispam-report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AS8PR03MB9698.eurprd03.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(396003)(376002)(39840400004)(366004)(346002)(136003)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(5660300002)(8936002)(4326008)(8676002)(6916009)(91956017)(52536014)(66446008)(64756008)(66476007)(66946007)(76116006)(66556008)(30864003)(2906002)(83380400001)(38070700009)(26005)(33656002)(122000001)(38100700002)(86362001)(71200400001)(54906003)(316002)(107886003)(41300700001)(6506007)(7696005)(478600001)(9686003)(966005)(55016003)(66899024)(559001)(579004);DIR:OUT;SFP:1102; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?oPR5uMdTFXzrp1G83MKG68mp/PKKtBjv9we76aFw0tPrAZPS+vS2Kw5ThT?= =?iso-8859-1?Q?LzIjsU9vSYAINhgPb5fbu8uVTgRE518BAcXZQyPrl7csGS6OhVJReMlnyr?= =?iso-8859-1?Q?lzdToxrTroi803Z3a86K/080wyw2DrMF3RHuN6s50IxBIV6yTBB9GHOt1K?= =?iso-8859-1?Q?LQf2EyCZJWC4AQyVBM7zWz4n++mqj51gy6DInALRxaqNJdJQ+XGwRd9Mkl?= =?iso-8859-1?Q?g6+iG9AlJzabCZLM8QZFgSFkG8tGzMYtdM6Pdrbx4AxhgPp2RbqksVIUSC?= =?iso-8859-1?Q?NzPYkrCq0vBW95HLqlyHu8XammgNbcenVhJwJ0f0cq4rjtmkJHxg95TPTJ?= =?iso-8859-1?Q?LKUijhVKfCHXXgs7a+npghPJLYpViCV5NG2TMlwks8VzEzolcGdvunGxPn?= =?iso-8859-1?Q?5ejP5p3cBJpX/5Ln1etwFBCwGDaO0unC2E1OSBC2CLMxl15bXKXxNhwqcx?= =?iso-8859-1?Q?FCf50CPzddfbWKSV+S/SVpEeQSdUjZCfBLZIKQF+pcdda1BG5CmIfgU1dP?= =?iso-8859-1?Q?QwG7d8aDYfNJKGVPqjtrKBN/pOPSGY0cyoqW7KIlJTgUJEwwsvOCn7lq6i?= =?iso-8859-1?Q?WJXoyTy3BOiRBrZdjrQZrdNoZ90k2AvletB6UdvKdqYatUm3TAq36qZP/M?= =?iso-8859-1?Q?TanGIfTqLMXl1NrxtB7B22fOPiZRYO5kDj7a7SC4MQU7Fznpa+mlJ8XcyQ?= =?iso-8859-1?Q?wP0KH+PhX/O25/AIX32DvpR5lxTliSZUf2NPi675VS/RDj1F6Hrd61cR/l?= =?iso-8859-1?Q?bGOfCQSlQtkGtzW2SJneO7oXyDkcvWbBjhbXt3hCSzj3tInhjlkySk+/Ng?= =?iso-8859-1?Q?UeoSO+XBJ/RHG5brRrhn3fUJoDgRSJpcZ+cFDmMjX0QbycqFrLdZSzgD4I?= =?iso-8859-1?Q?93cxg78dwHr4TCnz76eQlw+wj5zf3nvDNnmXdE2yYzv6BEK2BotEd/F1du?= =?iso-8859-1?Q?qi8PL5UUhL+yhyovXkbs5VKn/6hn4keRULebDbm5RsCpCcrNp+PLWWhdO0?= =?iso-8859-1?Q?iBbZVfAsEtfqn8nNL9qyX1Zebg/jKKZli4peIt3kBKT5UCX/47fi5epKAj?= =?iso-8859-1?Q?rpFL1ypMcYinRhRm1D/XD8xAcBkDwC8zEEYdqmsFl58I6kPtzm44uk5I5a?= =?iso-8859-1?Q?8E7f1R+Y+bKmj9FvmpV3cSqZyRa+aQlGtjbYyYR9UNUUn+KLFsMAT5U7bW?= =?iso-8859-1?Q?/TiwaoZbF7HzQCEdHq7RAHCQ2Q1wGYsP53GIesgjjys2WaDoEQx9Pf+siB?= =?iso-8859-1?Q?j9itF7XdLjTlhex3HFvoi/yH64HIJmRT227dEFNO5vsEFiEsYBs7vuNK4o?= =?iso-8859-1?Q?HPiOG7Rx67oHQ2dqIrb3HZHxBKjC/JYKXM2AO0RN4QL3KcfD/6Turgd2qJ?= =?iso-8859-1?Q?ZkxHKCBUtOx5HXLcZRshgOFX/1LKmZ9nhFcVKTPbAZ4Vtieiskgh6dyzcb?= =?iso-8859-1?Q?ukfU5e81XkhZXx5VHHlOz1bPDZB1oqNF+G1FchLwooCWcuCaqdS7G6lEKW?= =?iso-8859-1?Q?wAVujYUjAwj+2zHaPo138lfDsfoINsBHZbCElCTj5+0edCRTG6ezbQ8U/s?= =?iso-8859-1?Q?3xvw1KP3whqbCzPUGGNLNmiQfVY04wRBRYx2XGQj6nMXhr6CTcNZzunafc?= =?iso-8859-1?Q?cF0V6lDhgOd+md3+7YM+hfZu08Q7nejmLM?= Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: syrmia.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: AS8PR03MB9698.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: ca01cb1a-891a-4401-d8c3-08dc2d5ce5d2 X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Feb 2024 13:00:19.5251 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 19214a73-c1ab-4e19-8f59-14bdcb09a66e X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: jlumdLhVIC2MTT+52qQzCexYcan3gjioHESyMma9ZJbi4VVyyGhPQT0xDpVR1IqxTcfdGYfpqYt7s44h+fAUyUhEHeSfkKnQdMymsPzHoEI= X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR03MB8010 X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,KAM_SHORT,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS,TXREP,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Introduce new instruction encodings from Release 6 of the MIPS=0A= architecture [1]. Support breakpoints and single stepping with=0A= compact branches, forbidden slots, new branch instruction and=0A= new atomic load-store instruction encodings.=0A= =0A= Changes from v3: Apply code formatting as Simon Marchi suggested.=0A= =0A= [1] "MIPS64 Architecture for Programmers Volume II-A: The MIPS64=0A= Instruction Set Reference Manual", Document Number: MD00087,=0A= Revision 6.06, December 15, 2016, Section 3 "The MIPS64=0A= Instruction Set", pp. 42-530=0A= https://s3-eu-west-1.amazonaws.com/downloads-mips/documents/MD00087-2B-MIPS= 64BIS-AFP-6.06.pdf=0A= =0A= 2024-02-14 Andrew Bennett =0A= Matthew Fortune =0A= Faraz Shahbazker =0A= =0A= gdb/ChangeLog:=0A= * mips-tdep.c (is_mipsr6_isa): New.=0A= (b0s21_imm): New define.=0A= (mips32_relative_offset21, mips32_relative_offset26): New.=0A= (is_add32bit_overflow, is_add64bit_overflow): New.=0A= (mips32_next_pc): Handle r6 compact and fpu coprocessor branches.= =0A= Move handling of BLEZ, BGTZ opcode into ...=0A= (mips32_blez_pc): New.=0A= (mips32_instruction_is_compact_branch): New.=0A= (mips32_insn_at_pc_has_forbidden_slot): New.=0A= (mips32_scan_prologue): Ignore pre-r6 addi encoding on r6.=0A= Stop at compact branch also.=0A= (LLSC_R6_OPCODE,LL_R6_FUNCT,LLE_FUNCT,=0A= LLD_R6_FUNCT,SC_R6_FUNCT,SCE_FUNCT,=0A= SCD_R6_FUNCT: New defines.=0A= (is_ll_insn, is_sc_insn): New.=0A= (mips_deal_with_atomic_sequence): Use is_ll_insn/is_sc_insn.=0A= Handle compact branches.=0A= (mips_about_to_return): Handle jrc and macro jr.=0A= (mips32_stack_frame_destroyed_p): Likewise.=0A= (mips32_instruction_has_delay_slot): Don't handle JALX on r6.=0A= Handle compact branches and coprocessor branches.=0A= (mips_adjust_breakpoint_address): Skip forbidden slot for=0A= compact branches.=0A= ---=0A= gdb/mips-tdep.c | 538 +++++++++++++--=0A= gdb/testsuite/gdb.arch/mips-64-r6.c | 913 ++++++++++++++++++++++++++=0A= gdb/testsuite/gdb.arch/mips-64-r6.exp | 88 +++=0A= 3 files changed, 1492 insertions(+), 47 deletions(-)=0A= create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.c=0A= create mode 100644 gdb/testsuite/gdb.arch/mips-64-r6.exp=0A= =0A= diff --git a/gdb/mips-tdep.c b/gdb/mips-tdep.c=0A= index bf0b66c4b00..609932100cf 100644=0A= --- a/gdb/mips-tdep.c=0A= +++ b/gdb/mips-tdep.c=0A= @@ -60,7 +60,7 @@=0A= =0A= static struct type *mips_register_type (struct gdbarch *gdbarch, int regnu= m);=0A= =0A= -static int mips32_instruction_has_delay_slot (struct gdbarch *gdbarch,=0A= +static bool mips32_instruction_has_delay_slot (struct gdbarch *gdbarch,=0A= ULONGEST inst);=0A= static int micromips_instruction_has_delay_slot (ULONGEST insn, int mustbe= 32);=0A= static int mips16_instruction_has_delay_slot (unsigned short inst,=0A= @@ -76,6 +76,9 @@ static int mips16_insn_at_pc_has_delay_slot (struct gdbar= ch *gdbarch,=0A= static void mips_print_float_info (struct gdbarch *, struct ui_file *,=0A= frame_info_ptr, const char *);=0A= =0A= +static void mips_read_fp_register_single (struct frame_info_ptr, int,=0A= + gdb_byte *);=0A= +=0A= /* A useful bit in the CP0 status register (MIPS_PS_REGNUM). */=0A= /* This bit is set if we are emulating 32-bit FPRs on a 64-bit chip. */= =0A= #define ST0_FR (1 << 26)=0A= @@ -124,6 +127,10 @@ enum mips_breakpoint_kind=0A= MIPS_BP_KIND_MICROMIPS32 =3D 5,=0A= };=0A= =0A= +/* Enum describing type of compact branch or jump. */=0A= +enum compact_branch_type=0A= +{ COMP_BRANCH_NONE =3D 0, COMP_BRANCH_UNCOND =3D 1, COMP_BRANCH_COND =3D 2= };=0A= +=0A= /* For backwards compatibility we default to MIPS16. This flag is=0A= overridden as soon as unambiguous ELF file flags tell us the=0A= compressed ISA encoding used. */=0A= @@ -1500,6 +1507,16 @@ mips_fetch_instruction (struct gdbarch *gdbarch,=0A= return extract_unsigned_integer (buf, instlen, byte_order);=0A= }=0A= =0A= +/* Return true if the gdbarch is based on MIPS Release 6. */=0A= +static bool=0A= +is_mipsr6_isa (struct gdbarch *gdbarch)=0A= +{=0A= + const struct bfd_arch_info *info =3D gdbarch_bfd_arch_info (gdbarch);=0A= +=0A= + return (info->mach =3D=3D bfd_mach_mipsisa32r6=0A= + || info->mach =3D=3D bfd_mach_mipsisa64r6);=0A= +}=0A= +=0A= /* These are the fields of 32 bit mips instructions. */=0A= #define mips32_op(x) (x >> 26)=0A= #define itype_op(x) (x >> 26)=0A= @@ -1542,6 +1559,7 @@ mips_fetch_instruction (struct gdbarch *gdbarch,=0A= #define b0s11_op(x) ((x) & 0x7ff)=0A= #define b0s12_imm(x) ((x) & 0xfff)=0A= #define b0s16_imm(x) ((x) & 0xffff)=0A= +#define b0s21_imm(x) ((x) & 0x1fffff)=0A= #define b0s26_imm(x) ((x) & 0x3ffffff)=0A= #define b6s10_ext(x) (((x) >> 6) & 0x3ff)=0A= #define b11s5_reg(x) (((x) >> 11) & 0x1f)=0A= @@ -1578,6 +1596,18 @@ mips32_relative_offset (ULONGEST inst)=0A= return ((itype_immediate (inst) ^ 0x8000) - 0x8000) << 2;=0A= }=0A= =0A= +static LONGEST=0A= +mips32_relative_offset21 (ULONGEST insn)=0A= +{=0A= + return ((b0s21_imm (insn) ^ 0x100000) - 0x100000) << 2;=0A= +}=0A= +=0A= +static LONGEST=0A= +mips32_relative_offset26 (ULONGEST insn)=0A= +{=0A= + return ((b0s26_imm (insn) ^ 0x2000000) - 0x2000000) << 2;=0A= +}=0A= +=0A= /* Determine the address of the next instruction executed after the INST= =0A= floating condition branch instruction at PC. COUNT specifies the=0A= number of the floating condition bits tested by the branch. */=0A= @@ -1636,6 +1666,71 @@ is_octeon_bbit_op (int op, struct gdbarch *gdbarch)= =0A= return 0;=0A= }=0A= =0A= +static bool=0A= +is_add32bit_overflow (int32_t a, int32_t b)=0A= +{=0A= + int32_t r =3D (uint32_t) a + (uint32_t) b;=0A= + return (a < 0 && b < 0 && r >=3D 0) || (a >=3D 0 && b >=3D 0 && r < 0);= =0A= +}=0A= +=0A= +static bool=0A= +is_add64bit_overflow (int64_t a, int64_t b)=0A= +{=0A= + if (a !=3D (int32_t) a)=0A= + return true;=0A= + if (b !=3D (int32_t) b)=0A= + return true;=0A= + return is_add32bit_overflow ((int32_t) a, (int32_t) b);=0A= +}=0A= +=0A= +/* Calculate address of next instruction after BLEZ. */=0A= +=0A= +static CORE_ADDR=0A= +mips32_blez_pc (struct gdbarch *gdbarch, struct regcache *regcache,=0A= + ULONGEST inst, CORE_ADDR pc, int invert)=0A= +{=0A= + int rs =3D itype_rs (inst);=0A= + int rt =3D itype_rt (inst);=0A= + LONGEST val_rs =3D regcache_raw_get_signed (regcache, rs);=0A= + LONGEST val_rt =3D regcache_raw_get_signed (regcache, rt);=0A= + ULONGEST uval_rs =3D regcache_raw_get_unsigned (regcache, rs);=0A= + ULONGEST uval_rt =3D regcache_raw_get_unsigned (regcache, rt);=0A= + bool taken =3D false;=0A= + int delay_slot_size =3D 4;=0A= +=0A= + /* BLEZ, BLEZL, BGTZ, BGTZL */=0A= + if (rt =3D=3D 0)=0A= + taken =3D (val_rs <=3D 0);=0A= + else if (is_mipsr6_isa (gdbarch))=0A= + {=0A= + /* BLEZALC, BGTZALC */=0A= + if (rs =3D=3D 0 && rt !=3D 0)=0A= + taken =3D (val_rt <=3D 0);=0A= + /* BGEZALC, BLTZALC */=0A= + else if (rs =3D=3D rt && rt !=3D 0)=0A= + taken =3D (val_rt >=3D 0);=0A= + /* BGEUC, BLTUC */=0A= + else if (rs !=3D rt && rs !=3D 0 && rt !=3D 0)=0A= + taken =3D (uval_rs >=3D uval_rt);=0A= +=0A= + /* Step through the forbidden slot to avoid repeated exceptions we d= o=0A= + not currently have access to the BD bit when hitting a breakpoint=0A= + and therefore cannot tell if the breakpoint hit on the branch or the=0A= + forbidden slot. */=0A= + /* delay_slot_size =3D 0; */=0A= + }=0A= +=0A= + if (invert)=0A= + taken =3D !taken;=0A= +=0A= + /* Calculate branch target. */=0A= + if (taken)=0A= + pc +=3D mips32_relative_offset (inst);=0A= + else=0A= + pc +=3D delay_slot_size;=0A= +=0A= + return pc;=0A= +}=0A= =0A= /* Determine where to set a single step breakpoint while considering=0A= branch prediction. */=0A= @@ -1646,12 +1741,14 @@ mips32_next_pc (struct regcache *regcache, CORE_ADD= R pc)=0A= struct gdbarch *gdbarch =3D regcache->arch ();=0A= unsigned long inst;=0A= int op;=0A= + bool mips64bitreg =3D mips_isa_regsize (gdbarch) =3D=3D 8;=0A= +=0A= inst =3D mips_fetch_instruction (gdbarch, ISA_MIPS, pc, NULL);=0A= op =3D itype_op (inst);=0A= if ((inst & 0xe0000000) !=3D 0) /* Not a special, jump or branch=0A= instruction. */=0A= {=0A= - if (op >> 2 =3D=3D 5)=0A= + if (op >> 2 =3D=3D 5 && ((op & 0x02) =3D=3D 0 || itype_rt (inst) =3D= =3D 0))=0A= /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */=0A= {=0A= switch (op & 0x03)=0A= @@ -1661,7 +1758,7 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR = pc)=0A= case 1: /* BNEL */=0A= goto neq_branch;=0A= case 2: /* BLEZL */=0A= - goto less_branch;=0A= + goto lez_branch;=0A= case 3: /* BGTZL */=0A= goto greater_branch;=0A= default:=0A= @@ -1671,15 +1768,19 @@ mips32_next_pc (struct regcache *regcache, CORE_ADD= R pc)=0A= else if (op =3D=3D 17 && itype_rs (inst) =3D=3D 8)=0A= /* BC1F, BC1FL, BC1T, BC1TL: 010001 01000 */=0A= pc =3D mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 1);=0A= - else if (op =3D=3D 17 && itype_rs (inst) =3D=3D 9=0A= + else if (!is_mipsr6_isa (gdbarch)=0A= + && op =3D=3D 17=0A= + && itype_rs (inst) =3D=3D 9=0A= && (itype_rt (inst) & 2) =3D=3D 0)=0A= /* BC1ANY2F, BC1ANY2T: 010001 01001 xxx0x */=0A= pc =3D mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 2);=0A= - else if (op =3D=3D 17 && itype_rs (inst) =3D=3D 10=0A= - && (itype_rt (inst) & 2) =3D=3D 0)=0A= + else if (!is_mipsr6_isa (gdbarch)=0A= + && op =3D=3D 17=0A= + && itype_rs (inst) =3D=3D 10=0A= + && (itype_rt (inst) & 2) =3D=3D 0)=0A= /* BC1ANY4F, BC1ANY4T: 010001 01010 xxx0x */=0A= pc =3D mips32_bc1_pc (gdbarch, regcache, inst, pc + 4, 4);=0A= - else if (op =3D=3D 29)=0A= + else if (!is_mipsr6_isa (gdbarch) && op =3D=3D 29)=0A= /* JALX: 011101 */=0A= /* The new PC will be alternate mode. */=0A= {=0A= @@ -1707,7 +1808,135 @@ mips32_next_pc (struct regcache *regcache, CORE_ADD= R pc)=0A= else=0A= pc +=3D 8; /* After the delay slot. */=0A= }=0A= + else if (is_mipsr6_isa (gdbarch))=0A= + {=0A= + /* BOVC, BEQZALC, BEQC and BNVC, BNEZALC, BNEC */=0A= + if (op =3D=3D 8 || op =3D=3D 24)=0A= + {=0A= + int rs =3D rtype_rs (inst);=0A= + int rt =3D rtype_rt (inst);=0A= + LONGEST val_rs =3D regcache_raw_get_signed (regcache, rs);=0A= + LONGEST val_rt =3D regcache_raw_get_signed (regcache, rt);=0A= + bool taken =3D false;=0A= +=0A= + /* BOVC (BNVC) */=0A= + if (rs >=3D rt)=0A= + {=0A= + if (mips64bitreg)=0A= + taken =3D is_add64bit_overflow (val_rs, val_rt);=0A= + else=0A= + taken =3D is_add32bit_overflow (val_rs, val_rt);=0A= + }=0A= + /* BEQZALC (BNEZALC) */=0A= + else if (rs < rt && rs =3D=3D 0)=0A= + taken =3D (val_rt =3D=3D 0);=0A= + /* BEQC (BNEC) */=0A= + else=0A= + taken =3D (val_rs =3D=3D val_rt);=0A= +=0A= + /* BNVC, BNEZALC, BNEC */=0A= + if (op =3D=3D 24)=0A= + taken =3D !taken;=0A= =0A= + if (taken){=0A= + pc +=3D mips32_relative_offset (inst) + 4;=0A= + }=0A= + else{=0A= + /* Step through the forbidden slot to avoid repeated exceptions=0A= + we do not currently have access to the BD bit when hitting a=0A= + breakpoint and therefore cannot tell if the breakpoint=0A= + hit on the branch or the forbidden slot. */=0A= + pc +=3D 8;=0A= + }=0A= + }=0A= + /* BC1EQZ, BC1NEZ */=0A= + else if (op =3D=3D 17 && (itype_rs (inst) =3D=3D 9 || itype_rs (inst) = =3D=3D 13))=0A= + {=0A= + gdb_byte status;=0A= + gdb_byte true_val =3D 0;=0A= + unsigned int fp =3D (gdbarch_num_regs (gdbarch)=0A= + + mips_regnum (gdbarch)->fp0=0A= + + itype_rt (inst));=0A= + struct frame_info_ptr frame =3D get_current_frame ();=0A= + gdb_byte *raw_buffer =3D (gdb_byte *) alloca (sizeof (gdb_byte) * 4= );=0A= + mips_read_fp_register_single (frame, fp, raw_buffer);=0A= +=0A= + if (gdbarch_byte_order (gdbarch) =3D=3D BFD_ENDIAN_BIG)=0A= + status =3D *(raw_buffer + 3);=0A= + else=0A= + status =3D *(raw_buffer);=0A= +=0A= + if (itype_rs (inst) =3D=3D 13)=0A= + true_val =3D 1;=0A= +=0A= + if ((status & 0x1) =3D=3D true_val)=0A= + pc +=3D mips32_relative_offset (inst) + 4;=0A= + else=0A= + pc +=3D 8;=0A= + }=0A= + else if (op =3D=3D 22 || op =3D=3D 23)=0A= + /* BLEZC, BGEZC, BGEC, BGTZC, BLTZC, BLTC */=0A= + {=0A= + int rs =3D rtype_rs (inst);=0A= + int rt =3D rtype_rt (inst);=0A= + LONGEST val_rs =3D regcache_raw_get_signed (regcache, rs);=0A= + LONGEST val_rt =3D regcache_raw_get_signed (regcache, rt);=0A= + bool taken =3D false;=0A= + /* The R5 rt =3D=3D 0 case is handled above so we treat it as=0A= + an unknown instruction here for future ISA usage. */=0A= + if (rs =3D=3D 0 && rt !=3D 0)=0A= + taken =3D (val_rt <=3D 0);=0A= + else if (rs =3D=3D rt && rt !=3D 0)=0A= + taken =3D (val_rt >=3D 0);=0A= + else if (rs !=3D rt && rs !=3D 0 && rt !=3D 0)=0A= + taken =3D (val_rs >=3D val_rt);=0A= +=0A= + if (op =3D=3D 23)=0A= + taken =3D !taken;=0A= +=0A= + if (taken){=0A= + pc +=3D mips32_relative_offset (inst) + 4;=0A= + }=0A= + else{=0A= + /* Step through the forbidden slot to avoid repeated exceptions=0A= + we do not currently have access to the BD bit when hitting a=0A= + breakpoint and therefore cannot tell if the breakpoint=0A= + hit on the branch or the forbidden slot. */=0A= + pc +=3D 8;=0A= + }=0A= + }=0A= + else if (op =3D=3D 50 || op =3D=3D 58)=0A= + /* BC, BALC */=0A= + pc +=3D mips32_relative_offset26 (inst) + 4;=0A= + else if ((op =3D=3D 54 || op =3D=3D 62)=0A= + && rtype_rs (inst) =3D=3D 0)=0A= + /* JIC, JIALC */=0A= + {=0A= + pc =3D regcache_raw_get_signed (regcache, itype_rt (inst));=0A= + pc +=3D (itype_immediate (inst) ^ 0x8000) - 0x8000;=0A= + }=0A= + else if (op =3D=3D 54 || op =3D=3D 62)=0A= + /* BEQZC, BNEZC */=0A= + {=0A= + int rs =3D itype_rs (inst);=0A= + LONGEST rs_val =3D regcache_raw_get_signed (regcache, rs);=0A= + bool taken =3D (rs_val =3D=3D 0);=0A= + if (op =3D=3D 62)=0A= + taken =3D !taken;=0A= + if (taken){=0A= + pc +=3D mips32_relative_offset21 (inst) + 4;=0A= + }=0A= + else{=0A= + /* Step through the forbidden slot to avoid repeated exceptions=0A= + we do not currently have access to the BD bit when hitting a=0A= + breakpoint and therefore cannot tell if the breakpoint=0A= + hit on the branch or the forbidden slot. */=0A= + pc +=3D 8;=0A= + }=0A= + }=0A= + else=0A= + pc +=3D 4; /* Not a branch, next instruction is easy. */=0A= + }=0A= else=0A= pc +=3D 4; /* Not a branch, next instruction is easy. */=0A= }=0A= @@ -1751,7 +1980,6 @@ mips32_next_pc (struct regcache *regcache, CORE_ADDR = pc)=0A= case 2: /* BLTZL */=0A= case 16: /* BLTZAL */=0A= case 18: /* BLTZALL */=0A= - less_branch:=0A= if (regcache_raw_get_signed (regcache, itype_rs (inst)) < 0)=0A= pc +=3D mips32_relative_offset (inst) + 4;=0A= else=0A= @@ -1767,22 +1995,38 @@ mips32_next_pc (struct regcache *regcache, CORE_ADD= R pc)=0A= pc +=3D 8; /* after the delay slot */=0A= break;=0A= case 0x1c: /* BPOSGE32 */=0A= + case 0x1d: /* BPOSGE32C */=0A= case 0x1e: /* BPOSGE64 */=0A= pc +=3D 4;=0A= if (itype_rs (inst) =3D=3D 0)=0A= {=0A= unsigned int pos =3D (op & 2) ? 64 : 32;=0A= int dspctl =3D mips_regnum (gdbarch)->dspctl;=0A= + int delay_slot_size =3D 4;=0A= =0A= if (dspctl =3D=3D -1)=0A= /* No way to handle; it'll most likely trap anyway. */=0A= break;=0A= =0A= + /* BPOSGE32C */=0A= + if (op =3D=3D 0x1d)=0A= + {=0A= + if (!is_mipsr6_isa (gdbarch))=0A= + break;=0A= +=0A= + /* Step through the forbidden slot to avoid repeated=0A= + exceptions we do not currently have access to the BD=0A= + bit when hitting a breakpoint and therefore cannot=0A= + tell if the breakpoint hit on the branch or the=0A= + forbidden slot. */=0A= + /* delay_slot_size =3D 0; */=0A= + }=0A= +=0A= if ((regcache_raw_get_unsigned (regcache,=0A= dspctl) & 0x7f) >=3D pos)=0A= pc +=3D mips32_relative_offset (inst);=0A= else=0A= - pc +=3D 4;=0A= + pc +=3D delay_slot_size;=0A= }=0A= break;=0A= /* All of the other instructions in the REGIMM category */=0A= @@ -1816,19 +2060,14 @@ mips32_next_pc (struct regcache *regcache, CORE_ADD= R pc)=0A= else=0A= pc +=3D 8;=0A= break;=0A= - case 6: /* BLEZ, BLEZL */=0A= - if (regcache_raw_get_signed (regcache, itype_rs (inst)) <=3D 0)=0A= - pc +=3D mips32_relative_offset (inst) + 4;=0A= - else=0A= - pc +=3D 8;=0A= + case 6: /* BLEZ, BLEZL, BLEZALC, BGEZALC, BGEUC */=0A= + lez_branch:=0A= + pc =3D mips32_blez_pc (gdbarch, regcache, inst, pc + 4, 0);=0A= break;=0A= case 7:=0A= default:=0A= - greater_branch: /* BGTZ, BGTZL */=0A= - if (regcache_raw_get_signed (regcache, itype_rs (inst)) > 0)=0A= - pc +=3D mips32_relative_offset (inst) + 4;=0A= - else=0A= - pc +=3D 8;=0A= + greater_branch: /* BGTZ, BGTZL, BGTZALC, BLTZALC, BLTUC */=0A= + pc =3D mips32_blez_pc (gdbarch, regcache, inst, pc + 4, 1);=0A= break;=0A= } /* switch */=0A= } /* else */=0A= @@ -2451,6 +2690,72 @@ micromips_instruction_is_compact_branch (unsigned sh= ort insn)=0A= }=0A= }=0A= =0A= +=0A= +=0A= +/* Return non-zero if the MIPS instruction INSN is a compact branch=0A= + or jump. */=0A= +static enum compact_branch_type=0A= +mips32_instruction_is_compact_branch (struct gdbarch *gdbarch, ULONGEST in= sn)=0A= +{=0A= + switch (itype_op (insn))=0A= + {=0A= + /* BC */=0A= + case 50:=0A= + /* BALC */=0A= + case 58:=0A= + if (is_mipsr6_isa (gdbarch))=0A= + return COMP_BRANCH_UNCOND;=0A= + break;=0A= + /* BOVC, BEQZALC, BEQC */=0A= + case 8:=0A= + /* BNVC, BNEZALC, BNEC */=0A= + case 24:=0A= + if (is_mipsr6_isa (gdbarch))=0A= + return COMP_BRANCH_COND;=0A= + break;=0A= + /* BEQZC, JIC */=0A= + case 54:=0A= + /* BNEZC, JIALC */=0A= + case 62:=0A= + if (is_mipsr6_isa (gdbarch))=0A= + /* JIC, JIALC are unconditional */=0A= + return (itype_rs (insn) =3D=3D 0) ? COMP_BRANCH_UNCOND : COMP_BRANCH_COND= ;=0A= + break;=0A= + /* BLEZC, BGEZC, BGEC */=0A= + case 22:=0A= + /* BGTZC, BLTZC, BLTC */=0A= + case 23:=0A= + /* BLEZALC, BGEZALC, BGEUC */=0A= + case 6:=0A= + /* BGTZALC, BLTZALC, BLTUC */=0A= + case 7:=0A= + if (is_mipsr6_isa (gdbarch)=0A= + && itype_rt (insn) !=3D 0)=0A= + return COMP_BRANCH_COND;=0A= + break;=0A= + /* BPOSGE32C */=0A= + case 1:=0A= + if (is_mipsr6_isa (gdbarch)=0A= + && itype_rt (insn) =3D=3D 0x1d && itype_rs (insn) =3D=3D 0)=0A= + return COMP_BRANCH_COND;=0A= + }=0A= + return COMP_BRANCH_NONE;=0A= +}=0A= +=0A= +/* Return true if a standard MIPS instruction at ADDR has a branch=0A= + forbidden slot (i.e. it is a conditional compact branch instruction). = */=0A= +=0A= +static bool=0A= +mips32_insn_at_pc_has_forbidden_slot (struct gdbarch *gdbarch, CORE_ADDR a= ddr)=0A= +{=0A= + int status;=0A= + ULONGEST insn =3D mips_fetch_instruction (gdbarch, ISA_MIPS, addr, &stat= us);=0A= + if (status)=0A= + return false;=0A= +=0A= + return mips32_instruction_is_compact_branch (gdbarch, insn) =3D=3D COMP_= BRANCH_COND;=0A= +}=0A= +=0A= struct mips_frame_cache=0A= {=0A= CORE_ADDR base;=0A= @@ -3494,7 +3799,8 @@ mips32_scan_prologue (struct gdbarch *gdbarch,=0A= reg =3D high_word & 0x1f;=0A= =0A= if (high_word =3D=3D 0x27bd /* addiu $sp,$sp,-i */=0A= - || high_word =3D=3D 0x23bd /* addi $sp,$sp,-i */=0A= + || (high_word =3D=3D 0x23bd /* addi $sp,$sp,-i */=0A= + && !is_mipsr6_isa (gdbarch))=0A= || high_word =3D=3D 0x67bd) /* daddiu $sp,$sp,-i */=0A= {=0A= if (offset < 0) /* Negative stack adjustment? */=0A= @@ -3632,7 +3938,9 @@ mips32_scan_prologue (struct gdbarch *gdbarch,=0A= =0A= /* A jump or branch, or enough non-prologue insns seen? If so,=0A= then we must have reached the end of the prologue by now. */=0A= - if (prev_delay_slot || non_prologue_insns > 1)=0A= + if (prev_delay_slot=0A= + || non_prologue_insns > 1=0A= + || mips32_instruction_is_compact_branch (gdbarch, inst))=0A= break;=0A= =0A= prev_non_prologue_insn =3D this_non_prologue_insn;=0A= @@ -3938,6 +4246,59 @@ mips_addr_bits_remove (struct gdbarch *gdbarch, CORE= _ADDR addr)=0A= #define LLD_OPCODE 0x34=0A= #define SC_OPCODE 0x38=0A= #define SCD_OPCODE 0x3c=0A= +#define LLSC_R6_OPCODE 0x1f=0A= +#define LL_R6_FUNCT 0x36=0A= +#define LLE_FUNCT 0x2e=0A= +#define LLD_R6_FUNCT 0x37=0A= +#define SC_R6_FUNCT 0x26=0A= +#define SCE_FUNCT 0x1e=0A= +#define SCD_R6_FUNCT 0x27=0A= +=0A= +static bool=0A= +is_ll_insn (struct gdbarch *gdbarch, ULONGEST insn)=0A= +{=0A= + if (itype_op (insn) =3D=3D LL_OPCODE=0A= + || itype_op (insn) =3D=3D LLD_OPCODE)=0A= + return true;=0A= +=0A= + if (rtype_op (insn) =3D=3D LLSC_R6_OPCODE=0A= + && rtype_funct (insn) =3D=3D LLE_FUNCT=0A= + && (insn & 0x40) =3D=3D 0)=0A= + return true;=0A= +=0A= + /* Handle LL and LLP varieties. */=0A= + if (is_mipsr6_isa (gdbarch)=0A= + && rtype_op (insn) =3D=3D LLSC_R6_OPCODE=0A= + && (rtype_funct (insn) =3D=3D LL_R6_FUNCT=0A= + || rtype_funct (insn) =3D=3D LLD_R6_FUNCT=0A= + || rtype_funct (insn) =3D=3D LLE_FUNCT))=0A= + return true;=0A= +=0A= + return false;=0A= +}=0A= +=0A= +static bool=0A= +is_sc_insn (struct gdbarch *gdbarch, ULONGEST insn)=0A= +{=0A= + if (itype_op (insn) =3D=3D SC_OPCODE=0A= + || itype_op (insn) =3D=3D SCD_OPCODE)=0A= + return true;=0A= +=0A= + if (rtype_op (insn) =3D=3D LLSC_R6_OPCODE=0A= + && rtype_funct (insn) =3D=3D SCE_FUNCT=0A= + && (insn & 0x40) =3D=3D 0)=0A= + return true;=0A= +=0A= + /* Handle SC and SCP varieties. */=0A= + if (is_mipsr6_isa (gdbarch)=0A= + && rtype_op (insn) =3D=3D LLSC_R6_OPCODE=0A= + && (rtype_funct (insn) =3D=3D SC_R6_FUNCT=0A= + || rtype_funct (insn) =3D=3D SCD_R6_FUNCT=0A= + || rtype_funct (insn) =3D=3D SCE_FUNCT))=0A= + return true;=0A= +=0A= + return false;=0A= +}=0A= =0A= static std::vector=0A= mips_deal_with_atomic_sequence (struct gdbarch *gdbarch, CORE_ADDR pc)=0A= @@ -3950,10 +4311,11 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdb= arch, CORE_ADDR pc)=0A= int index;=0A= int last_breakpoint =3D 0; /* Defaults to 0 (no breakpoints placed). */= =0A= const int atomic_sequence_length =3D 16; /* Instruction sequence length.= */=0A= + bool is_mipsr6 =3D is_mipsr6_isa (gdbarch);=0A= =0A= insn =3D mips_fetch_instruction (gdbarch, ISA_MIPS, loc, NULL);=0A= /* Assume all atomic sequences start with a ll/lld instruction. */=0A= - if (itype_op (insn) !=3D LL_OPCODE && itype_op (insn) !=3D LLD_OPCODE)= =0A= + if (!is_ll_insn (gdbarch, insn))=0A= return {};=0A= =0A= /* Assume that no atomic sequence is longer than "atomic_sequence_length= " =0A= @@ -3983,28 +4345,72 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdb= arch, CORE_ADDR pc)=0A= return {}; /* fallback to the standard single-step code. */=0A= case 4: /* BEQ */=0A= case 5: /* BNE */=0A= - case 6: /* BLEZ */=0A= - case 7: /* BGTZ */=0A= case 20: /* BEQL */=0A= case 21: /* BNEL */=0A= - case 22: /* BLEZL */=0A= - case 23: /* BGTTL */=0A= + case 22: /* BLEZL (BLEZC, BGEZC, BGEC) */=0A= + case 23: /* BGTZL (BGTZC, BLTZC, BLTC) */=0A= + is_branch =3D 1;=0A= + break;=0A= + case 6: /* BLEZ (BLEZALC, BGEZALC, BGEUC) */=0A= + case 7: /* BGTZ (BGTZALC, BLTZALC, BLTUC) */=0A= + if (is_mipsr6)=0A= + {=0A= + /* BLEZALC, BGTZALC */=0A= + if (itype_rs (insn) =3D=3D 0 && itype_rt (insn) !=3D 0)=0A= + return {}; /* fallback to the standard single-step code. */=0A= + /* BGEZALC, BLTZALC */=0A= + else if (itype_rs (insn) =3D=3D itype_rt (insn)=0A= + && itype_rt (insn) !=3D 0)=0A= + return {}; /* fallback to the standard single-step code. */=0A= + }=0A= is_branch =3D 1;=0A= break;=0A= + case 8: /* BOVC, BEQZALC, BEQC */=0A= + case 24: /* BNVC, BNEZALC, BNEC */=0A= + if (is_mipsr6)=0A= + is_branch =3D 1;=0A= + break;=0A= + case 50: /* BC */=0A= + case 58: /* BALC */=0A= + if (is_mipsr6)=0A= + return {}; /* fallback to the standard single-step code. */=0A= + break;=0A= + case 54: /* BEQZC, JIC */=0A= + case 62: /* BNEZC, JIALC */=0A= + if (is_mipsr6)=0A= + {=0A= + if (itype_rs (insn) =3D=3D 0) /* JIC, JIALC */=0A= + return {}; /* fallback to the standard single-step code. */=0A= + else=0A= + is_branch =3D 2; /* Marker for branches with a 21-bit offset. */=0A= + }=0A= + break;=0A= case 17: /* COP1 */=0A= - is_branch =3D ((itype_rs (insn) =3D=3D 9 || itype_rs (insn) =3D=3D 10)= =0A= - && (itype_rt (insn) & 0x2) =3D=3D 0);=0A= - if (is_branch) /* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T */=0A= + is_branch =3D ((!is_mipsr6=0A= + /* BC1ANY2F, BC1ANY2T, BC1ANY4F, BC1ANY4T */=0A= + && (itype_rs (insn) =3D=3D 9 || itype_rs (insn) =3D=3D 10)=0A= + && (itype_rt (insn) & 0x2) =3D=3D 0)=0A= + /* BZ.df: 010001 110xx */=0A= + || (itype_rs (insn) & 0x18) =3D=3D 0x18);=0A= + if (is_branch)=0A= break;=0A= [[fallthrough]];=0A= case 18: /* COP2 */=0A= case 19: /* COP3 */=0A= - is_branch =3D (itype_rs (insn) =3D=3D 8); /* BCzF, BCzFL, BCzT, BCzTL *= /=0A= + /* BCzF, BCzFL, BCzT, BCzTL, BC*EQZ, BC*NEZ */=0A= + is_branch =3D ((itype_rs (insn) =3D=3D 8)=0A= + || (is_mipsr6=0A= + && (itype_rs (insn) =3D=3D 9=0A= + || itype_rs (insn) =3D=3D 13)));=0A= break;=0A= }=0A= if (is_branch)=0A= {=0A= - branch_bp =3D loc + mips32_relative_offset (insn) + 4;=0A= + /* Is this a special PC21_S2 branch? */=0A= + if (is_branch =3D=3D 2)=0A= + branch_bp =3D loc + mips32_relative_offset21 (insn) + 4;=0A= + else=0A= + branch_bp =3D loc + mips32_relative_offset (insn) + 4;=0A= if (last_breakpoint >=3D 1)=0A= return {}; /* More than one branch found, fallback to the=0A= standard single-step code. */=0A= @@ -4012,12 +4418,12 @@ mips_deal_with_atomic_sequence (struct gdbarch *gdb= arch, CORE_ADDR pc)=0A= last_breakpoint++;=0A= }=0A= =0A= - if (itype_op (insn) =3D=3D SC_OPCODE || itype_op (insn) =3D=3D SCD_O= PCODE)=0A= + if (is_sc_insn (gdbarch, insn))=0A= break;=0A= }=0A= =0A= /* Assume that the atomic sequence ends with a sc/scd instruction. */= =0A= - if (itype_op (insn) !=3D SC_OPCODE && itype_op (insn) !=3D SCD_OPCODE)= =0A= + if (!is_sc_insn (gdbarch, insn))=0A= return {};=0A= =0A= loc +=3D MIPS_INSN32_SIZE;=0A= @@ -4231,7 +4637,7 @@ mips_software_single_step (struct regcache *regcache)= =0A= /* Test whether the PC points to the return instruction at the=0A= end of a function. */=0A= =0A= -static int=0A= +static bool=0A= mips_about_to_return (struct gdbarch *gdbarch, CORE_ADDR pc)=0A= {=0A= ULONGEST insn;=0A= @@ -4242,8 +4648,14 @@ mips_about_to_return (struct gdbarch *gdbarch, CORE_= ADDR pc)=0A= gdb_assert (mips_pc_is_mips (pc));=0A= =0A= insn =3D mips_fetch_instruction (gdbarch, ISA_MIPS, pc, NULL);=0A= - hint =3D 0x7c0;=0A= - return (insn & ~hint) =3D=3D 0x3e00008; /* jr(.hb) $ra */=0A= + /* Mask the hint and the jalr/jr bit. */=0A= + hint =3D 0x7c1;=0A= +=0A= + if (is_mipsr6_isa (gdbarch) && insn =3D=3D 0xd81f0000) /* jrc $31 */=0A= + return true;=0A= +=0A= + /* jr(.hb) $ra and "jalr(.hb) $ra" */=0A= + return ((insn & ~hint) =3D=3D 0x3e00008);=0A= }=0A= =0A= =0A= @@ -6760,7 +7172,9 @@ mips32_stack_frame_destroyed_p (struct gdbarch *gdbar= ch, CORE_ADDR pc)=0A= =0A= if (high_word !=3D 0x27bd /* addiu $sp,$sp,offset */=0A= && high_word !=3D 0x67bd /* daddiu $sp,$sp,offset */=0A= - && inst !=3D 0x03e00008 /* jr $ra */=0A= + && (inst & ~0x1) !=3D 0x03e00008 /* jr $31 or jalr $0, $31 */=0A= + && (!is_mipsr6_isa (gdbarch)=0A= + || inst !=3D 0xd81f0000) /* jrc $31 */=0A= && inst !=3D 0x00000000) /* nop */=0A= return 0;=0A= }=0A= @@ -7129,32 +7543,41 @@ mips_sw_breakpoint_from_kind (struct gdbarch *gdbar= ch, int kind, int *size)=0A= };=0A= }=0A= =0A= -/* Return non-zero if the standard MIPS instruction INST has a branch=0A= +/* Return true if the standard MIPS instruction INST has a branch=0A= delay slot (i.e. it is a jump or branch instruction). This function=0A= is based on mips32_next_pc. */=0A= =0A= -static int=0A= +static bool=0A= mips32_instruction_has_delay_slot (struct gdbarch *gdbarch, ULONGEST inst)= =0A= {=0A= int op;=0A= int rs;=0A= int rt;=0A= + int is_mipsr6 =3D is_mipsr6_isa (gdbarch);=0A= =0A= op =3D itype_op (inst);=0A= if ((inst & 0xe0000000) !=3D 0)=0A= {=0A= rs =3D itype_rs (inst);=0A= rt =3D itype_rt (inst);=0A= - return (is_octeon_bbit_op (op, gdbarch) =0A= - || op >> 2 =3D=3D 5 /* BEQL, BNEL, BLEZL, BGTZL: bits 0101xx */=0A= - || op =3D=3D 29 /* JALX: bits 011101 */=0A= + return (is_octeon_bbit_op (op, gdbarch)=0A= + || (op >> 1 =3D=3D 10) /* BEQL, BNEL: bits 01010x */=0A= + || (op >> 1 =3D=3D 11 && rt =3D=3D 0) /* BLEZL, BGTZL: bits 01011x = */=0A= + || (!is_mipsr6 && op =3D=3D 29) /* JALX: bits 011101 */=0A= || (op =3D=3D 17=0A= && (rs =3D=3D 8=0A= /* BC1F, BC1FL, BC1T, BC1TL: 010001 01000 */=0A= - || (rs =3D=3D 9 && (rt & 0x2) =3D=3D 0)=0A= + || (!is_mipsr6 && rs =3D=3D 9 && (rt & 0x2) =3D=3D 0)=0A= /* BC1ANY2F, BC1ANY2T: bits 010001 01001 */=0A= - || (rs =3D=3D 10 && (rt & 0x2) =3D=3D 0))));=0A= + || (!is_mipsr6 && rs =3D=3D 10 && (rt & 0x2) =3D=3D 0)))=0A= /* BC1ANY4F, BC1ANY4T: bits 010001 01010 */=0A= + || (is_mipsr6=0A= + && ((op =3D=3D 17=0A= + && (rs =3D=3D 9 /* BC1EQZ: 010001 01001 */=0A= + || rs =3D=3D 13)) /* BC1NEZ: 010001 01101 */=0A= + || (op =3D=3D 18=0A= + && (rs =3D=3D 9 /* BC2EQZ: 010010 01001 */=0A= + || rs =3D=3D 13))))); /* BC2NEZ: 010010 01101 */=0A= }=0A= else=0A= switch (op & 0x07) /* extract bits 28,27,26 */=0A= @@ -7173,8 +7596,12 @@ mips32_instruction_has_delay_slot (struct gdbarch *g= dbarch, ULONGEST inst)=0A= || ((rt & 0x1e) =3D=3D 0x1c && rs =3D=3D 0));=0A= /* BPOSGE32, BPOSGE64: bits 1110x */=0A= break; /* end REGIMM */=0A= - default: /* J, JAL, BEQ, BNE, BLEZ, BGTZ */=0A= - return 1;=0A= + case 6: /* BLEZ */=0A= + case 7: /* BGTZ */=0A= + return (itype_rt (inst) =3D=3D 0);=0A= + break;=0A= + default: /* J, JAL, BEQ, BNE */=0A= + return true;=0A= break;=0A= }=0A= }=0A= @@ -7385,7 +7812,18 @@ mips_adjust_breakpoint_address (struct gdbarch *gdba= rch, CORE_ADDR bpaddr)=0A= =0A= So, we'll use the second solution. To do this we need to know if=0A= the instruction we're trying to set the breakpoint on is in the=0A= - branch delay slot. */=0A= + branch delay slot.=0A= +=0A= + A similar problem occurs for breakpoints on forbidden slots where=0A= + the trap will be reported for the branch with the BD bit set.=0A= + In this case it would be ideal to recover using solution 1 from=0A= + above as there is no problem with the branch being skipped=0A= + (since the forbidden slot only exists on not-taken branches).=0A= + However, the BD bit is not available in all scenarios currently=0A= + so instead we move the breakpoint on to the next instruction.=0A= + This means that it is not possible to stop on an instruction=0A= + that can be in a forbidden slot even if that instruction is=0A= + jumped to directly. */=0A= =0A= boundary =3D mips_segment_boundary (bpaddr);=0A= =0A= @@ -7407,6 +7845,12 @@ mips_adjust_breakpoint_address (struct gdbarch *gdba= rch, CORE_ADDR bpaddr)=0A= prev_addr =3D bpaddr - 4;=0A= if (mips32_insn_at_pc_has_delay_slot (gdbarch, prev_addr))=0A= bpaddr =3D prev_addr;=0A= + /* If the previous instruction has a forbidden slot, we have to=0A= + move the breakpoint to the following instruction to prevent=0A= + breakpoints in forbidden slots being reported as unknown=0A= + traps. */=0A= + else if (mips32_insn_at_pc_has_forbidden_slot (gdbarch, prev_addr))= =0A= + bpaddr +=3D 4;=0A= }=0A= else=0A= {=0A= diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.c b/gdb/testsuite/gdb.arch/m= ips-64-r6.c=0A= new file mode 100644=0A= index 00000000000..cd540d1e70c=0A= --- /dev/null=0A= +++ b/gdb/testsuite/gdb.arch/mips-64-r6.c=0A= @@ -0,0 +1,913 @@=0A= +/*=0A= + Copyright 2006-2024 Free Software Foundation, Inc.=0A= +=0A= + This file is part of GDB.=0A= +=0A= + This program is free software; you can redistribute it and/or modify=0A= + it under the terms of the GNU General Public License as published by=0A= + the Free Software Foundation; either version 3 of the License, or=0A= + (at your option) any later version.=0A= +=0A= + This program is distributed in the hope that it will be useful,=0A= + but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= + GNU General Public License for more details.=0A= +=0A= + You should have received a copy of the GNU General Public License=0A= + along with this program. If not, see .= =0A= +*/=0A= +=0A= +#define xstr(s) str(s)=0A= +#define str(s) #s=0A= +=0A= +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D macros from sim/testutils/mips/uti= ls-r6.inc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */=0A= +=0A= +/* 58 is local label to exit with errcode !=3D 0 */=0A= +#define fp_assert(a, b) "beq " xstr (a) ", " xstr (b) ", 1f \n\t" \=0A= + "nop \n\t" \=0A= + "b 58f \n\t" \=0A= + "nop \n\t" \=0A= + "1: \n\t"=0A= +=0A= +/* Clobbers: $4,$6,$7 */=0A= +#define r6ck_1r(inst, a, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4 \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$6,$7 */=0A= +#define r6ck_1dr(inst, a, ret) \=0A= + "ld $4, " xstr (a) " \n\t" \=0A= + "ld $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4 \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7 */=0A= +#define r6ck_2r(inst, a, b, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $5, " xstr (b) " \n\t" \=0A= + "li $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, $5 \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7 */=0A= +#define r6ck_2dr(inst, a, b, ret) \=0A= + "ld $4, " xstr (a) " \n\t" \=0A= + "ld $5, " xstr (b) " \n\t" \=0A= + "ld $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, $5 \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7 */=0A= +#define r6ck_2dr1i(inst, a, b, imm, ret) \=0A= + "ld $4, " xstr (a) " \n\t" \=0A= + "ld $5, " xstr (b) " \n\t" \=0A= + "ld $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, $5, " xstr (imm) " \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$6,$7 */=0A= +#define r6ck_1r1i(inst, a, imm, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, " xstr (imm) " \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$6,$7 */=0A= +#define r6ck_1dr1i(inst, a, imm, ret) \=0A= + "ld $4, " xstr (a) " \n\t" \=0A= + "ld $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, " xstr (imm) " \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$6 */=0A= +#define r6ck_0dr1i(inst, a, imm, ret) \=0A= + "ld $4, " xstr (a) " \n\t" \=0A= + "ld $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $4, $4, " xstr (imm) " \n\t" \=0A= + fp_assert ($6, $4)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7 */=0A= +#define r6ck_2r1i(inst, a, b, imm, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $5, " xstr (b) " \n\t" \=0A= + "li $6, " xstr (ret) " \n\t" \=0A= + xstr (inst) " $7, $4, $5, " xstr (imm) " \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7,$8,$f2,$f4,$f6 */=0A= +#define r6ck_3s(inst, a, b, c, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $5, " xstr (b) " \n\t" \=0A= + "li $6, " xstr (c) " \n\t" \=0A= + "li $7, " xstr (ret) " \n\t" \=0A= + "mtc1 $4, $f2 \n\t" \=0A= + "mtc1 $5, $f4 \n\t" \=0A= + "mtc1 $6, $f6 \n\t" \=0A= + xstr (inst) " $f2, $f4, $f6 \n\t" \=0A= + "mfc1 $8, $f2 \n\t" \=0A= + fp_assert ($7, $8)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7,$f2,$f4 */=0A= +#define r6ck_2s(inst, a, b, ret) \=0A= + "li $4, " xstr (a) " \n\t" \=0A= + "li $5, " xstr (b) " \n\t" \=0A= + "li $6, " xstr (ret) " \n\t" \=0A= + "mtc1 $4, $f2 \n\t" \=0A= + "mtc1 $5, $f4 \n\t" \=0A= + xstr (inst) " $f2, $f4 \n\t" \=0A= + "mfc1 $7, $f2 \n\t" \=0A= + fp_assert ($6, $7)=0A= +=0A= +/* Clobbers: $4,$5,$6,$7,$8,$9,$10,$f2,$f4 */=0A= +#define r6ck_2d(inst, a, b, ret) \=0A= + ".data \n\t" \=0A= + "1: .dword " xstr (a) " \n\t" \=0A= + "2: .dword " xstr (b) " \n\t" \=0A= + "3: .dword " xstr (ret) " \n\t" \=0A= + ".text \n\t" \=0A= + "dla $4, 1b \n\t" \=0A= + "dla $5, 2b \n\t" \=0A= + "dla $6, 3b \n\t" \=0A= + "ldc1 $f2, 0($4) \n\t" \=0A= + "ldc1 $f4, 0($5) \n\t" \=0A= + "lw $7, 0($6) \n\t" \=0A= + "lw $8, 4($6) \n\t" \=0A= + xstr (inst) " $f2, $f4 \n\t" \=0A= + "mfhc1 $9, $f2 \n\t" \=0A= + "mfc1 $10, $f2 \n\t" \=0A= + fp_assert ($7, $9) \=0A= + fp_assert ($8, $10)=0A= +=0A= +/* Clobbers: $2,$4,$5,$6,$7,$8,$9,$10,$f2,$f4,$f6 */=0A= +#define r6ck_3d(inst, a, b, c, ret) \=0A= + ".data \n\t" \=0A= + "1: .dword " xstr (a) " \n\t" \=0A= + "2: .dword " xstr (b) " \n\t" \=0A= + "3: .dword " xstr (c) " \n\t" \=0A= + "4: .dword " xstr (ret) " \n\t" \=0A= + ".text \n\t" \=0A= + "dla $4, 1b \n\t" \=0A= + "dla $5, 2b \n\t" \=0A= + "dla $6, 3b \n\t" \=0A= + "dla $2, 4b \n\t" \=0A= + "ldc1 $f2, 0($4) \n\t" \=0A= + "ldc1 $f4, 0($5) \n\t" \=0A= + "ldc1 $f6, 0($6) \n\t" \=0A= + "lw $7, 0($2) \n\t" \=0A= + "lw $8, 4($2) \n\t" \=0A= + xstr (inst) " $f2, $f4, $f6 \n\t" \=0A= + "mfhc1 $9, $f2 \n\t" \=0A= + "mfc1 $10, $f2 \n\t" \=0A= + fp_assert ($7, $9) \=0A= + fp_assert ($8, $10)=0A= +=0A= +=0A= +/* =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D macros from sim/testutils/mips/tes= tutils.inc =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D */=0A= +=0A= +/* Put value 'val' into register 'reg'=0A= + * Clobbers: None */=0A= +#define load32(reg, val) \=0A= + "li " xstr (reg) ", " xstr (val) " \n\t"=0A= +=0A= +/* Check whether two registers contain the same value=0A= + * Clobbers: None */=0A= +#define checkreg(reg, expreg) \=0A= + ".set push \n\t" \=0A= + ".set noat \n\t" \=0A= + ".set noreorder \n\t" \=0A= + "beq " xstr (expreg) ", " xstr (reg) ", 901f \n\t" \=0A= + "nop \n\t" \=0A= + "b 58f \n\t" \=0A= + "nop \n\t" \=0A= + "901: \n\t" \=0A= + ".set pop \n\t"=0A= +=0A= +/* Check if register 'reg' contains value 'val'.=0A= + * Clobbers: $1 */=0A= +#define check32(reg, val) \=0A= + ".set push \n\t" \=0A= + ".set noat \n\t" \=0A= + load32 ($1, val) \=0A= + checkreg (reg, $1) \=0A= + ".set pop \n\t"=0A= +=0A= +/* Checkpair based on endianess=0A= + * Clobbers: $1 */=0A= +#define checkpair_xendian(lo, hi, base, ec, w) \=0A= + ".set noat \n\t" \=0A= + "lw $1, " xstr (ec) " \n\t" \=0A= + "andi $1, $1, 0x1 \n\t" \=0A= + "beqz $1, 2f \n\t" \=0A= + ".set at \n\t" \=0A= + "1: \n\t" \=0A= + checkpair_be_##w (lo, hi, base) \=0A= + "b 3f \n\t" \=0A= + "nop \n\t" \=0A= + "2: \n\t" \=0A= + checkpair_le_##w (lo, hi, base) \=0A= + "3: \n\t"=0A= +=0A= +=0A= +/* Check hi-lo register pair against data stored at base+o1 and base+o2=0A= + * Clobbers: $1 - $5 */=0A= +#define checkpair(lo, hi, base, w, o1, o2) \=0A= + "move $2, " xstr (lo) " \n\t" \=0A= + "move $3, " xstr (hi) " \n\t" \=0A= + ".set noat \n\t" \=0A= + "dla $1, " xstr (base) " \n\t" \=0A= + "l" xstr (w) " $4, " xstr (o1) "($1) \n\t" \=0A= + "l" xstr (w) " $5, " xstr (o2) "($1) \n\t" \=0A= + ".set at \n\t" \=0A= + checkreg ($2, $4) \=0A= + checkreg ($3, $5)=0A= +=0A= +#define checkpair_le_d(lo, hi, base) \=0A= + checkpair (lo, hi, base, w, 0, 4)=0A= +=0A= +#define checkpair_be_d(lo, hi, base) \=0A= + checkpair (lo, hi, base, w, 4, 0)=0A= +=0A= +=0A= +#define checkpair_le_q(lo, hi, base) \=0A= + checkpair (lo, hi, base, d, 0, 8)=0A= +=0A= +#define checkpair_be_q(lo, hi, base) \=0A= + checkpair (lo, hi, base, d, 8, 0)=0A= +=0A= +#define checkpair_qword(lo, hi, base, oe) \=0A= + checkpair_xendian (lo, hi, base, oe, q)=0A= +=0A= +#define checkpair_dword(lo, hi, base, oe) \=0A= + checkpair_xendian (lo, hi, base, oe, d)=0A= +=0A= +void=0A= +abort (void);=0A= +=0A= +int=0A= +test_r6_branch(void)=0A= +{=0A= +/* Using volatile to prevent certain optimizations which could cause=0A= + * instruction deletion.=0A= + * 'err' identifies instruction which (eventually) caused error.=0A= + * (err =3D=3D 0) =3D=3D> all instructions executed successfully */=0A= +=0A= + volatile int err =3D -1;=0A= + volatile int a14 =3D 0xffffffff;=0A= + volatile int a13 =3D 0x123;=0A= + volatile int a12 =3D 0x45;=0A= + volatile int a7 =3D 0x45;=0A= + volatile int a8 =3D 0xfffffffe;=0A= + volatile int a9 =3D 2147483647;=0A= + volatile int a11 =3D 0;=0A= + volatile int a10 =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t" /* create new scope for asm configuration *= /=0A= + ".set noreorder \n\t" /* don't allow reordering of instructions *= /=0A= + "li %[err], 1 \n\t"=0A= + "bovc %[a12], %[a13], Lfail \n\t" /* BOVC */=0A= + "nop \n\t"=0A= + "bovc %[a9], %[a13], L2 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L2: \n\t"=0A= + "li %[err], 2 \n\t"=0A= + "bnvc %[a9], %[a13], Lfail \n\t" /* BNVC */=0A= + "nop \n\t"=0A= + "bnvc %[a12], %[a13], L3 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L3: \n\t"=0A= + "li %[err], 3 \n\t"=0A= + "beqc %[a12], %[a13], Lfail \n\t" /* BEQC */=0A= + "nop \n\t"=0A= + "beqc %[a12], %[a7], L4 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L4: \n\t"=0A= + "li %[err], 4 \n\t"=0A= + "bnec %[a12], %[a7], Lfail \n\t" /* BNEC */=0A= + "nop \n\t"=0A= + "bnec %[a12], %[a13], L5 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L5: \n\t"=0A= + "li %[err], 5 \n\t"=0A= + "bltc %[a13], %[a12], Lfail \n\t" /* BLTC */=0A= + "nop \n\t"=0A= + "bltc %[a12], %[a13], L6 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L6: \n\t"=0A= + "L7: \n\t"=0A= + "li %[err], 7 \n\t"=0A= + "bgec %[a12], %[a13], Lfail \n\t" /* BGEC */=0A= + "nop \n\t"=0A= + "bgec %[a13], %[a12], L8 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L8: \n\t"=0A= + "L9: \n\t"=0A= + "li %[err], 9 \n\t"=0A= + "bltuc %[a14], %[a13], Lfail \n\t" /* BLTUC */=0A= + "nop \n\t"=0A= + "bltuc %[a8], %[a14], L10 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L10: \n\t"=0A= + "L11: \n\t"=0A= + "li %[err], 11 \n\t"=0A= + "bgeuc %[a13], %[a14], Lfail \n\t" /* BGEUC */=0A= + "nop \n\t"=0A= + "bgeuc %[a14], %[a8], L12 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L12: \n\t"=0A= + "L13: \n\t"=0A= + "li %[err], 13 \n\t"=0A= + "bltzc %[a13], Lfail \n\t" /* BLTZC */=0A= + "nop \n\t"=0A= + "bltzc %[a11], Lfail \n\t"=0A= + "nop \n\t"=0A= + "bltzc %[a14], L14 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L14: \n\t"=0A= + "li %[err], 14 \n\t"=0A= + "blezc %[a13], Lfail \n\t" /* BLEZC */=0A= + "nop \n\t"=0A= + "blezc %[a11], L145 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L145: \n\t"=0A= + "blezc %[a14], L15 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L15: \n\t"=0A= + "li %[err], 15 \n\t"=0A= + "bgezc %[a8], Lfail \n\t" /* BGEZC */=0A= + "nop \n\t"=0A= + "bgezc %[a11], L155 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L155: \n\t"=0A= + "bgezc %[a13], L16 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L16: \n\t"=0A= + "li %[err], 16 \n\t"=0A= + "bgtzc %[a8], Lfail \n\t" /* BGTZC */=0A= + "nop \n\t"=0A= + "bgtzc %[a11], Lfail \n\t"=0A= + "nop \n\t"=0A= + "bgtzc %[a13], L17 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "li %[a10], 0 \n\t"=0A= + "L17: \n\t"=0A= + "li %[err], 17 \n\t"=0A= + "blezalc %[a12], Lfail \n\t" /* BLEZALC */=0A= + "nop \n\t"=0A= + "blezalc %[a11], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L175 \n\t" /* BEQZC */=0A= + "nop \n\t"=0A= + "li %[err], 8531 \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L175: \n\t"=0A= + "li %[err], 23531 \n\t"=0A= + "blezalc %[a14], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L18 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L18: \n\t"=0A= + "li %[err], 18 \n\t"=0A= + "bgezalc %[a14], Lfail \n\t" /* BGEZALC */=0A= + "nop \n\t"=0A= + "bgezalc %[a11], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L185 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L185: \n\t"=0A= + "bgezalc %[a12], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L19 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L19: \n\t"=0A= + "li %[err], 19 \n\t"=0A= + "bgtzalc %[a14], Lfail \n\t" /* BGTZALC */=0A= + "nop \n\t"=0A= + "bgtzalc %[a11], Lfail \n\t"=0A= + "nop \n\t"=0A= + "bgtzalc %[a12], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L20 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L20: \n\t"=0A= + "li %[err], 20 \n\t"=0A= + "bltzalc %[a12], Lfail \n\t" /* BLTZALC */=0A= + "nop \n\t"=0A= + "bltzalc %[a11], Lfail \n\t"=0A= + "nop \n\t"=0A= + "bltzalc %[a14], Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L21 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L21: \n\t"=0A= + "li %[err], 21 \n\t"=0A= + "bc L22 \n\t" /* BC */=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L22: \n\t"=0A= + "li %[err], 22 \n\t"=0A= + "balc Lret \n\t" /* BALC */=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], L23 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L23: \n\t"=0A= + "li %[err], 23 \n\t"=0A= + "jal GetPC \n\t" /* JAL */=0A= + "nop \n\t"=0A= + "jic $6, 4 \n\t" /* JIC */=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L24: \n\t"=0A= + "li %[err], 24 \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "jal GetPC \n\t"=0A= + "nop \n\t"=0A= + "jialc $6, 20 \n\t" /* JIALC */=0A= + "nop \n\t"=0A= + "beqzc %[a10], L25 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "LJIALCRET: \n\t"=0A= + "li %[a10], 0 \n\t"=0A= + "jr $31 \n\t" /* JR */=0A= + "nop \n\t"=0A= + "L25: \n\t"=0A= + "li %[err], 25 \n\t"=0A= + "jal GetPC \n\t"=0A= + "nop \n\t"=0A= + "move %[a11], $6 \n\t"=0A= + "nal \n\t"=0A= + "nop \n\t"=0A= + "addiu %[a11], 12 \n\t" /* ADDIU */=0A= + "beqc %[a11], $31, L26 \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "L26: \n\t"=0A= + "li %[err], 26 \n\t"=0A= + "balc Lret \n\t"=0A= + "li %[a10], 1 \n\t"=0A= + "beqzc %[a10], Lend \n\t"=0A= + "nop \n\t"=0A= + "b Lfail \n\t"=0A= + "nop \n\t"=0A= + "Lret: \n\t"=0A= + "li %[a10], 0 \n\t"=0A= + "daddiu $31, 4 \n\t" /* DADDIU */=0A= + "jrc $31 \n\t" /* JRC */=0A= + "nop \n\t"=0A= + "GetPC: \n\t"=0A= + "move $6, $31 \n\t"=0A= + "jr $31 \n\t"=0A= + "Lend: \n\t"=0A= + "li %[err], 0 \n\t"=0A= + "Lfail: \n\t"=0A= + ".set pop \n\t" /* Restore previous config */=0A= + : [err] "+r"(err), [a14] "+r"(a14), [a13] "+r"(a13), [a12] "+r"(a12),=0A= + [a7] "+r"(a7), [a8] "+r"(a8), [a9] "+r"(a9), [a10] "+r"(a10), [a11] "+= r"(a11)=0A= + : /* inputs */=0A= + : "$31", "$6" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +int=0A= +test_r6_forbidden(void)=0A= +{=0A= + volatile int err =3D -1;=0A= + volatile int a4 =3D 0;=0A= + volatile int a2 =3D 0;=0A= + volatile int a1 =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= +/* Test if FS is ignored when branch is taken */=0A= + "li %[err], 1 \n\t"=0A= + "li %[a4], 0 \n\t"=0A= + "beqzalc %[a4], L41 \n\t"=0A= + "li %[err], -85 \n\t"=0A= + "L42: \n\t"=0A= + "b Lfail2 \n\t"=0A= + "nop \n\t"=0A= + "L41: \n\t"=0A= + "blez %[err], Lfail2 \n\t"=0A= +/* Test if FS is used when branch is not taken */=0A= + "li %[err], 2 \n\t"=0A= + "li %[a4], 1 \n\t"=0A= + "blezc %[a4], L43 \n\t"=0A= + "addiu %[a4], %[a4], 1 \n\t"=0A= + "li %[a2], 2 \n\t"=0A= + "beq %[a4], %[a2], L44 \n\t"=0A= + "nop \n\t"=0A= + "L43: \n\t"=0A= + "nop \n\t"=0A= + "b Lfail2 \n\t"=0A= + "nop \n\t"=0A= + "L44: \n\t"=0A= +/* Test if FS causes an error when it contains a branch */=0A= + "li %[err], 3 \n\t"=0A= + "li %[a4], 3 \n\t"=0A= + "beqzalc %[a4], Lfail2 \n\t"=0A= +/* Note: bc L45 here causes SegFault: Illegal instruction which is OK. */= =0A= + "nop \n\t"=0A= + "b Lend2 \n\t"=0A= + "nop \n\t"=0A= + "L45: \n\t"=0A= + "nop \n\t"=0A= + "b Lfail2 \n\t"=0A= + "nop \n\t"=0A= + "Lend2: \n\t"=0A= + "li %[err], 0 \n\t"=0A= + "Lfail2: \n\t"=0A= + "nop \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r" (err), [a4] "+r"(a4), [a2] "+r"(a2), [a1] "+r"(a1) /* outpu= ts */=0A= + : /* inputs */=0A= + : "$31" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +int=0A= +test_r6_64(void)=0A= +{=0A= + volatile int err =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= + ".data \n\t"=0A= + "dval: .dword 0xaa55bb66cc77dd88 \n\t"=0A= + "d1: .dword 0xaaaabbbbccccdddd \n\t"=0A= + "d5: .dword 0x00000000000000dd \n\t"=0A= + "d7: .dword 0xeeeeffff00001111 \n\t"=0A= + "d8: .dword 0xbbccccddddeeeeff \n\t"=0A= + "d9: .dword 0x000000ddaaaabbbb \n\t"=0A= + "dval1: .word 0x1234abcd \n\t"=0A= + "dval2: .word 0xffee0000 \n\t"=0A= + "dval3: .dword 0xffffffffffffffff \n\t"=0A= + " .fill 240,1,0 \n\t"=0A= + "dval4: .dword 0x5555555555555555 \n\t"=0A= + " .fill 264,1,0 \n\t"=0A= +=0A= +/* Register $11 stores instruction currently being tested and hence=0A= + * identifies error if it occurs */=0A= + ".text \n\t"=0A= +=0A= + "li $11, 1 \n\t" /* Test DALIGN */=0A= + r6ck_2dr1i (dalign, d7, d1, 3, d8)=0A= + r6ck_2dr1i (dalign, d1, d5, 4, d9)=0A= +=0A= + "li $11, 2 \n\t" /* Test LDPC */=0A= + "ld $5, dval \n\t"=0A= + "nop \n\t"=0A= + "ldpc $4, dval \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 3 \n\t" /* Test LWUPC */=0A= + "lwu $5, dval1 \n\t"=0A= + "lwupc $4, dval1 \n\t"=0A= + fp_assert ($4, $5)=0A= + "lwu $5, dval2 \n\t"=0A= + "lwupc $4, dval2 \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 4 \n\t" /* Test LLD */=0A= + "ld $5, dval3 \n\t"=0A= + "dla $3, dval4 \n\t"=0A= + "lld $4, -248($3) \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 5 \n\t" /* Test SCD */=0A= + "lld $4, -248($3) \n\t"=0A= + "dli $4, 0xafaf \n\t"=0A= + "scd $4, -248($3) \n\t"=0A= + "ld $5, dval3 \n\t"=0A= + "dli $4, 0xafaf \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "Lend3: \n\t"=0A= + "li $11, 0 \n\t"=0A= + "58: \n\t"=0A= + "move %[err], $11 \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r" (err) /* outputs */=0A= + : /* inputs */=0A= + : "$3", "$4", "$5", "$6", "$7", "$11" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +int=0A= +test_r6(void)=0A= +{=0A= + volatile int err =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= + ".data \n\t"=0A= + "dval_1: .word 0xabcd1234 \n\t"=0A= + "dval_2: .word 0x1234eeff \n\t"=0A= + ".fill 248,1,0 \n\t"=0A= + "dval_3: .word 0x55555555 \n\t"=0A= + ".fill 260,1,0 \n\t"=0A= + "dval_4: .word 0xaaaaaaaa \n\t"=0A= + ".text \n\t"=0A= + "li $11, 1 \n\t" /* ADDIUPC */=0A= + "jal GetPC_2 \n\t"=0A= + "nop \n\t"=0A= + "addiu $4, $6, 8 \n\t"=0A= + "addiupc $5, 4 \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 2 \n\t" /* AUIPC */=0A= + "jal GetPC_2 \n\t"=0A= + "nop \n\t"=0A= + "addiu $4, $6, 8 \n\t"=0A= + "aui $4, $4, 8 \n\t"=0A= + "auipc $5, 8 \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 3 \n\t" /* ALUIPC */=0A= + "jal GetPC_2 \n\t"=0A= + "nop \n\t"=0A= + "addiu $4, $6, 16 \n\t"=0A= + "aui $4, $4, 8 \n\t"=0A= + "li $7, 0xffff0000 \n\t"=0A= + "and $4, $4, $7 \n\t"=0A= + "aluipc $5, 8 \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 4 \n\t" /* LWPC */=0A= + "lw $5, dval_1 \n\t"=0A= + "lwpc $4, dval_1 \n\t"=0A= + fp_assert ($4, $5)=0A= + "lw $5, dval_2 \n\t"=0A= + "lwpc $4, dval_2 \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= +/* Testing LL follows.=0A= + * NOTE: May be redundant because SC already contains LL in its test */=0A= + "li $11, 5 \n\t"=0A= + "lw $5, dval_2 \n\t"=0A= +/* Ammendment in the following line: 'la' -> 'dla' to load 64-bit address = */=0A= + "dla $3, dval_3 \n\t"=0A= + "ll $4, -252($3) \n\t"=0A= + fp_assert ($4, $5)=0A= +=0A= + "li $11, 6 \n\t" /* LL-SC sequence */=0A= + "ll $4, -252($3) \n\t"=0A= + "li $4, 0xafaf \n\t"=0A= + "sc $4, -252($3) \n\t"=0A= + "lw $5, dval_2 \n\t"=0A= + "li $4, 0xafaf \n\t"=0A= + fp_assert ($4, $5)=0A= + "b Lend4 \n\t"=0A= + "nop \n\t"=0A= + "GetPC_2: \n\t"=0A= + "move $6, $31 \n\t"=0A= + "jr $31 \n\t"=0A= + "Lend4: \n\t"=0A= + "li $11, 0 \n\t"=0A= + "58: \n\t"=0A= + "move %[err], $11 \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r"(err) /* outputs */=0A= + : /* inputs */=0A= + : "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",=0A= + "$11", "$31" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +/* For fpu-branching, bc1eq/eqz are enough */=0A= +int=0A= +test_r6_fpu(void)=0A= +{=0A= + volatile int err =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= +/* Test qNaN format is 754-2008 */=0A= + "li $11, 1 \n\t"=0A= + "li $4, 0x0 \n\t"=0A= + "li $5, 0x0 \n\t"=0A= + "li $6, 0x7fc00000 \n\t"=0A= + "mtc1 $4, $f2 \n\t"=0A= + "mtc1 $5, $f4 \n\t"=0A= + "div.s $f6, $f2, $f4 \n\t"=0A= + "mfc1 $8, $f6 \n\t"=0A= + fp_assert ($6, $8)=0A= +=0A= + "li $11, 2 \n\t" /* bc1eqz */=0A= + "li $10, 0x01 \n\t"=0A= + "mtc1 $10, $f2 \n\t"=0A= + "mtc1 $0, $f4 \n\t"=0A= + "bc1eqz $f2, 58f \n\t"=0A= + "nop \n\t"=0A= + "bc1eqz $f4, L62 \n\t"=0A= + "nop \n\t"=0A= + "b 58f \n\t"=0A= + "nop \n\t"=0A= +"L62: \n\t"=0A= + "li $11, 3 \n\t" /* bc1nez */=0A= + "bc1nez $f4, 58f \n\t"=0A= + "nop \n\t"=0A= + "bc1nez $f2, Lend8 \n\t"=0A= + "nop \n\t"=0A= + "b 58f \n\t"=0A= + "nop \n\t"=0A= +"Lend8: \n\t"=0A= + "li $11, 0 \n\t"=0A= + "58: \n\t"=0A= + "move %[err], $11 \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r"(err) /* outputs */=0A= + : /* inputs */=0A= + : "$4", "$5", "$6", "$8", "$10", "$11", "$31",=0A= + "$f2", "$f4", "$f6" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +/* R6 specific tests for mips64 (64-bit) */=0A= +int=0A= +test_r6_llsc_dp(void)=0A= +{=0A= + volatile int err =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= + ".data \n\t"=0A= + ".align 16 \n\t"=0A= + "test_data: \n\t"=0A= + ".word 0xaaaaaaaa \n\t"=0A= + ".word 0xbbbbbbbb \n\t"=0A= + ".word 0xcccccccc \n\t"=0A= + ".word 0xdddddddd \n\t"=0A= + ".align 16 \n\t"=0A= + "end_check: \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0x1 \n\t"=0A= + ".text \n\t"=0A= + "li $11, 1 \n\t" /* LLWP */= =0A= + "llwp $2, $3, test_data \n\t"=0A= + checkpair_dword ($2, $3, test_data, end_check)=0A= + "sll $2, $2, 1 \n\t"=0A= + "srl $3, $3, 1 \n\t"=0A= + "move $s0, $2 \n\t"=0A= + "scwp $2, $3, test_data \n\t"=0A= + check32 ($2, 1)=0A= + checkpair_dword ($s0, $3, test_data, end_check)=0A= + /* Test SCWP, done */=0A= + "li $11, 2 \n\t"=0A= + "li $11, 3 \n\t" /* LLDP */= =0A= + "lldp $2, $3, test_data \n\t"=0A= + checkpair_qword ($2, $3, test_data, end_check)=0A= + "dsll $2, $2, 1 \n\t"=0A= + "dsrl $3, $3, 1 \n\t"=0A= + "move $s0, $2 \n\t"=0A= + "scdp $2, $3, test_data \n\t"=0A= + check32 ($2, 1)=0A= + checkpair_qword ($s0, $3, test_data, end_check)=0A= + "li $11, 4 \n\t" /* SCDP done= */=0A= + "Lend5: \n\t"=0A= + "li $11, 0 \n\t"=0A= + "58: \n\t"=0A= + "move %[err], $11 \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r"(err) /* outputs */=0A= + : /* inputs */=0A= + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10", "$11",=0A= + "$31", "$s0" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +/* R6 specific tests for mips32 (32-bit) */=0A= +int=0A= +test_r6_llsc_wp(void)=0A= +{=0A= + volatile int err =3D 0;=0A= +=0A= + asm (=0A= + ".set push \n\t"=0A= + ".set noreorder \n\t"=0A= + ".data \n\t"=0A= + ".align 8 \n\t"=0A= + "test_data_2: \n\t"=0A= + ".word 0xaaaaaaaa \n\t"=0A= + ".word 0xbbbbbbbb \n\t"=0A= + ".align 8 \n\t"=0A= + "end_check_2: \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0 \n\t"=0A= + ".byte 0x1 \n\t"=0A= + ".text \n\t"=0A= + "li $11, 1 \n\t" /* Test LLWP= */=0A= + "llwp $2, $3, test_data_2 \n\t"=0A= + checkpair_dword ($2, $3, test_data_2, end_check_2)=0A= + "sll $2, $2, 1 \n\t"=0A= + "srl $3, $3, 1 \n\t"=0A= + "move $s0, $2 \n\t"=0A= + "scwp $2, $3, test_data_2 \n\t"=0A= + check32 ($2, 1)=0A= + checkpair_dword ($s0, $3, test_data_2, end_check_2)=0A= +/* Test SCWP, done */=0A= + "li $11, 2 \n\t"=0A= + "Lend6: \n\t"=0A= + "li $11, 0 \n\t"=0A= + "58: \n\t"=0A= + "move %[err], $11 \n\t"=0A= + ".set pop \n\t"=0A= + : [err] "+r"(err) /* outputs */=0A= + : /* inputs */=0A= + : "$2", "$3", "$4", "$5", "$6", "$7", "$8", "$9", "$10",=0A= + "$11", "$31", "$s0" /* clobbers */=0A= + );=0A= +=0A= + return err;=0A= +}=0A= +=0A= +/*=0A= + * Any test_r6_* function returns non-zero =3D> failure=0A= + */=0A= +#define EXPECT(X) if ((X)) abort ();=0A= +=0A= +int=0A= +main(void)=0A= +{=0A= + EXPECT (test_r6_branch ());=0A= +=0A= + EXPECT (test_r6_forbidden ());=0A= +=0A= + EXPECT (test_r6_64 ());=0A= +=0A= + EXPECT (test_r6 ());=0A= +=0A= + EXPECT (test_r6_fpu ());=0A= +=0A= + EXPECT (test_r6_llsc_dp ());=0A= +=0A= + EXPECT (test_r6_llsc_wp ());=0A= +=0A= + return 0;=0A= +}=0A= diff --git a/gdb/testsuite/gdb.arch/mips-64-r6.exp b/gdb/testsuite/gdb.arch= /mips-64-r6.exp=0A= new file mode 100644=0A= index 00000000000..cddf9c19574=0A= --- /dev/null=0A= +++ b/gdb/testsuite/gdb.arch/mips-64-r6.exp=0A= @@ -0,0 +1,88 @@=0A= +# Copyright (C) 2012-2023 Free Software Foundation, Inc.=0A= +=0A= +# This program is free software; you can redistribute it and/or modify=0A= +# it under the terms of the GNU General Public License as published by=0A= +# the Free Software Foundation; either version 3 of the License, or=0A= +# (at your option) any later version.=0A= +#=0A= +# This program is distributed in the hope that it will be useful,=0A= +# but WITHOUT ANY WARRANTY; without even the implied warranty of=0A= +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the=0A= +# GNU General Public License for more details.=0A= +#=0A= +# You should have received a copy of the GNU General Public License=0A= +# along with this program; if not, see .=0A= +=0A= +# Test mips release 6 patch.=0A= +=0A= +require {istarget "*mips*"}=0A= +=0A= +standard_testfile .c=0A= +=0A= +set tests { test_r6_branch test_r6_forbidden test_r6_64 test_r6=0A= +test_r6_fpu test_r6_llsc_dp test_r6_llsc_wp }=0A= +=0A= +proc single_step {} {=0A= + global gdb_prompt=0A= +=0A= + send_gdb "si\n"=0A= + gdb_expect {=0A= + -re "$gdb_prompt \$" {=0A= + return 1=0A= + }=0A= + -re ".*Breakpoint.*test_.*" {=0A= + return 2=0A= + }=0A= + -re ".*exited normally.*" {=0A= + return 3=0A= + }=0A= + -re ".*The program is not being run.*" {=0A= + return 4=0A= + }=0A= + }=0A= + return 0=0A= +}=0A= +=0A= +if { [gdb_compile "${srcdir}/${subdir}/${srcfile}" "${binfile}" executabl= e { debug }] !=3D "" } {=0A= + fail "compilation"=0A= + return=0A= +}=0A= +=0A= +clean_restart $binfile=0A= +if { ![runto_main] } {=0A= + return=0A= +}=0A= +=0A= +# put breakpoint on each test-function=0A= +foreach func $tests {=0A= + gdb_test "break $func" "Breakpoint.*at.*" "set breakpoint on $func"=0A= +}=0A= +=0A= +set rt [single_step]=0A= +if { $rt =3D=3D 0 } {=0A= + fail "single_step returned $rt"=0A= + return=0A= +}=0A= +=0A= +set start [timestamp]=0A= +global timeout=0A= +while { $rt !=3D 0 && [timestamp] - $start < 3*$timeout } {=0A= +=0A= + if { $rt =3D=3D 3 } {=0A= + pass "all tests are fine"=0A= + return=0A= + } elseif { $rt =3D=3D 4 } {=0A= + fail "Program exited abnormally"=0A= + return=0A= + }=0A= +# elseif { $rt =3D=3D 1 || $rt =3D=3D 2 } { # 1->got gdb_prompt ; 2->hit = breakpoint=0A= +# verbose -log "\[DEBUG_\] 'single_step' returned rt=3D$rt ; timeout = =3D $timeout"=0A= +# }=0A= +=0A= + set rt [single_step]=0A= +}=0A= +=0A= +if {$rt =3D=3D 0 } {=0A= + fail "stepi"=0A= +}=0A= +=0A= -- =0A= 2.34.1=0A=