comparison dyncallback/dyncall_args_mips_o32.c @ 110:9aa75a74614c

- working mips32 eabi callbacks - mips32 eabi doc update - switched some mips32 eabi call assembly to use more portable pseudo instructions for storing floats - fixed weird type use of var declaration in mips callbacks - ToDo update - converted some // comments to old c-style - test code build fix for some test suites on some platforms
author cslag
date Sat, 18 Jun 2016 19:38:22 +0200
parents 9e677d4c0b6b
children f0437f85091b
comparison
equal deleted inserted replaced
109:9e677d4c0b6b 110:9aa75a74614c
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 p->freg_count = 2; /* first int will disable float reg use. */
33 value = *((int*)p->stackptr); 33 value = *((int*)p->stackptr);
34 p->stackptr += sizeof(int); 34 p->stackptr += sizeof(int);
35 return value; 35 return value;
36 } 36 }
37 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); } 37 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); }
38 38
39 DCulonglong dcbArgULongLong(DCArgs* p) 39 DCulonglong dcbArgULongLong(DCArgs* p)
40 { 40 {
41 DCulonglong value; 41 DCulonglong value;
42 p->stackptr += ((int)p->stackptr & 4); // Skip one slot if not aligned. 42 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
43 #if defined(DC__Endian_LITTLE) 43 #if defined(DC__Endian_LITTLE)
44 value = dcbArgUInt(p); 44 value = dcbArgUInt(p);
45 value |= ((DCulonglong)dcbArgUInt(p)) << 32; 45 value |= ((DCulonglong)dcbArgUInt(p)) << 32;
46 #else 46 #else
47 value = ((DCulonglong)dcbArgUInt(p)) << 32; 47 value = ((DCulonglong)dcbArgUInt(p)) << 32;
62 62
63 DCfloat dcbArgFloat(DCArgs* p) 63 DCfloat dcbArgFloat(DCArgs* p)
64 { 64 {
65 DCfloat result; 65 DCfloat result;
66 if(p->freg_count < 2) { 66 if(p->freg_count < 2) {
67 // Stored float regs (max 2) are always 8b aligned. The way we look them up, 67 /* 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 68 /* 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 69 /* 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. 70 /* 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 71 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) 72 #if defined(DC__Endian_LITTLE)
73 [0]; 73 [0];
74 #else 74 #else
75 [1]; 75 [1];
76 #endif 76 #endif
85 { 85 {
86 union { 86 union {
87 DCdouble result; 87 DCdouble result;
88 DCfloat f[2]; 88 DCfloat f[2];
89 } d; 89 } d;
90 p->stackptr += ((int)p->stackptr & 4); // Skip one slot if not aligned. 90 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
91 if(p->freg_count < 2) { 91 if(p->freg_count < 2) {
92 //result = *((DCdouble*)p->stackptr-2); this changes the value, slightly 92 /*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 93 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]; 94 d.f[1] = ((DCfloat*)p->stackptr-4)[1];
95 ++p->freg_count; 95 ++p->freg_count;
96 } else { 96 } else {
97 //result = *((DCdouble*)p->stackptr); this changes the value, slightly 97 /*result = *((DCdouble*)p->stackptr); this changes the value, slightly*/
98 d.f[0] = ((DCfloat*)p->stackptr)[0]; 98 d.f[0] = ((DCfloat*)p->stackptr)[0];
99 d.f[1] = ((DCfloat*)p->stackptr)[1]; 99 d.f[1] = ((DCfloat*)p->stackptr)[1];
100 } 100 }
101 p->stackptr += sizeof(DCdouble); 101 p->stackptr += sizeof(DCdouble);
102 return d.result; 102 return d.result;