Mercurial > pub > dyncall > dyncall
comparison dyncall/dyncall_callvm_mips_n64.c @ 305:b104c5beec8b
- softfloat support for mips64/n64 abi
author | Tassilo Philipp |
---|---|
date | Wed, 23 May 2018 11:41:34 +0200 |
parents | f5577f6bf97a |
children | ad5f9803f52f |
comparison
equal
deleted
inserted
replaced
304:6869d834a847 | 305:b104c5beec8b |
---|---|
56 static void dc_callvm_reset_mips_n64(DCCallVM* in_self) | 56 static void dc_callvm_reset_mips_n64(DCCallVM* in_self) |
57 { | 57 { |
58 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; | 58 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; |
59 dcVecReset(&self->mVecHead); | 59 dcVecReset(&self->mVecHead); |
60 self->mRegCount = 0; | 60 self->mRegCount = 0; |
61 #if defined(DC__ABI_HARDFLOAT) | |
61 self->mRegData.mUseDouble = 0LL; | 62 self->mRegData.mUseDouble = 0LL; |
63 #endif /* DC__ABI_HARDFLOAT */ | |
62 } | 64 } |
63 | 65 |
64 | 66 |
65 static void dc_callvm_free_mips_n64(DCCallVM* in_self) | 67 static void dc_callvm_free_mips_n64(DCCallVM* in_self) |
66 { | 68 { |
73 - fill up integers and float - left-to-right otherwise go over stack. | 75 - fill up integers and float - left-to-right otherwise go over stack. |
74 */ | 76 */ |
75 | 77 |
76 /* arg int -- fillup 64-bit integer register file OR push on stack */ | 78 /* arg int -- fillup 64-bit integer register file OR push on stack */ |
77 | 79 |
78 static void dc_callvm_argLongLong_mips_n64(DCCallVM* in_self, DClonglong Lv) | 80 static void dc_callvm_argLongLong_mips_n64(DCCallVM* in_self, DClonglong x) |
79 { | 81 { |
80 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; | 82 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; |
81 /* fillup integer register file */ | 83 /* fillup integer register file */ |
82 if (self->mRegCount < 8) | 84 if (self->mRegCount < 8) |
83 self->mRegData.mIntData[self->mRegCount++] = Lv; | 85 self->mRegData.mIntData[self->mRegCount++] = x; |
84 else | 86 else |
85 dcVecAppend(&self->mVecHead, &Lv, sizeof(DClonglong)); | 87 dcVecAppend(&self->mVecHead, &x, sizeof(DClonglong)); |
86 } | 88 } |
87 | 89 |
88 static void dc_callvm_argInt_mips_n64(DCCallVM* in_self, DCint i) | 90 static void dc_callvm_argInt_mips_n64(DCCallVM* in_self, DCint x) |
89 { | 91 { |
90 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong) i ); | 92 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong)x); |
91 } | 93 } |
92 | 94 |
93 static void dc_callvm_argPointer_mips_n64(DCCallVM* in_self, DCpointer x) | 95 static void dc_callvm_argPointer_mips_n64(DCCallVM* in_self, DCpointer x) |
94 { | 96 { |
95 dc_callvm_argLongLong_mips_n64(in_self, * (DClonglong*) &x ); | 97 dc_callvm_argLongLong_mips_n64(in_self, *(DClonglong*)&x); |
96 } | 98 } |
97 | 99 |
98 static void dc_callvm_argBool_mips_n64(DCCallVM* in_self, DCbool x) | 100 static void dc_callvm_argBool_mips_n64(DCCallVM* in_self, DCbool x) |
99 { | 101 { |
100 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong)x); | 102 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong)x); |
115 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong)x); | 117 dc_callvm_argLongLong_mips_n64(in_self, (DClonglong)x); |
116 } | 118 } |
117 | 119 |
118 static void dc_callvm_argDouble_mips_n64(DCCallVM* in_self, DCdouble x) | 120 static void dc_callvm_argDouble_mips_n64(DCCallVM* in_self, DCdouble x) |
119 { | 121 { |
122 #if defined(DC__ABI_HARDFLOAT) | |
120 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; | 123 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; |
121 if (self->mRegCount < 8) { | 124 if (self->mRegCount < 8) { |
122 self->mRegData.mUseDouble |= 1<<( self->mRegCount ); | 125 self->mRegData.mUseDouble |= 1<<( self->mRegCount ); |
123 self->mRegData.mFloatData[self->mRegCount++].d = x; | 126 self->mRegData.mFloatData[self->mRegCount++].d = x; |
124 } else { | 127 } else { |
125 dcVecAppend(&self->mVecHead, &x, sizeof(DCdouble) ); | 128 dcVecAppend(&self->mVecHead, &x, sizeof(DCdouble)); |
126 } | 129 } |
130 #else | |
131 dc_callvm_argLongLong_mips_n64(in_self, *(DClonglong*)&x); | |
132 #endif /* DC__ABI_HARDFLOAT */ | |
127 } | 133 } |
128 | 134 |
129 static void dc_callvm_argFloat_mips_n64(DCCallVM* in_self, DCfloat x) | 135 static void dc_callvm_argFloat_mips_n64(DCCallVM* in_self, DCfloat x) |
130 { | 136 { |
137 #if defined(DC__ABI_HARDFLOAT) | |
131 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; | 138 DCCallVM_mips_n64* self = (DCCallVM_mips_n64*)in_self; |
132 if (self->mRegCount < 8) { | 139 if (self->mRegCount < 8) { |
133 /*self->mRegData.mFloatData[self->mRegCount++].d = (DCdouble) x;*/ | 140 /*self->mRegData.mFloatData[self->mRegCount++].d = (DCdouble) x;*/ |
134 self->mRegData.mFloatData[self->mRegCount++].f = x; | 141 self->mRegData.mFloatData[self->mRegCount++].f = x; |
135 } else { | 142 } else { |
136 dcVecAppend(&self->mVecHead, &x, sizeof(DCfloat) ); | 143 dcVecAppend(&self->mVecHead, &x, sizeof(DCfloat)); |
137 dcVecSkip(&self->mVecHead, sizeof(DCfloat) ); | 144 dcVecSkip(&self->mVecHead, sizeof(DCfloat)); |
138 } | 145 } |
146 #else | |
147 DCfloat f[] = {x,0.f}; | |
148 # if defined(DC__Endian_BIG) | |
149 // floats in regs always right justified | |
150 if (((DCCallVM_mips_n64*)in_self)->mRegCount < 8) { | |
151 f[1] = f[0]; | |
152 f[0] = 0.f; | |
153 } | |
154 # endif /* DC__Endian_BIG */ | |
155 dc_callvm_argLongLong_mips_n64(in_self, *(DClonglong*)&f); | |
156 #endif /* DC__ABI_HARDFLOAT */ | |
139 } | 157 } |
140 | 158 |
141 | 159 |
142 /* Ellipsis calls: | 160 /* Ellipsis calls: |
143 - float is promoted to double (due to ANSI C). | 161 - float is promoted to double (due to ANSI C). |