From patchwork Tue Nov 5 03:23:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yangyu Chen X-Patchwork-Id: 2006603 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; unprotected) header.d=qq.com header.i=@qq.com header.a=rsa-sha256 header.s=s201512 header.b=blh/VNpQ; 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 4XjDFn5Slhz1xyD for ; Tue, 5 Nov 2024 14:23:57 +1100 (AEDT) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE215385783B for ; Tue, 5 Nov 2024 03:23:55 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from out162-62-58-211.mail.qq.com (out162-62-58-211.mail.qq.com [162.62.58.211]) by sourceware.org (Postfix) with UTF8SMTPS id 376563857830 for ; Tue, 5 Nov 2024 03:23:23 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 376563857830 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cyyself.name Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cyyself.name ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 376563857830 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=162.62.58.211 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730777008; cv=none; b=k9wbIHkK9x9BHtZdvo7SEWgFt+oQr5sCYerreyxjl8e0Tr3MFi2FSDfdN6r7jNBB33S4MWlmH7n/agaCmqRV4qj+BPuglc+cIG+4ZK0/5qrnSQBzvmkUiZYVL+7Cio3953YQaA++5JqqCeNXcNknCsV288TyWrZEP5W0mWxJaBE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1730777008; c=relaxed/simple; bh=0PxguMCX8r4J60Qpualba3KK6ZXlp7is9nIDe7w9P8Y=; h=DKIM-Signature:Message-ID:From:To:Subject:Date:MIME-Version; b=A9lci1gnbDd/0fydn3TWoLhMY5jzvwzmuHTRDH6yccJnLjArfIRwDk4VXvlrdxTD6HPx6vmVA9+Wd2pfoD6IOMM9eOQL9Dv18jp5D8imSCLSILo/6lIzEyD05YPpfItqeDzscKGC2LURx8Sv8lFkU1eYskdF1TCByDkS62JKddQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qq.com; s=s201512; t=1730777001; bh=RHFlmZrfTCP4WcQHnTKocE/fAUltLDVbGwG0DSir3gQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=blh/VNpQMc2CTXLtd7x9uJ2rTpp6UOI208lm97YsuS+31gdoFlhDNLA3bTyGZ1DTa 9TxAnPDdL74Sx0gOhD3avtTGTaSeRQW/TlpqtLZUemLQTK1LwRxB+RFwc/jYxK8V3a nQVJD/KE3akj0flN3rZyuXUhs4Gz8IghRcHu9/lc= Received: from cyy-pc.lan ([240e:379:2276:5d00:cda0:97a5:84f4:5191]) by newxmesmtplogicsvrsza36-0.qq.com (NewEsmtp) with SMTP id 5D234E22; Tue, 05 Nov 2024 11:23:18 +0800 X-QQ-mid: xmsmtpt1730776998t5v5rid3f Message-ID: X-QQ-XMAILINFO: N/WmRbclY25GgSjUQdGBjjejAVOqC0V9by9wzqKa7XhJGXXKt0DJuVvkkXnZvL skDFud1Ln0D7ahWYfEE0qUf1KjwSE/0KuhmlT0uXA9xLPYZW8VfELLagYyKdER2pz70FFhbmDGai iBoDqmwpRTUZPAKYJxzzpa8njDy4BK07Kt9iC0g9Ogr1HiphmfXInSOBxRmNnmX6VGReY/Vcnjh5 ZM1+yMYDKFkgTz8VkWZ6lq+w2pPCeiobu33j0guA9qbx+V1i815XeD1Ye0feigndLRZ7GG8EdJ2p bYbiUGwM2UZ/jBpecbfJpg54ei14bJwTtYSubqlR986ByF8FaL9nkHDIDtpSYhZbIg9AgA1bSjjZ UjbPFyLkXHp9FZNUv6TJ7JT5r3aGfxnuheMPzfECFl2REV861nipaaBEViwGGiUyTwis0ehC0Iyu nU6t1J46oOedVbbnxDlrR8LC71VF5VfLt454kSu5qm4vl1IVstgyDXLL58Ia50qv/aD1/S7JEPKL MpzQ6cwLxzgFifUqP00a4yalkeFg5foRffm+uw74XUwk7yBvjF2H+HG0O3wVAfD/Ii8/Ed7qwkIW F9yXVjQg+oEH7e8UceKyeZPkONKsGZ4Oap4y+5RSjR+dP1ZyaFJYx3/Nm6xAKjfm+70RrKV3xvDX fm5HXgKO3utSi7G6DWHurLM65PRUgvoaMdEcNDmIzy6QUbwsZr5u5HOo5d2mA4brrPAzt9DwsNZK ChlNoYdBfUJJJZ6MmsvEZzbqeiJXOxFtVRWYnYk0qQMODUCKSRDhN++WjJy3bPduWqreJt2PTG09 /Un3yZX3iCCEyDGrsTGEmRbsD2A3puWzNxmKtRbjTYPyCwcGDOB8V36RfCmIBdIQqxPfmbOpNKQh l718vVXt2oYVOWNe1OLBzTUj9Rp7uxuTswuncaNqls5TX6+/0xe/aFo4fGiIVzh48ratrO5vj12f GUEb3NUzX2fnYRVowQzKLKeqoe6QrXJOxv4Y/a7/RQ9TD1DexVb3KxIDQnYzBz/7K70meSzQ9YA7 F6BvWIRy7LNqubJbTYn/ZeMyscllY= X-QQ-XMRINFO: MSVp+SPm3vtS1Vd6Y4Mggwc= From: Yangyu Chen To: gcc-patches@gcc.gnu.org Cc: Kito Cheng , Palmer Dabbelt , Jiawei , Jeff Law , Evgeny Stupachenko , Andrew Carlotti , Hank Chang , Yangyu Chen Subject: [PATCH v5 8/8] RISC-V: Add Multi-Versioning Test Cases Date: Tue, 5 Nov 2024 11:23:16 +0800 X-OQ-MSGID: <20241105032316.2646322-1-cyy@cyyself.name> X-Mailer: git-send-email 2.45.2 In-Reply-To: References: MIME-Version: 1.0 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 This patch adds test cases for the Function Multi-Versioning (FMV) feature for RISC-V, which reuses the existing test cases from the aarch64 and ported them to RISC-V. Signed-off-by: Yangyu Chen gcc/testsuite/ChangeLog: * g++.target/riscv/mv-symbols1.C: New test. * g++.target/riscv/mv-symbols2.C: New test. * g++.target/riscv/mv-symbols3.C: New test. * g++.target/riscv/mv-symbols4.C: New test. * g++.target/riscv/mv-symbols5.C: New test. * g++.target/riscv/mvc-symbols1.C: New test. * g++.target/riscv/mvc-symbols2.C: New test. * g++.target/riscv/mvc-symbols3.C: New test. * g++.target/riscv/mvc-symbols4.C: New test. --- gcc/testsuite/g++.target/riscv/mv-symbols1.C | 70 +++++++++++++++++++ gcc/testsuite/g++.target/riscv/mv-symbols2.C | 61 ++++++++++++++++ gcc/testsuite/g++.target/riscv/mv-symbols3.C | 50 +++++++++++++ gcc/testsuite/g++.target/riscv/mv-symbols4.C | 56 +++++++++++++++ gcc/testsuite/g++.target/riscv/mv-symbols5.C | 62 ++++++++++++++++ gcc/testsuite/g++.target/riscv/mvc-symbols1.C | 49 +++++++++++++ gcc/testsuite/g++.target/riscv/mvc-symbols2.C | 36 ++++++++++ gcc/testsuite/g++.target/riscv/mvc-symbols3.C | 42 +++++++++++ gcc/testsuite/g++.target/riscv/mvc-symbols4.C | 32 +++++++++ 9 files changed, 458 insertions(+) create mode 100644 gcc/testsuite/g++.target/riscv/mv-symbols1.C create mode 100644 gcc/testsuite/g++.target/riscv/mv-symbols2.C create mode 100644 gcc/testsuite/g++.target/riscv/mv-symbols3.C create mode 100644 gcc/testsuite/g++.target/riscv/mv-symbols4.C create mode 100644 gcc/testsuite/g++.target/riscv/mv-symbols5.C create mode 100644 gcc/testsuite/g++.target/riscv/mvc-symbols1.C create mode 100644 gcc/testsuite/g++.target/riscv/mvc-symbols2.C create mode 100644 gcc/testsuite/g++.target/riscv/mvc-symbols3.C create mode 100644 gcc/testsuite/g++.target/riscv/mvc-symbols4.C diff --git a/gcc/testsuite/g++.target/riscv/mv-symbols1.C b/gcc/testsuite/g++.target/riscv/mv-symbols1.C new file mode 100644 index 00000000000..ea1a536fd00 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mv-symbols1.C @@ -0,0 +1,70 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +int foo () +{ + return 1; +} + +__attribute__((target_version("arch=+v"))) +int foo () +{ + return 3; +} +__attribute__((target_version("arch=+zba,+zbb"))) +int foo () +{ + return 5; +} + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (int) +{ + return 6; +} + +__attribute__((target_version("arch=+v"))) +int foo (int) +{ + return 4; +} + +int foo (int) +{ + return 2; +} + + +int bar() +{ + return foo (); +} + +int bar(int x) +{ + return foo (x); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mv-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 2 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 2 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\call\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\call\t_Z3fooi\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mv-symbols2.C b/gcc/testsuite/g++.target/riscv/mv-symbols2.C new file mode 100644 index 00000000000..43fa1502b7d --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mv-symbols2.C @@ -0,0 +1,61 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_version("default"))) +int foo () +{ + return 1; +} + +__attribute__((target_version("arch=+v"))) +int foo () +{ + return 3; +} +__attribute__((target_version("arch=+zba,+zbb"))) +int foo () +{ + return 5; +} + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (int) +{ + return 6; +} + +__attribute__((target_version("arch=+v"))) +int foo (int) +{ + return 4; +} + +__attribute__((target_version("default"))) +int foo (int) +{ + return 2; +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mv-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 2 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 2 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 0 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mv-symbols3.C b/gcc/testsuite/g++.target/riscv/mv-symbols3.C new file mode 100644 index 00000000000..4dc81cf7395 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mv-symbols3.C @@ -0,0 +1,50 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_version("default"))) +int foo (); + +__attribute__((target_version("arch=+v"))) +int foo (); + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (); + +__attribute__((target_version("default"))) +int foo (int); + +__attribute__((target_version("arch=+v"))) +int foo (int); + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (int); + + +int bar() +{ + return foo (); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mv-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 0 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 0 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mv-symbols4.C b/gcc/testsuite/g++.target/riscv/mv-symbols4.C new file mode 100644 index 00000000000..b0ed16a5eda --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mv-symbols4.C @@ -0,0 +1,56 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_version("default"))) +int foo () +{ + return 1; +} + +__attribute__((target_version("arch=+v"))) +int foo (); + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (); + +__attribute__((target_version("default"))) +int foo (int) +{ + return 2; +} + +__attribute__((target_version("arch=+v"))) +int foo (int); + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (int); + + +int bar() +{ + return foo (); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mv-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 0 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 0 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mv-symbols5.C b/gcc/testsuite/g++.target/riscv/mv-symbols5.C new file mode 100644 index 00000000000..f4c6b294e0f --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mv-symbols5.C @@ -0,0 +1,62 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_version("default"))) +int foo (); + +__attribute__((target_version("arch=+v"))) +int foo () +{ + return 3; +} + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo () +{ + return 5; +} + +__attribute__((target_version("default"))) +int foo (int); + +__attribute__((target_version("arch=+v"))) +int foo (int) +{ + return 4; +} + +__attribute__((target_version("arch=+zba,+zbb"))) +int foo (int) +{ + return 6; +} + + +int bar() +{ + return foo (); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mv-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 2 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 2 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 0 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mvc-symbols1.C b/gcc/testsuite/g++.target/riscv/mvc-symbols1.C new file mode 100644 index 00000000000..c78bc7cb64a --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mvc-symbols1.C @@ -0,0 +1,49 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_clones("default", "arch=+v", "arch=+zba,+zbb"))) +int foo () +{ + return 1; +} + +__attribute__((target_clones("arch=+zba,+zbb", "arch=+v", "default"))) +int foo (int) +{ + return 2; +} + + +int bar() +{ + return foo (); +} + +int bar(int x) +{ + return foo (x); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mvc-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 2 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 2 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mvc-symbols2.C b/gcc/testsuite/g++.target/riscv/mvc-symbols2.C new file mode 100644 index 00000000000..d7e1bd228f8 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mvc-symbols2.C @@ -0,0 +1,36 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_clones("default", "arch=+v", "arch=+zba,+zbb"))) +int foo () +{ + return 1; +} + +__attribute__((target_clones("arch=+zba,+zbb", "arch=+v", "default"))) +int foo (int) +{ + return 2; +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mvc-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 2 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 2 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mvc-symbols3.C b/gcc/testsuite/g++.target/riscv/mvc-symbols3.C new file mode 100644 index 00000000000..b36c3fa7a95 --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mvc-symbols3.C @@ -0,0 +1,42 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_clones("default", "arch=+v", "arch=+zba,+zbb"))) +int foo (); + +__attribute__((target_clones("arch=+zba,+zbb", "arch=+v", "default"))) +int foo (int); + +int bar() +{ + return foo (); +} + +int bar(int x) +{ + return foo (x); +} + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mvc-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 0 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 1 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 1 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 1 } } */ diff --git a/gcc/testsuite/g++.target/riscv/mvc-symbols4.C b/gcc/testsuite/g++.target/riscv/mvc-symbols4.C new file mode 100644 index 00000000000..e83b6d8368b --- /dev/null +++ b/gcc/testsuite/g++.target/riscv/mvc-symbols4.C @@ -0,0 +1,32 @@ +/* { dg-do compile } */ +/* { dg-require-ifunc "" } */ +/* { dg-options "-O0 -march=rv64gc -mabi=lp64" } */ + +__attribute__((target_clones("default", "arch=+v", "arch=+zba,+zbb"))) +int foo (); + +__attribute__((target_clones("arch=+zba,+zbb", "arch=+v", "default"))) +int foo (int); + +/* When updating any of the symbol names in these tests, make sure to also + update any tests for their absence in mvc-symbolsN.C */ + +/* { dg-final { scan-assembler ".attribute arch, \"rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0\"" } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_v1p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0" 0 } } */ +/* { dg-final { scan-assembler-times ".option arch, rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0_zmmul1p0_zaamo1p0_zalrsc1p0_zca1p0_zcd1p0_zba1p0_zbb1p0" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3foov\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3foov\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3foov\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3foov, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3foov,_Z3foov\.resolver\n" 0 } } */ + +/* { dg-final { scan-assembler-times "\n_Z3fooi\.default:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__v:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.arch__zba__zbb:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n_Z3fooi\.resolver:\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\tcall\t_Z3fooi\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.type\t_Z3fooi, @gnu_indirect_function\n" 0 } } */ +/* { dg-final { scan-assembler-times "\n\t\.set\t_Z3fooi,_Z3fooi\.resolver\n" 0 } } */