view python/ppci/target/arm/arm.brg @ 365:98ff43cfdd36

Nasty bug in adr instruction
author Windel Bouwman
date Wed, 19 Mar 2014 22:32:04 +0100
parents c49459768aaa
children
line wrap: on
line source


from ppci.target.arm.instructions import Add1, Add2, Sub1, Mul1
from ppci.target.arm.instructions import Ldr1, Ldr3, Adr
from ppci.target.arm.instructions import And1, Lsr1, Lsl1, Mov1
from ppci.target.basetarget import LabelAddress

%%

%terminal ADDI32 SUBI32 MULI32 ADR
%terminal ORI32 SHLI32 SHRI32 ANDI32
%terminal CONSTI32 CONSTDATA MEMI32 REGI32 CALL GLOBALADDRESS
%terminal MOVI32

%%

reg: ADDI32(reg, reg)         2 'd = self.newTmp(); self.emit(Add1, dst=[d], src=[c0, c1]); return d'
reg: ADDI32(reg, cn)          2 'return tree.children[1].value < 256' 'd = self.newTmp(); self.emit(Add2, dst=[d], src=[c0], others=[c1]); return d'
reg: ADDI32(cn, reg)          2 'return tree.children[0].value < 256' 'd = self.newTmp(); self.emit(Add2, dst=[d], src=[c1], others=[c0]); return d'
reg: SUBI32(reg, reg)         2 'd = self.newTmp(); self.emit(Sub1, dst=[d], src=[c0, c1]); return d'
reg: MULI32(reg, reg)         2 'd = self.newTmp(); self.emit(Mul1, dst=[d], src=[c0, c1]); return d'
reg: ANDI32(reg, reg)         2 'd = self.newTmp(); self.emit(And1, dst=[d], src=[c0, c1]); return d'
reg: SHRI32(reg, reg)         2 'd = self.newTmp(); self.emit(Lsr1, dst=[d], src=[c0, c1]); return d'

reg: MEMI32(ADDI32(reg, cn))  2 'd = self.newTmp(); self.emit(Ldr1, dst=[d], src=[c0], others=[c1]); return d'
reg: MEMI32(reg)              2 'd = self.newTmp(); self.emit(Ldr1, dst=[d], src=[c0], others=[0]); return d'
reg: GLOBALADDRESS 21  'd = self.newTmp(); ln = self.selector.frame.add_constant(LabelAddress(tree.value)); self.emit(Ldr3, dst=[d], others=[ln]); return d'

cn: CONSTI32 0 'return tree.value'

reg: CONSTI32         6 'd = self.newTmp(); ln = self.selector.frame.add_constant(tree.value); self.emit(Ldr3, dst=[d], others=[ln]); return d'

reg: CONSTI32         2 'return (type(tree.value) is int) and (tree.value < 256)' 'd = self.newTmp(); self.emit(Mov1, dst=[d], others=[tree.value]); return d'

reg: ADR(CONSTDATA)   2  'd = self.newTmp(); ln = self.selector.frame.add_constant(tree.children[0].value); self.emit(Adr, dst=[d], others=[ln]); return d'

reg: REGI32           1 'return tree.value'

reg: CALL             1 'return self.selector.munchCall(tree.value)'