Commit Graph

299 Commits

Author SHA1 Message Date
Irmen de Jong
91e1643627 update 3rd party libraries 2023-05-18 11:47:30 +02:00
Irmen de Jong
91421b0c62 IR handy sequence shortcut functions 2023-05-18 11:32:20 +02:00
Irmen de Jong
b43223cb7a added clamp() builtin function and floats.clampf() 2023-05-17 23:12:58 +02:00
Irmen de Jong
85cf0e311c Merge branch 'master' into version_9
# Conflicts:
#	codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt
#	docs/source/todo.rst
#	intermediate/src/prog8/intermediate/IRInstructions.kt
2023-05-14 20:47:09 +02:00
Irmen de Jong
0e3d75cfeb move irType() to intermediate module 2023-05-14 20:44:32 +02:00
Irmen de Jong
630c8a5faa IR: fix romsub encoding 2023-05-14 18:08:06 +02:00
Irmen de Jong
905921a684 IR: new (sys)call instructions that encapsulate the full subroutine call
to fix the bugs resulting from nesting subroutine calls (as param to another call etc)
2023-05-14 15:20:25 +02:00
Irmen de Jong
1e469b3b0f Merge branch 'master' into version_9
# Conflicts:
#	docs/source/todo.rst
#	examples/test.p8
2023-05-09 22:45:21 +02:00
Irmen de Jong
bff3c4f95c IR now converts IRInlineAsmChunk (of type IR) into regular code chunks directly.
.p8ir files usually won't contain <INLINEASM> nodes any longer
2023-05-09 21:04:31 +02:00
Irmen de Jong
bd2bcb6994 Merge branch 'master' into version_9
# Conflicts:
#	codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt
#	compiler/res/prog8lib/c128/syslib.p8
#	compiler/res/prog8lib/c64/syslib.p8
#	compiler/res/prog8lib/cx16/syslib.p8
#	docs/source/todo.rst
#	examples/test.p8
#	intermediate/src/prog8/intermediate/IRInstructions.kt
2023-05-08 23:17:52 +02:00
Irmen de Jong
97df33ab1a IR: fix byte to word assignment not doing value extension 2023-05-08 22:47:00 +02:00
Irmen de Jong
add8a777d8 IR: binarydata fixes 2023-05-03 22:31:04 +02:00
Irmen de Jong
3fc49c001e IR: fix for-loop codegen when step<0 2023-05-02 23:12:11 +02:00
Irmen de Jong
3d69a95c49 IR: fix for-loop codegen when step<0 2023-05-02 23:09:42 +02:00
Irmen de Jong
92062d056d divmod() now works on multiple data types including float.
divmodw() has been removed
2023-05-02 01:19:53 +02:00
Irmen de Jong
06368ab0a1 sqrt() now works on multiple data types including float.
no need to use floats.sqrtf() anymore
2023-05-02 01:19:53 +02:00
Irmen de Jong
38efe25c68 abs() now works on multiple data types including float.
no need to use floats.fabs() anymore
2023-05-02 01:19:53 +02:00
Irmen de Jong
319079de7a sqrt 2023-05-02 01:19:53 +02:00
Irmen de Jong
c07eda15b1 adding min() and max() 2023-05-02 01:19:53 +02:00
Irmen de Jong
76a203d4df api change: rename builtin func sqrt16 to sqrtw 2023-05-02 01:19:53 +02:00
Irmen de Jong
24f37e2062 fix 2023-05-02 01:19:36 +02:00
Irmen de Jong
f465b2e2a0 some improvements to IR peephole optimizer 2023-05-02 00:29:04 +02:00
Irmen de Jong
d494f9d66b fix 2023-04-29 18:04:08 +02:00
Irmen de Jong
efd7d6f0c0 tweak IR call args setting now via special SETPARAM instruction 2023-04-14 02:10:39 +02:00
Irmen de Jong
b55be093be tweak IR 2023-04-11 22:48:20 +02:00
Irmen de Jong
7c1d5cadd7 fix sort and reverse on strings on 6502 codegen 2023-04-10 19:33:24 +02:00
Irmen de Jong
dd1592b03b ir syscalls args via stack instead of fixed r65500+ 2023-04-10 18:02:37 +02:00
Irmen de Jong
9b37ac483f vm fix str to word conversion
ir SYSCALL puts result(s) on value stack,  instead of on hardcoded r0, r1
2023-04-10 16:26:42 +02:00
Irmen de Jong
090820958e ir divmod returns its results on valuestack, to keep consistency with the rule that only 1 register can be a returnvalue 2023-04-10 15:26:30 +02:00
Irmen de Jong
ac21e1be5c vm syscall instruction no longer fixed to r0 2023-04-10 13:44:05 +02:00
Irmen de Jong
5196443b26 fix 2023-04-10 12:16:52 +02:00
Irmen de Jong
c8531cbeb1 remove unused variables from IR output 2023-04-09 23:09:30 +02:00
Irmen de Jong
9b952fbc44 tweaking IR instruction set branch instructions 2023-04-09 22:17:19 +02:00
Irmen de Jong
ccdf05e922 tweaking IR instruction formats 2023-04-09 16:12:16 +02:00
Irmen de Jong
c3d74f2ae9 fix golden ram area for x16, remove romsub restriction
note: romsubs still won't work in the VM but at least they compile again
2023-04-08 00:40:52 +02:00
Irmen de Jong
f47498888c optimize imports 2023-04-07 22:34:23 +02:00
Irmen de Jong
5665a7f0cb also track ir reg types 2023-04-07 22:24:17 +02:00
Irmen de Jong
c4f53fe525 IR: small optimization 2023-04-05 22:55:54 +02:00
Irmen de Jong
befe0fff2a IR: fix comparison codegen errors in newexpr path 2023-04-05 00:15:09 +02:00
Irmen de Jong
d8214d4f12 fix IR array indexing for newexpr 2023-04-03 03:13:35 +02:00
Irmen de Jong
47d0f0ea40 implement missing operators in IR code gen 2023-04-01 02:29:33 +02:00
Irmen de Jong
2d85fd093e Merge branch 'new-expr-codegen'
# Conflicts:
#	codeGenCpu6502/src/prog8/codegen/cpu6502/BuiltinFunctionsAsmGen.kt
#	codeGenIntermediate/src/prog8/codegen/intermediate/BuiltinFuncGen.kt
#	examples/test.p8
2023-03-29 23:56:16 +02:00
Irmen de Jong
d936568b76 added divmod() and divmodw() builtin functions to efficiently compute division and remainder in a single call 2023-03-29 23:46:44 +02:00
Irmen de Jong
07fde7f6cc fix IR same register error 2023-03-28 20:01:26 +02:00
Irmen de Jong
729209574e fixing str compares codegen 2023-03-28 20:01:26 +02:00
Irmen de Jong
f28206d989 new attempt 2023-03-28 20:01:26 +02:00
Irmen de Jong
11216017cb fix IR same register error 2023-03-28 20:00:21 +02:00
Irmen de Jong
1fa2e2e37d 3rd party library versions upgrades 2023-03-26 21:36:21 +02:00
Irmen de Jong
629ed74d09 got rid of rpn deadend code... 2023-03-25 18:45:17 +01:00
Irmen de Jong
6e4ae034b2 more Rpn optimizations 2023-03-19 00:48:12 +01:00
Irmen de Jong
5b0e1b4f9e a little rpn refactor 2023-03-17 23:04:56 +01:00
Irmen de Jong
8c0a93779b added first implementation of RPN 6502 codegen - all via stackeval still 2023-03-17 22:28:22 +01:00
Irmen de Jong
9241479da4 add "-rpn" command line switch to transform exprs to RPN in codegen 2023-03-17 22:28:22 +01:00
Irmen de Jong
8ffca93cd5 added transform routine for expr -> RPN 2023-03-17 22:28:22 +01:00
Irmen de Jong
7fea0c124a introduce PtRpn node to replace PtBinaryExpression later 2023-03-17 22:28:22 +01:00
Irmen de Jong
92276b5769 IR fix unneeded register allocated for array indexing with variable 2023-03-14 21:24:44 +01:00
Irmen de Jong
a2133f61a8 get rid of all the require() checks that test result regs to be different 2023-03-14 01:01:46 +01:00
Irmen de Jong
199adbbcf0 IR: don't allow to have 2 same registers on instructions 2023-03-14 00:45:41 +01:00
Irmen de Jong
dc316fd7b4 IR: more optimal branch instructions for comparisons against zero 2023-03-13 23:17:53 +01:00
Irmen de Jong
025183602f refactor IR returnregs 6 2023-03-13 21:35:23 +01:00
Irmen de Jong
db4619a9d9 refactor IR returnregs 5 2023-03-13 04:16:50 +01:00
Irmen de Jong
451e527b7c refactor IR returnregs 4 2023-03-13 03:54:16 +01:00
Irmen de Jong
54dd3a00df refactor IR returnregs 3 2023-03-13 03:20:06 +01:00
Irmen de Jong
03c5dab79d refactor IR returnregs 2 2023-03-13 02:50:41 +01:00
Irmen de Jong
1fdee861e8 refactor IR returnregs 2023-03-13 00:32:48 +01:00
Irmen de Jong
c12bf991b3 reintegrate into existing IR optimizer 2023-03-12 22:16:20 +01:00
Irmen de Jong
78a097585d new IR call and return instructions to deal with returnregisters 2023-03-12 21:54:59 +01:00
Irmen de Jong
39132327cc added optimizer for IR code
with two very simple optimizations
2023-03-12 20:30:51 +01:00
Irmen de Jong
d76547ead4 don't crash on certain undefined symbols, give proper error instead
Also the error handlers in unit tests now de-duplicate messages just like the compiler itself does
2023-03-11 14:58:41 +01:00
Irmen de Jong
48fed4e6fb slight tweak to codegenerator backend interface 2023-03-08 00:14:38 +01:00
Irmen de Jong
fc253237c9 fix issues with reporting inlined subroutines as unused 2023-03-07 23:47:14 +01:00
Irmen de Jong
589948c7f4 fix IR translateIfElseNonZeroComparison for ints + floats 2023-03-07 23:07:51 +01:00
Irmen de Jong
7e69690605 fix IR translateIfFollowedByJustGoto for ints + floats 2023-03-07 22:04:02 +01:00
Irmen de Jong
95f498ba9b fix IR translateIfElseZeroComparison for ints + floats 2023-03-07 21:26:34 +01:00
Irmen de Jong
fd07ae5225 fix various IR file and symboltable issues 2023-03-07 19:40:11 +01:00
Irmen de Jong
d282a2d846 remove cx16.callrom() just use callfar 2023-02-23 23:02:56 +01:00
Irmen de Jong
435b9d8973 get rid of 'noreinit' option for now, because it resulted in unreliable code 2023-02-20 23:29:16 +01:00
Irmen de Jong
c3c82282ba reinitGlobals option is clearer than the inverse 2023-02-19 19:09:29 +01:00
Irmen de Jong
aaf375a57b move some utility methods into Pt Ast nodes itself 2023-02-16 22:45:35 +01:00
Irmen de Jong
5c3f41f64d reintroduce explicit PtAugmentedAssign ast node 2023-02-15 22:54:32 +01:00
Irmen de Jong
b95608f68a new common ICodeGeneratorBackend interface for all code generator classes 2023-02-12 23:52:54 +01:00
Irmen de Jong
694d088160 some cleanups about asmsub return registers and types 2023-02-09 03:19:57 +01:00
Irmen de Jong
07d5fafe2e Merge branch 'master' into codegen-on-new-ast
# Conflicts:
#	compiler/src/prog8/compiler/astprocessing/IntermediateAstMaker.kt
2023-01-29 13:34:00 +01:00
Irmen de Jong
e08da659e5 got rid of PtScopeVarsDecls node, just insert variable nodes directly 2023-01-29 13:25:15 +01:00
Irmen de Jong
a3c0c7c96f Merge branch 'master' into codegen-on-new-ast
# Conflicts:
#	codeGenIntermediate/src/prog8/codegen/intermediate/IRCodeGen.kt
#	examples/test.p8
2023-01-22 18:30:37 +01:00
Irmen de Jong
4403e4ed62 optimize node renames 2023-01-22 18:26:37 +01:00
Irmen de Jong
b2cb125bd4 more 6502 codegen on new Pt-AST. 2023-01-22 17:10:52 +01:00
Irmen de Jong
6ee270d9d8 make name a var in new ast to allow cheap renames 2023-01-22 17:10:04 +01:00
Irmen de Jong
c25eb088ec redo 8e730ef93d to avoid larger code generated 2023-01-01 23:43:33 +01:00
Irmen de Jong
8e730ef93d optimizing scoped names more and fix scoping of identifier names in arrays (pointers) in SymbolTable 2022-12-31 03:20:20 +01:00
Irmen de Jong
e0913a39ab optimizing 2022-12-30 18:50:45 +01:00
Irmen de Jong
a7df094ff4 don't allow ~ on booleans, also introduce SZ and SNZ instructions in IR to complete the conditional-set instruction list. 2022-12-28 21:19:38 +01:00
Irmen de Jong
1e6fa77633 ir: 4 new instructions to branch on signed <0, >0, <=0, >=0 2022-12-28 13:14:20 +01:00
Irmen de Jong
eb4cff202c removed redundant branch opcodes in IR: BLT(S), BLE(S). Just use swapped BGT(S), BGE(S). 2022-12-28 12:41:05 +01:00
Irmen de Jong
7ee777f405 vm/ir: for loop is now correctly skipped if loopvar>endvar
this is different still in the 6502 codegen, where it wraps around $00!
2022-12-27 18:12:41 +01:00
Irmen de Jong
def7e87151 fixed silly if-goto expression code in IR codegen where it used too many branching instructions 2022-12-12 22:47:15 +01:00
Irmen de Jong
d1d0115aed removed unused option 'keepIR' 2022-12-09 18:44:44 +01:00
Irmen de Jong
f2273c0acc fix several FP rom routine addresses on cx16. 2022-12-03 19:56:54 +01:00
Irmen de Jong
483f313eda ir: keep correct child node order in blocks 2022-11-24 01:19:48 +01:00
Irmen de Jong
c21913a66b ir: keep order of children in block 2022-11-22 02:04:24 +01:00
Irmen de Jong
922033c1b2 main block element order now remains the same as in source 2022-11-16 00:32:00 +01:00
Irmen de Jong
00c059e5b1 adding cx16/adpcm example 2022-11-15 01:17:28 +01:00
Irmen de Jong
d08451bccc ir: Block can now contain inline binary 2022-11-12 20:17:23 +01:00
Irmen de Jong
d8e785aed0 ir: fix too greedy chunk removal 2022-11-12 19:56:54 +01:00
Irmen de Jong
267b6f49b5 IRFileReader parses the p8ir file with xml parser 2022-11-12 16:51:20 +01:00
Irmen de Jong
e614e9787a ir: write values as hex into p8ir file 2022-11-08 21:59:05 +01:00
Irmen de Jong
38efaae7b2 ir/vm: syscall params in high base register to avoid push/pop 2022-11-06 12:52:09 +01:00
Irmen de Jong
469e042216 vm: replaced prog8_lib.string_compare and others with syscalls 2022-11-04 23:12:13 +01:00
Irmen de Jong
fc55b34d84 ir: fix asmsub multi-value return codegen 2022-11-03 22:29:41 +01:00
Irmen de Jong
6f67fc0e02 ir: get rid of '_' symbol prefix 2022-11-03 21:54:53 +01:00
Irmen de Jong
06b032af91 refactor 2022-11-03 00:20:31 +01:00
Irmen de Jong
3603140114 ir: fix unused code remover 2022-11-02 23:54:52 +01:00
Irmen de Jong
e094785cbd ir: fix unused code remover 2022-11-02 23:16:51 +01:00
Irmen de Jong
e7408224ac ir: remove position tracking from codechunk for now 2022-11-02 22:12:42 +01:00
Irmen de Jong
e67c05c274 ir: fix asmsub contents not appearing in IR file 2022-11-02 20:50:51 +01:00
Irmen de Jong
b22804efaf ir: fix inlineasm linking 2022-10-31 23:59:33 +01:00
Irmen de Jong
5efe2b027a ir: fix chunk linkage in optimizer 2022-10-30 23:42:41 +01:00
Irmen de Jong
5b6569d0f9 ir: fix overwriting chunk label 2022-10-30 19:03:02 +01:00
Irmen de Jong
a5ef353484 ir: fix memory mapped var as for loop counter 2022-10-30 14:54:47 +01:00
Irmen de Jong
224f490455 Merge branch 'master' into labeledchunks
# Conflicts:
#	codeGenIntermediate/src/prog8/codegen/intermediate/AssignmentGen.kt
#	codeGenIntermediate/src/prog8/codegen/intermediate/ExpressionGen.kt
#	examples/test.p8
2022-10-29 18:26:09 +02:00
Irmen de Jong
5b35232ab4 fix "fpReg1 out of bounds" crash for vm target for in-place float array assignment. #85 2022-10-29 17:04:39 +02:00
Irmen de Jong
b718b12083 ir/vm fix chunk linkage 2022-10-26 00:12:56 +02:00
Irmen de Jong
cfa7258ff4 various 2022-10-25 23:18:42 +02:00
Irmen de Jong
585009ac5c ir: fix syscall numbers and more 2022-10-24 01:57:37 +02:00
Irmen de Jong
30ee65fd14 ir: ensure that block and sub labels are also on the first chunk in said block/sub 2022-10-23 18:54:08 +02:00
Irmen de Jong
76428b16f0 Merge branch 'master' into labeledchunks
# Conflicts:
#	codeGenIntermediate/src/prog8/codegen/intermediate/BuiltinFuncGen.kt
#	docs/source/todo.rst
#	examples/test.p8
#	virtualmachine/src/prog8/vm/VirtualMachine.kt
2022-10-23 12:19:02 +02:00
Irmen de Jong
e94bf4c63c replace rnd()/rndw() builtin functions by regular routines in math module 2022-10-22 17:02:43 +02:00
Irmen de Jong
fabae6e970 ir: fix handling of labeled chunks 2022-10-16 23:53:17 +02:00
Irmen de Jong
a9f9c40d8a ir: fix handling of labeled chunks 2022-10-13 00:56:44 +02:00
Irmen de Jong
6fc89607d3 ir: moving to labeled chunks, no more IRLabel nodes 2022-10-07 00:34:56 +02:00
Irmen de Jong
2340760f53 rename 2022-10-04 22:54:14 +02:00
Irmen de Jong
39d6d2857e ir: change inline binary a bit 2022-10-04 00:57:08 +02:00
Irmen de Jong
7b722a0001 ir: fix count register uses 2022-10-04 00:25:55 +02:00
Irmen de Jong
af6be44676 ir: adding register usage inspections
fix compiler problems with untrimmed inlined asm, and when only a single return statement is present in a subroutine
2022-09-30 20:25:00 +02:00
Irmen de Jong
5a8f97a0b6 ir: adding last missing features to be able to encode all of Prog8 2022-09-30 16:01:00 +02:00
Irmen de Jong
0d4dd385b8 added '%ir' to write inline IR code, '%asm' is now only for real 6502 assembly.
(%ir is probably only used in the library modules for the virtual machine target)
2022-09-30 15:12:26 +02:00
Irmen de Jong
94f0f3e966 ir: join code chunks 2022-09-30 02:47:33 +02:00
Irmen de Jong
7ea7e63f44 use require() more often 2022-09-27 18:27:55 +02:00
Irmen de Jong
1d2ce2cbeb consolidate IR line parse function 2022-09-27 18:02:57 +02:00
Irmen de Jong
06cf2e0bd7 vm: fix memory slabs (bsieve example) 2022-09-27 16:32:44 +02:00
Irmen de Jong
90b2be2bf4 vm: new memory initialization of array vars 2022-09-27 02:43:50 +02:00
Irmen de Jong
4d6dcbd173 ir: consolidate IRCodeInstruction and Instruction 2022-09-26 19:46:44 +02:00
Irmen de Jong
0da117efd2 vm: get rid of .p8virt file and cruft 2022-09-26 19:28:40 +02:00
Irmen de Jong
1a56743bb1 fix IR repeat loop codegen when amount is 0 2022-09-25 20:48:17 +02:00
Irmen de Jong
1d65d63bd9 ir: making sure all names are scoped properly. textelite now runs in vm 2022-09-25 18:02:35 +02:00
Irmen de Jong
0e1886e6bd vm: fix nested label prefixing 2022-09-24 16:00:25 +02:00
Irmen de Jong
ca2fb6cef3 IR no longer depends on VM syscalls but has its own syscall list for the few builtin functions that still require it 2022-09-23 14:27:51 +02:00
Irmen de Jong
ab00822764 move IR optimizer to IR Codegen module 2022-09-19 19:41:43 +02:00
Irmen de Jong
b4352ad38b refactor IR codegen into separate module 2022-09-19 19:24:24 +02:00