From patchwork Wed Aug 9 11:46:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiajie Chen X-Patchwork-Id: 133167 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c44e:0:b0:3f2:4152:657d with SMTP id w14csp2743022vqr; Wed, 9 Aug 2023 04:55:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/BWj1AKHdaDQ4iiqDiclB9v4mJEcTj/4K8dt4DlrLx/2tg13xe8CnVc6qrNP1TihxcwQ1 X-Received: by 2002:a17:906:92:b0:99b:c517:88a1 with SMTP id 18-20020a170906009200b0099bc51788a1mr2003068ejc.67.1691582106042; Wed, 09 Aug 2023 04:55:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1691582106; cv=none; d=google.com; s=arc-20160816; b=CwWlO3pBygbEyrAFSoE7pv0J6eEN2vdKCswX+3HQqGbTSLqa/fu7GQ/6gfQDzE2ENu E8qakwuOhVziGZBeI/orNIP02EORD1EeGm6FAA17ewEwu13IZgqcincUmql971fzpX4g JCnjTxMWYlTJo3YuJ6ONPLLNk0fqEJs4sy99v7BsGUrHjq6wev1VbMwFGmaDvi4o/tHg gZbBaJuYN/LiJobjdG4uN/ySGh9CLr0CDAMt71EqOoHH/EVF9++bsj06bwvvOsBl3Crt v6w+ARgTsg629ICZ0ZM4BjSqzrKkNBJv1/+WcOp3B+geZlEPhFttKQ/7YWAFhsu+xCYe 0Lbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from: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:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=GICcTj6nT+T9zVp+KmWtbQiPu0MhYNo0OepD5RnTgQE=; fh=nBdY3vW/mgwv3C0AxagIWVpWoiWSUh4TsWT+uiKUcFM=; b=oYxRfNj85qIJ4xYpAeUJwBHcLdGReyayZDN+a/r8ZIW582FRjMHBlvjq7FSpvtIf4D 2TJ5ryLrYniTBRIjcZlTvr7h9n14E/MPr5B8OqVlm0/Gb6NlGBmnHLMD9hG3gXo6tZHF I3ayWFrKBq615pyV+ecZDf7ipK6fQHpru67N4Vg6mPwOAyrD3yCJ0bR0/Bf5bm4Zr9Eq 5xyT78zP/nqsBYhN2GVCvO2wlJ24bCyaRLTmbgIA8pqgpUmnqTLahx3LuGXlFUoUqPUc HnluMoTqO7NE0RdQ4G0kKlYql1wuaiudKnAnVWo5HsxmIHagVtjB9p7NhwMYGguqA/A2 npFQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=TuEF3KyB; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id c6-20020a170906170600b0098874379199si8995570eje.163.2023.08.09.04.55.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 09 Aug 2023 04:55:06 -0700 (PDT) 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=@gcc.gnu.org header.s=default header.b=TuEF3KyB; 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=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 573B5385C8B0 for ; Wed, 9 Aug 2023 11:54:39 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 573B5385C8B0 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1691582079; bh=GICcTj6nT+T9zVp+KmWtbQiPu0MhYNo0OepD5RnTgQE=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=TuEF3KyBXPVfBv6a4A2liQmCDCftYIaauHzUV+4qzFiY8VUqa6uv68/FcJDVePs3W +/E2cRiTNTjJMnUU8atfbTRMRCdNkkRJx36Sj3pIkC5jvjMa/NDPyU+1dBTERZCzrp Uks4fCF7QWGYooIXGKdzKKPMueFP9z5M7fx8tZ6g= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from hognose1.porkbun.com (hognose1.porkbun.com [35.82.102.206]) by sourceware.org (Postfix) with ESMTPS id E7AE4385828E for ; Wed, 9 Aug 2023 11:53:52 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E7AE4385828E Received: from cslab-raptor.. (unknown [166.111.226.99]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: c@jia.je) by hognose1.porkbun.com (Postfix) with ESMTPSA id E460F44063; Wed, 9 Aug 2023 11:53:50 +0000 (UTC) To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, xuchenghua@loongson.cn, Jiajie Chen Subject: [PATCH v2 02/14] LoongArch: Fix default ISA setting Date: Wed, 9 Aug 2023 19:46:09 +0800 Message-ID: <20230809115325.3716347-3-c@jia.je> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230809115325.3716347-1-c@jia.je> References: <20230809115325.3716347-1-c@jia.je> MIME-Version: 1.0 X-Spam-Status: No, score=-13.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, SPF_HELO_PASS, SPF_PASS, TXREP 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Jiajie Chen via Gcc-patches From: Jiajie Chen Reply-To: Jiajie Chen Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1773752398310974326 X-GMAIL-MSGID: 1773752398310974326 When loongarch_arch_target is called, la_target has not been initialized, thus the macro LARCH_ACTUAL_ARCH always equals to zero. This commit fixes by expanding the macro and reading the latest value. It permits -march=loongarch64 when the default target is loongarch32 and vice versa. gcc/ChangeLog: * config/loongarch/loongarch-opts.cc (loongarch_config_target): Fix -march detection. gcc/testsuite/ChangeLog: * gcc.target/loongarch/arch-1.c: New test. * gcc.target/loongarch/arch-2.c: New test. --- gcc/config/loongarch/loongarch-opts.cc | 5 ++++- gcc/testsuite/gcc.target/loongarch/arch-1.c | 5 +++++ gcc/testsuite/gcc.target/loongarch/arch-2.c | 5 +++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/loongarch/arch-1.c create mode 100644 gcc/testsuite/gcc.target/loongarch/arch-2.c diff --git a/gcc/config/loongarch/loongarch-opts.cc b/gcc/config/loongarch/loongarch-opts.cc index 9fc0bbbcb6e..29c0c4468bb 100644 --- a/gcc/config/loongarch/loongarch-opts.cc +++ b/gcc/config/loongarch/loongarch-opts.cc @@ -246,7 +246,10 @@ loongarch_config_target (struct loongarch_target *target, config_target_isa: /* Get default ISA from "-march" or its default value. */ - t.isa = loongarch_cpu_default_isa[LARCH_ACTUAL_ARCH]; + if (t.cpu_arch == TARGET_ARCH_NATIVE) + t.isa = loongarch_cpu_default_isa[t.cpu_native]; + else + t.isa = loongarch_cpu_default_isa[t.cpu_arch]; /* Apply incremental changes. */ /* "-march=native" overrides the default FPU type. */ diff --git a/gcc/testsuite/gcc.target/loongarch/arch-1.c b/gcc/testsuite/gcc.target/loongarch/arch-1.c new file mode 100644 index 00000000000..379036ec76f --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/arch-1.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=loongarch64 -mabi=lp64d" } */ +int foo() +{ +} diff --git a/gcc/testsuite/gcc.target/loongarch/arch-2.c b/gcc/testsuite/gcc.target/loongarch/arch-2.c new file mode 100644 index 00000000000..55d646902a6 --- /dev/null +++ b/gcc/testsuite/gcc.target/loongarch/arch-2.c @@ -0,0 +1,5 @@ +/* { dg-do compile } */ +/* { dg-options "-march=loongarch32 -mabi=ilp32d" } */ +int foo() +{ +}