Commit Graph

146 Commits

Author SHA1 Message Date
Bill Currie 1cd5ea5732 [qfcc] Add support for named labels in statements
Yeah, I've finally decided to implement goto. Limited to function scope
of course.
2020-03-11 12:49:10 +09:00
Bill Currie 9b269c2f8e [qfcc] Fix mangled method parameters
Method parameters (ie, extra parameters without selector names) were
getting reversed during function type construction.
2020-03-06 17:37:58 +09:00
Bill Currie 1459361cbd [qfcc] Set builtin function def flags
This fixes the missing redefinition error when a builtin is defined
twice (and thus corrupting the function chain).
2020-03-05 11:48:15 +09:00
Bill Currie 5893bd7501 [qfcc] Catch erroneous negative builtin numbers
Setting a builtin number negative makes it a non-builtin function, but
possibly in the middle of another function. Not good.
2020-03-02 13:47:46 +09:00
Bill Currie 80d9401eee [qfcc] Report errors for objects in function decls
The number of time's I've forgotten the * in a declaration in objective
code (probably thanks to C#'s lack of them).
2020-03-01 17:44:13 +09:00
Bill Currie caa297b756 [qfcc] Remove type alias encoding
It proved to be too fragile in its current implementation. It broke
pointers to incomplete structs and switch enum checking, and getting it
to work for other things was overly invasive. I still want the encoding,
but need to come up with something more robust.a
2020-03-01 16:13:18 +09:00
Bill Currie 69b5029de5 Throw away function parameter type alias info
typedef is meant to create a simple renaming of a potentially complex
type, not create a new type. Keeping the parameter type alias info makes
the types effectively different when it comes to overloaded function
resolution, which is quite contrary to the goal. Does expose some
breakage elsewhere, though.
2020-02-26 17:46:53 +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 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 a4a57b6ffd Implement aligned allocations 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 8920c59515 Find @override functions even when there's only one 2020-02-15 23:49:12 +09:00
Bill Currie 7e31704ebe Be more informative for pass by value size errors 2019-06-06 06:46:38 +09:00
Bill Currie ff5c1cd4c2 Clean up redundant type parameter to initialize_def. 2018-10-15 22:11:20 +09:00
Bill Currie ca0b03687f Change the naming of ALLOC's free-list.
Rather than prefixing free_ to the supplied name, suffix _freelist to the
supplied name. The biggest advantage of this is it allows the free-list to
be a structure member. It also cleans up the name-space a little.
2013-03-08 22:16:31 +09:00
Bill Currie 955e3ee258 Initialize the type to be ev_func.
This fixes the returning of the wrong function symbol when resolving
overloaded functions and one of the functions takes no parameters.
2013-01-07 13:52:48 +09:00
Bill Currie 338bb9bba0 Look up the function symbol when resolving overloaded functions.
This fixes the bogus undefined symbol errors when resolving unambigous
overloaded functions.
2013-01-07 13:51:01 +09:00
Bill Currie 681bd6f4b2 Don't try to emit code if there have been errors.
The expression tree can't really be trusted if there have been errors.
While warnings as errors are another matter, it's not worth sorting out.
2012-12-22 19:22:08 +09:00
Bill Currie fe7cd7e7a7 Catch omitted parameter names from function definitions.
void foo (int); is fine for a prototype (or, presumably, a qc function
variable), but not for an actual function body. This fixes the segmentation
fault when the parameter name is omitted.
2012-12-20 10:10:41 +09:00
Bill Currie 2317811f2b Don't allocate space for locals for builtin functions.
While the symtab is needed for debug info, there is no need for any actual
data to be allocated for a builtin function's locals.
2012-12-15 13:13:40 +09:00
Bill Currie 1c99cf50da Clean up the flow api a little. 2012-12-09 20:50:53 +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 0585471723 Make defspaces typed.
Simply "backed" and "virutal". Backed spaces have memory allocated to them
while virtual spaces do not. Virtual spaces are intended for local
variables and entity fields.
2012-12-04 14:16:52 +09:00
Bill Currie 0872961269 Do a little bit of cleanup. 2012-12-04 12:48:52 +09:00
Bill Currie 72108ba0b5 Document def.h.
Also remove the extern for current_storage as it belongs in shared.h.

I'm not satisfied with the documentation for initialize_def, but it will do
for now. I probably have to rewrite the thing as it's a bit of a beast.
2012-12-02 19:54:20 +09:00
Bill Currie 5725c5124c Rename the storage_class_t enum values.
With the intoduction of the statement type enum came a prefix clash. As
"st" makes sense for "statement type", I decided that "storage class"
should be "sc". Although there haven't been any problems as of yet, I
decided it would be a good idea to clean up the clash now. It also helps
avoid confusion (I was a bit surprised after working with st_assign etc to
be reminded of st_extern etc).
2012-12-02 10:11:30 +09:00
Bill Currie d47fa0fc89 Make the new optimizations optional.
The usual -O :) (no numbers yet, though). Alternatively, -C [no-]optimize
may be used.
2012-12-01 11:13:45 +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 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
Bill Currie d76e2a8423 Make a start on regenerating code from dags.
Some parts are a lot messier than I thought, so the actual codegen in the
dags code is just a minimal stub for now.
2012-11-15 13:44:09 +09:00
Bill Currie c358a0e77e Create a function to generalize dot dumping.
Now, any time a graph is wanted, the file can be consistently named without
a lot of messy code.
2012-11-15 13:44:08 +09:00
Bill Currie cd224c00d4 Add live variable info to flow graph dumps.
Things are a little bogus, but at least the bogosity is visible :)
2012-11-15 13:44:08 +09:00
Bill Currie 8817c4a1c2 Re-enable the flow graph dumping.
It's still in a bogus place, but it's necessary.
2012-11-15 13:44:08 +09:00
Bill Currie 4b64912793 Begin doing some data flow analysis.
In te beginning, live variables.
2012-11-15 13:44:08 +09:00
Bill Currie 0b49bd343c Collect information on statements that set or use vars.
First, it turns out using daglabels wasn't such a workable plan (due to
labels being flushed every sblock). Instead, flowvars are used. Each actual
variable (whether normal or temp) has a pointer to the flowvar attached to
that variable.

For each variable, the statements that use or define the variable are
recorded in the appropriate set attached to each (flow)variable.
2012-11-15 13:44:08 +09:00
Bill Currie 98245f6d00 Bury a dead field. 2012-11-15 13:44:07 +09:00
Bill Currie d7177a78e9 Rewrite the flow graph code.
The flow graph nodes are now properly separated from the graph, and edge
information is stored in the graph struct. This actually made for much
cleaner code (partly thanks to the use of sets and set iterators).

Flow graph reduction has been (temporarily) ripped out as the entire
approach was wrong. There was also a bug in that I didn't really understand
the dragon book about selecting nodes and thus messed things up. The
depth-first search tree "fixed" the problem, but was really the wrong
solution (sledge hammer :P).

Also, now that I understand that dot's directed graphs must be acyclic, I
now have much better control over the graphs (back edges need to be
flipped).
2012-11-15 13:44:07 +09:00
Bill Currie 2da038ce0f Bring back dot_flow.c.
However, it produces simplified flow graphs (ie, just nodes and edges, no
statements, though later on data flow information will be added).
2012-11-15 13:44:07 +09:00
Bill Currie 8b374305d2 Rename dot_flow.c and print_flow.
They're now dot_sblock.c and print_sblock. The new names both better
reflect their purpose and free up "flow" for outputting the real flow
analysis graphs.
2012-11-15 13:44:07 +09:00
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 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 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 93b007b1f8 Take care of relocs when defining external defs.
For most of the cases, some relocs may have been lost, but they were
certainly lost for type encodings. Now that all seems to be fixed.
2012-11-12 16:14:09 +09:00
Bill Currie 61ef901254 Tweak some FIXMEs. 2012-11-08 17:03:02 +09:00
Bill Currie ed4018fd8d Clear out the function overloading tables between compiles.
Fixes some issues with multiple compiles (especially mixed languages!).
2012-11-01 20:53:33 +09:00
Bill Currie ec42bde527 Make hash tables more const correct.
And clean up the resulting mess :/
2012-10-27 11:44:31 +09:00