Commit graph

14079 commits

Author SHA1 Message Date
Bill Currie
198cec6df8 [qfcc] Add a failing test case for dags
I'm not yet sure what went wrong, but the introduction of dags broke
something in my set_transform function (perhaps the dual?), but it's
something to do with the symbol being dagged (I guess because it's
required for everything else to dag). However, the strangest thing is
the error shows up with 155a8cbcda which
is before dags had any direct effect on the geometric algebra code. I
have a sneaking suspicion it's yet another convert_name issue.
2023-09-29 10:15:04 +09:00
Bill Currie
9c258b02e8 [qfcc] Be more cautious with summed extents
They should be treated as such only when merging vector components. This
fixes a bug that doesn't actually exist (it's in experimental code),
where the sum of two 3-component vectors was getting lost.
2023-09-29 10:15:04 +09:00
Bill Currie
c01cbf4fc4 [qfcc] Use distributivity to cancel cross and dot products
For cross products: remove any a from a×(...+/-a...)
For dot products: remove any a×b from a•(...+/-a×b...) (or b×a)

This removed another 2 instructions :)
2023-09-29 10:14:56 +09:00
Bill Currie
7271d2d570 [qfcc] Add flags for commutative and anticommutative
They don't have much effect that I've noticed, but the expression dags
code does check for commutative expressions. The algebra code uses the
anticommutative flag for cross, wedge and subtract (unconditional at
this stage). Integer ops that are commutative are always commutative (or
anticommutative). Floating point ops can be controlled (default to non),
but no way to set the options currently.
2023-09-25 17:26:37 +09:00
Bill Currie
5119237c4c [qfcc] Apply a×a=0
This takes advantage of the expression dag to detect when an expression
is on both sides of a cross product (which always results in 0). This
removes 3 instructions from my motor test (28 to go).
2023-09-25 16:57:15 +09:00
Bill Currie
6d2e3c166d [qfcc] Add GA algebraic expressions to the dags
Again, doesn't affect generated code yet, but it does make it easier to
work with the resulting graphs looking for cancellations.
2023-09-25 16:57:15 +09:00
Bill Currie
155a8cbcda [qfcc] Use dags for many expressions
Especially binary expressions. That expressions can now be reused is
what caused the need to make expression lists non-invasive: the reuse
resulted in loops in the lists. This doesn't directly affect code
generation at this stage but it will help with optimizing algebraic
expressions.

The dags are per sequence point (as per my reading of the C spec).
2023-09-25 16:57:15 +09:00
Bill Currie
d7714eeca7 [qfcc] Disable VM evaluation for non-ruamoko targets
This is really a bandaid for the problem of ruamoko not being an actual
superset of v6 progs (eg, no float | operation). With this, even ctf
builds.
2023-09-25 16:57:15 +09:00
Bill Currie
1e7b1ec86f [qfcc] Fix vector component symbols
The removal of the e tag from expr_t necessitated making convert_name
return a new expressions which resulted in get_type no longer being
enough to both convert a name expression and get the type. This was just
another missed spot. With this, all of game-source except ctf builds.
2023-09-25 16:57:15 +09:00
Bill Currie
79dbc9b866 [qfcc] Add pragma control of code options 2023-09-25 16:57:15 +09:00
Bill Currie
f974192177 [qfcc] Use non-invasive lists for function arguments
This allows expressions to be repeated (by reference) in function
argument lists, which will allow for expression dags.
2023-09-25 16:57:15 +09:00
Bill Currie
81b544c362 [qfcc] Use non-invasive lists for most expressions
This covers attribute params, vector, state, and comma expressions. Just
function args to go, I think.
2023-09-25 16:57:15 +09:00
Bill Currie
cc67e69923 [qfcc] Use non-invasive lists for block expressions
They will be used for other expression types too. Invasive lists make it
difficult to do expression dags.
2023-09-25 16:57:15 +09:00
Bill Currie
345eba45d5 [qfcc] Make the expression union anonymous
Finally, that little e. is cleaned up. convert_name was a bit of a pain
(in that it relied on modifying the expression rather than returning a
new one, or more that such behavior was relied on).
2023-09-23 18:01:49 +09:00
Bill Currie
9af94da151 [qfcc] Rename ex_list_t to ex_boollist_t
I need to create an actual expression list type and want the name.
2023-09-22 20:26:41 +09:00
Bill Currie
2e90022d5c [util] Define ALLOC_STATE for DEBUG_QF_MEMORY
I haven't used DEBUG_QF_MEMORY for a while, so it suffered a bit of
bitrot.
2023-09-22 20:22:24 +09:00
Bill Currie
5c72ce10d2 [input] Delay event system init
I think I had though it using a constructor init was ok, but it turns
out that was problematic. That, or I missed it in my recent audit. Fixes
a sys syserror during shutdown.
2023-09-21 02:02:12 +09:00
Bill Currie
9a081b6809 [input] Fix input shutdown order
This fixes another segfault on shutdown (not sure just which recent
change caused it, but the listener pointer needed clearing) but while
fixing the listener issue, I noticed that binding and imt shutdown were
in the wrong order with respect to buttons and axes.
2023-09-21 01:36:43 +09:00
Bill Currie
1183d44361 [qfcc] Skip dag dependency lines for leaf nodes
Leaf nodes never generate code so showing lines to them only cluttered
the displayed dag (they're still there internally, though).
2023-09-19 11:47:28 +09:00
Bill Currie
1e274b385d [qfcc] Improve handling of negative GA expressions
Sum expressions pull the negation through extend expressions allowing
them to switch to subtraction when appropriate, and offset_cast reaches
past negation to check for extend expressions. This has eliminated all
negation-only instructions from the motor-point, shaving off more
instructions (now 27 not including the return).
2023-09-19 00:47:29 +09:00
Bill Currie
ca01ab2a27 [qfcc] Improve offset_cast's zero detection
I'd caught 0 single components, but I'd missed 0 vector components. This
shaves 4 instructions off the motor-point test.
2023-09-18 21:43:23 +09:00
Bill Currie
068f685fde [qfcc] Simplify offset_cast for correctness
I don't know why I didn't think to do it this way before, but simply
recursing into each operand for + or - expressions makes it much easier
to generate correct code. Fixes the motor-point test.
2023-09-18 19:36:15 +09:00
Bill Currie
7646f6b51e [qfcc] Add failing test case for motor-point sandwich
This tests a subtle bug where part of the product is dropped on the
floor due to an issue with aliasing through expand expressions.
2023-09-18 19:34:22 +09:00
Bill Currie
84df81bd03 [ruamoko] Clean up buttons and axes
Reloading progs (or shutting down) needs to clean up the buttons
otherwise the input system will have issues when it cleans up because
the buttons and axes have ceased to exist.
2023-09-15 14:04:21 +09:00
Bill Currie
1a36d3786d [input] Allow buttons and axes to be deregistered
This is used by the Ruamoko input bindings so progs can clean up.
2023-09-15 14:04:21 +09:00
Bill Currie
5e041ef3f8 [qwaq] Remove the shutdown builtin
It proved to be a bad idea with the error handler stack.
2023-09-15 13:53:46 +09:00
Bill Currie
fab5ae9d1f [input] Delay button and axis init
It turns out that initializing them via constructors led to their
shutdowns happening too late which resulted in problems with button and
axis cleanup.
2023-09-15 13:51:59 +09:00
Bill Currie
4eaaf28030 [sys] Ensure dstrings don't get double-freed
Never nice.
2023-09-15 01:15:10 +09:00
Bill Currie
ea375a4e2f [qfcc] Fix @dot for vecN types
The change from @dot producing a vector to producing a scalar missed
basic vecN types.
2023-09-14 21:29:59 +09:00
Bill Currie
cb72769aa9 [model] Clean up the model struct a little
Mostly just removing some (near) dead fields and making the
flags/effects more clear on what it's for.
2023-09-14 20:35:45 +09:00
Bill Currie
e535fd51b7 [qfcc] Make passing int constants through ... ok
That is, passing int constants through ... in Ruamoko progs is no longer
a warning (still is for v6p and v6 progs). I got tired of getting the
warning for sizeof expressions when int through ... hasn't been a
problem for even most v6p progs, and was intended to not be a problem
for Ruamoko progs.
2023-09-14 18:33:06 +09:00
Bill Currie
862b2669a5 [qfcc] Ensure progs defs are sorted by address
This ensures they can be found by the progs debug support (since they do
a simple bsearch).
2023-09-12 22:26:30 +09:00
Bill Currie
3f93f6b226 [qfprogs] Create a stack for disassembly of locals
This prevents local variables getting intertwined with globals when
disassembling.
2023-09-12 22:21:55 +09:00
Bill Currie
d03637ede8 [gamecode] Dump void data in hex
This makes dealing with assign instructions much easier.
2023-09-12 22:16:35 +09:00
Bill Currie
ea02af57eb [gamecode] Allow stack with no heap
Trying to use stack without a heap allocated would result in some very
bogus stack info.
2023-09-12 22:13:18 +09:00
Bill Currie
8ec66f118a [qfcc] Set a flowvar's minimum size based on usage
But really only for memset and memmove because they need to use an int
alias of the variable and it may be only that alias that sets a much
larger variable.
2023-09-11 22:59:40 +09:00
Bill Currie
73d1044bec [qfcc] Support offset aliases of values
But explicitly not for pointers (even an offset of 0 breaks the pointer
relocation).
2023-09-11 22:56:10 +09:00
Bill Currie
b456f936c6 [qfcc] Fix vector expressions for generic vectors
It seems the code was never really tested due to an incorrect progs
version test.
2023-09-11 12:31:08 +09:00
Bill Currie
91c3049348 [qfcc] Ensure scale expressions have the correct type
fold_constants was replacing the pseudoscalar type with a float. I
really need to rewrite that whole block sometime.
2023-09-11 12:30:38 +09:00
Bill Currie
eb9954700a [qfcc] Simplify algebra_field_expr
This removes all the special cases and thus it should be more robust. It
did show up some out-by-one (or a factor of two!) errors elsewhere in
the group mask calculations.
2023-09-11 10:25:35 +09:00
Bill Currie
c066e638e5 [qfcc] Take memset/move size into account for use/def
This fixed the bogus uninitialized variable working in b648c353f
2023-09-11 00:37:53 +09:00
Bill Currie
b648c353ff [qfcc] Add a failing test for bogus uninitialized
The variable is very definitely initialized... by a memset (which is the
problem, actually).
2023-09-11 00:34:15 +09:00
Bill Currie
4bcbfc3473 [qfcc] Fix an uninitialized test
When the function is empty, not even a stack adjust instruction is
emitted, so checking for one wound up accessing uninitialized memory.
2023-09-11 00:32:01 +09:00
Bill Currie
2d7b5c18af [qfcc] Add named types to algebra subtypes
I'm uncertain about the names, but this makes it much easier to get at
specific subtypes (eg, PGA.tvec as a type) rather than having to know
the group mask.
2023-09-11 00:31:27 +09:00
Bill Currie
d387b56f60 [qfcc] Support block initializers for multi-vectors
They're not supported (yet) for single-group multi-vectors, and
designators are required for all initializer elements.
2023-09-11 00:24:50 +09:00
Bill Currie
bce2b7d767 [ruamoko] Add sincos and sincosh functions
sincos is just a wrapper around the GNU libc sincos. sincosh is the
equivalent for sinh and cosh, but there doesn't seem to be any such
function, so it's just the two wrapped. They both return their results
in a vec2/vec2d as (sih[h], cos[h]).
2023-09-10 14:13:56 +09:00
Bill Currie
b35f4c82a4 [qfcc] Implement field access for multi-vector expressions
Of course as an r-value (I think), but it makes getting only the desired
part of a geometric algebra expression much nicer.
2023-09-10 13:13:49 +09:00
Bill Currie
97624b84aa [qfcc] Implement field access to sub-algebra variables
This makes working with the plethora of types a little easier still. The
check for an algebra expression in field_expr needed to be moved up
because the struct code thought the algebra type was a normal vector.
2023-09-10 10:53:59 +09:00
Bill Currie
55fc343383 [qfcc] Allow casting float algebras to double
And vis-versa.

I'm not sure what I was thinking, but I've decided that not being able
to cast the pseudo-scalar from float to double (for printf etc) was a
bug.
2023-09-10 10:49:50 +09:00
Bill Currie
ed824405fe [qfcc] Support struct access to full algebra vectors
This makes them actually useable. Multi-vector expressions and variables
will be done soon.
2023-09-09 23:08:38 +09:00