Commit graph

2839 commits

Author SHA1 Message Date
Bill Currie
a01cbd56fd [qfcc] Write tests for 3d PGA dot products
And fix the bugs that were uncovered.
2023-08-29 21:30:18 +09:00
Bill Currie
c42aaea060 [qfcc] Write tests for 3d PGA wedge products
And fix the discovered bugs.
2023-08-29 19:42:00 +09:00
Bill Currie
33295a8ad9 [qfcc] Use structs for multi-vector type layouts
Simple k-vectors don't use structs for their layout since they're just
an array of scalars, but having the structs for group sets or full
multi-vectors makes the system alignment agnostic.
2023-08-29 17:10:29 +09:00
Bill Currie
09cdf87f67 [qfcc] Used aligned type sizes for sizeof
And geometric algebra vectors. This does break things a little in GA,
but it does bring qfcc's C closer to standard C in that sizeof respects
the alignment of the type (very important for arrays).
2023-08-29 13:59:12 +09:00
Bill Currie
ad6b4057f9 [qfcc] Apply member alignment to union size
Seeing a union of size 7 when its members need an alignment of 4 was
rather a concern.
2023-08-29 08:25:19 +09:00
Bill Currie
e4391992cb [qfcc] Remove the internal error for null bool lists
It turns out that both lists can be null when applying short circuit
logic to constants.
2023-08-29 08:06:28 +09:00
Bill Currie
d6ec250897 [qfcc] Fix vector int tests
These too needed a horizontal or.
2023-08-29 08:04:32 +09:00
Bill Currie
327cb88af3 [qfcc] Demote implicit double vector literals correctly
The code for demoting the literals wasn't taking the width into account.
2023-08-29 08:02:11 +09:00
Bill Currie
8de722bfc7 [qfcc] Mark large products as unimplemented
Before I forget and wonder why they're not working.
2023-08-28 20:35:03 +09:00
Bill Currie
58a1758363 [qfcc] Implement the regressive product
That went surprisingly well (but it is built up from other ops, so
pretty easy, really).
2023-08-28 20:35:03 +09:00
Bill Currie
e2d812ab6a [qfcc] Implement multi-vector dual
It's implemented as the Hodge dual, which is probably reasonable until
people complain. Both ⋆ and ! are supported, though the former is a
little hard to see in Consola.
2023-08-28 20:35:03 +09:00
Bill Currie
1329a1c43a [qfcc] Implement multi-vector negation
That was surprisingly harder than expected due to recursion and a
not-so-good implementation in expr_negate (it went too high-level thus
resulting in multivec expressions getting to the code generator).
2023-08-28 17:00:14 +09:00
Bill Currie
6b1684b711 [qfcc] Implement mutli-vector division
But only for scalar divisors. The simple method of AB†/(BB†) works only
if B is a versor and there's also the problem of left and right
division. Thanks to sudgy for making me stop and think before I actually
implemented anything (though he mentioned only that it doesn't work for
general mutli-vector divisors).
2023-08-28 12:17:59 +09:00
Bill Currie
41e0483102 [qfcc] Read float/double vector literals correctly
Wow, I thought that had been tested. I guess that not vary many vector
literals used fractional values.
2023-08-28 12:06:25 +09:00
Bill Currie
5b1ce309ef [qfcc] Implement multi-vector reversion
For a change, something that's actually general rather than specific to
PGA.
2023-08-28 11:56:35 +09:00
Bill Currie
717b09f33e [qfcc] Fix vector long tests
And the discovered typos (yes, I double-checked the values) in the PGA
tests.
2023-08-27 18:40:40 +09:00
Bill Currie
55b7547451 [qfcc] Get the rest of the main 2d PGA products working
That was tedious. I can't say I'm looking forward to writing the tests
for 3d. And even though trivector . bivector and bivector . trivector
give the same answer, they're not really commutative when it comes to
the code.
2023-08-27 15:24:35 +09:00
Bill Currie
5aea74de7e [qfcc] Show algebra signature for bad basis blades
Clear error messages are always more helpful than opaque ones.
2023-08-27 15:17:22 +09:00
Bill Currie
c7d6e80d69 [qfcc] Use GPU-style alignment for algebra types
Meaning vec3 is aligned to 4 components instead of 1. 2-component ops
use vec2 in the VM thus requiring alignment to boundaries of 2, but 4
seems better as it conforms with OpenGL and Vulkan (and, I imagine,
DirectX, but I doubt QF will ever use DirectX).
2023-08-27 15:13:49 +09:00
Bill Currie
74b7e0a35b [qfcc] Get some of 2d PGA mostly working
Better yet, some tests :)
2023-08-27 00:24:23 +09:00
Bill Currie
0939979d84 [qfcc] Allow #pragma to control warning options
I probably need to make a decision about vararg integer constants, but
the ability to control warnings is never a bad thing.
2023-08-26 23:47:00 +09:00
Bill Currie
a5304461dd [qfcc] Fix adjusted swizzles for the same def
The singleton alias resulted in the adjusted swizzles being corrupted
when for the same def. Other than adding properly sized swizzles
(planned), the simplest solution is to (separately) allow alias that
stick out from from the def.
2023-08-26 23:08:55 +09:00
Bill Currie
29a57b7128 [qfcc] Correct handling of 64-bit comparisons
While the progs engine itself implements the instructions correctly, the
opcode specs (and thus qfcc) treated the results as 32-bit (which was,
really, a hidden fixme, it seems).
2023-08-26 23:04:34 +09:00
Bill Currie
91edc5d177 [qfcc] Unalias expressions when checking for math values
Fixes some ICEs when trying to fold constants in geometric algebra.
2023-08-26 11:48:23 +09:00
Bill Currie
77c1b584ea [qfcc] Clean up the blade scaling
I didn't particularly like that solution due to the implied extra
bandwidth (probably should profile such sometime), but I think the
extend operations could be merged into simple assignments by the
optimizer at some stage (or further cleaned up when this stuff gets
moved to actual code gen where it should be).
2023-08-25 22:34:41 +09:00
Bill Currie
60ce4ba8fb [qfcc] Give direct access to algebra subtypes
Currently via only the group mask (which is really horrible to work
with: requires too much knowledge of implementation details, but does
the job for testing), but it got some basics working.
2023-08-25 22:13:54 +09:00
Bill Currie
d2e134cc22 [qfcc] Support multiple parameters for attributes
I have no idea why I threw away all but the *last* parameter (especially
considering nothing used parameters until now).
2023-08-25 22:13:54 +09:00
Bill Currie
b2301c8bad [qfcc] Implement 3d PGA geometric algebra
No clue whether anything is actually correct. Time to start creating
real tests.
2023-08-25 22:13:54 +09:00
Bill Currie
e888f71f8a [qfcc] Fetch sum operand type early
Because component_sum works in-place, using a[i]'s type after setting
c[i] resulting in a null type and thus a segfault.
2023-08-25 22:13:54 +09:00
Bill Currie
a46f9a63d2 [qfcc] Clean up GA sum and scale expressions
Scale was inconsistent and sum was error prone due to using
new_binary_expression raw.
2023-08-25 17:24:47 +09:00
Bill Currie
53d9fee586 [qfcc] Support the extended extend instruction
That... feels odd :)
2023-08-25 17:20:28 +09:00
Bill Currie
55bdcbe4c5 [qfcc] Implement 2d PGA geometric product
This is definitely showing the need for better vector instructions
(mostly a 2d wedge and width dependent swizzles).
2023-08-24 22:07:04 +09:00
Bill Currie
e66ae0aad6 [qfcc] Correct swizzle expressions
It turned out they were always using floats for the source type (meaning
doubles were broken), and not shifting the component in the final sizzle
code meaning all swizzles were ?xxx (neglecting minus or 0). I'd make
tests, but I plan on modifying the instruction set a little bit.
2023-08-24 21:43:09 +09:00
Bill Currie
5f22fd07d9 [qfcc] Implement 3d PGA dot products
Also, correct the handling of scalars in dot and wedge products: it
turns out s.v and s^v both scale. However, it seems the CSE code loses
things sometimes.
2023-08-24 15:49:52 +09:00
Bill Currie
6d75d91de2 [qfcc] Implement 2d PGA dot (inner) product
This has shown the need for more instructions, such as a 2d wedge
product and narrower swizzles. Also, making dot product produce a vector
instead of a scalar was a big mistake (works nicely in C, but not so
well in Ruamoko).
2023-08-24 00:19:58 +09:00
Bill Currie
469fdea0a1 [qfcc] Implement 2d PGA outer products
The specialization is really just in the layout.
2023-08-23 21:52:33 +09:00
Bill Currie
da1b797cb7 [qfcc] Get scalar promotion working again
The cleanup of the scalar expressions lost the type promotion so using
ints in expressions didn't always work.
2023-08-23 21:51:01 +09:00
Bill Currie
d7bab4e222 [qfcc] Avoid constant folding for vector types
The current code is pretty broken when it comes to vector types (losing
the vector and bogus errors among other issues). The whole thing needs a
rework or even just to be tossed in favor of better DAG processing.
2023-08-23 21:48:25 +09:00
Bill Currie
c550ab6b86 [qfcc] Switch 2d PGA groups to be easily implemented
I guess Hamish's suggestion made sense at the time, but I found that
with the current instructions, the reversed bivector wasn't so nice to
implement it would need a swizzle as well as the cross-product.
2023-08-23 21:43:14 +09:00
Bill Currie
8ff2c5a747 [util] Support utf-8 strings in Sys_Printf
By default. Conversion of quake strings needs to be requested (which is
done by nq and qw clients and servers, as well as qfprogs via an
option). I got tired of seeing mangled source code in the disassembly.
2023-08-23 21:40:50 +09:00
Bill Currie
24c085c1bd [qfcc] Implement 3d-PGA wedge products
Not all possibilities have been tested yet, but the initial code looks
good even if it has a couple of excessive temporary variables.
2023-08-23 15:38:32 +09:00
Bill Currie
c92dd9d86c [type] Use vec4 and vec3 in Ruamoko progs
I'm not sure if that was a thinko, typo, or something else, but judging
by the relevant commit message, the use of quaternion and vector was
intended only for advanced progs (v6p).
2023-08-23 15:38:32 +09:00
Bill Currie
0d639510e3 [qfcc] Add a function to create typed zero expressions
Sometimes, nil's untyped 0 isn't really suitable.
2023-08-23 15:38:32 +09:00
Bill Currie
deb03ca27a [qfcc] Set correct statement type for memset
Explicit memset expressions were becoming move instructions when
optimizing, which would generally not result in correct values.
2023-08-23 15:38:32 +09:00
Bill Currie
0d491ce68c [qfcc] Build multi-vector expressions correctly
Losing the other components and getting the offset wrong doesn't make
for a correct multi-vector expression when pulling apart a multi-vector
def.
2023-08-23 15:38:32 +09:00
Bill Currie
d75bf346f3 [qfcc] Support multivec expressions for dot
They don't normally survive to the block-dot stage, but being able to
see the graphs when debugging.
2023-08-23 15:38:32 +09:00
Bill Currie
cfcacfbf28 [qfcc] Use scatter-gather for multivec expressions
This makes working with them much easier, and the type system reflects
what's in the multi-vector. Unfortunately, that does mean that large
algebras will wind up having a LOT of types, but it allows for efficient
storage of sparse multi-vectors:

    auto v = 4*(e1 + e032 + e123);

results in:

    0005 0213 1:0008<00000008>4:void     0:0000<00000000>?:invalid
              0:0044<00000044>4:void          assign (<void>), v
    0006 0213 1:000c<0000000c>4:void     0:0000<00000000>?:invalid
              0:0048<00000048>4:void          assign (<void>), {v + 4}

Where the two source vectors are:

    44:1 0 .imm float:18e [4, 0, 0, 0]
    48:1 0 .imm float:1aa [4, 0, 0, 4]

They just happen to be adjacent, but don't need to be.
2023-08-23 15:38:32 +09:00
Bill Currie
dfb719c92b [qfcc] Correct scaling and multivec sums
Scaling now works for multi-vector expressions, and always subtracting
even when addition is wanted doesn't work too well. However, now there's
the problem of multi-vectors very quickly becoming full algebra vectors,
which means certain things need a rethink.
2023-08-21 20:10:13 +09:00
Bill Currie
2e91b29580 [qfcc] Start work on implementing geometric algebra
This gets only some very basics working:
 * Algebra (multi-vector) types: eg @algebra(float(3,0,1)).
 * Algebra scopes (using either the above or @algebra(TYPE_NAME) where
   the above was used in a typedef.
 * Basis blades (eg, e12) done via procedural symbols that evaluate to
   suitable constants based on the basis group for the blade.
 * Addition and subtraction of multi-vectors (only partially tested).
 * Assignment of sub-algebra multi-vectors to full-algebra multi-vectors
   (missing elements zeroed).

There's still much work to be done, but I thought it time to get
something into git.
2023-08-21 17:58:20 +09:00
Bill Currie
cb9a82e74c [qfcc] Allow symbol tables to have procedural symbols
If a symbol is not found in the table and a callback is provided, the
callback will be used to check for a valid procedural symbol before
moving on to the next table in the chain. This allows for both tight
scoping of the procedural symbols and caching.
2023-08-21 17:47:55 +09:00
Bill Currie
dfb7862419 [qfcc] Use the progs VM to help with constant folding
Due to joys of pointers and the like, it's a bit of a bolt-on for now,
but it works nicely for basic math ops which is what I wanted, and the
code is generated from the expression.
2023-08-21 17:47:55 +09:00
Bill Currie
27ccad40c9 [qfcc] Split out the conversion evaluation code
This takes care of the FIXME regarding breaking it out for more general
use (the time has come to redo constant folding).
2023-08-21 17:47:55 +09:00
Bill Currie
a64895b98f [qfcc] Include C function in diagnostic messages
It's kind of redundant with the line number, but it's helpful for seeing
the context at a glance.
2023-08-21 17:47:55 +09:00
Bill Currie
b9fd7a46af [qfcc] Implement auto as per c23
That was surprisingly easy, which makes me worried I missed something.
2023-08-21 17:47:55 +09:00
Bill Currie
cb4b073e47 [qfcc] Support some unicode ops and GA ops
Only · (dot product) and × (cross product for vector, commutator product
for geometric algebra) have been tested so far, but that involved
fighting with cpp to get it to not convert the · to \U000000b7, which
was rather annoying.
2023-08-21 17:47:55 +09:00
Bill Currie
a0ddc2b2bd [qfcc] Support explicit dot product in v6p code
The dot product in v6p code returns a float rather than a vector.
2023-08-21 17:47:55 +09:00
Th3T3chn0G1t
3098b5d3f7 Implement clang support
Fixing a load of issues related to autoconf and some small source-level issues to re-add clang support.
autoconf feature detection probably needs some addressing - partially as -Werror is applied late.
2023-08-11 14:25:01 +09:00
Bill Currie
7ce475b114 [qfcc] Use full type for encoding alias types
This is needed for distinguishing type aliases when only the name
changes.
2023-06-30 02:42:28 +09:00
Bill Currie
56d33d1b98 [qfcc] Remove 8 argument limit from ruamoko function calls
That hasn't been an issue for over a year thanks to the stack.
2023-06-29 21:17:25 +09:00
Bill Currie
dbd3d6502a Nuke qboolean from orbit
I never liked it, but with C2x coming out, it's best to handle bools
properly. I haven't gone through all the uses of int as bool (I'll leave
that for fixing when I encounter them), but this gets QF working with
both c2x (really, gnu2x because of raw strings).
2023-06-13 18:06:11 +09:00
Bill Currie
9871b44d68 [build] Fix a warning in attribute const check
The warning flag check worked too well: it enabled the warning and
autoconf's default main wanted the const attribute. The bug has been
floating around for a while, it seems.
2023-06-13 13:08:38 +09:00
Bill Currie
fe045f75fb [qfcc] Force live vars used by function statements
This uses ud-chains for function statements (call/return) to force their
arguments to be live (in particular, indirect references via pointers)
this fixes the arraylife test.
2023-06-05 17:20:12 +09:00
Bill Currie
fb1b3e0869 [qfcc] Use ud- and du-chains for block live analysis
The ud- and du-chains include known side-effects of the instructions and
thus depict a more accurate view of what operands an instruction uses or
defines. Fixes the arraylife2 test.
2023-06-05 11:03:44 +09:00
Bill Currie
38fd09573f [qfcc] Avoid defining whole temp via alias
Like defs, a partial write should not define the whole temp. Thus, copy
the "don't visit main" behavior recently added to def_visit_all. Fixes
missing ud-chains for component-by-component assignments to temporary
vectors.
2023-06-05 09:42:33 +09:00
Bill Currie
8f6e145257 [qfcc] Don't add target def for store statements
Store statements dereference the pointer in target and thus don't modify
target itself.
2023-06-04 11:45:35 +09:00
Bill Currie
e2c1da9b6a [qfcc] Create du-chains from ud-chains
I'm not certain this is correct, but it seems to me that du-chains are
the same information as ud-chains, but from the defining statement's
point of view instead of that of the using statement.
2023-06-04 11:24:52 +09:00
Bill Currie
7149a092f6 [qfcc] Create ud-chains more aggressively
As certain statements (in particular, function calls) can use additional
variables via pointer parameters, it's necessary to iterate ud-chain
building until the count stabilizes. This should make live variable
analysis much easier.
2023-06-04 01:47:30 +09:00
Bill Currie
5d9823af30 [qfcc] Implement designated initializers
Conforms fairly closely to GCC's C implementation.
2023-05-27 12:47:33 +09:00
Bill Currie
09a3e257e8 [qfcc] Fully initialize local structural defs
I think the current build_element_chain implementation does a reasonable
job, but I'm in the process of getting designated initializers working,
thus it will become important to ensure uninitialized members get
initialized.
2023-05-26 21:56:19 +09:00
Bill Currie
d001473536 [qfcc] Make is_struct struct-only
And add is_union to handle unions. Sometimes it's necessary to check
between the two.
2023-05-25 21:23:27 +09:00
Bill Currie
6d5e8922a5 [qfcc] Add a handle type for engine resources
I never liked the various hacks I had come up with for representing
resource handles in Ruamoko. Structs with an int were awkward to test,
pointers and ints could be modified, etc etc. The new @handle keyword (@
used to keep handle free for use) works just like struct, union and
enum in syntax, but creates an opaque type suitable for a 32-bit handle.
The backing type is a function so v6 progs can use it without (all the
necessary opcodes exist) and no modifications were needed for
type-checking in binary expressions, but only assignment and comparisons
are supported, and (of course) nil. Tested using cbuf_t and QFile: seems
to work as desired.

I had considered 64-bit handles, but really, if more than 4G resource
objects are needed, I'm not sure QF can handle the game. However, that
limit is per resource manager, not total.
2023-05-25 10:41:28 +09:00
Bill Currie
7b6b25a751 [qfcc] Find variables referenced by function arguments
This takes advantage of the ud-chains to follow the trail of pointer
assignments looking for an address. This gets array element assignments
surviving across blocks when the array itself is passed to a function.
It doesn't help when the address of the element is taken though. I think
that's a dags problem and probably needs du-chains. Also, the ud-chain
creation should probably be done in two passes so the newly found
information can be recorded.
2023-05-21 22:11:46 +09:00
Bill Currie
a5943c8a3b [qfcc] Use statement use chain for v6 calls
Def and kill are still handled in flow_analyze_statement, but this makes
call meta data more consistent between v6 and ruamoko progs, allowing
the statement use chain to be used for call argument analysis. It even
found a bug in the extraction of param counts from the call instruction.
2023-05-21 10:23:03 +09:00
Bill Currie
208359edc6 [qfcc] Ensure all operands are cleared before flow
I had missed the flowvar clearing for auxiliary use/def/kill operands.
It's possible it wasn't necessary at the time since the operands were
added just for dealloc checking, but there's every reason it could
become necessary.
2023-05-20 13:54:40 +09:00
Bill Currie
b5a57cd15c [qfcc] Use assign_statement for v6p call arguments
I had written assign_statement a while after the call handling code and
didn't think to modify the call code. This makes for more consistent
code.
2023-05-20 13:52:24 +09:00
Bill Currie
9247ab91fd [qfcc] Calculate ud-chains
The first use will be pointer analysis for function arguments where the
argument points to an array to mark the array as live, but I'm sure
there'll be plenty of other uses.
2023-05-20 08:49:51 +09:00
Bill Currie
4b3b6d516a [qfcc] Use available functions for dealloc use/def
I had written those use/def sets before creating the functions, and it
turns out I had goofed slightly with the def chaining.
2023-05-19 19:41:34 +09:00
Bill Currie
0c116b8ff0 [qfcc] Record actual statements in a function
This is to help with building ud-chains as I suspect I won't be all that
interested in defs from the dummy blocks.
2023-05-19 17:50:19 +09:00
Bill Currie
74e15fc582 [qfcc] Show var use in flow vars 2023-05-19 17:48:47 +09:00
Bill Currie
95dd63cd68 [qfcc] Avoid defining whole def via alias
A partial write to a def should not define the whole def, thus
def_visit_all's overlap parameter now has a flag that prevents a visit
to the main def when accessing the def from an alias def. This prevents
a lot of spurious kills and defines in flow analysis.
2023-05-19 16:42:13 +09:00
Bill Currie
8d4602ec61 [qfcc] Fix indexed pointer vector indexing
The array access code was loading the vector, modifying the element,
then forgetting to write the modified vector back to whence it came.
However, that would be rather sub-optimal, so now when the vector is
accessed by a pointer, the array code switches to field access to get at
the vector element thus avoiding the need to copy the whole vector.
2023-05-17 01:09:31 +09:00
Bill Currie
0d78a865c6 [qfcc] Show flow vars and statements for reaching dot
A bunch of nodes with a pile of numbers doesn't mean much without the
context.
2023-05-15 11:08:23 +09:00
Bill Currie
7b7b2ef000 [qfcc] Add flow defs for parameters
Needed for proper analysis (ud-chains etc). Of course, it was then
necessary to remove the parameter defs from the uninitialized defs.

Also, plug a couple of memory leaks (forgot to free some temporary
sets).
2023-05-14 13:40:40 +09:00
Bill Currie
4435db0329 [qfcc] Support pointer arithmetic on arrays
That is, `array + offset`. This actually works around the bug
highlighted by arraylife.r (because the array is explicitly used), but
is not a proper solution, so that test still fails of course. However,
with this, it's no longer necessary to use `&array[index]` instead of
`array + index`.
2023-05-14 12:45:08 +09:00
Bill Currie
8e1883a306 [qfcc] Allow assignment of arrays to void pointers
I guess it just never came up until now.
2023-05-14 12:45:08 +09:00
Bill Currie
61d656881b [qfcc] Improve readability of flow vars in live
I could never remember what any of the numbers meant. While define is
still a little fuzzy (they're (pseudo)statement numbers), at least now
I'll always know that the numbers are the define set. Also, having the
flow address of the variable helps with understanding the reaching defs
output.
2023-05-14 12:45:08 +09:00
Bill Currie
904b211576 [qfcc] Fix some comment typos in the flow analyzer 2023-05-14 12:45:08 +09:00
Bill Currie
cee00c8243 [qfcc] Fix declarators for pointers/functions/arrays
I had messed up the handling of declarators for combinations of pointer,
function, and array: the pointer would get lost (and presumably arrays
of functions etc). I think I had gotten confused and thought things were
a tree rather than a simple list, but Holub set me straight once again
(I've never regretted getting that book). Once I understood that, it was
just a matter of finding all the places that needed to be fixed. Nicely,
most of the duplicated code has been refactored and should be easier to
debug in the future.
2023-03-09 02:22:23 +09:00
Bill Currie
45c0341daf [qfcc] Actually skip compile for -E etc
The preprocess-only option wasn't being checked enough.
2023-03-06 13:06:05 +09:00
Bill Currie
795021e229 [util] Record allocated blocs for ALLOC
Recording the blocks makes it possible to free them later. As a
convenience, ALLOC_STATE declares the freelist and blocks vars needed by
ALLOC.
2023-03-05 18:31:30 +09:00
Bill Currie
694c3ad5f5 [qfcc] Ensure params and arguments have unique flow addresses
This fixes the false-negative in the dealloc-warn4.r test (and thus what
I found in vkgen), and should stave off a few other issues.
2023-02-26 20:43:52 +09:00
Bill Currie
c16d0bae7b [qfcc] Fix handling of storage class {...} blocks
Another victim of the type system, but this one was due to the handling
of storage classes in general.
2023-02-14 12:45:04 +09:00
Bill Currie
3da7ca4421 [qfcc] Support qc function local variables
This had gotten completely lost in the rework.
2023-02-14 12:45:04 +09:00
Bill Currie
3a297c70b3 [qfcc] Handle qc function field parameters
The type system rewrite had lost some of the checks for function fields.
This puts the actual code in the one place and covers parameters as well
as globals.
2023-02-14 12:45:04 +09:00
Bill Currie
fa97074aff [qfcc] Update vector constant folding checks
Internally, * is not really a valid operator for vectors since it can
have many meanings. This didn't cause trouble until trying to build
everything in game-source (since there's still a lot of legacy code in
there).
2023-02-14 12:45:04 +09:00
Bill Currie
b7ad02c71d [qfcc] Use float for v6 comparisons
While simple types used floats, functions, vectors and entities used
ints. This doesn't go so well when compiling for v6 progs.
2023-02-14 12:45:04 +09:00
Bill Currie
67eb38173b [qfcc] Back out incorrect precedence check changes
The precedence check changes done in
63795e790b seem to have been incorrect
(game-source/ctf produced many false positives), so putting that check
against '=' back into the code seems like a good idea (no more false
positives). That sounds a bit cargo-cult, but I'm really not sure what I
was thinking when I did the changes (probably just tired).
2023-02-14 12:45:04 +09:00
Bill Currie
a2b5ebde65 [qfcc] Treat parameter shadowing as an error
This applies only to the top-level scope of the function. I'm not sure
if it's right for traditional quakec code, but that can be adjusted
easily enough.
2023-02-14 12:45:04 +09:00
Bill Currie
bc2204d446 [qfcc] Differentiate symtabs by intended use
The symtab code itself cares only about global/not global for the size
of the hash table, but other code can use the symtab type for various
checks (eg, parameter shadowing).
2023-02-14 12:45:04 +09:00
Bill Currie
fc7c96d208 [qfcc] Support C's full type system
Along with QuakeC's, of course. This fixes type typeredef2 test (a lot
of work for one little syntax error). Unfortunately, it came at the cost
of requiring `>>` in front of state expressions on C-style functions
(QuakeC-style functions are unaffected). Also, there are now two
shift/reduce conflicts with structs and unions (but these same conflicts
are in gcc 3.4).

This has highlighted the need for having the equivalent of the
expression tree for the declaration system as there are now several
hacks to deal with the separation of types and declarators. But that's a
job for another week.

The grammar constructs for declarations come from gcc 3.4's parser (I
think it's the last version of gcc that used bison. Also, 3.4 is still
GPL 2, so no chance of an issue there).
2023-02-14 12:45:04 +09:00