This patch adds 64-bit integer (long long and unsigned long long) support to the SDCC PIC14 backend, targeting Enhanced Mid-Range PIC devices.
The patch is based on the official SDCC trunk revision r17148 and contains changes to 10 files.
Changes included:
- Extend PIC14 code generation and register allocation to handle 64-bit integer operands.
- Correct 64-bit literal extraction, masks, arithmetic and comparison handling.
- Enable acceptance of
long long types for the PIC14 target.
- Add the PIC14-specific
__mullonglong runtime helper.
- Include signed and unsigned 64-bit division and modulus runtime functions in the Enhanced PIC14 libraries.
- Update the relevant PIC14 library build definitions.
The implementation targets Enhanced PIC14 devices. Classic PIC14 support is not claimed by this patch.
Validation performed:
- Patch application check against clean SDCC trunk r17148: PASS.
- Reverse patch check against the isolated patched source tree: PASS.
- Fresh isolated SDCC compiler build: PASS.
- Enhanced PIC14 runtime library build: PASS.
- Verified runtime symbols:
__mullonglong, __divulonglong, __modulonglong, __divslonglong, __modslonglong.
- 64-bit signed and unsigned division/modulus regression tests using GPSIM: 68/68 PASS, 0 FAIL.
- Additional arithmetic, comparison, multiplication and generic-pointer tests were previously performed in the development environment.
The 68 regression cases include boundary values such as UINT64_MAX, INT64_MIN, INT64_MAX, operands exceeding 32 bits, and positive/negative operand combinations.
I only had a quick look, and didn't test this yet. So just one quick recommendation for now: instead of
emitGptrTransfer64, which is hardcoded to 64 bits, implement a function that works for any width (that is a multiple of 8). That will make it easier to later implement support for_BitInt, which you'll want, since it is an important C23 feature especially useful for memory-constrained devices, and the generalized constant propagation optimization, which is also very helpful to reduce memory usage, also depends on_BitIntsupport.