From patchwork Mon Jan 8 01:14:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Yujie X-Patchwork-Id: 83496 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id ABAEE386F00E for ; Mon, 8 Jan 2024 01:21:39 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id DBD7E386483B for ; Mon, 8 Jan 2024 01:20:06 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DBD7E386483B Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=loongson.cn Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=loongson.cn ARC-Filter: OpenARC Filter v1.0.0 sourceware.org DBD7E386483B Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=114.242.206.163 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704676814; cv=none; b=TqT9UcGvRcKaikchBBJgim776wvmuMq4qkE1YHDcVbeyklnXfCfvkToGZsKrtZpXAfa/H/BNAxw6JaDGHpRzcauJlTGWnYC3GZnYXjOyzOFg3JxjU0N9z52kaUB9XYq8Qfq3OhCgGNt7w05cV7rB5kI6TLJk9fNIoD9/DrY4AaE= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1704676814; c=relaxed/simple; bh=synwocSR1iW+FBj6lcqjFLGobNAzu9UnT6BnKkqHnIg=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=pWCyWoTTnCPNwtBLhBCN/rLjbirGatA0w3z5gx3mPKn5JIr6UfTyeL5fcdpp6vCR1GTqlTAu04/KYpoAQzW7AJtLbiW0+Go+7R866BJtNtPohu6jH/rjiws2o2yn4KzSzpn1tMifojvYotV/SyEJ+nQxmXWh4cJ71bprHSm0xNM= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [114.243.106.119]) by gateway (Coremail) with SMTP id _____8AxDOvDTZtly_4CAA--.9893S3; Mon, 08 Jan 2024 09:20:03 +0800 (CST) Received: from localhost.localdomain (unknown [114.243.106.119]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxTN65TZtlLMEGAA--.838S5; Mon, 08 Jan 2024 09:20:02 +0800 (CST) From: Yang Yujie To: gcc-patches@gcc.gnu.org Cc: xry111@xry111.site, chenglulu@loongson.cn, xuchenghua@loongson.cn, Yang Yujie Subject: [PATCH v2 3/4] LoongArch: Use enums for constants Date: Mon, 8 Jan 2024 09:14:09 +0800 Message-ID: <20240108011410.305003-4-yangyujie@loongson.cn> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240108011410.305003-1-yangyujie@loongson.cn> References: <20240108011410.305003-1-yangyujie@loongson.cn> MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxTN65TZtlLMEGAA--.838S5 X-CM-SenderInfo: 51dqw5pxmlvqxorr0wxvrqhubq/1tbiAQAKAGWbSakAuwAAsu X-Coremail-Antispam: 1Uk129KBj93XoWxAFykJF1UWFW8KrWrKF4UAwc_yoWrZw1xpa 9xu395tr40yFsxX34kt3s5u347Xr4xGrW2qa1agry8u3yDG348Wr4UGay5Xa4Yqa95K347 Xrn5X3W0v3W5GrXCm3ZEXasCq-sJn29KB7ZKAUJUUUU8529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkjb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r126r13M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_Gr0_Xr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Gr0_Cr1l84ACjcxK6I8E87Iv67AKxVW8JVWxJwA2z4x0Y4vEx4A2jsIEc7CjxVAFwI0_ Gr0_Gr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx1l5I 8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r126r1DMcIj6I8E87Iv67AK xVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2Ij64 vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s026x8G jcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r126r1DMIIYrxkI7VAKI48JMIIF0xvE2I x0cI8IcVAFwI0_JFI_Gr1lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE42xK 8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6xkF7I 0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07jjpB-UUUUU= X-Spam-Status: No, score=-10.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, 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+patchwork=sourceware.org@gcc.gnu.org Target features constants from loongarch-def.h are currently defined as macros. Switch to enums for better look in the debugger. gcc/ChangeLog: * config/loongarch/loongarch-def.h: Define constants with enums instead of Macros. --- gcc/config/loongarch/loongarch-def.h | 115 ++++++++++++++++----------- 1 file changed, 67 insertions(+), 48 deletions(-) diff --git a/gcc/config/loongarch/loongarch-def.h b/gcc/config/loongarch/loongarch-def.h index f8cb3adf509..a1237ecf1fd 100644 --- a/gcc/config/loongarch/loongarch-def.h +++ b/gcc/config/loongarch/loongarch-def.h @@ -23,12 +23,10 @@ along with GCC; see the file COPYING3. If not see - ISA extensions (isa_ext), - base ABI types (abi_base), - ABI extension types (abi_ext). - - - code models (cmodel) - - other command-line switches (switch) + - code models (cmodel) These values are primarily used for implementing option handling - logic in "loongarch.opt", "loongarch-driver.c" and "loongarch-opt.c". + logic in "loongarch.opt", "loongarch-driver.cc" and "loongarch-opt.cc". As for the result of this option handling process, the following scheme is adopted to represent the final configuration: @@ -53,30 +51,40 @@ along with GCC; see the file COPYING3. If not see #include "loongarch-def-array.h" #include "loongarch-tune.h" -/* enum isa_base */ -/* LoongArch64 */ -#define ISA_BASE_LA64 0 -#define N_ISA_BASE_TYPES 1 +/* ISA base */ +enum { + ISA_BASE_LA64 = 0, /* LoongArch64 */ + N_ISA_BASE_TYPES = 1 +}; + extern loongarch_def_array loongarch_isa_base_strings; -/* enum isa_ext_* */ -#define ISA_EXT_NONE 0 -#define ISA_EXT_FPU32 1 -#define ISA_EXT_FPU64 2 -#define N_ISA_EXT_FPU_TYPES 3 -#define ISA_EXT_SIMD_LSX 3 -#define ISA_EXT_SIMD_LASX 4 -#define N_ISA_EXT_TYPES 5 + +/* ISA extensions */ +enum { + ISA_EXT_NONE = 0, + ISA_EXT_FPU32 = 1, + ISA_EXT_FPU64 = 2, + N_ISA_EXT_FPU_TYPES = 3, + ISA_EXT_SIMD_LSX = 3, + ISA_EXT_SIMD_LASX = 4, + N_ISA_EXT_TYPES = 5 +}; + extern loongarch_def_array loongarch_isa_ext_strings; -/* enum abi_base */ -#define ABI_BASE_LP64D 0 -#define ABI_BASE_LP64F 1 -#define ABI_BASE_LP64S 2 -#define N_ABI_BASE_TYPES 3 + +/* Base ABI */ +enum { + ABI_BASE_LP64D = 0, + ABI_BASE_LP64F = 1, + ABI_BASE_LP64S = 2, + N_ABI_BASE_TYPES = 3 +}; + extern loongarch_def_array loongarch_abi_base_strings; @@ -90,28 +98,38 @@ extern loongarch_def_array (abi_base == ABI_BASE_LP64S) -/* enum abi_ext */ -#define ABI_EXT_BASE 0 -#define N_ABI_EXT_TYPES 1 +/* ABI Extension */ +enum { + ABI_EXT_BASE = 0, + N_ABI_EXT_TYPES = 1 +}; + extern loongarch_def_array loongarch_abi_ext_strings; -/* enum cmodel */ -#define CMODEL_NORMAL 0 -#define CMODEL_TINY 1 -#define CMODEL_TINY_STATIC 2 -#define CMODEL_MEDIUM 3 -#define CMODEL_LARGE 4 -#define CMODEL_EXTREME 5 -#define N_CMODEL_TYPES 6 + +/* Code Model */ +enum { + CMODEL_NORMAL = 0, + CMODEL_TINY = 1, + CMODEL_TINY_STATIC = 2, + CMODEL_MEDIUM = 3, + CMODEL_LARGE = 4, + CMODEL_EXTREME = 5, + N_CMODEL_TYPES = 6 +}; + extern loongarch_def_array loongarch_cmodel_strings; -/* enum explicit_relocs */ -#define EXPLICIT_RELOCS_AUTO 0 -#define EXPLICIT_RELOCS_NONE 1 -#define EXPLICIT_RELOCS_ALWAYS 2 -#define N_EXPLICIT_RELOCS_TYPES 3 + +/* Explicit Reloc Type */ +enum { + EXPLICIT_RELOCS_AUTO = 0, + EXPLICIT_RELOCS_NONE = 1, + EXPLICIT_RELOCS_ALWAYS = 2, + N_EXPLICIT_RELOCS_TYPES = 3 +}; /* The common default value for variables whose assignments are triggered by command-line options. */ @@ -159,17 +177,18 @@ struct loongarch_target int cmodel; /* CMODEL_ */ }; -/* CPU properties. */ -/* index */ -#define CPU_NATIVE 0 -#define CPU_ABI_DEFAULT 1 -#define CPU_LOONGARCH64 2 -#define CPU_LA464 3 -#define CPU_LA664 4 -#define N_ARCH_TYPES 5 -#define N_TUNE_TYPES 5 - -/* parallel tables. */ +/* CPU model */ +enum { + CPU_NATIVE = 0, + CPU_ABI_DEFAULT = 1, + CPU_LOONGARCH64 = 2, + CPU_LA464 = 3, + CPU_LA664 = 4, + N_ARCH_TYPES = 5, + N_TUNE_TYPES = 5 +}; + +/* CPU model properties */ extern loongarch_def_array loongarch_cpu_strings; extern loongarch_def_array