From 82b9e428d4bc97a28b057e65e037a935ceaa1ce8 Mon Sep 17 00:00:00 2001 From: rfm Date: Sun, 4 Jan 2009 17:08:02 +0000 Subject: [PATCH] Guyess at sparc64 openbsd config git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@27508 72102866-910b-0410-8b05-ffd578937521 --- ChangeLog | 8 +++ Source/mframe/README | 3 +- Source/mframe/configure | 1 + Source/mframe/configure.ac | 1 + Source/mframe/sparc64/generic | 93 +++++++++++++++++++++++++++++++++++ Source/mframe/sparc64/openbsd | 93 +++++++++++++++++++++++++++++++++++ 6 files changed, 198 insertions(+), 1 deletion(-) create mode 100644 Source/mframe/sparc64/generic create mode 100644 Source/mframe/sparc64/openbsd diff --git a/ChangeLog b/ChangeLog index c17a28172..af5cbf369 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2009-01-04 Richard Frith-Macdonald + + * Source/mframe/sparc64/generic: guess at a config + * Source/mframe/sparc64/openbsd: guess at a config + * Source/mframe/configure.ac: add sparc64 + * Source/mframe/configure: regenerate + Guess at config for sparc64 openbsd + 2009-01-02 Richard Frith-Macdonald * Source/NSBundle.m: ([+bundleForLibrary:]) return nil if the diff --git a/Source/mframe/README b/Source/mframe/README index b08f56610..472469bd0 100644 --- a/Source/mframe/README +++ b/Source/mframe/README @@ -17,7 +17,8 @@ You should have received a copy of the GNU Lesser General Public License along with this library; if not, write to the Free - Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 USA. + Software Foundation, Inc., 51 Franklin Street, Fifth Floor, + Boston, MA 02111 USA. The code in this directory was written by Richard Frith-Macdonald . diff --git a/Source/mframe/configure b/Source/mframe/configure index 9b862e5f0..8c0f278f8 100755 --- a/Source/mframe/configure +++ b/Source/mframe/configure @@ -1342,6 +1342,7 @@ case "$target_cpu" in alpha*) target_cpu=alpha;; hppa*) target_cpu=hppa;; i[3456]86*) target_cpu=i386;; + sparc64*) target_cpu=sparc64;; sparc*) target_cpu=sparc;; esac diff --git a/Source/mframe/configure.ac b/Source/mframe/configure.ac index 03d194016..5e92bfec7 100644 --- a/Source/mframe/configure.ac +++ b/Source/mframe/configure.ac @@ -39,6 +39,7 @@ case "$target_cpu" in alpha*) target_cpu=alpha;; hppa*) target_cpu=hppa;; i[[3456]]86*) target_cpu=i386;; + sparc64*) target_cpu=sparc64;; sparc*) target_cpu=sparc;; esac diff --git a/Source/mframe/sparc64/generic b/Source/mframe/sparc64/generic new file mode 100644 index 000000000..c906b7ad0 --- /dev/null +++ b/Source/mframe/sparc64/generic @@ -0,0 +1,93 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 1 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 32 +#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) + +#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);}) + +#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; +}; + +#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; \ +}) + +#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))) + +#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); \ +\ + (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)++; \ + } \ + 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] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) + diff --git a/Source/mframe/sparc64/openbsd b/Source/mframe/sparc64/openbsd new file mode 100644 index 000000000..1c798144f --- /dev/null +++ b/Source/mframe/sparc64/openbsd @@ -0,0 +1,93 @@ +/* See ../README for copyright */ + +#define MFRAME_STACK_STRUCT 0 +#define MFRAME_STRUCT_BYREF 0 +#define MFRAME_SMALL_STRUCT 0 +#define MFRAME_ARGS_SIZE 32 +#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) + +#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);}) + +#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; +}; + +#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; \ +}) + +#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))) + +#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); \ +\ + (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)++; \ + } \ + 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] += \ + size < sizeof(int) \ + ? ROUND(size, align) \ + : ROUND(size, sizeof(void*)); \ +}) +