Mercurial > lcfOS
comparison python/target/arminstructionselector.py @ 305:0615b5308710
Updated docs
author | Windel Bouwman |
---|---|
date | Fri, 06 Dec 2013 13:50:38 +0100 |
parents | 6753763d3bec |
children | 56e6ff84f646 |
comparison
equal
deleted
inserted
replaced
304:fa99f36fabb5 | 305:0615b5308710 |
---|---|
1 from ppci import ir | 1 from ppci import ir |
2 from ppci.irmach import AbstractInstruction as makeIns | 2 from ppci.irmach import AbstractInstruction as makeIns |
3 from .basetarget import Label, Comment, Alignment, LabelRef, DebugInfo, Nop | 3 from .basetarget import Label, Comment, Alignment, LabelRef, DebugInfo, Nop |
4 from .instructionselector import InstructionSelector | 4 from .instructionselector import InstructionSelector |
5 from .arminstructions import Orr, Lsl, Str2, Ldr2, Ldr3, B, Bl, Bgt, Blt, Beq | 5 from .arminstructions import Orr, Lsl, Str2, Ldr2, Ldr3 |
6 from .arminstructions import B, Bl, Bgt, Blt, Beq, Bne | |
6 from .arminstructions import Mov2, Mov3 | 7 from .arminstructions import Mov2, Mov3 |
7 from .arminstructions import Add, Sub, Cmp, Sub2, Add2, Mul | 8 from .arminstructions import Add, Sub, Cmp, Sub2, Add2, Mul |
8 from .basetarget import Imm8, Imm7, Imm3 | 9 from .basetarget import Imm8, Imm7, Imm3 |
9 | 10 |
10 | 11 |
92 loc = self.frame.argLoc(i) | 93 loc = self.frame.argLoc(i) |
93 m = ir.Move(loc, a) | 94 m = ir.Move(loc, a) |
94 self.munchStm(m) | 95 self.munchStm(m) |
95 if isinstance(loc, ir.Temp): | 96 if isinstance(loc, ir.Temp): |
96 reguses.append(loc) | 97 reguses.append(loc) |
97 self.emit(Bl(LabelRef(e.f.name)), src=reguses, dst=[self.frame.rv]) | 98 self.emit(Bl(LabelRef(e.f)), src=reguses, dst=[self.frame.rv]) |
98 d = self.newTmp() | 99 d = self.newTmp() |
99 self.move(d, self.frame.rv) | 100 self.move(d, self.frame.rv) |
100 return d | 101 return d |
101 else: | 102 else: |
102 raise NotImplementedError('Expr --> {}'.format(e)) | 103 raise NotImplementedError('Expr --> {}'.format(e)) |
131 b = self.munchExpr(s.b) | 132 b = self.munchExpr(s.b) |
132 self.emit(Cmp, src=[a, b]) | 133 self.emit(Cmp, src=[a, b]) |
133 ntgt = self.targets[s.lab_no] | 134 ntgt = self.targets[s.lab_no] |
134 ytgt = self.targets[s.lab_yes] | 135 ytgt = self.targets[s.lab_yes] |
135 jmp_ins = makeIns(B(LabelRef(s.lab_no.name)), jumps=[ntgt]) | 136 jmp_ins = makeIns(B(LabelRef(s.lab_no.name)), jumps=[ntgt]) |
136 opnames = {'<': Blt, '>':Bgt, '==':Beq} | 137 opnames = {'<': Blt, '>':Bgt, '==':Beq, '!=':Bne} |
137 op = opnames[s.cond](LabelRef(s.lab_yes.name)) | 138 op = opnames[s.cond](LabelRef(s.lab_yes.name)) |
138 self.emit(op, jumps=[ytgt, jmp_ins]) # Explicitely add fallthrough | 139 self.emit(op, jumps=[ytgt, jmp_ins]) # Explicitely add fallthrough |
139 self.emit2(jmp_ins) | 140 self.emit2(jmp_ins) |
140 else: | 141 else: |
141 raise NotImplementedError('Stmt --> {}'.format(s)) | 142 raise NotImplementedError('Stmt --> {}'.format(s)) |