From: Dmitry Selyutin <ghostmansd@gmail.com>
To: binutils@sourceware.org
Cc: Alan Modra <amodra@gmail.com>,
Luke Leighton <luke.leighton@gmail.com>,
Jan Beulich <jbeulich@suse.com>,
Dmitry Selyutin <ghostmansd@gmail.com>
Subject: [PATCH] ppc: use reg_name_search for CFI register lookup
Date: Thu, 14 Jul 2022 09:05:18 +0300 [thread overview]
Message-ID: <20220714060518.170611-1-ghostmansd@gmail.com> (raw)
In-Reply-To: <CAMqzjeufQbWEkkU0OdD0L5h1EmkkCZCz0xhTz9fUsZENRkwwkw@mail.gmail.com>
---
gas/config/tc-ppc.c | 37 +++++++++++++++----------------------
1 file changed, 15 insertions(+), 22 deletions(-)
diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c
index 05d8ee19be..765eb3fa2f 100644
--- a/gas/config/tc-ppc.c
+++ b/gas/config/tc-ppc.c
@@ -7715,10 +7715,8 @@ ppc_cfi_frame_initial_instructions (void)
int
tc_ppc_regname_to_dw2regnum (char *regname)
{
- unsigned int regnum = -1;
unsigned int i;
- const char *p;
- char *q;
+ const struct pd_reg *reg;
static struct { const char *name; int dw2regnum; } regnames[] =
{
{ "sp", 1 }, { "r.sp", 1 }, { "rtoc", 2 }, { "r.toc", 2 },
@@ -7731,23 +7729,18 @@ tc_ppc_regname_to_dw2regnum (char *regname)
if (strcmp (regnames[i].name, regname) == 0)
return regnames[i].dw2regnum;
- if (regname[0] == 'r' || regname[0] == 'f' || regname[0] == 'v')
- {
- p = regname + 1 + (regname[1] == '.');
- regnum = strtoul (p, &q, 10);
- if (p == q || *q || regnum >= 32)
- return -1;
- if (regname[0] == 'f')
- regnum += 32;
- else if (regname[0] == 'v')
- regnum += 77;
- }
- else if (regname[0] == 'c' && regname[1] == 'r')
- {
- p = regname + 2 + (regname[2] == '.');
- if (p[0] < '0' || p[0] > '7' || p[1])
- return -1;
- regnum = p[0] - '0' + 68;
- }
- return regnum;
+ if (regname[0] == '%' && ISALPHA (regname[1]))
+ ++regname;
+
+ reg = reg_name_search (pre_defined_registers,
+ ARRAY_SIZE (pre_defined_registers), regname);
+
+ if ((reg != NULL) &&
+ (((reg->flags & PPC_OPERAND_GPR) == PPC_OPERAND_GPR) ||
+ ((reg->flags & PPC_OPERAND_FPR) == PPC_OPERAND_FPR) ||
+ ((reg->flags & PPC_OPERAND_VR) == PPC_OPERAND_VR) ||
+ ((reg->flags & PPC_OPERAND_CR_REG) == PPC_OPERAND_CR_REG)))
+ return reg->value;
+
+ return -1;
}
--
2.37.0
next prev parent reply other threads:[~2022-07-14 6:05 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-07-12 13:50 [PATCH 0/1] ppc: support register names in macros Dmitry Selyutin
2022-07-12 13:50 ` [PATCH 1/1] " Dmitry Selyutin
2022-07-12 14:13 ` Dmitry Selyutin
2022-07-12 14:18 ` lkcl
2022-07-12 14:24 ` Dmitry Selyutin
2022-07-12 21:22 ` [PATCH v2 0/1] " Dmitry Selyutin
2022-07-12 21:22 ` [PATCH v2 1/1] " Dmitry Selyutin
2022-07-12 21:29 ` [PATCH v3 0/1] " Dmitry Selyutin
2022-07-12 21:29 ` [PATCH v3 1/1] " Dmitry Selyutin
2022-07-13 15:34 ` Alan Modra
2022-07-14 6:03 ` PowerPC: implement md_operand to parse register names Alan Modra
2022-07-14 6:04 ` [PATCH v3 1/1] ppc: support register names in macros Dmitry Selyutin
2022-07-14 6:05 ` Dmitry Selyutin [this message]
2022-07-14 7:25 ` [PATCH] ppc: use reg_name_search for CFI register lookup Alan Modra
2022-07-14 8:21 ` [PATCH v2] " Dmitry Selyutin
2022-07-14 23:01 ` Alan Modra
2022-07-14 8:23 ` [PATCH] " Dmitry Selyutin
2022-07-14 8:25 ` Dmitry Selyutin
2022-07-14 23:02 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220714060518.170611-1-ghostmansd@gmail.com \
--to=ghostmansd@gmail.com \
--cc=amodra@gmail.com \
--cc=binutils@sourceware.org \
--cc=jbeulich@suse.com \
--cc=luke.leighton@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).