Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [rfc] Replace x86 register macros
@ 2008-02-18 20:42 Markus Deuling
  2008-02-19 15:45 ` Ulrich Weigand
  0 siblings, 1 reply; 9+ messages in thread
From: Markus Deuling @ 2008-02-18 20:42 UTC (permalink / raw)
  To: GDB Patches; +Cc: Ulrich Weigand

[-- 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

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-03-11  5:23 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-02-18 20:42 [rfc] Replace x86 register macros Markus Deuling
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox