Bill Currie
c483770121
Rework flow.c with the aim of graph reduction.
...
Much of the data recently added to sblock_t has been moved to flownode_t.
No graph reduction is carried out yet, but the initial (innermost level)
graph has been built.
2012-11-15 13:44:07 +09:00
Bill Currie
da446fd343
Detect natural loops.
...
Non-nested loops that have the same head-node are merged into one loop.
However, loop nesting is not currently detected (next step).
2012-11-15 13:44:07 +09:00
Bill Currie
8fb958603c
Add set_first.
...
It returns the first element of a set. If the set is empty, -1 (unsigned)
is returned.
2012-11-15 13:44:07 +09:00
Bill Currie
4cc8d4a04b
Fix an apparent snafu in set_test.
...
It looks like a bit of case&paste where I forgot to change != to &.
2012-11-15 13:44:07 +09:00
Bill Currie
1fead50f4e
Calculate the dominators of each node in the flow graph.
...
The dominators are represented by sets using the node numbers.
2012-11-15 13:44:07 +09:00
Bill Currie
964ea7f9fe
Add set_as_string for debug output.
2012-11-15 13:44:07 +09:00
Bill Currie
d2fab28d01
Implement set_is_member.
...
Oops, forgot that one.
2012-11-15 13:44:06 +09:00
Bill Currie
7853bf1859
Calculate a node's successors and predecessors.
...
The dot graphs are a little odd (arrow heads on the wrong end of the
predecessor edges), but things seem to be correct.
2012-11-15 13:44:06 +09:00
Bill Currie
739ebc522c
Begin working on flow analysis.
...
For now, variable and flow graph node maps are built.
2012-11-15 13:44:06 +09:00
Bill Currie
5acf474882
Double quote dag labels.
...
Dot interprets escape sequences in non-html string, and needs the quotes to
be escaped, so quote the result of operand_string. Unfortunately,
operand_string uses quote_string and quote_string returns a static pointer,
so some hoop-jumping is necessary.
2012-11-15 13:44:06 +09:00
Bill Currie
cdc790d0c8
Add a set type and support code.
2012-11-15 13:44:06 +09:00
Bill Currie
60d03dbdd9
Fix the naive opcode checks.
...
Confusing . with .=, and < and <= with more <MOVE etc isn't good.
2012-11-15 13:44:06 +09:00
Bill Currie
dc9d2a982e
Make the returned dag a linked list of root-nodes.
...
A dag can have mulitple "root" nodes (ie, nodes with no parents).
2012-11-15 13:44:06 +09:00
Bill Currie
a22260030a
Use value for pointer operands.
...
This allows daglabels on pointer operands without a redundant daglabel
pointer.
2012-11-15 13:44:06 +09:00
Bill Currie
0c58cd9067
Generate only one daglabel for value operands.
...
As each value is now unique, their labels can also be unique, which will
improve CSE.
2012-11-15 13:44:06 +09:00
Bill Currie
16869cabd1
Fix a slew of uninitialized data problems.
...
Bah, structs on stacks... good fun :P
2012-11-15 13:44:06 +09:00
Bill Currie
01c8aaae8c
Add some error checking for attaching identifiers.
2012-11-15 13:44:06 +09:00
Bill Currie
0ccf4093e4
Handle attached identifier labels correctly.
...
I'd forgotten I had the prev field. Makes for much cleaner code.
2012-11-15 13:44:06 +09:00
Bill Currie
0cedf0d13a
Fix a bunch of mis-uses of an expressions's value.
...
The value field really should be treated as constant.
2012-11-15 13:44:06 +09:00
Bill Currie
28ce35f1c1
Make values independent objects.
...
values are now uniquely allocated (for the current object file). With
this, constants in dags will work.
2012-11-15 13:44:06 +09:00
Bill Currie
c57df8b5f3
Print all dag nodes in a dag.
...
Dags can have multiple roots, so only recursing once could miss much of the
dag.
2012-11-15 13:44:06 +09:00
Bill Currie
dbf1aa8f72
Attach dags to statement blocks.
...
Now, if a dag is attached to a statement block, it will be included in the
flowgraph with that statement block.
2012-11-15 13:44:06 +09:00
Bill Currie
39506881c0
Fix the completely bogus handling of "x" in dag creation.
...
That made a complete mashup of attached identifiers :P
2012-11-15 13:44:06 +09:00
Bill Currie
24553867a4
Use dashed lines for attached identifiers in dags.
2012-11-15 13:44:06 +09:00
Bill Currie
aa72f263ec
Use an extra temp for v6 float modulo.
...
It seems the dag creation algorithm doesn't like "a = a op a", so use
"b = a op a" instead. Since I plan on fixing temp leaks anyway, this won't
be a problem (also, few people even use qfcc's v6 float modulo :P).
2012-11-15 13:44:06 +09:00
Bill Currie
d9354255a3
Avoid double-printing dag nodes.
2012-11-15 13:44:05 +09:00
Bill Currie
7b2e426545
Support temp operands in dags.
2012-11-15 13:44:05 +09:00
Bill Currie
9bc65ffedb
Start actually trying to build dags.
...
Temporary variables aren't being handled correctly (treated as constants),
but it looks like a good start.
2012-11-15 13:44:05 +09:00
Bill Currie
b7b6294d87
Fix some dag printing goofs.
...
Typo and no node recursion.
2012-11-15 13:44:05 +09:00
Bill Currie
aa2943709e
Start work on building dags from basic blocks.
...
Doesn't compile and the design is in flux anyway, but I want to get back to
iqm.
2012-11-15 13:44:05 +09:00
Bill Currie
60108c688c
Change dags from binary to trinary.
...
I'd forgotten some instructions take three inputs that can benefit from
CSE.
2012-11-15 13:44:05 +09:00
Bill Currie
0fefeb73fe
Initial support for basic block dags.
...
Currently, only dumping to dot, but that seems to be a very sensible place
to start: debug support.
2012-11-15 13:44:05 +09:00
Bill Currie
ee8247ec61
Support using enums as array indices.
2012-11-15 13:39:23 +09:00
Bill Currie
f18a4d3c4a
Support pointer - pointer.
2012-11-15 13:38:57 +09:00
Bill Currie
552142497e
Support progs.dat when dumping type encodings.
...
Knock up a quick and dirty progs-to-qfo "converter" (strings and types
only) to re-use the qfo types dumper.
2012-11-15 11:58:13 +09:00
Bill Currie
9691b50f0f
Make .type_encodings more useful.
...
Rather than just a pointer, it is now a struct with a pointer and size
indicating the extent of the type encodings block.
2012-11-15 11:57:16 +09:00
Bill Currie
74ac4ee142
Fix a misplaced line.
2012-11-15 11:00:51 +09:00
Bill Currie
39c1034afb
Relocate the data in the type encodings space.
...
Because of the way it is used, the data in the type encodings space needs
to always be correct (ie, relocated), even for partially linked object
files.
2012-11-14 20:37:19 +09:00
Bill Currie
453ac11bc3
Correct some comments.
2012-11-14 17:13:14 +09:00
Bill Currie
2685d38059
More paranoia when dumping qfo type encodings.
2012-11-14 16:32:41 +09:00
Bill Currie
3b3e013d4a
Do not demand a defined def is actually global.
...
Rather, only that it is neither external nor local. The idea was to catch
myself swapping the arguments to resolve_external_def, but for some reason
I decided type encoding defs would not be global (save game reasons?).
2012-11-14 15:50:55 +09:00
Bill Currie
acc188d62b
Ressurect the builtin symbol type fixup.
...
I was a little overzealous when gutting process_type_space :P
2012-11-14 15:49:19 +09:00
Bill Currie
33eb3f2418
A bit of pointer saftey in add_defs.
...
Directly accessing odef after can be dangerous (probably not here, but
hey), so use the defref instead.
2012-11-14 13:25:30 +09:00
Bill Currie
00c87434bf
A touch of whitespace.
2012-11-14 13:25:03 +09:00
Bill Currie
281e203545
Make process_data_def use the correct def tables.
...
Fixes the bogus redefined errors when entity fields are used.
Also, rename extern_defs and defined_defs to extern_data_defs and
defined_data_defs (more consistent with the other tables).
2012-11-14 13:14:54 +09:00
Bill Currie
e05c12e16d
Make linker_add_def take a pointer for the value.
...
While it looks like I might not use it for the type encodings, it should be
useful in the future.
2012-11-14 13:12:58 +09:00
Bill Currie
51236b0693
Fix the incorrect type space reloc offsets.
...
The problem was caused by add_relocs and process_loose_relocs adjusting the
reloc offset based on the reloc's space's base address. This is fine for
most relocs, but as relocs for the type space have already been adjusted by
process_type_space, those relocs must be left alone by add_relocs and
process_loose_relocs. As a bonus, the duplicate code has been refactored
into a separate function :)
2012-11-14 10:29:45 +09:00
Bill Currie
31739f4dbf
Rewrite the type_space processing.
...
Now each encoding is copied across def by def using memcpy, with the
expectation that any references to other types will be handled via the
reloc system. Unfortunately, it seems there's an off-by-4 (hmm, suspicious
number...) in the reloc offsets, but I'll look into that after I get some
sleep.
2012-11-13 21:55:54 +09:00
Bill Currie
8625964634
Fix some careless inernal_error changes.
...
Back when I did the abort->internal_error change, I wasn't paying attention
and forgot I should use linker_internal_error in linker.c.
2012-11-13 21:51:16 +09:00
Bill Currie
f80a74228c
Add (and use) alloc_data for work qfo data allocations.
...
defspace_alloc_loc can cause a realloc which will break the work qfo space
data pointers, so wrap it with alloc_data, which updates the appropriate
pointers and sizes.
2012-11-13 21:48:46 +09:00