[cfe-dev] thoughts about n-bit bytes for clang/llvm

Eli Friedman eli.friedman at gmail.com
Tue Sep 8 15:04:41 PDT 2009

On Tue, Sep 8, 2009 at 2:32 PM, Ray Fix<rayfix.ml at gmail.com> wrote:
> On Sep 4, 2009, at 1:35 PM, me22 wrote:
>> 2009/9/4 Ray Fix <rayfix.ml at gmail.com>:
>>> On Sep 4, 2009, at 11:19 AM, me22 wrote:
>>>> 2009/9/4 Ray Fix <rayfix.ml at gmail.com>:
>>>>> Do these changes seem reasonable to pursue?  What other things
>>>>> are broken
>>>>> in
>>>>> Clang and LLVM by changing the assumption about 8-bit bytes?
>>>> Bitter Melon appears to use i8* to implement void*, so you might
>>>> consider whether or how that should change.  (It might be handled
>>>> better by clang than gcc, though.)
>>> Interesting point.  On IRC the other day nlewycky mentioned a type
>>> like i3*
>>> would use the architecture's smallest word size so I might be able
>>> to get
>>> away with doing very little.  I like the idea of making void*
>>> depend on the
>>> architecture, which would be i16* in my case and i8* in all others
>>> (currently).  It just seems cleaner.  I guess I need to give a hard
>>> look to
>>> TargetData, which someone else on IRC was telling me (his nick is
>>> currently
>>> escaping me).
>> I'm curious why "void*" doesn't translate to "{}*", myself, as I think
>> that fits better.  I suppose you also need to figure out the semantics
>> of the align annotations with different byte sizes.
> I think the reason might be because internally the SizeOfPointee that
> is getting passed around as 1 in some cases to handle GNU void* and
> function pointer arithmetic extensions.  At least that is what the
> code seems to say.  See ExprConstant.cpp:357.  I am guessing there
> would be lots of breakage if you set SizeOfPointee to, say, 0 here.
> Of course there are others on this list that know much better than
> I.    I will just be happy when I can get void* to point an i16
> (*sigh*  Still working on it.)

It doesn't really matter what void* translates to in the IR to;
nothing should attempt to load from a void* or do arithmetic with it
anyway.  The use of i8* is purely tradition; I think you could change
CodeGenTypes::ConvertNewType to use an arbitrary type without any
trouble.  And ExprConstant.cpp is at a the AST level, so it isn't
really relevant here beyond the fact that we support void* arithmetic;
we handle that explicitly in ScalarExprEmitter::EmitAdd and friends,


More information about the cfe-dev mailing list