Commit Graph

1812 Commits

Author SHA1 Message Date
Bill Currie c4ba294433 Fix the icky fixme :) 2012-11-27 20:32:52 +09:00
Bill Currie a91f4cedeb Add the @nil keyword.
@nil is exactly the same as nil, but it is always available.
2012-11-27 18:33:42 +09:00
Bill Currie edeffd64e9 Fix a missed obj_module_s/_t from the class cleanup.
Doesn't seem to have caused any problems, but still :)
2012-11-27 18:33:42 +09:00
Bill Currie 31b07bcbbf Rewrite expr_alias().
Modifying the existing alias chain proved to be a bad idea (in retrospect,
I should have known better:P). Instead, just walk down any existing alias
chain to the root operand and build a new alias from that.
2012-11-27 18:33:41 +09:00
Bill Currie d6b38dd0ee Add an option to control expr tree dumping.
About bloody time :P
2012-11-26 21:00:28 +09:00
Bill Currie e28aa0a5fb Fix some errors in the set code.
I really need to write some unit tests for the set code, but with this (and
an uncommitted dags patch (still thinking about it)) ctf compiles.
2012-11-26 17:19:02 +09:00
Bill Currie 8e225cd726 Fix a missing label use count decrement.
if statements in dead code weren't being removed due to the label.
2012-11-26 16:13:59 +09:00
Bill Currie 24847857ef Fix some whitespace. 2012-11-26 16:13:40 +09:00
Bill Currie 128547b885 Resurrect the "next" pointers for labels and conditionals. 2012-11-26 16:09:53 +09:00
Bill Currie f7417345ba Rewrite print_bool to be more informative. 2012-11-26 15:47:10 +09:00
Bill Currie 147d00d41f Rewrite print_block making it more informative. 2012-11-26 15:04:33 +09:00
Bill Currie ce1d89ba50 Replace some of the quotes around node names.
Null expression pointers can show up unexpectedly, and printf's (null)
messes up dot.
2012-11-26 14:18:23 +09:00
Bill Currie 578ad07487 Fix yet another empty block issue.
I think I need to rework all the code in there, but this will do for now.
2012-11-25 15:01:36 +09:00
Bill Currie f6e5428382 Don't create default_expr unless needed.
The goto for the default expression is the source of the mis-counted label
users: the label was being counted by the goto, but the goto was never
being inserted into the code (only v6 progs or "difficult" types insert the
goto).
2012-11-24 21:53:00 +09:00
Bill Currie d0e56c91cc Detect non-initial nodes with no predecessors.
Such nodes are unreachable code (ie, dead blocks), but the dead block
removal code failed to remove them (current known cause: miscounted label
userrs). As such blocks cause problems for data flow analysis, ignoring
them is not a good idea. Thus make them an internal error.
2012-11-24 21:39:02 +09:00
Bill Currie 4f8b3b5692 More empty block checks. 2012-11-24 19:06:10 +09:00
Bill Currie 6e7aaac1b9 Fix the wording of a comment. 2012-11-24 19:06:01 +09:00
Bill Currie b68401e552 Produce a debug print when using jump tables. 2012-11-24 17:55:57 +09:00
Bill Currie 4c1dc568e0 Cop out on uninitialized large variables.
vectors, quaternions and structs are a little tricky. I need to think about
how to get them working, but I also want qfcc to get through as much code
as possible.
2012-11-24 16:49:46 +09:00
Bill Currie 40c97f9570 Tread immediate move statements similarly to assignments.
They're used for structure assignment in near data space. This fixes the
bogus uninitialized warnings on fully initialized structs.
2012-11-24 16:47:44 +09:00
Bill Currie 7f229b7682 Remove execessive html quoting.
Heh, I must have put that in long before I did the quoting functions.
2012-11-24 15:42:21 +09:00
Bill Currie dbbca47a3b Mark initialized struct/array defs as initalized.
Also, use the initialized flag for setting up the initalized var set in
flow_uninitialized().
2012-11-24 15:26:27 +09:00
Bill Currie f4604d9db5 Remove gotos that go to the following statement.
eg:
	goto foo:
foo:
	//some code
2012-11-24 15:08:48 +09:00
Bill Currie 738fc65e0f Treat global vars as always live.
This fixes the infloop.r test.
2012-11-24 14:56:30 +09:00
Bill Currie bdafdad0d5 Treat flow control statements separately.
I'm not convinced this is the correct fix for while (count--), but it does
work.
2012-11-24 12:53:51 +09:00
Bill Currie 607d7dd45e Simplify the child match in dagnode_match.
I have no idea why I did it that way when all that's needed is to check the
child pointers. Well, that's modulo.r fixed :)
2012-11-22 21:59:01 +09:00
Bill Currie eef399209d Add some very evil pragmas.
The evil comment is not just "pragmas are bad, ok?", but switching between
advanced, extended and tradtitional modes when compiling truly is evil and
not guaranteed to work. However, I needed it to make building test cases
easier (it's mostly ok to go from advanced to extended or tradtional, but
going the other way will probably cause all sorts of fun).

In the process, opcode_init now copies the opcode table data rather than
modifying it.
2012-11-22 21:59:01 +09:00
Bill Currie 4b5e00afdf Do a bunch of refactoring.
The dag creation loop was getting too messy.
2012-11-21 18:30:44 +09:00
Bill Currie c5f2e3c4ad Make dag dumping from gdb easier. 2012-11-21 15:03:44 +09:00
Bill Currie bedde02307 Make flow graphs with dags easier to read.
The node contents are now the dag rather than the dag being attached to the
node.
2012-11-21 13:43:03 +09:00
Bill Currie c759b73b24 Cope with empty sblocks when producing dot graphs. 2012-11-21 12:23:15 +09:00
Bill Currie 2c09464e80 Don't attach a dag label to its own node.
This kills a = a; statements :)
2012-11-21 12:16:10 +09:00
Bill Currie 0583dc82d3 Treat uninitialized temps as a bug.
It really should be impossible, but I'm not sure where the bug is yet
(though there are uninitialized variables that are false positives that
most definitely are initialized, might be related)
2012-11-21 10:26:41 +09:00
Bill Currie 86968f662e Store the function type in function values.
This fixes IMP msg = nil;
2012-11-21 10:06:15 +09:00
Bill Currie 686937123c Ensure flowvars always point to the var itself.
Pointing to aliases of the var causes all sorts of problems, but this time
it was causing the uninitialized variable detector to miss certain
parameters.
2012-11-21 09:43:59 +09:00
Bill Currie 0dc306c4b7 Fix the initialized var data flow.
Now most false positives have been fixed. Just some problems with aliased
vars (next) and then the usual false positives caused by branches.
2012-11-21 09:42:02 +09:00
Bill Currie 547ea78ad7 Implement uninitialized variable checking.
It currently gets a lot of false positives (globals and parameters?), but
the initial tests for just local vars worked.
2012-11-20 21:49:47 +09:00
Bill Currie d8a5d6745f Add a param flag to defs.
It is necessary to know if a def is a function parameter so it can be
treated as initialized by the flow analyzer. The support for the flag in
object files is, at this stage, purely for debugging purposes.
2012-11-20 17:50:59 +09:00
Bill Currie a734feacfd Create the .parN variables for varargs functions.
Ouch, 2 years and this is the first test?
2012-11-20 17:14:58 +09:00
Bill Currie 984aa9a4cf Support entity.field = structvar2 = structvar1;
The structvar2 = structvar1 is implemented as a move expresion, which
address_expr didn't like. Return the address of the source. For indirect
move expressions, this is just the source expression itself.
2012-11-20 17:12:16 +09:00
Bill Currie 5cfeb7809f Fix a missing ; 2012-11-20 17:11:39 +09:00
Bill Currie b91bb2e915 Add direct moves to expression dumping. 2012-11-20 16:55:19 +09:00
Bill Currie 87121b4cf1 Be slightly picky about which nodes to kill.
Constant/label nodes should never be killed because they can (in theory)
never change. While constants /can/ change in the Quake VM, it's not worth
worrying about as there would be much more important things to worry about
(like 2+2 not giving 4).

Due to the hoops one would have to jump through, it is assumed that a
pointer or an offset from that pointer will never overwrite the pointer.
2012-11-20 15:28:57 +09:00
Bill Currie 22d72f33d2 Match pointer dereferences with pointer assignements.
Having the source operand of a pointer assignment available to later
instrctions can make for more efficient code as the value does not need to
be dereferenced later. For this purpose, pointer dereference dag nodes now
store the source operand as their value, and dagnode_match will match x=a.b
with *(a+b)=y so long as both a and b are the same in both nodes. x and y
are irrelevant to the match. The resulting code will be the equivalent of:
    *(a+b) = y;
    x = y;
2012-11-20 15:22:05 +09:00
Bill Currie 36e359e2ee Correct a typo. 2012-11-20 15:19:32 +09:00
Bill Currie ef0f30935f Kill all dag nodes on pointer assignment.
It's brutal, but it works and is conservatively correct.
2012-11-20 14:30:42 +09:00
Bill Currie f83cf1748f Allow node() to work for all operand types.
This is a bit of an expermiment to get better dags (more node reuse).
2012-11-20 14:23:43 +09:00
Bill Currie 1472fec7f2 Factor out the live vars magic from dag_create.
The code is messy enough as it is :P
2012-11-20 13:44:36 +09:00
Bill Currie 06a62be1d5 Fix redundant constant values.
I had forgotten to add the new value to the hash table. Oops.
2012-11-20 13:33:57 +09:00
Bill Currie 56103f9a38 Treat global variables as live at the end of a function.
.return and .param_N are not classed as global variables for data flow
analysis. .return is taken care of by return statements, and .param_N by
call statements.

With this, the menus work up to attempting to load the menu plist.
Something is corrupting zmalloc's blocks.
2012-11-19 17:21:35 +09:00