annotate 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
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
1 /*
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
2
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
3 Package: dyncall
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
4 Library: dyncallback
118
f0437f85091b - cleanups in comments, etc.
cslag
parents: 110
diff changeset
5 File: dyncallback/dyncall_args_mips_o32.c
109
9e677d4c0b6b - mips comment cleanups
cslag
parents: 104
diff changeset
6 Description: Callback's Arguments VM - Implementation for MIPS o32
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
7 License:
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
8
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 118
diff changeset
9 Copyright (c) 2013-2018 Daniel Adler <dadler@uni-goettingen.de>,
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
10 Tassilo Philipp <tphilipp@potion-studios.com>
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
11
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
12 Permission to use, copy, modify, and distribute this software for any
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
13 purpose with or without fee is hereby granted, provided that the above
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
14 copyright notice and this permission notice appear in all copies.
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
15
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
16 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
17 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
18 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
19 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
20 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
21 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
22 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
23
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
24 */
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
25
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
26
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
27 #include "dyncall_args_mips.h"
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
28
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
29 DCint dcbArgInt(DCArgs* p)
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
30 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
31 DCint value;
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
32
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
33 #if defined(DC__ABI_HARDFLOAT)
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
34 /* first int will disable float reg use. */
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
35 p->freg_count = 2;
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
36 #endif /* DC__ABI_HARDFLOAT */
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
37
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
38 value = *((int*)p->stackptr);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
39 p->stackptr += sizeof(int);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
40 return value;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
41 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
42 DCuint dcbArgUInt(DCArgs* p) { return (DCuint)dcbArgInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
43
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
44 DCulonglong dcbArgULongLong(DCArgs* p)
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
45 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
46 DCulonglong value;
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
47 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
48 #if defined(DC__Endian_LITTLE)
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
49 value = dcbArgUInt(p);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
50 value |= ((DCulonglong)dcbArgUInt(p)) << 32;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
51 #else
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
52 value = ((DCulonglong)dcbArgUInt(p)) << 32;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
53 value |= dcbArgUInt(p);
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
54 #endif
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
55 return value;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
56 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
57 DClonglong dcbArgLongLong(DCArgs* p) { return (DClonglong)dcbArgULongLong(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
58
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
59 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
60 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
61 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
62 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
63 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
64 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
65 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
66 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgUInt(p); }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
67
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
68 DCfloat dcbArgFloat(DCArgs* p)
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
69 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
70 DCfloat result;
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
71
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
72 #if defined(DC__ABI_HARDFLOAT)
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
73 if(p->freg_count < 2) {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
74 /* Stored float regs (max 2) are always 8b aligned. The way we look them up, */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
75 /* relative to a diverging p->stackptr, we need consider this. Only works */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
76 /* with up to two float args, which is all we need. Hacky, but saves us */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
77 /* from one more variable and more bookkeeping in DCArgs. */
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
78 result = ((DCfloat*)(p->stackptr + ((int)p->stackptr & 4)) - 4) /* '-4' b/c those regs are stored right before the args */
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
79 # if defined(DC__Endian_LITTLE)
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
80 [0];
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
81 # else
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
82 [1];
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
83 # endif
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
84 ++p->freg_count;
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
85 } else
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
86 #endif /* DC__ABI_HARDFLOAT */
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
87 {
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
88 result = *((DCfloat*)p->stackptr);
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
89 }
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
90 p->stackptr += sizeof(DCfloat);
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
91 return result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
92 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
93 DCdouble dcbArgDouble(DCArgs* p)
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
94 {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
95 union {
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
96 DCdouble result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
97 DCfloat f[2];
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
98 } d;
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
99 p->stackptr += ((int)p->stackptr & 4); /* Skip one slot if not aligned. */
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
100
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
101 #if defined(DC__ABI_HARDFLOAT)
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
102 if(p->freg_count < 2) {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
103 /*result = *((DCdouble*)p->stackptr-2); this changes the value, slightly*/
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
104 d.f[0] = ((DCfloat*)p->stackptr-4)[0]; /* '-4' b/c those regs are stored right before the args */
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
105 d.f[1] = ((DCfloat*)p->stackptr-4)[1];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
106 ++p->freg_count;
302
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
107 } else
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
108 #endif /* DC__ABI_HARDFLOAT */
d55f9d508074 - mips softfloat support for o32 callconv (calls and callbacks, little and big endian)
Tassilo Philipp
parents: 281
diff changeset
109 {
110
9aa75a74614c - working mips32 eabi callbacks
cslag
parents: 109
diff changeset
110 /*result = *((DCdouble*)p->stackptr); this changes the value, slightly*/
104
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
111 d.f[0] = ((DCfloat*)p->stackptr)[0];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
112 d.f[1] = ((DCfloat*)p->stackptr)[1];
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
113 }
dbca6763f2be - complete, working mips o32 callback (using hardware fp); fixes error from last commit, which ignored first 2 float args
cslag
parents: 102
diff changeset
114 p->stackptr += sizeof(DCdouble);
102
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
115 return d.result;
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
116 }
b7a9b524f0c3 - mips o32 callbacks, first draft (calls into handler correctly, with correct params, but doesn't return)
cslag
parents:
diff changeset
117