From patchwork Thu Jun 13 00:10:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick O'Neill X-Patchwork-Id: 1947154 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=rivosinc-com.20230601.gappssmtp.com header.i=@rivosinc-com.20230601.gappssmtp.com header.a=rsa-sha256 header.s=20230601 header.b=En6mZBN9; 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 4W02qt4995z20Pb for ; Thu, 13 Jun 2024 10:10:50 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C06E43882162 for ; Thu, 13 Jun 2024 00:10:48 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-pf1-x435.google.com (mail-pf1-x435.google.com [IPv6:2607:f8b0:4864:20::435]) by sourceware.org (Postfix) with ESMTPS id BF0F1388207A for ; Thu, 13 Jun 2024 00:10:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org BF0F1388207A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rivosinc.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=rivosinc.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org BF0F1388207A Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2607:f8b0:4864:20::435 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718237427; cv=none; b=fPl0SujXDXKFoXhzvCDsD+4lnEorhFbFos1KP1sa8kt5sf851zXzbf6J/CTtwVteFZ+8Xg2zNVZB1sF5jLOAFmoriW2UVDtMpeAJYsRFNeXRz2aXqnKHqwJcM1B8Sy3AVDlxHF83KNuEwwPAaltJol6nvTc1DgFbZRnj1LeFvco= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1718237427; c=relaxed/simple; bh=JZ8dP3jMPFyMmoQ9sEaFfQVgLeBhY8VZEmgryAPZhLI=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=uwL1IzpvG0GmsPij8BQDoJZ0Ylp1Kpz55GCnju/ws6ZKAafh3jVAp1xDjA0Hez8UVZfRkOFM8KYdtd9oaWWMXEj0wrUue8QNI94TbrU4LTfEIRBFG5d/BUV3WvD300++tF+eQaM8yZJvW4TFnO9+YHs4Io3xibqO5w4yz/LpJeI= ARC-Authentication-Results: i=1; server2.sourceware.org Received: by mail-pf1-x435.google.com with SMTP id d2e1a72fcca58-70436048c25so341929b3a.0 for ; Wed, 12 Jun 2024 17:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rivosinc-com.20230601.gappssmtp.com; s=20230601; t=1718237421; x=1718842221; darn=gcc.gnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=+5V/lUYOVb2Jw5ThqhVpqpGGCfq6zm/vyO0w1K1+JVo=; b=En6mZBN9q8L8039N7UWU9qPrhRIv1J9vVXhCQakMCfDQy4dSYk9dYvN0JaRvscMMKr NDJdfP63Y7AClA3b/8yEievAE+GY0q4dWNNDV7Y1fDGn54vZXog3E19f6pt0y0F1r6f+ Blw9AN1Exaw5KQIqvZaU1+HFXL66p7tHl9jtZheWEDRKeYOsgkobGnrv95FDYjVLrFVG Af4jn0zsvbZPYyr1+4iwedw6ny+QetquD9cVIs+hdlG3C/DuGl+At6OklKUNjQnHzhsM TAAYwZ+Het6IoMwNx4viMEhotCdaiLTO5JFmZGcI710P0r85SnPIEvLESJ3fVBiNqVpD RvUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718237421; x=1718842221; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=+5V/lUYOVb2Jw5ThqhVpqpGGCfq6zm/vyO0w1K1+JVo=; b=OeE5By6/x15HZcwGiTKNeOjbUunWTOo4m8YJG8Ha8oDZQytKBwWsg78YGa8qH2Tjol uoCl1SbjVydG9PAq2+VjH15fiSmU0nuafRbRIUiss+q87slBYHOphRSjxntGpTW+HHwK SyKHXQ+griZxZLGCVjVIATByT632u1Cl03v6Zz0mVdOjxyFt3Pq7eqTCefWPU8MS0K5e xcjvyN0ahelkIFJdJsQWVrr2SkdKN5QYoj7EOV8EzjkFatVji0lxca2Yed3A/VDf+Xci +Je0ZtWQv+77I4m7j5mw5sSspkjTfWDYn1x4aLz36oO63MuLP5mAce80+mj1jIx+Zu9C dUDw== X-Gm-Message-State: AOJu0YzvBaFmWRc96REf/eKj6/8qRHQchAyDN+iaHaLo90LGITPCZeet i1D6OCwc2j9T3G6DmXOMIzT1o8pZBKPGD3XodG144yKZwV52snBAT6bcA2Dz9vRKJOp5EUjD4IP w X-Google-Smtp-Source: AGHT+IHfcenvo8L6RliZQU18c6dU54i0hegHvaAKDkL/jEfJ1UOJAIFwGmvTQJw6D6qQO555l5YCzg== X-Received: by 2002:a05:6a00:2e10:b0:705:a171:b994 with SMTP id d2e1a72fcca58-705bcf1052emr4126245b3a.32.1718237420329; Wed, 12 Jun 2024 17:10:20 -0700 (PDT) Received: from patrick-ThinkPad-X1-Carbon-Gen-8.hq.rivosinc.com ([50.145.13.30]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-705cc9257e0sm144290b3a.29.2024.06.12.17.10.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 12 Jun 2024 17:10:19 -0700 (PDT) From: Patrick O'Neill To: gcc-patches@gcc.gnu.org Cc: andrea@rivosinc.com, jeffreyalaw@gmail.com, kito.cheng@gmail.com, palmer@dabbelt.com, gnu-toolchain@rivosinc.com, Patrick O'Neill Subject: [PATCH] RISC-V: Add support for subword atomic loads/stores Date: Wed, 12 Jun 2024 17:10:13 -0700 Message-ID: <20240613001013.91104-1-patrick@rivosinc.com> X-Mailer: git-send-email 2.43.2 MIME-Version: 1.0 X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, 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 Andrea Parri recently pointed out that we were emitting overly conservative fences for seq_cst atomic loads/stores. This adds support for the optimized fences specified in the PSABI: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/2092568f7896ceaa1ec0f02569b19eaa42cd51c9/riscv-atomic.adoc gcc/ChangeLog: * config/riscv/sync-rvwmo.md: Add support for subword fenced loads/stores. * config/riscv/sync-ztso.md: Ditto. * config/riscv/sync.md: Ditto. gcc/testsuite/ChangeLog: * gcc.target/riscv/amo/amo-table-a-6-load-1.c: Increase test coverage to include longs, shorts, chars, and bools. * gcc.target/riscv/amo/amo-table-a-6-load-2.c: Ditto. * gcc.target/riscv/amo/amo-table-a-6-load-3.c: Ditto. * gcc.target/riscv/amo/amo-table-a-6-store-1.c: Ditto. * gcc.target/riscv/amo/amo-table-a-6-store-2.c: Ditto. * gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-load-1.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-load-2.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-load-3.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-store-1.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-store-2.c: Ditto. * gcc.target/riscv/amo/amo-table-ztso-store-3.c: Ditto. Signed-off-by: Patrick O'Neill Tested-by: Andrea Parri --- Andrea Parri's comment: https://inbox.sourceware.org/gcc-patches/ZmeXGRF+zDktFqaY@andrea/ --- gcc/config/riscv/sync-rvwmo.md | 24 ++++---- gcc/config/riscv/sync-ztso.md | 20 +++---- gcc/config/riscv/sync.md | 8 +-- .../riscv/amo/amo-table-a-6-load-1.c | 48 +++++++++++++++- .../riscv/amo/amo-table-a-6-load-2.c | 52 ++++++++++++++++- .../riscv/amo/amo-table-a-6-load-3.c | 56 ++++++++++++++++++- .../riscv/amo/amo-table-a-6-store-1.c | 48 +++++++++++++++- .../riscv/amo/amo-table-a-6-store-2.c | 52 ++++++++++++++++- .../riscv/amo/amo-table-a-6-store-compat-3.c | 56 ++++++++++++++++++- .../riscv/amo/amo-table-ztso-load-1.c | 48 +++++++++++++++- .../riscv/amo/amo-table-ztso-load-2.c | 48 +++++++++++++++- .../riscv/amo/amo-table-ztso-load-3.c | 52 ++++++++++++++++- .../riscv/amo/amo-table-ztso-store-1.c | 48 +++++++++++++++- .../riscv/amo/amo-table-ztso-store-2.c | 48 +++++++++++++++- .../riscv/amo/amo-table-ztso-store-3.c | 52 ++++++++++++++++- 15 files changed, 610 insertions(+), 50 deletions(-) -- 2.34.1 diff --git a/gcc/config/riscv/sync-rvwmo.md b/gcc/config/riscv/sync-rvwmo.md index e639a1e2392..5db94c8c27f 100644 --- a/gcc/config/riscv/sync-rvwmo.md +++ b/gcc/config/riscv/sync-rvwmo.md @@ -47,9 +47,9 @@ ;; Atomic memory operations. (define_insn "atomic_load_rvwmo" - [(set (match_operand:GPR 0 "register_operand" "=r") - (unspec_volatile:GPR - [(match_operand:GPR 1 "memory_operand" "A") + [(set (match_operand:ANYI 0 "register_operand" "=r") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "memory_operand" "A") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_LOAD))] "!TARGET_ZTSO" @@ -59,13 +59,13 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,rw\;" - "l\t%0,%1\;" + "\t%0,%1\;" "fence\tr,rw"; if (model == MEMMODEL_ACQUIRE) - return "l\t%0,%1\;" + return "\t%0,%1\;" "fence\tr,rw"; else - return "l\t%0,%1"; + return "\t%0,%1"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) @@ -73,9 +73,9 @@ ;; Implement atomic stores with conservative fences. ;; This allows us to be compatible with the ISA manual Table A.6 and Table A.7. (define_insn "atomic_store_rvwmo" - [(set (match_operand:GPR 0 "memory_operand" "=A") - (unspec_volatile:GPR - [(match_operand:GPR 1 "reg_or_0_operand" "rJ") + [(set (match_operand:ANYI 0 "memory_operand" "=A") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "reg_or_0_operand" "rJ") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_STORE))] "!TARGET_ZTSO" @@ -85,13 +85,13 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,w\;" - "s\t%z1,%0\;" + "\t%z1,%0\;" "fence\trw,rw"; if (model == MEMMODEL_RELEASE) return "fence\trw,w\;" - "s\t%z1,%0"; + "\t%z1,%0"; else - return "s\t%z1,%0"; + return "\t%z1,%0"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) diff --git a/gcc/config/riscv/sync-ztso.md b/gcc/config/riscv/sync-ztso.md index 0a866d2906b..f99a21b45ca 100644 --- a/gcc/config/riscv/sync-ztso.md +++ b/gcc/config/riscv/sync-ztso.md @@ -41,9 +41,9 @@ ;; Atomic memory operations. (define_insn "atomic_load_ztso" - [(set (match_operand:GPR 0 "register_operand" "=r") - (unspec_volatile:GPR - [(match_operand:GPR 1 "memory_operand" "A") + [(set (match_operand:ANYI 0 "register_operand" "=r") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "memory_operand" "A") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_LOAD))] "TARGET_ZTSO" @@ -53,17 +53,17 @@ if (model == MEMMODEL_SEQ_CST) return "fence\trw,rw\;" - "l\t%0,%1"; + "\t%0,%1"; else - return "l\t%0,%1"; + return "\t%0,%1"; } [(set_attr "type" "multi") (set (attr "length") (const_int 12))]) (define_insn "atomic_store_ztso" - [(set (match_operand:GPR 0 "memory_operand" "=A") - (unspec_volatile:GPR - [(match_operand:GPR 1 "reg_or_0_operand" "rJ") + [(set (match_operand:ANYI 0 "memory_operand" "=A") + (unspec_volatile:ANYI + [(match_operand:ANYI 1 "reg_or_0_operand" "rJ") (match_operand:SI 2 "const_int_operand")] ;; model UNSPEC_ATOMIC_STORE))] "TARGET_ZTSO" @@ -72,10 +72,10 @@ model = memmodel_base (model); if (model == MEMMODEL_SEQ_CST) - return "s\t%z1,%0\;" + return "\t%z1,%0\;" "fence\trw,rw"; else - return "s\t%z1,%0"; + return "\t%z1,%0"; } [(set_attr "type" "multi") (set (attr "length") (const_int 8))]) diff --git a/gcc/config/riscv/sync.md b/gcc/config/riscv/sync.md index 4df9d0b5a5f..4784375449f 100644 --- a/gcc/config/riscv/sync.md +++ b/gcc/config/riscv/sync.md @@ -57,8 +57,8 @@ ;; Atomic memory operations. (define_expand "atomic_load" - [(match_operand:GPR 0 "register_operand") - (match_operand:GPR 1 "memory_operand") + [(match_operand:ANYI 0 "register_operand") + (match_operand:ANYI 1 "memory_operand") (match_operand:SI 2 "const_int_operand")] ;; model "" { @@ -72,8 +72,8 @@ }) (define_expand "atomic_store" - [(match_operand:GPR 0 "memory_operand") - (match_operand:GPR 1 "reg_or_0_operand") + [(match_operand:ANYI 0 "memory_operand") + (match_operand:ANYI 1 "reg_or_0_operand") (match_operand:SI 2 "const_int_operand")] ;; model "" { diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c index 53dd5234452..dc98c7d5ed1 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-1.c @@ -5,12 +5,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_relaxed: +** ld\t[atx][0-9]+,0\(a0\) +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_relaxed (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_int_relaxed: ** lw\t[atx][0-9]+,0\(a0\) ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_relaxed (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_short_relaxed: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_relaxed (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_char_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_relaxed (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_bool_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_relaxed (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c index dda0f541515..abb841ddad6 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-2.c @@ -5,13 +5,61 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_acquire: +** ld\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_acquire (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_int_acquire: ** lw\t[atx][0-9]+,0\(a0\) ** fence\tr,rw ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_acquire (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_short_acquire: +** lh\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_acquire (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_char_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_acquire (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_bool_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_acquire (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c index 3279557fa4a..654f890aac0 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-load-3.c @@ -5,14 +5,66 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_seq_cst: +** fence\trw,rw +** ld\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_seq_cst (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_int_seq_cst: ** fence\trw,rw ** lw\t[atx][0-9]+,0\(a0\) ** fence\tr,rw ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_seq_cst (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_short_seq_cst: +** fence\trw,rw +** lh\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_seq_cst (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_char_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_seq_cst (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_bool_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** fence\tr,rw +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_seq_cst (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c index 6b05429520b..a1a33ccb454 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-1.c @@ -5,12 +5,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_relaxed: +** ld\t[atx][0-9]+,0\(a1\) +** sd\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_relaxed (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_int_relaxed: ** lw\t[atx][0-9]+,0\(a1\) ** sw\t[atx][0-9]+,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_relaxed (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_short_relaxed: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_relaxed (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_char_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_relaxed (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_bool_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_relaxed (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c index 1ad7dede931..5c9451fa324 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-2.c @@ -5,13 +5,61 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_release: +** ld\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sd\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_release (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_int_release: ** lw\t[atx][0-9]+,0\(a1\) ** fence\trw,w ** sw\t[atx][0-9]+,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_release (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_short_release: +** lhu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_release (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_char_release: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_release (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_bool_release: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_release (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c index b16b2058413..52d53b9104f 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-a-6-store-compat-3.c @@ -5,14 +5,66 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_seq_cst: +** ld\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sd\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_long_seq_cst (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_int_seq_cst: ** lw\t[atx][0-9]+,0\(a1\) ** fence\trw,w ** sw\t[atx][0-9]+,0\(a0\) ** fence\trw,rw ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_seq_cst (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_short_seq_cst: +** lhu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sh\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_short_seq_cst (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_char_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_char_seq_cst (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_bool_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** fence\trw,w +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_bool_seq_cst (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c index ebb0a2e1d38..b3e263e777d 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-1.c @@ -6,12 +6,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_relaxed: +** ld\t[atx][0-9]+,0\(a0\) +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_relaxed (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_int_relaxed: ** lw\t[atx][0-9]+,0\(a0\) ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_relaxed (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_short_relaxed: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_relaxed (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_char_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_relaxed (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_load_bool_relaxed: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_relaxed (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c index c88c4be5aea..15ecccf473b 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-2.c @@ -6,12 +6,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_acquire: +** ld\t[atx][0-9]+,0\(a0\) +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_acquire (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_int_acquire: ** lw\t[atx][0-9]+,0\(a0\) ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_acquire (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_short_acquire: +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_acquire (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_char_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_acquire (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_ACQUIRE); +} + +/* +** atomic_load_bool_acquire: +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_acquire (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_ACQUIRE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c index 8713729c378..ca56f233042 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-load-3.c @@ -6,13 +6,61 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_load_long_seq_cst: +** fence\trw,rw +** ld\t[atx][0-9]+,0\(a0\) +** sd\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_long_seq_cst (long* bar, long* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_int_seq_cst: ** fence\trw,rw ** lw\t[atx][0-9]+,0\(a0\) ** sw\t[atx][0-9]+,0\(a1\) ** ret */ -void foo (int* bar, int* baz) +void atomic_load_int_seq_cst (int* bar, int* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_short_seq_cst: +** fence\trw,rw +** lh\t[atx][0-9]+,0\(a0\) +** sh\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_short_seq_cst (short* bar, short* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_char_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_char_seq_cst (char* bar, char* baz) +{ + __atomic_load(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_load_bool_seq_cst: +** fence\trw,rw +** lb\t[atx][0-9]+,0\(a0\) +** sb\t[atx][0-9]+,0\(a1\) +** ret +*/ +void atomic_load_bool_seq_cst (_Bool* bar, _Bool* baz) { __atomic_load(bar, baz, __ATOMIC_SEQ_CST); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c index ca8d5ed7515..b353f53d7b8 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-1.c @@ -6,12 +6,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_relaxed: +** ld\t[atx][0-9]+,0\(a1\) +** sd\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_relaxed (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_int_relaxed: ** lw\t[atx][0-9]+,0\(a1\) ** sw\t[atx][0-9]+,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_relaxed (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_short_relaxed: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_relaxed (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_char_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_relaxed (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELAXED); +} + +/* +** atomic_store_bool_relaxed: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_relaxed (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_RELAXED); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c index 23957198cfb..989e062bf75 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-2.c @@ -6,12 +6,56 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_release: +** ld\t[atx][0-9]+,0\(a1\) +** sd\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_long_release (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_int_release: ** lw\t[atx][0-9]+,0\(a1\) ** sw\t[atx][0-9]+,0\(a0\) ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_release (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_short_release: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_short_release (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_char_release: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_char_release (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_RELEASE); +} + +/* +** atomic_store_bool_release: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** ret +*/ +void atomic_store_bool_release (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_RELEASE); } diff --git a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c index 11c12f0ca1a..0c24dc60225 100644 --- a/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c +++ b/gcc/testsuite/gcc.target/riscv/amo/amo-table-ztso-store-3.c @@ -6,13 +6,61 @@ /* { dg-final { check-function-bodies "**" "" } } */ /* -** foo: +** atomic_store_long_seq_cst: +** ld\t[atx][0-9]+,0\(a1\) +** sd\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_long_seq_cst (long* bar, long* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_int_seq_cst: ** lw\t[atx][0-9]+,0\(a1\) ** sw\t[atx][0-9]+,0\(a0\) ** fence\trw,rw ** ret */ -void foo (int* bar, int* baz) +void atomic_store_int_seq_cst (int* bar, int* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_short_seq_cst: +** lhu\t[atx][0-9]+,0\(a1\) +** sh\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_short_seq_cst (short* bar, short* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_char_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_char_seq_cst (char* bar, char* baz) +{ + __atomic_store(bar, baz, __ATOMIC_SEQ_CST); +} + +/* +** atomic_store_bool_seq_cst: +** lbu\t[atx][0-9]+,0\(a1\) +** sb\t[atx][0-9]+,0\(a0\) +** fence\trw,rw +** ret +*/ +void atomic_store_bool_seq_cst (_Bool* bar, _Bool* baz) { __atomic_store(bar, baz, __ATOMIC_SEQ_CST); }