Commit graph

4408 commits

Author SHA1 Message Date
Bill Currie
baa4099de6 [io_qfmap] File off a pile of bitrot
While much is broken, especially textures, e4m8.map successfully imports
into blender 4.2-ish, and even the entity relation lines seem to work
(which surprised me as those were the first sign of trouble).
2024-08-11 20:28:38 +09:00
Bill Currie
925dba732c [build] Add an option to enable ubsan
It's disabled by default because it's a runtime thing and I'm not sure I
want to keep it enabled, but it did find some issues (which I've cleaned
up), although it didn't find the problem I was looking for :P
2024-02-21 22:41:08 +09:00
Bill Currie
073c93eebf [qfcc] Don't split basic blocks on function calls
This allows the dags code to optimize the return values, and when I make
the node killing by function calls less aggressive, should make for many
more potential CSE optimizations.
2024-02-21 22:41:08 +09:00
Bill Currie
03b2ee2a25 [qfcc] Delay creation of leaf nodes
Creating leaf nodes early gets in the way of supporting multi-call basic
blocks, and never really seemed right anyway.
2024-02-21 22:41:08 +09:00
Bill Currie
6d6a387a81 [qfcc] Treat move the same as assign in dags
This goes a long way towards allowing basic blocks to include multiple
function calls instead of always ending on a call.
2024-02-21 22:41:08 +09:00
Bill Currie
277feaeb03 [qfcc] Support multivector expression to/from functions
The multivector is first assigned to a temporary then passed or returned
as usual.
2024-02-21 22:41:08 +09:00
Bill Currie
389571cbbe [qfcc] Handle pointer dereferences in offset casts
Offset casts are used heavily in geometric algebra, but doing an offset
cast on a dereferenced pointer (array index) doesn't work well for
assignments. Fixes yet another bug in my test scene :)
2024-02-21 22:41:08 +09:00
Bill Currie
62221b2735 [qfcc] Set the source location for compound init elements
Finally, less bouncing to the compound initializer's closing brace line.
2024-02-21 22:41:08 +09:00
Bill Currie
2be9821a59 [qfcc] Use statement aux def if def not in operands
This takes care of ptrmove instructions, fixing the printf problem in
ptrstructinit. It might even make it possible to not break basic blocks
on function calls, which should make for some more optimization
opportunities, but that can come later.

For this to work properly, it was necessary to avoid converting alias
defs to st_alias nodes.

It also fixes ptrstructinit itself (at first, I hadn't noticed that the
test passed entirely).
2024-02-21 22:41:08 +09:00
Bill Currie
07ef862c52 [qfcc] Put problematic printf into ptrstructinit
It turns out the bug I was chasing in set_poses was not the data getting
lost or incorrect data being read, but the arguments to printf being set
from the parent pose `p` before `p` had actually been set.
2024-02-21 22:41:08 +09:00
Bill Currie
00781160e2 [qfcc] Remove the node from its own edges
This gets rid of the funny little self-loop edge in dags dot files that
has bothered me for a while. It was just because the node to which an
identifier was attached happened to be the parent of the identifier's
leaf node.
2024-02-21 22:41:08 +09:00
Bill Currie
b842913ca9 [qfcc] Remove special treatment for flow/func statements
The fix in bdafdad0d5 for
`while (count--)` never did appeal to me. I think I understood the core
problem at the time, but I hadn't figured out how to use a var's
use/define sets to detect the write-before-read. Using them allows the
special handling for flow control to be removed, making things more
robust. The function call handling has been superfluous since the
Ruamoko instruction set required the auxiliary operands on the call
statements.
2024-02-21 22:41:08 +09:00
Bill Currie
1fb4a556d7 [qfcc] Remove old ptrmove code from dag creation
It doesn't seem to help any, and removing it doesn't break anything
(that is tested), and I'm working on better handling of ptrmove support.
2024-02-21 22:41:08 +09:00
Bill Currie
9a38cdfd78 [qfcc] Clean up dag item counting and init
Not by much really, but using one "aux" count instead of different
types, and using functions to iterate through the statement's aux
operands makes the code easier to read.
2024-02-21 22:41:08 +09:00
Bill Currie
768113d37b [qfcc] Replace expr_file_line with a scoped version
Two birds with one stone: eliminates most of the problems with going
const-correct with expr_t, and it make dealing with internally generated
expressions at random locations much easier as the set source location
affects all new expressions created within that scope, to any depth.
Debug output is much easier to read now.
2024-02-21 22:41:08 +09:00
Bill Currie
6e8c98433a [qfcc] Fix a missed const type_t 2024-02-21 22:41:08 +09:00
Bill Currie
b9aad99381 [qfcc] Clean up warning and notice return types
They never needed to return expr.
2024-02-21 22:41:08 +09:00
Bill Currie
131ad9013c [qfcc] Tidy up expr_assign_copy a little
It proved that expr_assign_copy wasn't the cause of any problems, but I
cleaned up some of its types a little.
2024-02-21 22:41:08 +09:00
Bill Currie
35e2044bfa [qfcc] Fix nested compound initializers
Add static array indexing. This gets the compoundinit test working.
2024-02-21 22:41:08 +09:00
Bill Currie
19965e7cbd [qfcc] Add a failing test case for compound initializers
It turns out that compound intializers break on when the nesting level
increases (eg, initializing vectors in structs in arrays).
2024-02-21 22:41:08 +09:00
Bill Currie
1b4db639af [qfcc] Handle quaternion (in)equality tests
I'm surprised this didn't come up earlier.
2024-02-21 22:41:08 +09:00
Bill Currie
0e7c80e9fe [qfcc] Use ud-chains for ptrmove pointer analysis
ptrmove was not treating its indirect source operand as used because the
pointer wasn't checked for its source.

This fixes part of ptrstructinit, but there's a lot more breakage in
that test: it looks like all sorts of fun with arrays.
2024-02-21 22:41:08 +09:00
Bill Currie
ab69e65e02 [qfcc] Add failing test case for pointer struct initialization 2024-02-21 22:41:08 +09:00
Bill Currie
3a22091455 [qfcc] add pointer validity check function to test-harness 2024-02-21 22:41:08 +09:00
Bill Currie
192eb11235 [qfcc] Dereference most array types properly
This should prevent some fun bugs in the future (it's what necessitated
the const-correct patch).
2024-02-20 16:47:06 +09:00
Bill Currie
f0dfe47a32 [qfcc] Make type_t mostly const-correct
There were a few places where some const-casts were needed, but they're
localized to code that's supposed to manipulate types (but I do want to
come up with something to clean that up).
2024-02-20 16:47:04 +09:00
Bill Currie
6e71aadfa4 [qfcc] Use dereference_type for initialized arrays
In particular, when the size is inferred from the compound initializer.
Fixes a fun "incomplete type" error.
2024-02-20 16:46:02 +09:00
Bill Currie
fa5c3ab12e [qfcc] Support arrays in dereference_type
This is needed to get the correct type from arrays of typedefed
elements.
2024-02-20 16:46:02 +09:00
Bill Currie
827ca3cf27 [qfcc] Make array_type const-correct
As such... need to cast away the const when calling append_type (which
should probably become internal).
2024-02-20 16:46:02 +09:00
Bill Currie
3d26aafbea [qfcc] Unalias def ops too
When I implemented the st_alias handing (d8a78fc849) I was
unsure if I needed to unalias aliased defs too, but it turns out to have
been necessary: this is what caused my 2d PGA dynamics test to blow up
strangely due to the GA vector loaded from an array into a local
variable getting the local var replaced by a temp but the var itself
being read later in the code (uninitialized variable due to incorrect
optimization... oops).
2024-02-20 16:46:02 +09:00
Bill Currie
37fe0bc4ed [qfcc] Fix some 2d PGA bugs
When sum_expr gets a null expression as one of its args, it simply
returns the other arg, but that arg needs to have the correct type
applied.

Handle zero (null result) cross product in bivector geometric product.

Clean up types in bivector * vector geometric product.
2024-02-20 16:46:02 +09:00
Bill Currie
946211bca2 [qfcc] Use a better name for a var
Looking at the code afterwards, I realized flips would be a far better
name than mask. Not sure what I was thinking when I wrote the code.
2024-02-20 16:46:02 +09:00
Bill Currie
40f04ff33e [qfcc] Implement undual and use for regressive product
I'm not sure the regressive product is right (overall sign), but that's
actually partly a problem in the math itself (duals and the regressive
product still get poked at, so it may be just a matter of
interpretation).
2024-02-20 16:46:02 +09:00
Bill Currie
10861986fb [qfcc] Add tests for the hodge dual 2024-02-20 16:46:02 +09:00
Bill Currie
d319ce6106 [qfcc] Support multi-vector comparison
I'm not sure anything other than == or != has much meaning on anything
but scalars and pseudo scalars, but all comparisons are supported as a
simple boolean test. Any missing components are assumed to be 0. If
nothing else, it makes unit tests easier to write.
2024-02-20 16:46:02 +09:00
Bill Currie
11b247918e [qfcc] Find current algebra context for duals
Now finding the dual of a scalar works, too (need a context as otherwise
the pseudo-scalar is unknown).
2024-02-20 16:45:55 +09:00
Bill Currie
e56b4a3a6d [qfcc] Strip off algebra types internally
It turns out the algebra types make expression dag creation much more
difficult resulting in missed optimizations (eg, recognizing `a × a`).
This fixes the dead cross products in `⋆(s.B × ⋆s.B)`
2024-02-08 13:56:59 +09:00
Bill Currie
cf756eb1a0 [qfcc] Emit statements for expressions only once
The switch to using expression dags instead of trees meant that the
statement generator could traverse sub-expressions multiple times. This
is inefficient but usually ok if there are no side effects. However,
side effects and branches (usually from ?:, due to labels) break: side
effects happen more than once, and labels get emitted multiple times
resulting in orphaned statement blocks (and, in the end, uninitialized
temporaries).
2024-02-08 13:56:59 +09:00
Bill Currie
701b0f3992 [qfcc] Print block label expressions first
Just running through the list of expressions in a block expression
results in label expressions within the block getting printed by
expressions that reference them and thus don't receive the correct next
pointer and wind up pointing to themselves. Printing the labels first
ensures they have the correct next pointer. However, I suspect there are
other ways things will get tangled.
2024-02-08 13:56:59 +09:00
Bill Currie
5fef8e6edb [qfcc] Implement quaternion multiplication
I'm surprised it took almost two years to discover that I had no
quaternion multiplications in any test code, but getting an ICE for a
quaternion-vector product, and the Hadamard product for
quaternion-quaternion was a bit of a nasty surprise.
2024-02-01 11:00:27 +09:00
Bill Currie
8994042a47 [qfcc] Support expanding constant expressions
This makes a slight improvement to the commutator product in that it
removes the expand statement, but there's still the problem of (a+a)/2.
However, at least now the product is correct and slightly less abysmal.
2024-01-19 15:36:47 +09:00
Bill Currie
aa9be53b6e [qfcc] Include divide by two in commutator product
I had forgotten this, and of course didn't have any tests.
2024-01-19 15:26:18 +09:00
Bill Currie
5c22ba118c [qfcc] Support aliasing constants
This takes advantage of evaluate_constexpr to do all the work. Necessary
for use of basis blade constants in algebra contexts (avoids an internal
error).
2024-01-18 13:08:21 +09:00
Bill Currie
0ed4df3fb9 [quakeio] Rework Qgetline to use dstring
This clears up its stray memory allocation, and incidentally makes it
thread-safe.
2024-01-05 11:50:48 +09:00
Bill Currie
bfa7c1722a [build] Implement tracy memory zones
This proved to be quite the challenge, and is probably rather fragile,
but it does seem to work, and might help with tracking down memory
leaks.
2024-01-05 11:50:48 +09:00
Bill Currie
18c0ea3657 [qfcc] Ensure one is the correct type for incop expressions
This makes for nicer generated code when the incop (especially post) is
used in a condition.
2023-12-20 23:10:17 +09:00
Bill Currie
dd183d3ba6 [qfcc] Handle signed-unsigned int comparison better
This fixes the upostop-- test by auto-casting implicit constants to
unsigned (and it gives a warning for signed-unsigned comparisons
otherwise). The generated code isn't quite the best, but the fix for
that is next.

Also clean up the resulting mess, though not properly. There are a few
bogus warnings, and the legit ones could do with a review.
2023-12-20 23:09:06 +09:00
Bill Currie
54839db826 [qfcc] Add some tests for postop--
Interestingly, intval-- works properly, but unsignedval-- does not (test
case fails). This is why menus blow up when opening the load/save
sub-menu.
2023-12-20 21:50:51 +09:00
Bill Currie
dd4f51049d [build] Fix up unwanted dependency on tracy source
The tracy source files should not be required for make dist to work, so
this works around it by using a little indirection.
2023-12-17 19:18:58 +09:00
Bill Currie
9c3f0bc5d4 [build] Fix some release script issues
Set sharepath correctly and the menu is not gzipped any more.
2023-11-25 15:45:25 +09:00