From: Markus Deuling <deuling@de.ibm.com>
To: GDB Patches <gdb-patches@sourceware.org>
Cc: Ulrich Weigand <uweigand@de.ibm.com>
Subject: [rfc] Replace x86 register macros
Date: Mon, 18 Feb 2008 20:42:00 -0000 [thread overview]
Message-ID: <47B9ED1B.7070303@de.ibm.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 1055 bytes --]
Hi,
in some places used by x86/amd64 architecture there is a weird mechanism to
get at the number of registers or the registers themselves which make the code hard to
read.
One example is i386_sse_regnum_p in i386-tdep.c where two macros I387_ST0_REGNUM and
I387_NUM_XMM_REGS have to be defined so that other two macros I387_XMM0_REGNUM and
I387_MXCSR_REGNUM are valid.
What I'd like to do is to unknot this source to make it more readable. For my opinion
it is bad practice to define and undef macros per funtion in a source file describing a target.
What do you think about this in general and about this patch in special? If this would be a way to
go I'd like to commit this patch and come up with a bigger one to handle some more of these.
Testsuite on x86 showed no regression.
ChangeLog:
* i386-tdep.c (i386_sse_regnum_p): Replace I387_XMM0_REGNUM and
I387_MXCSR_REGNUM by its expressions. Remove I387_ST0_REGNUM and
I387_NUM_XMM_REGS.
Regards,
Markus
--
Markus Deuling
GNU Toolchain for Linux on Cell BE
deuling@de.ibm.com
[-- Attachment #2: diff-i386 --]
[-- Type: text/plain, Size: 751 bytes --]
diff -urpN src/gdb/i386-tdep.c dev/gdb/i386-tdep.c
--- src/gdb/i386-tdep.c 2008-01-27 06:30:37.000000000 +0100
+++ dev/gdb/i386-tdep.c 2008-02-18 21:26:40.000000000 +0100
@@ -96,16 +96,9 @@ i386_sse_regnum_p (struct gdbarch *gdbar
{
struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
-#define I387_ST0_REGNUM tdep->st0_regnum
-#define I387_NUM_XMM_REGS tdep->num_xmm_regs
-
- if (I387_NUM_XMM_REGS == 0)
- return 0;
-
- return (I387_XMM0_REGNUM <= regnum && regnum < I387_MXCSR_REGNUM);
-
-#undef I387_ST0_REGNUM
-#undef I387_NUM_XMM_REGS
+ /* True if REGNUM in [st0_regnum + 16, st0_regnum + 16 + num_xmm_regs). */
+ return (regnum >= tdep->st0_regnum + 16
+ && regnum < tdep->st0_regnum + 16 + tdep->num_xmm_regs);
}
static int
next reply other threads:[~2008-02-18 20:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-02-18 20:42 Markus Deuling [this message]
2008-02-19 15:45 ` Ulrich Weigand
2008-02-19 16:21 ` Daniel Jacobowitz
2008-02-20 16:45 ` Markus Deuling
2008-03-04 0:32 ` Ulrich Weigand
2008-03-10 6:58 ` Markus Deuling
2008-03-10 12:13 ` Ulrich Weigand
2008-03-10 12:23 ` Mark Kettenis
2008-03-11 5:23 ` Markus Deuling
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=47B9ED1B.7070303@de.ibm.com \
--to=deuling@de.ibm.com \
--cc=gdb-patches@sourceware.org \
--cc=uweigand@de.ibm.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