From patchwork Thu Oct 27 12:49:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xiongchuan Tan X-Patchwork-Id: 11776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp210817wru; Thu, 27 Oct 2022 05:50:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6CZo36v4RQTTucNelNdIg5G2C9LiT24Dmy+gozuBJ2a6p0W7iiaCuLaw9bHKubGT1xnZ8H X-Received: by 2002:a17:907:7250:b0:791:9093:47f7 with SMTP id ds16-20020a170907725000b00791909347f7mr42325959ejc.278.1666875023075; Thu, 27 Oct 2022 05:50:23 -0700 (PDT) Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d12-20020a05640208cc00b00461992160edsi958468edz.384.2022.10.27.05.50.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Oct 2022 05:50:23 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="PN/ucXYn"; arc=fail (signature failed); spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DA8F93854167 for ; Thu, 27 Oct 2022 12:50:21 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org DA8F93854167 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1666875021; bh=7fs5jMH6b0tOgl3+9z6okEgJidg5q6CU+/Oe1Dd69cw=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=PN/ucXYnEHU16rZr+ZBIm9HD2HrfkFPJP25k5FrM1tHD/IstVJXP3h7torO3OkwzR PIPB9nvGXl5MBWFQYZFFIBYPJN/ulYbBIHciqWYkPTxjz/fYsq/UNmGw12J0/gxT9x t43rXFLwwSA+bukUcAoXJkGiNuFZoeFtYhQCor0k= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from JPN01-TYC-obe.outbound.protection.outlook.com (mail-tycjpn01olkn2026.outbound.protection.outlook.com [40.92.99.26]) by sourceware.org (Postfix) with ESMTPS id 0B00D3851506 for ; Thu, 27 Oct 2022 12:49:32 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 0B00D3851506 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=caUHRGFzhEitvL7t5SH2J30Hup+1E0gJjDIkbU+U9RtOO7QyB4DxrlgqU3kU8Jqn8bgPjrPqtaTvZ2QaJJl8JH/ZdgWqnQp9endOg+uT77SfOrIpKx1RsZMfToSltqgWUocL67bBFL66D2mcNWyzzBp/HxmV8+2tTPkmGsHK69UoLqNBT6xvrwIeO0Mjt5dqhsDbO91iHhmIicWnVm6thBDTd/1HBJ7GOpuv5KMBWAvIyHfq5tNoAf2fF6ABma7UbD8tex+L1Ejx9VF2yfVx+Ne/BsOycKVjSOj1yS90al7Nf/GVfG0sQ67Nz0F1nScNsuK/6UGPS7nGyhhZuIO/bQ== 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=7fs5jMH6b0tOgl3+9z6okEgJidg5q6CU+/Oe1Dd69cw=; b=mBhzMAR0deBu5Uo1057hF1g/w64mcbks4w3pPAd53ale1qjkoi20sUBiH/eB81Iz1QPT28fYD5cFTl0HiXOBnwdFSxTxHYHgYaT6Gh+FqE+elfpBOO7qHNvcOYaOkQ66pTFoe6pk6H2obriOojfvZpDKJnJCyPKUWs2nBIh6DEEKFQGjMe1etiqOhAsyYxQFgJSbzuVxfNo8jPHF0ySMApG1kctZ0FBxtxn9lrpg32V3IgTFbWAblesw1/3hWv8/ghJc3ZkLs0XSlpB2PDbADGlA5/BgEPtrwaSBSWT+7SJdSpeV7Ahsasg21wJVE4ibo7lubf7E0gR3s4RL0Nqrqw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none Received: from OSYP286MB0261.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:8c::8) by OS3P286MB2373.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:156::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5746.28; Thu, 27 Oct 2022 12:49:27 +0000 Received: from OSYP286MB0261.JPNP286.PROD.OUTLOOK.COM ([fe80::8ed2:bcf9:f9d6:7976]) by OSYP286MB0261.JPNP286.PROD.OUTLOOK.COM ([fe80::8ed2:bcf9:f9d6:7976%7]) with mapi id 15.20.5746.028; Thu, 27 Oct 2022 12:49:27 +0000 To: gcc-patches@gcc.gnu.org Subject: [PATCH v2] RISC-V: Libitm add RISC-V support. Date: Thu, 27 Oct 2022 20:49:42 +0800 Message-ID: X-TMN: [vf9+0Lm9FPVVjvD5AaenEnDi6Ua9ZneknRNwFa6b3oSwxQvr+e6wlO5NFudlvOIr] X-ClientProxiedBy: TYAPR03CA0003.apcprd03.prod.outlook.com (2603:1096:404:14::15) To OSYP286MB0261.JPNP286.PROD.OUTLOOK.COM (2603:1096:604:8c::8) X-Microsoft-Original-Message-ID: <5093263.GXAFRqVoOG@koishi> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: OSYP286MB0261:EE_|OS3P286MB2373:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f052ec2-d025-4098-db91-08dab819aec4 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: TSD7Xfv1BudK3/u2graW4ljh2DRVAaHAgk0sv1qbp3t9m+rjy65s8OdmjpGUsTblcA/icKDv024AmbrEFQqN60n0ObmzpRDFpudtYK1cyAElD6OXZBiA4p3I10E2hEsiac5tEuySwrsIaoTyioYyMXFY9g+tINNAzug78mDgTTsAyDux8qfjAkaNfDJttEA0TOGoZuwsasUAWuvAhLUGNTM52rKWkHqGwkA2lJRWdWMsAAO/S57JIvU3Un5iEUymuQae8FNe5oAmA6HCZL5nzOitoXFV6aTD6owwxB/CCVGUuuyhvWrPVyQ0Q+vt9qOYNHmu5y1QnsCUVrXHCdsO1MzwWUygkd1g7WVnXQZrKAEfzCSifyCllLyoI4vAwvi+k8mASCI7nm2xa2Hj32fBjPAeSaTQKQ+AjGkCEajOHdHHdiNlYaPSt5/r9UBOs09X+RU+Q3rvJ+JgZ3lV2XF4xQPfMBP8Zuv9larLUdGVw1mhpihypzRSpOrOvWrnSuHbpImy8CY1SE7q83i9kXrhOqf0M9r3TUry7eWySGOTsK+tEkJK3yYQ8T7QHCrT4Cf3JNf/mxRcdpF6JyXvKvgTcOxKo/00CkGUWZCOgFujLQ3CY6zw0lZwCyngvXAlbJ/D+J7QzJVyK+/3wo9Z8oou3Yy3Nc9CYCc09UEKdZUMztA= X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 2tlg8YKO/nkPdni6ehRtlzRSFXtHKwn8bgxaPFQMGE/ejRCRiN4vYyL73XpbDv3CAOK1A2ATEzIBhYWUn7PfUTVWXF9NqB2dhksdeNsK9wX63eJWGxLmmZ01HeNQW1xUOvEYBRn7e/6tU5UXcbw6qEgeTaFwpGtw0+Xjn1P5x0lPozjzQdT9ne3pSSz89AYYZGu4/eT/IyVPcjGQWVGaLypiKj8cQy/SF6NRrrXIE+B6SKbvgIczpP0Tqwe3iUNGb6WUdMfUPn/8410ukeQcPDsWGeoB38t6nSGy+Iri6zvXd7iKg3YZtnRU2UbqC4YGGBq5iwi7zYlmEY4cxGnvlHJCzsudbFykOYiVHnlae7+N1hM8hr4UTMYq3mz792RPrwPzFGjHyVjdwHA79Ut/FUpy7X0jUWG/f4kkhcGL+tqAu0gI4fpZZ4NiK2vFRLzwlyMEkWRKPxMUfaS6NII42Dj//4Rv02BKRV+QsrMKkk8woAwzGtMQ+PZem2CS6nbxRIQB7I0Re8Ua0PoooNvqFGNQlnTZj49oZOfGZz4c7B7P7VaT1IVOTQtYyu8K6P35J5lxWobwcYjFqgefWVnYfMqNNIXwyPUvIKZSKDJXKvhpqM4f7zyc69m6fR7t8u7Jr249lYtLGeSOLYgkAsI5Kyv9ad+nEwIxNX9unplcxBic2UDAiGjKteZF2QFFRrCf3A3pJ9wquBHgvJgYlCsObilD2xc+lBFLR/zV8U5J49gp/cg7pjcxfgOiUj7StUa8wRZ+H2O+QNHdgZOooP2C6C7/Q+eWgl++uT6sH/WMlRlOatvkRKfTE68aptI1c3sIb+UamIsrHedlHu3ymFgWPnEvQXSwvDviyspjxwhbzE4VtLTs9kffi18R3XGV97WbOvgpMxxNbF3S8wgVBVN2xiF6AeQPlaEZgmw+FfDVM/NAq1V11wD+Dy6Yh61q70HNjRC508pkHykixcBrp2ZjeXk1Ahqnhh4KuJHj9Xo73BtVDGXQxsZr2zvD7y1pzGUlE9f9yc3wA/q96DHzKls8vIfqcvAlrAKMZkLnJw58MLOKg0mEyfXAylVypSqMwFiVrDqho1d/VHKLrMTK5x+dAIp7mPvaz/CW7yXcUh/OEGCs9IPReIJEMq8wNmU4gTf9NuoiZnPeTjcS2IcgwbvOkmELKvFkFtjXuXy2TN/B6xKIx2qast1C6qsS1CNix9d9RobKhx/OGRAJgQrHAp45lsTNQ07Rv3ihPSihMYQqqIyyVc3r1dn5j7wfHe2o2k4aaAtvEa14oBX7UmdwHdc5vW0ay7OB/1ERHULcfYvCV/J92xn0RUQlAN3JqfW50nt35mZ3YRjHmdJsTYvJIejQOw== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f052ec2-d025-4098-db91-08dab819aec4 X-MS-Exchange-CrossTenant-AuthSource: OSYP286MB0261.JPNP286.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 27 Oct 2022 12:49:27.4676 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: OS3P286MB2373 X-Spam-Status: No, score=-12.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_PASS, SPF_PASS, TXREP 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: , X-Patchwork-Original-From: Xiongchuan Tan via Gcc-patches From: Xiongchuan Tan Reply-To: Xiongchuan Tan Cc: fantasquex@gmail.com, andrew@sifive.com 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?1747845144427781325?= X-GMAIL-MSGID: =?utf-8?q?1747845144427781325?= libitm/ChangeLog: * configure.tgt: Add riscv support. * config/riscv/asm.h: New file. * config/riscv/sjlj.S: New file. * config/riscv/target.h: New file. Reviewed-by: Palmer Dabbelt Acked-by: Palmer Dabbelt --- v2: Change HW_CACHELINE_SIZE to 64 (in accordance with the RVA profiles, see https://github.com/riscv/riscv-profiles/blob/main/profiles.adoc) libitm/config/riscv/asm.h | 52 +++++++++++++ libitm/config/riscv/sjlj.S | 144 +++++++++++++++++++++++++++++++++++ libitm/config/riscv/target.h | 50 ++++++++++++ libitm/configure.tgt | 2 + 4 files changed, 248 insertions(+) create mode 100644 libitm/config/riscv/asm.h create mode 100644 libitm/config/riscv/sjlj.S create mode 100644 libitm/config/riscv/target.h diff --git a/libitm/config/riscv/asm.h b/libitm/config/riscv/asm.h new file mode 100644 index 0000000..6ba5e2c --- /dev/null +++ b/libitm/config/riscv/asm.h @@ -0,0 +1,52 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + Contributed by Xiongchuan Tan . + + This file is part of the GNU Transactional Memory Library (libitm). + + Libitm 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 of the License, or + (at your option) any later version. + + Libitm 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 + . */ + +#ifndef _RV_ASM_H +#define _RV_ASM_H + +#if __riscv_xlen == 64 +# define GPR_L ld +# define GPR_S sd +# define SZ_GPR 8 +#elif __riscv_xlen == 32 +# define GPR_L lw +# define GPR_S sw +# define SZ_GPR 4 +#else +# error Unsupported XLEN (must be 64-bit or 32-bit). +#endif + +#if defined(__riscv_flen) && __riscv_flen == 64 +# define FPR_L fld +# define FPR_S fsd +# define SZ_FPR 8 +#elif defined(__riscv_flen) && __riscv_flen == 32 +# define FPR_L flw +# define FPR_S fsw +# define SZ_FPR 4 +#else +# define SZ_FPR 0 +#endif + +#endif /* _RV_ASM_H */ diff --git a/libitm/config/riscv/sjlj.S b/libitm/config/riscv/sjlj.S new file mode 100644 index 0000000..6f25cb5 --- /dev/null +++ b/libitm/config/riscv/sjlj.S @@ -0,0 +1,144 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + Contributed by Xiongchuan Tan . + + This file is part of the GNU Transactional Memory Library (libitm). + + Libitm 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 of the License, or + (at your option) any later version. + + Libitm 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 "asmcfi.h" +#include "asm.h" + + .text + .align 2 + .global _ITM_beginTransaction + .type _ITM_beginTransaction, @function + +_ITM_beginTransaction: + cfi_startproc + mv a1, sp + addi sp, sp, -(14*SZ_GPR+12*SZ_FPR) + cfi_adjust_cfa_offset(14*SZ_GPR+12*SZ_FPR) + + /* Return Address */ + GPR_S ra, 0*SZ_GPR(sp) + cfi_rel_offset(ra, 0*SZ_GPR) + + /* Caller's sp */ + GPR_S a1, 1*SZ_GPR(sp) + + /* Caller's s0/fp */ + GPR_S fp, 2*SZ_GPR(sp) + cfi_rel_offset(fp, 2*SZ_GPR) + + /* Callee-saved registers */ + GPR_S s1, 3*SZ_GPR(sp) + GPR_S s2, 4*SZ_GPR(sp) + GPR_S s3, 5*SZ_GPR(sp) + GPR_S s4, 6*SZ_GPR(sp) + GPR_S s5, 7*SZ_GPR(sp) + GPR_S s6, 8*SZ_GPR(sp) + GPR_S s7, 9*SZ_GPR(sp) + GPR_S s8, 10*SZ_GPR(sp) + GPR_S s9, 11*SZ_GPR(sp) + GPR_S s10, 12*SZ_GPR(sp) + GPR_S s11, 13*SZ_GPR(sp) + +#if defined(__riscv_flen) + /* Callee-saved floating-point registers */ + FPR_S fs0, 0*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs1, 1*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs2, 2*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs3, 3*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs4, 4*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs5, 5*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs6, 6*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs7, 7*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs8, 8*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs9, 9*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs10, 10*SZ_FPR+14*SZ_GPR(sp) + FPR_S fs11, 11*SZ_FPR+14*SZ_GPR(sp) +#endif + mv fp, sp + + /* Invoke GTM_begin_transaction with the struct we've just built. */ + mv a1, sp + jal ra, GTM_begin_transaction + + /* Return; we don't need to restore any of the call-saved regs. */ + GPR_L ra, 0*SZ_GPR(sp) + cfi_restore(ra) + GPR_L fp, 2*SZ_GPR(sp) + cfi_restore(fp) + + addi sp, sp, 14*SZ_GPR+12*SZ_FPR + cfi_adjust_cfa_offset(-(14*SZ_GPR+12*SZ_FPR)) + + ret + cfi_endproc + .size _ITM_beginTransaction, . - _ITM_beginTransaction + + .align 2 + .global GTM_longjmp + .hidden GTM_longjmp + .type GTM_longjmp, @function + +GTM_longjmp: + /* The first parameter becomes the return value (a0). + The third parameter is ignored for now. */ + cfi_startproc + GPR_L s1, 3*SZ_GPR(a1) + GPR_L s2, 4*SZ_GPR(a1) + GPR_L s3, 5*SZ_GPR(a1) + GPR_L s4, 6*SZ_GPR(a1) + GPR_L s5, 7*SZ_GPR(a1) + GPR_L s6, 8*SZ_GPR(a1) + GPR_L s7, 9*SZ_GPR(a1) + GPR_L s8, 10*SZ_GPR(a1) + GPR_L s9, 11*SZ_GPR(a1) + GPR_L s10, 12*SZ_GPR(a1) + GPR_L s11, 13*SZ_GPR(a1) + +#if defined(__riscv_flen) + FPR_L fs0, 0*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs1, 1*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs2, 2*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs3, 3*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs4, 4*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs5, 5*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs6, 6*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs7, 7*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs8, 8*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs9, 9*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs10, 10*SZ_FPR+14*SZ_GPR(a1) + FPR_L fs11, 11*SZ_FPR+14*SZ_GPR(a1) +#endif + + GPR_L ra, 0*SZ_GPR(a1) + GPR_L fp, 2*SZ_GPR(a1) + GPR_L a3, 1*SZ_GPR(a1) + cfi_def_cfa(a1, 0) + mv sp, a3 + jr ra + cfi_endproc + .size GTM_longjmp, . - GTM_longjmp + +#ifdef __linux__ +.section .note.GNU-stack, "", @progbits +#endif diff --git a/libitm/config/riscv/target.h b/libitm/config/riscv/target.h new file mode 100644 index 0000000..16ee3f1 --- /dev/null +++ b/libitm/config/riscv/target.h @@ -0,0 +1,50 @@ +/* Copyright (C) 2022 Free Software Foundation, Inc. + Contributed by Xiongchuan Tan . + + This file is part of the GNU Transactional Memory Library (libitm). + + Libitm 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 of the License, or + (at your option) any later version. + + Libitm 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 + . */ + +namespace GTM HIDDEN { + +typedef struct gtm_jmpbuf + { + long int pc; + void *cfa; + long int s[12]; /* Saved registers, s0 is fp */ + + /* FP saved registers */ +#if defined(__riscv_flen) && __riscv_flen == 64 + double fs[12]; +#elif defined(__riscv_flen) && __riscv_flen == 32 + float fs[12]; +#endif + } gtm_jmpbuf; + +/* ??? The size of one line in hardware caches (in bytes). */ +#define HW_CACHELINE_SIZE 64 + +static inline void +cpu_relax (void) +{ + __asm__ volatile ("" : : : "memory"); +} + +} // namespace GTM diff --git a/libitm/configure.tgt b/libitm/configure.tgt index 4c0e78c..635c1d4 100644 --- a/libitm/configure.tgt +++ b/libitm/configure.tgt @@ -82,6 +82,8 @@ EOF loongarch*) ARCH=loongarch ;; + riscv*) ARCH=riscv ;; + sh*) ARCH=sh ;; sparc)