COBOL: Improve data conversions, reduce aliasing, and support big-endian
Enhances COBOL data type conversions, addresses C-based aliasing risks, and improves big-endian architecture support.
Significant improvements have been made to the COBOL compiler and runtime library, focusing on data type interconversions and addressing potential data aliasing issues arising from C-style pointer manipulations. The changes also improve compatibility and correctness on big-endian architectures by handling endianness during compile-time code generation and at runtime.
In Details
This commit overhauls data type handling within the GCC COBOL frontend and libgcobol. It refactors interconversions between various numeric and string types, aiming for consistency across GENERIC IR and runtime. Aliasing risks from C-style pointer casts in generated code are actively reduced. Crucially, it addresses endianness issues on big-endian targets like S390, using BYTES_BIG_ENDIAN and __BYTE_ORDER__ to ensure correct data representation and manipulation at compile time and runtime.
- GENERIC
- An intermediate representation (IR) used within GCC. It's a tree-based representation that sits between the language front-end and the lower-level RTL (Register Transfer Language).
- libgcobol.so
- The shared library for the GNU COBOL compiler, providing runtime support functions for COBOL programs.
- Aliasing
- In programming, aliasing occurs when two or more different names (e.g., pointers or variables) refer to the same memory location. This can complicate optimization as the compiler must ensure that modifications through one name are visible through the other.
- Big-endian
- A byte order convention where the most significant byte of a multi-byte data word is stored at the lowest memory address. This contrasts with little-endian, where the least significant byte is stored at the lowest address.
- Endian agnostic
- Code that functions correctly regardless of whether the underlying hardware architecture uses big-endian or little-endian byte ordering.