From: Anton Kolesov <Anton.Kolesov@synopsys.com>
To: gdb-patches@sourceware.org
Cc: Anton Kolesov <Anton.Kolesov@synopsys.com>,
Francois Bedard <Francois.Bedard@synopsys.com>
Subject: [PATCH 1/5] arc: Align internal regnums with architectural regnums
Date: Tue, 14 Feb 2017 10:01:00 -0000 [thread overview]
Message-ID: <20170214100130.29194-1-Anton.Kolesov@synopsys.com> (raw)
Add ARC_LIMM_REGNUM to arc_regnum enumeration and assign a number 62 to it.
This ensures that for core registers internal register numbers in this enum are
the same as architectural numbers. This allows to use internal register
numbers in the contexts where architectural number is implied, for example when
disassembling instruction during prologue analysis.
gdb/ChangeLog:
yyyy-mm-dd Anton Kolesov <anton.kolesov@synopsys.com>
* arc-tdep.c (core_v2_register_names, core_arcompact_register_names)
Add "limm" and "reserved".
(arc_cannot_fetch_register, arc_cannot_store_register): Add
ARC_RESERVED_REGNUM and ARC_LIMM_REGNUM.
* arc-tdep.h (arc_regnum): Likewise.
---
gdb/arc-tdep.c | 28 +++++++++++++++++++++-------
gdb/arc-tdep.h | 16 ++++++++++++++++
2 files changed, 37 insertions(+), 7 deletions(-)
diff --git a/gdb/arc-tdep.c b/gdb/arc-tdep.c
index 0800d7b..f78e3a9 100644
--- a/gdb/arc-tdep.c
+++ b/gdb/arc-tdep.c
@@ -86,7 +86,7 @@ static const char *const core_v2_register_names[] = {
"r48", "r49", "r50", "r51",
"r52", "r53", "r54", "r55",
"r56", "r57", "accl", "acch",
- "lp_count", "pcl",
+ "lp_count", "reserved", "limm", "pcl",
};
static const char *const aux_minimal_register_names[] = {
@@ -109,7 +109,7 @@ static const char *const core_arcompact_register_names[] = {
"r48", "r49", "r50", "r51",
"r52", "r53", "r54", "r55",
"r56", "r57", "r58", "r59",
- "lp_count", "pcl",
+ "lp_count", "reserved", "limm", "pcl",
};
/* Implement the "write_pc" gdbarch method.
@@ -430,8 +430,19 @@ arc_push_dummy_code (struct gdbarch *gdbarch, CORE_ADDR sp, CORE_ADDR funaddr,
static int
arc_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
{
- /* Assume that register is readable if it is unknown. */
- return FALSE;
+ /* Assume that register is readable if it is unknown. LIMM and RESERVED are
+ not real registers, but specific register numbers. They are available as
+ regnums to align architectural register numbers with GDB internal regnums,
+ but they shouldn't appear in target descriptions generated by
+ GDB-servers. */
+ switch (regnum)
+ {
+ case ARC_RESERVED_REGNUM:
+ case ARC_LIMM_REGNUM:
+ return true;
+ default:
+ return false;
+ }
}
/* Implement the "cannot_store_register" gdbarch method. */
@@ -439,13 +450,16 @@ arc_cannot_fetch_register (struct gdbarch *gdbarch, int regnum)
static int
arc_cannot_store_register (struct gdbarch *gdbarch, int regnum)
{
- /* Assume that register is writable if it is unknown. */
+ /* Assume that register is writable if it is unknown. See comment in
+ arc_cannot_fetch_register about LIMM and RESERVED. */
switch (regnum)
{
+ case ARC_RESERVED_REGNUM:
+ case ARC_LIMM_REGNUM:
case ARC_PCL_REGNUM:
- return TRUE;
+ return true;
default:
- return FALSE;
+ return false;
}
}
diff --git a/gdb/arc-tdep.h b/gdb/arc-tdep.h
index 422db46..326f486 100644
--- a/gdb/arc-tdep.h
+++ b/gdb/arc-tdep.h
@@ -24,6 +24,12 @@
/* Need disassemble_info. */
#include "dis-asm.h"
+/* To simplify GDB code this enum assumes that internal regnums should be same
+ as architectural register numbers, i.e. PCL regnum is 63. This allows to
+ use internal GDB regnums as architectural numbers when dealing with
+ instruction encodings, for example when analyzing what are the registers
+ saved in function prologue. */
+
enum arc_regnum
{
/* Core registers. */
@@ -49,6 +55,16 @@ enum arc_regnum
ARC_BLINK_REGNUM,
/* Zero-delay loop counter. */
ARC_LP_COUNT_REGNUM = 60,
+ /* Reserved register number. There should never be a register with such
+ number, this name is needed only for a sanity check in
+ arc_cannot_(fetch|store)_register. */
+ ARC_RESERVED_REGNUM,
+ /* Long-immediate value. This is not a physical register - if instruction
+ has register 62 as an operand, then this operand is a literal value
+ stored in the instruction memory right after the instruction itself.
+ This value is required in this enumeration as an architectural number
+ for instruction analysis. */
+ ARC_LIMM_REGNUM,
/* Program counter, aligned to 4-bytes, read-only. */
ARC_PCL_REGNUM,
ARC_LAST_CORE_REGNUM = ARC_PCL_REGNUM,
--
2.8.3
next reply other threads:[~2017-02-14 10:01 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-02-14 10:01 Anton Kolesov [this message]
2017-02-14 10:01 ` [PATCH 4/5] arc: Add disassembler helper Anton Kolesov
2017-02-14 15:50 ` Eli Zaretskii
2017-02-17 13:00 ` Pedro Alves
2017-02-17 13:01 ` Pedro Alves
2017-02-14 10:01 ` [PATCH 5/5] arc: Add prologue analysis Anton Kolesov
2017-02-14 15:51 ` Eli Zaretskii
2017-02-17 13:25 ` Pedro Alves
2017-03-15 15:18 ` [PATCH 5/5 v2] " Anton Kolesov
2017-03-15 15:59 ` Eli Zaretskii
2017-03-27 14:20 ` Anton Kolesov
2017-03-28 13:28 ` Pedro Alves
2017-02-14 10:01 ` [PATCH 2/5] arc: Set section to ".text" when disassembling Anton Kolesov
2017-02-15 22:27 ` Yao Qi
2017-02-16 16:35 ` Anton Kolesov
2017-02-17 12:31 ` Pedro Alves
2017-03-15 15:16 ` Anton Kolesov
2017-02-14 10:01 ` [PATCH 3/5] arc: Add "maintenance print arc" command prefix Anton Kolesov
2017-02-17 13:02 ` Pedro Alves
2017-02-17 13:26 ` [PATCH 1/5] arc: Align internal regnums with architectural regnums Pedro Alves
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=20170214100130.29194-1-Anton.Kolesov@synopsys.com \
--to=anton.kolesov@synopsys.com \
--cc=Francois.Bedard@synopsys.com \
--cc=gdb-patches@sourceware.org \
/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