From patchwork Thu Apr 27 16:22:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 88318 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp391433vqo; Thu, 27 Apr 2023 09:31:02 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4MNssVa1CeuVuR4Vmk86oR0a3Qcqd0G1R0AcnQqWbbSannpmE8YZXrglXe5lpov0y5/8N5 X-Received: by 2002:aa7:c996:0:b0:504:9394:188c with SMTP id c22-20020aa7c996000000b005049394188cmr1687679edt.9.1682613062574; Thu, 27 Apr 2023 09:31:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1682613062; cv=none; d=google.com; s=arc-20160816; b=COAnN+6H8BnHhQ9fTutU69LtZSC9B6oufVkoK+v905D64p8XfY/A6F5ccVQvcrTJ75 YLqGdV+S+V2kReVBU/YNywOhTWfA89Xc4aliLUypledc08UdGwBiG/NJdBHICBEsopZV nvijZgAouoGQZZqHkGN/6xp/0vZpR2bFQByi2sOXKrbiSYK/LK+oa6oUDj9kxDWasIjS rW2nbovcNM9ZrTlzZ2ylbWE+2SCQO2ys5BMhrtUMcxuSNG70xtqURrsp/e6GUT+TMuRZ hMOnqgzy9aQEVP3b3/AzjLZoh3SS/bHZsHrgeNpFT8il7HWaNwaVtigc3pU6jXb1thjX KZTA== ARC-Message-Signature: i=1; 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature:dmarc-filter:delivered-to; bh=JszsntAIyeAGykGBRUfRjYENXaFzUL1saHgV7Mp/d2w=; b=p3q2eveWshY6l1ejY/7lzhoL67HCcvpy1Nd37g7AftRZiScssPWnVTjVHhr9cInuVt ckMklDxDKkSq1B2iIysegSvew+OCI7ApnN+QD1MmS4XdheD1rHmOfXNd+2RUrdxxuJVK xJ9Wcenn7OzQkB6UN4tPa7zd1CsmjEN90bHxb60gl/pPCsR//Yv5fQGZDEXpUNUCAdLx 9CWPXZqrZ85732/ZMwvIQM5Bv5Ha/tQY69V/hDIfJuIl81joOeZ3n9zamuBk4Lhuj244 1Tm1Wee+TM5G036pwWq5Lh9JplqJCICEDW+B3Ov4cBlGA8S0Im1OS0WaO1Ig7yGMeXcb fsOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=LNVLSXvu; 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" Received: from sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id k17-20020a056402049100b0050697e93522si14092376edv.54.2023.04.27.09.31.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 09:31:02 -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=@rivosinc-com.20221208.gappssmtp.com header.s=20221208 header.b=LNVLSXvu; 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" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 2BE443948A72 for ; Thu, 27 Apr 2023 16:25:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by sourceware.org (Postfix) with ESMTPS id 49C543856090 for ; Thu, 27 Apr 2023 16:24:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 49C543856090 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com Received: by mail-pl1-x642.google.com with SMTP id d9443c01a7336-1a68f2345c5so67982865ad.2 for ; Thu, 27 Apr 2023 09:24:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20221208.gappssmtp.com; s=20221208; t=1682612661; x=1685204661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=JszsntAIyeAGykGBRUfRjYENXaFzUL1saHgV7Mp/d2w=; b=LNVLSXvuGR9Wz8a8ccqXYyINn6nihUTHzjksTJZHbfuV9zKL4I9Jfgwv1OPkOTS9im yiuCW5kh/3DysTxo0Kv4fFMoqiAnoYuI3F1fUAyxzJJwbCR2i7JqgAWy01wmf03YapPk RI09WZhpheZn/mFPEavGNbVlttJ1UOIylg3ID2+34RfPJGrWMcg3jXqgsGVwBU9uP6ZM lty/kdVLuxWjkNEYIVOYOqgNz5m5eNpSSsA3Z/0VAi05SkomFxsnDJ8bLKB32ZC8Uur0 bUl+1pHEKF1S7UIwjTc6cQYtbmgY/NVHDYPo4VvWK803BJt7Sfhk0SrvFDrBfu7frV/3 vaiQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1682612661; x=1685204661; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=JszsntAIyeAGykGBRUfRjYENXaFzUL1saHgV7Mp/d2w=; b=JZlqTGK3J7bhVVeqCqm3sn/E2NWtb4wZ0eUOE9EcVllW9xw7L6lKVPRnYuC6yXuny+ e+VKSe3MsUIGXWC21qWjZEBXkdQ6xmOrEnPup8YrVI+yYPH+RfQuh9UiOWc7oi1f5V5f ZRDBSpn1SniaAmfhOCXL6JC5sepN7PaJmeTrS5UTgF/zza9lKddLWSqq3iPf8hFsyzDB 6dAd6xMwQYdmSvsbHXwITGFjHpnptNyfmzy/D8Hgx+ny1xzQVWY5VPYHXWuJNbMTXCsC vENL7dliHbqGMSdCrfzYsmDBiHpslYNO9fVKOFx4nFj/hC6o3MC294tZqLVA3n3CgaNT cgDA== X-Gm-Message-State: AC+VfDwnWGg2+jFjQ9EH9PH/V/ZjeekVut9iESnjCQg/ZGQo/odTLKua MSbskbXqV4pdstq7M+LdObRDU3Z+GLhx7bGP93xPtkk/WMs= X-Received: by 2002:a17:903:2346:b0:1a6:a8e5:9240 with SMTP id c6-20020a170903234600b001a6a8e59240mr2515706plh.4.1682612661233; Thu, 27 Apr 2023 09:24:21 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id n19-20020a170902969300b001a6db2bef16sm11815906plp.303.2023.04.27.09.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Apr 2023 09:24:20 -0700 (PDT) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: palmer@rivosinc.com, gnu-toolchain@rivosinc.com, vineetg@rivosinc.com, andrew@sifive.com, kito.cheng@sifive.com, dlustig@nvidia.com, cmuellner@gcc.gnu.org, andrea@rivosinc.com, hboehm@google.com, jeffreyalaw@gmail.com, Patrick O'Neill Subject: [PATCH v5 09/11] RISC-V: Weaken mem_thread_fence Date: Thu, 27 Apr 2023 09:22:59 -0700 Message-Id: <20230427162301.1151333-10-patrick@rivosinc.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230427162301.1151333-1-patrick@rivosinc.com> References: <20230414170942.1695672-1-patrick@rivosinc.com> <20230427162301.1151333-1-patrick@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=unavailable 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?1764347674376274247?= X-GMAIL-MSGID: =?utf-8?q?1764347674376274247?= This change brings atomic fences in line with table A.6 of the ISA manual. Relax mem_thread_fence according to the memmodel given. 2023-04-27 Patrick O'Neill gcc/ChangeLog: * config/riscv/sync.md (mem_thread_fence_1): Change fence depending on the given memory model. Signed-off-by: Patrick O'Neill --- v3 Changelog: * Consolidate tests in [PATCH v3 10/10] * Remove helper functions --- gcc/config/riscv/sync.md | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gcc/config/riscv/sync.md b/gcc/config/riscv/sync.md index 3e6345e83a3..ba132d8a1ce 100644 --- a/gcc/config/riscv/sync.md +++ b/gcc/config/riscv/sync.md @@ -45,14 +45,24 @@ DONE; }) -;; Until the RISC-V memory model (hence its mapping from C++) is finalized, -;; conservatively emit a full FENCE. (define_insn "mem_thread_fence_1" [(set (match_operand:BLK 0 "" "") (unspec:BLK [(match_dup 0)] UNSPEC_MEMORY_BARRIER)) (match_operand:SI 1 "const_int_operand" "")] ;; model "" - "fence\tiorw,iorw") + { + enum memmodel model = (enum memmodel) INTVAL (operands[1]); + model = memmodel_base (model); + if (model == MEMMODEL_SEQ_CST) + return "fence\trw,rw"; + else if (model == MEMMODEL_ACQ_REL) + return "fence.tso"; + else if (model == MEMMODEL_ACQUIRE) + return "fence\tr,rw"; + else if (model == MEMMODEL_RELEASE) + return "fence\trw,w"; + } + [(set (attr "length") (const_int 4))]) ;; Atomic memory operations.