mirror of
https://github.com/irmen/prog8.git
synced 2024-09-10 09:54:32 +00:00
fix certain inefficient codegen when assigning a type casted value
This commit is contained in:
parent
7649be97b1
commit
04da44eb98
2
.gitignore
vendored
2
.gitignore
vendored
@ -15,6 +15,7 @@ out/
|
|||||||
parser/**/*.interp
|
parser/**/*.interp
|
||||||
parser/**/*.tokens
|
parser/**/*.tokens
|
||||||
parser/**/*.java
|
parser/**/*.java
|
||||||
|
compiler/src/prog8/buildversion/*
|
||||||
*.py[cod]
|
*.py[cod]
|
||||||
*.egg
|
*.egg
|
||||||
*.egg-info
|
*.egg-info
|
||||||
@ -32,3 +33,4 @@ compiler/lib/
|
|||||||
/prog8compiler.jar
|
/prog8compiler.jar
|
||||||
sd*.img
|
sd*.img
|
||||||
*.d64
|
*.d64
|
||||||
|
|
||||||
|
@ -177,7 +177,6 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) return
|
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.expression)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.expression)
|
||||||
} else {
|
} else {
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.expression!!)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", DataType.UBYTE, operator, value.expression!!)
|
||||||
@ -259,6 +258,10 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
indexVar!=null -> {
|
indexVar!=null -> {
|
||||||
when (target.datatype) {
|
when (target.datatype) {
|
||||||
in ByteDatatypes -> {
|
in ByteDatatypes -> {
|
||||||
|
if(value.kind==SourceStorageKind.EXPRESSION
|
||||||
|
&& value.expression is PtTypeCast
|
||||||
|
&& tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
||||||
|
return
|
||||||
asmgen.loadScaledArrayIndexIntoRegister(target.array, DataType.UBYTE, CpuRegister.Y)
|
asmgen.loadScaledArrayIndexIntoRegister(target.array, DataType.UBYTE, CpuRegister.Y)
|
||||||
asmgen.out(" lda ${target.array.variable.name},y | sta P8ZP_SCRATCH_B1")
|
asmgen.out(" lda ${target.array.variable.name},y | sta P8ZP_SCRATCH_B1")
|
||||||
asmgen.saveRegisterLocal(CpuRegister.Y, target.scope!!)
|
asmgen.saveRegisterLocal(CpuRegister.Y, target.scope!!)
|
||||||
@ -270,10 +273,6 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
|
||||||
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression)
|
||||||
} else {
|
} else {
|
||||||
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression!!)
|
inplaceModification_byte_value_to_variable("P8ZP_SCRATCH_B1", target.datatype, operator, value.expression!!)
|
||||||
@ -285,6 +284,10 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
asmgen.out(" lda P8ZP_SCRATCH_B1 | sta ${target.array.variable.name},y")
|
asmgen.out(" lda P8ZP_SCRATCH_B1 | sta ${target.array.variable.name},y")
|
||||||
}
|
}
|
||||||
in WordDatatypes -> {
|
in WordDatatypes -> {
|
||||||
|
if(value.kind==SourceStorageKind.EXPRESSION
|
||||||
|
&& value.expression is PtTypeCast
|
||||||
|
&& tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator))
|
||||||
|
return
|
||||||
asmgen.loadScaledArrayIndexIntoRegister(target.array, DataType.UWORD, CpuRegister.Y)
|
asmgen.loadScaledArrayIndexIntoRegister(target.array, DataType.UWORD, CpuRegister.Y)
|
||||||
if(target.array.splitWords) {
|
if(target.array.splitWords) {
|
||||||
asmgen.out(" lda ${target.array.variable.name}_lsb,y | sta P8ZP_SCRATCH_W1")
|
asmgen.out(" lda ${target.array.variable.name}_lsb,y | sta P8ZP_SCRATCH_W1")
|
||||||
@ -302,10 +305,6 @@ internal class AugmentableAssignmentAsmGen(private val program: PtProgram,
|
|||||||
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.array!!)
|
SourceStorageKind.ARRAY -> inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.array!!)
|
||||||
SourceStorageKind.EXPRESSION -> {
|
SourceStorageKind.EXPRESSION -> {
|
||||||
if(value.expression is PtTypeCast) {
|
if(value.expression is PtTypeCast) {
|
||||||
if (tryInplaceModifyWithRemovedRedundantCast(value.expression, target, operator)) {
|
|
||||||
asmgen.restoreRegisterLocal(CpuRegister.Y)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression)
|
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression)
|
||||||
} else {
|
} else {
|
||||||
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression!!)
|
inplaceModification_word_value_to_variable("P8ZP_SCRATCH_W1", target.datatype, operator, value.expression!!)
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
TODO
|
TODO
|
||||||
====
|
====
|
||||||
|
|
||||||
- fix double code gen with tryInplaceModifyWithRemovedRedundantCast() ? word birdX[j] += testbyte
|
|
||||||
|
|
||||||
- prog8->asm symbol name prefixing: prefix ALL symbols with p8_ Also update manual.
|
- prog8->asm symbol name prefixing: prefix ALL symbols with p8_ Also update manual.
|
||||||
EXCEPTION: library symbols such as cbm.CHROUT, cx16.r0 etc. should NOT be prefixed.
|
EXCEPTION: library symbols such as cbm.CHROUT, cx16.r0 etc. should NOT be prefixed.
|
||||||
Solution: add %option no_symbol_prefix to those blocks?
|
Solution: add %option no_symbol_prefix to those blocks?
|
||||||
|
Loading…
Reference in New Issue
Block a user