Tidied indents

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@3151 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1998-11-02 09:38:25 +00:00
parent e28a743c9e
commit 0dff23a3c5
11 changed files with 388 additions and 265 deletions

View file

@ -19,12 +19,12 @@
The code in this directory was written by
Richard Frith-Macdonald <richard@brainstorm.co.uk>.
Inspiration for this software came from the original mframe.m by
Andrew McCallum, and the libFoundation software by Ovidiu Predescu and
Mircea Oancea, while the algorithms used are copied from gcc and are
copyright the Free Software Foundation. Many code fragments are derived
from gcc by way of libFoundation.
Inspiration for (and some of the code of) this software came from the
original mframe.m by Andrew McCallum, the gcc compiler, and the
libFoundation software by Ovidiu Predescu and Mircea Oancea.
The algorithms used are copied from gcc and are copyright the Free
Software Foundation. Many code fragments are derived from gcc either
directly or by way of libFoundation.
These files are used by the configuration script to build a
machine/operating-system specific 'mframe.m' file containing macros used
@ -52,7 +52,7 @@ MFRAME_SMALL_STRUCT
structure return via pointe, you should also define this to zero.
MFRAME_STRUCT_BYREF
This should be defined to 1 if structure aprguments are passed
This should be defined to 1 if structure arguments are passed
by reference, 0 otherwise.
MFRAME_ARGS_SIZE
@ -71,6 +71,11 @@ MFRAME_RESULT_SIZE
value like 128 - which will probably be far larger than required
(and therefore somewhat inefficient) but will msot likely work.
MFRAME_FLT_IN_FRAME_AS_DBL
This should be defined as 1 if float parameters to functions and
objective-c methods are passed on the stack as double values.
Otherwise it should not be defined.
MFRAME_STRUCT_ADDR(ARGFRAME,TYPES)
If a function returns a structure by copying it into a location
whose address is set by the caller, this macro must return that

View file

@ -6,36 +6,46 @@
#define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
**(void***)(ARGS) : (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
**(void***)(ARGS) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
**(void***)(ARGS) = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
**(void***)(ARGS) = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \
(CUM) += ((size+3)/4); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
((((CUM) & 01) && ((size+3)/4) > 1) && (CUM)++); \
(CUM) += ((size+3)/4); \
})

View file

@ -6,35 +6,42 @@
#define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs + sizeof(void*)) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs + sizeof(void*)) = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
(CUM) += ROUND(size, sizeof(void*)); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
(CUM) += ROUND(size, sizeof(void*)); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
(CUM) += ROUND(size, sizeof(void*)); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})

View file

@ -6,35 +6,45 @@
#define MFRAME_RESULT_SIZE 116
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)(ARGS)->arg_ptr : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)(ARGS)->arg_ptr = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
((CUM) = (*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) ? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
(CUM) += ROUND(size, sizeof(void*)); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B||*type==_C_UNION_B||*type==_C_ARY_B)&&size>2) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})

View file

@ -2,67 +2,90 @@
inline static void*
mframe_arg_addr(arglist_t argf, NSArgumentInfo *info)
{
int offset = info->offset;
int offset = info->offset;
#if WORDS_BIGENDIAN
if (info->size < sizeof(int))
offset += sizeof(int) - info->size;
if (info->size < sizeof(int))
{
offset += sizeof(int) - info->size;
}
#endif
if (info->isReg)
return(argf->arg_regs + offset);
else
return(argf->arg_ptr + offset);
if (info->isReg)
{
return(argf->arg_regs + offset);
}
else
{
return(argf->arg_ptr + offset);
}
}
inline static void
mframe_get_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
{
#if MFRAME_STRUCT_BYREF
const char *typ = info->type;
const char *typ = info->type;
/*
* If structures are passed in the stack frame by reference - we need
* to copy the actual structure, rather than it's pointer.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) {
memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size);
/*
* If structures are passed in the stack frame by reference - we need
* to copy the actual structure, rather than it's pointer.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
{
memcpy(buffer, *(void**)mframe_arg_addr(argf, info), info->size);
}
else
else
#endif
memcpy(buffer, mframe_arg_addr(argf, info), info->size);
#if MFRAME_FLT_IN_FRAME_AS_DBL
if (*typ == _C_FLT)
{
*(float*)buffer = (float)*(double*)mframe_arg_addr(argf, info);
}
else
#endif
memcpy(buffer, mframe_arg_addr(argf, info), info->size);
}
inline static void
mframe_set_arg(arglist_t argf, NSArgumentInfo *info, void* buffer)
{
#if MFRAME_STRUCT_BYREF
const char *typ = info->type;
const char *typ = info->type;
/*
* If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) {
memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*));
/*
* If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
{
memcpy(mframe_arg_addr(argf, info), &buffer, sizeof(void*));
}
else
else
#endif
memcpy(mframe_arg_addr(argf, info), buffer, info->size);
#if MFRAME_FLT_IN_FRAME_AS_DBL
if (*typ == _C_FLT)
{
*(double*)mframe_arg_addr(argf, info) = *(float*)buffer;
}
else
#endif
memcpy(mframe_arg_addr(argf, info), buffer, info->size);
}
inline static void
mframe_cpy_arg(arglist_t dst, arglist_t src, NSArgumentInfo *info)
{
#if MFRAME_STRUCT_BYREF
const char *typ = info->type;
const char *typ = info->type;
/*
* If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B) {
memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*));
/*
* If structures are passed in the stack frame by reference - we need
* to copy a pointer onto the stack rather than the actual structure.
*/
if (*typ == _C_STRUCT_B || *typ == _C_UNION_B || *typ == _C_ARY_B)
{
memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), sizeof(void*));
}
else
else
#endif
memcpy(mframe_arg_addr(dst, info), mframe_arg_addr(src, info), info->size);
}

View file

@ -1,5 +1,5 @@
/* Interface for functions that dissect/make method calls
Copyright (C) 1994, 1996 Free Software Foundation, Inc.
Copyright (C) 1994, 1996, 1998 Free Software Foundation, Inc.
Written by: Andrew Kachites McCallum <mccallum@gnu.ai.mit.edu>
Created: Oct 1994
@ -31,8 +31,8 @@
#if NeXT_runtime
typedef union {
char *arg_ptr;
char arg_regs[sizeof (char*)];
char *arg_ptr;
char arg_regs[sizeof (char*)];
} *arglist_t;
#endif

View file

@ -6,64 +6,83 @@
#define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
#define IN_REGS 0
#define ON_STACK 1
struct sparc_args {
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack;
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack;
};
#define MFRAME_ARGS struct sparc_args
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
({ (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; })
({ \
(CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; \
})
#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \
((CUM).onStack \
? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \
: ((CUM).onStack = YES, ON_STACK)))
((CUM).onStack \
? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \
: ((CUM).onStack = YES, ON_STACK)))
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
\
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
(TYPE) = objc_skip_typespec(type); \
if (locn == IN_REGS) \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
else \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if (locn == ON_STACK) { \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \
else \
(STACK) = (CUM).offsets[ON_STACK] + size; \
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \
{ \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
} \
(TYPE) = objc_skip_typespec(type); \
if (locn == IN_REGS) \
{ \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
} \
else \
{ \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
} \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if (locn == ON_STACK) \
{ \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
{ \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \
} \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})
else \
{ \
(STACK) = (CUM).offsets[ON_STACK] + size; \
} \
} \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})

View file

@ -6,64 +6,83 @@
#define MFRAME_RESULT_SIZE 16
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) ? \
*(void**)((ARGS)->arg_regs+sizeof(void*)): (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
({if (*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) \
*(void**)((ARGS)->arg_regs+sizeof(void*)) = (ADDR);})
#define IN_REGS 0
#define ON_STACK 1
struct sparc_args {
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack;
int offsets[2]; /* 0 for args in regs, 1 for the rest of args on stack */
int onStack;
};
#define MFRAME_ARGS struct sparc_args
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
({ (CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; })
({ \
(CUM).offsets[0] = 8; /* encoding in regs starts from 8 */ \
(CUM).offsets[1] = 20; /* encoding on stack starts from 20 or 24 */ \
(CUM).onStack = NO; \
})
#define GET_SPARC_ARG_LOCATION(CUM, CSTRING_TYPE, TYPESIZE) \
((CUM).onStack \
? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \
: ((CUM).onStack = YES, ON_STACK)))
((CUM).onStack \
? ON_STACK \
: ((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 8 \
? (((CUM).offsets[IN_REGS] + TYPESIZE <= 6 * sizeof(int) + 4 \
? 0 : ((CUM).offsets[ON_STACK] += 4)),\
IN_REGS) \
: ((CUM).onStack = YES, ON_STACK)))
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
int locn = GET_SPARC_ARG_LOCATION(CUM, type, size); \
\
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
(TYPE) = objc_skip_typespec(type); \
if (locn == IN_REGS) \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
else \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if (locn == ON_STACK) { \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \
else \
(STACK) = (CUM).offsets[ON_STACK] + size; \
(CUM).offsets[locn] = ROUND((CUM).offsets[locn], align); \
if (size < sizeof(int)) \
{ \
(CUM).offsets[locn] += sizeof(int) - ROUND(size, align); \
} \
(TYPE) = objc_skip_typespec(type); \
if (locn == IN_REGS) \
{ \
sprintf((DEST), "%.*s+%d", (TYPE)-type, type, (CUM).offsets[locn]); \
} \
else \
{ \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM).offsets[locn]); \
} \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if (locn == ON_STACK) \
{ \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
{ \
(STACK) = (CUM).offsets[ON_STACK] + ROUND(size, align); \
} \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})
else \
{ \
(STACK) = (CUM).offsets[ON_STACK] + size; \
} \
} \
(CUM).offsets[locn] += \
size < sizeof(int) \
? ROUND(size, align) \
: ROUND(size, sizeof(void*)); \
})

View file

@ -6,40 +6,50 @@
#define MFRAME_RESULT_SIZE 128
#define MFRAME_GET_STRUCT_ADDR(ARGS, TYPES) \
(((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0)
(((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || *(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) ? \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) : (void*)0)
#define MFRAME_SET_STRUCT_ADDR(ARGS, TYPES, ADDR) \
({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \
*(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);})
({if ((*(TYPES)==_C_STRUCT_B || *(TYPES)==_C_UNION_B || \
*(TYPES)==_C_ARY_B) && \
objc_sizeof_type(TYPES) > MFRAME_SMALL_STRUCT) \
*(void**)((ARGS)->arg_ptr + sizeof(void*)) = (ADDR);})
#define MFRAME_ARGS int
#define MFRAME_INIT_ARGS(CUM, RTYPE) \
((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) && \
objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \
? sizeof(void*) : 0)
((CUM) = ((*(RTYPE)==_C_STRUCT_B || *(RTYPE)==_C_UNION_B || \
*(RTYPE)==_C_ARY_B) && \
objc_sizeof_type(RTYPE) > MFRAME_SMALL_STRUCT) \
? sizeof(void*) : 0)
#define MFRAME_ARG_ENCODING(CUM, TYPE, STACK, DEST) \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
({ \
const char* type = (TYPE); \
int align = objc_alignof_type(type); \
int size = objc_sizeof_type(type); \
\
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') (TYPE)++; \
while (isdigit(*(TYPE))) (TYPE)++; \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
(STACK) = (CUM) + ROUND(size, align); \
else \
(STACK) = (CUM) + size; \
(CUM) += ROUND(size, sizeof(void*)); \
})
(CUM) = ROUND((CUM), align); \
(TYPE) = objc_skip_typespec(type); \
sprintf((DEST), "%.*s%d", (TYPE)-type, type, (CUM)); \
if (*(TYPE) == '+') \
{ \
(TYPE)++; \
} \
while (isdigit(*(TYPE))) \
{ \
(TYPE)++; \
} \
(DEST)=&(DEST)[strlen(DEST)]; \
if ((*type==_C_STRUCT_B || *type==_C_UNION_B || *type==_C_ARY_B)) \
{ \
(STACK) = (CUM) + ROUND(size, align); \
} \
else \
{ \
(STACK) = (CUM) + size; \
} \
(CUM) += ROUND(size, sizeof(void*)); \
})