Commit Graph

190 Commits

Author SHA1 Message Date
Irmen de Jong
101b33c381 split intermediate representation into separate module 2022-09-13 23:06:05 +02:00
Irmen de Jong
18790d867c optimize conditional expression WORD & $ff00 to just msb(WORD)&$ff 2022-08-12 00:21:44 +02:00
Irmen de Jong
4d840c7db8 optimized mkword(0, X) 2022-08-11 22:51:09 +02:00
Irmen de Jong
4d2b21816d optimized uword <<8 and >>8 2022-08-11 22:25:15 +02:00
Irmen de Jong
68abda1219 fix a few small compiler errors (removing functioncall, removing block, assigning virtual register return value) 2022-08-09 23:38:29 +02:00
Irmen de Jong
93ce74eeb1 removed problematic expression "simplifications" (that introduced arbitrary r9 temp register usage) 2022-08-07 12:26:11 +02:00
Irmen de Jong
4644c9b621 got rid of GoSub ast node and codegen complexity related to that.
sometimes programs get smaller, sometimes bigger.
2022-08-07 03:24:20 +02:00
Irmen de Jong
046dceb5c2 added optimized case for signed division by 2 2022-07-24 13:59:35 +02:00
Irmen de Jong
dcc1f00048 fix rounding errors in signed divide by power-of-two
The optimized bit-shifting division is removed (for now)
2022-07-24 12:34:55 +02:00
Irmen de Jong
35af53828a fix endless loop in optimizer, fix cx16 register clobbering in psg interrupt handler, fix crash on certain arrays, fix undefined symbol when it's in another imported module 2022-07-13 18:42:06 +02:00
Irmen de Jong
68da661edc optimize comparison to true/1 into comparison to zero, optimize while/until conditions 2022-07-11 16:42:52 +02:00
Irmen de Jong
bdb7de34be added several compiler checks against weird boolean type use in expressions 2022-07-07 22:23:56 +02:00
Irmen de Jong
41f4e22a17 introduce BOOL type 2022-07-07 22:23:56 +02:00
Irmen de Jong
7fff4f249d optimize msb(cx16.r0) -> cx16.r0H, lsb(cx16.r0) -> cx16.r0L 2022-07-02 21:38:22 +02:00
Irmen de Jong
25aad8d7be improve const-evaluation of builtin expressions 2022-07-02 16:29:01 +02:00
Irmen de Jong
965340ff90 logical and/or/xor/not all replaced by bitwise &,|,^,~ (ast, codegens)
this also fixed some invalid outcomes of logical expressions!
2022-07-02 00:38:17 +02:00
Irmen de Jong
97cb0cbd08 tweak "not" removal/rewriting 2022-06-30 02:16:30 +02:00
Irmen de Jong
4b358abbb7 "not" operator removed from ast and codegen (it's been replaced with x==0 as equivalent) 2022-06-29 01:13:08 +02:00
Irmen de Jong
435d6f6f3f vm: and/or/xor/not are all bitwise operations again 2022-06-28 03:17:51 +02:00
Irmen de Jong
775c85fc18 don't swap operands that would change function evaluation order + vm: fix label casing error 2022-06-13 00:25:45 +02:00
Irmen de Jong
5a756aaed9 Pipe expression "|>" removed from the language 2022-06-12 18:41:42 +02:00
Irmen de Jong
dca092fd7c fix pipe expression when start term is constant number 2022-06-12 16:59:28 +02:00
Irmen de Jong
c6e92ecac4 some code cleanup 2022-06-12 16:15:08 +02:00
Irmen de Jong
f7183e38ee tweak trivial subroutine inlining 2022-06-08 21:05:03 +02:00
Irmen de Jong
46ca0ac10d properly optimize X - -1 and X + -1, this also fixes type change of ubyte - 2 + 10 2022-06-05 15:35:29 +02:00
Irmen de Jong
7f69517fd4 preparing optimizing pointer indexing 2022-06-04 16:18:27 +02:00
Irmen de Jong
ba614801ee cleanup 2022-05-22 23:11:22 +02:00
Irmen de Jong
fd6eb47e68 added inlining certain trivial non-asm subroutine calls 2022-05-22 20:22:09 +02:00
Irmen de Jong
627aa61184 clean up subroutine inlining, basis for new try 2022-05-09 15:42:58 +02:00
Irmen de Jong
942c5cc04b fix crash when optimizing pipe expression too aggressively 2022-05-07 17:29:36 +02:00
Irmen de Jong
348b3036ff now correctly accepts "xxx" * constexpr (where constexpr is not just a single const number) 2022-05-05 23:21:20 +02:00
Irmen de Jong
220246278a removed sum(), max(), min(). abs() now always returns uword type.
This greatly simplifies internal handling of builtin functions by always having one fixed return type.
2022-04-14 00:21:16 +02:00
Irmen de Jong
207a7e5160 move operator lists 2022-04-10 13:24:17 +02:00
Irmen de Jong
036d9dbe59 got rid of unnecessary cast of boolean expressions by making their type dynamically adjust to byte or word 2022-04-04 23:43:55 +02:00
Irmen de Jong
ae45ce517e cleanups 2022-04-03 17:33:50 +02:00
Irmen de Jong
30cbb6c9a8 implementing more of the vm 2022-03-27 21:59:46 +02:00
Irmen de Jong
ed30108961 removed '**' power-operator. Use floats.pow() instead. 2022-03-27 13:16:34 +02:00
Irmen de Jong
7b27d270a2 gosub only uses an identifier 2022-03-22 20:53:06 +01:00
Irmen de Jong
97b3a0b093 don't use the temp-variables introducing optimizations for the vm target 2022-03-22 20:21:32 +01:00
Irmen de Jong
ff57c5e9d3 working on vm and new ast 2022-03-21 01:36:11 +01:00
Irmen de Jong
3961f26635 consolidating modules 2022-03-11 20:45:39 +01:00
Irmen de Jong
e51c274a18 reducing dependencies 2022-03-11 20:32:35 +01:00
Irmen de Jong
e75d0c58a9 reducing dependencies 2022-03-10 23:46:43 +01:00
Irmen de Jong
9a798360f4 introduced codeAst and codeCore modules to reduce dependencies 2022-03-10 22:38:16 +01:00
Irmen de Jong
251b6fcf70 reducing dependencies 2022-03-10 02:09:34 +01:00
Irmen de Jong
ab1fffb721 reducing dependencies 2022-03-10 01:41:42 +01:00
Irmen de Jong
fc1c3c6808 working on altered pipe syntax 2022-03-02 20:58:38 +01:00
Irmen de Jong
96ba895b84 working on altered Pipe syntax 2022-02-27 02:42:28 +01:00
Irmen de Jong
064a8e785c cleanups 2022-02-21 03:26:17 +01:00
Irmen de Jong
60b2c44a44 fix returntype handling of builtinfunctions, fix errors in pipe expressions 2022-02-21 01:44:29 +01:00
Irmen de Jong
c4fe3ecc0a refactor 2022-02-20 22:04:18 +01:00
Irmen de Jong
0a43eae184 rework registerArgsViaStackEvaluation to use cpu hardware stack instead 2022-02-18 22:38:00 +01:00
Irmen de Jong
3117e2b2a3 more tweaks 2022-02-18 01:25:08 +01:00
Irmen de Jong
41fece4643 slight tweaks related to builtin functions in the ast 2022-02-17 01:25:13 +01:00
Irmen de Jong
7aa807ec7f proper error if attempting to do a containment check against non const range, and some cleanup in asmgen 2022-02-16 00:39:19 +01:00
Irmen de Jong
b47fc1c020 renames of some Ast node classes 2022-02-11 00:34:36 +01:00
Irmen de Jong
bd0dee5db5 cleanup 2022-02-10 22:22:50 +01:00
Irmen de Jong
343f01d5e1 re-enabled unused variable removal from library modules (+fixed some @shared vars in libraries) 2022-02-10 03:10:47 +01:00
Irmen de Jong
08bacdd090 temp vars are now dynamically added to AST as needed 2022-02-10 02:52:47 +01:00
Irmen de Jong
8c2e6971fc start using vars instead of callgraph (2) 2022-02-08 21:09:00 +01:00
Irmen de Jong
7d67005709 more rewrite variable allocation 2022-02-08 20:40:10 +01:00
Irmen de Jong
30e1c3307c simplify SourceCode: just read the full text immediately. Also optimized imports. 2022-02-05 03:50:54 +01:00
Irmen de Jong
f965804e6d fix invalid optimization of returning a parameter variable in a subroutine 2022-01-28 16:44:42 +01:00
Irmen de Jong
ec078eba72 optimize w=msb(w) => w>>=8, w=lsb(w) ==> w&=$00ff 2022-01-28 16:11:52 +01:00
Irmen de Jong
7b3cd71085 fixed improper optimization of word<<8 and word>>8 2022-01-28 13:54:06 +01:00
Irmen de Jong
586ce1fc80 tweak return's use of intermediate variable 2022-01-24 01:10:04 +01:00
Irmen de Jong
3b59592110 generalize string encoding flag into enum 2022-01-18 21:21:49 +01:00
Irmen de Jong
8e56656c8d fix broken code generated for certain ==/!= expressions 2022-01-16 17:10:49 +01:00
Irmen de Jong
564a6a1f62 fix invalid removal of Jump
that would generate wrong code if occurs at the end of a subroutine
2022-01-16 14:05:42 +01:00
Irmen de Jong
b29c3152db Assignment: make its origin explicit 2022-01-10 02:25:02 +01:00
Irmen de Jong
3831679772 VarDecl: make its origin explicit 2022-01-10 01:53:03 +01:00
Irmen de Jong
895534f32b don't remove dead variable assignments if they are a function call 2022-01-09 18:41:01 +01:00
Irmen de Jong
d99d977d2b fix more typecasting issues 2022-01-08 17:04:25 +01:00
Irmen de Jong
7dd7e562bc pipes also as expressions, cleanup codegen, fix various typecasting issues 2022-01-08 13:45:19 +01:00
Irmen de Jong
17694c1d01 better error handling of invalid number casts 2022-01-07 22:12:13 +01:00
Irmen de Jong
749ad700d8 naming consistency for some expression classes 2022-01-07 21:02:55 +01:00
Irmen de Jong
8f3df3039a added pipe operator `|>` 2022-01-06 22:54:18 +01:00
Irmen de Jong
b62183adcb slightly optimized binexpr evaluation for ==/!= in some cases 2021-12-30 02:00:36 +01:00
Irmen de Jong
de6ce4a46e add "X in [1,2,3]" expression (efficient containment check) 2021-12-29 17:26:00 +01:00
Irmen de Jong
7b54aa0c7d more consistent naming of the statement classes 2021-12-28 13:56:47 +01:00
Irmen de Jong
6e11b8ada1 GoSub no longer inherits from Jump node, fixes subtle ast/codegen bugs related to jsrs 2021-12-28 01:55:13 +01:00
Irmen de Jong
1c7c4fc3b0 optimized if-goto codegeneration 2021-12-28 00:42:00 +01:00
Irmen de Jong
97e84d0977 tweak if statement handling 2021-12-27 15:04:25 +01:00
Irmen de Jong
9906b58818 tweak while desugaring, moved postfixexpr optimizations to VariousCleanups regardless of optimizer setting because asmgen requires these for conditional expressions 2021-12-27 12:41:26 +01:00
Irmen de Jong
4da4f96669 lower code: break -> goto after (simplifies codegen) 2021-12-25 22:30:38 +01:00
Irmen de Jong
a090fe3834 no compiler optimizer crash on certain missing symbol 2021-12-23 23:51:21 +01:00
Irmen de Jong
e051e09c1d trim down number of warnings a bit 2021-12-17 20:21:14 +01:00
Irmen de Jong
1462c57d0c no need for intermediary returnvalue var for prefix expressions 2021-12-16 21:00:38 +01:00
Irmen de Jong
08f87c321f fixed capitalization of operator sets to be consistent with other sets names 2021-12-15 23:43:14 +01:00
Irmen de Jong
a7b5949e6a fix compiler crash when using a gosub/subroutinecall in a branch statement 2021-12-11 15:11:16 +01:00
Irmen de Jong
3d743a1ba1 added more constfolding 2021-12-09 23:32:48 +01:00
Irmen de Jong
abca618008 added more constfolding 2021-12-09 23:12:12 +01:00
Irmen de Jong
0d2c3901a3 added more constfolding 2021-12-09 22:12:31 +01:00
Irmen de Jong
d8d56b195f comments 2021-12-09 21:13:13 +01:00
Irmen de Jong
c92f914081 gradle build settings tweak to avoid jdk version conflict 2021-12-04 18:36:47 +01:00
Irmen de Jong
0498444ef2 moved all unit tests into single project to avoid dependency issues 2021-12-04 18:20:22 +01:00
Irmen de Jong
e545ea9504 fix and optimize storing A into pointervar 2021-12-04 04:43:58 +01:00
Irmen de Jong
b438d8aec0 fix invalid range size check when stepval is not a positive integer 2021-11-29 02:01:19 +01:00
Irmen de Jong
45b8762188 use inc/ina instead of adc 2021-11-29 00:07:15 +01:00
Irmen de Jong
9256f910f0 rollback binexpr splitting, caused slowdowns 2021-11-28 18:50:05 +01:00