annotate dyncallback/dyncall_args_mips64.c @ 305:b104c5beec8b

- softfloat support for mips64/n64 abi
author Tassilo Philipp
date Wed, 23 May 2018 11:41:34 +0200
parents f5577f6bf97a
children 71c884e610f0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
1 /*
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
2
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
3 Package: dyncall
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
4 Library: dyncallback
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
5 File: dyncallback/dyncall_args_mips64.c
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
6 Description: Callback's Arguments VM - Implementation for MIPS64 n32&n64
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
7 License:
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
8
281
f5577f6bf97a - file header cleanups for release
Tassilo Philipp
parents: 126
diff changeset
9 Copyright (c) 2016-2018 Tassilo Philipp <tphilipp@potion-studios.com>
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
10
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
11 Permission to use, copy, modify, and distribute this software for any
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
12 purpose with or without fee is hereby granted, provided that the above
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
13 copyright notice and this permission notice appear in all copies.
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
14
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
15 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
16 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
17 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
18 ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
19 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
20 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
21 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
22
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
23 */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
24
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
25
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
26 #include "dyncall_args_mips.h"
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
27
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
28 /* @@@ test and add n32 code here, also, if needed */
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
29
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
30 DClonglong dcbArgLongLong(DCArgs* p)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
31 {
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
32 DClonglong value;
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 281
diff changeset
33 if(p->reg_count < DCARGS_MIPS_NUM_REGS)
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
34 value = p->ireg_data[p->reg_count++];
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
35 else {
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
36 value = *((DClonglong*)p->stackptr);
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
37 p->stackptr += sizeof(DClonglong);
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
38 }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
39 return value;
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
40 }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
41 DCulonglong dcbArgULongLong(DCArgs* p) { return (DCulonglong)dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
42
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
43 DCint dcbArgInt (DCArgs* p) { return (DCint) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
44 DCuint dcbArgUInt (DCArgs* p) { return (DCuint) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
45 DClong dcbArgLong (DCArgs* p) { return (DClong) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
46 DCulong dcbArgULong (DCArgs* p) { return (DCulong) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
47 DCchar dcbArgChar (DCArgs* p) { return (DCchar) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
48 DCuchar dcbArgUChar (DCArgs* p) { return (DCuchar) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
49 DCshort dcbArgShort (DCArgs* p) { return (DCshort) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
50 DCushort dcbArgUShort (DCArgs* p) { return (DCushort) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
51 DCbool dcbArgBool (DCArgs* p) { return (DCbool) dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
52 DCpointer dcbArgPointer(DCArgs* p) { return (DCpointer)dcbArgLongLong(p); }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
53
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
54 DCdouble dcbArgDouble(DCArgs* p)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
55 {
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
56 DCdouble result;
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 281
diff changeset
57 if(p->reg_count < DCARGS_MIPS_NUM_REGS)
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
58 result = p->freg_data[p->reg_count++];
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
59 else {
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
60 result = *((DCdouble*)p->stackptr);
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
61 p->stackptr += sizeof(DCdouble);
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
62 }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
63 return result;
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
64 }
126
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
65 DCfloat dcbArgFloat(DCArgs* p)
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
66 {
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
67 DCfloat result;
305
b104c5beec8b - softfloat support for mips64/n64 abi
Tassilo Philipp
parents: 281
diff changeset
68 if(p->reg_count < DCARGS_MIPS_NUM_REGS) {
126
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
69 result = ((DCfloat*)&p->freg_data[p->reg_count++])
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
70 #if defined(DC__Endian_LITTLE)
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
71 [0];
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
72 #else
126
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
73 [1]; /* single precision floats are right-justified in big-endian registers */
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
74 #endif
126
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
75 } else {
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
76 result = *((DCfloat*)p->stackptr); /* single precision floats are left-justified on stack in 64bit slots */
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
77 p->stackptr += sizeof(DCdouble);
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
78 }
be08b699dca5 - mips64 n64 float fixes (big endian), now mips64 n64 is fully supported (for at least big-endian platforms, still need to test little endian)
cslag
parents: 122
diff changeset
79 return result;
122
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
80 }
f63467916f98 - first draft of mips64 n64 callbacks, not everything working, though
cslag
parents:
diff changeset
81