Abstract

One of the basic premises in the implementation of a ISO C compiler is that the size and alignment of all types specified by the language is known at compile time. The ISO C standard unambiguously states the size and alignment requirements of all types specified by the language. It follows that the size and alignment of all composite types is hence also known at compile time. The compiler uses the knowledge of the size and alignment of the types to be able to correctly allocate objects, generate object layouts, compute member offsets into structures and array indices, load/store alignments, allocate function call stack frame, etc. Even for platforms that support both 32-bit and 64-bit data models, with the latter providing wider sizes for some of the basic types such as pointers and long, the compiler needs the data model to be specified at compile-time in view of the above considerations.

There are certain domain-specific extensions to the C language, most notably the source language for EFI Byte Code (EBC), that do not specify the size and alignment of certain types, leaving them to be determined by the underlying architecture at runtime. Such specifications allow for the generated code (typically a high-level byte code) to be platform agnostic, allowing execution without change on multiple platforms. One of the primary motivations for such non-standard lenient language specification is the significant cost savings realized by the consolidated development and testing of the platform agnostic code deployed on multiple platforms.

Unfortunately, there are no documented and well-defined techniques to implement a compiler with the ability to support such types with unknown compile-time size and alignment.

Creative Commons License

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 4.0 License.

Share

COinS