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: 1882758 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gaisler.com header.i=@gaisler.com header.a=rsa-sha256 header.s=unoeuro header.b=EF5KImeo; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=server2.sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=patchwork.ozlabs.org) Received: from server2.sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4T5vyD6CwLz1yP3 for ; Fri, 5 Jan 2024 18:21:08 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id DC7383857400 for ; Fri, 5 Jan 2024 07:21:06 +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+incoming=patchwork.ozlabs.org@gcc.gnu.org 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"