[LLVMdev] How to handle size_t in front ends?

Gordon Henriksen
2008-05-22T03:26:51Z

On 2008-05-21, at 22:17, Talin wrote:

> Chris Lattner wrote:
>> On Wed, 21 May 2008, Talin wrote:
>>
>>> On a related topic: The source-level debugging descriptors require
>>> you
>>> to know up front what the sizeof pointer types are. Is there any
>>> hope of
>>> the frontend remaining blissfully unaware of platform details?
>>>
>>
>> I really don't know how to do this.  The current debug info stuff
>> depends
>> on emitting size info into the IR.  At this point, I don't think
>> there is
>> a good way around this.  Improvements to the design are welcome of
>> course.
>>
>> -Chris
>>
> As I understand this, this issue and others like it all require a
> difficult step to be taken, which is to introduce the concept of a
> constant whose value is not known until code generation time or at
> least
> until the compilation target is fully known. These "late bound
> constants" could then be used to implement "sizeof(type)"
and other
> constants whose value is different on different targets.

LLVM already does this.

http://www.nondot.org/sabre/LLVMNotes/SizeOf-OffsetOf-VariableSizedStructs.txt

— Gordon