-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Adding support to mono for v128 constants #81902
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
Changes from all commits
f3f0340
046ddc9
ed988af
e21a876
1fa29d7
cef739e
c94cb5c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7005,6 +7005,13 @@ encode_patch (MonoAotCompile *acfg, MonoJumpInfo *patch_info, guint8 *buf, guint | |
| encode_value (((guint32 *)patch_info->data.target) [MINI_LS_WORD_IDX], p, &p); | ||
| encode_value (((guint32 *)patch_info->data.target) [MINI_MS_WORD_IDX], p, &p); | ||
| break; | ||
| case MONO_PATCH_INFO_X128: | ||
| case MONO_PATCH_INFO_X128_GOT: | ||
| encode_value (((guint32 *)patch_info->data.target) [(MINI_LS_WORD_IDX * 2) + MINI_LS_WORD_IDX], p, &p); | ||
| encode_value (((guint32 *)patch_info->data.target) [(MINI_LS_WORD_IDX * 2) + MINI_MS_WORD_IDX], p, &p); | ||
| encode_value (((guint32 *)patch_info->data.target) [(MINI_MS_WORD_IDX * 2) + MINI_LS_WORD_IDX], p, &p); | ||
| encode_value (((guint32 *)patch_info->data.target) [(MINI_MS_WORD_IDX * 2) + MINI_MS_WORD_IDX], p, &p); | ||
|
Comment on lines
+7008
to
+7013
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. AFAIK, there isn't any SIMD support for BE architectures today. It's possibly this needs to track the underlying element type and splat each |
||
| break; | ||
| case MONO_PATCH_INFO_VTABLE: | ||
| case MONO_PATCH_INFO_CLASS: | ||
| case MONO_PATCH_INFO_IID: | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7296,6 +7296,17 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) | |
| case OP_XONES: | ||
| amd64_sse_pcmpeqb_reg_reg (code, ins->dreg, ins->dreg); | ||
| break; | ||
| case OP_XCONST: { | ||
| if (cfg->compile_aot && cfg->code_exec_only) { | ||
| mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_X128_GOT, ins->inst_p0); | ||
| amd64_mov_reg_membase (code, AMD64_R11, AMD64_RIP, 0, sizeof(gpointer)); | ||
| amd64_sse_movups_reg_membase (code, ins->dreg, AMD64_R11, 0); | ||
| } else { | ||
| mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_X128, ins->inst_p0); | ||
| amd64_sse_movups_reg_membase (code, ins->dreg, AMD64_RIP, 0); | ||
| } | ||
| break; | ||
| } | ||
| case OP_ICONV_TO_R4_RAW: | ||
| amd64_movd_xreg_reg_size (code, ins->dreg, ins->sreg1, 4); | ||
| if (!cfg->r4fp) | ||
|
|
@@ -8140,11 +8151,13 @@ mono_arch_emit_exceptions (MonoCompile *cfg) | |
| for (patch_info = cfg->patch_info; patch_info; patch_info = patch_info->next) { | ||
| if (patch_info->type == MONO_PATCH_INFO_EXC) | ||
| code_size += 40; | ||
| if (patch_info->type == MONO_PATCH_INFO_R8) | ||
| else if (patch_info->type == MONO_PATCH_INFO_X128) | ||
| code_size += 16 + 15; /* sizeof (Vector128<T>) + alignment */ | ||
| else if (patch_info->type == MONO_PATCH_INFO_R8) | ||
| code_size += 8 + 15; /* sizeof (double) + alignment */ | ||
| if (patch_info->type == MONO_PATCH_INFO_R4) | ||
| else if (patch_info->type == MONO_PATCH_INFO_R4) | ||
| code_size += 4 + 15; /* sizeof (float) + alignment */ | ||
| if (patch_info->type == MONO_PATCH_INFO_GC_CARD_TABLE_ADDR) | ||
| else if (patch_info->type == MONO_PATCH_INFO_GC_CARD_TABLE_ADDR) | ||
|
Comment on lines
+8154
to
+8160
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As per the FIXME comment below, the alignment here only needs to be That should ideally be fixed and those updated to properly use X128 constants to save on space and help ensure correctness. |
||
| code_size += 8 + 7; /*sizeof (void*) + alignment */ | ||
| } | ||
|
|
||
|
|
@@ -8218,6 +8231,10 @@ mono_arch_emit_exceptions (MonoCompile *cfg) | |
| guint8 *pos, *patch_pos; | ||
| guint32 target_pos; | ||
|
|
||
| // FIXME: R8 and R4 only need 8 and 4 byte alignment, respectively | ||
| // They should be handled separately with anything needing 16 byte | ||
| // alignment using X128 | ||
|
|
||
| /* The SSE opcodes require a 16 byte alignment */ | ||
| code = (guint8*)ALIGN_TO (code, 16); | ||
|
|
||
|
|
@@ -8244,6 +8261,31 @@ mono_arch_emit_exceptions (MonoCompile *cfg) | |
| remove = TRUE; | ||
| break; | ||
| } | ||
| case MONO_PATCH_INFO_X128: { | ||
| guint8 *pos, *patch_pos; | ||
| guint32 target_pos; | ||
|
|
||
| /* The SSE opcodes require a 16 byte alignment */ | ||
| code = (guint8*)ALIGN_TO (code, 16); | ||
|
|
||
| pos = cfg->native_code + patch_info->ip.i; | ||
| if (IS_REX (pos [0])) { | ||
| patch_pos = pos + 4; | ||
| target_pos = GPTRDIFF_TO_UINT32 (code - pos - 8); | ||
| } | ||
| else { | ||
| patch_pos = pos + 3; | ||
| target_pos = GPTRDIFF_TO_UINT32 (code - pos - 7); | ||
| } | ||
|
|
||
| memcpy (code, patch_info->data.target, 16); | ||
| code += 16; | ||
|
|
||
| *(guint32*)(patch_pos) = target_pos; | ||
|
|
||
| remove = TRUE; | ||
| break; | ||
| } | ||
|
Comment on lines
+8264
to
+8288
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The original handling I added was the cause of the failures. MonoJIT doesn't support the VEX encoding today (only the legacy encoding) and the For that scenario, we have:
So this the For
Thus it's 1-byte smaller. We could but don't want to emit We could emit When the VEX support is added this all becomes a constant |
||
| case MONO_PATCH_INFO_GC_CARD_TABLE_ADDR: { | ||
| guint8 *pos; | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1281,6 +1281,8 @@ mono_patch_info_hash (gconstpointer data) | |
| } | ||
| case MONO_PATCH_INFO_GSHAREDVT_IN_WRAPPER: | ||
| return hash | mono_signature_hash (ji->data.sig); | ||
| case MONO_PATCH_INFO_X128_GOT: | ||
| return hash | (guint32)*(double*)ji->data.target; | ||
| case MONO_PATCH_INFO_R8_GOT: | ||
| return hash | (guint32)*(double*)ji->data.target; | ||
|
Comment on lines
+1284
to
1287
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is how the hashes are currently being built for R4/R8, but they don't necessarily make "sense" to me. This isn't a "good" hash since it just
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's not the best, but its just used during JITting/AOTing, so it's not a problem in practice. |
||
| case MONO_PATCH_INFO_R4_GOT: | ||
|
|
@@ -1605,6 +1607,8 @@ mono_resolve_patch_target_ext (MonoMemoryManager *mem_manager, MonoMethod *metho | |
| case MONO_PATCH_INFO_R4_GOT: | ||
| case MONO_PATCH_INFO_R8: | ||
| case MONO_PATCH_INFO_R8_GOT: | ||
| case MONO_PATCH_INFO_X128: | ||
| case MONO_PATCH_INFO_X128_GOT: | ||
| target = patch_info->data.target; | ||
| break; | ||
| case MONO_PATCH_INFO_EXC_NAME: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.