Merged revisions 7688-7692 via svnmerge from
[cacao.git] / src / vm / jit / x86_64 / md-abi.c
index 031093b7a5881e825ad8ac213cc4d54ebd3f093d..307cc26787024cf6288343f16cfe0898eef842a1 100644 (file)
@@ -22,7 +22,7 @@
    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
    02110-1301, USA.
 
-   $Id: md-abi.c 7248 2007-01-29 19:28:12Z twisti $
+   $Id: md-abi.c 7630 2007-04-02 19:56:14Z twisti $
 
 */
 
@@ -34,6 +34,8 @@
 
 #include "vm/global.h"
 
+#include "vm/jit/jit.h" /* for REG_* (maybe can be removed) */
+
 #include "vmcore/descriptor.h"
 
 
@@ -45,11 +47,32 @@ s4 nregdescint[] = {
     REG_END
 };
 
-char *regs[] = {
+const char *abi_registers_integer_name[] = {
        "rax", "rcx", "rdx", "rbx", "rsp", "rbp", "rsi", "rdi",
        "r8",  "r9",  "r10", "r11", "r12", "r13", "r14", "r15"
 };
 
+const s4 abi_registers_integer_argument[] = {
+       7,  /* a0 */
+       6,  /* a1 */
+       2,  /* a2 */
+       1,  /* a3 */
+       8,  /* a4 */
+       9,  /* a5 */
+};
+
+const s4 abi_registers_integer_saved[] = {
+       7,  /* s0 */
+       12, /* s1 */
+       13, /* s2 */
+       14, /* s3 */
+       15, /* s4 */
+};
+
+const s4 abi_registers_integer_temporary[] = {
+       3,  /* t0 */
+};
+
 
 s4 nregdescfloat[] = {
     REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG, REG_ARG,
@@ -90,15 +113,13 @@ void md_param_alloc(methoddesc *md)
                        if (iarg < INT_ARG_CNT) {
                                pd->inmemory = false;
                                pd->regoff   = iarg;
+                               iarg++;
                        }
                        else {
                                pd->inmemory = true;
                                pd->regoff   = stacksize;
-                       }
-                       if (iarg < INT_ARG_CNT)
-                               iarg++;
-                       else
                                stacksize++;
+                       }
                        break;
 
                case TYPE_FLT:
@@ -106,15 +127,13 @@ void md_param_alloc(methoddesc *md)
                        if (farg < FLT_ARG_CNT) {
                                pd->inmemory = false;
                                pd->regoff   = farg;
+                               farg++;
                        }
                        else {
                                pd->inmemory = true;
                                pd->regoff   = stacksize;
-                       }
-                       if (farg < FLT_ARG_CNT)
-                               farg++;
-                       else
                                stacksize++;
+                       }
                        break;
                }
        }
@@ -134,6 +153,21 @@ void md_param_alloc(methoddesc *md)
 }
 
 
+/* md_param_alloc_native *******************************************************
+
+   Pre-allocate arguments according the native ABI.
+
+*******************************************************************************/
+
+void md_param_alloc_native(methoddesc *md)
+{
+       /* On x86_64 we use the same ABI for JIT method calls as for
+          native method calls. */
+
+       md_param_alloc(md);
+}
+
+
 /* md_return_alloc *************************************************************
 
    Precolor the Java Stackelement containing the Return Value. Only