about summary refs log tree commit diff stats
path: root/test/arch/x86/unit
diff options
context:
space:
mode:
Diffstat (limited to 'test/arch/x86/unit')
-rw-r--r--test/arch/x86/unit/mn_pcmpeq.py64
-rw-r--r--test/arch/x86/unit/mn_pextr.py25
-rw-r--r--test/arch/x86/unit/mn_pinsr.py25
-rw-r--r--test/arch/x86/unit/mn_pmaxu.py25
-rw-r--r--test/arch/x86/unit/mn_pminu.py25
-rw-r--r--test/arch/x86/unit/mn_pmovmskb.py26
-rw-r--r--test/arch/x86/unit/mn_pshufb.py25
-rw-r--r--test/arch/x86/unit/mn_psrl_psll.py55
-rw-r--r--test/arch/x86/unit/mn_punpck.py124
9 files changed, 394 insertions, 0 deletions
diff --git a/test/arch/x86/unit/mn_pcmpeq.py b/test/arch/x86/unit/mn_pcmpeq.py
new file mode 100644
index 00000000..a8774cbc
--- /dev/null
+++ b/test/arch/x86/unit/mn_pcmpeq.py
@@ -0,0 +1,64 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PCMPEQB(Asm_Test):
+    TXT = '''
+    main:
+       CALL    next
+       .byte 0x88, 0x78, 0x66, 0x56, 0x44, 0x3F, 0xFF, 0x11
+       .byte 0x89, 0x77, 0x66, 0x55, 0xF9, 0x33, 0x22, 0x11
+    next:
+       POP     EBP
+       MOVQ    MM0, QWORD PTR [EBP]
+       MOVQ    MM1, MM0
+       PCMPEQB MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x11FF3F4456667888
+        assert self.myjit.cpu.MM1 == 0xFF00000000FF0000
+
+
+class Test_PCMPEQW(Asm_Test):
+    TXT = '''
+    main:
+       CALL    next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x3F, 0x22, 0x11
+       .byte 0x89, 0x77, 0x66, 0x55, 0xF9, 0x33, 0x22, 0x11
+    next:
+       POP     EBP
+       MOVQ    MM0, QWORD PTR [EBP]
+       MOVQ    MM1, MM0
+       PCMPEQW MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x11223F4455667788
+        assert self.myjit.cpu.MM1 == 0xFFFF0000FFFF0000
+
+
+
+class Test_PCMPEQD(Asm_Test):
+    TXT = '''
+    main:
+       CALL    next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x3F, 0x22, 0x11
+       .byte 0x88, 0x77, 0x66, 0x55, 0xF9, 0x33, 0x22, 0x11
+    next:
+       POP     EBP
+       MOVQ    MM0, QWORD PTR [EBP]
+       MOVQ    MM1, MM0
+       PCMPEQD MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x11223F4455667788
+        assert self.myjit.cpu.MM1 == 0x00000000FFFFFFFF
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PCMPEQB, Test_PCMPEQW, Test_PCMPEQD]]
diff --git a/test/arch/x86/unit/mn_pextr.py b/test/arch/x86/unit/mn_pextr.py
new file mode 100644
index 00000000..eb724cf9
--- /dev/null
+++ b/test/arch/x86/unit/mn_pextr.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PEXTRB(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01
+    next:
+       POP       EBP
+       MOV       EAX, 0xFFFFFFFF
+       MOVQ      MM0, QWORD PTR [EBP]
+       PEXTRW    EAX, MM0, 2
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.EAX == 0x3344
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PEXTRB]]
diff --git a/test/arch/x86/unit/mn_pinsr.py b/test/arch/x86/unit/mn_pinsr.py
new file mode 100644
index 00000000..b7a86d2d
--- /dev/null
+++ b/test/arch/x86/unit/mn_pinsr.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PINSRB(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PINSRW    MM1, QWORD PTR [EBP+0x8], 2
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0x1122070855667788
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PINSRB]]
diff --git a/test/arch/x86/unit/mn_pmaxu.py b/test/arch/x86/unit/mn_pmaxu.py
new file mode 100644
index 00000000..08e54c03
--- /dev/null
+++ b/test/arch/x86/unit/mn_pmaxu.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PMAXU(Asm_Test):
+    TXT = '''
+    main:
+       CALL   next
+       .byte 0x88, 0x76, 0x66, 0x54, 0x44, 0x32, 0x00, 0x10
+       .byte 0x87, 0x77, 0x66, 0x55, 0x40, 0x33, 0x22, 0x11
+    next:
+       POP    EBP
+       MOVQ   MM0, QWORD PTR [EBP]
+       MOVQ   MM1, MM0
+       PMAXUB MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1000324454667688
+        assert self.myjit.cpu.MM1 == 0x1122334455667788
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PMAXU]]
diff --git a/test/arch/x86/unit/mn_pminu.py b/test/arch/x86/unit/mn_pminu.py
new file mode 100644
index 00000000..38a29787
--- /dev/null
+++ b/test/arch/x86/unit/mn_pminu.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PMINU(Asm_Test):
+    TXT = '''
+    main:
+       CALL   next
+       .byte 0x88, 0x78, 0x66, 0x56, 0x44, 0x3F, 0xFF, 0x1F
+       .byte 0x89, 0x77, 0x66, 0x55, 0xF9, 0x33, 0x22, 0x11
+    next:
+       POP    EBP
+       MOVQ   MM0, QWORD PTR [EBP]
+       MOVQ   MM1, MM0
+       PMINUB MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1FFF3F4456667888
+        assert self.myjit.cpu.MM1 == 0x1122334455667788
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PMINU]]
diff --git a/test/arch/x86/unit/mn_pmovmskb.py b/test/arch/x86/unit/mn_pmovmskb.py
new file mode 100644
index 00000000..97435794
--- /dev/null
+++ b/test/arch/x86/unit/mn_pmovmskb.py
@@ -0,0 +1,26 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PMOVMSKB(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0xE6, 0x55, 0xC4, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOV       EAX, 0xFFFFFFFF
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PMOVMSKB  EAX, MM1
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x112233C455E67788
+        assert self.myjit.cpu.MM1 == 0x112233C455E67788
+        assert self.myjit.cpu.EAX == 0x00000015
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PMOVMSKB,]]
diff --git a/test/arch/x86/unit/mn_pshufb.py b/test/arch/x86/unit/mn_pshufb.py
new file mode 100644
index 00000000..187b2f72
--- /dev/null
+++ b/test/arch/x86/unit/mn_pshufb.py
@@ -0,0 +1,25 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PSHUFB(Asm_Test):
+    TXT = '''
+    main:
+       CALL   next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x7, 0x6, 0x5, 0x4, 0x3, 0x2, 0x1, 0x0
+    next:
+       POP    EBP
+       MOVQ   MM0, QWORD PTR [EBP]
+       MOVQ   MM1, MM0
+       PSHUFB MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788L
+        assert self.myjit.cpu.MM1 == 0x8877665544332211L
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PSHUFB]]
diff --git a/test/arch/x86/unit/mn_psrl_psll.py b/test/arch/x86/unit/mn_psrl_psll.py
new file mode 100644
index 00000000..93a356f7
--- /dev/null
+++ b/test/arch/x86/unit/mn_psrl_psll.py
@@ -0,0 +1,55 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PSRL(Asm_Test):
+    TXT = '''
+    main:
+       CALL   next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+    next:
+       POP    EBP
+       MOVQ   MM0, QWORD PTR [EBP]
+       MOVQ   MM1, MM0
+       MOVQ   MM2, MM0
+       MOVQ   MM3, MM0
+       PSRLW  MM1, QWORD PTR [EBP+0x8]
+       PSRLD  MM2, QWORD PTR [EBP+0x8]
+       PSRLQ  MM3, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788L
+        assert self.myjit.cpu.MM1 == 0x0112033405560778L
+        assert self.myjit.cpu.MM2 == 0x0112233405566778L
+        assert self.myjit.cpu.MM3 == 0x0112233445566778L
+
+class Test_PSLL(Asm_Test):
+    TXT = '''
+    main:
+       CALL   next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x4, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0
+    next:
+       POP    EBP
+       MOVQ   MM0, QWORD PTR [EBP]
+       MOVQ   MM1, MM0
+       MOVQ   MM2, MM0
+       MOVQ   MM3, MM0
+       PSLLW  MM1, QWORD PTR [EBP+0x8]
+       PSLLD  MM2, QWORD PTR [EBP+0x8]
+       PSLLQ  MM3, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788L
+        assert self.myjit.cpu.MM1 == 0x1220344056607880L
+        assert self.myjit.cpu.MM2 == 0x1223344056677880L
+        assert self.myjit.cpu.MM3 == 0x1223344556677880L
+
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PSRL, Test_PSLL]]
diff --git a/test/arch/x86/unit/mn_punpck.py b/test/arch/x86/unit/mn_punpck.py
new file mode 100644
index 00000000..84d86c32
--- /dev/null
+++ b/test/arch/x86/unit/mn_punpck.py
@@ -0,0 +1,124 @@
+#! /usr/bin/env python
+from asm_test import Asm_Test
+import sys
+
+class Test_PUNPCKHBW(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKHBW MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xAA11BB22CC33DD44
+
+
+class Test_PUNPCKHWD(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKHWD MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xAABB1122CCDD3344
+
+
+
+class Test_PUNPCKHDQ(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKHDQ MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xAABBCCDD11223344
+
+
+
+
+class Test_PUNPCKLBW(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKLBW MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xEE55FF6602770188
+
+
+class Test_PUNPCKLWD(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKLWD MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xEEFF556602017788
+
+
+
+class Test_PUNPCKLDQ(Asm_Test):
+    TXT = '''
+    main:
+       CALL      next
+       .byte 0x88, 0x77, 0x66, 0x55, 0x44, 0x33, 0x22, 0x11
+       .byte 0x01, 0x02, 0xFF, 0xEE, 0xDD, 0xCC, 0xBB, 0xAA
+    next:
+       POP       EBP
+       MOVQ      MM0, QWORD PTR [EBP]
+       MOVQ      MM1, MM0
+       PUNPCKLDQ MM1, QWORD PTR [EBP+0x8]
+       RET
+    '''
+
+    def check(self):
+        assert self.myjit.cpu.MM0 == 0x1122334455667788
+        assert self.myjit.cpu.MM1 == 0xEEFF020155667788
+
+if __name__ == "__main__":
+    [test()() for test in [Test_PUNPCKHBW, Test_PUNPCKHWD, Test_PUNPCKHDQ,
+                           Test_PUNPCKLBW, Test_PUNPCKLWD, Test_PUNPCKLDQ,]]