From: "Alex Bennée" <alex.bennee@linaro.org>
To: qemu-devel@nongnu.org
Cc: famz@redhat.com, f4bug@amsat.org,
"Theodore Dubois" <tblodt@icloud.com>,
"Alex Bennée" <alex.bennee@linaro.org>,
"Paolo Bonzini" <pbonzini@redhat.com>,
"Richard Henderson" <rth@twiddle.net>,
"Eduardo Habkost" <ehabkost@redhat.com>
Subject: [Qemu-devel] [PATCH v2 2/3] tests/tcg: make test-i386 test program compile on clang
Date: Tue, 9 Oct 2018 15:59:32 +0100 [thread overview]
Message-ID: <20181009145933.18925-3-alex.bennee@linaro.org> (raw)
In-Reply-To: <20181009145933.18925-1-alex.bennee@linaro.org>
From: Theodore Dubois <tblodt@icloud.com>
Clang's assembler is slightly incompatible with GCC's assembler, which
caused the program to not compile on Clang for these reasons:
- The "q" constraint was specified for an argument to the set
instruction, which didn't work because Clang chose the esi register,
which has no 8-bit form on i386.
- Clang doesn't support size suffixes on the loop instructions.
https://bugs.llvm.org/show_bug.cgi?id=33741
- Clang requires a size suffix on the fist instruction.
- Clang doesn't support specifying segment prefixes before the
instruction, and requires specifying them on the address.
- The arguments to the bound instruction are in the wrong order on
Clang. https://bugs.llvm.org/show_bug.cgi?id=27653
Signed-off-by: Theodore Dubois <tblodt@icloud.com>
[AJB: tweaked title, add bugref]
Signed-off-by: Alex Bennée <alex.bennee@linaro.org>
---
tests/tcg/i386/test-i386.c | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/tests/tcg/i386/test-i386.c b/tests/tcg/i386/test-i386.c
index a29b41e764..c5f67000e4 100644
--- a/tests/tcg/i386/test-i386.c
+++ b/tests/tcg/i386/test-i386.c
@@ -368,7 +368,7 @@ void test_lea(void)
asm("movl $0, %0\n\t"\
"cmpl %2, %1\n\t"\
"set" JCC " %b0\n\t"\
- : "=r" (res)\
+ : "=q" (res)\
: "r" (v1), "r" (v2));\
printf("%-10s %d\n", "set" JCC, res);\
if (TEST_CMOV) {\
@@ -490,15 +490,23 @@ void test_loop(void)
#if !defined(__x86_64__)
TEST_LOOP("jcxz");
+#if !defined(__clang__)
TEST_LOOP("loopw");
TEST_LOOP("loopzw");
TEST_LOOP("loopnzw");
+#endif
#endif
TEST_LOOP("jecxz");
+#if !defined(__clang__)
TEST_LOOP("loopl");
TEST_LOOP("loopzl");
TEST_LOOP("loopnzl");
+#else
+ TEST_LOOP("loop");
+ TEST_LOOP("loopz");
+ TEST_LOOP("loopnz");
+#endif
}
#undef CC_MASK
@@ -866,7 +874,7 @@ void test_fcvt(double a)
uint16_t val16;
val16 = (fpuc & ~0x0c00) | (i << 10);
asm volatile ("fldcw %0" : : "m" (val16));
- asm volatile ("fist %0" : "=m" (wa) : "t" (a));
+ asm volatile ("fists %0" : "=m" (wa) : "t" (a));
asm volatile ("fistl %0" : "=m" (ia) : "t" (a));
asm volatile ("fistpll %0" : "=m" (lla) : "t" (a) : "st");
asm volatile ("frndint ; fstl %0" : "=m" (ra) : "t" (a));
@@ -1317,12 +1325,12 @@ void test_segs(void)
seg_data1[1] = 0xaa;
seg_data2[1] = 0x55;
- asm volatile ("fs movzbl 0x1, %0" : "=r" (res));
+ asm volatile ("movzbl %%fs:0x1, %0" : "=r" (res));
printf("FS[1] = %02x\n", res);
asm volatile ("pushl %%gs\n"
"movl %1, %%gs\n"
- "gs movzbl 0x1, %0\n"
+ "movzbl %%gs:0x1, %0\n"
"popl %%gs\n"
: "=r" (res)
: "r" (MK_SEL(2)));
@@ -1763,7 +1771,11 @@ void test_exceptions(void)
/* bound exception */
tab[0] = 1;
tab[1] = 10;
+#if defined(__clang__)
+ asm volatile ("bound %1, %0" : : "r" (11), "m" (tab[0]));
+#else
asm volatile ("bound %0, %1" : : "r" (11), "m" (tab[0]));
+#endif
}
#endif
--
2.17.1
next prev parent reply other threads:[~2018-10-09 15:00 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-10-09 14:59 [Qemu-devel] [PATCH v2 0/3] Travis tweaks and tcg test fixes Alex Bennée
2018-10-09 14:59 ` [Qemu-devel] [PATCH v2 1/3] .travis.yml: split MacOSX builds and reduce target list Alex Bennée
2018-10-09 14:59 ` Alex Bennée [this message]
2018-10-09 14:59 ` [Qemu-devel] [PATCH v2 3/3] tests/tcg: disable enterN insn tests for test-i386 with clang Alex Bennée
2018-10-09 15:48 ` Paolo Bonzini
2018-10-09 16:35 ` Alex Bennée
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20181009145933.18925-3-alex.bennee@linaro.org \
--to=alex.bennee@linaro.org \
--cc=ehabkost@redhat.com \
--cc=f4bug@amsat.org \
--cc=famz@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=rth@twiddle.net \
--cc=tblodt@icloud.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).