346
|
1
|
354
|
2 from ppci.target.arm.instructions import Add1, Sub1, Mul1
|
|
3 from ppci.target.arm.instructions import Ldr1, Ldr3, Adr
|
346
|
4
|
|
5 %%
|
|
6
|
354
|
7 %terminal ADDI32 SUBI32 MULI32 ADR
|
346
|
8 %terminal ORI32 SHLI32
|
354
|
9 %terminal CONSTI32 CONSTDATA MEMI32 REGI32 CALL
|
346
|
10 %terminal MOVI32
|
|
11
|
|
12 %%
|
|
13
|
|
14 reg: ADDI32(reg, reg) 2 (. d = self.newTmp(); self.emit(Add1, dst=[d], src=[$1, $2]); return d .)
|
|
15 reg: SUBI32(reg, reg) 2 (. d = self.newTmp(); self.emit(Sub1, dst=[d], src=[$1, $2]); return d .)
|
354
|
16 reg: MULI32(reg, reg) 2 (. d = self.newTmp(); self.emit(Mul1, dst=[d], src=[$1, $2]); return d .)
|
|
17
|
346
|
18 reg: MEMI32(ADDI32(reg, cn)) 2 (. d = self.newTmp(); self.emit(Ldr1, dst=[d], src=[$1], others=[$2]); return d .)
|
352
|
19 reg: MEMI32(reg) 2 (. d = self.newTmp(); self.emit(Ldr1, dst=[d], src=[$1], others=[0]); return d .)
|
346
|
20
|
|
21
|
|
22 cn: CONSTI32 0 (. return $$.value .)
|
|
23
|
353
|
24 reg: CONSTI32 3 (. d = self.newTmp(); ln = self.selector.frame.add_constant($$.value); self.emit(Ldr3, dst=[d], others=[ln]); return d .)
|
354
|
25
|
|
26 reg: ADR(CONSTDATA) 2 (. d = self.newTmp(); ln = self.selector.frame.add_constant($$.children[0].value); self.emit(Adr, dst=[d], others=[ln]); return d .)
|
|
27
|
346
|
28 reg: REGI32 1 (. return $$.value .)
|
352
|
29
|
|
30 reg: CALL 1 (. return self.selector.munchCall($$.value) .)
|