Commit graph

53 commits

Author SHA1 Message Date
Bill Currie
f9e177efd6 Obtain the label to be removed from the correct place.
This fixes the undetected dead block after "if return else return".
2011-03-03 17:50:46 +09:00
Bill Currie
ed901bd48f Drop unused labels rather than adding them to the statement block.
However, even unused labels create a new statement block if necessary.
2011-03-03 17:35:06 +09:00
Bill Currie
c5ecc170b6 Give labels a usage count to detect unused labels. 2011-03-03 15:28:49 +09:00
Bill Currie
d937172243 Create and use alias operands for alias expressions.
This avoids the alias expression modifying the operand used in other
expressions.
2011-03-03 13:46:07 +09:00
Bill Currie
022fde666f Implement unary expression statements. 2011-03-03 13:10:07 +09:00
Bill Currie
45de7327dc Implement alias expressions (finally).
Alias expressions are like cast expressions, but never do any conversions.
2011-03-03 11:06:10 +09:00
Bill Currie
497db3ac81 Fix the return symbol extraction when appending a return statement.
The code is still icky, though :P
2011-02-22 09:20:52 +09:00
Bill Currie
bcaf3687c5 Fix loading structs into params via an offset pointer.
For certain values of "fix" :/. The code is ugly, but it does the right
thing: calculate the effect address and use the resulting pointer in a
move instruction.
2011-02-14 23:10:45 +09:00
Bill Currie
179c1f7058 Support move statements (structure copy). 2011-02-11 22:29:57 +09:00
Bill Currie
370f0b97ed Produce cleaner output for a = b op c. 2011-02-11 22:29:57 +09:00
Bill Currie
d93d8d7d46 Remove the dirty hack used for accessing params and the return value.
Instead of using the equivalent of *(float*)&.return, now use the
equivalent of (float).return. No conversion is done in the "cast".

NOTE: this sort of cast should be separated from normal casts.
2011-02-11 22:29:38 +09:00
Bill Currie
7d2a95ee40 Mark a few problem spots. 2011-02-11 22:29:37 +09:00
Bill Currie
6f625e426f Use the correct type when deferencing an offset pointer. 2011-02-10 14:26:12 +09:00
Bill Currie
006c16807d Add the statement for based loads.
Oops :P
2011-02-09 22:40:16 +09:00
Bill Currie
0d5ab6600d Store the source expression in a statement.
This makes problem reporting more informative.
2011-02-08 18:18:34 +09:00
Bill Currie
3c849b970b Handle union access now that they're detected properly. 2011-02-08 14:45:48 +09:00
Bill Currie
3b080fcbb0 Fix an uninitialized variable. 2011-02-08 13:27:37 +09:00
Bill Currie
65a07ada1c Implement offset dereferences. 2011-02-07 14:56:29 +09:00
Bill Currie
d2b464053c Fix assignment sub-expressions. 2011-02-07 14:43:07 +09:00
Bill Currie
ef2ad46f7a Convert complex types to a suitable low-level type.
This takes care of moving structures etc around.
2011-02-07 10:55:09 +09:00
Bill Currie
b629c12b31 Do not change the type of the return operand.
Doing so made a mess of returning expressions. It was probably a holdover
from before getting instructions with void operand types working.
2011-02-07 10:21:54 +09:00
Bill Currie
e4ac92b5f2 Auto-cast between enums and the default type. 2011-02-06 20:08:16 +09:00
Bill Currie
c53001800a Create a struct for representing specifiers.
The specifiers are yet to come (next few commits), but this will be
necessary when they do.
2011-02-01 21:15:51 +09:00
Bill Currie
e7424e1496 Don't segfault on bare return statements.
I will probably need to do something about the required operand for v6
progs, but this will do for now.
2011-01-30 21:43:56 +09:00
Bill Currie
834417b8c8 Add "debug" diagnotic printing, and use it.
Debug diagnostics are silent for verbosity levels less than 1.
2011-01-28 13:28:45 +09:00
Bill Currie
a37bdd9fb5 Free removed sblocks. 2011-01-28 13:23:20 +09:00
Bill Currie
80424f6ad5 Ensure functions are always properly terminated.
Control that reaches the end of a function must see a return statement.
2011-01-28 13:14:30 +09:00
Bill Currie
9159daf99d Do simple unreachable block analysis and dead block removal. 2011-01-28 11:45:04 +09:00
Bill Currie
90a2738459 Add the label to the block to which it refers. 2011-01-28 11:41:53 +09:00
Bill Currie
4738c767a2 Fix branch label handling.
Conditional branches and goto now go to the correct location.
2011-01-27 21:11:32 +09:00
Bill Currie
71b5decbe8 Get assignments to .return working.
I really do not like the mechanism I currently use for handling pointer
derefences vs pointer assignments, but this will have to do for now until
I can get qfcc producing code again.
2011-01-27 15:44:11 +09:00
Bill Currie
56106892c8 The & operator produces a pointer, not void. 2011-01-27 15:44:10 +09:00
Bill Currie
6ce3c5a59a Get statments being emitted to the code segment.
The first function seems to work fine, but there's a problems with the
scope of params causing params to get their knickers in a twist (tangled
linked list).
2011-01-25 15:46:48 +09:00
Bill Currie
fd3b594ca5 Move label relocs to the relevant statement block. 2011-01-25 15:45:31 +09:00
Bill Currie
0624408317 Move the diagnostic functions into their own file. 2011-01-24 21:54:57 +09:00
Bill Currie
d618e51dc8 Move save_string and make_string into strpool
Might not be the perfect place, but at least they're strongly related.
2011-01-24 21:32:48 +09:00
Bill Currie
a79b6f0a6c Partially implement casts. 2011-01-23 11:53:08 +09:00
Bill Currie
55d3d17807 Add a missing break.
"return" falling through to "goto" was bad news :)
2011-01-22 15:52:01 +09:00
Bill Currie
3b462e16cf Produce flow diagrams of the basic blocks. 2011-01-22 11:40:53 +09:00
Bill Currie
bcb2667b73 Possibly get vector calls working. 2011-01-21 19:40:46 +09:00
Bill Currie
52b561f7cb Nuke bind expressions.
Since I'm planning on implementing CSE and other optimizations, they're
rather redundant (and I'm having trouble getting them to work).
2011-01-21 19:07:58 +09:00
Bill Currie
977c48d728 Make operator type overrides clear. 2011-01-21 15:57:53 +09:00
Bill Currie
aec9f256a7 Get calls mostly working.
Bind seems to be broken, but parameters seem to be being set correctly.
2011-01-21 15:54:53 +09:00
Bill Currie
96fae582e3 Implement bind expressions. 2011-01-21 11:27:40 +09:00
Bill Currie
4a24393d8d Temp expressions now use operands instead of defs. 2011-01-21 11:26:43 +09:00
Bill Currie
2998e578fb Get very basic deref assignments working.
More complicated expressions will not work yet.
2011-01-21 10:59:16 +09:00
Bill Currie
ff6e2584da Handle block sub-expressions that produce results. 2011-01-21 10:57:47 +09:00
Bill Currie
16e013ff5d Allow the operand to override the symbol's type. 2011-01-21 10:56:32 +09:00
Bill Currie
3f2793ef72 Get a lot of statements being generated. 2011-01-20 23:26:13 +09:00
Bill Currie
e45ea4b2ae Move the statement printing near the top of the file. 2011-01-20 18:07:24 +09:00