From patchwork Fri Jan 5 07:19:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Cederman X-Patchwork-Id: 185250 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:6f82:b0:100:9c79:88ff with SMTP id tb2csp6070133dyb; Thu, 4 Jan 2024 23:21:29 -0800 (PST) X-Google-Smtp-Source: AGHT+IFIgSoDYGzdBzVV/sQp8i57ZDvyj4hwhioz+YrLiyu0s86qu3uviQqQaMRRxVkOGZR2xWjz X-Received: by 2002:ac8:5a06:0:b0:427:a33e:8b97 with SMTP id n6-20020ac85a06000000b00427a33e8b97mr1903864qta.5.1704439288902; Thu, 04 Jan 2024 23:21:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1704439288; cv=pass; d=google.com; s=arc-20160816; b=wH0XRYpxdYCr2y6dnqG5MKYhq7CdFgdHRE2lvy2hEhcROP9ouvuye7+ds8qzygO4lW LlNTDCF+OGzIK5aFyOFBkDD7C9b7Ag3NXO91V/Xzcm8M0lQcJFDoc9P5TmCMYulRep9c /UmFN5G6j5X5ZxaeJOxmMUJ5T4noXwDFOLLTGjqA/NCMp/4s+4dmg2xeOsTb8WA/lOTU NXoai7fWmRBTMXO5eJaHs+28kGlLGHO6hNtnDAd0pY4qVrdv1fpJjtTs6kj1+JeBPDe9 6rzaCbCvOft12yP6hBbMF2vdI8uQSvMRFs3O0M6tjLwnHhvoiR94fGMJWdx30LA9I6bb UhCw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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:arc-filter:dmarc-filter:delivered-to; bh=jgwrPigoAIeSBUSfTetOehvtcToSes2fA3TVbeunOtA=; fh=rIObTAxIziLroRYYyAaA4FmRqLBS8lo6qLKQtV3fxpU=; b=mmrExszUaoYcg7ccES0yPIlPbV0jP6IcvdAwf5+WYW1nxDJMyYqOB4ylZZGBx0RKxy I6zpVhxwjkyqLy5UtIYMXKuIOGJT6IbWX9aVHDHQA5xBvu/XwNirLyR2q+ZxDCG0FUwO pmmlqw8Uo7E07WXANyOX4Da6Yt5bMIsiZYNM/Gb9hlMS3syE7DaF03HPQNTrUefqWK7w j9gB3G7UALHw5M+KI9gvQqDImfMqXQXtG2er1iqSC1wFNZ0RelvIYHXr4+67X169wEdY AGXz6QvLtjAB8UqXepUmQC+rWb1xqQNJxPehxOlbNs821fEJYGBNFeXHtBj912f2P3lL 2ZxQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gaisler.com header.s=unoeuro header.b=EF5KImeo; arc=pass (i=1); 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"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=gaisler.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id i18-20020ac85e52000000b00427e96d51a7si1276749qtx.197.2024.01.04.23.21.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Jan 2024 23:21:28 -0800 (PST) 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=@gaisler.com header.s=unoeuro header.b=EF5KImeo; arc=pass (i=1); 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"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=gaisler.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 9B37B385E00A for ; Fri, 5 Jan 2024 07:21:28 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out3.simply.com (smtp-out3.simply.com [94.231.106.210]) by sourceware.org (Postfix) with ESMTPS id AE1213857BA3 for ; Fri, 5 Jan 2024 07:19:38 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org AE1213857BA3 Authentication-Results: sourceware.org; dmarc=pass (p=reject dis=none) header.from=gaisler.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gaisler.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org AE1213857BA3 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=94.231.106.210 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704439180; cv=none; b=XE2swyVWcKx0Yrd0vnqNuSfZzCiSBVi1+bsvTmrc+csGnCd7r0h/3m7uWU+30MakbP5KH5duSYMu8MFvz9UebRTanJvRsqMt/3ooicSoP1/CR3dA9vRcdlY4UKW4oEFuNN8MM+1wcIFMhK5W7zF+AinjDBB5yCApq6f8sxAAQqM= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704439180; c=relaxed/simple; bh=00sUL889NIdU7eBvRFaB2+zFMW+2E1K+AJVdx8RBiXg=; h=DKIM-Signature:From:To:Subject:Date:Message-Id:MIME-Version; b=E+LBQQvq331A6qt3ukIHm0y8rF+lbWN91Tpis37JLBf4QAmvRYPi4lpzjwF8zQb8MzKcCFM5y7ZPtd9+wNKSRynCeDJqRugY4SUqT9qMqgtiaCOrAV4LYmKrs+7TgjBFHyabHbNU/TPn2Jec7P5vhBouAHyTYuOyruVvSxKWS4A= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from localhost (localhost [127.0.0.1]) by smtp.simply.com (Simply.com) with ESMTP id 4T5vwT4bDRz67wy; Fri, 5 Jan 2024 08:19:37 +0100 (CET) Received: from cederman.got.gaisler.com (h-98-128-223-123.NA.cust.bahnhof.se [98.128.223.123]) by smtp.simply.com (Simply.com) with ESMTPA id 4T5vwT3H7sz67wG; Fri, 5 Jan 2024 08:19:37 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gaisler.com; s=unoeuro; t=1704439177; bh=jgwrPigoAIeSBUSfTetOehvtcToSes2fA3TVbeunOtA=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=EF5KImeofuEuJXHFWW3RmUNICHNC09ndL2y5J+wQU5kz59CR9PIFwCBgg35MnipDB wxa36REj1JMLHDtIvoZHBJTphtEoMX0r/b4iKV/zzaoZptj2KoDj+EBUHqzu5bSl5f ablj+9WAjg4tETQ1VXUKuB08PRFqbAELY6GmIsp4= From: Daniel Cederman To: gcc-patches@gcc.gnu.org Cc: ebotcazou@libertysurf.fr, daniel@gaisler.com Subject: [PATCH 2/2] sparc: Add errata workaround to membar patterns Date: Fri, 5 Jan 2024 08:19:13 +0100 Message-Id: <20240105071913.593978-4-cederman@gaisler.com> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20240105071913.593978-1-cederman@gaisler.com> References: <20240105071913.593978-1-cederman@gaisler.com> MIME-Version: 1.0 X-Spam-Status: No, score=-16.2 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_LOW, 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.30 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1787234131767628402 X-GMAIL-MSGID: 1787234131767628402 LEON now uses the standard V8 membar patterns that contains an ldstub instruction. This instruction needs to be aligned properly when the GR712RC errata workaround is enabled. gcc/ChangeLog: * config/sparc/sparc.cc (atomic_insn_for_leon3_p): Treat membar_storeload as atomic * config/sparc/sync.md: Add GR712RC errata workaround --- gcc/config/sparc/sparc.cc | 1 + gcc/config/sparc/sync.md | 23 ++++++++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/gcc/config/sparc/sparc.cc b/gcc/config/sparc/sparc.cc index ebf1a557a49d..62c57cc53159 100644 --- a/gcc/config/sparc/sparc.cc +++ b/gcc/config/sparc/sparc.cc @@ -1052,6 +1052,7 @@ atomic_insn_for_leon3_p (rtx_insn *insn) { switch (INSN_CODE (insn)) { + case CODE_FOR_membar_storeload: case CODE_FOR_swapsi: case CODE_FOR_ldstub: case CODE_FOR_atomic_compare_and_swap_leon3_1: diff --git a/gcc/config/sparc/sync.md b/gcc/config/sparc/sync.md index ac291420b8b9..fa249908a55f 100644 --- a/gcc/config/sparc/sync.md +++ b/gcc/config/sparc/sync.md @@ -65,12 +65,19 @@ [(set_attr "type" "multi")]) ;; For V8, LDSTUB has the effect of membar #StoreLoad. -(define_insn "*membar_storeload" +(define_insn "membar_storeload" [(set (match_operand:BLK 0 "" "") (unspec:BLK [(match_dup 0) (const_int 2)] UNSPEC_MEMBAR))] "TARGET_V8" - "ldstub\t[%%sp-1], %%g0" - [(set_attr "type" "multi")]) +{ + if (sparc_fix_gr712rc) + return ".align\t16\n\tldstub\t[%%sp-1], %%g0"; + else + return "ldstub\t[%%sp-1], %%g0"; +} + [(set_attr "type" "multi") + (set (attr "length") (if_then_else (eq_attr "fix_gr712rc" "true") + (const_int 4) (const_int 1)))]) ;; Put the two together, in combination with the fact that V8 implements PSO ;; as its weakest memory model, means a full barrier. Match all remaining @@ -80,9 +87,15 @@ (unspec:BLK [(match_dup 0) (match_operand:SI 1 "const_int_operand")] UNSPEC_MEMBAR))] "TARGET_V8" - "stbar\n\tldstub\t[%%sp-1], %%g0" +{ + if (sparc_fix_gr712rc) + return "stbar\n.align\t16\n\tldstub\t[%%sp-1], %%g0"; + else + return "stbar\n\tldstub\t[%%sp-1], %%g0"; +} [(set_attr "type" "multi") - (set_attr "length" "2")]) + (set (attr "length") (if_then_else (eq_attr "fix_gr712rc" "true") + (const_int 5) (const_int 2)))]) ;; For V9, we have the full membar instruction. (define_insn "*membar"