[Mesa-dev] [PATCH] rtasm/translate_sse: support Win64
Luca Barbieri
luca at luca-barbieri.com
Fri Aug 13 05:09:18 PDT 2010
I just discovered that Microsoft wisely decided to use their own
calling convention on Win64...
This hasn't actually been tested on Win64 though.
---
src/gallium/auxiliary/rtasm/rtasm_x86sse.c | 15 +++++++++++++++
src/gallium/auxiliary/translate/translate_sse.c | 21 +++++++++------------
2 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
index 6d6b76a..a076e17 100644
--- a/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
+++ b/src/gallium/auxiliary/rtasm/rtasm_x86sse.c
@@ -2090,6 +2090,20 @@ struct x86_reg x86_fn_arg( struct x86_function *p,
{
switch(arg)
{
+/* Microsoft uses a different calling convention than the rest of the world */
+#ifdef WIN64
+ case 1:
+ return x86_make_reg(file_REG32, reg_CX);
+ case 2:
+ return x86_make_reg(file_REG32, reg_DX);
+ case 3:
+ return x86_make_reg(file_REG32, reg_R8);
+ case 4:
+ return x86_make_reg(file_REG32, reg_R9);
+ default:
+ return x86_make_disp(x86_make_reg(file_REG32, reg_SP),
+ p->stack_offset + (arg - 4) * 8); /* ??? */
+#else
case 1:
return x86_make_reg(file_REG32, reg_DI);
case 2:
@@ -2105,6 +2119,7 @@ struct x86_reg x86_fn_arg( struct x86_function *p,
default:
return x86_make_disp(x86_make_reg(file_REG32, reg_SP),
p->stack_offset + (arg - 6) * 8); /* ??? */
+#endif
}
}
#else
diff --git a/src/gallium/auxiliary/translate/translate_sse.c b/src/gallium/auxiliary/translate/translate_sse.c
index e2d8d53..5dfb186 100644
--- a/src/gallium/auxiliary/translate/translate_sse.c
+++ b/src/gallium/auxiliary/translate/translate_sse.c
@@ -1234,26 +1234,23 @@ static boolean build_vertex_emit( struct translate_sse *p,
x86_init_func(p->func);
-#ifdef PIPE_ARCH_X86_64
x86_push(p->func, p->outbuf_EBX);
x86_push(p->func, p->count_EBP);
- /* Load arguments into regs; the first two are already there */
- x86_mov(p->func, p->count_EBP, x86_fn_arg(p->func, 3));
- x64_mov64(p->func, p->outbuf_EBX, x86_fn_arg(p->func, 5));
-#else
- /* Push a few regs?
- */
- x86_push(p->func, p->outbuf_EBX);
- x86_push(p->func, p->count_EBP);
+/* on non-Win64 x86-64, these are already in the right registers */
+#if defined(PIPE_ARCH_X86) || defined(WIN64)
x86_push(p->func, p->machine_EDI);
x86_push(p->func, p->idx_ESI);
- /* Load arguments into regs:
- */
x86_mov(p->func, p->machine_EDI, x86_fn_arg(p->func, 1));
x86_mov(p->func, p->idx_ESI, x86_fn_arg(p->func, 2));
+#endif
+
x86_mov(p->func, p->count_EBP, x86_fn_arg(p->func, 3));
+
+#ifdef PIPE_ARCH_X86_64
+ x64_mov64(p->func, p->outbuf_EBX, x86_fn_arg(p->func, 5));
+#else
x86_mov(p->func, p->outbuf_EBX, x86_fn_arg(p->func, 5));
#endif
@@ -1333,7 +1330,7 @@ static boolean build_vertex_emit( struct translate_sse *p,
/* Pop regs and return
*/
-#ifndef PIPE_ARCH_X86_64
+#if defined(PIPE_ARCH_X86) || defined(WIN64)
x86_pop(p->func, p->idx_ESI);
x86_pop(p->func, p->machine_EDI);
#endif
--
1.7.0.4
More information about the mesa-dev
mailing list