Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mono][amd64] Pass and return SIMD values in SIMD registers. #93182

Closed
wants to merge 6 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion src/mono/mono/mini/cpu-amd64.mdesc
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,9 @@ vcall_reg: src1:i len:64 clob:c
vcall_membase: src1:b len:64 clob:c
call_reg: dest:a src1:i len:32 clob:c
call_membase: dest:a src1:b len:32 clob:c
xcall: dest:x len:64 clob:c
xcall_reg: dest:x src1:i len:64 clob:c
xcall_membase: dest:x src1:b len:64 clob:c
iconst: dest:i len:10
i8const: dest:i len:10
r4const: dest:f len:17
Expand Down Expand Up @@ -597,7 +600,7 @@ vcall2: len:64 clob:c
vcall2_reg: src1:i len:64 clob:c
vcall2_membase: src1:b len:64 clob:c

dyn_call: src1:i src2:i len:192 clob:c
dyn_call: src1:i src2:i len:252 clob:c

localloc_imm: dest:i len:120

Expand Down Expand Up @@ -786,6 +789,7 @@ cvttpd2dq: dest:x src1:x len:5 clob:1
cvttps2dq: dest:x src1:x len:5 clob:1

xmove: dest:x src1:x len:5
xmove_arg: dest:x src1:x len:5
xzero: dest:x len:5
xones: dest:x len:5
xconst: dest:x len:12
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/decompose.c
Original file line number Diff line number Diff line change
Expand Up @@ -1344,7 +1344,7 @@ mono_decompose_vtype_opts (MonoCompile *cfg)
MonoCallInst *call = (MonoCallInst*)ins;
int size;

if (COMPILE_LLVM (cfg))
if (COMPILE_LLVM (cfg) || call->dont_decompose)
break;

if (call->vret_in_reg) {
Expand Down
34 changes: 34 additions & 0 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,12 @@ mono_alloc_preg (MonoCompile *cfg)
return alloc_preg (cfg);
}

guint32
mono_alloc_xreg (MonoCompile *cfg)
{
return alloc_xreg (cfg);
}

guint32
mono_alloc_dreg (MonoCompile *cfg, MonoStackType stack_type)
{
Expand Down Expand Up @@ -1692,6 +1698,34 @@ MONO_RESTORE_WARNING
return ins;
}

MonoInst*
mini_emit_regmove (MonoCompile *cfg, int sreg, MonoType *type)
{
MonoInst *ins;
int opcode = mono_type_to_regmove (cfg, type);

if (opcode == OP_FMOVE) {
MONO_INST_NEW (cfg, ins, OP_FMOVE);
ins->dreg = mono_alloc_freg (cfg);
} else if (opcode == OP_LMOVE) {
MONO_INST_NEW (cfg, ins, OP_LMOVE);
ins->dreg = mono_alloc_lreg (cfg);
} else if (opcode == OP_RMOVE) {
MONO_INST_NEW (cfg, ins, OP_RMOVE);
ins->dreg = mono_alloc_freg (cfg);
} else if (opcode == OP_XMOVE) {
MONO_INST_NEW (cfg, ins, OP_XMOVE);
ins->dreg = mono_alloc_xreg (cfg);
ins->klass = mono_class_from_mono_type_internal (type);
} else {
MONO_INST_NEW (cfg, ins, OP_MOVE);
ins->dreg = mono_alloc_ireg (cfg);
}
ins->sreg1 = sreg;

return ins;
}

static MonoInst*
mono_create_fast_tls_getter (MonoCompile *cfg, MonoTlsKey key)
{
Expand Down
34 changes: 20 additions & 14 deletions src/mono/mono/mini/mini-amd64-gsharedvt.c
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,7 @@ get_arg_slots (ArgInfo *ainfo, int **out_slots, gboolean is_source_argument)
break;
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
case ArgSIMDInSSEReg:
nsrc = 1;
src = g_malloc (nsrc * sizeof (int));
src [0] = map_freg (sreg);
Expand Down Expand Up @@ -224,20 +225,21 @@ static void
handle_marshal_when_dst_gsharedvt (ArgInfo *src_info, int *arg_marshal)
{
switch (src_info->storage) {
case ArgInIReg:
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
case ArgValuetypeInReg:
case ArgOnStack:
*arg_marshal = GSHAREDVT_ARG_BYVAL_TO_BYREF;
break;
case ArgValuetypeAddrInIReg:
case ArgValuetypeAddrOnStack:
*arg_marshal = GSHAREDVT_ARG_NONE;
break;
default:
NOT_IMPLEMENTED; // See above
break;
case ArgInIReg:
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
case ArgSIMDInSSEReg:
case ArgValuetypeInReg:
case ArgOnStack:
*arg_marshal = GSHAREDVT_ARG_BYVAL_TO_BYREF;
break;
case ArgValuetypeAddrInIReg:
case ArgValuetypeAddrOnStack:
*arg_marshal = GSHAREDVT_ARG_NONE;
break;
default:
NOT_IMPLEMENTED; // See above
break;
}
}

Expand Down Expand Up @@ -331,6 +333,7 @@ mono_arch_get_gsharedvt_call_info (MonoMemoryManager *mem_manager, gpointer addr
case ArgInIReg:
case ArgInDoubleSSEReg:
case ArgInFloatSSEReg:
case ArgSIMDInSSEReg:
case ArgValuetypeInReg:
case ArgOnStack:
nsrc = get_arg_slots (src_info, &src, TRUE);
Expand Down Expand Up @@ -500,6 +503,9 @@ mono_arch_get_gsharedvt_call_info (MonoMemoryManager *mem_manager, gpointer addr
case ArgInFloatSSEReg:
info->ret_marshal = GSHAREDVT_RET_R8;
break;
case ArgSIMDInSSEReg:
info->ret_marshal = GSHAREDVT_RET_SIMD;
break;
case ArgValuetypeAddrInIReg:
break;
default:
Expand Down
1 change: 1 addition & 0 deletions src/mono/mono/mini/mini-amd64-gsharedvt.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ typedef enum {
GSHAREDVT_RET_I8, // 8 byte integer
GSHAREDVT_RET_IREGS_1, // Load in first return register
GSHAREDVT_RET_R8, // Double
GSHAREDVT_RET_SIMD, // SIMD
GSHAREDVT_RET_NUM,
} GSharedVtRetMarshal;

Expand Down
Loading
Loading