[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Gm2] translating C bit fields
From: |
SiTex Graphics |
Subject: |
Re: [Gm2] translating C bit fields |
Date: |
Mon, 21 Nov 2011 10:34:37 -0800 |
Gaius and Andreas,
Thanks for your replies. I'll try sets for now.
Native gm2 support for bit fields would of course be very convenient.
Perhaps gm2 could support the BITFIELDS extension used by the
Stonybrook compiler. I've copied the relevant docs below.
-Scott
<snip>
Bit fields can be declared anywhere in a record. Bit fields are
declared within a bit field block which starts with the BITFIELDS
keyword and ending with the END keyword.
BITFIELDS
BitFieldList
END
BitFieldList is
identifier {,identifier}: TypeSpecification BY Bits
where Bits is a compile time constant designating the number of bits
to use for storing the field.
where TypeSpecification can be any ordinal type.
TYPE BITREC =
RECORD
before : CARDINAL;
BITFIELDS
bitField1 : CARDINAL BY 3;
bitField2 : INTEGER BY 3;
END;
after : CARDINAL;
END;
Signed types have a minimum bit size of 2, and unsigned types can
occupy a single bit. Bit fields are grouped and packed via an
algorithm compatible with most C compilers. Therefore, translating a C
structure containing bit fields is straightforward.
Bit-fields obey the same size and alignment rules as other record
fields. Each bit-field exists within an aligned storage entity of the
type declared for the field. All bits of a bit-field must exist within
a single aligned entity. Padding bits and/or bytes will be added to
accomplish this. The bit-field aligned load entity can overlap with
any previous field and/or bit-field. On little endian processors bits
are allocated from low to high. On big endian processors bits are
allocated from high to low. In both cases this means that bit-fields
are allocated from lowest memory address to highest memory address
within the record.
</snip>
- [Gm2] translating C bit fields, SiTex Graphics, 2011/11/16
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/19
- Re: [Gm2] translating C bit fields,
SiTex Graphics <=
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/23
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/23
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields, SiTex Graphics, 2011/11/23
- Re: [Gm2] translating C bit fields, Dragiša Durić, 2011/11/23
- Re: [Gm2] translating C bit fields, Fischlin Andreas, 2011/11/24
- Re: [Gm2] translating C bit fields, Gaius Mulley, 2011/11/23