Age | Commit message (Collapse) | Author |
|
|
|
Compiling languages with closures often requires passing
an extra environment parameter to the called function.
One solution is to use a convention, and reserve, say,
the first argument for that purpose. However, that
makes binding to C a little less smooth.
Alternatively, QBE now provides a way to remain fully
ABI compatible with C by having a "hidden" environment
argument (marked with the keyword 'env'). Calling a
function expecting an environment from C will make the
contents of the environment undefined, but the normal
arguments will be passed without alteration. Conversely,
calling a C function like it is a closure by passing
it an environemnt will work smoothly.
|
|
|
|
This change is backward compatible, calls to
"variadic" functions (like printf) must now be
annotated (with ...).
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
I found it by compiling -O2 and seeing the ABI code
fail. Further investigation revealed GCC trimmed
away the last iteration of the loop because I was
accessing the third element of an array of size two.
This is undefined behavior, so GCC "proved" that the
last iteration was never run.
|
|
|
|
A struct of size 0 is now marked as passed in memory.
All the ABI code assumes structs passed in registers
have size at least 8. This could have an impact on
the alignment in the stack, but eh, I guess they are
rare.
|
|
|
|
|
|
|
|
Abi lowering does not need use counts, but
they are needed for instruction selection.
I changed main to call filluse() between
these two passes.
|
|
|