comparison dyncallback/dyncall_args_mips_o32.c @ 302:d55f9d508074

- mips softfloat support for o32 callconv (calls and callbacks, little and big endian) - cleanup of some mips files, removed unnecessary file, renamings.. - doc/manual cleanups, changelog entry
author Tassilo Philipp
date Mon, 21 May 2018 02:48:12 +0200
parents f5577f6bf97a
children 71c884e610f0
comparison
equal deleted inserted replaced
301:74948b02cfa0 302:d55f9d508074
27 #include "dyncall_args_mips.h" 27 #include "dyncall_args_mips.h"
28 28
29 DCint dcbArgInt(DCArgs* p) 29 DCint dcbArgInt(DCArgs* p)
30 { 30 {
31 DCint value; 31 DCint value;
32 p->freg_count = 2; /* first int will disable float reg use. */ 32
33 #if defined(DC__ABI_HARDFLOAT)
34 /* first int will disable float reg use. */
35 p->freg_count = 2;
36 #endif /* DC__ABI_HARDFLOAT */
37
33 value = *((int*)p->stackptr); 38 value = *((int*)p->stackptr);
34 p->stackptr += sizeof(int); 39 p->stackptr += sizeof(int);
35 return value; 40 return value;
36 } 41 }
37 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } 42 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); }
61 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); } 66 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); }
62 67
63 DCfloat dcbArgFloat(DCArgs* p) 68 DCfloat dcbArgFloat(DCArgs* p)
64 { 69 {
65 DCfloat result; 70 DCfloat result;
71
72 #if defined(DC__ABI_HARDFLOAT)
66 if(p->freg_count < 2) { 73 if(p->freg_count < 2) {
67 /* Stored float regs (max 2) are always 8b aligned. The way we look them up, */ 74 /* Stored float regs (max 2) are always 8b aligned. The way we look them up, */
68 /* relative to a diverging p->stackptr, we need consider this. Only works */ 75 /* relative to a diverging p->stackptr, we need consider this. Only works */
69 /* with up to two float args, which is all we need. Hacky, but saves us */ 76 /* with up to two float args, which is all we need. Hacky, but saves us */
70 /* from one more variable and more bookkeeping in DCArgs. */ 77 /* from one more variable and more bookkeeping in DCArgs. */
71 result = ((DCfloat*)(p->stackptr + ((int)p->stackptr & 4)) - 4) /* '-4' b/c those regs are stored right before the args */ 78 result = ((DCfloat*)(p->stackptr + ((int)p->stackptr & 4)) - 4) /* '-4' b/c those regs are stored right before the args */
72 #if defined(DC__Endian_LITTLE) 79 # if defined(DC__Endian_LITTLE)
73 [0]; 80 [0];
74 #else 81 # else
75 [1]; 82 [1];
76 #endif 83 # endif
77 ++p->freg_count; 84 ++p->freg_count;
78 } else { 85 } else
86 #endif /* DC__ABI_HARDFLOAT */
87 {
79 result = *((DCfloat*)p->stackptr); 88 result = *((DCfloat*)p->stackptr);
80 } 89 }
81 p->stackptr += sizeof(DCfloat); 90 p->stackptr += sizeof(DCfloat);
82 return result; 91 return result;
83 } 92 }
86 union { 95 union {
87 DCdouble result; 96 DCdouble result;
88 DCfloat f[2]; 97 DCfloat f[2];
89 } d; 98 } d;
90 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */ 99 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
100
101 #if defined(DC__ABI_HARDFLOAT)
91 if(p->freg_count < 2) { 102 if(p->freg_count < 2) {
92 /*result = *((DCdouble*)p->stackptr-2); this changes the value, slightly*/ 103 /*result = *((DCdouble*)p->stackptr-2); this changes the value, slightly*/
93 d.f[0] = ((DCfloat*)p->stackptr-4)[0]; /* '-4' b/c those regs are stored right before the args */ 104 d.f[0] = ((DCfloat*)p->stackptr-4)[0]; /* '-4' b/c those regs are stored right before the args */
94 d.f[1] = ((DCfloat*)p->stackptr-4)[1]; 105 d.f[1] = ((DCfloat*)p->stackptr-4)[1];
95 ++p->freg_count; 106 ++p->freg_count;
96 } else { 107 } else
108 #endif /* DC__ABI_HARDFLOAT */
109 {
97 /*result = *((DCdouble*)p->stackptr); this changes the value, slightly*/ 110 /*result = *((DCdouble*)p->stackptr); this changes the value, slightly*/
98 d.f[0] = ((DCfloat*)p->stackptr)[0]; 111 d.f[0] = ((DCfloat*)p->stackptr)[0];
99 d.f[1] = ((DCfloat*)p->stackptr)[1]; 112 d.f[1] = ((DCfloat*)p->stackptr)[1];
100 } 113 }
101 p->stackptr += sizeof(DCdouble); 114 p->stackptr += sizeof(DCdouble);