Commit Graph

160 Commits

Author SHA1 Message Date
ISSOtm
29629245a4 Use new hashmap implementation for symbols 2020-03-24 12:50:53 +01:00
ISSOtm
7deb8d3e8a Allow purging exported symbols 2020-03-24 10:52:02 +01:00
ISSOtm
cb0a882a31 Order warnings alphabetically 2020-03-23 16:03:36 +01:00
ISSOtm
cb52ae0f26 Implement unionized sections in RGBASM
This touched a lot more code than initially expected, for two reasons.

First, this broke a big RGBASM assumption: that sections are always being
written to at their end. This plus other problems required touching
basically the entirety of `section.c`.

Second, I tried different solutions to solve the above problem, and along
the way I cleaned up many things around. (I believe that keeping this to
"cleanup" commits yields subpar results, and since it's boring they get
postponed anyways.)

RGBLINK support still needs to be added, but this will come next.
2020-03-22 11:06:17 +01:00
Eldred Habert
fe824e0068 Merge pull request #490 from ISSOtm/const
Implement `ISCONST`, reporting compile-time constness
2020-03-21 23:20:01 +01:00
ISSOtm
fb58166e5d Add assertions
Closes #292
2020-03-21 23:00:38 +01:00
ISSOtm
03967bd623 Prevent purging referenced symbols
This is an immediate fix for #492, although #342 is needed to implement the
desired functionality.
2020-03-21 15:42:52 +01:00
ISSOtm
7ddbe44b21 Use hashmap system for charmap 2020-03-15 15:23:32 +01:00
ISSOtm
2f466c2939 Revamp macro arg system
This should significantly improve performance: on pokecrystal builds, perf
reported as much CPU time spent on `yyparse` as on `sym_UseNewMacroArgs`
Measurements show ~6 seconds of improvement on that codebase.

This also fixes #321, as a bonus, due to saner management!
2020-03-14 16:13:40 +01:00
ISSOtm
61897d8b52 Fix warning.h not including a required header 2020-03-14 11:33:51 +01:00
ISSOtm
a259f53b52 Rename macro functions with proper prefix 2020-03-13 23:20:27 +01:00
ISSOtm
ffdb1fbfe5 Split macro arg management into its own file
It has no relation to symbols, and helps a tiny bit deflate `symbol.c`
2020-03-11 02:39:36 +01:00
ISSOtm
4b33b4b387 Remove forward decl of nonexistent function
I can only assume it was for debugging? (No, I'm not looking it
up the history)
2020-03-11 02:21:30 +01:00
ISSOtm
8fcdcb1731 Implement ISCONST, reporting compile-time constness 2020-03-11 02:15:31 +01:00
ISSOtm
55b911654c Get rid of obsoleted function 2020-03-11 01:46:26 +01:00
ISSOtm
7c8eba9fd2 Remove error message causing segfault
This was utterly stupid. The check right above ensured that `sym` was NULL,
ergo that the argument to `yyerror` *would* segfault.

The only two call sites cannot pass a non-NULL pointer anyways, which I'm
betting is why this went unnoticed.
I did what an optimizing compiler would do anyways: remove the dead code.
2020-03-11 00:39:57 +01:00
ISSOtm
23effcc3f0 Fix error messages in sym_GetConstantValue 2020-03-11 00:16:35 +01:00
ISSOtm
ea0c5581a5 Prevent deletion of built-in symbols 2020-03-10 23:25:33 +01:00
ISSOtm
2ea329c920 Make symbol creation funcs return ptr to symbol 2020-03-10 16:36:02 +01:00
ISSOtm
361326e06c Allow inlining of two simple RPN functions 2020-03-07 18:18:57 +01:00
ISSOtm
f6f25296a0 Fix passing constant label to BANK() causing an error 2020-03-07 18:02:06 +01:00
ISSOtm
4cc24f4369 Add ds cnt, byte syntax
As suggested by https://github.com/rednex/rgbds/issues/350#issuecomment-498030458
The order `count` then `byte` was decided after some discussion:
- First argument consistent with single-arg syntax
- Intuitive at least to some people other than myself
- Consistent with other assemblers, at least ca65
2020-02-23 22:43:50 +01:00
ISSOtm
cfe21876e5 Make writing patches not affect the expression
This also removes one int member from the struct that shouldn't be there
2020-02-23 22:29:01 +01:00
ISSOtm
f01a227470 Fix non-const labels with callbacks having incorrect values when diffed
Basically, this broke PC, which is currently the only label-typed symbol
with a callback.
2020-02-13 20:16:59 +01:00
ISSOtm
91b65c9380 Add include guards and license header to section.h 2020-02-13 15:57:27 +01:00
ISSOtm
eb0d75711a Implement LOAD/ENDL blocks
Basically implements and closes rednex#274.
2020-02-10 03:39:09 +01:00
ISSOtm
2f60e0a59e Use meaningful types for byte output functions 2020-02-10 03:36:51 +01:00
ISSOtm
a4fe274c25 Unify all section declarations 2020-02-10 03:35:55 +01:00
ISSOtm
34597ce6a0 Mark some section functions as const 2020-02-10 03:34:58 +01:00
ISSOtm
4a2af807b2 Remove legacy forward declaration 2020-02-10 03:34:58 +01:00
ISSOtm
d0ec35628f Split section management into its own file 2020-02-10 03:34:58 +01:00
ISSOtm
bfdbd00092 Do some misc cleanup of output.c 2020-02-10 03:25:03 +01:00
ISSOtm
5014f55c48 Treat PC as a symbol as well 2020-02-10 02:51:48 +01:00
ISSOtm
1d78cd0f03 Axe the constexpr expression evaluator
This avoids redundancy between them (and also having to port fixes and features)
The error messages have been preserved through a string reporting mechanism
2020-02-10 02:51:48 +01:00
ISSOtm
9ce8a9f5f0 Add comments to RPN expr struct 2020-02-10 02:47:12 +01:00
ISSOtm
cc59730c5b Cleanup the RPN evaluator somewhat
Make the bool field an actual bool
Rename `iReloc` to a more exact `isKnown` (as was already pointed out by some
comments)
Make the value of `BANK(symbol)` consistent when the argument is invalid
2020-02-10 02:47:12 +01:00
ISSOtm
0a04904b75 Refactor RPN binary expressions into a single func
This mirrors what the constexpr evaluator is doing, and removes a lot of code shared
between all of them
2020-02-10 02:47:12 +01:00
ISSOtm
ea52e45335 Fix @
The symbol's evaluation by the assembler and linker was very inconsistent
2020-02-07 13:19:50 +01:00
ISSOtm
28473d314a Make implicit truncation a warning 2020-02-05 13:20:51 +01:00
ISSOtm
b1cd730db2 Add link-time RST instruction
This allows using a label as the argument to a `rst` instruction
Fixes rednex#448
2020-02-03 21:07:12 +01:00
Eldred Habert
20e5685c1a Merge pull request #424 from ISSOtm/better_deps
Improve dependency generation
2020-02-03 03:50:09 +01:00
Eldred Habert
ac6232bc87 Merge pull request #473 from ISSOtm/shift_ub
Remove undefined behavior from shifts
2020-02-03 03:49:38 +01:00
ISSOtm
ed72baca2a Make more symbol functions const
Can't hurt to specify those as they are now. Perhaps it'll enable slightly more
compiler optimizations, too?
2020-01-30 02:38:33 +01:00
ISSOtm
6d4b128611 Avoid unnecessary copies in symbol init 2020-01-30 02:15:43 +01:00
ISSOtm
b11d121c48 Remove undefined behavior from shifts
`asl` and `asr` in `src/link/patch.c` courtesy of @pinobatch, and rearranged in RGBASM
evaluators.
2020-01-28 12:37:38 +01:00
ISSOtm
08ab34cf57 Fix a few checkpatch warnings in symbol.h 2020-01-26 18:26:57 +01:00
ISSOtm
12f2f654dd Add -MG
This option allows for automatic dependency detection and generation:
as soon as a missing file is found, it is output to the dep file, and
assembly immediately aborts. (No .o file is produced, even if `-o` was
speicified.) This doesn't cause an error, either; the point is that once
the file is added to the dep file, the Makefile is re-parsed, and this
time the file will be generated, so the dep list builds up automatically.
This mimicks GCC's option and behavior.
2020-01-26 15:33:36 +01:00
ISSOtm
1fb9f90f0f Add -MT option
Allows overriding the output file in dependencies, which also allows
outputting those without also outputting the object file.
This, again, mimicks GCC's option.
2020-01-26 15:32:45 +01:00
ISSOtm
bfa8da78a6 Add -MP option
Adds a phony target to every included file, mimicking gcc's
2020-01-26 15:32:45 +01:00
ISSOtm
ab9307ac61 Clean up symbol management
Stop using that bitfield for everything, including what can be determined otherwise
It also makes it easier to have a sane state, since some bits were (supposedly)
mutually exclusive
2020-01-24 02:51:48 +01:00