322
|
1
|
342
|
2 from ppci.target.thumb.instructions import Orr, Lsl, Str2, Ldr2, Ldr3
|
|
3 from ppci.target.thumb.instructions import B, Bl, Bgt, Blt, Beq, Bne
|
|
4 from ppci.target.thumb.instructions import Mov2, Mov3, Sub3
|
|
5 from ppci.target.thumb.instructions import Add3, Sub, Cmp, Sub2, Add2, Mul
|
322
|
6
|
|
7 %%
|
|
8
|
323
|
9 %terminal ADDI32 SUBI32 MULI32
|
|
10 %terminal ORI32 SHLI32
|
322
|
11 %terminal CONSTI32 MEMI32 REGI32 CALL
|
323
|
12 %terminal MOVI32
|
322
|
13
|
|
14 %%
|
|
15
|
323
|
16
|
341
|
17 reg: ADDI32(reg, reg) 2 (. d = self.newTmp(); self.emit(Add3, dst=[d], src=[$1, $2]); return d .)
|
342
|
18 reg: SUBI32(reg, reg) 2 (. d = self.newTmp(); self.emit(Sub3, dst=[d], src=[$1, $2]); return d .)
|
323
|
19 reg: ORI32(reg, reg) 2 (. d = self.newTmp(); self.selector.move(d, $1); self.emit(Orr, dst=[], src=[d, $2]); return d .)
|
|
20 reg: SHLI32(reg, reg) 2 (. d = self.newTmp(); self.selector.move(d, $1); self.emit(Lsl, dst=[], src=[d, $2]); return d .)
|
|
21 reg: MULI32(reg, reg) 2 (. d = self.newTmp(); self.selector.move(d, $1); self.emit(Mul, dst=[d], src=[$2, d]); return d .)
|
322
|
22
|
342
|
23 reg: CONSTI32 3 (. d = self.newTmp(); ln = self.selector.frame.addConstant($$.value); self.emit(Ldr3, dst=[d], others=[ln]); return d .)
|
323
|
24 reg: MEMI32(reg) 4 (. d = self.newTmp(); self.emit(Ldr2, dst=[d], src=[$1], others=[0]); return d .)
|
|
25 reg: REGI32 1 (. return $$.value .)
|
|
26 reg: CALL 1 (. return self.selector.munchCall($$.value) .)
|
322
|
27
|
|
28
|
323
|
29 stmt: MOVI32(MEMI32(addr), reg) 3 (. self.emit(Str2, src=[$1, $2]) .)
|
|
30
|
|
31 addr: reg 2 (. .)
|