Commit graph

4187 commits

Author SHA1 Message Date
Bill Currie
479ec07fd4 [qfcc] Implement ruamoko conversion instructions
Thanks to me having done something right 20 years ago, that was pretty
easy :). The two boolean types aren't supported yet because I haven't
decided on just how to represent their types in qfcc.
2022-01-21 10:14:14 +09:00
Bill Currie
b8b47aaf54 [qfcc] Give finish_function the finishing blow
It's been twitching for over ten years, time to put it out of its
misery.
2022-01-21 00:23:40 +09:00
Bill Currie
17dfd1492f [qfcc] Make virtual defspaces useful for highwater allocation
This seems to be the most reasonable approach to allocating space for
function call parameters without using push and pop (or adding to the
stack pointer), though it's probably good even when using push and pop
to help keep things aligned.
2022-01-20 20:54:12 +09:00
Bill Currie
2b7a8387e7 [qfcc] Get void return statements working
My little test program now builds with the Ruamoko ISA :)

    void cp (int *dst, int *src, int count)
    {
	while (count--) {
	    *dst++ = *src++;
	}
    }

Calls are broken (unimplemented), and non-void returns are not likely to
work either (only partially implemented).
2022-01-20 18:40:55 +09:00
Bill Currie
6487fe7ea7 [qfcc] Allow -1 width to match with 0
I initially wanted them to be separate, but return (and other
instructions where width is encoded in one of the operands) made that
difficult.
2022-01-20 18:39:06 +09:00
Bill Currie
54d776f243 [qfcc] Take operand width into account
Operand width is encoded in the instruction opcode, so the width needs
to be accounted for in order to select the correct instruction. With
this, my little test generates correct code for the ruamoko ISA (except
for return, still fails).
2022-01-20 16:49:07 +09:00
Bill Currie
b2ddae46b2 [qfcc] Show raw opcode when dumping instructions
Allows checking the correct instruction has been selected (it's not:
getting 4-component instructions instead of 1)
2022-01-20 15:34:43 +09:00
Bill Currie
74d00d0a3c [qfcc] Update store statements for change in B mode
Ruamoko store instructions are now always indexed and thus need a 0 for
unindexed references, but v6 stores still have no-index addressing.
2022-01-20 15:34:16 +09:00
Bill Currie
a5a8017220 [qfcc] Switch internal statement format to ruamoko
For the most part, it wasn't too bad as it's just a rotation of the
operands for some instructions (store, assign, branch), but dealing with
all the direct accesses to specific operands was a small pain. I am very
glad I made all those automated tests :)
2022-01-20 13:08:05 +09:00
Bill Currie
19baae6969 [qfcc] Dump emitted statements when verbosity >= 2
I wish I had done this years (decades, even!) ago. It makes checking the
output so much easier.
2022-01-20 13:08:05 +09:00
Bill Currie
a4ebd6aa58 [gamecode] Fix a few missed opcode renames
if and ifnot became ifnz and ifz, and return_v lost its tail (it was
always redundant, except in dags, and that's fixed with a pointer check).
2022-01-20 13:07:57 +09:00
Bill Currie
143030fec4 [gamecode] Use text for all v6p opcode names
This makes the v6p instruction table consistent with the ruamoko
instruction table, and clears up some of the ugliness with the load,
store, and assign instructions (. .= and = are now spelled out). I think
I'd still prefer an enum code (faster) but at least this is more
readable.
2022-01-20 09:26:01 +09:00
Bill Currie
30008aeb13 [qfcc] Fix a missed address expression conversion
Found while testing operator renaming.
2022-01-20 00:42:29 +09:00
Bill Currie
105d57f5e7 [qfcc] Improve handling of type names as variables
This is allowed in C so long as the scopes are different.
2022-01-19 23:17:49 +09:00
Bill Currie
07c4d28638 [qfcc] Handle bare "short"
Missed this case in duplicate_type. Allows "short foo" and
"sizeof(short)" (even though qfcc and the engine have two ideas of the
size: I expect trouble later).
2022-01-19 21:23:11 +09:00
Bill Currie
9f42cf726b [qfcc] Clean up duplicate specifier check code
I don't like the name, but having two identical copies of code is never
a good thing, especially something that big.
2022-01-19 21:20:31 +09:00
Bill Currie
df890432b7 [qfcc] Add support for unsigned, long, etc
long is ignored for double, and v6p progs are stuck with 32 bits for
longs (don't feel like extending v6p any further), but the basics are
there for Ruamoko.

short is ignored for ints because the minimum size is 32, and signed is
just noise for ints anyway (and no chars, so...).

unsigned, however, is finally implemented properly (or at least seems to
be working correctly: tests pass after getting things compiling again,
and lt.u is used where it should be :)
2022-01-19 18:08:58 +09:00
Bill Currie
e11fa77a34 [qfcc] Use pr_type_names to generate is_TYPE
This means basic types will always have a check function automatically.
2022-01-19 18:07:54 +09:00
Bill Currie
380cb3ba7f [qfcc] Clean up the type tables for binary expressions
More index labels and remove the null entries since they're not needed
with the labels.
2022-01-19 10:52:07 +09:00
Bill Currie
17add5e00f [qfcc] Use pr_type_names to create basic type defs
This takes care of the type structs and the ev_* to type map.
2022-01-18 22:59:53 +09:00
Bill Currie
57fe669099 [qfcc] Shorten type_function and type_pointer names
To type_func and type_ptr to match the ev type names.
2022-01-18 22:34:52 +09:00
Bill Currie
068c04ece6 [gamecode] Add ev_ushort and partial support
Really, only just enough to get everything compiling (which does include
vkgen running correctly).
2022-01-18 22:08:37 +09:00
Bill Currie
6df79b2b06 [qfcc] Correct xdef structures and usage in test
Attempting to add ev_ushort caused ptraliasenc to break, but that was
because it was already broken: I had implemented the scan of the xdef
table incorrectly, thus adding only 1 ev type resulted in the walked
pointer being out of phase with its data due to it first passing over
the type encodings (which is why adding long and ulong didn't cause any
obvious trouble).
2022-01-18 21:42:53 +09:00
Bill Currie
5b97aa3897 [qfcc] Use index labels for the type arrays
The one place that needed it most... constfold.c
2022-01-18 21:22:18 +09:00
Bill Currie
cd30408675 [gamecode] Rename ev_quat to ev_quaternion
I much prefer the full name, though the short version is easier to type.
2022-01-18 17:05:12 +09:00
Bill Currie
e9e54d08c0 [gamecode] Rename func_t to pr_func_t
Even more consistency.
2022-01-18 15:36:58 +09:00
Bill Currie
afd1eb775b [gamecode] Rename ev_pointer to ev_ptr
Rather short (no worse than ev_int, though) but more consistency is
usually a good thing.
2022-01-18 14:36:06 +09:00
Bill Currie
cfe7c44df0 [gamecode] Rename ev_integer to ev_int
And other related fields so integer is now int (and uinteger is uint). I
really don't know why I went with integer in the first place, but this
will make using macros easier for dealing with types.
2022-01-18 13:27:19 +09:00
Bill Currie
2df64384c1 [gamecode] Clean up string_t and pointer_t
They are both gone, and pr_pointer_t is now pr_ptr_t (pointer may be a
little clearer than ptr, but ptr is consistent with things like intptr,
and keeps the type name short).
2022-01-18 12:11:14 +09:00
Bill Currie
0bd05c71ac [gamecode] Use unsigned for entity values
I don't know why they were ever signed (oversight at id and just
propagated?). Anyway, this resulted in "unsigned" spreading a bit, but
all to reasonable places.
2022-01-16 22:15:18 +09:00
Bill Currie
66528e34fc [qfcc] Give return expressions their own type
Very simple for now (just the return value if not a void return), but
that's the last of the statements masquerading as expressions.
2022-01-09 16:28:08 +09:00
Bill Currie
563de20208 [qfcc] Give branch expressions their own type
This includes calls and unconditional jumps, relative and through a
table. The parameters are all lumped into the one object, with some
being unused by the different types (eg, args and ret_type used only by
call expressions). Just having nice names for the parameters (instead of
e1 and e2) makes it nice, even with all the sub-types lumped together.

No mysterious type aliasing bugs this time ;)
2022-01-09 14:02:16 +09:00
Bill Currie
4111d44dcc [gamecode] Move progs auxiliary headers into a subdirectory
Just another step along the road of tidying up the QF include directory
(and desirable for generated data).
2022-01-09 00:26:52 +09:00
Bill Currie
63795e790b [qfcc] Clean out some old code
The move operator names are definitely obsolete (due to dropping the
expressions a year or two ago) and the precedence checks seem to be
handled elsewhere. Memset and state expressions went away a while back
too.
2022-01-08 21:21:31 +09:00
Bill Currie
14352ea65a [qfcc] Really fix those type aliasing bugs
Found the cause: revered to wrong case for template code :/
2022-01-08 18:49:35 +09:00
Bill Currie
62d58a2255 Revert "[qfcc] Fix another type aliasing bug"
This reverts commit d14f695c68.

Found the cause: revered to wrong case for template code
2022-01-08 18:48:54 +09:00
Bill Currie
134f5ca6a4 Revert "[qfcc] Fix some type aliasing bugs"
This reverts commit da210db720.

Found the cause: revered to wrong case for template code
2022-01-08 18:48:23 +09:00
Bill Currie
65b6c366c3 [qfcc] Give assignment expressions their own type
This is getting easier (know where to look, I guess). Nicely, I found
the source of those weird type aliasing bugs :)
2022-01-08 18:44:29 +09:00
Bill Currie
d14f695c68 [qfcc] Fix another type aliasing bug
This one exposed by the address expression cleanup.
2022-01-08 16:54:08 +09:00
Bill Currie
fa482e8ee5 [qfcc] Give address expressions their own type
Definitely a pain to get working after the switch, but definitely worth
the effort. Still exposing type aliasing bugs.
2022-01-08 16:52:24 +09:00
Bill Currie
cf8061c4d3 [qfcc] Mark opcode_get as pure
Because gcc told me to :P
2022-01-08 12:14:27 +09:00
Bill Currie
da210db720 [qfcc] Fix some type aliasing bugs
I have no idea why sorting out expression aliasing exposed these type
aliasing bugs, but it did. All tests *build* again (and pass).
2022-01-08 12:10:30 +09:00
Bill Currie
23c9a317f8 [qfcc] Give alias expressions their own type
While this was a pain to get working, that pain only went to prove the
value of using proper "types" (even if only an enum) for different
expression types: just finding all the places to edit was a chore, and
easy to make mistakes (forgetting bits here and there).

Strangely enough, this exposed a pile of *type* aliasing bugs (next
commit).
2022-01-08 12:06:52 +09:00
Bill Currie
420d55406f [qfcc] Add a rule to build the qfcc tests
This makes it easier to build and run (by hand) the tests when things
aren't working.
2022-01-08 03:09:15 +09:00
Bill Currie
f5be54b6d2 [qfcc] Sanitize expr type enum
Got tired of dealing with out of date string tables.
2022-01-07 23:12:20 +09:00
Bill Currie
479d82f380 [qfcc] Create separate instruction init and lookup
v6 vs v6p are more or less as before, with ruamoko added in. qfcc will
now try (and fail, due to the opcode table opnames being wrong) to
create ruamoko progs when given the ruamoko target option.
2022-01-07 19:56:15 +09:00
Bill Currie
14d95f81d1 [gamecode] Remove PR_Opcode_Init
It was idempotent, then it became impotent. Now it's just not needed.
2022-01-07 19:25:34 +09:00
Bill Currie
7e303a1151 [qfcc] Hide details about instruction type
At this stage, I doubt emit.c will need to know the details of the
target (v6, v6p, ruamoko) since the instruction formats are identical,
just different meanings for the opcode itself.
2022-01-07 19:05:26 +09:00
Bill Currie
d9ccf3a394 [qfcc] Remove a pile of stale externs
Those opcode pointers haven't been used for years.
2022-01-07 18:54:59 +09:00
Bill Currie
2d245b8cdc [qfcc] Replace [no-]v6only with target=
This allows v6, v6p (older QF VM) or ruamoko (new QF VM) to be targeted.
Currently defaults to v6p to allow QF to continue building without too
much hassle.
2022-01-07 18:34:05 +09:00
Bill Currie
fe153b5b22 [qfcc] Add progs version to qfo and check in linker
While qfcc dealing sensibly with mixed target VMs in the object files
has always been an outstanding issue, with the new instruction set it
has become a priority. Most importantly, this should allow QF to
continue building while I work on qfcc targeting the new IS.
2022-01-07 17:56:05 +09:00
Bill Currie
c96cb1f302 [qfcc] Fix some stale documentation comments
It does little good for documentation to refer to fields that don't
exist (because a certain someone forgot to change the docs when changing
the field names, I wonder who :P).
2022-01-07 15:59:06 +09:00
Bill Currie
c9b2a740a0 [gamecode] Add etypes for long and ulong
And partial implementations in qfcc (most places will generate an
internal error (not implemented) or segfault, but some low-hanging fruit
has already been implemented).
2022-01-05 22:32:07 +09:00
Bill Currie
8a2788c267 [gamecode] Add PROG_V6P_VERSION and bump PROG_VERSION
This allows the VM to select the right execution loop and qfcc currently
still produces only the old IS (it doesn't know how to deal with the new
IS yet)
2022-01-03 13:56:43 +09:00
Bill Currie
0c17c6dc24 [gamecode] Rename the old opcodes
To reflect their basis on v6 progs instructions, they sport the v6p tag
where the p is for "plus" due to the QuakeForge extensions.
2022-01-02 21:30:02 +09:00
Bill Currie
f56fd6ffb6 [qfcc] Preserve requested alignment if larger
build_struct was unconditionally setting the type's alignment. This was
not a problem before because no types were requesting alignments larger
than those requested by their members (for structs). However, with the
upcoming new instruction set, quaternions need to be 4-word aligned.
2022-01-02 11:44:48 +09:00
Bill Currie
97034d9dde [simd] Add 2d vector types
For int, long, float and double. I've been meaning to add them for a
while, and they're part of the new Ruamoko instructions set (which is
progressing nicely).
2022-01-02 00:57:55 +09:00
Bill Currie
365762b8a6 [gamecode] Switch to using indexed initializers
The opcode table is a nightmare to maintain, but this does clean it up
and speed up opcode lookups since they can now be indexed. Of course, it
turns out I had missed adding several instructions, so had to fix that,
and qfcc needed a bit of a re-jigger to get the opcode out of the table.
2021-12-31 19:16:02 +09:00
Bill Currie
be474d9937 [gamecode] Remove the wart from def and function names
I never liked the leading s_ (though I guess it means one is supposed to
interpret the int as a string pointer, but meh).
2021-12-31 15:02:31 +09:00
Bill Currie
44c48feb56 [qfcc] Add attached node's parents to source edges
The assignment to the node's variable must come after any uses of that
node, which the node's parent set indicates. In the swap test, this was
not a problem as the node had no parents, and in the link order test, it
just happened(?) to work.
2021-12-28 09:23:14 +09:00
Bill Currie
8433905015 [qfcc] Extend reachable to the label node's parents
While using just the label node's reachable set was sufficient for a
simple swap (t = a; a = b; b = t;), it is not sufficient for
read-before-write dependencies such as found in linked-list building:

    { o = array[ind]; o.next = obj; obj = o; }

The assignment to o.next uses obj, but that use is hidden because obj's
reachable nodes does not include o thus assigning o to obj causes the
array dereference to be assigned directly to obj and thus o.next winds
up pointing to o instead of whatever obj was. The parent nodes of obj's
node are its users, so any new assigned to obj must come after those
parents as well as any node reachable by obj's node.

Fixes a runaway loop error when adding a frikbot to the server.
2021-12-27 14:25:55 +09:00
Bill Currie
4ad84b3786 [qfcc] Add a test for use/write dependencies
I ran into this with frikbot causing an infinite loop due to incorrectly
linked objects.
2021-12-27 14:17:12 +09:00
Bill Currie
44dd183d55 [qfcc] Make it a little easier to see extra info
instead of having to find an #if 0, just uncomment the define.
2021-12-27 14:15:51 +09:00
Bill Currie
95991e0d77 [qfcc] Check switch test expression early
Avoids a segfault when the test expression has errors.
2021-12-27 00:47:35 +09:00
Bill Currie
3059aa7979 [qfcc] Preserve input qfo data in qfo_to_progs
qfo_to_progs was modifying the space data pointers in the input qfo,
making it impossible to reuse the qfo. However, qfo_relocate_refs needs
the updated pointers, thus do a shallow copy of the qfo and its spaces
(but not any of the data)
2021-12-27 00:27:15 +09:00
Bill Currie
dcf8beeccc [qfcc] Remove a union wart from qfo_mspace_t 2021-12-26 20:37:01 +09:00
Bill Currie
1d3970bc38 [qfcc] Allow extern builtin function declarations
build_builtin_function does the right thing, and it was only legacy
syntax functions that were affected anyway. Certainly, external
variables should not be initialized, but klik uses @extern { } wrapped
around several builtin functions and I had added the feature to allow
just this as it is rather convenient.
2021-12-26 15:01:38 +09:00
Bill Currie
22c67fc268 [qfcc] Use flow analysis for dealloc check
I decided that the check for whether control reaches the end of the
function without performing some necessary action (eg, invoking
[super dealoc] in a derived -dealoc) is conceptually the return
statement using a pseudo operand and the necessary action defining that
pseudo operand and thus is the same as checking for uninitialised
variables. Thus, add a pseudo operand type and use one to represent the
invocation of [super alloc], with a special function to call when the
"used" pseudo operand is "uninitialised".

While I currently don't know what else pseudo operands could be used
for, the system should be flexible enough to add any check.

Fixes #24
2021-12-25 17:04:26 +09:00
Bill Currie
f903211362 [qfcc] Make operand union anonymous
This one was easy enough and gets rid of that little o. wart.
2021-12-25 12:40:24 +09:00
Bill Currie
7c24f116b4 [qfcc] Rename tmpaddr to pseudo_addr
I want to use the function's pseudo address that was used for managing
aliased temporary variables for other pseudo operands as well. The new
name seems to better reflect the variable's purpose even without the
other pseudo operands as temporary variables are, effectively, pseudo
operands until they are properly allocated.
2021-12-25 12:21:59 +09:00
Bill Currie
79b760b1d0 [qfcc] Add failing test for multi-path dealloc
This test checks for control reaching the end of the function without
invoking [super dealloc] in all paths.
2021-12-24 22:45:43 +09:00
Bill Currie
8385046486 [qfcc] Warn when super dealloc invocation is missing
Forgetting to invoke [super dealloc] in a derived class's -dealloc
method has caused me to waste far too much time chasing down the
resulting memory leaks and crashes. This is actually the main focus of
issue #24, but I want to take care of multiple paths before I consider
the issue to be done.

However, as a bonus, four cases were found :)
2021-12-24 22:45:43 +09:00
Bill Currie
ff1cdb6f89 [qfcc] Give select expressions their own type
While get_selector does the job of getting a selector from a selector
reference expression, I have long considered lumping various expression
types under ex_expr to be a mistake. Not only is this a step towards
sorting that out, it will make working on #24 easier.
2021-12-24 22:45:43 +09:00
Bill Currie
bdd3870d2f [qfcc] Add failing test for dealloc warning
I have gotten tired of chasing memory leaks caused by me forgetting to
add [super dealloc] to my dealloc methods, so getting qfcc to chew me
out when I do seems to be a good idea (having such a warning would have
saved me many hours, just as missing return warnings have).
2021-12-24 22:45:43 +09:00
Bill Currie
bdc9e9c39f [qfcc] Unalias types before checking for equality
Fixes a bogus redefinition when going from struct declaration to
typedef.
2021-12-24 06:45:13 +09:00
Bill Currie
e0497c7fff [tools] Add a tool to dump sprite info 2021-12-17 08:31:28 +09:00
Bill Currie
ca9566a425 [qfbsp] Print the number of textures in the bsp
I needed to check what sort of numbers to expect for bsp texture counts.
It turns out id maps use only 81 max, but oum uses up to 173.
2021-12-17 08:28:02 +09:00
Bill Currie
3b1acf8a7b [qfcc] Correct some errors in the man page 2021-11-29 11:38:54 +09:00
Bill Currie
88b3965794 [vulkan] Pick up vulkan.h from correct location
Well... it could be done better, but this works for now assuming it's in
/usr/include (and it's correct for mxe builts). Does need proper
autoconfiscation, though.
2021-11-19 22:36:19 +09:00
Bill Currie
7ed12e2f37 [qfcc] Fix static function declarations
I'm surprised it took this long for static not working to cause a
problem.
2021-09-24 19:49:55 +09:00
Bill Currie
6144100d9b [qfcc] Check init exists before checking compound
Fixes a segfault that occurred during a parse error in a def
initializer.
2021-09-24 19:44:14 +09:00
Bill Currie
8a5c3c1ac1 [util] Add sys function to get cpu count
And use it in qfvis.
2021-08-13 21:26:48 +09:00
Bill Currie
d88bd96390 [qfvis] Use cmem for portal flow stack node allocation
The portal flow stack nodes contain a simd vector, which requires
16-byte alignment. However, on 32-bit Windows, malloc returns 8-byte
aligned memory, leading to eventual segfaults. Since pstack_t is 48
bytes on 32-bit systems, it fits nicely into a 64-byte aligned cache
line (or two on 64-bit systems due to being 80 bytes).
2021-08-13 11:33:03 +09:00
Bill Currie
6fb6885b88 [qfvis] Allocate only 128MB for the main hunk
Even ad_tears didn't really need 1GB, and 32-bit machines can't really
handle 1GB (at least on windows).
2021-08-13 11:33:03 +09:00
Bill Currie
2828500f04 [qfvis] Delay freeing of winding memory
If anything, this is probably a nano-optimization, depending on how
often portals are vis-rejected. I couldn't see any actual difference.
2021-08-08 12:34:18 +09:00
Bill Currie
9a93bf8d4a [qfvis] Make cluster reconstruction O(N)
For most (if not all) maps. The heapsort is needed only if the clustered
leafs are not contiguous, but most bsp compilers output contiguous leaf
clusters, so is just a bit of protection. The difference isn't really
noticeable on a fast machine, but no point in doing more work than
necessary.
2021-08-08 12:34:18 +09:00
Bill Currie
648ae3f877 [qfvis] Clean up the code and output a little
Dead code removed, and the job progress lines are now consistent and
have a job completion time when done.
2021-08-03 21:52:24 +09:00
Bill Currie
fe998f41b4 [qfvis] Convert leaf vis to cluster vis
Now that only 3852 clusters need to be checked for each cluster, fat-pvs
construction for ad_tears completes in about 0.7s, most of which seems
to be loading, conversion, compression and writing. O(N^3) cuts both
ways (hurts like crazy when N increases, does wonders when N decreases,
especially by a factor of 25). And then throw in improved cache
performance...

I suspect having an off-line compiler is still useful, but even if
qfvis's implementation never actually gets used, if cluster
reconstruction is put in the engine, large maps will be feasible even
for quakeworld. Just the reduced memory requirements alone will be a
huge benefit (~3GB down to 1.8MB).
2021-08-03 15:48:45 +09:00
Bill Currie
8da019e31c [qfvis] Reconstruct the leaf clusters in a bsp
This is only the first half (vertical) in that the vis bits are still
for the leafs rather than the clusters, but ad_tears goes from 500s to
7s for calculating the fat pvs (3852 clusters).
2021-08-03 11:37:24 +09:00
Bill Currie
421047328a [qfvis] Catch a missed winding mark stat 2021-08-02 23:17:55 +09:00
Bill Currie
ec54c54226 [build] Fix some windows bitrot 2021-08-02 14:02:41 +09:00
Bill Currie
f514345d77 [qfbsp] Show correct object counts for bsp29 files
Yes, this was the goal of that size_t change, but it made sense anyway.
2021-08-01 22:05:31 +09:00
Bill Currie
674ffa0941 [util] Make bsp_t counts size_t
and other bsp data counts unsigned, and clean up the resulting mess.
2021-08-01 21:54:05 +09:00
Bill Currie
40367e5bca [qfvis] Thread the ambient sounds computation 2021-08-01 18:14:28 +09:00
Bill Currie
e671b3f230 [qfvis] Thread the portal vis compaction
The compaction deals with merging all the portal visibility into cluster
visibility, expanding out to leafs, and final compression.
2021-08-01 17:06:13 +09:00
Bill Currie
523ab007d6 [qfvis] Produce more details base-vis stats
And nicely, things add up (after fixing 32-bit overflows :P)
2021-07-30 23:07:12 +09:00
Bill Currie
ca8dcf3fa9 [qfvis] Use cluster sphere culling for base vis
While this doesn't give as much of a boost as does basic sphere culling
(since it's just culling sphere tests), it took ad_tears' base vis from
1000s to 720s on my machine.
2021-07-30 18:52:47 +09:00
Bill Currie
9461779ba7 [qfvis] Remove the cluster portals limit
This removes the last of the arbitrary limits from qfvis. The goal is
not so much supporting crazy maps, but more about better data usage
(cluster_t is now 24 (or 16) bytes instead of 1048 (or 528). And
passages isn't used (yet?)...
2021-07-29 21:03:07 +09:00
Bill Currie
756214ca8e [qfvis] Use unsigned for the plane side tests
Doesn't make any difference to the number of instructions, but seeing
sar instead of shr bothers me when working with bit patterns.
2021-07-29 15:25:37 +09:00
Bill Currie
72a1fef714 [qfvis] Use hunk to manage winding memory
It turns out cmem is not so good for many large allocations (probably a
bug in handling the blocks), but was really meant for lots of little
churning allocations anyway. After an analysis of winding lifetimes, it
became clear that the hunk allocator would work very well. The base
windings are allocated from a global hunk (currently 1GB, plenty for
even ad_tears), and ephemeral windings are allocated from a per-thread
hunk of 1MB (seems to be way more than enough: gmsp3v2 uses a maximum of
only 56064 bytes, and ad_tears got through 30% before I gave up on it).
Any speed difference (for gmsp3v2) seems to be lost in the noise: still
completing in 38.4s on my machine.
2021-07-29 11:49:18 +09:00
Bill Currie
e39bc83a6a [qfvis] Optionally use utf8 to encode run lengths
Adds 50 bytes to marcher's fat-pvs, but removes about 4.7MB from
ad_tear's fat-pvs.
2021-07-27 23:29:14 +09:00
Bill Currie
b9d2882e02 [qfvis] Write out the fat-pvs file
The output fat-pvs data is the *difference* between the base pvs and fat
pvs. This currently makes for about 64kB savings for marcher.bsp, and
about 233MB savings for ad_tears.bsp (or about 50% (470.7MB->237.1MB)).
I expect using utf-8 encoding for the run lengths to make for even
bigger savings (the second output fat-pvs leaf of marcher.bsp is all 0s,
or 6 bytes in the file, which would reduce to 3 bytes using utf-8).
2021-07-27 20:04:19 +09:00
Bill Currie
49c3dacbbc [util] Rename set_size to set_count
After seeing set_size and thinking it redundant (thought it returned the
capacity of the set until I checked), I realized set_count would be a
much better name (set_count (node->successors) in qfcc does make much
more sense).
2021-07-27 11:52:21 +09:00
Bill Currie
946867c82e [qfvis] Start work on an off-line fat pvs compiler
Extremely large maps take a very long time to process their PVS sets for
PHS or shadows, so having an off-line compiler seems like a good idea.
The data isn't written out yet, and the fat pvs code may not be optimal
for cache access, but it gets through ad_tears in about 500s (12
threads, compared to 2100s single-threaded in the qw server).
2021-07-26 22:42:03 +09:00
Bill Currie
60d23bdc8f [qfbsp] Remove all arbitrary bsp limits
Planes, verts, etc can now all get crazy big.
2021-07-26 13:10:06 +09:00
Bill Currie
13e1682f5e [qfbsp] Add an option to dump info about a bsp file
Just the header plus some basics of model info.
2021-07-25 12:14:04 +09:00
Bill Currie
342ba65f57 [qfcc] Handle aliased field types
Fixes use of structs as entity fields. The test is currently
compile-only.
2021-07-24 18:09:54 +09:00
Bill Currie
8369a2206a [glstub] Add functions needed to get glsl working
Pity vulkan won't be so easy.
2021-07-22 10:12:41 +09:00
Bill Currie
6b38a17cf1 [gamecode] Clean up state imlementations
This makes the code easier to read. Also, yay for automated tests:
caught a mistyped time :)
2021-07-15 16:55:02 +09:00
Bill Currie
0a847f92f1 [util] Use mmap/munmap for cmem internal alloc/free
This reduces the overhead needed to manage the memory blocks as the
blocks are guaranteed to be page-aligned. Also, the superblock is now
alllocated from within one of the memory blocks it manages. While this
does slightly reduce the available cachelines within the first block (by
one or two depending on 32 vs 64 bit pointers), it removes the need for
an extra memory allocation (probably via malloc) for the superblock.
2021-07-12 16:33:47 +09:00
Bill Currie
6db6f8f0e2 [win] Fix a pile of bitrot
Man, those bits rot quickly. Must be stored with a rotfish.
2021-07-11 13:30:52 +09:00
Bill Currie
ef6dd422e5 [qfcc] Add source line number to statement blocks
For statement dot blocks.
2021-07-06 18:06:47 +09:00
Bill Currie
ddc6f6bcb0 [qfcc] Un-dereference src expression early for movep
The VM has no pointer to direct reference move instruction.

Fixes #9
2021-06-30 20:05:27 +09:00
Bill Currie
9d140d1d15 [qfcc] Use {>...} for unnamed alias types
The ... is the encoding of the aliased type. Avoids (null) in the
encoding. Fixes #10.
2021-06-30 11:00:05 +09:00
Bill Currie
a3aebc983b [qfcc] Add dependency edges for moved labels
When moving an identifier label from one node to another, the first node
must be evaluated before the second node, which the edge guarantees.
However, code for swapping two variables

    t = a; a = b; b = t;

creates a dependency cycle. The solution is to create a new leaf node
for the source operand of the assignment. This fixes the swap.r test
without pessimizing postop code.

This takes care of the core problem in #3, but there is still room for
improvement in that the load/store can be combined into a move.
2021-06-29 14:42:16 +09:00
Bill Currie
76b3bedb72 [qfcc] Revert "Kill dag leaf nodes on assignment."
This reverts commit 2fcda44ab0.

Killing the node is not the correcgt answer as it blocks many
optimization opportunities. The correct answer is adding edges to
describe the temporal dependencies. Of course, this breaks the swap.r
test.
2021-06-29 12:09:35 +09:00
Bill Currie
5291cfb03d [qfcc] Keep track of reachable dag nodes
In order to correctly handle swap-style code

    { t = a; a = b; b = t; }

edges need to be created for each of the assignments moving an
identifier lable, but the dag must remain acyclic (the above example
wants to create a cycle). Having the reachable nodes recorded makes
checking for potential loops a quick operation.
2021-06-29 09:41:03 +09:00
Bill Currie
0d1fad12f0 [qfcc] Add some comments 2021-06-29 09:12:57 +09:00
Bill Currie
d50f2c3145 [qfcc] Correctly check for constant op
Identifiers can be constants. I don't remember quite what it fixed other
than some bogus kill relations in the dags (which might have caused
issues later).
2021-06-28 20:25:26 +09:00
Bill Currie
38a6ccdc85 [qfcc] Use indexed initializers for expr functions
This will make adding new expression types easier (though the current
reason for doing so has been abandoned for now).
2021-06-28 18:12:15 +09:00
Bill Currie
365e298908 [qfcc] Make internal_error const correct
This way it can be used with const expr objects.
2021-06-28 18:12:15 +09:00
Bill Currie
93167279fc Fix a bunch of issues found by gcc-11 2021-06-13 14:30:59 +09:00
Bill Currie
13b4b44e35 [qfcc] Handle l and ll integer suffixes
They're ignored, but allow recent vulkan headers to compile.
Fixes #13
2021-06-13 13:25:18 +09:00
Bill Currie
927a446bd3 [qfcc] Ensure type src type is a class
If the src type is not a class, there is no inheritance chain to walk.
Fixes a segfault when returning self after a syntax error in the
following:

    +(EditStatus *)withRect:(Rect)rect
    {
	return [[[self alloc] initWithRect:rect]:
    }

    -setCursorMode:(CursorMode)mode
    {
	cursorMode = mode;
	return self;
    }
2021-06-09 12:08:13 +09:00
Bill Currie
88c9517629 [qfprogs] Dump class ivars when dumping modules 2021-06-04 14:59:15 +09:00
Bill Currie
778c07e91f [util] Get vectors working for non-SSE archs
GCC does a fairly nice job of producing code for vector types when the
hardware doesn't support SIMD, but it seems to break certain math
optimization rules due to excess precision (?). Still, it works well
enough for the core engine, but may not be well suited to the tools.
However, so far, only qfvis uses vector types (and it's not tested yet),
and tools should probably be used on suitable machines anyway (not
forces, of course).
2021-06-01 18:53:53 +09:00
Bill Currie
18247a8c8e [tools] Fix up 32-bit cross-compile scripts 2021-04-02 08:55:16 +09:00
Bill Currie
574a123716 [qfvis] Remove obsolete notes file
While some of it is still correct, I'd rather start afresh next time I
need to sort that stuff out.
2021-03-28 21:14:17 +09:00
Bill Currie
634219ea06 [qfvis] Add set debug prints (disabled)
They were useful for narrowing down why mightsee wasn't being updated.
2021-03-28 21:11:13 +09:00
Bill Currie
9f42943589 [qfvis] Reset portal status after base vis
This fixes the mightsee updates never occurring, but it doesn't make a
huge difference (though I suppose it might have back in the 90s, or with
a different map).
2021-03-28 21:06:50 +09:00
Bill Currie
0fa65be106 [qfvis] Fix stats collection for mightseeupdate
The stats were being updated before UpdateMightsee was getting called,
and it was incrementing the wrong value (so it would not have been
thread-safe).
2021-03-28 21:06:50 +09:00
Bill Currie
ff4cd84891 [qfvis] Use simd vector code
While whether it's any faster is debatable (it's slightly slower, but
many more portals are being tested due to different rounding in the base
vis stage), it's certainly easier to read.
2021-03-28 19:55:47 +09:00
Bill Currie
eb325376b1 [qfvis] Collect base vis culling stats
Specifically, just how many are culled by sphere and winding tests.
2021-03-28 12:17:15 +09:00
Bill Currie
d072a7b99c [qfvis] Add stats for memory usage
Verbosity levels probably need more tweaking, but -v is at least a
little more usable.
2021-03-27 23:04:13 +09:00
Bill Currie
3ef38188ce [qfvis] Add an option to limit the processed portals
It's not documented as I needed it for debugging memory allocations and
it causes qfvis to error out due to unprocessed portals.
2021-03-27 20:59:56 +09:00
Bill Currie
f2b6b23acc [qfvis] Switch to unsigned for various counts 2021-03-27 20:55:15 +09:00
Bill Currie
72280186bf [qfvis] Use cmem for memory management
While the main bulk of the improvement (36s down from 42s for
gmsp3v2.bsp on my i7-6850K) comes from using a high-tide allocator for
the windings (which necessitated using a fixed size), it is ever so
slightly faster than using malloc as the back-end.
2021-03-27 20:30:35 +09:00
Bill Currie
88ff254f42 Get QF cross-compiling using MXE/mingw32
This includes -win clients (no clue if anything actually works yet).
2021-03-27 20:09:37 +09:00
Bill Currie
a9bd436837 [build] Autoconfiscate printf format attribute
I don't know if gnu_printf is appropriate for all cases, but it is
needed for mingw32.
2021-03-27 19:52:59 +09:00
Bill Currie
238e80c89b [build] Fix selective build of tools
A couple of things get built when they shouldn't (eg, vkgen) but this
gets the build system back to its pre-non-recursive-make
configurability.
2021-03-26 16:11:29 +09:00
Bill Currie
c901fe74f9 [qfvis] Fix pthread portability macros
Those that were defined were incorrectly defined (didn't swallow the
parameter), and portal lock macros were missing.
2021-03-26 15:27:48 +09:00
Bill Currie
c9f1d770e0 Merge master into csqc-improvements
That was a mess
2021-03-25 22:01:31 +09:00
Bill Currie
0cae54d25d Move the tex conversion to libQFimage.
This is for the conversion /to/ paletted textures. The conversion is
necessary for csqc support. In the process, the conversion has been sped up
by implementing a color cache for the conversion process. I haven't
measured the difference yet, but Mr Fixit does seem to load much faster for
the sw renderer than it did before the change (many months old memory).
2021-03-25 18:16:24 +09:00
Bill Currie
66fda1fddb Rewrite edict access.
The server edict arrays are now stored outside of progs memory, only the
entity data itself (ie data accessible to progs via ent.fld) is stored in
progs memory. Many of the changes were due to code accessing edicts and
entity fields directly rather than through the provided macros.
2021-03-25 18:13:48 +09:00
Bill Currie
5d9bf32d3c Merge branch 'vulkan' 2021-03-23 12:31:58 +09:00
Bill Currie
a3c1b2e992 [util] Rename qfplist.[ch]
The name is a hold-over from before the current quakeforge tree and the
QF include directory.
2021-03-21 16:13:03 +09:00
Bill Currie
9e633e7230 [qflight] Remove minlights
It seems to be have been DOA (even in the original qutils light).
2021-03-21 10:11:53 +09:00
Bill Currie
e3444b726f [model] Add a re-entrant Mod_LeafPVS
Double benefit, actually: faster when building a fat PVS (don't need to
copy as much) and can be used in multiple threads. Also, default visiblity
can be set, and the buffer size has its own macro.
2021-03-20 12:13:58 +09:00
Bill Currie
f8961e4376 [qflight] Fix some typos in comments 2021-02-25 10:12:19 +09:00
Bill Currie
bc763da9f6 [qfcc] Fix a typo in the man page 2021-02-09 15:02:22 +09:00
Bill Currie
dfa7af03c6 [util] Plug a thread-safety hole in plists 2021-02-09 09:57:07 +09:00
Bill Currie
84dc73da2c [test] Get the tests building again
They happen to all pass, which is nice :)
2021-02-05 21:43:12 +09:00
Bill Currie
0bfb60775e [util] Ensure hunk allocs are cache alligned
This doesn't seem to make much difference in the vulkan renderer, but it
certainly doesn't hurt.
2021-02-03 13:19:19 +09:00
Bill Currie
22fe49d0ef Add support for loading an alternative palette.
Sort of at the request of leileilol (a utility to create quakepal.py was
asked for, but this seems to be better approach). However, the feature is
not used yet (needs hooks in the import and export modules).
2021-02-02 21:47:34 +09:00
Bill Currie
7970525ef4 [util] Make va thread-safe
It now takes a context pointer (opaque data) that holds the buffers it
uses for the temporary strings. If the context pointer is null, a static
context is used (making those uses of va NOT thread-safe). Most calls to
va use the static context, but all such calls have been formatted
consistently so they are easy to find when it comes time to do a full
audit.
2021-01-31 16:05:48 +09:00
Bill Currie
97febc0888 [tools/misc] Update mdl.py for python 3 2021-01-27 12:51:22 +09:00
Bill Currie
e50430e00c [image] Add parameter to load only the header
I want to be able to calculate texture sizes without actually loading
the images.
2021-01-19 10:15:57 +09:00
Bill Currie
64c7efdc0c [qfcc] Use local_expr only for local variables
ie, not function-scope static variables.
2021-01-13 18:35:24 +09:00
Bill Currie
1fcb16d8cf [qfcc] Add failing test for static init
The function local static init is being treated as a non-static init
(ie, initialized each call).
2021-01-13 18:35:24 +09:00
Bill Currie
c7da999b6a [qfcc] Use local_expr only for local variables
ie, not function-scope static variables.
2021-01-13 18:08:30 +09:00
Bill Currie
1205c935d0 [qfcc] Add failing test for static init
The function local static init is being treated as a non-static init
(ie, initialized each call).
2021-01-13 16:47:49 +09:00
Bill Currie
0c1699fdbb Fix a pile of double semicolons 2021-01-09 20:42:23 +09:00
Bill Currie
0426879bf6 [qfcc] Check returned type instead of expr type
Block expressions hide ex_error, but get_type() always returns null when
it finds one (which it does by recursing into block expression), so just
check the type itself.
2021-01-04 14:54:04 +09:00
Bill Currie
4f8a06ddd3 [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-28 18:58:51 +09:00
Bill Currie
ab04a1915e [build] Fix a pile of gcc 10 issues
gcc got stricter about array accesses, complicating progs macros, and
much better at detecting buffer overflows.
2020-12-21 14:14:29 +09:00
Bill Currie
4a8818f0b6 [qfcc] Clean up some excess includes 2020-08-17 14:36:08 +09:00
Bill Currie
550b9c3bb2 [qfcc] Fix silent make rules flex and bison 2020-08-17 14:35:20 +09:00
Bill Currie
3413947e0c [qfmap] Update script.py from io_object_mu
While not necessary for qf (at this stage), this brings in support for
optionally not parsing strings and better utf-8 and wide char handling.
2020-07-17 20:11:44 +09:00
Bill Currie
f544a6f0b0 [qfcc] Treat null method return type as id
This prevents a segfault when the method's return type is undefined.
2020-07-05 16:53:35 +09:00
Bill Currie
a177f363f7 [build] Support silent rules for qfcc 2020-06-29 14:19:50 +09:00
Bill Currie
03f6af39f4 [qfcc] Reset flowvars for aliased global variables
When a global variable is accessed via only an alias in a function the
actual def's flowvar would remain in the state it was from the last
function that accessed the global normally. This would result in invalid
flowvar accesses which can be difficult to reproduce (thus no test
case).
2020-06-29 14:19:50 +09:00
Bill Currie
aa8aaaaca9 [build] Support silent rules for qfcc 2020-06-26 10:52:06 +09:00
Bill Currie
ed42557dd1 [qfcc] Reset flowvars for aliased global variables
When a global variable is accessed via only an alias in a function the
actual def's flowvar would remain in the state it was from the last
function that accessed the global normally. This would result in invalid
flowvar accesses which can be difficult to reproduce (thus no test
case).
2020-06-25 22:45:12 +09:00
Bill Currie
86b5b30b45 Merge branch 'master' into vulkan 2020-06-25 14:03:52 +09:00
Bill Currie
6d5ffa9f8e [build] Move to non-recursive make
There's still some cleanup to do, but everything seems to be working
nicely: `make -j` works, `make distcheck` passes. There is probably
plenty of bitrot in the package directories (RPM, debian), though.

The vc project files have been removed since those versions are way out
of date and quakeforge is pretty much dependent on gcc now anyway.

Most of the old Makefile.am files  are now Makemodule.am.  This should
allow for new Makefile.am files that allow local building (to be added
on an as-needed bases).  The current remaining Makefile.am files are for
standalone sub-projects.a

The installable bins are currently built in the top-level build
directory. This may change if the clutter gets to be too much.

While this does make a noticeable difference in build times, the main
reason for the switch was to take care of the growing dependency issues:
now it's possible to build tools for code generation (eg, using qfcc and
ruamoko programs for code-gen).
2020-06-25 11:35:37 +09:00
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
Bill Currie
fd06cd2b00 [qfcc] Analyze assignment through const pointers
This fixes a false-positive uninitialized warning.
2020-03-17 01:40:35 +09:00
Bill Currie
8e6baf1bde [qfcc] Fix assigning to entity fields
At least for basic types. Compound types need testing.
2020-03-17 01:39:35 +09:00
Bill Currie
f9face0cef [qfcc] Make is_indirect easier to read 2020-03-16 23:26:39 +09:00
Bill Currie
5c0c056e2c [qfcc] Add is_entity type test helper 2020-03-16 21:07:31 +09:00
Bill Currie
ede7dd6d7e [qfcc] Catch attempts to emit a bad operand type 2020-03-16 20:31:21 +09:00
Bill Currie
1d10136f2e [qfcc] Treat all dereferences and indirect
Why I had a const pointer test on there is beyond me.
2020-03-16 20:24:22 +09:00
Bill Currie
69924fe717 [qfcc] Return correct value for is_const_ptr
It really helps if the logic is not inverted.
2020-03-16 20:21:07 +09:00
Bill Currie
db06300ddd [qfcc] Make print_operand usable from gdb
It not emitting a \n made life difficult, especially whenever gdb
decided to make access to printf or puts awkward.
2020-03-16 20:20:07 +09:00
Bill Currie
c8e45c6cfc [qfcc] Use operand_address in expr_deref
This fixes the technically correct but horrible mess of temps and
addressing when dealing with ivars, and the resulting uninitialized
temps due to the non-constant pointers (do need statement level constant
folding, though).
2020-03-16 14:24:48 +09:00
Bill Currie
b58deb5680 [qfcc] Rewrite operand_address to be much simpler
It now creates a pointer value and returns that rather than generating
an address statement.
2020-03-16 14:24:47 +09:00
Bill Currie
a0c28a5ac5 [qfcc] Support pointers to temp operands
This is necessary for correctly taking the address of operands.
2020-03-16 14:24:47 +09:00
Bill Currie
2f07d9a310 [qfcc] Improve accuracy of some more diagnostics 2020-03-16 10:42:18 +09:00
Bill Currie
0fe3fda44d [qfcc] Fix protocol adorned id as message receiver
This took a bit as type_id has no class data, only protocols attached to
the type_obj_object instance, and then protocol lists can get deep.
2020-03-16 10:42:18 +09:00
Bill Currie
ea042cf87a [qfcc] Split out the obj-qc specific expr code 2020-03-16 10:34:16 +09:00
Bill Currie
fb33a7f2a7 [qfcc] Remove "impossible" code
It is not possible to adorn Class with protocols, so no need to check
for them when checking if a type is a class.
2020-03-16 10:34:16 +09:00
Bill Currie
e1140d476a [qfcc] Handle syntax errors in method protos 2020-03-15 16:19:45 +09:00
Bill Currie
968de155a1 [qfcc] Make some counts unsigned
How do you have -1 def?
2020-03-15 01:33:25 +09:00
Bill Currie
9a08a51ebd [qfcc] Ensure progs defs are sorted by address 2020-03-15 01:32:38 +09:00
Bill Currie
067bc264fa [qfcc] Set local def size in debug sym file
It was getting random garbage. Not good for debuggers.
2020-03-14 22:08:27 +09:00
Bill Currie
20fd5eb80c [qfcc] Show def size when dumping defs 2020-03-14 22:07:36 +09:00
Bill Currie
327d692992 [qfcc] Correct order of @zero fields
This is part of what messed up float_val in the encoding for @params.
The other part is something in the linker type encoding merge code: it
may be too aggressive. It's also what messed up the size of @params.
2020-03-14 22:06:57 +09:00
Bill Currie
72f4b8ccb5 [qfcc] Give address operands a good expression
That is, those created by operand_address. The dag code needs the
expression that is attached to the statement to have the correct
expression type in order to do the right thing with the operands and
aliasing, especially when generating temps. This fixes assignchain when
optimizing (all tests pass again).
2020-03-14 19:26:47 +09:00
Bill Currie
025dd63493 [qfcc] Bubble right-hand assignee back up chain
This fixes assignchain when not optimizing. There are problems in dags,
though, with address expressions.
2020-03-14 17:48:53 +09:00
Bill Currie
97e0c23529 [qfcc] Create a nil operand
This is for struct assignments so they can pass the source operand back
up the assignment chain.
2020-03-14 17:47:23 +09:00
Bill Currie
eca976e5ae [qfcc] Expose l-value checking
Needed for assignment chains.
2020-03-14 17:45:54 +09:00