[LLVMdev] Expose int1, int2, intxxx to Higlh Level Languages
Fano il primo
fanoilprimo at gmail.com
Sat Jun 7 07:07:59 PDT 2014
Any ideas if is this possible?
Thanks for your help!
On Fri, May 23, 2014 at 5:15 PM, Fano il primo <fanoilprimo at gmail.com>
wrote:
> Good Morning,
>
> it is a lot of time that I'm lurking this mailing list and the LLVM
> documentation and when I've seen that the assembler bitcode uses this
> special int types a question arises in my mind, why they have not
> added them as C/C++ extensions?
>
> The bool type in C is an hack being defined as a unsigned char or an
> int, but it should be naturally an int1 in LLVM, right? (I don't know
> if there is code that depends to the fact that it's size is 4 to work
> it would be wrong code).
>
> This types could be useful to replace the bitfield struct with a more
> natural construct too:
>
> typedef struct printer_status_t {
> int1 pre_paper_out; // 1/true if the paper is in pre-out, 0 /
> false if paper present
> int1 paper_out; // 1/true if paper is out, 0/ false if paper is not
> ended
> int1 drawer_opened; // 1/true if drawer is opened, 0/false if
> drawer is closed
> int1 printer_offline; // 1/ true if printer is offline, 0/false if
> online
> int1 filler[4]; // or int4 filler, I imagine not to be possible
> to have them all for C
> } printer_status;
>
> Imagine the possibility for an Object Language as C++ you could
> replace the external libraries classes a BigNumber creating simply a
> class Number (an integer with size 1 to 2^80 bit) "allocating" space
> on demand for it so that:
>
> Number n1 = 1; // only a bit is needed
> Number n2 = 3 // only 2 bits are needed
> Number n3 = 99000 // Only 5 bits are needed
> Number n4 = 1'000'000'000'000'000'000'000'000'000 // log2(n4) bitsare
> needed
>
> I imagine this would be valid only for the bitcode itself and when it
> need to be compiled is probable that padding should be needed (or some
> strange Kludge to represent more that an int64 on a X86 on 32 mode).
>
> A character expressed as UTF32 could be expressed as an Int21, if one
> wants!
>
> I have intention this summer to play with Kaledoscopie and to try to
> derive a toy Object Language from it, it would be my first compiler
> :-)
> The "Number" class would be one of the first I'll implement (after
> Object and... null) but I needed to known if it is possible first...
>
> Thanks for your attention!
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20140607/1fdc7854/attachment.html>
More information about the llvm-dev
mailing list