On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <devang.patel at gmail.com> wrote:> On Tue, Sep 22, 2009 at 12:14 AM, Talin <viridia at gmail.com> wrote: >> So, one feature of the late, lamented DebugInfoBuilder that I am missing >> quite badly, and which is not available in the current DIFactory, is the >> ability to specify structure offsets abstractly. The DebugFactory >> requires that you pass in structure offset information as ints, whereas >> DebugInfoBuilder had "offsetOf" and "alignOf" methods, similar to the >> "sizeOf" trick, that would create the constants for you in a way that >> didn't require your front end to know the sizes of things. So far I've >> been able to avoid having any references to target machines in my >> frontend, but now that I am trying to flesh out my debug info more fully >> I'm finding it hard to use DIFactory as-is. >> >> What I'd like to see is a set of alternative factory methods in >> DIFactory, where you pass in an LLVM type, and possibly a GEP index, >> plus all of the parameters that it can't figure out from looking at the >> type. So you can eliminate the offset, size, and alignment parameters >> since those can be figured out from the type. > > Is it true that DIFactory can figure this out with Target info in all cases ?oops... I meant to say "... without Target info..." - Devang
On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <devang.patel at gmail.com>wrote:> On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <devang.patel at gmail.com> > wrote: > > On Tue, Sep 22, 2009 at 12:14 AM, Talin <viridia at gmail.com> wrote: > >> So, one feature of the late, lamented DebugInfoBuilder that I am missing > >> quite badly, and which is not available in the current DIFactory, is the > >> ability to specify structure offsets abstractly. The DebugFactory > >> requires that you pass in structure offset information as ints, whereas > >> DebugInfoBuilder had "offsetOf" and "alignOf" methods, similar to the > >> "sizeOf" trick, that would create the constants for you in a way that > >> didn't require your front end to know the sizes of things. So far I've > >> been able to avoid having any references to target machines in my > >> frontend, but now that I am trying to flesh out my debug info more fully > >> I'm finding it hard to use DIFactory as-is. > >> > >> What I'd like to see is a set of alternative factory methods in > >> DIFactory, where you pass in an LLVM type, and possibly a GEP index, > >> plus all of the parameters that it can't figure out from looking at the > >> type. So you can eliminate the offset, size, and alignment parameters > >> since those can be figured out from the type. > > > > Is it true that DIFactory can figure this out with Target info in all > cases ? > > oops... I meant to say "... without Target info..." > > // Calculate the size of the specified LLVM type.Constant * DebugInfoBuilder::getSize(const Type * type) { Constant * one = ConstantInt::get(Type::Int32Ty, 1); return ConstantExpr::getPtrToInt( ConstantExpr::getGetElementPtr( ConstantPointerNull::get(PointerType::getUnqual(type)), &one, 1), Type::Int32Ty); } Constant * DebugInfoBuilder::getAlignment(const Type * type) { // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)" return ConstantExpr::getSub( getSize(StructType::get(Type::Int8Ty, type, NULL)), getSize(type)); } This was code that was checked in before DebugInfoBuilder was replaced by DIFactory. -- -- Talin -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090922/23d0313f/attachment.html>
On Tue, Sep 22, 2009 at 4:49 PM, Talin <viridia at gmail.com> wrote:> > > On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <devang.patel at gmail.com> > wrote: >> >> On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <devang.patel at gmail.com> >> wrote: >> > On Tue, Sep 22, 2009 at 12:14 AM, Talin <viridia at gmail.com> wrote: >> >> So, one feature of the late, lamented DebugInfoBuilder that I am >> >> missing >> >> quite badly, and which is not available in the current DIFactory, is >> >> the >> >> ability to specify structure offsets abstractly. The DebugFactory >> >> requires that you pass in structure offset information as ints, whereas >> >> DebugInfoBuilder had "offsetOf" and "alignOf" methods, similar to the >> >> "sizeOf" trick, that would create the constants for you in a way that >> >> didn't require your front end to know the sizes of things. So far I've >> >> been able to avoid having any references to target machines in my >> >> frontend, but now that I am trying to flesh out my debug info more >> >> fully >> >> I'm finding it hard to use DIFactory as-is. >> >> >> >> What I'd like to see is a set of alternative factory methods in >> >> DIFactory, where you pass in an LLVM type, and possibly a GEP index, >> >> plus all of the parameters that it can't figure out from looking at the >> >> type. So you can eliminate the offset, size, and alignment parameters >> >> since those can be figured out from the type. >> > >> > Is it true that DIFactory can figure this out with Target info in all >> > cases ? >> >> oops... I meant to say "... without Target info..." >> > // Calculate the size of the specified LLVM type. > Constant * DebugInfoBuilder::getSize(const Type * type) { > Constant * one = ConstantInt::get(Type::Int32Ty, 1); > return ConstantExpr::getPtrToInt( > ConstantExpr::getGetElementPtr( > ConstantPointerNull::get(PointerType::getUnqual(type)), > &one, 1), Type::Int32Ty); > } > > Constant * DebugInfoBuilder::getAlignment(const Type * type) { > // Calculates the alignment of T using "sizeof({i8, T}) - sizeof(T)" > return ConstantExpr::getSub( > getSize(StructType::get(Type::Int8Ty, type, NULL)), > getSize(type)); > } > > This was code that was checked in before DebugInfoBuilder was replaced by > DIFactory.This adds code to find the info that FE knows anyway. That is undesirable IMO. If there is a need, you can do this trick in your FE. -- - Devang
On Sep 22, 2009, at 4:49 PM, Talin wrote:> > // Calculate the size of the specified LLVM type. > Constant * DebugInfoBuilder::getSize(const Type * type) { > Constant * one = ConstantInt::get(Type::Int32Ty, 1); > return ConstantExpr::getPtrToInt( > ConstantExpr::getGetElementPtr( > ConstantPointerNull::get(PointerType::getUnqual(type)), > &one, 1), Type::Int32Ty); > } > > Constant * DebugInfoBuilder::getAlignment(const Type * type) { > // Calculates the alignment of T using "sizeof({i8, T}) - sizeof > (T)" > return ConstantExpr::getSub( > getSize(StructType::get(Type::Int8Ty, type, NULL)), > getSize(type)); > }Are ConstantExpr::getAlignOf, getSizeOf, and getOffsetOf what you're looking for? Dan