Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <vladimir@codesourcery.com>
To: Mark Kettenis <mark.kettenis@xs4all.nl>
Cc: gdb-patches@sources.redhat.com
Subject: Re: m68k-elf return value registers
Date: Tue, 25 Jan 2011 17:01:00 -0000	[thread overview]
Message-ID: <201101251949.15840.vladimir@codesourcery.com> (raw)
In-Reply-To: <201101141037.p0EAbFFA023135@glazunov.sibelius.xs4all.nl>

On Friday, January 14, 2011 13:37:15 Mark Kettenis wrote:
> > From: Vladimir Prus <vladimir@codesourcery.com>
> > Date: Fri, 14 Jan 2011 01:57:38 +0300
> > 
> > This patch, originally written by Nathan Sidwel, makes m68k-tdep.c use
> > right registrers for returning values from functions on bare metal.
> > There are actually 3 parts:
> > 
> > 1. Right now, it's assumed that pointer values are returned in %a0.
> > However, for m68k-elf, they are returned in %d0. So, this patch makes
> > %a0 the default, and then makes OSABI sniffers set %a0 again.
> > 
> > 2. Structures can be returned in either %a0 or %a1. This was discussed
> > 
> > previously at:
> > 	http://thread.gmane.org/gmane.comp.gdb.devel/20117
> > 
> > I have now put together a table listing what register gcc uses, and how
> > 
> > gdb does the same with this patch. See:
> > 	http://tinyurl.com/5r2j5x6
> > 
> > As you see, in the end we have only uclinuxoldeabi using wrong register
> > (just as now). I am not sure whether (i) this can be fixed, and (ii)
> > anybody care, given that this target was proposed for deprecation in gcc
> > 4.6. Anyway, if somebody cares, it can be done with a separate patch.
> > 
> > 3. This patch also updates the logic that decides whether structure is
> > returned in memory or registers. This is a black magic written by Nathan
> > that I don't pretend to understand.
> > 
> > Is this OK? I have tests still running, but they will only cover elf and
> > linux, so it would be great to have somebody check behaviour for other
> > targets.
> 
> Sorry, but this doesn't make an awful lot of sense to me.  For one
> thing, there is no such thing as an OpenBSD ELF platform.
> OpenBSD/m68k still uses a.out as its executable format.

Oh. I might have mistakenly assumed that OpenBSD uses the same format
on x86 and m68k. Well, if it's a.out on m68k this actually simplified things.
Please refer to updated table.

	http://tinyurl.com/5r2j5x6

For OpenBSD/a.out, m68k-tdep.c sets structure return register to a1, which matches
that GCC uses for that purpose. No need for override m68kbsd-tdep.c

> Second, there is a formal System V ABI for the Motorola 68000.  I
> think GCC has never properly implemented that ABI.  But it seems that
> GCC has diverged even more from it in the last couple of years.
> Probably the point has been reached that you shouldn't call this the
> System V ABI anymore.  So it'd make more sense to implement the GCC
> ABI in its own set of functions, and leave the SVR4 variants (largely)
> alone.

Are there any other compilers that matter for m68k and for which GDB should be
used. If not, then probably, those functions should be just renamed?

> Then, m68k_reg_struct_return_r() is a nonsensical name.  That function
> should probably be renamed in something like
> m68k_gcc_reg_struct_return_p().  

Well, there's m68k_reg_struct_return_p() and m68k_reg_struct_return_r(), with
the _r version being a recursive version of _p. I suppose I can add gcc to both
function, but that won't change the need to have non-recursive front-end
and recursive back-end functions, I don't think.

> The comment isn't really helpful,
> since it uses GCC-specific terminology.  Can the rules be formulated
> in a more GDB-centric way?  I never quite understood what BLKmode is,
> and I always have to look up what QI mode, SF mode, etc. etc. are.

I think the problem with describing things in GDB-centric way is that nobody
will be able to match that description with GCC logic -- which is pretty
much the point of this function. 

> 
> Also, you should make sure that that code doesn't get used for
> OpenBSD/m68k a.out, since it will be wrong.

Ok, I'll think about making this code only used for ELF targets.

> 
> Also, I think you're trying to fix too many issues in a single diff,
> which makes it hard to review.  Can you split this up in seperate
> diffs each addressing a seperate issue?  

How about this split:

- Register used to return structures
- Logic used to decide whether a structure is returned in register
- Adjusting register used for returning pointers

Thanks,

-- 
Vladimir Prus
Mentor Graphics
+7 (812) 677-68-40


  reply	other threads:[~2011-01-25 16:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 23:04 Vladimir Prus
2011-01-14 11:00 ` Mark Kettenis
2011-01-25 17:01   ` Vladimir Prus [this message]
2011-04-26 11:37     ` Vladimir Prus
2011-06-11 18:50       ` Vladimir Prus
2011-04-26 11:50     ` Vladimir Prus
2011-04-26 11:58     ` Vladimir Prus

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=201101251949.15840.vladimir@codesourcery.com \
    --to=vladimir@codesourcery.com \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mark.kettenis@xs4all.nl \
    /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