{"id":2175442,"url":"http://patchwork.ozlabs.org/api/1.0/patches/2175442/?format=json","project":{"id":17,"url":"http://patchwork.ozlabs.org/api/1.0/projects/17/?format=json","name":"GNU Compiler Collection","link_name":"gcc","list_id":"gcc-patches.gcc.gnu.org","list_email":"gcc-patches@gcc.gnu.org","web_url":null,"scm_url":null,"webscm_url":null},"msgid":"<20251218071311.941102-3-i@xen0n.name>","date":"2025-12-18T07:13:11","name":"[2/2] LoongArch: Add built-in macro __loongarch_non_reduced to signify non-LA32R arches","commit_ref":null,"pull_url":null,"state":"new","archived":false,"hash":"e39f4710425a3d2d0567f443366c4315fd9e5477","submitter":{"id":80195,"url":"http://patchwork.ozlabs.org/api/1.0/people/80195/?format=json","name":"WANG Xuerui","email":"i@xen0n.name"},"delegate":null,"mbox":"http://patchwork.ozlabs.org/project/gcc/patch/20251218071311.941102-3-i@xen0n.name/mbox/","series":[{"id":485792,"url":"http://patchwork.ozlabs.org/api/1.0/series/485792/?format=json","date":"2025-12-18T07:13:09","name":"LoongArch: Preliminary LA32 clean-ups","version":1,"mbox":"http://patchwork.ozlabs.org/series/485792/mbox/"}],"check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/2175442/checks/","tags":{},"headers":{"Return-Path":"<gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org>","X-Original-To":["incoming@patchwork.ozlabs.org","gcc-patches@gcc.gnu.org"],"Delivered-To":["patchwork-incoming@legolas.ozlabs.org","gcc-patches@gcc.gnu.org"],"Authentication-Results":["legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=xen0n.name header.i=@xen0n.name header.a=rsa-sha256\n header.s=mail header.b=dFf8iUan;\n\tdkim-atps=neutral","legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org\n (client-ip=38.145.34.32; helo=vm01.sourceware.org;\n envelope-from=gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org;\n receiver=patchwork.ozlabs.org)","sourceware.org;\n\tdkim=pass (1024-bit key,\n unprotected) header.d=xen0n.name header.i=@xen0n.name header.a=rsa-sha256\n header.s=mail header.b=dFf8iUan","sourceware.org;\n dmarc=none (p=none dis=none) header.from=xen0n.name","sourceware.org; spf=pass smtp.mailfrom=xen0n.name","server2.sourceware.org;\n arc=none smtp.remote-ip=115.28.160.31"],"Received":["from vm01.sourceware.org (vm01.sourceware.org [38.145.34.32])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4dX24823Wgz1xpw\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 18:15:04 +1100 (AEDT)","from vm01.sourceware.org (localhost [127.0.0.1])\n\tby sourceware.org (Postfix) with ESMTP id 35DEF4BA2E24\n\tfor <incoming@patchwork.ozlabs.org>; Thu, 18 Dec 2025 07:15:01 +0000 (GMT)","from mailbox.box.xen0n.name (mail.xen0n.name [115.28.160.31])\n by sourceware.org (Postfix) with ESMTPS id 8EB234BA2E1F\n for <gcc-patches@gcc.gnu.org>; Thu, 18 Dec 2025 07:13:24 +0000 (GMT)","from ld50.lan (unknown [IPv6:240e:b8f:939d:bb00::8c0])\n (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest\n SHA256)\n (No client certificate requested)\n by mailbox.box.xen0n.name (Postfix) with ESMTPSA id 200BC60199;\n Thu, 18 Dec 2025 15:13:22 +0800 (CST)"],"DKIM-Filter":["OpenDKIM Filter v2.11.0 sourceware.org 35DEF4BA2E24","OpenDKIM Filter v2.11.0 sourceware.org 8EB234BA2E1F"],"DMARC-Filter":"OpenDMARC Filter v1.4.2 sourceware.org 8EB234BA2E1F","ARC-Filter":"OpenARC Filter v1.0.0 sourceware.org 8EB234BA2E1F","ARC-Seal":"i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1766042006; cv=none;\n b=nMzSj8lvcpChhvrovgSe2n7m1LUwn831ArABW585oXTEG4PonAsr11NCSkl6YjFwVyhPqAxg3IIIr1Y1RZG3Yfc814BfWHLGHIGhIUCHlgeEEp4x5SD19nPun6Gzy+NTcqSxsS0SRM9U8a3FvX57LO5UMFR3SteSkZ/OpSxWlto=","ARC-Message-Signature":"i=1; a=rsa-sha256; d=sourceware.org; s=key;\n t=1766042006; c=relaxed/simple;\n bh=pNIN54RaE+PywK6QLaqkJogH5Hcdp54jXj7HqVDh3rg=;\n h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version;\n b=BLqV18Qhk+/mGDKIlz2oDt5Gk4Ea+d8bGx5+RgyfT3Q/JgpD+7sN34hVMS1ZVTx+A5471Peas+Q/15UEZG51QJ0j1iIJfIzWqr1xF1k370LsNrrVMyU96zZH+11+U2NFFsM5V99jyi2cmhGBI03a5Z/jn9ES85WQvF75IDJ2PcQ=","ARC-Authentication-Results":"i=1; server2.sourceware.org","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=xen0n.name; s=mail;\n t=1766042002; bh=pNIN54RaE+PywK6QLaqkJogH5Hcdp54jXj7HqVDh3rg=;\n h=From:To:Cc:Subject:Date:In-Reply-To:References:From;\n b=dFf8iUanm02YK/YWdtWmFuQuLB9NRLuKzj+hXOBZcT0OwYPftkVqiMidwu6S9FoGI\n Pf9KwW0lFP4rtWhVPJBwUKOg7zt/yssLNeLDDqZ8QjbpwSQrJXDduaZtk3dTBURj34\n AJuglaJJFy7tsQ/sM8HBQKbD5ltubDC5IicsZrrA=","From":"WANG Xuerui <i@xen0n.name>","To":"gcc-patches@gcc.gnu.org","Cc":"Xi Ruoyao <xry111@xry111.site>, Lulu Cheng <chenglulu@loongson.cn>,\n Chenghua Xu <xuchenghua@loongson.cn>, WANG Xuerui <git@xen0n.name>","Subject":"[PATCH 2/2] LoongArch: Add built-in macro __loongarch_non_reduced to\n signify non-LA32R arches","Date":"Thu, 18 Dec 2025 15:13:11 +0800","Message-ID":"<20251218071311.941102-3-i@xen0n.name>","X-Mailer":"git-send-email 2.52.0","In-Reply-To":"<20251218071311.941102-1-i@xen0n.name>","References":"<20251218071311.941102-1-i@xen0n.name>","MIME-Version":"1.0","Content-Transfer-Encoding":"8bit","X-BeenThere":"gcc-patches@gcc.gnu.org","X-Mailman-Version":"2.1.30","Precedence":"list","List-Id":"Gcc-patches mailing list <gcc-patches.gcc.gnu.org>","List-Unsubscribe":"<https://gcc.gnu.org/mailman/options/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=unsubscribe>","List-Archive":"<https://gcc.gnu.org/pipermail/gcc-patches/>","List-Post":"<mailto:gcc-patches@gcc.gnu.org>","List-Help":"<mailto:gcc-patches-request@gcc.gnu.org?subject=help>","List-Subscribe":"<https://gcc.gnu.org/mailman/listinfo/gcc-patches>,\n <mailto:gcc-patches-request@gcc.gnu.org?subject=subscribe>","Errors-To":"gcc-patches-bounces~incoming=patchwork.ozlabs.org@gcc.gnu.org"},"content":"From: WANG Xuerui <git@xen0n.name>\n\nThis helps writing portable code that needs to work across LA32R and\nLA32S.  The tests only work with the fix for PR123171 applied.\n\ngcc/ChangeLog:\n\n\t* config/loongarch/loongarch-c.cc (loongarch_update_cpp_builtins):\n\tDefine __loongarch_non_reduced iff the current base ISA is not\n\tLA32R.\n\ngcc/testsuite/ChangeLog:\n\n\t* gcc.target/loongarch/non-reduced-macro-1.c: New test.\n\t* gcc.target/loongarch/non-reduced-macro-2.c: New test.\n\t* gcc.target/loongarch/non-reduced-macro-3.c: New test.\n\nSigned-off-by: WANG Xuerui <git@xen0n.name>\n---\n gcc/config/loongarch/loongarch-c.cc           |  3 +++\n .../loongarch/non-reduced-macro-1.c           | 19 +++++++++++++++++++\n .../loongarch/non-reduced-macro-2.c           | 19 +++++++++++++++++++\n .../loongarch/non-reduced-macro-3.c           |  7 +++++++\n 4 files changed, 48 insertions(+)\n create mode 100644 gcc/testsuite/gcc.target/loongarch/non-reduced-macro-1.c\n create mode 100644 gcc/testsuite/gcc.target/loongarch/non-reduced-macro-2.c\n create mode 100644 gcc/testsuite/gcc.target/loongarch/non-reduced-macro-3.c","diff":"diff --git a/gcc/config/loongarch/loongarch-c.cc b/gcc/config/loongarch/loongarch-c.cc\nindex b91ba8dd73d..d3dba74a7d5 100644\n--- a/gcc/config/loongarch/loongarch-c.cc\n+++ b/gcc/config/loongarch/loongarch-c.cc\n@@ -103,6 +103,9 @@ loongarch_update_cpp_builtins (cpp_reader *pfile)\n   builtin_define_with_value (\"__loongarch_tune\",\n \t\t\t     loongarch_tune_strings[la_target.cpu_tune], 1);\n \n+  loongarch_def_or_undef (la_target.isa.base != ISA_BASE_LA32R,\n+\t\t\t  \"__loongarch_non_reduced\", pfile);\n+\n   /* Legacy compatibility macros for arch/tune info.  */\n   if (TARGET_64BIT)\n     {\ndiff --git a/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-1.c b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-1.c\nnew file mode 100644\nindex 00000000000..a915c92bd03\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-1.c\n@@ -0,0 +1,19 @@\n+/* { dg-do preprocess } */\n+/* { dg-options \"-march=la32v1.0\" } */\n+\n+#ifndef __loongarch_non_reduced\n+#error __loongarch_non_reduced should be defined here\n+#endif\n+\n+#pragma GCC push_options\n+#pragma GCC target \"arch=la32rv1.0\"\n+\n+#ifdef __loongarch_non_reduced\n+#error __loongarch_non_reduced should not be defined here\n+#endif\n+\n+#pragma GCC pop_options\n+\n+#ifndef __loongarch_non_reduced\n+#error __loongarch_non_reduced should be defined here\n+#endif\ndiff --git a/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-2.c b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-2.c\nnew file mode 100644\nindex 00000000000..05a81def5af\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-2.c\n@@ -0,0 +1,19 @@\n+/* { dg-do preprocess } */\n+/* { dg-options \"-march=la32rv1.0\" } */\n+\n+#ifdef __loongarch_non_reduced\n+#error __loongarch_non_reduced should not be defined here\n+#endif\n+\n+#pragma GCC push_options\n+#pragma GCC target \"arch=la32v1.0\"\n+\n+#ifndef __loongarch_non_reduced\n+#error __loongarch_non_reduced should be defined here\n+#endif\n+\n+#pragma GCC pop_options\n+\n+#ifdef __loongarch_non_reduced\n+#error __loongarch_non_reduced should not be defined here\n+#endif\ndiff --git a/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-3.c b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-3.c\nnew file mode 100644\nindex 00000000000..edb1623c5b7\n--- /dev/null\n+++ b/gcc/testsuite/gcc.target/loongarch/non-reduced-macro-3.c\n@@ -0,0 +1,7 @@\n+/* { dg-do preprocess } */\n+/* { dg-options \"-march=loongarch64\" } */\n+\n+/* LA64 does not have any reduced variant.  */\n+#ifndef __loongarch_non_reduced\n+#error __loongarch_non_reduced should be defined here\n+#endif\n","prefixes":["2/2"]}