From patchwork Mon Apr 10 18:23:46 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: 81603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp2078237vqo; Mon, 10 Apr 2023 11:33:09 -0700 (PDT) X-Google-Smtp-Source: AKy350aFJns/66z73qa/GeLEA3Xx9qMsDScMetrHrzhR/yXYG2OYd1Juwq4WFosk8H72Qf874rzT X-Received: by 2002:a17:906:a84:b0:8b1:781d:f9a4 with SMTP id y4-20020a1709060a8400b008b1781df9a4mr9056356ejf.21.1681151589049; Mon, 10 Apr 2023 11:33:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681151589; cv=none; d=google.com; s=arc-20160816; b=ILPZ8BoqBIIIBye0KqTz52saQyNLrZMH1ISxAiBYUb4z4iNmMzGynEYQwMookGUoVR szRxGSmWGx7ZPTzFGSQY9PVej/dxYOguBU3Vkpc14EGrJGmiVMu2+Sbhw0RC0ZswXxpQ BnqmhWjy7z4YHpzbXXXQuTwWywqNyNU8/t6pTZbCNcQz3n+R/ZSw3IMrBsW2NvRUgp/J BNpqbO/c0yKhLWzSC8gom2GNMHmiZ7tIp6NBrev1AGUeU3zokeIJ60shzDGmQWeXodF4 NxepT6CIivAnPyem71Yg5sYGhYdDkJkKmeXd8I+VNhK9gFfkJOYZiEDb2RuDUSzoFXym OjKg== 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=mo+bRZ+pfwq9fZONe7Uv95uVmcTBnjKtM3toy3bHl0g=; b=c23o7+1FjCvX5E5aqm46rnAl6QjrMQto6ckLq+zAYcPaAAbprbpAtZ7n6bs9t827i6 05bohuIjHuVH5uR6xRPCB2wsEhIwbUJNy1D24H2GZ+6nxk5i97W0wL/Hkdq5kT1nYcHf 0UENSah2AAZr+R+92GRMzHOtX6urwPaOQkCY5DzInAoZyvLJWXGfF83fIRYxEUUxmWd8 qZvBMGYYzLmXVS+wqWWZu8L4c6V6xSoHMNjnC57HDW+XOHIEZvSJCB8AzmPH8rETdt+g at2vTx6ZmUbjp18kp+uvOBV8PETYA1n8eFC9DNSO+lz8oaWCLZX6HfFhMgpVAU+HQmir fPjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@rivosinc-com.20210112.gappssmtp.com header.s=20210112 header.b=RX1x74G+; 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 z20-20020a17090665d400b009267d6857ebsi10183547ejn.952.2023.04.10.11.33.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 11:33:09 -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.20210112.gappssmtp.com header.s=20210112 header.b=RX1x74G+; 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 68C33388982C for ; Mon, 10 Apr 2023 18:29:27 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by sourceware.org (Postfix) with ESMTPS id 8A58F3857727 for ; Mon, 10 Apr 2023 18:27:00 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8A58F3857727 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-x644.google.com with SMTP id e13so5068572plc.12 for ; Mon, 10 Apr 2023 11:27:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20210112.gappssmtp.com; s=20210112; t=1681151219; x=1683743219; 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=mo+bRZ+pfwq9fZONe7Uv95uVmcTBnjKtM3toy3bHl0g=; b=RX1x74G+CmaLaqzQJVwB9krnl/NGA2Y32RG6OaFe4Ds/pEliaD3+FNfhKzv3CvnwN9 rE6fR3njS1Ms5Rs7Zc/+6Bi43elRmjuLe/bQ5Z+O4Ag9aInuG0ZepccTXSqwhPxhWy0S I7qKSJexUWIMGh9o0rc4uj0VQPeWySetVt8xZjxODvkxI1ajSgZLaDjxkeYUhb25lxgP pplgAwE9QcvkdrG5obDmI/gMTz1IdF2CwchaIJo+2dp6Gq2RdUEi4v/SxBWQt/DxUl7a 33odgt5deXKe0yxERJz8cTFxSCc+OlEhG+cqU3Lcei/tY4GR+uSvmULLafV+Fdai/4gX Dx6A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681151219; x=1683743219; 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=mo+bRZ+pfwq9fZONe7Uv95uVmcTBnjKtM3toy3bHl0g=; b=cWrlAgKt2KH1gyQwqCd93QBe3Bb83iWojHYb3FpuBL+jorovlUFEQDtWb6RSO0Jz2k tAnWXEBZH8EVonLyubkYV7aOX3igBjyjLw58vVqrlACdupVatSMihkb7RC6tzBPz3xfb 8Scjn2jwiICyOzaIYB1Lc3itY0T6kq79SxHeHUM+s0DDNJ3TLlLzIdH+WApInUQPeZme 9z+/v59iNWQ4KqSmGD5dIoy0iSwp+BgNM2T/FW28qS9GH3kpYQDjnxeq7lK0D92PxtcF 7etWyVPGwbBopwFfHO4HeOX2cmRVHbrFHcQboABybUkn3jx3MKIomFibiw5SlaHFk667 xBRw== X-Gm-Message-State: AAQBX9d6st0bKvDN2lKOG/xwOyYvJf16sq0IVLs/DjUTT9abKRrAlbV/ MaqBh8yM/BPkkkyKUsTJYD6QOM7z8bBD4FPto004OibUW9s= X-Received: by 2002:a05:6a20:b192:b0:d9:77f7:d62e with SMTP id ee18-20020a056a20b19200b000d977f7d62emr11635060pzb.36.1681151219550; Mon, 10 Apr 2023 11:26:59 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.221.140.188]) by smtp.gmail.com with ESMTPSA id d2-20020aa78e42000000b00627f054a3cdsm4478977pfr.31.2023.04.10.11.26.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Apr 2023 11:26:59 -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, jefferyalaw@gmail.com, cmuellner@gcc.gnu.org, andrea@rivosinc.com, hboehm@google.com, Patrick O'Neill Subject: [PATCH v3 08/10] RISCV: Weaken mem_thread_fence Date: Mon, 10 Apr 2023 11:23:46 -0700 Message-Id: <20230410182348.2168356-9-patrick@rivosinc.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230410182348.2168356-1-patrick@rivosinc.com> References: <20230405210118.1969283-1-patrick@rivosinc.com> <20230410182348.2168356-1-patrick@rivosinc.com> MIME-Version: 1.0 X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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: , 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?1762372273929861892?= X-GMAIL-MSGID: =?utf-8?q?1762815208802652566?= 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-10 Patrick O'Neill * 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 a31b8c4f28a..e91fa29da51 100644 --- a/gcc/config/riscv/sync.md +++ b/gcc/config/riscv/sync.md @@ -42,14 +42,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.