diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2021-01-11 18:04:25 +0100 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2021-01-14 14:54:33 +0100 |
commit | 88567ce6d247562a9fa9151eaa32f7ad63ea37c0 (patch) | |
tree | af67d85428f969b60028999fba041156bf2c18bd /test/regression | |
parent | 522285d1163523b02a1972b99d71c08552cd9c7b (diff) | |
download | compcert-88567ce6d247562a9fa9151eaa32f7ad63ea37c0.tar.gz compcert-88567ce6d247562a9fa9151eaa32f7ad63ea37c0.zip |
RISC-V: fix FP calling conventions
This is a follow-up to e81d015e3.
In the RISC-V ABI, FP arguments to functions are passed in integer registers
(or pairs of integer registers) in two cases:
1- the FP argument is a variadic argument
2- the FP argument is a fixed argument but all 8 FP registers reserved for
parameter passing have been used already.
The previous implementation handled only case 1, with some problems.
This commit implements both 1 and 2. To this end, 8 extra FP
caller-save registers are used to hold the values of the FP arguments
that must be passed in integer registers. Fixup code moves these FP
registers to integer registers / register pairs. Symmetrically, at
function entry, the integer registers / register pairs are moved back
to the FP registers.
8 extra FP registers is enough because there are only 8 integer
registers used for parameter passing, so at most 8 FP arguments may
need to be moved to integer registers.
Diffstat (limited to 'test/regression')
-rw-r--r-- | test/regression/Results/varargs2 | 2 | ||||
-rw-r--r-- | test/regression/varargs2.c | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/test/regression/Results/varargs2 b/test/regression/Results/varargs2 index 050b6331..9e77da1b 100644 --- a/test/regression/Results/varargs2 +++ b/test/regression/Results/varargs2 @@ -10,5 +10,5 @@ Twice: -1 1.23 With va_copy: -1 1.23 With va_copy: -1 1.23 With extra args: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746 -With extra FP args: 123456789012345 & 3.141592654 & 2.718281746 +With extra FP args: 3.141592654 & 2.718281746 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 42 va_list compatibility: x & Hello, world! & 42 & 123456789012345 & 3.141592654 & 2.718281746 diff --git a/test/regression/varargs2.c b/test/regression/varargs2.c index 32140d5c..d64509e5 100644 --- a/test/regression/varargs2.c +++ b/test/regression/varargs2.c @@ -154,11 +154,11 @@ int main() 123456789012345LL, 3.141592654, 2.71828182); - miniprintf_float(0.0, 1.0, - "With extra FP args: %l & %e & %f\n", - 123456789012345LL, + miniprintf_float(0.0, 0.5, + "With extra FP args: %e & %f & %e & %e & %e & %e & %e & %e & %e & %e & %d\n", 3.141592654, - 2.71828182); + 2.71828182, + 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 42); printf_compat("va_list compatibility: %c & %s & %d & %lld & %.10g & %.10g\n", 'x', "Hello, world!", |