Commit graph

4278 commits

Author SHA1 Message Date
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
Bill Currie
4028590240 [qfbsp] Add an option to extract models to C
Probably not a good idea for large maps, but handy for generating C
structs for small test maps. Does not include vertices or surfaces, just
the bsp tree itself for now.
2023-08-15 17:20:45 +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
9f8a6f5d62 [qfvis] Initialize set pool arrays
The relatively recent changes to ALLOC missed the set pools used in fat
pvs calculations.
2023-07-18 11:27:06 +09:00
Bill Currie
55705dac83 [qfcc] Only compile in the compile-only tests
The source tree is made read-only by `make distcheck`, so writing
temporary files to the source directory is a no-no (really, it's a bit
of a bug in qfcc, as per #51).
2023-07-10 11:04:17 +09:00
Bill Currie
fdeb294c58 [qfcc] Update ptraliasenc test for new format
With the use of the full type for encoding type aliases, ptraliasenc's
simple check became invalid (it's purpose is to ensure the encoding
doesn't have "null" in it, not the exact encoding itself, but this is
good enough).
2023-06-30 02:45:49 +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
dc61d15340 [qfcc] Add failing test for array-typedef interaction
Two variables declared as arrays (same size) of different typedefs to
the same base type have their type encodings both pointing to the same
short alias.

From vkgen:

    51d3  ty_array  [4={int32_t>i}]      207f  0 4
    51d9  ty_array  [4=i]                1035  0 4
    51df  ty_alias  {>[4=i]}              16  51d9  51e6
    51e6  ty_array  [4={uint32_t>i}]     2063  0 4
    51ec  ty_union  {tag VkClearColorValue-} tag VkClearColorValue
	    4ca0     0 float32
	    51df     0 int32
	    51df     0 uint32

uint32 should use 51e6 and int32 should use 513d,
2023-06-30 02:39:51 +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
9d1c07d2ac Fix a few strict aliasing warnings
gcc 13 got a little stricter on those (at least with gnu2x/c2x).
2023-06-13 18:13:54 +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
a5ed154cfe [qfcc] Add a second failing array lifetime test
This one covers regular array references across function call.
2023-06-05 10:58:02 +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
ce6b27cfae [qfcc] Add failing test for array life
It seems that the optimizer keeps array assignments live when passing
the array as a pointer, but not when passing the address of an element.
Found when testing the following code:

    BasisBlade *pga_blades[16] = {
        blades[1],  blades[2],  blades[3],  blades[4],
        blades[7],  blades[6],  blades[5],  blades[0],
        blades[8],  blades[9],  blades[10], blades[15],
        blades[14], blades[13], blades[12], blades[11],
    };
    BasisGroup *pga_groups[4] = {
        [BasisGroup new:4 basis:&pga_blades[ 0]],
        [BasisGroup new:4 basis:&pga_blades[ 4]],
        [BasisGroup new:4 basis:&pga_blades[ 8]],
        [BasisGroup new:4 basis:&pga_blades[12]],
    };

Only the first element of pga_blades is being assigned in the optimized
code, but everything is correct when not optimizing.
2023-05-14 12:45:08 +09:00
Bill Currie
a8efde1dd3 Fix some mxe build issues 2023-03-25 21:36:45 +09:00
Bill Currie
ef2793010c [simd] Improve portability for aarch64
No need for compiler flags for 64-bit arm, and the few intrinsics that
are actually needed are in a different header.
2023-03-25 21:21:13 +09:00
Bill Currie
7d4c1d79b1 [plist] Use reference counts for items
This makes it much easier to share items between property lists (eg,
targets and the main entity list in cl_light).
2023-03-13 11:26:13 +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
549ffcd534 [qfcc] Add failing test for function/array pointers
It turns out I broke the type system when it comes to pointers to
functions and arrays. This test checks basic function and array pointers
and passes with qfcc from before the type system rework.
2023-03-07 13:17:46 +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
e2640d51a7 [gl_stub] Make some gen functions generate indices
This makes gl_stub usable with valgrind (otherwise, the returned indices
are uninitialized).
2023-03-05 18:31:30 +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
b103709bfd [qfcc] Fix incorrect build error in dealloc-warn2
It was dying due to an undefined symbol rather than the warning.
2023-02-26 20:09:21 +09:00
Bill Currie
e07f25e10f [qfcc] Add failing test for super dealloc
While working on vkgen, I found a dealloc that wasn't calling [super
dealloc] but qfcc hadn't noticed it.
2023-02-26 20:08:56 +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
Bill Currie
02432311c5 [qfcc] Add a function to print the source line
It's not used anywhere, but it saves me a lot of grief when debugging.
2023-02-14 12:45:04 +09:00
Bill Currie
35f4f2e692 [qfcc] Move basic specifier creation into qc-lex
This simplifies type type_specifier rule significantly as now TYPE_SPEC
(was TYPE) includes all types and their basic modifiers (long, short,
signed, unsigned). This should allow me to make the type system closer
to gcc's (as of 3.4 as that seems to be the last version that used a
bison parser) and thus fix typeredef2.
2023-02-14 12:45:04 +09:00
Bill Currie
5f22a322df [qfcc] Allow redefined typedefs if the same type
This fixes typeredef1, and will allow typeredef2 to pass once the
grammar is sorted out.
2023-02-14 12:45:04 +09:00
Bill Currie
e974e9d758 [qfcc] Add some failing typedef redef tests
typeredef1 parses properly but fails due to it erroneously complaining
that foo is redeclared as a different kind of object (it's the same
kind).

typeredef2 is the real problem in that it's a syntax error when it
should not be. This has proven to be a show-stopper for development on
my laptop as it has very recent vulkan headers which have such a
duplicate typedef.
2023-02-14 12:45:04 +09:00
Bill Currie
490217a136 [qfcc] Ensure non-unicode char string is terminated
Once a unicode char (ie, > 127) was used, any ascii chars would get the
tail of the last unicode char resulting in broken utf-8 streams. The
resulting null glyph boxes were not very appealing.
2022-12-10 21:53:45 +09:00
Bill Currie
6fc2dcae20 [qfprogs] Dump hex for non-ascii chars
More useful when dealing with non-quake text (especially broken utf-8
strings).
2022-12-10 21:53:00 +09:00
Bill Currie
99b568c208 [build] Fix distcheck once again
Probably the hardest part of QF to maintain.
2022-12-02 17:10:04 +09:00
Bill Currie
1cada2c931 [qfvis] Remove (mostly) unnecessary vector normalization
Because of the way the plane normal is used (front/on/back checks, and
midpoint calculation), other than possible precision, there is no need
to normalize the normal. Removing the square root and division resulted
in a huge boost: from 34s to 14 seconds. The average clusters visible
hasn't change much, and a quick check in-game didn't show any issues.
2022-11-19 23:16:47 +09:00