Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add HuCC now that it seems to have stabilized to be a solid "alpha". #40

Merged
merged 135 commits into from
Sep 6, 2024

Conversation

jbrandwood
Copy link
Collaborator

No description provided.

See https://github.com/matthklo/xgetopt

Also fix a bunch of VS2019 compiler warnings in the PCEAS code.
All original xopt* and xget* labels have changed to opt* and get* so that this
is a drop-in replacement for the GNU/BSD functions on Windows.

Error messages have been changed to make them more consistent with MSYS2.

In getopt_long_only(), ambiguous single letter options now try short options.
… a single build.

The extra source files on the command line are automatically included at the end of
the main (first) source file, and the section is changed to .CODE before each one.

These files are included before "kickc-final" or "sdcc-final".

While this could be used to include asm library code, it was added so that seperately
compiled C source files could be combined into a single project output, with PCEAS as
the "linker", but using assembly language source instead of object files.

This also includes a bunch of cleanup and error-checking of the command line options.
…ces in behavior.

Display "--" for the long options in the help message, even though a single "-" works
in order to maintain backwards compatibility.
Go back to using the platform's dynamically linked getopt() library
and just deal with the bugs and annoyances.
This is needed by SDCC so that the compiler can execute the C preprocessor.
 Please enter the commit message for your changes. Lines starting
… defined.

Use a string pool for macro lines as well as source file names.

Change macro and func structures to get their name string from the associated label.
Revert as much as possible of the change from "int" to "intptr_t" that
was done in a hurry a few years ago to allow a 64-bit build of HuC.

This also *begins* the process of cleaning up some stuff in the SmallC
codebase that should have been "bool" or something other than an "int".

Removed the remains of Uli's interrupt-handling additions.

Begin renaming some of the macros as part of figuring out how to fix
the code-generation for conditionals.
They should be moved to a header file in include/hucc/ instead.
The "__far" version is more compliant with C standard usage.
…tions.

They should be moved to a header file in include/hucc/ instead.
Also change the spelling of "Small-C" to match common modern usage.
Also fix warning that VS2019 flags in input.c
about, this is automatically handled by PCEAS's ".opt a+" now.
…ccessful

attempt to optimize access to a byte-array.

Remove X_LDB_P and X_LDUB_P i-codes which only seem to exist in order to use
zero-page access to the __ptr variable. PCEAS automatically handles that now.

Change the optimizer so that the X_LDB_S optimization is done in the routine
that handles the X_LDW_S optimization, instead of relying on X_LDB_P.
the existing word-array address optimization.

It feels like these need more work, but they're a starting point.
to a symbol instead of sometimes just containing a string pointer.

This only worked in HuC because the symbol structure started with the
symbol's name string ... which is an ugly leftover hack from Small-C.
routines to fail on the SuperGRAFX.

Change SuperGRAFX detection back to the older check-VRAM method as
Mednafen does not respond the way that Charles MacDonald documents.

The behavior needs to be tested on real-hardware to confirm who is
right.
unsigned comparisons and math when a function returns an unsigned int.

Change HuCC abs() to return an int and not an unsigned int.

Fix rand() to return a true 16-bit unsigned int.

Add rand8() to return an 8-bit unsigned int.

Add random8() to allow using a random range of up to 254 if "limit" is
set to 255.
…sive" to

make them individual "static" declarations rather than use Uli's pseudo-stack
method.

This can make it easier to identify the variables when debugging, but it does
mean that leaf-functions do not currently share/overlay their memory usage.

Because of this, the change is optional using the ULI_RECURSE flag in defs.h
…WI symbol"

without generating garbage.

HuC has optimized "LDWI symbol; ADDWI number" for a long time, but it could not
understand the "ADDWI symbol" that HuCC can now generate.
2nd parameter that the compiler never actually generates.

Also finally remove the __ldby macro that isn't used anymore.
after the index has been calculated.

This is normally done in the peephole optimizer, but only when the
index is a simple variable access. Moving it to the code generator
allows complex indices to be calculated.
Reorder the i-codes in defs.h to group similar functions together so
that you can see what kind of alternatives exist.

Reorder both the macros in hucc-codegen.asm, and the output routines
code.c, to match the order of i-codes in defs.h to make finding them
a bit simpler.

Remove some i-codes that were never actually generated.

Clean up optimize.c so that all of the peephole tests have a similar
structure and comment layout.

Change HuCC's code generation of "switch()" and "case" to output new
__switch, __case and __endcase macros to make them easier to see and
to highlight when a case statement falls though to the next case.

These macros will be important if or when "switch()" is optimized in
the future.
also add a further byte optimization for "switch(var)" where "var"
is a signed or unsigned char variable without any math done on it.
less than 256 bytes long, and the variable is not an expression.

This only works for global and static arrays, and not arrays which
are located on the C stack (-fno-recursive arrays are OK).
newly optimized array-loading i-codes.

Swap the order of the test bytes in switch statements so that case
word-tests are usually as fast case byte-tests (i.e. twice as fast
as HuC).
to make it easier to understand and replicate for future rules.
on unsigned-byte variables. Signed-byte variables are going to get
ignored because the generated code is faster with 16-bit integers!

Remove I_ADDBS because it is easier to do that optimization in the
the peephole rules.

Remove __addwi_sym because it's easier to check for a value/symbol
in the __addwi macro itself.
…and it makes

it harder to write peephole rules that apply to both local and global variables.

Fix instruction rescheduler to stop leaving orphaned I_LDWI behind.

Add I_ISUBWI inverse subtraction for the instruction rescheduler to use.

Rename X_LEA_S to I_LEA_S because it's compiler-generated and not an optimization.

Write the stack-based local variable names into the instruction output as comments
to make debugging easier because the stack offsets are meaningless to humans.

Remove the peephole optimizer's base+offset I_ADDWI rearrangment rules as they are
not used anymore and are just in the way.
that some types of C structures cause the compiler to generate.
less than 256 bytes long. Complex index calculations are OK.

This only works for global and static arrays, and not for arrays
that are located on the C stack (-fno-recursive arrays are OK).

Change the "array[variable]" read optimization to handle complex
indexes at the cost of being slightly slower for just "variable".

Reorganize the optimizer's instruction rescheduler to make it a
bit more understandable, and to handle the "array[index]" write.

Move the __stwip and __stbip optimizations after the instruction
rescheduler because they get in its way and the rescheduler gets
better results.
@jbrandwood jbrandwood merged commit 5f3a7a1 into pce-devel:master Sep 6, 2024
12 checks passed
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.

1 participant