[pypy-svn] r18483 - in pypy/dist/pypy/translator/asm: . i386gen
mwh at codespeak.net
mwh at codespeak.net
Wed Oct 12 16:39:06 CEST 2005
Author: mwh
Date: Wed Oct 12 16:39:04 2005
New Revision: 18483
Modified:
pypy/dist/pypy/translator/asm/genasm.py
pypy/dist/pypy/translator/asm/i386gen/ (props changed)
pypy/dist/pypy/translator/asm/infregmachine.py (contents, props changed)
pypy/dist/pypy/translator/asm/regalloc.py (contents, props changed)
Log:
use the second most straightforward register allocator:
one that spills all the time.
also, a little fixeol-ing
Modified: pypy/dist/pypy/translator/asm/genasm.py
==============================================================================
--- pypy/dist/pypy/translator/asm/genasm.py (original)
+++ pypy/dist/pypy/translator/asm/genasm.py Wed Oct 12 16:39:04 2005
@@ -59,9 +59,16 @@
return r
elif processor == 'ppc':
+ maxregs = 0
+ for insn in g.assembler.instructions:
+ if isinstance(insn, str):
+ continue
+ for r in insn.registers_used():
+ maxregs = max(r, maxregs)
fin = g.assembler.allocate_registers(30)
return make_func(fin.assemble(), 'i',
- 'i'*len(graph.startblock.inputargs))
+ 'i'*len(graph.startblock.inputargs),
+ maxregs)
class FuncGenerator(object):
Modified: pypy/dist/pypy/translator/asm/infregmachine.py
==============================================================================
--- pypy/dist/pypy/translator/asm/infregmachine.py (original)
+++ pypy/dist/pypy/translator/asm/infregmachine.py Wed Oct 12 16:39:04 2005
@@ -127,6 +127,12 @@
A.mr(dest + 2, src + 2)
def EXCH(self, A, a, b):
- A.xor(a, a, b)
- A.xor(b, b, a)
- A.xor(a, a, b)
+ A.xor(a+2, a+2, b+2)
+ A.xor(b+2, b+2, a+2)
+ A.xor(a+2, a+2, b+2)
+
+ def STORESTACK(self, A, s, v):
+ A.stw(v+2, 1, 24+4*s.value)
+
+ def LOADSTACK(self, A, v, s):
+ A.lwz(v+2, 1, 24+4*s.value)
Modified: pypy/dist/pypy/translator/asm/regalloc.py
==============================================================================
--- pypy/dist/pypy/translator/asm/regalloc.py (original)
+++ pypy/dist/pypy/translator/asm/regalloc.py Wed Oct 12 16:39:04 2005
@@ -1,14 +1,24 @@
+from pypy.objspace.flow.model import Constant
def regalloc(insns, nregisters):
-# from pypy.translator.asm.infregmachine import Instruction
+ from pypy.translator.asm.infregmachine import Instruction
- maxregs = 0
+ output = []
for insn in insns:
if isinstance(insn, str):
+ output.append(insn)
continue
- maxregs = max(insn.registers_used() + [0])
-
- if maxregs < 30:
- return insns[:]
-
+ thismap = {}
+ for i, r in enumerate(insn.registers_used()):
+ if r not in thismap:
+ if insn.name != 'LIA':
+ output.append(Instruction('LOADSTACK', (i+1, Constant(r))))
+ thismap[r] = i+1
+ else:
+ thismap[r] = r
+ output.append(insn.renumber(thismap))
+ for r, i in thismap.items():
+ output.append(Instruction('STORESTACK', (Constant(r), i)))
+
+ return output
More information about the Pypy-commit
mailing list