From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR03-AM7-obe.outbound.protection.outlook.com (mail-am7eur03on2044.outbound.protection.outlook.com [40.107.105.44]) by sourceware.org (Postfix) with ESMTPS id B20E53858284 for ; Tue, 3 Oct 2023 10:54:08 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org B20E53858284 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=arm.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pu1xEHoqPaoopW8ztccXast0TaeAg4Ls3ImLGPlAtEk=; b=t49QkqKztkkKxFEVRa9r/onS0xp4hCAT8Im4aoFxEtPa14cUbrcTaVPkjYNym+Bb97iLy1tgfo+m3jilNwMDLzyhuj4Aef6CofDR6XvWy2aKldJlM5daRAPhefcTruShvr3V6lAzOuwbno3dxSAeShmwPuX9XgO6GBYywEXxaWk= Received: from AS4P189CA0036.EURP189.PROD.OUTLOOK.COM (2603:10a6:20b:5dd::7) by AS8PR08MB9455.eurprd08.prod.outlook.com (2603:10a6:20b:5ed::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.28; Tue, 3 Oct 2023 10:54:01 +0000 Received: from AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:5dd:cafe::a1) by AS4P189CA0036.outlook.office365.com (2603:10a6:20b:5dd::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.30 via Frontend Transport; Tue, 3 Oct 2023 10:54:00 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 63.35.35.123) smtp.mailfrom=arm.com; dkim=pass (signature was verified) header.d=armh.onmicrosoft.com;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 63.35.35.123 as permitted sender) receiver=protection.outlook.com; client-ip=63.35.35.123; helo=64aa7808-outbound-1.mta.getcheckrecipient.com; pr=C Received: from 64aa7808-outbound-1.mta.getcheckrecipient.com (63.35.35.123) by AM7EUR03FT025.mail.protection.outlook.com (100.127.140.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6863.24 via Frontend Transport; Tue, 3 Oct 2023 10:54:00 +0000 Received: ("Tessian outbound 9aeaca65ec26:v211"); Tue, 03 Oct 2023 10:54:00 +0000 X-CheckRecipientChecked: true X-CR-MTA-CID: 08fe75f8748245c1 X-CR-MTA-TID: 64aa7808 Received: from b413fc5381e8.1 by 64aa7808-outbound-1.mta.getcheckrecipient.com id 517F1D39-7908-4181-B7FC-84E378DD5EB8.1; Tue, 03 Oct 2023 10:53:54 +0000 Received: from EUR01-VE1-obe.outbound.protection.outlook.com by 64aa7808-outbound-1.mta.getcheckrecipient.com with ESMTPS id b413fc5381e8.1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384); Tue, 03 Oct 2023 10:53:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ExTiX2egQ5Nwz4W/1AemTwjTGqZooM5SGW0hMzVjml4PE2+ZqFB9P1rWGa3ppBP+kpcBaNGgBjH/WFRtqEs/d1UXPVGs7XJHgDnG3MZ05JIUj9aDSlXuVyoT0l29bKNPwJ7ZVx5SH/Rq8H5vE1Ixyi0epIm0QlLZ2LRxSYwYCw3XHLa6pA7+sbRu11xaUn17VBQr7QcgmiC83mGhETXMB76/tltCtr5Pb8G839NISC/84NFADvhugAKt9yMp6MVdL29sE6C8ed/781NCY98/CMab3EQDaUutxpkjoJVTe+gwFjp9nGQ+LIztVXzgvJs7ofb7tKmotmN/pPXXMbZaCw== 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=pu1xEHoqPaoopW8ztccXast0TaeAg4Ls3ImLGPlAtEk=; b=PS44QF8K6vGRZE5LO0JxJL0YU6/UO7ZO6lPk57in7s5GIyYU7c0kdlNHthZkW9NSa9fKpe0zZv1yvQsripnNOPzlZ/RqQ8fwFUuSrN9WJG47wQioBKSbqS9Ia+aHovgBTNBP0iVTk8ER+EtD8ZXbbMABB1/aF5EAZ0WCe62UYUBSmGmTL6r0fEg3c1WzwdTIBMqhiEmuIXcJSUp+qgTG1GbXAnER0EGh0bn7zwykD8N6DlTeLQriMuRrpTq72LCRzI/1e/7XJq1ezD+Vtlipd4Mk3UDpxtnveR4wersMp/SNYXFaeIBJxV0IScbmJA+UZoz190uck9hthD3gNYYAzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 40.67.248.234) smtp.rcpttodomain=sourceware.org smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=armh.onmicrosoft.com; s=selector2-armh-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=pu1xEHoqPaoopW8ztccXast0TaeAg4Ls3ImLGPlAtEk=; b=t49QkqKztkkKxFEVRa9r/onS0xp4hCAT8Im4aoFxEtPa14cUbrcTaVPkjYNym+Bb97iLy1tgfo+m3jilNwMDLzyhuj4Aef6CofDR6XvWy2aKldJlM5daRAPhefcTruShvr3V6lAzOuwbno3dxSAeShmwPuX9XgO6GBYywEXxaWk= Received: from AM6PR08CA0002.eurprd08.prod.outlook.com (2603:10a6:20b:b2::14) by AS2PR08MB9389.eurprd08.prod.outlook.com (2603:10a6:20b:597::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33; Tue, 3 Oct 2023 10:53:51 +0000 Received: from AM7EUR03FT017.eop-EUR03.prod.protection.outlook.com (2603:10a6:20b:b2:cafe::d9) by AM6PR08CA0002.outlook.office365.com (2603:10a6:20b:b2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6838.33 via Frontend Transport; Tue, 3 Oct 2023 10:53:51 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 40.67.248.234) smtp.mailfrom=arm.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=arm.com; Received-SPF: Pass (protection.outlook.com: domain of arm.com designates 40.67.248.234 as permitted sender) receiver=protection.outlook.com; client-ip=40.67.248.234; helo=nebula.arm.com; pr=C Received: from nebula.arm.com (40.67.248.234) by AM7EUR03FT017.mail.protection.outlook.com (100.127.140.184) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6863.24 via Frontend Transport; Tue, 3 Oct 2023 10:53:51 +0000 Received: from AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) by AZ-NEU-EX03.Arm.com (10.251.24.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 3 Oct 2023 10:53:50 +0000 Received: from AZ-NEU-EX04.Arm.com (10.251.24.32) by AZ-NEU-EX02.Emea.Arm.com (10.251.26.5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Tue, 3 Oct 2023 10:53:50 +0000 Received: from e125768.cambridge.arm.com (10.2.78.50) by mail.arm.com (10.251.24.32) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Tue, 3 Oct 2023 10:53:50 +0000 From: Victor Do Nascimento To: CC: , , Victor Do Nascimento Subject: [PATCH v2 1/2] aarch64: system register aliasing detection Date: Tue, 3 Oct 2023 11:51:57 +0100 Message-ID: <20231003105338.1812768-2-victor.donascimento@arm.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231003105338.1812768-1-victor.donascimento@arm.com> References: <20231003105338.1812768-1-victor.donascimento@arm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EOPAttributedMessage: 1 X-MS-TrafficTypeDiagnostic: AM7EUR03FT017:EE_|AS2PR08MB9389:EE_|AM7EUR03FT025:EE_|AS8PR08MB9455:EE_ X-MS-Office365-Filtering-Correlation-Id: 80a1ca4d-954b-4154-6436-08dbc3ff0d43 X-LD-Processed: f34e5979-57d9-4aaa-ad4d-b122a662184d,ExtAddr x-checkrecipientrouted: true NoDisclaimer: true X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam-Untrusted: BCL:0; X-Microsoft-Antispam-Message-Info-Original: dUIneMovDDGUaHVUM5e+iiSEjOZdCi+cE3rqVkkZXGaHc1YjFFYR2iTkCgeZY1Dp7MDiUJUNjp4FNvx8rkb0O/+xVsr9OX8Y4auG6RtKA0f59EXKJc64c9JHW6xU5P2cW/pWU9LV+Wjqx90IjkC2rpoqu3XRiVZ5oaU+0mC+6EuZyQWctMMEjmyWFs1gONK/yveJrJqoywyNSmi3e2ma4SjCliJt/H4/PUAVH+prbO/L7sMwc95yjjNVT+NmuDvP4T48f0tFhG/Q0iXqoLPk5b3T/t5Ftv4odZBvq2w+PnXTrbDF/U8aXEfTiFb6lH+RwEPFAa+rUpL9xXm/Uvan7j09IN6Eee5XjtaoGrulpLzBLoQzYHqNYTybVkAz3uNz8krVwzGg9D0YP9R+YOOTj2VdzIVQ4pmxK+z4bat2H4m0iWG0gwNlyC2+WuByrUco/42wzhpMVlhAsry1caE//ha/kZpn16X6rddspZer6TzFBjByMm0TYxhWCRk0IKW6YRoKM36XUPX4ufVV0j5eArWf0NTfxqpJjOqXyVoe+dOLac3bz/9AXGxM9E/wvLNzTJj3IsjfzTGEh3JhAuhOZ4sacffDf7f07M9gXz4iXrrg7/qP5n2SXbRwnefiyo341cUiuTgmtPy5f9qaYcg8l8eY5r7V4Ay/ou5/ARXstgdwaIwBGYeJy9d9R6P0jJzvQPgS6wXqpkWoISpQt+gmLGxDfzbqua0OS3+QD75l/ebF6ZssLp+cCYXECZax4/agIbQFq/qwUtwc7z2oQZGbmA== X-Forefront-Antispam-Report-Untrusted: CIP:40.67.248.234;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:nebula.arm.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230031)(4636009)(396003)(39860400002)(346002)(376002)(136003)(230922051799003)(1800799009)(451199024)(64100799003)(186009)(82310400011)(46966006)(40470700004)(36840700001)(82740400003)(426003)(478600001)(356005)(81166007)(36756003)(6916009)(70206006)(70586007)(41300700001)(54906003)(316002)(36860700001)(47076005)(83380400001)(26005)(1076003)(2616005)(7696005)(336012)(5660300002)(86362001)(8676002)(4326008)(8936002)(40480700001)(2906002)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS2PR08MB9389 X-MS-Exchange-Transport-CrossTenantHeadersStripped: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id-Prvs: bfc35192-b512-4947-41b9-08dbc3ff07de X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 95GDU2FGnvEm5SqrDnP2eKLhqdLxUZnyFDOaka0/9j9JucfHb8QBbUoCUSypfJcoZyix3Up0qplrtp6MNqsMdbNkUb/QwcylUb+iXYBqmVmlJhEXmQRS1ExadnUAREDJ6ffGX9Co4HiEbb4vkwD2wv0Td9pX754guECXHjx32/yL52Ey84+q7Q5mjV+NYHR1pPWjADVRi71DsAHOEoaXEaLpb1lemU8juodo+HXrvv9SxmO+MVuudhHBm3rQQ+6DtP4g4XhGPZr0CrBHuCqJNRpbD2NMdJHC+Unjj6jh1qaaOKMI4KMSy8VuzKpovKnOpkGzVvkFTzAeLooyY3cbtLpGI79VkPmXesoJIbwRURZh2Ki8t6Bkxd3mX/07gEQUiVdAbI4nVQOFB8xtNkB2YvpjbYoAhiPzdwbM2ZkhjkJVnQF1NreUqb+jELwH0rFcO7Ll0hSZrjzvSYMMMGexzvfgxEQln5lSQso17ezfduLnc6ojV7Ga7borz7xghImVrnzg3vWggwVuU+PMKWHAZjRNYm247b2uV5BpcYY3xL1RpsuHOzmxL1AMPZJkjP1X1CInm5i5MAZClUC+tr7hD07VtkQ7AeqMR9dBg79nxmNi2FdUiTdFYfOuKs64D+a54UU1OPYfW9tkAOVqIK09Bu7t8zy3JxFLOV+KbLYDmmn7OZ/QeaOCn5adlGrybr7XeJSrZSu7muU+LCs3XBjPb6wziTwpMzr0KaasiiJQEfwuPIDvUdWEIXUEwURpjc8C X-Forefront-Antispam-Report: CIP:63.35.35.123;CTRY:IE;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:64aa7808-outbound-1.mta.getcheckrecipient.com;PTR:ec2-63-35-35-123.eu-west-1.compute.amazonaws.com;CAT:NONE;SFS:(13230031)(4636009)(346002)(376002)(136003)(396003)(39860400002)(230922051799003)(64100799003)(186009)(451199024)(1800799009)(82310400011)(36840700001)(46966006)(40470700004)(40460700003)(2906002)(2616005)(1076003)(86362001)(70206006)(70586007)(6916009)(82740400003)(478600001)(36860700001)(47076005)(426003)(26005)(83380400001)(336012)(81166007)(7696005)(316002)(40480700001)(36756003)(5660300002)(41300700001)(54906003)(8936002)(4326008)(8676002);DIR:OUT;SFP:1101; X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Oct 2023 10:54:00.9029 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 80a1ca4d-954b-4154-6436-08dbc3ff0d43 X-MS-Exchange-CrossTenant-Id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=f34e5979-57d9-4aaa-ad4d-b122a662184d;Ip=[63.35.35.123];Helo=[64aa7808-outbound-1.mta.getcheckrecipient.com] X-MS-Exchange-CrossTenant-AuthSource: AM7EUR03FT025.eop-EUR03.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS8PR08MB9455 X-Spam-Status: No, score=-12.8 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,FORGED_SPF_HELO,GIT_PATCH_0,KAM_DMARC_NONE,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_NONE,TXREP,UNPARSEABLE_RELAY 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: This patch adds a mechanism for system register name alias detection to register matching mechanisms. A new `F_REG_ALIAS' flag is added to the set of register flags and used to label which entries in aarch64_sys_regs[] correspond to aliases (and thus which CPENC values are non-unique in this array). Where this is used is, for example, in `aarch64_print_operand' where, in the case of system register decoding, the aarch64_sys_regs[] array is iterated through until a match in CPENC value is made and the first match accepted. If insufficient care is given in the ordering of system registers in this array, the alias is encountered before the "real" register and used incorrectly as the register name in the disassembled output. With this flag and the new `aarch64_sys_reg_alias_p' test, search candidates corresponding to aliases can be conveniently skipped over. One concrete example of where this is useful is with the `trcextinselr0' system register. It was initially placed in the system register list before `trcextinselr', in contrast to a more natural alphabetical order. include/ChangeLog: * opcode/aarch64.h: add `aarch64_sys_reg_alias_p' prototype. opcodes/ChangeLog: * aarch64-opc.c (aarch64_sys_reg_alias_p): New. (aarch64_print_operand): add aarch64_sys_reg_alias_p check. (aarch64_sys_regs): Add F_REG_ALIAS flag to "trcextinselr" entry. * aarch64-opc.h (F_REG_ALIAS): New. --- include/opcode/aarch64.h | 1 + opcodes/aarch64-opc.c | 9 ++++++++- opcodes/aarch64-opc.h | 3 +++ 3 files changed, 12 insertions(+), 1 deletion(-) diff --git a/include/opcode/aarch64.h b/include/opcode/aarch64.h index ab42acac8c2..d4ec60c1354 100644 --- a/include/opcode/aarch64.h +++ b/include/opcode/aarch64.h @@ -1240,6 +1240,7 @@ typedef struct extern const aarch64_sys_reg aarch64_sys_regs []; extern const aarch64_sys_reg aarch64_pstatefields []; extern bool aarch64_sys_reg_deprecated_p (const uint32_t); +extern bool aarch64_sys_reg_alias_p (const uint32_t); extern bool aarch64_pstatefield_supported_p (const aarch64_feature_set, const aarch64_sys_reg *); diff --git a/opcodes/aarch64-opc.c b/opcodes/aarch64-opc.c index df1b5113641..c901d3d587b 100644 --- a/opcodes/aarch64-opc.c +++ b/opcodes/aarch64-opc.c @@ -4507,6 +4507,7 @@ aarch64_print_operand (char *buf, size_t size, bfd_vma pc, partial match that was found. */ if (aarch64_sys_regs[i].value == opnd->sysreg.value && ! aarch64_sys_reg_deprecated_p (aarch64_sys_regs[i].flags) + && ! aarch64_sys_reg_alias_p (aarch64_sys_regs[i].flags) && (name == NULL || exact_match)) { name = aarch64_sys_regs[i].name; @@ -5320,7 +5321,7 @@ const aarch64_sys_reg aarch64_sys_regs [] = SR_CORE ("trceventctl0r", CPENC (2,1,C0,C8,0), 0), SR_CORE ("trceventctl1r", CPENC (2,1,C0,C9,0), 0), SR_CORE ("trcextinselr0", CPENC (2,1,C0,C8,4), 0), - SR_CORE ("trcextinselr", CPENC (2,1,C0,C8,4), 0), + SR_CORE ("trcextinselr", CPENC (2,1,C0,C8,4), F_REG_ALIAS), SR_CORE ("trcextinselr1", CPENC (2,1,C0,C9,4), 0), SR_CORE ("trcextinselr2", CPENC (2,1,C0,C10,4), 0), SR_CORE ("trcextinselr3", CPENC (2,1,C0,C11,4), 0), @@ -5742,6 +5743,12 @@ aarch64_sys_reg_deprecated_p (const uint32_t reg_flags) return (reg_flags & F_DEPRECATED) != 0; } +bool +aarch64_sys_reg_alias_p (const uint32_t reg_flags) +{ + return (reg_flags & F_REG_ALIAS) != 0; +} + /* The CPENC below is fairly misleading, the fields here are not in CPENC form. They are in op2op1 form. The fields are encoded by ins_pstatefield, which just shifts the value by the width of the fields diff --git a/opcodes/aarch64-opc.h b/opcodes/aarch64-opc.h index 32e4da2bbb6..fe1f882c20e 100644 --- a/opcodes/aarch64-opc.h +++ b/opcodes/aarch64-opc.h @@ -292,6 +292,9 @@ verify_constraints (const struct aarch64_inst *, const aarch64_insn, bfd_vma, #undef F_REG_IN_CRM #define F_REG_IN_CRM (1 << 5) /* Register extra encoding in CRm. */ +#undef F_REG_ALIAS +#define F_REG_ALIAS (1 << 6) /* Register name aliases another. */ + /* PSTATE field name for the MSR instruction this is encoded in "op1:op2:CRm". Part of CRm can be used to encode . E.g. CRm[3:1] for SME. In order to set/get full PSTATE field name use flag F_REG_IN_CRM and below -- 2.41.0