[LLVMdev] DebugFactory

Talin viridia at gmail.com
Wed Sep 23 14:27:49 PDT 2009


On Wed, Sep 23, 2009 at 1:51 PM, Dan Gohman <gohman at apple.com> wrote:

>
> 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?
>
> That will work. Now all I need is for the methods of DIFactory to take a
Constant* instead of uint64.

-- 
-- Talin
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20090923/ac51bec2/attachment.html>


More information about the llvm-dev mailing list