[pypy-commit] pypy ppc-jit-backend: Added some more assembler tests.

hager noreply at buildbot.pypy.org
Mon Jul 18 17:37:47 CEST 2011


Author: hager <sven.hager at uni-duesseldorf.de>
Branch: ppc-jit-backend
Changeset: r45716:77eb70dec1b5
Date: 2011-07-18 11:17 +0200
http://bitbucket.org/pypy/pypy/changeset/77eb70dec1b5/

Log:	Added some more assembler tests.

diff --git a/pypy/jit/backend/ppc/ppcgen/test/test_ppc.py b/pypy/jit/backend/ppc/ppcgen/test/test_ppc.py
--- a/pypy/jit/backend/ppc/ppcgen/test/test_ppc.py
+++ b/pypy/jit/backend/ppc/ppcgen/test/test_ppc.py
@@ -18,6 +18,7 @@
         inst = a.insts[-1]
         assert A.add.match(inst.assemble())
 
+# Testing simple assembler instructions
 class TestAssemble(object):
     def setup_class(cls):
         if autodetect_main_model() not in ["ppc", "ppc64"]: 
@@ -41,14 +42,66 @@
     def test_load_word(self):
         a = MyPPCAssembler()
         word = 12341234
+
         a.load_word(10, word)
         a.mtctr(10)
         a.mfctr(11)
         a.mr(3, 11)
         a.blr()
+
         f = a.assemble()
         assert f() == word
 
+    def test_add_reg(self):
+        a = MyPPCAssembler()
+        word1 = 11111111
+        word2 = 22222222
+
+        a.load_word(10, word1)
+        a.load_word(11, word2)
+        a.add(12, 10, 11)
+        a.mr(3, 12)
+        a.blr()
+
+        f = a.assemble()
+        assert f() == word1 + word2
+
+    def test_add_pos_and_neg(self):
+        a = MyPPCAssembler()
+        word1 = 2000
+        word2 = -3000
+
+        a.load_word(10, word1)
+        a.load_word(11, word2)
+        a.add(3, 10, 11)
+        a.blr()
+
+        f = a.assemble()
+        assert f() == -1000
+
+    def test_sub_imm(self):
+        a = MyPPCAssembler()
+        
+        a.li(3, 10)
+        a.subi(3, 3, 3)
+        a.blr()
+
+        f = a.assemble()
+        assert f() == 7
+
+    def test_sub_reg(self):
+        a = MyPPCAssembler()
+        word1 = 123435
+        word2 = 76457
+
+        a.load_word(5, word1)
+        a.load_word(6, word2)
+        a.sub(3, 5, 6)
+        a.blr()
+
+        f = a.assemble()
+        assert f() == word1 - word2
+
     def test_call_function(self):
         functype =  lltype.Ptr(lltype.FuncType([lltype.Signed], lltype.Signed))
         call_addr = rffi.cast(lltype.Signed, llhelper(functype, func))


More information about the pypy-commit mailing list