From patchwork Fri Apr 28 12:33:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: YunQiang Su X-Patchwork-Id: 88632 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp895955vqo; Fri, 28 Apr 2023 05:34:41 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7Xn/sgINoSGh73EM3MqNMuDK1FIP47UlU+z3WaXBKbquTfG5XDyLZAVhmtYYA9kmwniDQR X-Received: by 2002:aa7:d41a:0:b0:504:894b:1bb7 with SMTP id z26-20020aa7d41a000000b00504894b1bb7mr4163850edq.5.1682685281021; Fri, 28 Apr 2023 05:34:41 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1682685281; cv=pass; d=google.com; s=arc-20160816; b=gDe7YjMiarHq3LAdJkQn4hHuvhHAV7aUZFS90c5ixdN9x9t2ywEy/NFbIRkzLW8Gk0 UALK+x1PzhIeXeRq8s9TiCSbHYyPIvGHdH64qI104Cqqe+juQEsNgSZvEDCZD9k8fiYI FFs/BMTJ0UgEmILXAqkVLNjVusQ3H42aFAgC03Tz34g7A15aaSy8eHaJj9F3prWru6/h P9Awov8x0YlEGhDKJ4QldwMnujcMOJm9U9ihkGFFYIfCRMr3fbI/GY/rSk+OMnvCFzia ULtzbw91tGTe/yeShnSXgENiocpbZo0pdq/UR4l7ATXASjyAX3Y2Q3jeF+KZyN6uPeIH 7T/g== 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:message-id:date:subject:cc:to:from :dkim-signature:dmarc-filter:delivered-to; bh=H41KARspbWelaw2xNe2xk15jF7PL9WlVlFRrvMFTufk=; b=AlM5RFnRZRpKX4ixvKhmbLEVa2Z1aTwM8efZLL/2lWQ7Ewf10CDinEerdZOrAhH4VU P1jvi6Rek5/vl6POJMEB2PVAxsnNOHzLikQfLQqdvlK5WYIbdrZDL4j5ZZgUgu8KuhHM nkswawVIAI+8IB5qoU7U2++ZcZNcKTdgmVYoD+kP0HLQU94lEoz8my1DRoKU0Y3VBVie sB5dZm9a/VAVcmcV7cVvPHJ4uMRb/Q52Pn5CUQFx73ynEzSDQjnZsvGSU/2byVyEs5P/ NSNPWPqC4TfI4ABGYj7V1AczOQz8WKtwqPlS528pTgUSsbYD9SZo2w1ij1kxK/6H05DX U/gw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@cipunited.onmicrosoft.com header.s=selector1-cipunited-onmicrosoft-com header.b=xbqaV77u; 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 r17-20020aa7cb91000000b00509d229747fsi10692064edt.88.2023.04.28.05.34.40 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 28 Apr 2023 05:34:40 -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=xbqaV77u; 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 A246A385B538 for ; Fri, 28 Apr 2023 12:34:17 +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-sgaapc01on2092.outbound.protection.outlook.com [40.107.215.92]) by sourceware.org (Postfix) with ESMTPS id CC56B3858C50 for ; Fri, 28 Apr 2023 12:33:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CC56B3858C50 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=VBXut2run8OogGijOjeHE5GY7ZwKqouF19jtklYgjyqEa/cOnE+JyGZJfl6Vz6siQvbCJX4HeNLQEdpKcm8KYtXVuMRa2KEYnR1fH37M9VVE+Ob/4qRlnblSNglCiM7p9qX4TqXn6XXhVRnwBTORwkQkP94Du2w4NtRoaJJRHYfy1XW1IVBOh2nTxKV3KqPDA4ZpHyMz2+XlO1umKIpGkpG7pGO6FYpOaXbhFTO3NRg2dgbLDyFf4p+RuoE12gZptRBgOi4qA5tAatYzKkP2V1TqT5XM/+We2xZZZ6BqRIsYV25e9DH/S1tZjCdiPsXhwLdbI8pg2CCTXMhDFn7dzQ== 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=H41KARspbWelaw2xNe2xk15jF7PL9WlVlFRrvMFTufk=; b=boBqj/Iu02y4M64rsZR11QhtTRyevHDrLLCgIg+JcpzZIgzA0KD3j2bGZ8rKR4a8+pjBRoS4U2Bhz19GYor5EFP5RGMdBM5rAc2lKbxpOomk6c3cC3OWt17ZqCdAI4dDjVUdIWrd4bAh954EpqhIFL0xdNGb+luBz58UWTlCiGfqxGNCEUTFjDuxC3eWh1Y5jddpCdBwCRw9TpBLQayd1YF+tIBJhfXiT45MAD89jf4LiawXjW/AaGZqDFs+VkcqyEI2rHfM59227a6Ff0XI9djV1CUvIONLgeCXw/CsNBiRo125fRndgbErWQkrKP+lDM1+GIK2fZh+CbihmF6eXw== 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=H41KARspbWelaw2xNe2xk15jF7PL9WlVlFRrvMFTufk=; b=xbqaV77uozGzAYOwY2Q642/REeC3lqIKHtetxxXDjBr3KIhAHUUk8HSl2wofGWV0YLGGpsUje91VQiflG4Pbw+Ahv5hVa6FVZii8fS9AkzFGq5YbhPB4yF7lNSpD3jFa05ddIn+Y5vZyiPi649Q3Cbt8necScW1oy1FQsAKe42M= 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 TYZPR04MB5783.apcprd04.prod.outlook.com (2603:1096:400:1fd::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6340.23; Fri, 28 Apr 2023 12:33:44 +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.6340.023; Fri, 28 Apr 2023 12:33:43 +0000 From: YunQiang Su To: gcc-patches@gcc.gnu.org Cc: macro@orcam.me.uk, jiaxun.yang@flygoat.com, syq@debian.org, richard.sandiford@arm.com, YunQiang Su Subject: [PATCH] MIPS: add speculation_barrier support Date: Fri, 28 Apr 2023 20:33:27 +0800 Message-Id: <20230428123327.686353-1-yunqiang.su@cipunited.com> X-Mailer: git-send-email 2.30.2 X-ClientProxiedBy: TY2PR0101CA0011.apcprd01.prod.exchangelabs.com (2603:1096:404:92::23) To TYZPR04MB6117.apcprd04.prod.outlook.com (2603:1096:400:25a::9) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: TYZPR04MB6117:EE_|TYZPR04MB5783:EE_ X-MS-Office365-Filtering-Correlation-Id: 405e0dfa-ee18-4cc7-d125-08db47e4cdce X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dLdaQLY5/3iNoYRqBY6JBQatT7axnWEhEnO10ZaqHNmDyVy4jmggCci/VWEN9GT5MiA5piSH8hP6uH0tMAJAglFpwo97oItzH94By4rTN2Q7JURrtV6GgEAbFmtd3p/kVy03CeE9kZKXC3IGcZ2TFn2nuER2TLMjSxytvfvvEzGnChjoS6vISLbzqwX94M2b36dffwXRpNTmTJVXSokkUp+6IhkWE9gb4KFjT6s5Qz3rUMGik6b36g2jcmczDAdhUBJ6Ui9nasm9CylxWfXrsxCnXMrRgZpVm8JfgRG1UJckHc4gCc7MKKNPVIQM9CyEZ2tJFZqVK67MTolgHn0wvaEDPSAbKoYBlNHEZh4d6IuRWxB+6kCQfQVdHvmY4UVzdSlmg1rlPfUDzjvbufnCGiXm6RTtDJAEWBJ27QJ0dcY+T6ptvjVjfi056adU3p5zQbJ8ZP45eh7tGQF1/wOte7lpRdBj9Rcc9DuGJvIR18cQu9KDqlqNLpmnYgFGR4diilRfuealHI4elP0EdXtRol7zvLj8SqXmI9BYlIMM0qFQscPxkrjptdY2NpyqTHC9r37m3jO+Cp0A/Ut1zYjiZJEpzkU0ULUBWUdvko+Yufxoqn40NrEOmTwM7/xFtoJ/ 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)(376002)(39830400003)(136003)(346002)(366004)(396003)(451199021)(66946007)(66556008)(66476007)(6666004)(2906002)(52116002)(6486002)(26005)(1076003)(6512007)(6506007)(107886003)(41300700001)(186003)(6916009)(4326008)(316002)(36756003)(38100700002)(5660300002)(38350700002)(83380400001)(2616005)(8676002)(8936002)(478600001)(86362001)(2004002); DIR:OUT; SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: XHlTX+E/aBrHBEUCTynS/PYIfWkbVSIo/ayCFvpaOE1h5lxkX1W2EGSEUIdh4U5evSfLdFF+VUInwFxBv2YRra5oun2YvAfEyYI0rWcUXrx0WYX734YWEJ+xts0FnjuzPYY1ljhTE9INzxj9Va5pcBo/6wmwhV+zZJ3atm2qmY84g7pPxPV43TyAHpOgBq8KxiDQVWtw9I+4UiI6jt4qUHJ/kLiMuOSISLoZsPgMB8V+46FpEOlETDWBm5y14VtwrgK+6vut4CTdPtcHb/EMRtd9pJFS5KsPdb7YuD6LIeKlX6SGesX85P+nmFOQth6DbgiUyHMPX2zJ8g5O7Z6IBkyO6cSsM4R8W7NN16Xolnq4ARoY0ovSVNMTodiyxnuQJjh69C/A1tBFskP3Ap8NEzTKZW0qDm5kuJ/5mWQJF8Ow0o+odFoFV7oS//K9x5HS4lRiaxCVOz/cDtYDMkfYhAIrqoQL1tR1VMSvPXu2LC32NgyJQuuoIVKoyt+yG/lBTnFZiylvr+YPnLjmdKNIHeKS87N/2nqd8Ljjj35zOHY22f3f5OjZwAHChhN/8B2t6Y8OKJQPNRxzpk4YT1I7wueB5ZO8l3gBfUai6HuQYv6PflkDEn7O1SCy8JbdcDS4EEsryRw1ZUIwNPIJMCcT46DSg4hBDrmqcjTzx1SMldwWIEQ+A0sIshqkZ7UmUwCe2CF1fEWM2xI3es/qLfZcYfuD1X1EGLicVhrzrDYbafBw9KMhTAlMJkqjUiB7v7+YwyvxWZqh7i843JwgAWo8T1BmzLhq52XN1XK1z1cZfB0Zw54M7JXH/LO9huiV7kyVRjK3S2Zy8qe/CF8tlCIjn9kuKr6QVY+frK7uFrobsa5Wx9kUjQ/4H520NYU6b4JVTgWL3Y++LmfEo1579hI2P6s7SUBOYo4Agy6HxAsP6lnXG1pqJpMn4hJlAXCnmPZAWNETd9vMveVDa86I4mNmfsHY5vk/8dOcFQthuXRulCnosGFYQR90tutEdEv73pDjkh3Lr7Cdr+jJqtkn3dsF7h34ryAOOmodn419fnhzdzSOiblcPNxr6S8f7mBcpeY/70CkDtw2ZsGiTLprt2w7EMUe+a+pPrpKtXFJkDrK5x7N5h46ewVTHj/TdSmC7xnW7fEWr29XuyieR6P69bJqgxoeRHmtKPzLIqD+99yAaFhQjnjHtKk6Ht3plDwhKzNjh03o6id1zcsA7fJT5op8cTG7Kkn2DRZDHBh6DmpDEYrQ0yZffW4XyN1Q3NbQfjLY6+zO6ohy7Y5DR8jTuOS/3vrNnM6mZVb56/5OkbqV4Tvx8kplGy2kDq9mpNCfx2Af01PMSmjCElaldtx4R4ZbI7CK3EAiDeFNicP3OvzsMyypx2QG7WkLXpS7xvZpqggCvqO0LbZI+gUr7skBc94NzUZZFzMol9udQqQkDdk8DihwxwU7Pw24OL2lOR6lOf4LFNCndX6e8CI/qPTdcg5PFazoquSHHlVlKxfRwKzydCTaRjiCzkwScrJ72H/oehmuMD5GdJLcTuIrwsdMcxUkTqUtl2e45IrFJxWpnAcr8sJbQjWB9OkvLa2yRtywSG4QMoRiKZKZbel5w4H6JTpl2Q== X-OriginatorOrg: cipunited.com X-MS-Exchange-CrossTenant-Network-Message-Id: 405e0dfa-ee18-4cc7-d125-08db47e4cdce X-MS-Exchange-CrossTenant-AuthSource: TYZPR04MB6117.apcprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Apr 2023 12:33:43.7213 (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: jvciOqNysFD4LGOjek7kycJxQy8pfyOqbLhxyA8/4bpMbuqtw/gKP1RpddSnjRoGW2HSyNs2LohzpDl0qZ6W5JhrkwVjvDRyHQpaoX0YCMs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: TYZPR04MB5783 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?1764423401062025876?= 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/arm/arm.md (speculation_barrier): Call mips_emit_speculation_barrier. 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 ++++++ libgcc/config/mips/lib1funcs.S | 60 ++++++++++++++++++++++++++++++ libgcc/config/mips/libgcc-mips.ver | 21 +++++++++++ libgcc/config/mips/t-mips | 7 ++++ libgcc/config/mips/t-mips16 | 3 +- 7 files changed, 116 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/libgcc/config/mips/lib1funcs.S b/libgcc/config/mips/lib1funcs.S new file mode 100644 index 00000000000..45d74e2e762 --- /dev/null +++ b/libgcc/config/mips/lib1funcs.S @@ -0,0 +1,60 @@ +/* Copyright (C) 1995-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 +/* MIPS1 has no sync, and in fact it doesn't need it at all. + We wish that all newer CPUs should run software with MIPS2+ */ +#if __mips >= 2 + sync /* complementation barrier for memory */ +#endif +#if __mips_isa_rev >= 2 +/* MIPSr2+: sync+jr.hb is enough */ + jr.hb $ra /* Jump with instruction hazard barrier */ +#else +/* Make ssnop available, ssnop only recognized by GAS since mips32, + however it's actually available since R5500, + and it will be decoded as nop on earlier processors */ + .set mips32 +/* MIPS1 to MIPSr1: R10000 have 7 stage pipeline, + so 8 ssnop is sufficient to block all speculation on all CPUs */ + .rept 8 + ssnop + .endr + jr $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..f0e9fc54965 --- /dev/null +++ b/libgcc/config/mips/libgcc-mips.ver @@ -0,0 +1,21 @@ +# Copyright (C) 2008-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 \