Commit Graph

188 Commits

Author SHA1 Message Date
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