Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Cc: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>,
	Mark Kettenis <mark.kettenis@xs4all.nl>
Subject: [commit 4/4] Revert use of classify callback in i386 gdbarch_tdep.
Date: Tue, 24 Sep 2013 16:33:00 -0000	[thread overview]
Message-ID: <1380040404-16932-5-git-send-email-brobecker@adacore.com> (raw)
In-Reply-To: <1380040404-16932-1-git-send-email-brobecker@adacore.com>

This is no longer useful, as it was introduced to reuse the funcall
handling code in amd64-tdep.c in the context of x64-windows. But
we have since then changed the implementations to be completely
independent of each other.

This reverts the non-windows-specific part of the change called:
    amd64: Integer parameters in function calls on Windows
(the x64-windows portion has already been reverted)

gdb/ChangeLog:

	Revert:
	* i386-tdep.h (enum amd64_reg_class): New, moved here from
	amd64-tdep.c.
	(struct gdbarch_tdep): Add fields call_dummy_num_integer_regs,
	call_dummy_integer_regs, and classify.
	* amd64-tdep.h (amd64_classify): Add declaration.
	* amd64-tdep.c (amd64_dummy_call_integer_regs): New static constant.
	(amd64_reg_class): Delete, moved to i386-tdep.h.
	(amd64_classify): Make non-static.  Move declaration to amd64-tdep.h.
	Replace call to amd64_classify by call to tdep->classify.
	(amd64_push_arguments): Get the list of registers to use for
	passing integer parameters from the gdbarch tdep structure,
	rather than using a hardcoded one.  Replace calls to amd64_classify
	by calls to tdep->classify.
	(amd64_push_dummy_call): Get the register number used for
	the "hidden" argument from tdep->call_dummy_integer_regs.
	(amd64_init_abi): Initialize tdep->call_dummy_num_integer_regs
	and tdep->call_dummy_integer_regs.  Set tdep->classify.

Tested on x86_64-linux, checked in.

---
 gdb/ChangeLog    | 21 ++++++++++++++++++
 gdb/amd64-tdep.c | 65 +++++++++++++++++++++++++++-----------------------------
 gdb/amd64-tdep.h |  4 ----
 gdb/i386-tdep.h  | 24 ---------------------
 4 files changed, 52 insertions(+), 62 deletions(-)

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index cd03e31..9d42eec 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,6 +1,27 @@
 2013-09-24  Joel Brobecker  <brobecker@adacore.com>
 
 	Revert:
+	* i386-tdep.h (enum amd64_reg_class): New, moved here from
+	amd64-tdep.c.
+	(struct gdbarch_tdep): Add fields call_dummy_num_integer_regs,
+	call_dummy_integer_regs, and classify.
+	* amd64-tdep.h (amd64_classify): Add declaration.
+	* amd64-tdep.c (amd64_dummy_call_integer_regs): New static constant.
+	(amd64_reg_class): Delete, moved to i386-tdep.h.
+	(amd64_classify): Make non-static.  Move declaration to amd64-tdep.h.
+	Replace call to amd64_classify by call to tdep->classify.
+	(amd64_push_arguments): Get the list of registers to use for
+	passing integer parameters from the gdbarch tdep structure,
+	rather than using a hardcoded one.  Replace calls to amd64_classify
+	by calls to tdep->classify.
+	(amd64_push_dummy_call): Get the register number used for
+	the "hidden" argument from tdep->call_dummy_integer_regs.
+	(amd64_init_abi): Initialize tdep->call_dummy_num_integer_regs
+	and tdep->call_dummy_integer_regs.  Set tdep->classify.
+
+2013-09-24  Joel Brobecker  <brobecker@adacore.com>
+
+	Revert:
 	* i386-tdep.h (gdbarch_tdep): Add field memory_args_by_pointer.
 	* amd64-tdep.c (amd64_push_arguments): Add handling of architectures
 	where tdep->memory_args_by_pointer is non-zero.
diff --git a/gdb/amd64-tdep.c b/gdb/amd64-tdep.c
index 35526cf..37218ce 100644
--- a/gdb/amd64-tdep.c
+++ b/gdb/amd64-tdep.c
@@ -92,17 +92,6 @@ static const char *amd64_ymmh_names[] =
   "ymm12h", "ymm13h", "ymm14h", "ymm15h"
 };
 
-/* The registers used to pass integer arguments during a function call.  */
-static int amd64_dummy_call_integer_regs[] =
-{
-  AMD64_RDI_REGNUM,		/* %rdi */
-  AMD64_RSI_REGNUM,		/* %rsi */
-  AMD64_RDX_REGNUM,		/* %rdx */
-  AMD64_RCX_REGNUM,		/* %rcx */
-  8,				/* %r8 */
-  9				/* %r9 */
-};
-
 /* DWARF Register Number Mapping as defined in the System V psABI,
    section 3.6.  */
 
@@ -391,6 +380,20 @@ amd64_pseudo_register_write (struct gdbarch *gdbarch,
 
 \f
 
+/* Register classes as defined in the psABI.  */
+
+enum amd64_reg_class
+{
+  AMD64_INTEGER,
+  AMD64_SSE,
+  AMD64_SSEUP,
+  AMD64_X87,
+  AMD64_X87UP,
+  AMD64_COMPLEX_X87,
+  AMD64_NO_CLASS,
+  AMD64_MEMORY
+};
+
 /* Return the union class of CLASS1 and CLASS2.  See the psABI for
    details.  */
 
@@ -427,6 +430,8 @@ amd64_merge_classes (enum amd64_reg_class class1, enum amd64_reg_class class2)
   return AMD64_SSE;
 }
 
+static void amd64_classify (struct type *type, enum amd64_reg_class class[2]);
+
 /* Return non-zero if TYPE is a non-POD structure or union type.  */
 
 static int
@@ -546,7 +551,7 @@ amd64_classify_aggregate (struct type *type, enum amd64_reg_class class[2])
 
 /* Classify TYPE, and store the result in CLASS.  */
 
-void
+static void
 amd64_classify (struct type *type, enum amd64_reg_class class[2])
 {
   enum type_code code = TYPE_CODE (type);
@@ -614,7 +619,6 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
 		    struct type *type, struct regcache *regcache,
 		    gdb_byte *readbuf, const gdb_byte *writebuf)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   enum amd64_reg_class class[2];
   int len = TYPE_LENGTH (type);
   static int integer_regnum[] = { AMD64_RAX_REGNUM, AMD64_RDX_REGNUM };
@@ -624,10 +628,9 @@ amd64_return_value (struct gdbarch *gdbarch, struct value *function,
   int i;
 
   gdb_assert (!(readbuf && writebuf));
-  gdb_assert (tdep->classify);
 
   /* 1. Classify the return type with the classification algorithm.  */
-  tdep->classify (type, class);
+  amd64_classify (type, class);
 
   /* 2. If the type has class MEMORY, then the caller provides space
      for the return value and passes the address of this storage in
@@ -749,10 +752,15 @@ static CORE_ADDR
 amd64_push_arguments (struct regcache *regcache, int nargs,
 		      struct value **args, CORE_ADDR sp, int struct_return)
 {
-  struct gdbarch_tdep *tdep = gdbarch_tdep (get_regcache_arch (regcache));
-  int *integer_regs = tdep->call_dummy_integer_regs;
-  int num_integer_regs = tdep->call_dummy_num_integer_regs;
-
+  static int integer_regnum[] =
+  {
+    AMD64_RDI_REGNUM,		/* %rdi */
+    AMD64_RSI_REGNUM,		/* %rsi */
+    AMD64_RDX_REGNUM,		/* %rdx */
+    AMD64_RCX_REGNUM,		/* %rcx */
+    8,				/* %r8 */
+    9				/* %r9 */
+  };
   static int sse_regnum[] =
   {
     /* %xmm0 ... %xmm7 */
@@ -769,8 +777,6 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
   int sse_reg = 0;
   int i;
 
-  gdb_assert (tdep->classify);
-
   /* Reserve a register for the "hidden" argument.  */
   if (struct_return)
     integer_reg++;
@@ -785,7 +791,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
       int j;
 
       /* Classify argument.  */
-      tdep->classify (type, class);
+      amd64_classify (type, class);
 
       /* Calculate the number of integer and SSE registers needed for
          this argument.  */
@@ -799,7 +805,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
 
       /* Check whether enough registers are available, and if the
          argument should be passed in registers at all.  */
-      if (integer_reg + needed_integer_regs > num_integer_regs
+      if (integer_reg + needed_integer_regs > ARRAY_SIZE (integer_regnum)
 	  || sse_reg + needed_sse_regs > ARRAY_SIZE (sse_regnum)
 	  || (needed_integer_regs == 0 && needed_sse_regs == 0))
 	{
@@ -823,7 +829,7 @@ amd64_push_arguments (struct regcache *regcache, int nargs,
 	      switch (class[j])
 		{
 		case AMD64_INTEGER:
-		  regnum = integer_regs[integer_reg++];
+		  regnum = integer_regnum[integer_reg++];
 		  break;
 
 		case AMD64_SSE:
@@ -881,7 +887,6 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
 		       int struct_return, CORE_ADDR struct_addr)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (gdbarch);
-  struct gdbarch_tdep *tdep = gdbarch_tdep (gdbarch);
   gdb_byte buf[8];
 
   /* Pass arguments.  */
@@ -890,12 +895,8 @@ amd64_push_dummy_call (struct gdbarch *gdbarch, struct value *function,
   /* Pass "hidden" argument".  */
   if (struct_return)
     {
-      /* The "hidden" argument is passed throught the first argument
-         register.  */
-      const int arg_regnum = tdep->call_dummy_integer_regs[0];
-
       store_unsigned_integer (buf, 8, byte_order, struct_addr);
-      regcache_cooked_write (regcache, arg_regnum, buf);
+      regcache_cooked_write (regcache, AMD64_RDI_REGNUM, buf);
     }
 
   /* Store return address.  */
@@ -2888,10 +2889,6 @@ amd64_init_abi (struct gdbarch_info info, struct gdbarch *gdbarch)
   set_gdbarch_push_dummy_call (gdbarch, amd64_push_dummy_call);
   set_gdbarch_frame_align (gdbarch, amd64_frame_align);
   set_gdbarch_frame_red_zone_size (gdbarch, 128);
-  tdep->call_dummy_num_integer_regs =
-    ARRAY_SIZE (amd64_dummy_call_integer_regs);
-  tdep->call_dummy_integer_regs = amd64_dummy_call_integer_regs;
-  tdep->classify = amd64_classify;
 
   set_gdbarch_convert_register_p (gdbarch, i387_convert_register_p);
   set_gdbarch_register_to_value (gdbarch, i387_register_to_value);
diff --git a/gdb/amd64-tdep.h b/gdb/amd64-tdep.h
index a33e7d6..265e535 100644
--- a/gdb/amd64-tdep.h
+++ b/gdb/amd64-tdep.h
@@ -103,13 +103,9 @@ extern void amd64_supply_xsave (struct regcache *regcache, int regnum,
 
 extern void amd64_collect_fxsave (const struct regcache *regcache, int regnum,
 				  void *fxsave);
-
 /* Similar to amd64_collect_fxsave, but use XSAVE extended state.  */
 extern void amd64_collect_xsave (const struct regcache *regcache,
 				 int regnum, void *xsave, int gcore);
-
-void amd64_classify (struct type *type, enum amd64_reg_class class[2]);
-
 \f
 
 /* Variables exported from amd64-linux-tdep.c.  */
diff --git a/gdb/i386-tdep.h b/gdb/i386-tdep.h
index 0c408fa..092744c 100644
--- a/gdb/i386-tdep.h
+++ b/gdb/i386-tdep.h
@@ -52,20 +52,6 @@ enum struct_return
   reg_struct_return		/* Return "short" structures in registers.  */
 };
 
-/* Register classes as defined in the AMD x86-64 psABI.  */
-
-enum amd64_reg_class
-{
-  AMD64_INTEGER,
-  AMD64_SSE,
-  AMD64_SSEUP,
-  AMD64_X87,
-  AMD64_X87UP,
-  AMD64_COMPLEX_X87,
-  AMD64_NO_CLASS,
-  AMD64_MEMORY
-};
-
 /* i386 architecture specific information.  */
 struct gdbarch_tdep
 {
@@ -75,16 +61,6 @@ struct gdbarch_tdep
   int gregset_num_regs;
   size_t sizeof_gregset;
 
-  /* The general-purpose registers used to pass integers when making
-     function calls.  This only applies to amd64, as all parameters
-     are passed through the stack on x86.  */
-  int call_dummy_num_integer_regs;
-  int *call_dummy_integer_regs;
-
-  /* Classify TYPE according to calling conventions, and store
-     the result in CLASS.  Used on amd64 only.  */
-  void (*classify) (struct type *type, enum amd64_reg_class class[2]);
-
   /* Floating-point registers.  */
   struct regset *fpregset;
   size_t sizeof_fpregset;
-- 
1.8.1.2


  parent reply	other threads:[~2013-09-24 16:33 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-10-24 17:23 amd64-windows: Fix funcall with by-pointer arguments Joel Brobecker
2012-10-24 17:23 ` [RFA 2/2] amd64-windows: Arguments passed by pointer Joel Brobecker
2012-10-24 17:24 ` [RFA 1/2] Revert "amd64-windows: memory args passed by pointer during function calls." Joel Brobecker
2012-10-25 13:18 ` amd64-windows: Fix funcall with by-pointer arguments Mark Kettenis
2013-01-16 11:59   ` Joel Brobecker
2013-09-13 22:11     ` [RFC-v2] " Pierre Muller
2013-09-16 20:57       ` Joel Brobecker
2013-09-17 13:50         ` Joel Brobecker
2013-09-20 23:20           ` Joel Brobecker
2013-09-24 16:33             ` Joel Brobecker
2013-09-24 16:33               ` [commit 3/4] Revert use of memory_args_by_pointer in i386 gdbarch_tdep Joel Brobecker
2013-09-24 16:33               ` [commit 2/4] Revert use of integer_param_regs_saved_in_caller_frame " Joel Brobecker
2013-09-24 16:33               ` Joel Brobecker [this message]
2013-09-24 16:33               ` [commit 1/4] Reimplement function calls on amd64-windows Joel Brobecker
2013-09-24 17:26                 ` fixed ChangeLog: " Joel Brobecker
2013-09-24 16:53               ` [RFC-v2] amd64-windows: Fix funcall with by-pointer arguments Mark Kettenis
2013-09-24 22:02               ` Pierre Muller
2013-09-26  0:34                 ` Joel Brobecker

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=1380040404-16932-5-git-send-email-brobecker@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=mark.kettenis@xs4all.nl \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /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