Commit eb774d8d by Nigel Stephens Committed by Jeff Law

mips16.S: Various changes to make it work with -msingle-float and -EL.

        *  mips/mips16.S: Various changes to make it work with -msingle-float
        and -EL.

From-SVN: r17293
parent 2bcb2ab3
Sun Jan 4 20:24:00 1998 Nigel Stephens <nigel@algor.co.uk>
* mips/mips16.S: Various changes to make it work with -msingle-float
and -EL.
Sun Jan 4 14:25:18 1998 Gavin Koch <gavin@cygnus.com> Sun Jan 4 14:25:18 1998 Gavin Koch <gavin@cygnus.com>
Ian Lance Taylor <ian@cygnus.com> Ian Lance Taylor <ian@cygnus.com>
Jeff Law <law@cygnus.com> Jeff Law <law@cygnus.com>
......
/* mips16 floating point support code /* mips16 floating point support code
Copyright (C) 1996, 1997 Free Software Foundation, Inc. Copyright (C) 1996, 1997, 1998 Free Software Foundation, Inc.
Contributed by Cygnus Support Contributed by Cygnus Support
This file is free software; you can redistribute it and/or modify it This file is free software; you can redistribute it and/or modify it
...@@ -81,6 +81,25 @@ SFOP(__mips16_mulsf3, mul.s) ...@@ -81,6 +81,25 @@ SFOP(__mips16_mulsf3, mul.s)
SFOP(__mips16_divsf3, div.s) SFOP(__mips16_divsf3, div.s)
#endif #endif
#define SFOP2(NAME, OPCODE) \
STARTFN (NAME); \
.set noreorder; \
mtc1 $4,$f0; \
nop; \
OPCODE $f0,$f0; \
mfc1 $2,$f0; \
j $31; \
nop; \
.set reorder; \
ENDFN (NAME)
#ifdef L_m16negsf2
SFOP2(__mips16_negsf2, neg.s)
#endif
#ifdef L_m16abssf2
SFOP2(__mips16_abssf2, abs.s)
#endif
/* Single precision comparisons. */ /* Single precision comparisons. */
/* This macro defines a function which loads two single precision /* This macro defines a function which loads two single precision
...@@ -161,6 +180,8 @@ STARTFN (__mips16_fixsfsi) ...@@ -161,6 +180,8 @@ STARTFN (__mips16_fixsfsi)
ENDFN (__mips16_fixsfsi) ENDFN (__mips16_fixsfsi)
#endif #endif
#if !defined(__mips_single_float) && !defined(__SINGLE_FLOAT)
/* The double precision operations. We need to use different code /* The double precision operations. We need to use different code
based on the preprocessor symbol __mips64, because the way in which based on the preprocessor symbol __mips64, because the way in which
double precision values will change. Without __mips64, the value double precision values will change. Without __mips64, the value
...@@ -169,28 +190,41 @@ STARTFN (__mips16_fixsfsi) ...@@ -169,28 +190,41 @@ STARTFN (__mips16_fixsfsi)
/* Load the first double precision operand. */ /* Load the first double precision operand. */
#ifdef __mips64 #if defined(__mips64)
#define LDDBL1 dmtc1 $4,$f0 #define LDDBL1 dmtc1 $4,$f12
#else #elif defined(__mipsfp64)
#define LDDBL1 mtc1 $4,$f1; mtc1 $5,$f0 #define LDDBL1 sw $4,0($29); sw $5,4($29); l.d $f12,0($29)
#elif defined(__MIPSEB__)
#define LDDBL1 mtc1 $4,$f13; mtc1 $5,$f12
#else
#define LDDBL1 mtc1 $4,$f12; mtc1 $5,$f13
#endif #endif
/* Load the second double precision operand. */ /* Load the second double precision operand. */
#ifdef __mips64 #if defined(__mips64)
#define LDDBL2 dmtc1 $5,$f2 /* XXX this should be $6 for Algo arg passing model */
#else #define LDDBL2 dmtc1 $5,$f14
#define LDDBL2 mtc1 $6,$f3; mtc1 $7,$f2 #elif defined(__mipsfp64)
#endif #define LDDBL2 sw $6,8($29); sw $7,12($29); l.d $f14,8($29)
#elif defined(__MIPSEB__)
#define LDDBL2 mtc1 $6,$f15; mtc1 $7,$f14
#else
#define LDDBL2 mtc1 $6,$f14; mtc1 $7,$f15
#endif
/* Move the double precision return value to the right place. */ /* Move the double precision return value to the right place. */
#ifdef __mips64 #if defined(__mips64)
#define RETDBL dmfc1 $2,$f0 #define RETDBL dmfc1 $2,$f0
#else #elif defined(__mipsfp64)
#define RETDBL s.d $f0,0($29); lw $2,0($29); lw $3,4($29)
#elif defined(__MIPSEB__)
#define RETDBL mfc1 $2,$f1; mfc1 $3,$f0 #define RETDBL mfc1 $2,$f1; mfc1 $3,$f0
#else
#define RETDBL mfc1 $2,$f0; mfc1 $3,$f1
#endif #endif
/* Double precision math. */ /* Double precision math. */
/* This macro defines a function which loads two double precision /* This macro defines a function which loads two double precision
...@@ -203,7 +237,7 @@ STARTFN (NAME); \ ...@@ -203,7 +237,7 @@ STARTFN (NAME); \
LDDBL1; \ LDDBL1; \
LDDBL2; \ LDDBL2; \
nop; \ nop; \
OPCODE $f0,$f0,$f2; \ OPCODE $f0,$f12,$f14; \
RETDBL; \ RETDBL; \
j $31; \ j $31; \
nop; \ nop; \
...@@ -223,14 +257,34 @@ DFOP(__mips16_muldf3, mul.d) ...@@ -223,14 +257,34 @@ DFOP(__mips16_muldf3, mul.d)
DFOP(__mips16_divdf3, div.d) DFOP(__mips16_divdf3, div.d)
#endif #endif
#define DFOP2(NAME, OPCODE) \
STARTFN (NAME); \
.set noreorder; \
LDDBL1; \
nop; \
OPCODE $f0,$f12; \
RETDBL; \
j $31; \
nop; \
.set reorder; \
ENDFN (NAME)
#ifdef L_m16negdf2
DFOP2(__mips16_negdf2, neg.d)
#endif
#ifdef L_m16absdf2
DFOP2(__mips16_absdf2, abs.d)
#endif
/* Conversions between single and double precision. */ /* Conversions between single and double precision. */
#ifdef L_m16extsfdf2 #ifdef L_m16extsfdf2
STARTFN (__mips16_extendsfdf2) STARTFN (__mips16_extendsfdf2)
.set noreorder .set noreorder
mtc1 $4,$f0 mtc1 $4,$f12
nop nop
cvt.d.s $f0,$f0 cvt.d.s $f0,$f12
RETDBL RETDBL
j $31 j $31
nop nop
...@@ -243,7 +297,7 @@ STARTFN (__mips16_truncdfsf2) ...@@ -243,7 +297,7 @@ STARTFN (__mips16_truncdfsf2)
.set noreorder .set noreorder
LDDBL1 LDDBL1
nop nop
cvt.s.d $f0,$f0 cvt.s.d $f0,$f12
mfc1 $2,$f0 mfc1 $2,$f0
j $31 j $31
nop nop
...@@ -262,7 +316,7 @@ STARTFN (__mips16_truncdfsf2) ...@@ -262,7 +316,7 @@ STARTFN (__mips16_truncdfsf2)
STARTFN (NAME); \ STARTFN (NAME); \
LDDBL1; \ LDDBL1; \
LDDBL2; \ LDDBL2; \
OPCODE $f0,$f2; \ OPCODE $f12,$f14; \
li $2,TRUE; \ li $2,TRUE; \
bc1t 1f; \ bc1t 1f; \
li $2,FALSE; \ li $2,FALSE; \
...@@ -276,7 +330,7 @@ STARTFN (NAME); \ ...@@ -276,7 +330,7 @@ STARTFN (NAME); \
STARTFN (NAME); \ STARTFN (NAME); \
LDDBL1; \ LDDBL1; \
LDDBL2; \ LDDBL2; \
OPCODE $f2,$f0; \ OPCODE $f12,$f14; \
li $2,TRUE; \ li $2,TRUE; \
bc1t 1f; \ bc1t 1f; \
li $2,FALSE; \ li $2,FALSE; \
...@@ -308,9 +362,9 @@ DFCMP(__mips16_ltdf2, c.lt.d, -1, 0) ...@@ -308,9 +362,9 @@ DFCMP(__mips16_ltdf2, c.lt.d, -1, 0)
#ifdef L_m16fltsidf #ifdef L_m16fltsidf
STARTFN (__mips16_floatsidf) STARTFN (__mips16_floatsidf)
.set noreorder .set noreorder
mtc1 $4,$f0 mtc1 $4,$f12
nop nop
cvt.d.w $f0,$f0 cvt.d.w $f0,$f12
RETDBL RETDBL
j $31 j $31
nop nop
...@@ -323,13 +377,14 @@ STARTFN (__mips16_fixdfsi) ...@@ -323,13 +377,14 @@ STARTFN (__mips16_fixdfsi)
.set noreorder .set noreorder
LDDBL1 LDDBL1
nop nop
trunc.w.d $f0,$f0,$4 trunc.w.d $f0,$f12,$4
mfc1 $2,$f0 mfc1 $2,$f0
j $31 j $31
nop nop
.set reorder .set reorder
ENDFN (__mips16_fixdfsi) ENDFN (__mips16_fixdfsi)
#endif #endif
#endif /* !__mips_single_float */
/* These functions are used to return floating point values from /* These functions are used to return floating point values from
mips16 functions which do not use -mentry. In this case we can mips16 functions which do not use -mentry. In this case we can
...@@ -345,14 +400,30 @@ STARTFN (__mips16_ret_sf) ...@@ -345,14 +400,30 @@ STARTFN (__mips16_ret_sf)
ENDFN (__mips16_ret_sf) ENDFN (__mips16_ret_sf)
#endif #endif
#if !defined(__mips_single_float) && !defined(__SINGLE_FLOAT)
#ifdef L_m16retdf #ifdef L_m16retdf
STARTFN (__mips16_ret_df) STARTFN (__mips16_ret_df)
.set noreorder .set noreorder
#if defined(__mips64)
j $31
dmtc1 $2,$f0
#elif defined(__mipsfp64)
sw $2,0($29)
sw $3,4($29)
l.d $f0,0($29)
#elif defined(__MIPSEB__)
mtc1 $2,$f1 mtc1 $2,$f1
j $31 j $31
mtc1 $3,$f0 mtc1 $3,$f0
#else
mtc1 $2,$f0
j $31
mtc1 $3,$f1
#endif
.set reorder
ENDFN (__mips16_ret_df) ENDFN (__mips16_ret_df)
#endif #endif
#endif /* !__mips_single_float */
/* These functions are used by 16 bit code when calling via a function /* These functions are used by 16 bit code when calling via a function
pointer. They must copy the floating point arguments from the gp pointer. They must copy the floating point arguments from the gp
...@@ -372,18 +443,6 @@ STARTFN (__mips16_call_stub_1) ...@@ -372,18 +443,6 @@ STARTFN (__mips16_call_stub_1)
ENDFN (__mips16_call_stub_1) ENDFN (__mips16_call_stub_1)
#endif #endif
#ifdef L_m16stub2
/* (double) */
STARTFN (__mips16_call_stub_2)
.set noreorder
mtc1 $5,$f12
mtc1 $4,$f13
j $2
nop
.set reorder
ENDFN (__mips16_call_stub_2)
#endif
#ifdef L_m16stub5 #ifdef L_m16stub5
/* (float, float) */ /* (float, float) */
STARTFN (__mips16_call_stub_5) STARTFN (__mips16_call_stub_5)
...@@ -396,12 +455,24 @@ STARTFN (__mips16_call_stub_5) ...@@ -396,12 +455,24 @@ STARTFN (__mips16_call_stub_5)
ENDFN (__mips16_call_stub_5) ENDFN (__mips16_call_stub_5)
#endif #endif
#if !defined(__mips_single_float) && !defined(__SINGLE_FLOAT)
#ifdef L_m16stub2
/* (double) */
STARTFN (__mips16_call_stub_2)
.set noreorder
LDDBL1
j $2
nop
.set reorder
ENDFN (__mips16_call_stub_2)
#endif
#ifdef L_m16stub6 #ifdef L_m16stub6
/* (double, float) */ /* (double, float) */
STARTFN (__mips16_call_stub_6) STARTFN (__mips16_call_stub_6)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13
mtc1 $6,$f14 mtc1 $6,$f14
j $2 j $2
nop nop
...@@ -414,8 +485,7 @@ STARTFN (__mips16_call_stub_6) ...@@ -414,8 +485,7 @@ STARTFN (__mips16_call_stub_6)
STARTFN (__mips16_call_stub_9) STARTFN (__mips16_call_stub_9)
.set noreorder .set noreorder
mtc1 $4,$f12 mtc1 $4,$f12
mtc1 $7,$f14 LDDBL2
mtc1 $6,$f15
j $2 j $2
nop nop
.set reorder .set reorder
...@@ -426,15 +496,14 @@ STARTFN (__mips16_call_stub_9) ...@@ -426,15 +496,14 @@ STARTFN (__mips16_call_stub_9)
/* (double, double) */ /* (double, double) */
STARTFN (__mips16_call_stub_10) STARTFN (__mips16_call_stub_10)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13 LDDBL2
mtc1 $7,$f14
mtc1 $6,$f15
j $2 j $2
nop nop
.set reorder .set reorder
ENDFN (__mips16_call_stub_10) ENDFN (__mips16_call_stub_10)
#endif #endif
#endif /* !__mips_single_float */
/* Now we have the same set of functions, except that this time the /* Now we have the same set of functions, except that this time the
function being called returns an SFmode value. The calling function being called returns an SFmode value. The calling
...@@ -455,7 +524,7 @@ STARTFN (__mips16_call_stub_sf_0) ...@@ -455,7 +524,7 @@ STARTFN (__mips16_call_stub_sf_0)
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -470,56 +539,55 @@ STARTFN (__mips16_call_stub_sf_1) ...@@ -470,56 +539,55 @@ STARTFN (__mips16_call_stub_sf_1)
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
ENDFN (__mips16_call_stub_sf_1) ENDFN (__mips16_call_stub_sf_1)
#endif #endif
#ifdef L_m16stubsf2 #ifdef L_m16stubsf5
/* (double) */ /* (float, float) */
STARTFN (__mips16_call_stub_sf_2) STARTFN (__mips16_call_stub_sf_5)
.set noreorder .set noreorder
mtc1 $5,$f12 mtc1 $4,$f12
mtc1 $4,$f13 mtc1 $5,$f14
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
ENDFN (__mips16_call_stub_sf_2) ENDFN (__mips16_call_stub_sf_5)
#endif #endif
#ifdef L_m16stubsf5 #if !defined(__mips_single_float) && !defined(__SINGLE_FLOAT)
/* (float, float) */ #ifdef L_m16stubsf2
STARTFN (__mips16_call_stub_sf_5) /* (double) */
STARTFN (__mips16_call_stub_sf_2)
.set noreorder .set noreorder
mtc1 $4,$f12 LDDBL1
mtc1 $5,$f14
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
ENDFN (__mips16_call_stub_sf_5) ENDFN (__mips16_call_stub_sf_2)
#endif #endif
#ifdef L_m16stubsf6 #ifdef L_m16stubsf6
/* (double, float) */ /* (double, float) */
STARTFN (__mips16_call_stub_sf_6) STARTFN (__mips16_call_stub_sf_6)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13
mtc1 $6,$f14 mtc1 $6,$f14
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -531,12 +599,11 @@ STARTFN (__mips16_call_stub_sf_6) ...@@ -531,12 +599,11 @@ STARTFN (__mips16_call_stub_sf_6)
STARTFN (__mips16_call_stub_sf_9) STARTFN (__mips16_call_stub_sf_9)
.set noreorder .set noreorder
mtc1 $4,$f12 mtc1 $4,$f12
mtc1 $7,$f14 LDDBL2
mtc1 $6,$f15
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -547,14 +614,12 @@ STARTFN (__mips16_call_stub_sf_9) ...@@ -547,14 +614,12 @@ STARTFN (__mips16_call_stub_sf_9)
/* (double, double) */ /* (double, double) */
STARTFN (__mips16_call_stub_sf_10) STARTFN (__mips16_call_stub_sf_10)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13 LDDBL2
mtc1 $7,$f14
mtc1 $6,$f15
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $4,$f0 mfc1 $2,$f0
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -571,8 +636,7 @@ STARTFN (__mips16_call_stub_df_0) ...@@ -571,8 +636,7 @@ STARTFN (__mips16_call_stub_df_0)
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -587,8 +651,7 @@ STARTFN (__mips16_call_stub_df_1) ...@@ -587,8 +651,7 @@ STARTFN (__mips16_call_stub_df_1)
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -599,13 +662,11 @@ STARTFN (__mips16_call_stub_df_1) ...@@ -599,13 +662,11 @@ STARTFN (__mips16_call_stub_df_1)
/* (double) */ /* (double) */
STARTFN (__mips16_call_stub_df_2) STARTFN (__mips16_call_stub_df_2)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -621,8 +682,7 @@ STARTFN (__mips16_call_stub_df_5) ...@@ -621,8 +682,7 @@ STARTFN (__mips16_call_stub_df_5)
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -633,14 +693,12 @@ STARTFN (__mips16_call_stub_df_5) ...@@ -633,14 +693,12 @@ STARTFN (__mips16_call_stub_df_5)
/* (double, float) */ /* (double, float) */
STARTFN (__mips16_call_stub_df_6) STARTFN (__mips16_call_stub_df_6)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13
mtc1 $6,$f14 mtc1 $6,$f14
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -652,13 +710,11 @@ STARTFN (__mips16_call_stub_df_6) ...@@ -652,13 +710,11 @@ STARTFN (__mips16_call_stub_df_6)
STARTFN (__mips16_call_stub_df_9) STARTFN (__mips16_call_stub_df_9)
.set noreorder .set noreorder
mtc1 $4,$f12 mtc1 $4,$f12
mtc1 $7,$f14 LDDBL2
mtc1 $6,$f15
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
...@@ -669,17 +725,16 @@ STARTFN (__mips16_call_stub_df_9) ...@@ -669,17 +725,16 @@ STARTFN (__mips16_call_stub_df_9)
/* (double, double) */ /* (double, double) */
STARTFN (__mips16_call_stub_df_10) STARTFN (__mips16_call_stub_df_10)
.set noreorder .set noreorder
mtc1 $5,$f12 LDDBL1
mtc1 $4,$f13 LDDBL2
mtc1 $7,$f14
mtc1 $6,$f15
move $18,$31 move $18,$31
jal $2 jal $2
nop nop
mfc1 $5,$f0 RETDBL
mfc1 $4,$f1
j $18 j $18
nop nop
.set reorder .set reorder
ENDFN (__mips16_call_stub_df_10) ENDFN (__mips16_call_stub_df_10)
#endif #endif
#endif /* !__mips_single_float */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment