signedness of types

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

signedness of types

ST-7
Hi

I currently would like to find out the signedness of a instruction. But
looking at the CBackend, it looks as if it is not that simple? So i have two
questions:
Is there an easier way than guessing as it is done in the CBackend?
Is there a reason for that signedness is not part of the instruction type?

Best regards
ST
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: signedness of types

Eli Friedman-2
On Tue, Jun 3, 2008 at 2:42 AM, ST <[hidden email]> wrote:
> Hi
>
> I currently would like to find out the signedness of a instruction. But
> looking at the CBackend, it looks as if it is not that simple? So i have two
> questions:
> Is there an easier way than guessing as it is done in the CBackend?
> Is there a reason for that signedness is not part of the instruction type?

A lot of LLVM integer instructions don't naturally have a sign.  For
example, signed addition and unsigned addition are exactly the same
operation in two's complement, so the LLVM assembly doesn't bother to
encode the signedness.  The CBacked "guesses" because the necessary
information is completely gone.

If you haven't looked at http://llvm.org/docs/LangRef.html, I'd
suggest taking a look; it precisely states the semantics of all the
LLVM instructions and intrinsics.

-Eli
_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
Reply | Threaded
Open this post in threaded view
|

Re: signedness of types

Gordon Henriksen-3
On Jun 3, 2008, at 07:44, Eli Friedman wrote:

> On Tue, Jun 3, 2008 at 2:42 AM, ST <[hidden email]> wrote:
>>
>
>> I currently would like to find out the signedness of a instruction.  
>> But looking at the CBackend, it looks as if it is not that simple?  
>> So i have two questions:
>> Is there an easier way than guessing as it is done in the CBackend?
>> Is there a reason for that signedness is not part of the  
>> instruction type?
>
> A lot of LLVM integer instructions don't naturally have a sign.  For  
> example, signed addition and unsigned addition are exactly the same  
> operation in two's complement, so the LLVM assembly doesn't bother  
> to encode the signedness.  The CBacked "guesses" because the  
> necessary information is completely gone.


This is so because it avoids encoding many sign conversions, which  
makes the IR more transparent to optimization (and avoids sign  
conversions!). It's also a closer match to the hardware. LLVM used to  
have signed integer types.

— Gordon


_______________________________________________
LLVM Developers mailing list
[hidden email]         http://llvm.cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev