From patchwork Fri May 12 10:30:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 93111 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp4994015vqo; Fri, 12 May 2023 03:32:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7pO/pgpC1MDO8wEt6+KugWZxI7WR3qQtXmiXVwNuNvrU284ghoDRRV5T00JP2girPg94X6 X-Received: by 2002:a05:6402:517b:b0:4fa:b302:84d4 with SMTP id d27-20020a056402517b00b004fab30284d4mr19664599ede.13.1683887527828; Fri, 12 May 2023 03:32:07 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1683887527; cv=pass; d=google.com; s=arc-20160816; b=etVxSZqvF7/wnVXEzhUqLkcFcaVLlBxlB5JmrpivepnTZylaeGRp6tPEBOgv8cRa2V l1iUJGQ7lmgHdZuhX9pW5WeGuVIjedG4kCVTXjb+g5I9vnd8UMxroRjxYuF4G47iMLfO OvtBjdeZ3nf1Hjfl3xu3+xyiBmqsbuBed32QmFNx5E/OzwjJO0XWRNgoj7A3RcLQJxRI dTuDm4PTqKHst2Yu/vLdhNK/3lJSh7Lv+YVv+AmUdvRwV0FVeljH8sCvdD3cinAjso96 l7lBziM5F9JndSMb7V4ZDhh6ltIWupIr/mxsBt75wd6CsYAcjnq9MkH1cDYNqT61oGI1 8iFg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:mime-version :content-transfer-encoding:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dmarc-filter:delivered-to; bh=T0xsHQodjtBLTuPbA+AUV79xepvEBIKJl1y2uH60BiI=; b=yY0jRIZ/O+hC/jrLgDHq/ZX7hfeVIxy0GZsmPUIg2xrtKxCqMMRUePgC84kWkpa033 qxox+GXRhz5aVH4uqFBCbuiA611TfP3bt4l8eGyauCs4l21lK661c77e8xqMHY9XBB+v iJvMuZ7NSJ7abh0l5j/u7cSeKqYRWQcqw7Pxscgqn5zd1tW8dkgpAf9T/UpvKPTx2v6b HQj1eFNTyKbfsqOwfcUBq62+8oADD19PwmJVokqB7LvuRuAXMQIyBd31cEGThIGU6FY4 fMesbGHugLgfg9QNthLbN6zANHmVsjMNUyU3ZK5m6dreScOPRVt1ydxsK21CDjss4pS2 UATQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b="A4ySVlu/"; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id g13-20020aa7c58d000000b0050bc13ea5a0si6064396edq.177.2023.05.12.03.32.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 12 May 2023 03:32:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b="A4ySVlu/"; arc=pass (i=1 spf=pass spfdomain=cipunited.com dkim=pass dkdomain=cipunited.com dmarc=pass fromdomain=cipunited.com); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 810483854162 for ; Fri, 12 May 2023 10:31:26 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from APC01-SG2-obe.outbound.protection.outlook.com (mail-sgaapc01on2120.outbound.protection.outlook.com [40.107.215.120]) by sourceware.org (Postfix) with ESMTPS id 8B4BE3858C5F for ; Fri, 12 May 2023 10:30:27 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B4BE3858C5F Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cipunited.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cipunited.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Jg1LsYTdxCIyUu2z0Kyr+vm3fRFOwSoLErg1WR/s3SsW4C64Dc3JdvhJyikyWRG6BwF17vKTVcouWc4aWuLaq591L9Dr8WC5JQhS//mkF22O6ffPKdghtHddJFcNxACoG98lSpXfGY5xNg3MYIaFM6pq+u2BUJHyXqCyLJnqFvbR1vJneQ6fG1xupG5ZSpYwXRLc82cX+1DS9a+ssc4hNb4KoC+ay1KfFhhbLP4tprWhz5BU+sWeat8gW97C4B5PY++taNr/PF8+PFtOwB76WGNFU6Xm3tWvqeNO9ENE1mBU6fLJg8qCnV3KauN0wjy6dpngfdkSetbQ0M9NJsbzyA== 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=T0xsHQodjtBLTuPbA+AUV79xepvEBIKJl1y2uH60BiI=; b=GJiD4581wDJoxvKeQFvXgWUuxk9QSfp+aouAO6+UgVw9AGBmO6LHuik5KYBsPldrQ6Aky83OtGIHpjhoNIXdUV6pnQ3QylXaq8uR7XHj5dTbWnbHG4JI39BZhO0ctOiGW9wFDjuwBItB57ib+ZNPHMgP6nmTAa/yZk0zf9o9PzKZAYBf3LRwmOdWI/WVm+w3EyKZmFRHlj9XI7+vzdk5xm+fgxw7T8d+uU67Vv9cEpjtbciIdqYnvjV0DjYEenlOd8GgSoVYyUZtTqiZtyh6rbban5Wp36/m/lgadyvTrH6P4hXqYnLfQcupD8L6Dt8nAtRcYYKY2g0X3WzrCdyJMA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=cipunited.com; dmarc=pass action=none header.from=cipunited.com; dkim=pass header.d=cipunited.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cipunited.onmicrosoft.com; s=selector1-cipunited-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=T0xsHQodjtBLTuPbA+AUV79xepvEBIKJl1y2uH60BiI=; b=A4ySVlu/vZpgkAezkKbMBI1iAQNPWdwf4ZAFctg+/Wa/OveIvqMA4CuMNjGYduvuchs1vDKxmW3Re7lvjJnOMvPNOA2eBAkF3CR6gam1rCMsvJw8MfwCVx44rG4zvLXutMQWAnNVcluBZWVwb6um2L1Cy+QFnsd9LF/nYuChyxI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=cipunited.com; Received: from TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) by SG2PR04MB3931.apcprd04.prod.outlook.com (2603:1096:0:b::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6363.27; Fri, 12 May 2023 10:30:23 +0000 Received: from TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150]) by TYZPR04MB6117.apcprd04.prod.outlook.com ([fe80::4016:87b:f0d1:b150%6]) with mapi id 15.20.6387.021; Fri, 12 May 2023 10:30:23 +0000 From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: syq@debian.org, macro@orcam.me.uk, xry111@xry111.site, richard.sandiford@arm.com, jiaxun.yang@flygoat.com, amodra@gmail.com, YunQiang Su Subject: [PATCH v4] MIPS: add speculation_barrier support Date: Fri, 12 May 2023 18:30:06 +0800 Message-Id: <20230512103006.1944244-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230512100327.1941926-1-yunqiang.su@cipunited.com> References: <20230512100327.1941926-1-yunqiang.su@cipunited.com> X-ClientProxiedBy: TYWPR01CA0017.jpnprd01.prod.outlook.com (2603:1096:400:a9::22) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|SG2PR04MB3931:EE_ X-MS-Office365-Filtering-Correlation-Id: 67028fb8-5cc5-4b9d-fd4a-08db52d3e4c2 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MH158eLArwuM57siqclJhfnAK9s9bGUNU58gYPjK1YP1xwKrizKozhYN6Yb1DMeLDzIfZN7I2WT5LRBMzl5nyFmFBUQWyqm+NrbRUULbZ+5PY+YNWWnO+SBQ4tm3NkbVeqpiVayHPaJe4/rpDECUvL/5InPhWNORu2JZnehIi0hD2o2/OCmAVlXLcTSF5hc1wTsL7rvefHnW4T7HA3hFEwARrct705kYg4DeMNOS8opFV+GETQ7o9NOsY7pVKZNlh3zY+49hxMegevFVdlnhwBy4OtH+Zh8xNJU/OBZVv0WtJwK6sVs4SjvHPvqMy00piafyle98IcfNlnIaT5gURugNKzkhtmTw5LFNZZUgfWQ/TzXHakBJ7F3NNL+mOrUJeid4fYM5cXggoFXupDV164kH46BUMkIiIvtxBOZwnrwb5EGOZXr5r0+C0zIwH2a10mZRkDCM9QDzn6xyenONrZlnaIkYLZJyWxEgMePToQhzQk4I9VzCUf4jNl12ADzIFluoph4fvsO2DS9awd3RnB+vTvLwMjDfFzqJzlKZ5FuaHk+VQ0owYvCmCQS5qheLXl1l2aKnm13n6SjPJP0BfPYy3dZQ+7XcAyykGuNhro53PGD71lu1xhgkhDdU9FMy X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:TYZPR04MB6117.apcprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230028)(39830400003)(366004)(346002)(136003)(376002)(396003)(451199021)(2616005)(8936002)(6512007)(107886003)(6506007)(5660300002)(8676002)(26005)(6916009)(1076003)(83380400001)(30864003)(38100700002)(2906002)(6666004)(4326008)(36756003)(52116002)(478600001)(86362001)(186003)(66946007)(316002)(66476007)(66556008)(41300700001)(38350700002)(6486002)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: HiivP7bX26pUaZ1CdfMysrQL/EkWZPkHr3yULEGvDf5vvX3X7VkJLq83jmkDgbWVg1ZdjJhYfkdheIeXPpZIKQRrkjt94Dp2r8QKF0anxRArZnR4sAC31906JPfcZ4lbsU3vNXG/49+nT98qA4EaPbI3vHACibKCOfbl7fIcB4B7g+Ngb5YghrKYReB+lPw2cuR1wFHC3wLYX9SAJAsBWkO0iB/cT7HvCeUSN+RDYQHwwOPudcBwKYOp0plqaZrbpO27kVIm4NDvSXxFoqOld7wRie8wTPpq0j0+BUzFmxi+QonNxpqHDeXxoKyR6xRpIVTR3qbFqkA/NLJ8PctymlKJeRgZXjy71jevpN8JHols/j5jAPYSCNiS3H2LhoRu7kkgFMFS6nrebL4gNeCJURy6b3OKKdeE5UVqUBy/Qf1aFI1UlCxu7mtwno/gRmCDV5aawIPhJcqMhkDbhaXjgwxHJ4uINoLvBTrFCG6pEHYFMi3n3eKdQRDR8oCZRHBunEb63TytcM2eOm7VmLrO0sGiltLPkWHZMOutvyXQFk/3PR40hDbQSCZafCN/exqShzXoDMdLq+HCjxud2Iud0UhNnuHXJk0HNXQHRoP7sgj8V9OSn0D8EcJOhTTNFjvC4MkQF8SlaviCOtjp2Ws2JJsiyqpBnUty65FWkOyKtqs87J0h66IOaSGEdvvL/jd+DcBJ3+37QX2IOyGy3h2XJf0Cgrea+iDUkLTn9I7h9yNCpXthOk3qSmQFt5zcU55X4CsJOYM4hI9WTLWSRfDOpbk97hVuwgQaPaW93fkmTxQdEs124zG+8enSqd5HFZ+CHyGX2xXiIdGrm69CW319fZ0k6glAHGMVsYVS175KGGf21SKKhUgTaat66CJXiZBgw8cga2KafJDZyx8arVzkHDfxjLdJV8Q+09XxWUMStBzgkvfkMFA+mNmDSOVHkzRJ3qkrNAGYEQf3Hqlhu5ORTSDO1eUJy7GfdWoXrzeQMFcvYZj4tq4J4Jaqme3EJek+kCqvLQjg1AD91XVl7Zl8HcbiI6JnN/SD6vCUBobmTPv2P+koS7/Hsl+VrX7l7CDqilX+eoBp2F6+F1m1gvHJ3HQQ5vRJL6D79QzzvX00lf+Gsb1prnXCgTW9kSYWfOAqu9RZ3dKH3v/rnz6lOK713ikaoY023fBKRsvnhg0+obTUGP+bQ/xO89Bw6CBI0jHZfEhww3qCPVrobu7HPnJzRK+OokrlUiV012OxeJKyjUanJntQFAhamqpAYdZQz16ZH7w7NdZz7sdDRoh46PLCQEn1bwSnlAWZEps42QJ+F3p8rGgzNyEEnREMMG+JhrEgalUHBZLnuoZn/BrgqsB5DyV6iVMl7lvPtcu8hKbDDVgnRD7jUnay7832tI8prX8T9n1A2MnXaqcFxQaWqkbilMLEWGINIXEpT/NwIW5m/jXg9SPm/EPScjFcC3lM0gPU+TDNmxSS5yu5XfcbJfL4Cb0/FYM+oFehTMHsii8T9wrYkuHY5LzmUYNEtlFzPiqnE8UaMDQ5F8o6LOaJuNSXJM0/aI6WQdkq4yuyOITPk/ouKhLAKqM0KxGBin62tLP7GLrqsB9uT2TSz+b1vXHdmw== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 67028fb8-5cc5-4b9d-fd4a-08db52d3e4c2 X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 May 2023 10:30:23.5678 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: e31cf5b5-ee69-4d5f-9c69-edeeda2458c0 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: mH7SnAYyUQ5ekwcVychCgL+OFGnrxc+rBcIdBc6QJ+dUUiQkYAmm2Js+09l3/lu2KVnB8YEdJjvDNNf3BSN9OIF4tXf5nqK/jz8BhmDBBas= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SG2PR04MB3931 X-Spam-Status: No, score=-13.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_PASS, 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 X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1764423401062025876?= X-GMAIL-MSGID: =?utf-8?q?1765684048030659262?= speculation_barrier for MIPS needs sync+jr.hb (r2+), so we implement __speculation_barrier in libgcc, like arm32 does. gcc/ChangeLog: * config/mips/mips-protos.h (mips_emit_speculation_barrier): New prototype. * config/mips/mips.cc (speculation_barrier_libfunc): New static variable. (mips_init_libfuncs): Initialize it. (mips_emit_speculation_barrier): New function. * config/mips/mips.md (speculation_barrier): Call mips_emit_speculation_barrier. * configure.ac: error if gas doesn't accept ssnop for mips1. * configure: regenerated. * doc/install.texi: documents mips requires binutils 2.21+. libgcc/ChangeLog: * config/mips/lib1funcs.S: New file. define __speculation_barrier and include mips16.S. * config/mips/t-mips: define LIB1ASMSRC as mips/lib1funcs.S. define LIB1ASMFUNCS as _speculation_barrier. set version info for __speculation_barrier. * config/mips/libgcc-mips.ver: New file. * config/mips/t-mips16: don't define LIB1ASMSRC as mips16.S is included in lib1funcs.S now. --- gcc/config/mips/mips-protos.h | 2 + gcc/config/mips/mips.cc | 13 +++++++ gcc/config/mips/mips.md | 12 ++++++ gcc/configure | 32 +++++++++++++++ gcc/configure.ac | 7 ++++ gcc/doc/install.texi | 2 + libgcc/config/mips/lib1funcs.S | 62 ++++++++++++++++++++++++++++++ libgcc/config/mips/libgcc-mips.ver | 21 ++++++++++ libgcc/config/mips/t-mips | 7 ++++ libgcc/config/mips/t-mips16 | 3 +- 10 files changed, 159 insertions(+), 2 deletions(-) create mode 100644 libgcc/config/mips/lib1funcs.S create mode 100644 libgcc/config/mips/libgcc-mips.ver diff --git a/gcc/config/mips/mips-protos.h b/gcc/config/mips/mips-protos.h index 20483469105..da7902c235b 100644 --- a/gcc/config/mips/mips-protos.h +++ b/gcc/config/mips/mips-protos.h @@ -388,4 +388,6 @@ extern void mips_register_frame_header_opt (void); extern void mips_expand_vec_cond_expr (machine_mode, machine_mode, rtx *); extern void mips_expand_vec_cmp_expr (rtx *); +extern void mips_emit_speculation_barrier_function (void); + #endif /* ! GCC_MIPS_PROTOS_H */ diff --git a/gcc/config/mips/mips.cc b/gcc/config/mips/mips.cc index ca822758b41..139707fda34 100644 --- a/gcc/config/mips/mips.cc +++ b/gcc/config/mips/mips.cc @@ -13611,6 +13611,9 @@ mips_autovectorize_vector_modes (vector_modes *modes, bool) return 0; } + +static GTY(()) rtx speculation_barrier_libfunc; + /* Implement TARGET_INIT_LIBFUNCS. */ static void @@ -13680,6 +13683,7 @@ mips_init_libfuncs (void) synchronize_libfunc = init_one_libfunc ("__sync_synchronize"); init_sync_libfuncs (UNITS_PER_WORD); } + speculation_barrier_libfunc = init_one_libfunc ("__speculation_barrier"); } /* Build up a multi-insn sequence that loads label TARGET into $AT. */ @@ -19092,6 +19096,15 @@ mips_avoid_hazard (rtx_insn *after, rtx_insn *insn, int *hilo_delay, } } +/* Emit a speculation barrier. + JR.HB is needed, so we need to put + speculation_barrier_libfunc in libgcc */ +void +mips_emit_speculation_barrier_function () +{ + emit_library_call (speculation_barrier_libfunc, LCT_NORMAL, VOIDmode); +} + /* A SEQUENCE is breakable iff the branch inside it has a compact form and the target has compact branches. */ diff --git a/gcc/config/mips/mips.md b/gcc/config/mips/mips.md index ac1d77afc7d..5d04ac566dd 100644 --- a/gcc/config/mips/mips.md +++ b/gcc/config/mips/mips.md @@ -160,6 +160,8 @@ ;; The `.insn' pseudo-op. UNSPEC_INSN_PSEUDO UNSPEC_JRHB + + VUNSPEC_SPECULATION_BARRIER ]) (define_constants @@ -7455,6 +7457,16 @@ mips_expand_conditional_move (operands); DONE; }) + +(define_expand "speculation_barrier" + [(unspec_volatile [(const_int 0)] VUNSPEC_SPECULATION_BARRIER)] + "" + " + mips_emit_speculation_barrier_function (); + DONE; + " +) + ;; ;; .................... diff --git a/gcc/configure b/gcc/configure index 191f68581b3..e55b40d7f4c 100755 --- a/gcc/configure +++ b/gcc/configure @@ -28699,6 +28699,38 @@ $as_echo "#define HAVE_LD_PERSONALITY_RELAXATION 1" >>confdefs.h fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for mips1 recognize ssnop" >&5 +$as_echo_n "checking assembler for mips1 recognize ssnop... " >&6; } +if ${gcc_cv_as_mips1_ssnop+:} false; then : + $as_echo_n "(cached) " >&6 +else + gcc_cv_as_mips1_ssnop=no + if test x$gcc_cv_as != x; then + $as_echo 'ssnop' > conftest.s + if { ac_try='$gcc_cv_as $gcc_cv_as_flags -mabi=32 -mips1 -o conftest.o conftest.s >&5' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + echo $ac_try + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + gcc_cv_as_mips1_ssnop=yes + else + echo "configure: failed program was" >&5 + cat conftest.s >&5 + fi + rm -f conftest.o conftest.s + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_mips1_ssnop" >&5 +$as_echo "$gcc_cv_as_mips1_ssnop" >&6; } + + + if test x$gcc_cv_as_mips1_ssnop = xno; then + as_fn_error $? "New binutils is required to support ssnop even for MIPS I: 2.21+" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for -mnan= support" >&5 $as_echo_n "checking assembler for -mnan= support... " >&6; } if ${gcc_cv_as_mips_nan+:} false; then : diff --git a/gcc/configure.ac b/gcc/configure.ac index 075424669c9..6d2cb4c51a0 100644 --- a/gcc/configure.ac +++ b/gcc/configure.ac @@ -5270,6 +5270,13 @@ EOF pointers into PC-relative form.]) fi + gcc_GAS_CHECK_FEATURE([mips1 recognize ssnop], gcc_cv_as_mips1_ssnop, + [-mabi=32 -mips1], [ssnop],,,) + if test x$gcc_cv_as_mips1_ssnop = xno; then + AC_MSG_ERROR( + [New binutils is required to support ssnop even for MIPS I: 2.21+]) + fi + gcc_GAS_CHECK_FEATURE([-mnan= support], gcc_cv_as_mips_nan, [-mnan=2008],,, diff --git a/gcc/doc/install.texi b/gcc/doc/install.texi index fa91ce1953d..fae6ec5f7a9 100644 --- a/gcc/doc/install.texi +++ b/gcc/doc/install.texi @@ -4610,6 +4610,8 @@ the use of break, use the @option{--with-divide=breaks} @command{configure} option when configuring GCC@. The default is to use traps on systems that support them. +GNU Binutils 2.21 or newer is required. + @html
@end html diff --git a/libgcc/config/mips/lib1funcs.S b/libgcc/config/mips/lib1funcs.S new file mode 100644 index 00000000000..12314953a7f --- /dev/null +++ b/libgcc/config/mips/lib1funcs.S @@ -0,0 +1,62 @@ +/* Copyright (C) 2023 Free Software Foundation, Inc. + +This file 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. + +This file 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 +. */ + +//#include "mips16.S" + +#ifdef L_speculation_barrier + +/* MIPS16e1 has no sync/jr.hb instructions, and MIPS16e2 lacks of jr.hb. + So, we use normal MIPS code here, just like what we do for __sync_* */ + .set nomips16 + + .set noreorder + .globl __speculation_barrier + .ent __speculation_barrier + +__speculation_barrier: + .set push +#if __mips >= 2 || defined(__linux) + /* MIPS1 has no sync. while Linux can trap&emu sync */ + /* FIXME: Will somebody use linux/gcc for MIPS1/baremetal? */ + sync /* complementation barrier for memory */ +#endif + + +#if __mips_isa_rev >= 1 + /* Binutils claims that JR in R1 can do same as jr.hb. + R6 changes the encoding of jr.hb */ + jr.hb $ra /* Jump with instruction hazard barrier */ +#else + /* ssnop is actually available since R5500, + and it will be decoded as nop on earlier processors. + gas can recognize it even with -march=mips1 since 2.21 */ + /* MIPS1 to MIPSr1: R10000 have 7 stage pipeline, + so 8 ssnop is sufficient to block all speculation on all CPUs */ + .rept 8 + ssnop + .endr + .word 0x03e00408 /* The encoding of jr.hb $ra */ +#endif + .set pop + .end __speculation_barrier + + .set reorder +#endif diff --git a/libgcc/config/mips/libgcc-mips.ver b/libgcc/config/mips/libgcc-mips.ver new file mode 100644 index 00000000000..68f8d2bbd51 --- /dev/null +++ b/libgcc/config/mips/libgcc-mips.ver @@ -0,0 +1,21 @@ +# Copyright (C) 2023 Free Software Foundation, Inc. +# +# 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. +# +# You should have received a copy of the GNU General Public License +# along with GCC; see the file COPYING3. If not see +# . + +GCC_14.0 { + __speculation_barrier +} diff --git a/libgcc/config/mips/t-mips b/libgcc/config/mips/t-mips index 4fb8e136217..d05ef7cbf74 100644 --- a/libgcc/config/mips/t-mips +++ b/libgcc/config/mips/t-mips @@ -7,3 +7,10 @@ softfp_truncations := softfp_exclude_libgcc2 := n LIB2ADD_ST += $(srcdir)/config/mips/lib2funcs.c + + +LIB1ASMSRC = mips/lib1funcs.S +LIB1ASMFUNCS = _speculation_barrier + +# Version these symbols if building libgcc.so. +SHLIB_MAPFILES += $(srcdir)/config/mips/libgcc-mips.ver diff --git a/libgcc/config/mips/t-mips16 b/libgcc/config/mips/t-mips16 index 2bad5119d51..5fd9d60d7a3 100644 --- a/libgcc/config/mips/t-mips16 +++ b/libgcc/config/mips/t-mips16 @@ -16,8 +16,7 @@ # along with GCC; see the file COPYING3. If not see # . -LIB1ASMSRC = mips/mips16.S -LIB1ASMFUNCS = _m16addsf3 _m16subsf3 _m16mulsf3 _m16divsf3 \ +LIB1ASMFUNCS += _m16addsf3 _m16subsf3 _m16mulsf3 _m16divsf3 \ _m16eqsf2 _m16nesf2 _m16gtsf2 _m16gesf2 _m16lesf2 _m16ltsf2 \ _m16unordsf2 \ _m16fltsisf _m16fix_truncsfsi _m16fltunsisf \