aboutsummaryrefslogtreecommitdiff
path: root/tests/tcg
diff options
context:
space:
mode:
Diffstat (limited to 'tests/tcg')
-rw-r--r--tests/tcg/x86_64/Makefile.target3
-rw-r--r--tests/tcg/x86_64/adox.c69
2 files changed, 72 insertions, 0 deletions
diff --git a/tests/tcg/x86_64/Makefile.target b/tests/tcg/x86_64/Makefile.target
index 4eac78293f..e64aab1b81 100644
--- a/tests/tcg/x86_64/Makefile.target
+++ b/tests/tcg/x86_64/Makefile.target
@@ -12,11 +12,14 @@ ifeq ($(filter %-linux-user, $(TARGET)),$(TARGET))
X86_64_TESTS += vsyscall
X86_64_TESTS += noexec
X86_64_TESTS += cmpxchg
+X86_64_TESTS += adox
TESTS=$(MULTIARCH_TESTS) $(X86_64_TESTS) test-x86_64
else
TESTS=$(MULTIARCH_TESTS)
endif
+adox: CFLAGS=-O2
+
run-test-i386-ssse3: QEMU_OPTS += -cpu max
run-plugin-test-i386-ssse3-%: QEMU_OPTS += -cpu max
diff --git a/tests/tcg/x86_64/adox.c b/tests/tcg/x86_64/adox.c
new file mode 100644
index 0000000000..36be644c8b
--- /dev/null
+++ b/tests/tcg/x86_64/adox.c
@@ -0,0 +1,69 @@
+/* See if ADOX give expected results */
+
+#include <assert.h>
+#include <stdint.h>
+#include <stdbool.h>
+
+static uint64_t adoxq(bool *c_out, uint64_t a, uint64_t b, bool c)
+{
+ asm ("addl $0x7fffffff, %k1\n\t"
+ "adoxq %2, %0\n\t"
+ "seto %b1"
+ : "+r"(a), "=&r"(c) : "r"(b), "1"((int)c));
+ *c_out = c;
+ return a;
+}
+
+static uint64_t adoxl(bool *c_out, uint64_t a, uint64_t b, bool c)
+{
+ asm ("addl $0x7fffffff, %k1\n\t"
+ "adoxl %k2, %k0\n\t"
+ "seto %b1"
+ : "+r"(a), "=&r"(c) : "r"(b), "1"((int)c));
+ *c_out = c;
+ return a;
+}
+
+int main()
+{
+ uint64_t r;
+ bool c;
+
+ r = adoxq(&c, 0, 0, 0);
+ assert(r == 0);
+ assert(c == 0);
+
+ r = adoxl(&c, 0, 0, 0);
+ assert(r == 0);
+ assert(c == 0);
+
+ r = adoxl(&c, 0x100000000, 0, 0);
+ assert(r == 0);
+ assert(c == 0);
+
+ r = adoxq(&c, 0, 0, 1);
+ assert(r == 1);
+ assert(c == 0);
+
+ r = adoxl(&c, 0, 0, 1);
+ assert(r == 1);
+ assert(c == 0);
+
+ r = adoxq(&c, -1, -1, 0);
+ assert(r == -2);
+ assert(c == 1);
+
+ r = adoxl(&c, -1, -1, 0);
+ assert(r == 0xfffffffe);
+ assert(c == 1);
+
+ r = adoxq(&c, -1, -1, 1);
+ assert(r == -1);
+ assert(c == 1);
+
+ r = adoxl(&c, -1, -1, 1);
+ assert(r == 0xffffffff);
+ assert(c == 1);
+
+ return 0;
+}