Bill Currie
d50a27a045
Race down the alias chain before checking types
...
This takes care of some of the type aliasing issues.
2020-02-19 21:41:46 +09:00
Bill Currie
a5aba6c8ac
Implement type aliasing
...
The separate types are in the file, but there are multiple issues
2020-02-19 21:41:46 +09:00
Bill Currie
2f18364364
Start work on encoding typedef chains
2020-02-19 21:41:46 +09:00
Bill Currie
b00c866c4e
Allow casting between string and pointer types
2020-02-19 21:41:46 +09:00
Bill Currie
7a315b4a89
Fix storage class for for-loop declarations
...
Getting "i redeclared" when i was declared in a for loop in two
different functions was a tad unexpected.
2020-02-19 21:41:46 +09:00
Bill Currie
4c40928112
Remove what appears to be a redundant check
...
It was long wrong anyway as it checked past the end of the function's
parameters, which caused a segfault when calling varargs functions with
no formal parameters.
2020-02-19 02:53:38 +09:00
Bill Currie
a65d6bce09
Fix a warning that got through
...
I forgot to compile test in optimized...
2020-02-19 02:43:27 +09:00
Bill Currie
bd6dcafdc8
Replace system defines/includes with qfcc's
...
Right now, it probably works only with modern gcc.
2020-02-19 02:35:09 +09:00
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
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
1a9510834a
Add a missed opcode conversion for %%
2020-02-16 12:10:09 +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
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
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
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
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
a4a57b6ffd
Implement aligned allocations
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
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
8920c59515
Find @override functions even when there's only one
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
a5ee58cebb
Support 2d vector expressions
...
[x, y] expands to [x, y, 0] (for now, might add a 2d vector type).
2019-06-18 11:54:45 +09:00
Bill Currie
83fac13a0c
Fix debug line numbers for vector expressions
2019-06-18 11:53:58 +09:00
Bill Currie
b37c331e76
Catch taking size of null type
...
This should help catch similar errors in the future.
2019-06-18 10:39:17 +09:00
Bill Currie
0f1f477e64
Set up temp aliases correctly
...
Fixes vector expressions as sub-expresses. I really don't know why I did
the temp alias setup that way.
2019-06-18 10:38:19 +09:00
Bill Currie
fc50376297
Fix a minor error check mistake
2019-06-18 08:54:18 +09:00
Bill Currie
fe73547f43
Update alias type sameness check
...
This one seems to be fairly robust. Fixes alias being used to cast
pointers (maybe a better way, but this works for now).
2019-06-18 08:53:05 +09:00
Bill Currie
f7825fe7cf
Print types properly in pointer value expressions
2019-06-18 00:22:24 +09:00
Bill Currie
b996fb7aa4
Make operand->type actual type instead of low-level
...
And clean up the resulting mess. This fixes struct copy, but uncovers
another bug :/
2019-06-17 23:38:34 +09:00
Bill Currie
dd52b7fea1
Merge aliased alias expressions
...
This comes up when accessing struct fields nested in another struct.
Fixes the nested struct fields test.
2019-06-17 22:48:42 +09:00
Bill Currie
d6d3027411
Mark the correct operand as live
...
This fixes vecexpr (and possibly other cases).
2019-06-16 19:21:02 +09:00
Bill Currie
6e21c3ae2e
Treat func statements similarly to flow statements
...
func statements need their operands marked live like flow statements do
because usage is more indirect.
2019-06-16 19:20:21 +09:00
Bill Currie
db4a7a139e
Use the alias code when making vars live
...
Not sure the live forcing flag is needed anymore (need to test).
2019-06-16 19:17:45 +09:00
Bill Currie
2977c145d0
Clean up dag live alias code a little
...
Mainly, this makes it possible to reuse the alias code.
2019-06-16 19:17:01 +09:00
Bill Currie
82b334e919
Number dot dumps to help identify order
2019-06-16 19:12:18 +09:00