This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[rfc] Replace x86 register macros
- From: Markus Deuling <deuling at de dot ibm dot com>
- To: GDB Patches <gdb-patches at sourceware dot org>
- Cc: Ulrich Weigand <uweigand at de dot ibm dot com>
- Date: Mon, 18 Feb 2008 21:39:55 +0100
- Subject: [rfc] Replace x86 register macros
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
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