Commit Graph

1870 Commits

Author SHA1 Message Date
Irmen de Jong
b334d89715 refactor and fix the way memory addresses are checked to be in IO space or regular ram 2021-11-18 22:47:58 +01:00
Irmen de Jong
4f5d36a84d optimization added: bitwise operations with a negative constant number -> replace the number by its positive 2 complement 2021-11-18 02:51:42 +01:00
Irmen de Jong
fa11a6e18b removed faulty and too aggressive assembly optimization of double-store 2021-11-18 01:43:22 +01:00
Irmen de Jong
4c82af36e6 fix improperly changed behavior about =0 initializer 2021-11-18 00:17:22 +01:00
Irmen de Jong
dafa0d9138 fix compiler crash bug due to reused ast expression nodes. Now all (relevant) Nodes have a copy() function to make a clone. 2021-11-17 23:05:59 +01:00
Irmen de Jong
2e0450d7ed fix bug where variable=0 initializer was forgotten if vardecl is followed by an augmented assignment 2021-11-17 22:31:43 +01:00
Irmen de Jong
f48d6ca9f8 simplified NumericLiteral to always just contain a Double instead of a Number for the value 2021-11-16 23:52:54 +01:00
Irmen de Jong
1f60a2d8b9 comments 2021-11-15 01:30:12 +01:00
Irmen de Jong
5fd83f2757 version 7.3 2021-11-14 22:55:13 +01:00
Irmen de Jong
c80df4140b until-loop condition now also simplified to avoid stack-eval 2021-11-14 22:51:02 +01:00
Irmen de Jong
53e1729e2f introduce option to use internal scratch variables via prog8_lib definitions (ony for compiler, not for user code!) 2021-11-14 16:01:54 +01:00
Irmen de Jong
ab2d1122a9 conditional expressions are optimized more intelligently (simple ones are not split off in separate assignments) 2021-11-14 12:38:56 +01:00
Irmen de Jong
5190594c8a added several more assembly-level optimizations to remove redundant instructions 2021-11-14 12:23:46 +01:00
Irmen de Jong
c858ceeb58 compiler shouldn't use cx16.r15 as temp var 2021-11-14 02:38:59 +01:00
Irmen de Jong
f0f52b9166 optimize typecasted binary expression to avoid even more estack use. also fix wrong parent crash in removal of unused variable's assignments. 2021-11-13 14:22:37 +01:00
Irmen de Jong
00c6f74481 tweak temp float 2021-11-13 12:56:59 +01:00
Irmen de Jong
2177ba0ed2 added signed versions of the cx16 virtual registers 2021-11-13 02:42:21 +01:00
Irmen de Jong
3483515346 preparing for more optimizations 2021-11-12 23:23:51 +01:00
Irmen de Jong
75a06d2a40 preparing for more optimizations 2021-11-12 02:17:37 +01:00
Irmen de Jong
53ac11983b better unused variable removal 2021-11-11 03:03:21 +01:00
Irmen de Jong
69f4a4d4f8 tweak expr.typecastTo() a bit 2021-11-11 00:15:09 +01:00
Irmen de Jong
222bcb808f optimize load-store-load combo in output asm 2021-11-10 23:47:35 +01:00
Irmen de Jong
8df3da11e3 add cosr8, sinr8, cosr16 and sinr16 builtin functions that take a degree 0..179 (= 0..358 in 2 degree steps)
to more easily scale halves/quarters etc of a circle than possible with the ones that take 0..255 'degrees'.
2021-11-09 23:39:26 +01:00
Irmen de Jong
84dafda0e4 fix error message for type mismatch on builtin-function parameter 2021-11-09 22:19:07 +01:00
Irmen de Jong
b909facfe5 fix compiler stackoverflow crash on certain typecasted expressions containing floats. 2021-11-09 19:31:19 +01:00
Irmen de Jong
7780d94de1 discovered crash related to float typecasting in asm assignment codegen 2021-11-09 03:45:07 +01:00
Irmen de Jong
4937e004b5 fix compiler crash where it used wrong datatype in split assignment
fixes crash for "ubyte bb ;; uword ww ;; bb = not bb or not ww"
2021-11-09 01:13:23 +01:00
Irmen de Jong
857724c7e6 attempt to make if-statement not use stack eval anymore 2021-11-08 19:07:36 +01:00
Irmen de Jong
2d1e5bbc7e remove unimportant empty tests 2021-11-08 17:00:10 +01:00
Irmen de Jong
7961a09d16 converting compiler module's testcases to kotest assertions 2021-11-08 16:14:22 +01:00
Irmen de Jong
613efcacc7 converting compiler module's testcases to kotest (ongoing) 2021-11-08 15:08:48 +01:00
Irmen de Jong
7e8db16e18 moved to kotest assertions in compilerAst module tests 2021-11-07 21:18:18 +01:00
Irmen de Jong
f4c4ee78d9 re-use global returnvalue temp var instead of duplicating it in every subroutine that needs it 2021-11-07 14:19:21 +01:00
Irmen de Jong
72a7e61fd0 version 7.2 2021-11-06 23:42:13 +01:00
Irmen de Jong
f40620aa25 "not x" as a condition (if, while, until) is optimized into "x==0", this avoids calculating the value 2021-11-06 23:25:32 +01:00
Irmen de Jong
4270c04856 don't crash but give proper error on "-X" expression where X is not a signed type 2021-11-06 18:06:01 +01:00
Irmen de Jong
62dc824bc0 tweaks 2021-11-06 17:14:07 +01:00
Irmen de Jong
1605791f1b float swap() no longer uses evaluation stack but a single temp var instead + FAC1 2021-11-06 03:36:14 +01:00
Irmen de Jong
23961f695d fixed some parse tree node position end-columns. cleanup some todo's 2021-11-05 22:48:28 +01:00
Irmen de Jong
eea3fb48a8 add command line option 'optfloatx' to explicitly re-enable float expr optimization as this can increase code size significantly.
The output size of the various example programs using floating point, when not using this optimization, has been reduced significantly.
The resulting code runs a (tiny) bit slower though.
2021-11-03 22:52:08 +01:00
Irmen de Jong
b4fa72c058 fix parent node linkage for reading array parameter 2021-11-03 21:57:31 +01:00
Irmen de Jong
3410aea788 fix regression: don't add 0 initializer when variable is assigned to anyway (or is loopvar in a for-loop) 2021-11-02 21:23:59 +01:00
Irmen de Jong
7e287a5359 proper parent node linkage in generated const values out of typecast expressions. Fixes crash mentioned in #72 2021-11-02 00:47:01 +01:00
Irmen de Jong
1110bd0851 fix vardecl initialization value to not use stack eval anymore but separate assignment
(this causes the optimized assignment code gen to be used instead)
but some programs now end up larger in output size
2021-11-01 00:24:15 +01:00
Irmen de Jong
fe17566370 improved reporting of slow stack based evaluation code 2021-10-31 14:18:49 +01:00
Irmen de Jong
03ac9b6956 various cleanups, slight update to dbus 2021-10-30 19:30:19 +02:00
Irmen de Jong
dfbef8495d got rid of ParsingFailedError 2021-10-30 17:05:23 +02:00
Irmen de Jong
7b17c49d8f update petscii tables with improvements to box drawing chars. fixes #68 2021-10-30 16:45:23 +02:00
Irmen de Jong
4b3f31c2ee added option to suppress assembler output (and enabled this in unit tests) 2021-10-30 15:26:40 +02:00
Irmen de Jong
9ccc65bf8f more petscii tests 2021-10-30 15:15:11 +02:00
Irmen de Jong
f9e22add03 fix crash when using array as paramater type 2021-10-30 15:15:00 +02:00
Irmen de Jong
97836e18b2 simplified gradle config, automatically run installDist task after build 2021-10-30 12:01:52 +02:00
Irmen de Jong
7b69df4db2 todos 2021-10-30 00:38:48 +02:00
Irmen de Jong
3767b4bbe7 'Program' is not an ast Node 2021-10-30 00:25:34 +02:00
Irmen de Jong
d7d2eefa4f implemented CharLiteral.constValue() 2021-10-30 00:05:55 +02:00
Irmen de Jong
6737f28d1e moved unittests of compilerInterfaces into compiler module itself 2021-10-29 23:46:51 +02:00
Irmen de Jong
3da9404c2d removed memsizer arg from all builtin functions 2021-10-29 23:38:31 +02:00
Irmen de Jong
1137da37c3 reshuffle ErrorReporter 2021-10-29 17:02:03 +02:00
Irmen de Jong
495a18805c move asmgen test to codeGeneration module 2021-10-29 16:20:53 +02:00
Irmen de Jong
a226b82d0b cleanup imports 2021-10-29 05:30:12 +02:00
Irmen de Jong
0b5ddcdc9b split out the code generator into own project submodule 2021-10-29 05:00:30 +02:00
Irmen de Jong
5ff481ce3c make sure tmp folders exist for unit tests 2021-10-29 03:04:16 +02:00
Irmen de Jong
f21dcaa6fb split out the code optimizers into own project submodule 2021-10-29 02:42:10 +02:00
Irmen de Jong
2c940de598 better name 2021-10-29 01:06:01 +02:00
Irmen de Jong
ce75b776bb refactor loadAsmIncludeFile response 2021-10-29 01:01:24 +02:00
Irmen de Jong
7d22b9b9f9 simplified name conflict check for sub params 2021-10-29 00:20:33 +02:00
Irmen de Jong
6cb8b3b5cd removed unneeded scope param from lookup() 2021-10-29 00:01:28 +02:00
Irmen de Jong
2bf4017f2b fix nested label lookups in anon scopes
fixed non-global qualified names lookup
2021-10-28 23:48:01 +02:00
Irmen de Jong
08d2f8568b refactoring symbol lookups 2021-10-27 23:48:12 +02:00
Irmen de Jong
ac5f45d2d4 fix nested label lookups in anon scopes (partly) 2021-10-27 02:41:24 +02:00
Irmen de Jong
3cc7ad7d20 slightly improve error message for unknown module import 2021-10-27 00:38:36 +02:00
Irmen de Jong
d4513364fb fix compiler crash when file on command line doesn't exist 2021-10-27 00:23:54 +02:00
Irmen de Jong
9684f4e42a add unit tests for AnonScope refactoring, cleaned up imports 2021-10-27 00:05:46 +02:00
Irmen de Jong
141689e697 change many uses of .definingScope to just the parent node 2021-10-26 23:25:16 +02:00
Irmen de Jong
743c8b44a2 AnonymousScope refactor: it's no longer a INameScope
because it doesn't contain scoped variables (these are moved to the subroutine's scope)
2021-10-26 23:01:51 +02:00
Irmen de Jong
5e1459564a no longer take AddressOf a str-variable that is a subroutine's parameter with str type (it's just an address/uword already) 2021-10-25 23:49:01 +02:00
Irmen de Jong
69a8813a3d first steps to add support for str parameter type 2021-10-24 20:57:10 +02:00
Irmen de Jong
17175df835 more precise error messages checks 2021-10-24 19:14:46 +02:00
Irmen de Jong
6b32535cb6 don't complain about uninitialized str var if it's not a var 2021-10-24 15:13:38 +02:00
Irmen de Jong
2815a14bb5 (7.2) can now test for specific error messages, and specify to omit invoking assembler in tests 2021-10-22 01:25:26 +02:00
Irmen de Jong
f4dfa60790 (7.2) tests for pass by ref parameters 2021-10-22 00:41:34 +02:00
Irmen de Jong
35e88dd529 (7.2) correctly parse datatype of array parameters 2021-10-21 22:06:21 +02:00
Irmen de Jong
4d5094a517 (7.2) cleanup Petscii converter errorhandling, add unit tests for error scenarios 2021-10-20 23:48:20 +02:00
Irmen de Jong
dd5abae721 move testcase to proper location 2021-10-20 23:08:40 +02:00
Irmen de Jong
8f2fb20934 Merge branch 'v7.1' into v7.2 2021-10-20 22:51:14 +02:00
Irmen de Jong
440abf4998 fix test to recognise inserted return statements 2021-10-20 22:50:18 +02:00
Irmen de Jong
74555a32ed Merge branch 'v7.1' into v7.2 2021-10-20 22:37:43 +02:00
Irmen de Jong
85956b5828 code generator: add a return (RTS) to empty subroutines. Fixes #67 2021-10-20 22:36:13 +02:00
Irmen de Jong
41e40cad03 optimizer bug: don't remove empty subroutine if it's referenced. Fixes #67 2021-10-20 22:25:10 +02:00
Irmen de Jong
df2d5c6585 tests for callgraph and unused subroutine removal in optimizer 2021-10-20 22:24:10 +02:00
Irmen de Jong
e6c41eac93 Merge branch 'v7.1' into v7.2 2021-10-19 23:22:38 +02:00
Irmen de Jong
82d20dea39 a few comment and TODO cleanups.
remove remark about chars UBYTE type, kotlin's closest native type that can contain 0-255 is a short.
2021-10-19 23:20:34 +02:00
Irmen de Jong
804bb06859 clarified isInRegularRAM() by making it an extension method on AssignTarget 2021-10-19 22:36:05 +02:00
Irmen de Jong
5afa7e53f8 got rid of program arg for isInRegularRAM 2021-10-19 22:30:30 +02:00
Irmen de Jong
7f15b7b716 remove unneeded check for duplicate module names as this is now caught by the logic in Program.addModule itself 2021-10-19 22:12:54 +02:00
Irmen de Jong
552e0c2248 rename mainModule to toplevelModule.
failed module no longer retains in the Ast.
improved some tests on that.
2021-10-19 21:49:05 +02:00
Irmen de Jong
502bf90007 comments 2021-10-19 01:12:28 +02:00
Irmen de Jong
4011dce31b added a few more tests for the file element of Position 2021-10-19 00:26:02 +02:00
Irmen de Jong
14aad2358f version 7.2 started 2021-10-16 18:46:08 +02:00
Irmen de Jong
cf0e395921 got rid of SourceCode.pathString() and the 'need' to strip < and > 2021-10-16 17:15:22 +02:00