Commit graph

9979 commits

Author SHA1 Message Date
Bill Currie
2d52da9c0d Fix segfault in unlimited params 2020-02-19 02:35:09 +09:00
Bill Currie
c61d0b6ff0 Allow unlimited parameters in function declarations
However, definitions are still limited to 8 parameters. This allows
processing of C headers for type information.
2020-02-19 02:35:09 +09:00
Bill Currie
ee228504aa Fix self-referenced enum declarations
eg:
typedef enum foo {
    bar = 1,
    baz = bar,
} foo;
2020-02-19 02:35:09 +09:00
Bill Currie
ed283a9e7f Copy only the necessary number of vararg parameters 2020-02-16 18:00:29 +09:00
Bill Currie
12d2a0ff75 Copy the correct number of words for rcall 2020-02-16 17:58:36 +09:00
Bill Currie
f5741a979e Implement parameter alignment in the engine
The engine now requires non-v6 progs to store the log2 alignment for the
param struct in .param_alignment.

PR_EnterFunction is clearer and possibly more efficient.
2020-02-16 17:13:45 +09:00
Bill Currie
7a399c956b Encode function parameter alignment
The encoding is 3:5 giving 3 bits for alignment (log2) and 5 bits for
size, with alignment in the 3 most significant bits. This keeps the
format backwards compatible as until doubles were added, all types were
aligned to 1 word which gets encoded as 0, and the size is unaffected.
2020-02-16 17:10:43 +09:00
Bill Currie
1bc08c59f6 Add tests for %%
double fails due to qfcc aligning double param locals, but the engine
not doing so.
2020-02-16 17:02:38 +09:00
Bill Currie
1a9510834a Add a missed opcode conversion for %% 2020-02-16 12:10:09 +09:00
Bill Currie
32c21ec559 Make gcc accept the bitwise-boolean magic
Forgot to compile check...
2020-02-16 12:08:08 +09:00
Bill Currie
9d2d33fa50 Implement %% (true modulo) support in qfcc
However, it's not quite working yet
2020-02-16 11:57:58 +09:00
Bill Currie
b4fd804e4e Implement true modulo in the engine 2020-02-16 11:53:56 +09:00
Bill Currie
4269c8cb07 Rename the mod instruction to rem
Because % really implements remainder rather than true modulo, and I
plan on adding %% to implement true modulo.
2020-02-16 11:04:30 +09:00
Bill Currie
db9996023f Add some tests for double comparison
More testing the engine than the compiler, but hey :)
2020-02-15 23:49:12 +09:00
Bill Currie
bab3752e98 Add missed overridden math functions
And fix misspelled ones too.
2020-02-15 23:49:12 +09:00
Bill Currie
14acfad7c4 Fix incorrect placement of far data
All the care in aligning things was undone by not updating the
calculations of the pointers.
2020-02-15 23:49:12 +09:00
Bill Currie
1985b6d4fd Avoid creating a struct temp for ivar struct return
This fixed the uninitialized temp warning in HUD.r. The problem was
caused by the flow analyzer not being able to detect that the struct
temp was being initialized by the move statement due to the address of
the temp being in a pointer temp. While it would be good to use a
constant pointer for the address of the struct temp or improving the
flow analyzer to track actual data, avoiding the temp in the first place
results in nicer code as it removes a move statement.
2020-02-15 23:49:12 +09:00
Bill Currie
9c996df7b4 Add a test case for the uninit temp in HUD.r 2020-02-15 23:49:12 +09:00
Bill Currie
7bfa0f7a92 Allow pragmas to have arguments
It does mean only one pragma per line, but that's not such a big deal.
2020-02-15 23:49:12 +09:00
Bill Currie
91f5023681 Promote bugs to internal errors
Mostly so I can catch them in test cases
2020-02-15 23:49:12 +09:00
Bill Currie
39df9c0c87 Fix some more double related warnings
Fewer than I expected
2020-02-15 23:49:12 +09:00
Bill Currie
344d429134 Test array initializer double demotions
Turns out array inits are very strict about types (bug?).
2020-02-15 23:49:12 +09:00
Bill Currie
6ce99afa5b Catch double demotion in global initializers
Local initializers are handled by regular assignments
2020-02-15 23:49:12 +09:00
Bill Currie
c5ce18591f Catch and warn demotion of double in assignments 2020-02-15 23:49:12 +09:00
Bill Currie
08ca59d0df Add tests for double demotion 2020-02-15 23:49:12 +09:00
Bill Currie
4bf37b274b Ensure double is not in zero or param structs for v6 2020-02-15 23:49:12 +09:00
Bill Currie
be30a0eb19 Fix missing alignment init on zero and param types 2020-02-15 23:49:12 +09:00
Bill Currie
3e651b43f8 Handle aliased values when emitting statements
With this, cast address initializers work. I have to wonder if the alias
value short-circuit was legacy from long before the rewrite, as it was
quite trivial to handle in the back-end.
2020-02-15 23:49:12 +09:00
Bill Currie
e4eb793fb3 Treat aliased values as constant
One step closer to cast address initializers working.
2020-02-15 23:49:12 +09:00
Bill Currie
ce9902baed Don't short-circuit aliased values
Not sure why I thought it was a good idea as it turns out this is why
cast pointer initializers were being lost.
2020-02-15 23:49:12 +09:00
Bill Currie
3257e7145b Add failing global init test too 2020-02-15 23:49:12 +09:00
Bill Currie
4caa875442 Finish up alignment tests and add address cast
It turns out that initializing a local int with a pointer cast doesn't
work.
2020-02-15 23:49:12 +09:00
Bill Currie
a4a57b6ffd Implement aligned allocations 2020-02-15 23:49:12 +09:00
Bill Currie
293f10211a Start on alignment test
Currently fails (deliberately, WIP)
2020-02-15 23:49:12 +09:00
Bill Currie
0542daacdf Create more double related tests
Including catching warnings :) (yay -Werror)
2020-02-15 23:49:12 +09:00
Bill Currie
7e7e0526dd Fix a double constant issue
There will be more of these :/
2020-02-15 23:49:12 +09:00
Bill Currie
7e09a94469 Fix "casts" between signed and unsigned int 2020-02-15 23:49:12 +09:00
Bill Currie
5d8d805b60 Fix test for single overload functions
All functions are stored in the overload functions table, even those
that are never explicitly overloaded, but only explicitly overloaded
functions (those with @overload) use the type-qualified naming.
2020-02-15 23:49:12 +09:00
Bill Currie
533fb8acc9 Implement double constants 2020-02-15 23:49:12 +09:00
Bill Currie
2cd62fe01b Fix several double-related bug
float is promoted to double through ... for non-v6 code.
PR_Sprintf has custom param access via P_*, messed up doubles.
2020-02-15 23:49:12 +09:00
Bill Currie
eb7f825158 Test for full-float % 2020-02-15 23:49:12 +09:00
Bill Currie
8920c59515 Find @override functions even when there's only one 2020-02-15 23:49:12 +09:00
Bill Currie
98216c6eb0 Fixed some missed doxygen updates 2020-02-15 23:49:12 +09:00
Bill Currie
df7c08a010 Add support for doubles to Ruamoko
Only as scalars, I still need to think about what to do for vectors and
quaternions due to param size issues. Also, doubles are not yet
guaranteed to be correctly aligned.
2020-02-15 23:49:12 +09:00
Bill Currie
13b608f40c Don't truncat float % float
This allows full usage, eg, x % pi, but otherwise maintains
compatibility with integer %
2020-02-15 23:49:12 +09:00
Bill Currie
16f8dca72e Align local and far data spaces
I plan on adding doubles, and so it's necessary to ensure that attempts
to align doubles in local or far data spaces remain aligned after final
linking.
2020-02-15 23:49:12 +09:00
Bill Currie
197f856a30 Fix incorrect scalar/quaternion division
It's just not possible.
2020-02-15 23:49:12 +09:00
Bill Currie
c50dda1d08 Document segmented text 2020-02-15 23:48:47 +09:00
Bill Currie
de64be1d67 Show more info when dumping x11 video modes
Found in an old stash. Probably the start of xrandr support.
2020-02-12 11:04:28 +09:00
Bill Currie
31501ad641 Add some docs for linked lists
Found in an old stash
2020-02-12 10:52:47 +09:00