From patchwork Mon Oct 30 09:07:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lulu Cai X-Patchwork-Id: 159568 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:d641:0:b0:403:3b70:6f57 with SMTP id cy1csp2072473vqb; Mon, 30 Oct 2023 02:07:26 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFE+vT74/uhAhw7JIqhPYS53Wa3dJK+NAl897wtdUlLnKeHlqNZ+14QpyaOusMkerjk7PAa X-Received: by 2002:a05:620a:55a5:b0:76e:ec77:10a4 with SMTP id vr5-20020a05620a55a500b0076eec7710a4mr8576306qkn.77.1698656846164; Mon, 30 Oct 2023 02:07:26 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1698656846; cv=pass; d=google.com; s=arc-20160816; b=sAYMh60RZEe8Mzs4Coz/f5kOnU1W+ecG7Q2nNf4BzxFzAQYx0LyurD6o1QS5Z0xY9F yaHzwoL3UnEZHGWFxcMOInd/4gB1Hqh36TFA05COnLRxyEfDnNhFZ7sj1yQWjMobT9Au ozezIC37++llpdxcAXphtasI3YTV0CUz9jyzOMSbX7IJ2KcVWZOf+oRB4XFfUu3+wn5+ PVShNZCJcPMTNxz5N4xmuhV/0ZfjXo+GAPD25nBuIgdHMsK4q0v6P3fyZNSgLWXL8aC+ BTG+/Wmxu2Ct3WiohiUTM3xNvV6Er2OnNqCdAEwSmHL1W+ADUrUkLTbDqwoZpgU1R4EH CvYg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:arc-filter :dmarc-filter:delivered-to; bh=dgSSBr/RiekMWBsTtYlsinnAmpv2384kT1h+qiQGDqk=; fh=gXh6TMHUROAkf4rWWHPcaXYH7f5eP0gLk1Z26il6bG8=; b=IOfR9zaPEKMB0hZiDus+CT7F/xIUU14i7yVqToHgrNhjsHry+mZM7j5NzKQcZM+gEw rsxJHnA6t53n9NxS+jiHLe/+H7NkjtCq5Zdss74AX3HGv5tsibWfHywdG9JKGqc3YrRi xYLaVsBEkP6/DoVnsh2uHMMZjr+g/IoOKB57oWuAxgGakcnynW31gXbuJ8qOUIZFYLsV MA48aIOy+C1EkI44eFQGvYt4dTRKnh3Zv9EiSFl4Z8BWgyltUForQ+igiNbOZuo99TI7 0S92lv/CPa/XgrR86+V2F82ihWKrMTzSZDxkiqEGir0LbmJUVWQcUXJuwLhXJxWmwZmL 4z4A== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id bj37-20020a05620a192500b00777722d8abfsi5394289qkb.244.2023.10.30.02.07.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Oct 2023 02:07:26 -0700 (PDT) Received-SPF: pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.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; arc=pass (i=1); spf=pass (google.com: domain of binutils-bounces+ouuuleilei=gmail.com@sourceware.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="binutils-bounces+ouuuleilei=gmail.com@sourceware.org" Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E66E23858417 for ; Mon, 30 Oct 2023 09:07:25 +0000 (GMT) X-Original-To: binutils@sourceware.org Delivered-To: binutils@sourceware.org Received: from mail.loongson.cn (mail.loongson.cn [114.242.206.163]) by sourceware.org (Postfix) with ESMTP id 10F753858D20 for ; Mon, 30 Oct 2023 09:07:15 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 10F753858D20 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 10F753858D20 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=1698656839; cv=none; b=iKcN5VeTY7i3JtOmphUaur7Ii6QwPUSIYCroNBfdebkBsiAm82wOQZ9lVpqxZ0KlobL3j2a5oHs6T5uoP6UN6DUEJ345/D2yoKfk/8F/Brjo1inXDRxmqfRxA/7qDV0f0eirPdvf6YWWsJEriQc0uee+aloRaj+rJoWJBjKVVog= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698656839; c=relaxed/simple; bh=445/1Ayv8FPg4ovAne/ZytXh/i7PlSY69RvZRfojxb8=; h=From:To:Subject:Date:Message-Id:MIME-Version; b=vLjChTCqJuYqdajS7jbpCCFYX9+xrd3MvNRpv7LwzvZIWb0Bgg78+fQD5kYIoVR+FPv32llfxYzW6yv6VbOwiGFIRHL4wffSdBCS3sqgMxjCB0QznAQL6XHwL17f9l9zYlL08WEEO17p3dskl+e0XUX35djz4AXMdcKY8le2r0g= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from loongson.cn (unknown [10.2.6.5]) by gateway (Coremail) with SMTP id _____8BxY_A+cj9lErU1AA--.39434S3; Mon, 30 Oct 2023 17:07:10 +0800 (CST) Received: from 5.5.5 (unknown [10.2.6.5]) by localhost.localdomain (Coremail) with SMTP id AQAAf8CxbS89cj9lzuY2AA--.52445S4; Mon, 30 Oct 2023 17:07:10 +0800 (CST) From: Lulu Cai To: binutils@sourceware.org Cc: xuchenghua@loongson.cn, chenglulu@loongson.cn, liuzhensong@loongson.cn, mengqinggang@loongson.cn, xry111@xry111.site, i.swmail@xen0n.name, maskray@google.com, yangtiezhu@loongson.cn, Lulu Cai Subject: [PATCH] Add support for ilp32 register alias. Date: Mon, 30 Oct 2023 17:07:08 +0800 Message-Id: <20231030090708.2006370-1-cailulu@loongson.cn> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CM-TRANSID: AQAAf8CxbS89cj9lzuY2AA--.52445S4 X-CM-SenderInfo: xfdlz3tox6z05rqj20fqof0/1tbiAQAAB2U-EqcEhQABsp X-Coremail-Antispam: 1Uk129KBj93XoWxtw4DAry8uw18Cw1kGw4UGFX_yoW3JFyDpF 9rZrnxtr1rGFnaqrnrC345W34DXrnrWr12qF4akF1xurs8X3srZr48JFyv9F13K3yUWrWj qFW8W3WUZF1UGFXCm3ZEXasCq-sJn29KB7ZKAUJUUUU5529EdanIXcx71UUUUU7KY7ZEXa sCq-sGcSsGvfJ3Ic02F40EFcxC0VAKzVAqx4xG6I80ebIjqfuFe4nvWSU5nxnvy29KBjDU 0xBIdaVrnRJUUUkFb4IE77IF4wAFF20E14v26r1j6r4UM7CY07I20VC2zVCF04k26cxKx2 IYs7xG6rWj6s0DM7CIcVAFz4kK6r106r15M28lY4IEw2IIxxk0rwA2F7IY1VAKz4vEj48v e4kI8wA2z4x0Y4vE2Ix0cI8IcVAFwI0_JFI_Gr1l84ACjcxK6xIIjxv20xvEc7CjxVAFwI 0_Jr0_Gr1l84ACjcxK6I8E87Iv67AKxVW8Jr0_Cr1UM28EF7xvwVC2z280aVCY1x0267AK xVW8Jr0_Cr1UM2AIxVAIcxkEcVAq07x20xvEncxIr21l57IF6xkI12xvs2x26I8E6xACxx 1l5I8CrVACY4xI64kE6c02F40Ex7xfMcIj6xIIjxv20xvE14v26r1Y6r17McIj6I8E87Iv 67AKxVWUJVW8JwAm72CE4IkC6x0Yz7v_Jr0_Gr1lF7xvr2IYc2Ij64vIr41l42xK82IYc2 Ij64vIr41l4I8I3I0E4IkC6x0Yz7v_Jr0_Gr1lx2IqxVAqx4xG67AKxVWUJVWUGwC20s02 6x8GjcxK67AKxVWUGVWUWwC2zVAF1VAY17CE14v26r1q6r43MIIYrxkI7VAKI48JMIIF0x vE2Ix0cI8IcVAFwI0_Jr0_JF4lIxAIcVC0I7IYx2IY6xkF7I0E14v26r1j6r4UMIIF0xvE 42xK8VAvwI8IcIk0rVWUJVWUCwCI42IY6I8E87Iv67AKxVWUJVW8JwCI42IY6I8E87Iv6x kF7I0E14v26r1j6r4UYxBIdaVFxhVjvjDU0xZFpf9x07j1YL9UUUUU= X-Spam-Status: No, score=-13.7 required=5.0 tests=BAYES_00, GIT_PATCH_0, KAM_DMARC_STATUS, SPF_HELO_NONE, 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: binutils@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Binutils mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: binutils-bounces+ouuuleilei=gmail.com@sourceware.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781170801252437593 X-GMAIL-MSGID: 1781170801252437593 --- gas/config/tc-loongarch.c | 41 +++++++++++++++++--------------------- gdb/loongarch-tdep.c | 12 +++++------ include/opcode/loongarch.h | 8 ++++---- opcodes/loongarch-dis.c | 4 ++-- opcodes/loongarch-opc.c | 8 ++++---- 5 files changed, 34 insertions(+), 39 deletions(-) diff --git a/gas/config/tc-loongarch.c b/gas/config/tc-loongarch.c index 33f3e71ce2f..d1ce111c186 100644 --- a/gas/config/tc-loongarch.c +++ b/gas/config/tc-loongarch.c @@ -303,6 +303,15 @@ loongarch_after_parse_args () for (i = 0; i < ARRAY_SIZE (loongarch_r_normal_name); i++) str_hash_insert (r_htab, loongarch_r_normal_name[i], (void *) (i + 1), 0); + /* Init ilp32/lp64 registers alias. */ + r_abi_names = loongarch_r_alias; + for (i = 0; i < ARRAY_SIZE (loongarch_r_alias); i++) + str_hash_insert (r_htab, loongarch_r_alias[i], (void *) (i + 1), + 0); + for (i = 0; i < ARRAY_SIZE (loongarch_r_alias_deprecated); i++) + str_hash_insert (r_deprecated_htab, loongarch_r_alias_deprecated[i], + (void *) (i + 1), 0); + if (!cr_htab) cr_htab = str_htab_create (), str_hash_insert (cr_htab, "", 0, 0); @@ -323,6 +332,15 @@ loongarch_after_parse_args () str_hash_insert (f_htab, loongarch_f_normal_name[i], (void *) (i + 1), 0); + /* Init float-ilp32/lp64 registers alias. */ + f_abi_names = loongarch_f_alias; + for (i = 0; i < ARRAY_SIZE (loongarch_f_alias); i++) + str_hash_insert (f_htab, loongarch_f_alias[i], + (void *) (i + 1), 0); + for (i = 0; i < ARRAY_SIZE (loongarch_f_alias_deprecated); i++) + str_hash_insert (f_deprecated_htab, loongarch_f_alias_deprecated[i], + (void *) (i + 1), 0); + if (!fc_htab) fc_htab = str_htab_create (), str_hash_insert (fc_htab, "", 0, 0); @@ -366,29 +384,6 @@ loongarch_after_parse_args () 0); } - /* Init lp64 registers alias. */ - if (LARCH_opts.ase_lp64) - { - r_abi_names = loongarch_r_lp64_name; - for (i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name); i++) - str_hash_insert (r_htab, loongarch_r_lp64_name[i], (void *) (i + 1), - 0); - for (i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name_deprecated); i++) - str_hash_insert (r_deprecated_htab, loongarch_r_lp64_name_deprecated[i], - (void *) (i + 1), 0); - } - - /* Init float-lp64 registers alias */ - if ((LARCH_opts.ase_sf || LARCH_opts.ase_df) && LARCH_opts.ase_lp64) - { - f_abi_names = loongarch_f_lp64_name; - for (i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name); i++) - str_hash_insert (f_htab, loongarch_f_lp64_name[i], - (void *) (i + 1), 0); - for (i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name_deprecated); i++) - str_hash_insert (f_deprecated_htab, loongarch_f_lp64_name_deprecated[i], - (void *) (i + 1), 0); - } } const char * diff --git a/gdb/loongarch-tdep.c b/gdb/loongarch-tdep.c index c65e2414bf8..f7d08c60a58 100644 --- a/gdb/loongarch-tdep.c +++ b/gdb/loongarch-tdep.c @@ -1774,15 +1774,15 @@ loongarch_gdbarch_init (struct gdbarch_info info, struct gdbarch_list *arches) info.target_desc = tdesc; info.tdesc_data = tdesc_data.get (); - for (int i = 0; i < ARRAY_SIZE (loongarch_r_lp64_name); ++i) - if (loongarch_r_lp64_name[i][0] != '\0') - user_reg_add (gdbarch, loongarch_r_lp64_name[i] + 1, + for (int i = 0; i < ARRAY_SIZE (loongarch_r_alias); ++i) + if (loongarch_r_alias[i][0] != '\0') + user_reg_add (gdbarch, loongarch_r_alias[i] + 1, value_of_loongarch_user_reg, (void *) (size_t) i); - for (int i = 0; i < ARRAY_SIZE (loongarch_f_lp64_name); ++i) + for (int i = 0; i < ARRAY_SIZE (loongarch_f_alias); ++i) { - if (loongarch_f_lp64_name[i][0] != '\0') - user_reg_add (gdbarch, loongarch_f_lp64_name[i] + 1, + if (loongarch_f_alias[i][0] != '\0') + user_reg_add (gdbarch, loongarch_f_alias[i] + 1, value_of_loongarch_user_reg, (void *) (size_t) (LOONGARCH_FIRST_FP_REGNUM + i)); } diff --git a/include/opcode/loongarch.h b/include/opcode/loongarch.h index f358ff429e4..da936f7945a 100644 --- a/include/opcode/loongarch.h +++ b/include/opcode/loongarch.h @@ -189,11 +189,11 @@ dec2 : [1-9][0-9]? extern void loongarch_eliminate_adjacent_repeat_char (char *dest, char c); extern const char *const loongarch_r_normal_name[32]; - extern const char *const loongarch_r_lp64_name[32]; - extern const char *const loongarch_r_lp64_name_deprecated[32]; + extern const char *const loongarch_r_alias[32]; + extern const char *const loongarch_r_alias_deprecated[32]; extern const char *const loongarch_f_normal_name[32]; - extern const char *const loongarch_f_lp64_name[32]; - extern const char *const loongarch_f_lp64_name_deprecated[32]; + extern const char *const loongarch_f_alias[32]; + extern const char *const loongarch_f_alias_deprecated[32]; extern const char *const loongarch_fc_normal_name[4]; extern const char *const loongarch_fc_numeric_name[4]; extern const char *const loongarch_c_normal_name[8]; diff --git a/opcodes/loongarch-dis.c b/opcodes/loongarch-dis.c index 1e711f27415..969ea28f96f 100644 --- a/opcodes/loongarch-dis.c +++ b/opcodes/loongarch-dis.c @@ -82,8 +82,8 @@ set_default_loongarch_dis_options (void) LARCH_opts.ase_lvz = 1; LARCH_opts.ase_lbt = 1; - loongarch_r_disname = loongarch_r_lp64_name; - loongarch_f_disname = loongarch_f_lp64_name; + loongarch_r_disname = loongarch_r_alias; + loongarch_f_disname = loongarch_f_alias; loongarch_fc_disname = loongarch_fc_normal_name; loongarch_c_disname = loongarch_c_normal_name; loongarch_cr_disname = loongarch_cr_normal_name; diff --git a/opcodes/loongarch-opc.c b/opcodes/loongarch-opc.c index 362b6581c76..82b88bdad2a 100644 --- a/opcodes/loongarch-opc.c +++ b/opcodes/loongarch-opc.c @@ -41,7 +41,7 @@ const char *const loongarch_r_normal_name[32] = "$r24", "$r25", "$r26", "$r27", "$r28", "$r29", "$r30", "$r31", }; -const char *const loongarch_r_lp64_name[32] = +const char *const loongarch_r_alias[32] = { "$zero", "$ra", "$tp", "$sp", "$a0", "$a1", "$a2", "$a3", "$a4", "$a5", "$a6", "$a7", "$t0", "$t1", "$t2", "$t3", @@ -49,7 +49,7 @@ const char *const loongarch_r_lp64_name[32] = "$s1", "$s2", "$s3", "$s4", "$s5", "$s6", "$s7", "$s8", }; -const char *const loongarch_r_lp64_name_deprecated[32] = +const char *const loongarch_r_alias_deprecated[32] = { "", "", "", "", "$v0", "$v1", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "$x", "", "", "", "", "", "", "", "", "", "", @@ -63,7 +63,7 @@ const char *const loongarch_f_normal_name[32] = "$f24", "$f25", "$f26", "$f27", "$f28", "$f29", "$f30", "$f31", }; -const char *const loongarch_f_lp64_name[32] = +const char *const loongarch_f_alias[32] = { "$fa0", "$fa1", "$fa2", "$fa3", "$fa4", "$fa5", "$fa6", "$fa7", "$ft0", "$ft1", "$ft2", "$ft3", "$ft4", "$ft5", "$ft6", "$ft7", @@ -71,7 +71,7 @@ const char *const loongarch_f_lp64_name[32] = "$fs0", "$fs1", "$fs2", "$fs3", "$fs4", "$fs5", "$fs6", "$fs7", }; -const char *const loongarch_f_lp64_name_deprecated[32] = +const char *const loongarch_f_alias_deprecated[32] = { "$fv0", "$fv1", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "", "",