Commit graph

615 commits

Author SHA1 Message Date
Bill Currie
db460155e9 Fix multiple function calls in expressions. 2013-09-27 23:15:57 +09:00
Bill Currie
3295370328 Expose and use field_expr().
This may cause problems later on, but it is needed for the binary_expr()
cleanup.
2013-09-27 23:15:57 +09:00
Bill Currie
ca9693d9cd Expose convert_from_bool(). 2013-09-27 23:15:57 +09:00
Bill Currie
7f50333b2c Add support for constant [] vector expressions. 2013-09-27 23:15:57 +09:00
Bill Currie
7a7a685105 Add support for actual vector expressions.
Currently, they can represent either vectors or quaternions, and the
quaternions can be in either [s, v] form or [w, x, y, z] form.

Many things will not actual work yet as the vector expression needs to be
converted into the appropriate form for assigning the elements to the
components of the "vector" type.
2013-09-27 23:15:57 +09:00
Bill Currie
a6cdc8735a Start implementing vec = [x,y,z].
This is a nice feature found in fteqcc (also a bit of a challenge from
Spike). Getting bison to accept the new expression required rewriting the
state expression grammar, so this is mostly for the state expression. A
test to ensure the state expression doesn't break is included.
2013-09-27 23:15:56 +09:00
Bill Currie
cef2136050 Implement "not" logic for while and do-while.
This goes towards complementing the "if not" logic extension. I need to
check if fteqcc supports "not" with "while" (the version I have access to
at the moment does not), and also whether it would be good  to support
"not" with "for", and if so, what form the syntax should take.
2013-06-26 23:04:35 +09:00
Bill Currie
6fa63f6c54 Implement the basics of fteqcc's -Fifstring.
It's -Cifstring in qfcc, but otherwise the intent is the same. More testing
and investigation into what fteqcc does is required.
2013-06-26 23:02:55 +09:00
Bill Currie
8d34d33055 Implement "if not (foo)" syntax.
It is syntactic sugar for if (!(foo)), but is useful for avoiding
inconsistencies between such things as if (string) and if (!string), even
though qcc can't parse if not (string). It also makes for easier to read
code when the logic in the condition is complex.
2013-06-26 23:02:55 +09:00
Bill Currie
fd1ea9e00e Add an option to control the enum switch warning. 2013-06-26 09:29:37 +09:00
Bill Currie
46d2959908 Delay calling find_type for enums.
As find_type encodes the type too, calling find_type before the enumerators
have been created causes the type encoding to lose the enumerators.
2013-01-17 20:55:25 +09:00
Bill Currie
76a69d9a53 Implement fteqcc's "nosave" specifier.
Of course, it's "@nosave" for traditional progs, but that's only a define
away.
2013-01-07 14:35:34 +09:00
Bill Currie
386a729209 Remove dead nodes from dags.
Dead nodes are those that generate unused values (unassigned leaf nodes,
expressions or destinationless move(p) nodes). The revoval is done by the
flow analysis code (via the dags code) so that any pre and post removal
flow analysis and manipulation may be done (eg, available expressions).
2012-12-25 17:07:58 +09:00
Bill Currie
b295524385 Add new_value_expr().
This simplifies creating a new expression for an arbitrary value object.
2012-12-23 19:29:50 +09:00
Bill Currie
42ba0c9d54 Add alias_value() function.
alias_value returns a new value where only the type is different, the
bit-pattern of the value itself is untouched.
2012-12-23 19:25:35 +09:00
Bill Currie
6eb6b6c0ba Change pointer_t to unsigned and clean up the mess.
It doesn't make sense to have negative pointers. The size of the commit is
from enabling gcc's -Wtype-limits warning and cleaning up that mess too.
2012-12-21 21:53:13 +09:00
Bill Currie
6d6f231bd2 Fix mangling of types when attaching protocols.
The protocol attachment test was in the wrong place, and there were some
typos in compare_protocols and procollist_find_protocol.
2012-12-20 13:12:05 +09:00
Bill Currie
211a7a8bbb Create and use more type checking functions. 2012-12-20 11:11:59 +09:00
Bill Currie
8c2af5cff7 Add more convenience functions.
Cleans up obj_types_assignable a little.
2012-12-20 10:10:41 +09:00
Bill Currie
3af031c33d Move the rest of the obj specific stuff into class.c.
This gives better hiding of implementation details.
2012-12-20 10:10:41 +09:00
Bill Currie
7cb2e40bce Add is_pointer convenience function. 2012-12-20 10:10:41 +09:00
Bill Currie
64c98bd4c3 Rename is_id to obj_is_id.
Better naming convenion.
2012-12-20 10:10:41 +09:00
Bill Currie
4f81a659b4 Move is_id() from type to class.
type_id's implementation should remain "private" to class.c
2012-12-20 10:10:41 +09:00
Bill Currie
f181772a76 Attach protocolrefs to class types.
The protocolrefs (as protocollist_t) are attached to the type as a
qualifier.
2012-12-20 10:10:41 +09:00
Bill Currie
3270bb3f5e Make node numbering int rather than unsigned.
(unsigned) -1 is not what I wanted :P
2012-12-19 16:50:06 +09:00
Bill Currie
c7ae58d7a3 Allow flownodes and sblocks to be numbered independently.
The numbering will need to be independent when unreachable nodes are
removed.
2012-12-19 16:22:15 +09:00
Bill Currie
3e38c4aa48 Merge branch 'qfcc-cse'
qfcc now does local common subexpression elimination. It seems to work, but
is optional (default off): use -O to enable. Also, uninitialized variable
detection is finally back :)

The progs engine now has very basic valgrind-like functionality for
checking pointer accesses. Enable with pr_boundscheck 2
2012-12-13 20:17:28 +09:00
Bill Currie
2dc60d4f9a Allow tests for full overlap of defs.
Not actually used yet, but I imagine I'll want it.
2012-12-13 14:42:51 +09:00
Bill Currie
c61e03a0b9 Clean up operand creation.
Rather than having the creation scattered through the code, use helper
functions. Makes exposing operand creating saner.
2012-12-13 12:49:00 +09:00
Bill Currie
204a0b3f72 Make def_visit_all return the actual result of visit.
This way, def_visit_all is a little more useful (though I think I might
redo the one case that's using this feature).
2012-12-13 09:47:00 +09:00
Bill Currie
75be251d65 Create and use def_visit_all.
Even though it turned out there were only two copies of the def alias
handling code, I got tired of writing it. The code is easier to read, too
:)
2012-12-12 12:01:31 +09:00
Bill Currie
76c9aa2930 Handle alias defs when building a dag.
When an alais def (or aliased def) is used, any overlapping aliases that
have previously been assigned need to be marked as live, and edges to the
aliases added to the new node. However, when assigned to, live-forcing
needs to be turned off.

This fixes the lost assignments to .super.
2012-12-11 19:57:19 +09:00
Bill Currie
7607c7d649 Resurrect alias operands.
It turns out they are necessary for the code output from dags. This fixes
the ice for *to = *from++;
2012-12-11 15:52:37 +09:00
Bill Currie
8582e9de63 Make it possible to dump statement blocks in a flow graph.
Much nicer looking with proper back edges :). Not actually enabled, though.
2012-12-11 11:31:55 +09:00
Bill Currie
3aa3a0945a Scan the statements in a node with suspect var usage.
When the naive uninitialized variable detection finds a node with possible
uses of uninitialized variables, the statements in the node are scanned one
at a time checking each usage and removing uninitialized definitions as
appropriate. vectest.r now compiles without warnings. As an added bonus,
accurate line number information is reported for uninitialized variables.

Unfortunately, there is still a problem with uninitialized temps in
switch.r, but that might just be poor handling of temp op aliases.
2012-12-10 20:49:08 +09:00
Bill Currie
2e105f17f2 Enable live var flow dumps. 2012-12-10 15:27:07 +09:00
Bill Currie
8f274f5b1d Add convenience functions for getting a def's offset and size. 2012-12-10 14:40:43 +09:00
Bill Currie
d717a0b3f2 Add dummy nodes at the beginning and end of the graph.
The dummy nodes are for detectining uninitialized variables (entry dummy)
and making globals live at function exit (exit dummy). The reaching defs
and live vars code currently seg because neither node has had its sets
initialized.
2012-12-10 13:56:26 +09:00
Bill Currie
4f70b48370 Add a function to check if two defs overlap.
Very useful for alias handling :)
2012-12-10 13:23:45 +09:00
Bill Currie
fa45ab842f Make the reaching defs dot dump optional. 2012-12-10 12:17:20 +09:00
Bill Currie
e4dd86c36b Calculate reaching defs. 2012-12-09 22:37:59 +09:00
Bill Currie
1c99cf50da Clean up the flow api a little. 2012-12-09 20:50:53 +09:00
Bill Currie
054d902d3a Document alias defs.
The diagram showing the basics of how alias defs work is in a spearate file
because it created to much clutter in the header file.
2012-12-09 19:43:12 +09:00
Bill Currie
eb8fd55677 Move set.c into libQFutil.
Also move the ALLOC/FREE macros from qfcc.h to QF/alloc.h (needed to for
set.c).

Both modules are more generally useful than just for qfcc (eg, set
builtins for ruamoko).
2012-12-06 20:52:53 +09:00
Bill Currie
b28ac6672b Add support for set of everything, and a lot of docs.
Set of everything is implemented by inverting the meaning of bits in the
bitmap: 1 becomes non-member, 0 member. This means that set_size and
set_first/set_next become inverted and represent non-members as counting
members becomes impossible :)
2012-12-06 19:32:31 +09:00
Bill Currie
b6ae9867c2 Fully connect temps and their aliases. 2012-12-06 09:40:16 +09:00
Bill Currie
7071a46936 Make convert_value create a new value.
It operating in-place proved to be troublesome.
2012-12-05 22:16:08 +09:00
Bill Currie
a099847026 Do a little bit of const correctness for type.[ch]
It's only the beginning :/
2012-12-05 22:15:19 +09:00
Bill Currie
08b27efe33 Nuke the return type flow calculations.
They've proven to be unnecessary with the recent symbol/def changes.
2012-12-05 19:56:10 +09:00
Bill Currie
3f3b501c58 Move flowvar/deflabel from symbol_t to def_t.
With the need to handle aliasing in the optimizer, it has become apparent
that having the flow data attached to symbols is not nearly as useful as
having it attached to defs (which are views of the actual variables).

This also involves a bit of a cleanup of operand types: op_pointer and
op_alias are gone (this seems to greatly simplify the optimizer)

There is a bit of a problem with enums in switch statements, but this might
actually be a sign that something is not quite right in the switch code
(other than enums not being recognized as ints for jump table
optimization).
2012-12-05 19:47:22 +09:00