mirror of
https://github.com/irmen/prog8.git
synced 2025-02-18 05:30:34 +00:00
optimized codegen for logical expressions with simple right operand (such as c64.READST() & $40 )
This commit is contained in:
parent
a1d04f2aad
commit
ca1089b881
@ -378,9 +378,8 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
if(!expr.inferType(program).isInteger)
|
||||
return false
|
||||
|
||||
if(expr.operator in setOf("&", "|", "^", "and", "or", "xor")) {
|
||||
if(expr.left.inferType(program).isBytes && expr.right.inferType(program).isBytes &&
|
||||
expr.left.isSimple && expr.right.isSimple) {
|
||||
fun simpleLogicalBytesExpr() {
|
||||
// both left and right expression operands are simple.
|
||||
if (expr.right is NumericLiteral || expr.right is IdentifierReference)
|
||||
assignLogicalWithSimpleRightOperandByte(assign.target, expr.left, expr.operator, expr.right)
|
||||
else if (expr.left is NumericLiteral || expr.left is IdentifierReference)
|
||||
@ -398,10 +397,10 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
assignRegisterByte(assign.target, CpuRegister.A)
|
||||
}
|
||||
return true
|
||||
}
|
||||
if(expr.left.inferType(program).isWords && expr.right.inferType(program).isWords &&
|
||||
expr.left.isSimple && expr.right.isSimple) {
|
||||
|
||||
fun simpleLogicalWordsExpr() {
|
||||
// both left and right expression operands are simple.
|
||||
if (expr.right is NumericLiteral || expr.right is IdentifierReference)
|
||||
assignLogicalWithSimpleRightOperandWord(assign.target, expr.left, expr.operator, expr.right)
|
||||
else if (expr.left is NumericLiteral || expr.left is IdentifierReference)
|
||||
@ -419,8 +418,21 @@ internal class AssignmentAsmGen(private val program: Program,
|
||||
}
|
||||
assignRegisterpairWord(assign.target, RegisterOrPair.AY)
|
||||
}
|
||||
}
|
||||
|
||||
if(expr.operator in setOf("&", "|", "^", "and", "or", "xor")) {
|
||||
if (expr.left.inferType(program).isBytes && expr.right.inferType(program).isBytes) {
|
||||
if (expr.right.isSimple) {
|
||||
simpleLogicalBytesExpr()
|
||||
return true
|
||||
}
|
||||
}
|
||||
if (expr.left.inferType(program).isWords && expr.right.inferType(program).isWords) {
|
||||
if (expr.right.isSimple) {
|
||||
simpleLogicalWordsExpr()
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
|
@ -3,7 +3,6 @@ TODO
|
||||
|
||||
For next release
|
||||
^^^^^^^^^^^^^^^^
|
||||
- why slow stack eval for "if c64.READST() & $40" ?
|
||||
- regression test the various projects before release
|
||||
|
||||
...
|
||||
|
Loading…
x
Reference in New Issue
Block a user