Commit Graph

4156 Commits

Author SHA1 Message Date
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
Bill Currie d283f07890 [qfvis] Replace modulo and SISD cross-product
At least modern gcc produces nice code for ?: (cmov), and a SIMD
cross-product uses several fewer instructions. The cross-product shaved
off 0.5-1s, but the modulo -> ?: shaved off about 3-4s, for a total of
about 10% speedup (1.09 insn/cyc vs 1.01 insn/cyc, so even perf agrees).
2022-11-19 20:49:13 +09:00
Bill Currie de2cc21c7e [qfcc] Add basic support for (u)long expressions
It's woefully incomplete, but sufficient to test initializing
non-scalars from ivec constants.

Fixes #36
2022-11-16 20:48:58 +09:00
Bill Currie 23469029ca [qfcc] Support converting non-scalar values
This fixes the basic vecconst test (extending it to other types breaks
because long and ulong are not properly supported yet). The conversion
is done by the progs VM rather than writing another 256 conversions
(though loops could be used). This works nicely as a test for using the
VM to help with compiling.
2022-11-16 19:44:40 +09:00
Bill Currie e1d7854af5 [qfcc] Rename G_* macros to Q_*
They clash with those in progs.h, which is needed for using progs code
in the compiler.
2022-11-16 17:53:21 +09:00
Bill Currie ce64baa92d [qfcc] Add failing test for vector constant init
Raw 'x y z' style vector constants that look like ints (no fractional
parts) used to initialize vector globals/constants don't get converted
to float vectors, resulting in nans for negative values and denormals
for positive values. This tends to make game physics... interesting.
2022-11-16 11:25:27 +09:00
Bill Currie f323401c10 [qfcc] Add an explicit hadamard operator
While the option to make '*' mean dot product for vectors is important,
it breaks vector scaling in ruamoko progs as the resultant vector op
becomes a dot product instead of the indented hadamard product (ie,
component-wise).
2022-11-16 00:06:21 +09:00
Bill Currie 5b202a1733 [qfcc] Skip over aliases when checking for blocks
This fixes the double call to [super init] as tested by ifsuper.r.
2022-11-13 04:15:26 +09:00
Bill Currie 76740d213e [qfcc] Add link from jump expression to destination
Having a dangling jump with no destination in my dot output wasn't very
informative.
2022-11-12 22:16:57 +09:00
Bill Currie bfda4e776f [qfcc] Add a failing test case for if-super calls
The common idiom for self init (below) causes a double-call when
compiling with --advanced, resulting in an incorrect retain count.

    if (!(self = [super init])) {
	return nil;
    }
2022-11-12 20:07:30 +09:00
Bill Currie 2d3c2da64d [qfcc] Support advanced progs again
The support for the new vector types broke compiling code using
--advanced. Thus it's necessary to ensure vector constants are
float-type and vec3 and vec4 are treated as vector and quaternion, which
meant resurrecting the old vector expression code for v6p progs.
2022-11-12 20:04:19 +09:00
Bill Currie 71af297a52 [qfcc] Support extend expressions in dot_expr 2022-11-12 18:51:08 +09:00
Bill Currie ea781c9dcc [qfmap] Fix some blender bit-rot. 2022-09-22 09:35:56 +09:00
Bill Currie 6e8a3b8153 [qfmap] Parse field info from quaked comments
Id's comments are a little inconsistent, but for the most part usable
info can be extracted. While not yet supported, Arcane Dimensions'
comments are extremely consistent (just some issues with hyphen counts
in separators), so parsing out usable info will be fairly easy. The hard
part will be presenting it.
2022-09-22 09:35:56 +09:00
Bill Currie 1fa202608e [qfcc] Don't free duplicate method when merging
The method is still held by known_methods, so freeing it causes grief.
However, it may cause a leak thus the free is only commented out. More
investigation is needed. I'm surprised the problem didn't show on linux,
but cygwin-native hit it and valgrind on linux found the spot :)
2022-09-19 16:39:25 +01:00
Bill Currie 08328f4076 Fix some cygwin portability issues
Cygwin's headers seem to be rather out of date with respect to linux
with regards to signed types, especially ctype.
2022-09-19 16:31:08 +01:00
Bill Currie feba790348 [qfcc] Use _algined_free when using _aligned_malloc
Windows requires the two to be paired. I think this is the first time I
really tested windows qfcc on windows.
2022-09-19 13:37:08 +01:00
Bill Currie 6d64195a7b [qfcc] Fix incorrect progs source path handling
The cvar rewrite changed how to deal with cvar setting in code and I
messed it up for qfprogs.
2022-09-14 22:10:11 +09:00
Bill Currie 3c797e15e6 [qfcc] Use PR_Debug_ValueString when dumping globals
While it does get a bit cluttered currently, being able to see the
contents of structures makes a huge difference. Also highlights that
vector immediates do not get the correct type encodings.
2022-09-14 19:26:17 +09:00
Bill Currie a8a8c567a2 [qfcc] Promote types before expanding scalars
This fixes the internal error generated by the likes of
`(sv_gravity * '0 0 1')` where sv_gravity is a float and `'0 0 1'` is an
ivec3: the vector is promoted to vec3 first so that expanding sv_gravity
is expanded to vec3 instead of ivec3 (which is not permitted for a
float: expansion requires the destination base type to be the same as
the source).
2022-09-14 14:43:31 +09:00
Bill Currie 5747ddb77f [qfcc] Skip recording defs for binary expressions
For now, anyway, as the generated code looks good. There might be
problems with actual pointer expressions, but it allows entity.field to
work as expected rather than generate an ICE.
2022-09-14 14:43:31 +09:00
Bill Currie 5ae782bf89 [qfcc] Add support for \uXXXX and \UXXXXXXXX
The resultant unicode is encoded as utf-8, which does conflict with the
quake character map, but right now unicode is useful only with font
text, and those support only standard unicode (currently only as utf-8),
but something will need to be sorted out.
2022-09-09 14:48:03 +09:00
Bill Currie 53d86e2a53 [qfcc] Don't check parameter size for arrays
Arrays are passed as a pointer to the first element, so are always valid
parameters. Fixes a bogus "formal parameter N is too large to be passed
by value" error.
2022-09-09 14:48:03 +09:00