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
On Tue, Jun 3, 2008 at 2:42 AM, ST <st at iss.tu-darmstadt.de> 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
On Jun 3, 2008, at 07:44, Eli Friedman wrote:> On Tue, Jun 3, 2008 at 2:42 AM, ST <st at iss.tu-darmstadt.de> 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