aboutsummaryrefslogtreecommitdiffstats
path: root/test/regression
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@college-de-france.fr>2019-06-17 14:22:22 +0200
committerXavier Leroy <xavierleroy@users.noreply.github.com>2019-06-17 17:19:05 +0200
commited0cfe4b38208f15763f2d1c0372c441a320ea56 (patch)
tree0b1d49bede1a0b9d3d1392809d354fefa5f695ef /test/regression
parent0a4e441a722c6aa9921ff47bd1a411e274e24047 (diff)
downloadcompcert-kvx-ed0cfe4b38208f15763f2d1c0372c441a320ea56.tar.gz
compcert-kvx-ed0cfe4b38208f15763f2d1c0372c441a320ea56.zip
Extended asm: print register names according to their types
When printing an extended asm code fragment, placeholders %n are replaced by register names. Currently we ignore the fact that some assemblers use different register names depending on the width of the data that resides in the register. For example, x86_64 uses %rax for a 64-bit quantity and %eax for a 32-bit quantity, but CompCert always prints %rax in extended asm statements. This is problematic if we want to use 32-bit integer instructions in extended asm, e.g. int x, y; asm("addl %1, %0", "=r"(x), "r"(y)); produces addl %rax, %rdx which is syntactically incorrect. Another example is ARM FP registers: D0 is a double-precision float, but S0 is a single-precision float. This commit partially solves this issue by taking into account the Cminor type of the asm parameter when printing the corresponding register. Continuing the previous example, int x, y; asm("addl %1, %0", "=r"(x), "r"(y)); now produces addl %eax, %edx This is not perfect yet: we use Cminor types, because this is all we have at hand, and not source C types, hence "char" and "short" parameters are still printed like "int" parameters, which is not good for x86. (I.e. we produce %eax where GCC might have produced %al or %ax.) We'll leave this issue open.
Diffstat (limited to 'test/regression')
-rw-r--r--test/regression/extasm.c10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/regression/extasm.c b/test/regression/extasm.c
index babc57f1..83a07a05 100644
--- a/test/regression/extasm.c
+++ b/test/regression/extasm.c
@@ -33,6 +33,7 @@ int main()
void * y;
long long z;
double f;
+ float sf;
char c[16];
/* No inputs, no outputs */
@@ -72,6 +73,15 @@ int main()
#ifdef FAILURES
asm("FAIL4 a:%[a]" : "=r"(x) : [z]"i"(0));
#endif
+ /* One argument of each type */
+ asm("TEST15 int32 %0" : : "r" (x));
+#ifdef SIXTYFOUR
+ asm("TEST15 int64 %0" : : "r" (z));
+#else
+ asm("TEST15 int64 %Q0 / %R0" : : "r" (z));
+#endif
+ asm("TEST15 float64 %0" : : "r" (f));
+ asm("TEST15 float32 %0" : : "r" (sf));
/* Various failures */
#ifdef FAILURES
asm("FAIL5 out:%0,%1" : "=r"(x), "=r"(y));