<br><br><div class="gmail_quote">On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <span dir="ltr"><<a href="mailto:devang.patel@gmail.com">devang.patel@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><div></div><div class="h5">On Tue, Sep 22, 2009 at 9:21 AM, Devang Patel <<a href="mailto:devang.patel@gmail.com">devang.patel@gmail.com</a>> wrote:<br>
> On Tue, Sep 22, 2009 at 12:14 AM, Talin <<a href="mailto:viridia@gmail.com">viridia@gmail.com</a>> wrote:<br>
>> So, one feature of the late, lamented DebugInfoBuilder that I am missing<br>
>> quite badly, and which is not available in the current DIFactory, is the<br>
>> ability to specify structure offsets abstractly. The DebugFactory<br>
>> requires that you pass in structure offset information as ints, whereas<br>
>> DebugInfoBuilder had "offsetOf" and "alignOf" methods, similar to the<br>
>> "sizeOf" trick, that would create the constants for you in a way that<br>
>> didn't require your front end to know the sizes of things. So far I've<br>
>> been able to avoid having any references to target machines in my<br>
>> frontend, but now that I am trying to flesh out my debug info more fully<br>
>> I'm finding it hard to use DIFactory as-is.<br>
>><br>
>> What I'd like to see is a set of alternative factory methods in<br>
>> DIFactory, where you pass in an LLVM type, and possibly a GEP index,<br>
>> plus all of the parameters that it can't figure out from looking at the<br>
>> type. So you can eliminate the offset, size, and alignment parameters<br>
>> since those can be figured out from the type.<br>
><br>
> Is it true that DIFactory can figure this out with Target info in all cases ?<br>
<br>
</div></div>oops... I meant to say "... without Target info..."<br><br></blockquote><span class="Apple-style-span" style="font-family: arial, sans-serif; font-size: medium; -webkit-border-horizontal-spacing: 10px; -webkit-border-vertical-spacing: 10px; "><pre>
// 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));
}
</pre></span><div>This was code that was checked in before DebugInfoBuilder was replaced by DIFactory.</div></div><div><br></div>-- <br>-- Talin<br>