Commit graph

358 commits

Author SHA1 Message Date
Dale Weiler
783b7b6594 Update license headers 2015-01-09 14:53:35 -05:00
Wolfgang Bumiller
8b25e95553 we like to spell things properly - if this commit message contains a typo I don't catch before pushing then that's totally intentional 2014-10-18 14:27:16 +02:00
Dale Weiler
53e9ed0d96 Merge branch 'arithmetic_exceptions' into cooking
Conflicts:
	doc/gmqcc.1
	gmqcc.ini.example
	opts.def
	parser.c
2014-05-25 03:01:47 -04:00
Dale Weiler
6424ebaf98 Perliminary work on arithmetic exception handling in the constant evaluator. We can safely check for arithmetic underflow, overflow, divison by zero and inexactness now. Inexactness of expressions are propagated through the AST such that using an inexact value in a comparison will trigger a warning with -Winexact-compares. 2014-05-24 09:53:38 -04:00
Wolfgang Bumiller
8dafdfc5e2 use INSTR_STATE by default, add -femulate-state to switch to emulation, and -state-fps=NUM to set its emulation FPS 2014-04-08 14:34:55 +02:00
Wolfgang Bumiller
4ff68e07e8 Adding coverage support:
The -coverage option causes all values have AST_FLAG_BLOCK_COVERAGE
set by default.
The coverage attribute can be used to control coverage:
It takes an optional list of coverage types, currently only "block"
and "none" is recognized.
[[coverage]] defaults to [[coverage(block)]].
Use [[coverage(none)]] or [[coverage()]] to disable.
2014-01-07 14:36:00 +01:00
Dale Weiler
a934e0fe4b Happy new year! 2014-01-01 06:24:16 -05:00
Dale Weiler
58cd326d85 Only optimize (a - (-b)) into (a + b) when the unary operand is a negation. This fixes (a - (!b)) being turned into (a + b). 2013-12-08 19:01:44 -05:00
Dale Weiler
ac7e1a557d Fixes 2013-11-29 13:36:35 -05:00
Wolfgang Bumiller
c3cc6f184e static variables now don't get re-initialized in functions; cannot be initialized with non-constants anymore; and a counter has been added so you can use the same name in a different scope for another static variable again. 2013-11-28 12:04:01 +01:00
Dale Weiler
87a43777ab strength reduct (a - (-b)) into (a + b) 2013-11-23 13:13:21 -05:00
Wolfgang Bumiller
065a870e7a build again 2013-10-23 14:04:20 +02:00
Wolfgang Bumiller
b87eb89853 This is not allowed 2013-10-23 14:01:56 +02:00
Wolfgang Bumiller
8d5e719026 replacing the current [[accumulate]] implementation: shorter and simpler, and also supports non-void return types 2013-10-18 11:26:41 +02:00
Dale Weiler
97217b55d1 Ignore generating a return instruction in accumulated functions, eventually we'll have a way to merge these into one function but for now the RETURN is a waste. 2013-10-17 04:45:24 -04:00
Dale Weiler
2c975bb344 Implemented [[accumulate]] attribute. This will hopefully be used by Xonotic to replace it's ACCUMULATE_FUNCTION stuff. 2013-10-17 03:21:30 -04:00
Dale Weiler
c8413a9a04 Clang is so anal 2013-10-14 21:03:24 -04:00
Dale Weiler
8e8b3608fb Cleanups 2013-10-14 20:58:36 -04:00
Dale Weiler
a02e44100e Fix some things: get all the Quake mods to compile again (I broke binary expressions .. oops) Fix the check-proj script, using $? for status was invalid because of pipes. The ir now properly considers negation virtual instruction to be operations (as it should). 2013-10-05 23:36:48 -04:00
Dale Weiler
ffdd6df828 Only when peephole optimization is on 2013-10-04 07:02:06 -04:00
Dale Weiler
2cf5046d38 Handle proper expression type assignment 2013-10-04 06:53:09 -04:00
Dale Weiler
cc69370575 Another peephole optimization which removes superfluous expressions such as (A + 0), (A - 0), (A * 1) and (A / 1). 2013-10-04 06:46:54 -04:00
Dale Weiler
b6f08e7fb1 Fix negation type for VINSTR_NEG_V. Source operand for optimization instead of the expression (to handle double negation elision properly.) 2013-09-30 14:32:21 -04:00
Dale Weiler
03b56bd41f Handle double negation case specially. Update TODO 2013-09-30 05:12:28 -04:00
Dale Weiler
b10de1b240 Make unary - operator act as an ast_unary node. This allows for consistency (no sense in making unary use binstore nodes, it doesn't make much sense). It also allows for the peephole optimization on unary chains that cancel each other to take place; i.e code like "-(-a)" simplifies to "a", thus eliminating instructions. 2013-09-29 22:01:46 -04:00
Dale Weiler
3c931ecbf1 Eh, only if peephole optimizations are turned on. 2013-09-28 06:41:40 -04:00
Dale Weiler
c6056d441b Less casts. 2013-09-28 06:36:00 -04:00
Dale Weiler
7c25af973c It was much easier in the AST, really. 2013-09-28 06:33:15 -04:00
Dale Weiler
15b0555546 Implement constant folding on ternary operations via fold_cond. 2013-09-26 06:51:49 -04:00
Wolfgang Bumiller
4600f1d7ff more thorough check for whether an ast node starts a new label; closes #121 2013-08-31 10:48:24 +02:00
Dale Weiler
a7c1f6f021 Implement [[eraseable]] attribute. When used with a function it instructs the AST (which than transfers logic to the IR) that the function (or variable) is potentially unused (verified by checking the read count). This than propogates through the IR and prevents the IR from generating both the definition and global/function. The intrinsics system uses this as well to prevent intrinsic functions from being generated unless they're used. 2013-08-29 00:05:37 -04:00
Dale Weiler
3b4a5667ea Constant fold intrinsics if their arguments are constant. TODO: reference count intrinsics such that they're not generated unless they're used, currently when an intrinsic can be folded-away it's marked for generation and makes it to the final output binary even though it isn't used. 2013-08-28 12:46:22 -04:00
Wolfgang Bumiller
988b4b4960 ast_binary->right_first and an execution order check 2013-08-27 10:42:13 +02:00
Wolfgang Bumiller
b26f53125d error on uninitialized arrays of unspecified size; otherwise it errors about a size overflow 2013-08-27 10:19:05 +02:00
Wolfgang Bumiller
844e84fc16 bail out when encountering an invalid array size in the ast as it's likely to cause breakage when trying to generate them anyway 2013-08-27 10:09:31 +02:00
Dale Weiler
c64005966f Remove some trailing whitespace 2013-08-17 23:43:41 +00:00
Dale Weiler
24fc2e5146 Fix that typecast 2013-07-31 19:36:09 +00:00
Dale Weiler
10b75fd8b9 Move const-branch-elision into fold.c 2013-07-31 19:34:38 +00:00
Dale Weiler
d8b931fbcf Experimental/Initial try at in-ast constant folding. (for TYPE_FLOAT currently .. since comparisions on UTF8 strings need to be worked out yet ..) 2013-07-30 18:06:42 +00:00
Dale Weiler
d6ca5673dc Use the _t consistency naming scheme. Also various cleanups. 2013-07-30 16:00:51 +00:00
Dale Weiler
c8c25ef6f7 Some cleanups and smaller binaries! 2013-07-28 00:23:15 +00:00
Dale Weiler
c7679722fb Please the whitespace gods 2013-07-27 11:48:55 +00:00
Dale Weiler
bbffdde2dc Fix some bugs and a memleak in the testsuite. 2013-06-22 01:56:22 +00:00
Dale Weiler
063c50fce4 More bug fixes and dead code elimination 2013-06-22 01:23:59 +00:00
Dale Weiler
ce23e95d0b Remove a ton of dead code and document the one really insane case. 2013-06-21 23:40:51 +00:00
Dale Weiler
fe296de42f Fix more bugs (mostly possible NULL pointer dereferences) 2013-06-21 23:26:49 +00:00
Dale Weiler
996d998ebb Fix possible NULL pointer dereference 2013-06-21 23:21:12 +00:00
Wolfgang Bumiller
290d065a79 again with the comments... 2013-06-15 09:49:15 +02:00
Wolfgang Bumiller
3fab06941a fix a call typecheck issue 2013-06-15 09:46:44 +02:00
Wolfgang Bumiller
179da9241c working on vararg piping: detecting several error cases, adding -Wunsafe-types and -funsafe-varargs 2013-06-15 09:46:44 +02:00