Skip to content

Fix array support (-Oarray optimization) - #143

Merged
alastairreid merged 4 commits into
masterfrom
areid/array-return
Aug 21, 2026
Merged

Fix array support (-Oarray optimization)#143
alastairreid merged 4 commits into
masterfrom
areid/array-return

Conversation

@alastairreid

@alastairreid alastairreid commented Apr 27, 2026

Copy link
Copy Markdown

This transformation fixes array support by wrapping arrays in structs.
This works because C does not support array assignment (because arrays are promoted to pointers) but it does support struct assignment.

Fixes #41

Comment thread libISA/xform_arrays.ml Outdated
Comment thread libISA/xform_arrays.mli Outdated
Comment thread bin/iic.py
Comment thread tests/backends/type_record_01.isa Outdated
Comment thread tests/backends/type_record_01.isa Outdated
Comment thread libISA/xform_arrays.ml Outdated
Comment thread libISA/xform_arrays.ml Outdated
Comment thread libISA/xform_arrays.ml Outdated
Comment thread libISA/xform_arrays.ml Outdated
Comment thread tests/lit/xform_arrays/function_00.isa Outdated
@alastairreid
alastairreid force-pushed the areid/array-return branch 3 times, most recently from 3d1d149 to 2ef4b0f Compare June 23, 2026 14:23
This change makes it easier to figure out the type of array literals
which is required for the array wrapping transformation xform_array.
This transformation wraps arrays in records.
The purpose of this is to simplify C code generation which was
incorrectly generating 'x = y;' to copy an array.
@alastairreid
alastairreid merged commit 59b75fe into master Aug 21, 2026
1 check passed
@alastairreid
alastairreid deleted the areid/array-return branch August 21, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: returning arrays from functions generates hilariously bad C code

2 participants