Commit graph

3812 commits

Author SHA1 Message Date
Bill Currie
7c922d2320 Update the blender map editor for 2.80+ 2020-04-15 11:22:07 +09:00
Bill Currie
31abf6f955 [qfcc] Fix some wrong fall-through cases
This fixes the unary minus issue for now. unary_expr needs a rewrite,
though: it's just horrible.
2020-04-08 21:23:57 +09:00
Bill Currie
d5604aef73 [qfcc] Add failing test for unary minus
Producing a void type... very odd.
2020-04-08 21:12:56 +09:00
Bill Currie
2bec2527b4 [gamecode] Re-expose PR_LoadStrings
It's required for qfprogs now that PR_LoadDebug reads strings early.
2020-04-04 14:33:49 +09:00
Bill Currie
7c5c462587 [qfcc] Write debug data space to sym file
This should keep things nicely extensible, since additional data can be
done in the data space and found using defs. This gets the compilation
units into the sym file.
2020-04-03 21:25:47 +09:00
Bill Currie
9400b9b115 [qfcc] Add a leading . to the compile_unit def 2020-04-03 19:56:07 +09:00
Bill Currie
453c646d85 [qfcc] Improve dependency checks for tests
They worked well if there was only one source file in the test, but
failed if there were two or more. While only typelinker needed the
enhanced macros, I got them all because I generally copy the nearest
block when adding a new test thus it's best if they're all "correct".
2020-04-03 19:54:25 +09:00
Bill Currie
718f243f69 [qfcc] Relocate loose string relocs when linking
This helps make partially linked object files make more sense when
looking at strings in data spaces.
2020-04-03 15:58:22 +09:00
Bill Currie
049b8f392c [qfcc] create a compilation unit for debug data
The compilation unit stores the directory from which qfcc was run and
any source files mentioned. This is similar to dwarf's compilation unit.
Right now, this is the only data in the new debug space, but more might
come in the future so it seems best to treat the debug space separately
in the object files.
2020-04-03 15:07:13 +09:00
Bill Currie
65e7df44d3 [qfcc] Add function to see if a string is in a pool
Makes for a nice string set.
2020-04-03 14:22:44 +09:00
Bill Currie
9089744290 [qfcc] Add a function to safely get cwd
getcwd is assumed to use malloc if its buff param is null. This may need
fixing in the future, but it's in one spot. The result in "saved" in the
non-progs pool.
2020-04-03 14:22:31 +09:00
Bill Currie
4b34bf3d95 [qfcc] Take optional space param for emit_structure
If the space param is null, the far data space is used.
2020-04-03 14:16:16 +09:00
Bill Currie
f8d9b720de [qfcc] Free data spaces between compiliations 2020-04-03 14:14:34 +09:00
Bill Currie
d69db50cf9 [qfcc] Remove path stripping
It never really helped sort out the path issues when using build
directories. It worked well enough for single directory projects, but
things got messy very quickly, especially when mixing ruamoko libs with
external progs. A better method based on dwarf is coming.
2020-04-03 00:50:06 +09:00
Bill Currie
5d06596814 [qfcc] Fix test harness after .ctor change 2020-04-03 00:20:39 +09:00
Bill Currie
a09eabeb4d [qfcc] Fix some const attribute warnings
Try to anticipate gcc's warnings and it one-ups you :P
2020-04-01 21:17:13 +09:00
Bill Currie
17bb408b57 [qfcc] Clean up stray dags edges
Killed nodes can leave stray (dangling) edges that cause some confusion
in the dot graphs and may cause problems later on down the track, so
ensure there are no dangling edges.
2020-04-01 16:06:45 +09:00
Bill Currie
199b3e82d9 [qfcc] Add killer node to replacement node's edges
When an operand refers to a killed node, it needs to be evaluated AFTER
the killing node is evaluated. This fixes the double-alias bug.
2020-04-01 16:05:26 +09:00
Bill Currie
4c79c9ffaf [qfcc] Do a dags pre-pass to give operands leafs
The reason double-alias fails is when the double assignment occurs, the
int operands don't yet have leaf nodes and thus the nodes cannot be
killed. This doesn't fix the bug.
2020-04-01 16:03:12 +09:00
Bill Currie
842125faf8 [qfcc] Add a failing test for aliased live vars
I'm not sure if it's due more to doubles or unions, but the bug was
found via double. It seems the dags code generator doesn't see that the
assignment to the union's double field kills the two int fields.

The test passes when NOT optimizing.
2020-04-01 13:49:58 +09:00
Bill Currie
dff0fd983c [qfcc] Fix missed t enum cleanup 2020-03-30 19:02:54 +09:00
Bill Currie
0de9b02726 [qfcc] Catch declarations of arrays of class
They're still static instances.
2020-03-30 19:02:41 +09:00
Bill Currie
ddec80edc1 [qfcc] Make type encoding union anonymous
I'd do more, but things get messy with direct access to unions that I
want to be anonymous.
2020-03-30 11:10:05 +09:00
Bill Currie
d4de1d7418 [qfcc] Do full type encoding relocation early
Because type aliases need to be unaliased, the type pointers in the type
encodings need to be correct when it comes to linking defs and
functions. This fixes the linking errors in ruamoko/game.
2020-03-29 18:19:36 +09:00
Bill Currie
188a1ea105 [qfcc] Add more comments to the linker
It's a horribly hairy beast to understand, especially anything to do
with relocs and type encodings.
2020-03-29 18:18:27 +09:00
Bill Currie
c6d5ceab0e [qfcc] Make things clearer about relocated types
I was very uncertain about the validity of messing with the old type
encoding that way, but adding the check to ensure the type has been
processed never fired, so it seems ok. And the comments help me a lot :)
2020-03-29 16:47:45 +09:00
Bill Currie
62b6e95746 [qfcc] Show a marker at first unbound reloc 2020-03-29 14:54:28 +09:00
Bill Currie
361b3ff422 [qfcc] Treat alias nodes in alias-free branch as ICE 2020-03-29 11:49:07 +09:00
Bill Currie
218cca71b8 [qfcc] Take special care when aliasing aliased types
When aliasing a type that already has aliases, the top node needs to be
replaced if it is unnamed, or the alias-free branch of the new node
needs to reach around to the alias-free branch of the existing node.
This fixes the bogus param counts in qwaq.
2020-03-29 11:29:15 +09:00
Bill Currie
78962cb205 [qwaq] Use append_type in field/pointer/array_type
This fixes the missing alias chain splitter, allowing scheme to compile
again.
2020-03-29 10:27:16 +09:00
Bill Currie
6f871a8af9 [qfcc] Unalias def types before checking
This fixes the typelinker test, but not the linking error in
ruamoko/game that it was supposed to represent. I guess there's
something more going on (maybe type encoding relocation issues).
2020-03-29 00:58:02 +09:00
Bill Currie
8ba3ab89d5 [qfcc] Add failing aliased type linking test 2020-03-28 23:30:05 +09:00
Bill Currie
c13162e41e [qfcc] Rearrange type initialization
Fixes #6
It turned out that the problem with @zero was caused by initial type
chaining occurring before the structures had been initialized and thus
the linker's @zero type encoding string was incorrect: {?=} instead of
{tag @zero-}, thus when the actual type encoding supplied by an object
file came along (with the correct encoding string), it wasn't found.
2020-03-28 22:53:35 +09:00
Bill Currie
31ea3814bb [qfcc] Decouple type encoding from the pr struct
This will allow encoding types correctly in the linker.
2020-03-28 22:15:06 +09:00
Bill Currie
54a9305dbf [qfcc] Use right object for sizeof
Since the bitfield has been abandoned, can use sizeof on the field
again.
2020-03-28 22:02:42 +09:00
Bill Currie
ac9f3404ef [qfcc] Improve string quoting when dumping strings
Not knowing if a blank line is an empty string or spaces...
2020-03-28 21:46:46 +09:00
Bill Currie
1cd7bd2bf0 [qfcc] Use correct meta for zerolinker test
Still fails, of course :)
2020-03-28 21:31:04 +09:00
Bill Currie
7218af6be4 [qfcc] Print qfo def type address 2020-03-28 21:19:20 +09:00
Bill Currie
262c6a61f5 [qfcc] Add failing test for linker zero/param issue
This tests issue #6
2020-03-28 21:11:42 +09:00
Bill Currie
f224eadbb8 [qfcc] Rework QuakeC function type manging
It is now "consistent" with the rest of the type building in that it
uses find_type(append_type(return, params)) like the C version, thus
allowing append_type to do its thing with type aliases. This fixes the
overload test.
2020-03-28 19:01:49 +09:00
Bill Currie
b6ea47dca6 [qfcc] Add failing function overload test
This is a bit of a weird one because it's a combination of the aliasing
code and mixing C prototypes with QuakeC function definitions, and the
function type rebuilding in qc-parse.y not being very "consistent" in
its abuse of the type system.
2020-03-28 18:58:08 +09:00
Bill Currie
eacdd0d3de [qfcc] Make file_basename accessible and more usable 2020-03-28 18:55:51 +09:00
Bill Currie
69037fe5eb [qfcc] Strip alias info off function params
For now. This fixes many problems but does lose type aliasing info from
function parameters.
2020-03-28 18:55:51 +09:00
Bill Currie
da39e675b8 [qfcc] Copy type chain for type aliases
The full_type branch of an alias splitter (alias with null name) needs
to mirror the clean side up to the type alias. It is causing problems
with functions, but that's expected because parameters complicate
things.
2020-03-28 18:55:51 +09:00
Bill Currie
ec3c2426ff [qfcc] Add type dot dumping
It's not connected up yet because I'm unsure of just where to put things
(it gets messy fast), but just being able to see the structure of
complex types is nice.
2020-03-28 16:22:44 +09:00
Bill Currie
8479cad8a8 [qfcc] Record alias-free type in function_t
This eases type unaliasing on functions a little.

Still more to to go, but this fixes a really hair-pulling bug: linux's
heap randomiser was making the typedef test fail randomly whenever
typedef.qfo was compiled.
2020-03-28 15:10:14 +09:00
Bill Currie
1eef2a8b5e [qfcc] Implement type aliasing again
When a type is aliased, the alias has two type chains: the simple type
chain with all other aliases stripped, and the full type chain. There
are still plenty of bugs in it, but having the clean type chain takes
care of the major issue that was in the previous attempt as only the
head of the type-chain needs to be skipped for type comparison.

Most of the bugs are in finding the locations where the head needs to be
skipped.
2020-03-28 12:10:23 +09:00
Bill Currie
734f10d43e [qfcc] Dump local defs for qfo functions 2020-03-28 12:06:34 +09:00
Bill Currie
e31f03fd36 [qfcc] Add type aliasing test again 2020-03-28 09:59:01 +09:00
Bill Currie
c6746fa391 [qfcc] Fix out-by-one in type meta check 2020-03-27 22:48:38 +09:00
Bill Currie
1da6eb5f51 [qfcc] Fix a typo in a comment 2020-03-27 22:17:36 +09:00
Bill Currie
653eabfdbf [qfcc] Clean up inconsistent type building idioms 2020-03-27 22:11:18 +09:00
Bill Currie
c6483b617c [qfcc] Remove obsolete notes
nil seems to have sorted himself out with the recent reworking of how
qfcc handles nil.
2020-03-27 20:52:37 +09:00
Bill Currie
4d616fab4a [qfcc] Use the correct statement type for memset 2020-03-27 20:47:42 +09:00
Bill Currie
fdf6fac077 [qfcc] Rewrite expr_nil to use memset if necessary
This fixes the problem with returning nil through @param (and probably
structs in general).
2020-03-27 20:32:52 +09:00
Bill Currie
9c556c07bb [qfcc] Add failing nil return through @param bug
I suspect it's general for struts, but nil really is a troubling
character sometimes.
2020-03-27 20:32:52 +09:00
Bill Currie
9e529d1508 [qfcc] Fix some incorrect test runs
Checking for float return when should be checking for int return.
Fortunately, the tests still passed.
2020-03-27 20:32:52 +09:00
Bill Currie
01cf28e436 [qfcc] Treat C-style function decls as prototypes
This removes the need for extern from the declaration.
2020-03-27 18:08:26 +09:00
Bill Currie
643711ef40 [qfcc] Pre-initialize type_object's strct pointer
This ensures that pointers to incomplete struct types are not
misidentified as id before the class system has been initialized.
2020-03-27 17:29:42 +09:00
Bill Currie
498dfdbfef [qfcc] Clean up Obj-QC type struct names
I decided that the obj_ tag was unnecessary.
2020-03-27 15:33:53 +09:00
Bill Currie
ab3d91f0c3 [qfcc] Clean up simple type checking
All simple type checks are now done using is_* helper functions. This
will help hide the implementation details of the type system from the
rest of the compiler (especially the changes needed for type aliasing).
2020-03-27 15:16:41 +09:00
Bill Currie
8b1e4eea58 [qfcc] Bring back the core of type aliasing
No aliasing is done yet, but most of the infrastructure is there again.
2020-03-27 12:27:46 +09:00
Bill Currie
53fd55143e [qfcc] Fix missed none->basic rename 2020-03-27 12:26:44 +09:00
Bill Currie
75394cc4f8 [gamecode,qfcc] Use enums for type encoding types
The enums are forced to 32 bits via bitfield spec, so can't use sizeof
on them, but this makes switch enum checks work in gcc.
2020-03-27 12:24:14 +09:00
Bill Currie
4de2c6b30e [qfcc] Move alias expr inside call block expression
This fixes the trampled return value when the first expression aliases
the return result.
2020-03-26 20:16:52 +09:00
Bill Currie
98eac2afbc [qfcc] Hide dependency generation commands 2020-03-26 20:16:32 +09:00
Bill Currie
15d4186fff [qfcc] Show line numbers in block sub expressions
Seems more useful than expression index.
2020-03-26 20:15:50 +09:00
Bill Currie
5fd63b95db [qfcc] Add a new failing test
The struct alias is somehow blocking the detection of the call so the
return value gets corrupted.
2020-03-26 19:22:41 +09:00
Bill Currie
1f8cc7186c [qfcc] Hide "function" type behind an @
I'm not sure it's all that useful and thus it clutters the namespace.
2020-03-25 21:04:22 +09:00
Bill Currie
4cef9792f4 [util] Make hash-tables semi-thread-safe
They take a pointer to a free-list used for hashlinks so the hashlink
pools can be per-thread. However, hash tables that are not updated are
always thread-safe, so this affects only updates. progs_t has been set
up such that it is easy for multiple progs within one thread can share
hashlinks.
2020-03-25 15:43:16 +09:00
Bill Currie
9bfd14b687 [qwaq] Bring in qc gcd to use for debugger testing
It was even recent enough to compile first try.
2020-03-24 23:02:19 +09:00
Bill Currie
1a7add3f6d Merge branch 'master' into vulkan 2020-03-20 13:04:41 +09:00
Bill Currie
298fcbbf70 [qfcc] Add ExitCode support to quake-pascal
gcd now passes :)
2020-03-20 12:59:25 +09:00
Bill Currie
ed03eeb8d2 [qfcc] Resync qc and qp common symbols
Forgot I needed to remove PAS from pascal as well.
2020-03-20 12:59:25 +09:00
Bill Currie
f64038b872 [qfcc] Add gcd.pas to the tests 2020-03-20 12:59:25 +09:00
Bill Currie
7447854d7c [qfcc] Recover from syntax errors in abstract_decl 2020-03-19 11:01:26 +09:00
Bill Currie
4c6e1b7fc4 [qfcc] Fix some uninitialized variable warnings
I really wish gcc would catch more issues when not optimizing.
2020-03-18 01:51:52 +09:00
Bill Currie
0293d335d0 [qfcc] Mark known source def live for movep
This fixes ivar-struct-return (and qwaq).
2020-03-18 00:02:36 +09:00
Bill Currie
43ea34535e [qfcc] Make ivar-struct-return fail
It turns out that assignments to struct fields are not counted as live
when the whole struct is later used via a pointer move.
2020-03-17 23:39:17 +09:00
Bill Currie
22cd39c853 [qfcc] Mark ptr assignment offset as an operand
This fixes structptr. All current tests pass.
2020-03-17 23:05:57 +09:00
Bill Currie
578bf9a16f [qfcc] Set dag node value for movep
This fixes compilation of all tests. However, structptr still fails.
2020-03-17 22:54:27 +09:00
Bill Currie
34c9ec51bb [qfcc] Make opcode and statement type names available 2020-03-17 22:46:23 +09:00
Bill Currie
77806f4b1b [qfcc] Get dag code generation mostly working
There's an ICE in return-ivar, but assignchain passes let alone builds.
2020-03-17 22:35:36 +09:00
Bill Currie
16bda66785 [qfcc] Add more statement types for move/memset
They ease the statement checks between assign/move/memset and the
pointer versions (don't need all those strcmps)
2020-03-17 21:39:49 +09:00
Bill Currie
3c2f6c8447 [qfcc] Simplify flow_analyize_pointer_operand
and its usage. The parts of flow_analyze_statement that use it know
where the returned operand needs to go. Unfortunately, this breaks dags
pretty hard, but that's because dags needs to learn about the fancy
assignment-type statements.
2020-03-17 21:30:16 +09:00
Bill Currie
dec2e6249e [qfcc] Increase flow operand count to 5
MOVEP instructions have up to 5 operands: 2 pointers, the count, and 0-2
referenced variables (when known).
2020-03-17 21:24:12 +09:00
Bill Currie
fa2cbc72d8 [qfcc] Analyze tempop pointers in move/memset statements 2020-03-17 15:48:06 +09:00
Bill Currie
6ec92fb83b [qfcc] Point pointer tempop to the operand
It turns out I need the operand itself, not just the tempop.
2020-03-17 15:47:42 +09:00
Bill Currie
0de011d0bf [qfcc] Add some disabled additional statement info
It's a bit cluttered for normal debugging, but I haven't decided how to
make it optional just yet.
2020-03-17 15:23:24 +09:00
Bill Currie
c5cbe83f71 [qfcc] Initialize statement numbers to -1
This is to indicate the statement has not yet been flow analyzed.
2020-03-17 15:05:58 +09:00
Bill Currie
d02a01c282 [qfcc] Make tempop pointer strings more informative
Now that the address of a tempop can be taken, their op strings need to
be visible.
2020-03-17 15:05:58 +09:00
Bill Currie
441e7b99bc [qfcc] Correctly implement pointer arithmetic 2020-03-17 13:39:22 +09:00
Bill Currie
c5400c4581 [qfcc] Make anonstruct test robust against pointer math
I noticed that pointer math is currently incorrect in qfcc, but it would
be nice for fixing it to not break anonstruct since it is testing
something else.
2020-03-17 12:16:24 +09:00
Bill Currie
0d784d9ef4 [qfcc] Rework address expr calculation
This removes a bogus lea from the instruction stream (and there can be
many such).
2020-03-17 12:13:09 +09:00
Bill Currie
0d751dcdc5 [qfcc] Improve robustness of do_op_integer 2020-03-17 12:12:06 +09:00
Bill Currie
9cb3ee01d6 [qfcc] Add pointer value check
Extraction is a little more complicated, though, so undecided on that.
2020-03-17 11:19:12 +09:00
Bill Currie
c3f04384d5 [qfcc] Make a general integral value extractor
All too often I just want the value.
2020-03-17 11:18:37 +09:00
Bill Currie
80967e1471 [qfcc] Support def exprs in integral value extractors 2020-03-17 10:56:45 +09:00
Bill Currie
e4a403bbb3 [qfcc] Improve integral value extraction readability 2020-03-17 10:55:27 +09:00
Bill Currie
888192a9ea [qfcc] Resurrect ex_def expression type
It turns out to be useful still as using symbol expressions isn't always
appropriate and the workarounds were getting nasty.
2020-03-17 01:42:46 +09:00