From 2cbfc57d9a058f85e84d32dd84d358749eca2dfe Mon Sep 17 00:00:00 2001 From: twisti Date: Wed, 8 Jun 2005 10:58:04 +0000 Subject: [PATCH] ABI stuff. --- src/vm/jit/x86_64/md-abi.c | 121 +++++++++++++++++++++++++++++++ src/vm/jit/x86_64/md-abi.h | 132 ++++++++++++++++++++++++++++++++++ src/vm/jit/x86_64/md-abi.inc | 71 ++++++++++++++++++ src/vm/jit/x86_64/md-asm.h | 136 +++++++++++++++++++++++++++++++++++ src/vm/jit/x86_64/md.h | 60 ++++++++++++++++ 5 files changed, 520 insertions(+) create mode 100644 src/vm/jit/x86_64/md-abi.c create mode 100644 src/vm/jit/x86_64/md-abi.h create mode 100644 src/vm/jit/x86_64/md-abi.inc create mode 100644 src/vm/jit/x86_64/md-asm.h create mode 100644 src/vm/jit/x86_64/md.h diff --git a/src/vm/jit/x86_64/md-abi.c b/src/vm/jit/x86_64/md-abi.c new file mode 100644 index 000000000..f0ef4b841 --- /dev/null +++ b/src/vm/jit/x86_64/md-abi.c @@ -0,0 +1,121 @@ +/* src/vm/jit/x86_64/md-abi.c - functions for x86_64 Linux ABI + + Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + Contact: cacao@complang.tuwien.ac.at + + Authors: Christian Thalinger + + Changes: + + $Id: md-abi.c 2588 2005-06-08 10:58:04Z twisti $ + +*/ + + +#include "vm/jit/x86_64/types.h" +#include "vm/jit/x86_64/md-abi.h" + +#include "vm/descriptor.h" +#include "vm/global.h" + + +/* md_param_alloc ************************************************************** + + XXX + +*******************************************************************************/ + +void md_param_alloc(methoddesc *md) +{ + paramdesc *pd; + s4 i; + s4 iarg; + s4 farg; + s4 stacksize; + + /* set default values */ + + iarg = 0; + farg = 0; + stacksize = 0; + + /* get params field of methoddesc */ + + pd = md->params; + + for (i = 0; i < md->paramcount; i++, pd++) { + switch (md->paramtypes[i].type) { + case TYPE_INT: + case TYPE_ADR: + case TYPE_LNG: + if (iarg < INT_ARG_CNT) { + pd->inmemory = false; + pd->regoff = iarg; + + } else { + pd->inmemory = true; + pd->regoff = stacksize; + } + if (iarg < INT_ARG_CNT) + iarg++; + else + stacksize++; + break; + case TYPE_FLT: + case TYPE_DBL: + if (farg < FLT_ARG_CNT) { + pd->inmemory = false; + pd->regoff = farg; + } else { + pd->inmemory = true; + pd->regoff = stacksize; + } + if (farg < FLT_ARG_CNT) + farg++; + else + stacksize++; + break; + } + } + + /* fill register and stack usage */ + + md->argintreguse = iarg; + md->argfltreguse = farg; + md->memuse = stacksize; +} + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/x86_64/md-abi.h b/src/vm/jit/x86_64/md-abi.h new file mode 100644 index 000000000..fbd1df64e --- /dev/null +++ b/src/vm/jit/x86_64/md-abi.h @@ -0,0 +1,132 @@ +/* src/vm/jit/x86_64/md-abi.h - defines for x86_64 Linux ABI + + Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + Contact: cacao@complang.tuwien.ac.at + + Authors: Christian Thalinger + + Changes: + + $Id: md-abi.h 2588 2005-06-08 10:58:04Z twisti $ + +*/ + + +#ifndef _MD_ABI_H +#define _MD_ABI_H + +/* define registers ***********************************************************/ + +#define RIP -1 +#define RAX 0 +#define RCX 1 +#define RDX 2 +#define RBX 3 +#define RSP 4 +#define RBP 5 +#define RSI 6 +#define RDI 7 +#define R8 8 +#define R9 9 +#define R10 10 +#define R11 11 +#define R12 12 +#define R13 13 +#define R14 14 +#define R15 15 + + +#define XMM0 0 +#define XMM1 1 +#define XMM2 2 +#define XMM3 3 +#define XMM4 4 +#define XMM5 5 +#define XMM6 6 +#define XMM7 7 +#define XMM8 8 +#define XMM9 9 +#define XMM10 10 +#define XMM11 11 +#define XMM12 12 +#define XMM13 13 +#define XMM14 14 +#define XMM15 15 + + +/* preallocated registers *****************************************************/ + +/* integer registers */ + +#define REG_RESULT RAX /* to deliver method results */ + +#define REG_ITMP1 RAX /* temporary register */ +#define REG_ITMP2 R10 /* temporary register and method pointer */ +#define REG_ITMP3 R11 /* temporary register */ + +#define REG_NULL -1 /* used for reg_of_var where d is not needed */ + +#define REG_ITMP1_XPTR RAX /* exception pointer = temporary register 1 */ +#define REG_ITMP2_XPC R10 /* exception pc = temporary register 2 */ + +#define REG_SP RSP /* stack pointer */ + +/* floating point registers */ + +#define REG_FRESULT XMM0 /* to deliver floating point method results */ + +#define REG_FTMP1 XMM8 /* temporary floating point register */ +#define REG_FTMP2 XMM9 /* temporary floating point register */ +#define REG_FTMP3 XMM10 /* temporary floating point register */ + + +#define INT_REG_CNT 16 /* number of integer registers */ +#define INT_SAV_CNT 5 /* number of integer callee saved registers */ +#define INT_ARG_CNT 6 /* number of integer argument registers */ +#define INT_TMP_CNT 1 /* number of integer temporary registers */ +#define INT_RES_CNT 3 /* number of integer reserved registers */ + +#define FLT_REG_CNT 16 /* number of float registers */ +#define FLT_SAV_CNT 0 /* number of float callee saved registers */ +#define FLT_ARG_CNT 8 /* number of float argument registers */ +#define FLT_TMP_CNT 5 /* number of float temporary registers */ +#define FLT_RES_CNT 3 /* number of float reserved registers */ + +#define TRACE_ARGS_NUM 6 + +#endif /* _MD_ABI_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/x86_64/md-abi.inc b/src/vm/jit/x86_64/md-abi.inc new file mode 100644 index 000000000..f4430c2a8 --- /dev/null +++ b/src/vm/jit/x86_64/md-abi.inc @@ -0,0 +1,71 @@ +/* src/vm/jit/x86_64/md-abi.inc - stuff for x86_64 Linux ABI + + Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + Contact: cacao@complang.tuwien.ac.at + + Authors: Christian Thalinger + + Changes: + + $Id: md-abi.inc 2588 2005-06-08 10:58:04Z twisti $ + +*/ + + +#ifndef _MD_ABI_INC +#define _MD_ABI_INC + +#include "vm/jit/jit.h" + + +/* register descripton array **************************************************/ + +static int nregdescint[] = { + REG_RET, REG_ARG, REG_ARG, REG_TMP, REG_RES, REG_SAV, REG_ARG, REG_ARG, + REG_ARG, REG_ARG, REG_RES, REG_RES, REG_SAV, REG_SAV, REG_SAV, REG_SAV, + REG_END +}; + + +static int nregdescfloat[] = { + REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, + REG_RES, REG_RES, REG_RES, REG_TMP, REG_TMP, REG_TMP, REG_TMP, REG_TMP, + REG_END +}; + +#endif /* _MD_ABI_INC */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/x86_64/md-asm.h b/src/vm/jit/x86_64/md-asm.h new file mode 100644 index 000000000..b1190bd4e --- /dev/null +++ b/src/vm/jit/x86_64/md-asm.h @@ -0,0 +1,136 @@ +/* src/vm/jit/x86_64/md-asm.h - assembler defines for x86_64 Linux ABI + + Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + Contact: cacao@complang.tuwien.ac.at + + Authors: Christian Thalinger + + Changes: + + $Id: md-asm.h 2588 2005-06-08 10:58:04Z twisti $ + +*/ + + +#ifndef _MD_ASM_H +#define _MD_ASM_H + + +/* register defines ***********************************************************/ + +#define v0 %rax +#define v0l %eax + +#define a0 %rdi +#define a1 %rsi +#define a2 %rdx +#define a3 %rcx +#define a4 %r8 +#define a5 %r9 + +#define fa0 %xmm0 +#define fa1 %xmm1 +#define fa2 %xmm2 +#define fa3 %xmm3 +#define fa4 %xmm4 +#define fa5 %xmm5 +#define fa6 %xmm6 +#define fa7 %xmm7 + +#define itmp1 %rax +#define itmp2 %r10 +#define itmp3 %r11 + +#define itmp1l %eax +#define itmp2l %r10d +#define itmp3l %r11d + +#define itmp1b %al +#define itmp2b %r10b +#define itmp3b %r11b + +#define xptr itmp1 +#define xpc itmp2 + + +/* save and restore macros ****************************************************/ + +#define SAVE_ARGUMENT_REGISTERS(off) \ + mov a0,(0+(off))*8(%rsp) ; \ + mov a1,(1+(off))*8(%rsp) ; \ + mov a2,(2+(off))*8(%rsp) ; \ + mov a3,(3+(off))*8(%rsp) ; \ + mov a4,(4+(off))*8(%rsp) ; \ + mov a5,(5+(off))*8(%rsp) ; \ + \ + movq fa0,(6+(off))*8(%rsp) ; \ + movq fa1,(7+(off))*8(%rsp) ; \ + movq fa2,(8+(off))*8(%rsp) ; \ + movq fa3,(9+(off))*8(%rsp) ; \ + movq fa4,(10+(off))*8(%rsp) ; \ + movq fa5,(11+(off))*8(%rsp) ; \ + movq fa6,(12+(off))*8(%rsp) ; \ + movq fa7,(13+(off))*8(%rsp) ; + + +#define RESTORE_ARGUMENT_REGISTERS(off) \ + mov (0+(off))*8(%rsp),a0 ; \ + mov (1+(off))*8(%rsp),a1 ; \ + mov (2+(off))*8(%rsp),a2 ; \ + mov (3+(off))*8(%rsp),a3 ; \ + mov (4+(off))*8(%rsp),a4 ; \ + mov (5+(off))*8(%rsp),a5 ; \ + \ + movq (6+(off))*8(%rsp),fa0 ; \ + movq (7+(off))*8(%rsp),fa1 ; \ + movq (8+(off))*8(%rsp),fa2 ; \ + movq (9+(off))*8(%rsp),fa3 ; \ + movq (10+(off))*8(%rsp),fa4 ; \ + movq (11+(off))*8(%rsp),fa5 ; \ + movq (12+(off))*8(%rsp),fa6 ; \ + movq (13+(off))*8(%rsp),fa7 ; + + +#define SAVE_TEMPORARY_REGISTERS(off) \ + mov %rbx,(0+(off))*8(%rsp) + + +#define RESTORE_TEMPORARY_REGISTERS(off) \ + mov (0+(off))*8(%rsp),%rbx + +#endif /* _MD_ASM_H */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ diff --git a/src/vm/jit/x86_64/md.h b/src/vm/jit/x86_64/md.h new file mode 100644 index 000000000..25d6f44d2 --- /dev/null +++ b/src/vm/jit/x86_64/md.h @@ -0,0 +1,60 @@ +/* src/vm/jit/x86_64/md.h - machine dependent x86_64 Linux functions + + Copyright (C) 1996-2005 R. Grafl, A. Krall, C. Kruegel, C. Oates, + R. Obermaisser, M. Platter, M. Probst, S. Ring, E. Steiner, + C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich, J. Wenninger, + Institut f. Computersprachen - TU Wien + + This file is part of CACAO. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License as + published by the Free Software Foundation; either version 2, or (at + your option) any later version. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA + 02111-1307, USA. + + Contact: cacao@complang.tuwien.ac.at + + Authors: Christian Thalinger + + Changes: + + $Id: md.h 2588 2005-06-08 10:58:04Z twisti $ + +*/ + + +#ifndef _MD_H +#define _MD_H + +#include "vm/descriptor.h" + + +/* function prototypes ********************************************************/ + +void md_param_alloc(methoddesc *md); + +#endif /* _MD_H_ */ + + +/* + * These are local overrides for various environment variables in Emacs. + * Please do not remove this and leave it at the end of the file, where + * Emacs will automagically detect them. + * --------------------------------------------------------------------- + * Local variables: + * mode: c + * indent-tabs-mode: t + * c-basic-offset: 4 + * tab-width: 4 + * End: + */ -- 2.25.1