Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion How should integer return value should be extended?
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post will appear after it is approved by moderators
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
hong...@gmail.com  
View profile  
 More options Aug 6 2007, 1:38 pm
From: hong...@gmail.com
Date: Mon, 06 Aug 2007 17:38:40 -0000
Local: Mon, Aug 6 2007 1:38 pm
Subject: Re: How should integer return value should be extended?
The Intel compiler people say:

---
I think callers need to assume that return value is in %al and that
the upper bits of %eax are undefined.  If the caller needs a 32-bit
sign- or zero-extended value, it needs to do the extend itself.  I
believe GCC, ICC, and MSVC all behave this way.

Given that, it shouldn't matter how the callee handles the upper
bits.  It should do whatever is most convenient.
---

So Richard's change is OK as far as x86 backend is concerned.

H.J.
On Jul 24, 8:04 am, Michael Matz <m...@suse.de> wrote:

> Hi,

> On Tue, 24 Jul 2007, hong...@gmail.com wrote:
> >http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32843

> > it seems that ia32 psABI doesn't specify how an integer return value
> > should be extended. For
> > example,

> > signed char
> > return_sc (signed char *sc)
> > {
> >   return *sc;
> > }

> > The return value is in eax. Should it be sign extended or zero
> > extended?

> I actually think it shouldn't matter.  The caller should only rely on the
> parts of %eax which are covered by the return type.

> So problems can only arise if the caller for some reason doesn't know the
> exact return type (like in the bugreport the ffi library, which simply
> assumes that the return type is ffi_arg).  If we want to define something
> for that case (I think outside the C standard, but the ABI doesn't need to
> confine itself to only valid programs), then we can't specify either sign
> or zero extension exclusively, as the extension needs to be value
> preserving.

> Hence I think we can only say that before returning, %eax should be sign
> extended when the actual return type was a signed one, or zero extended if
> not.  I don't think we should go that route, though.

> Ciao,
> Michael.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.