]> git.ipfire.org Git - thirdparty/valgrind.git/commitdiff
Add tests for amd64 LOOP{,E,NE} insn.
authorJulian Seward <jseward@acm.org>
Tue, 23 Aug 2005 23:52:54 +0000 (23:52 +0000)
committerJulian Seward <jseward@acm.org>
Tue, 23 Aug 2005 23:52:54 +0000 (23:52 +0000)
git-svn-id: svn://svn.valgrind.org/valgrind/trunk@4482

none/tests/amd64/Makefile.am
none/tests/amd64/looper.c [new file with mode: 0644]
none/tests/amd64/looper.stderr.exp [new file with mode: 0644]
none/tests/amd64/looper.stdout.exp [new file with mode: 0644]
none/tests/amd64/looper.vgtest [new file with mode: 0644]

index ab2aa6eec1e3118cd19a6e7ee7b77e3d1b5409d2..3c5728bb524f93bcce597eccf3308f8572c8dd77 100644 (file)
@@ -8,10 +8,11 @@ EXTRA_DIST = $(noinst_SCRIPTS) \
        $(addsuffix .stderr.exp,$(INSN_TESTS)) \
        $(addsuffix .stdout.exp,$(INSN_TESTS)) \
        $(addsuffix .vgtest,$(INSN_TESTS)) \
+       looper.stderr.exp looper.stdout.exp looper.vgtest \
         smc1.stderr.exp smc1.stdout.exp smc1.vgtest
 
 check_PROGRAMS = \
-       $(INSN_TESTS) smc1
+       $(INSN_TESTS) looper smc1
 
 AM_CFLAGS   = $(WERROR) -Winline -Wall -Wshadow -g -I$(top_srcdir)/include
 AM_CXXFLAGS = $(AM_CFLAGS)
diff --git a/none/tests/amd64/looper.c b/none/tests/amd64/looper.c
new file mode 100644 (file)
index 0000000..cb7f5cb
--- /dev/null
@@ -0,0 +1,82 @@
+
+#include <stdio.h>
+
+long long int arg = 0;
+long long int res = 0;
+
+extern void loop_plain ( void );
+asm("\n"
+".text\n"
+".globl loop_plain\n"
+"loop_plain:\n"
+"\tpushq %rcx\n"
+"\tmovq $999, %rax\n"
+"\tmovq arg, %rcx\n"
+
+".Lmn123plain:\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+"\tloop .Lmn123plain\n"
+
+"\tmovq %rax, res\n"
+"\tpopq %rcx\n"
+"\tret\n"
+);
+
+extern void loop_ne ( void );
+asm("\n"
+".text\n"
+".globl loop_ne\n"
+"loop_ne:\n"
+"\tpushq %rcx\n"
+"\tmovq $999, %rax\n"
+"\tmovq arg, %rcx\n"
+
+".Lmn123ne:\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+"\tloopne .Lmn123ne\n"
+
+"\tmovq %rax, res\n"
+"\tpopq %rcx\n"
+"\tret\n"
+);
+
+extern void loop_e ( void );
+asm("\n"
+".text\n"
+".globl loop_e\n"
+"loop_e:\n"
+"\tpushq %rcx\n"
+"\tmovq $999, %rax\n"
+"\tmovq arg, %rcx\n"
+
+".Lmn123e:\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+"\tdecq %rax\n"
+/* invert the Z flag */
+"\tpushfq\n"
+"\txorq $64, 0(%rsp)\n"
+"\tpopfq\n"
+"\tloope .Lmn123e\n"
+
+"\tmovq %rax, res\n"
+"\tpopq %rcx\n"
+"\tret\n"
+);
+
+int main ( void )
+{
+   res = 0; arg = 10;  loop_plain(); printf("res = %lld\n", res);
+
+   res = 0; arg = 10;  loop_ne();    printf("res = %lld\n", res);
+   res = 0; arg = 500; loop_ne();    printf("res = %lld\n", res);
+
+   res = 0; arg = 10;  loop_e();     printf("res = %lld\n", res);
+   res = 0; arg = 500; loop_e();     printf("res = %lld\n", res);
+
+   return 0;
+}
diff --git a/none/tests/amd64/looper.stderr.exp b/none/tests/amd64/looper.stderr.exp
new file mode 100644 (file)
index 0000000..139597f
--- /dev/null
@@ -0,0 +1,2 @@
+
+
diff --git a/none/tests/amd64/looper.stdout.exp b/none/tests/amd64/looper.stdout.exp
new file mode 100644 (file)
index 0000000..d57e264
--- /dev/null
@@ -0,0 +1,5 @@
+res = 969
+res = 969
+res = 0
+res = 969
+res = 0
diff --git a/none/tests/amd64/looper.vgtest b/none/tests/amd64/looper.vgtest
new file mode 100644 (file)
index 0000000..25f35c1
--- /dev/null
@@ -0,0 +1 @@
+prog: looper