-
Notifications
You must be signed in to change notification settings - Fork 12
Description
pgen refactor goals
- Break pgen into multiple modules (described below).
- Refactor to use input buffering (described below).
- Change read and write procedures to use temp for the read/write file.
- Implement a per-CPU/calling convention flag, like AMD64.
- Implement cexternal and cwexternal.
pgen modules [done]
The first refactor of pgen modules is:
registers - Describes CPU registers, prints of those registers, etc.
This needs to be a separate module because even the independent logic relies on them.
independent - Gives pgen routines that are not CPU dependent.
pgen - Contains the main module and all logic that is CPU dependent (outside of registers).
In the future these will be named for their CPUs, like pgen_amd64, etc.
Input buffering [done]
Like pcom, pgen will buffer up input lines. This will improve error handling, since errors can
print the input line in error. It will also greatly clean up the logic, because copy throughs (carrying
the input line to the output as a comment) will be a one step process contained in generate,
and not spread over assemble().
Change read/write procedures to use temps
The current read and write procedures chain the input or output file reference via a complicated
mechanism of preserving the file parameter During each chained call. Instead we put the
evaluated file in a temp and let the chained calls load that. Much cleaner and done entirely
in pcom.
Per CPU calling convention
The number of registered parameters becomes CPU specific, and the registered parameters
all go to a so called "pad" on the stack of all pushed registers. At present, all parameters are
both stacked and registered to keep compatibility with the interpreter. This would make
the calling convention in .p6 per CPU compatible, but improves the CPU calling convention
compatibility. The return result is also left in a register. This is also a required step to
prepare for Windows.
cexternal and cwexternal
Described elsewhere, this allows parameters to be converted to C form intelligently as part of
the call. This is done via a combination of "natural" conversions (like strings) and directed conversions done by special mode identifiers. Both cexternal and cwexternal do this convertion. cexternal drops module coining. cwexternal does not, and is used to create wrappers, by redirecting the call to a wrapper equivalent.