Commit graph

3034 commits

Author SHA1 Message Date
Dale Weiler
71138cbe1a rewrite dead code elimination for conditionals 2021-03-27 20:32:24 -04:00
Dale Weiler
85c79d2f1c fclose when fopen actually succeeds 2021-03-26 19:02:27 -04:00
Dale Weiler
13bcb5c5b1 set m_op as well when doing a-(-b) => a+b peephole 2021-03-26 18:57:31 -04:00
Dale Weiler
465941f357 pass parent scope to parse_statement_or_block
previous behavior when parsing a statement where a block is typically expected would fail to associate the statement with the parent block it's in, resulting in variable declarations ending up in global scope.

this fixes #197
2021-03-02 10:46:05 -05:00
Dale Weiler
237722c0b2 fix crash when cleaning up functions related to [[accumulate]] 2020-10-27 19:40:30 -04:00
Dale Weiler
f971f89e1e new makefile 2020-04-17 13:28:27 -04:00
Wolfgang Bumiller
94c2936bfa tests: xor peephole optimization regression test
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2019-09-15 10:27:26 +02:00
Wolfgang Bumiller
2d4a054440 ir: fix generation of multi-op vinstrs
Do not assume that the destination is a temporary location,
as our peephole optimizer will break this. For example, the
following IR code (generated via from `x ^= gety()`):

    (0) binst6 <- BITXOR   x,      call5
    (0) x <- STORE_F       binst6

after peephole optimization becomes:

    (7) x <- BITXOR        x,      call5

Therefore we cannot assume that the output of the virtual
xor instruction can be utilized as a temporary value.

BITXOR becomes `(x | y) - (x & y)`, which would wrongly be
generated as:
    x = x | y;
    temp0 = x & y;
    x = x - temp0;

While this particular case can be fixed by using temp0 first
and then x, the cross-product case would not be so simple.

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
Fixes #190
2019-09-15 10:23:47 +02:00
Wolfgang Bumiller
031f827da5 introduce another vinstr temp
Some vinstrs are currently broken when using peephole
optimization as they appear as writing to a temporary ssa
output before being stored into their real destination,
causing the store to be optimized out, but the generated
code relies on having the destination as another temporary
value available.

Let's just add a 2nd temp to be used in those cases.

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2019-09-15 10:12:40 +02:00
Dale Weiler
451873ae52
Merge pull request #187 from divVerent/patch-1
Fix printing of floating poing values in -dumpfin.
2019-02-04 09:20:23 -05:00
divVerent
9c81ff263a
Fix printing of floating poing values in -dumpfin.
%g is not lossless for single precision floats - %.9g is (other than distinguishing NaNs, who cares).
2019-02-04 06:14:58 -08:00
Dale Weiler
620bd76e76 fix __builtin_nan and add some missing builtins 2018-11-14 08:43:22 -05:00
Dale Weiler
2d99ce609d fix octals 2018-10-30 17:32:21 -04:00
Dale Weiler
0904a1ceb7 fixes for progs.src 2018-09-01 00:48:18 -04:00
Dale Weiler
c74fabffda Merge branch 'master' of github.com:graphitemaster/gmqcc 2018-05-09 21:19:39 -04:00
Dale Weiler
092067482f added -fdefault-eraseable which is the same as adding [[eraseable]] to all definitions
instead the opposite behavior can be controlled with [[noerase]] attribute
2018-05-09 21:18:37 -04:00
Dale Weiler
dac058107a
Delete .travis.yml 2018-05-05 15:44:21 -04:00
Dale Weiler
9a21c638fa error if a function is called from global scope opposed to crashing 2018-05-05 15:38:12 -04:00
Wolfgang Bumiller
97a74eb677 catch broken vector member access
These kinds of expressions currently cannot be handled
without pionter support in the qcvm without scanning the
ast from within ast_member::codegen for an assignments as
seen in the added test case.

This change makes code like that return a pointer type which
will cause an error that we did not get a vector or field
back. With pointer support this pointer could actually be
used instead.

So at least it shouldn't silently produce broken code
anymore.

Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2018-01-14 10:58:29 +01:00
Wolfgang Bumiller
f84c8ea629 add variable search order test
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2018-01-14 09:33:05 +01:00
Wolfgang Bumiller
e920766b10 Make parser_find_local only actually search locals
Fixes #163
Signed-off-by: Wolfgang Bumiller <wry.git@bumiller.com>
2018-01-14 09:33:05 +01:00
Wolfgang Bumiller
e006aa8238 Revert "search for funciton param first before function locals, this fixes #163"
This reverts commit 3cf2c52fce.
2018-01-14 09:33:05 +01:00
Dale Weiler
73d3d7eec1 fix some UB 2017-12-01 13:55:19 -05:00
Dale Weiler
3cf2c52fce search for funciton param first before function locals, this fixes #163 2017-12-01 12:24:50 -05:00
Dale Weiler
1580c23556 Merge branch 'master' of github.com:graphitemaster/gmqcc 2017-11-26 17:48:13 -05:00
Dale Weiler
b14a02e735 don't generate storep for vector field unless it's an ent field 2017-11-26 17:47:27 -05:00
Dale Weiler
679e3771de
Merge pull request #177 from xonotic/terencehill/warning_removal
Get rid of a warning on Windows
2017-11-26 17:30:42 -05:00
Dale Weiler
d9127bf28a
Merge pull request #180 from xonotic/mem_leak_fix_on_failure_paths
two small memory leak fixes on failure paths
2017-11-26 17:30:30 -05:00
Dale Weiler
fa7dce495b fix writing of globaldefs for vector subcomponents so that FTE field remapping works 2017-11-26 17:26:00 -05:00
Dale Weiler
02b20dbd09 fix member binops on entity fields to generate STOREP, this fixes stuff like ent.vec.x += value. 2017-11-26 17:09:38 -05:00
Wolfgang Bumiller
6ad5f18ef1 cleanup: 'move of a temporary object prevents copy elision' 2017-07-23 10:11:31 +02:00
Wolfgang Bumiller
047ecd426f move more parser code to c++, fix crashes with gcc
we initialized the parser with malloc -> memset to zero ->
placement new. With gcc the latter caused the memset to be
optimized out, causing uninitialized value accesses.
2017-07-23 10:11:31 +02:00
Wolfgang Bumiller
fb3af2831b cleanup some silly more warnings 2017-07-23 10:11:31 +02:00
Wolfgang Bumiller
5a0d645ede cleanup: silence fallthrough warnings 2017-07-23 10:11:31 +02:00
terencehill
27c0886ffb Get rid of a warning on Windows 2017-06-23 16:21:22 +02:00
Wolfgang Bumiller
163c4b99a4 tests: add check for vector negation 2017-06-22 08:45:38 +02:00
Wolfgang Bumiller
eb2d478770 qcvm: add stov builtin #16 2017-06-22 08:45:18 +02:00
Wolfgang Bumiller
3f5305af58 ir: fix vector negation using the nil value
We cannot use OFS_NULL as it is only a single value and
overlaps with OFS_RETURN.
2017-06-22 08:44:36 +02:00
David Carlier
8538658e83 two small memory leak fixes on failure paths 2017-05-23 21:56:03 +01:00
Wolfgang Bumiller
8b2149e315 sanitize: shift 1u (unsigned) for flag bits 2017-02-14 19:24:04 +01:00
Wolfgang Bumiller
c285eb385d c++: exec.cpp 2017-02-11 11:43:58 +01:00
Wolfgang Bumiller
2dde6d903e c++: ir_function::m_params 2016-12-03 21:42:15 +01:00
Wolfgang Bumiller
4bf63bb379 c++: ir: function_allocator 2016-12-03 21:39:09 +01:00
Wolfgang Bumiller
95d232ca72 c++: ir_block::m_instr 2016-12-03 21:30:33 +01:00
Wolfgang Bumiller
90f190f5e1 c++: ir_block::m_exits 2016-12-03 20:34:42 +01:00
Wolfgang Bumiller
566c17a964 c++: ir_block::m_entries 2016-12-03 20:32:26 +01:00
Dale Weiler
a5636899f2 Cleaner way to set the mask for -Wunused-component 2016-11-24 19:54:17 +00:00
Dale Weiler
17c0812ae4 Just mark LOCAL_RETURN noref instead of checking for '#' in the name 2016-11-24 15:50:48 +00:00
Dale Weiler
3a7848d67c Remove parser m_uses in favor of {IR,AST}_FLAG_NOREF instead 2016-11-24 15:33:58 +00:00
Dale Weiler
def1a26b12 Add -Wunused-component like -Wunused-variable but warns about unused components of vector 2016-11-24 14:52:57 +00:00