Skip to content

Commit 0699ae9

Browse files
committed
address review comments
1 parent 579eda9 commit 0699ae9

File tree

3 files changed

+21
-29
lines changed

3 files changed

+21
-29
lines changed

src/mono/mono/mini/mini-s390x.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ struct SeqPointInfo {
8383
#define MONO_ARCH_HAVE_SETUP_RESUME_FROM_SIGNAL_HANDLER_CTX 1
8484
#define MONO_ARCH_HAVE_UNWIND_BACKTRACE 1
8585
#define MONO_ARCH_FLOAT32_SUPPORTED 1
86-
#define MONO_ARCH_SIMD_INTRINSICS mono_hwcap_s390x_has_vec
86+
#define MONO_ARCH_SIMD_INTRINSICS 1
8787
#define MONO_ARCH_NEED_SIMD_BANK 1
8888
#define MONO_ARCH_USE_SHARED_FP_SIMD_BANK 1
8989
#define S390_STACK_ALIGNMENT 8

src/mono/mono/mini/mini.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ typedef struct SeqPointInfo SeqPointInfo;
6464
#include "mono/metadata/callspec.h"
6565
#include "mono/metadata/icall-signatures.h"
6666

67+
/* we use runtime checks to fallback to scalar ops for/
68+
* older z/Architectures
69+
*/
70+
#ifdef TARGET_S390X
71+
#include <mono/utils/mono-hwcap.h>
72+
#endif
6773
/*
6874
* The mini code should not have any compile time dependencies on the GC being used, so the same object file from mini/
6975
* can be linked into both mono and mono-sgen.
@@ -3015,6 +3021,11 @@ mini_safepoints_enabled (void)
30153021
static inline gboolean
30163022
mini_class_is_simd (MonoCompile *cfg, MonoClass *klass)
30173023
{
3024+
#ifdef TARGET_S390X
3025+
/* vector facility was introduced in z13 */
3026+
if (!mono_hwcap_s390x_has_vec)
3027+
return NULL;
3028+
#endif
30183029
#ifdef MONO_ARCH_SIMD_INTRINSICS
30193030
if (!(((cfg)->opt & MONO_OPT_SIMD) && m_class_is_simd_type (klass)))
30203031
return FALSE;

src/mono/mono/mini/simd-intrinsics.c

Lines changed: 9 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2138,7 +2138,9 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
21382138
return NULL;
21392139

21402140
#if defined(TARGET_S390X)
2141-
if (!mono_hwcap_s390x_has_ve1 && ((id == SN_Max) || (id == SN_Min) || (id == SN_MaxNative) || (id == SN_MinNative) || (id !=SN_Xor) || (id != SN_BitwiseAnd) || (id != SN_BitwiseOr)) && arg0_type == MONO_TYPE_R4)
2141+
if (!mono_hwcap_s390x_has_ve1 && arg0_type == MONO_TYPE_R4)
2142+
return NULL;
2143+
if (!mono_hwcap_s390x_has_ve1 && ((id == SN_Max) || (id == SN_Min) || (id == SN_MaxNative) || (id == SN_MinNative)) && (arg0_type == MONO_TYPE_R8))
21422144
return NULL;
21432145
#endif
21442146

@@ -3849,7 +3851,7 @@ emit_sri_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
38493851
return NULL;
38503852
arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID;
38513853
#ifdef TARGET_S390X
3852-
if (!mono_hwcap_s390x_has_ve1 && ((id !=SN_op_ExclusiveOr) || (id != SN_op_BitwiseAnd) || (id != SN_op_BitwiseOr)) && arg0_type == MONO_TYPE_R4)
3854+
if (!mono_hwcap_s390x_has_ve1 && arg0_type == MONO_TYPE_R4)
38533855
return NULL;
38543856
#endif
38553857
return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, arg0_type, id);
@@ -3968,6 +3970,11 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
39683970
return NULL;
39693971
#endif
39703972

3973+
#ifdef TARGET_S390X
3974+
if (!mono_hwcap_s390x_has_ve1)
3975+
return NULL;
3976+
#endif
3977+
39713978
if (!(cfg->opt & MONO_OPT_SIMD))
39723979
return NULL;
39733980

@@ -4218,18 +4225,10 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42184225
#ifndef TARGET_ARM64
42194226
if ((id == SN_Max) || (id == SN_Min))
42204227
return NULL;
4221-
#endif
4222-
#ifdef TARGET_S390X
4223-
if (!mono_hwcap_s390x_has_ve1 && ((id == SN_Max) || (id == SN_Min) || (id == SN_MaxNative) || (id == SN_MinNative)))
4224-
return NULL;
42254228
#endif
42264229
return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, MONO_TYPE_R4, id);
42274230
}
42284231
case SN_Dot: {
4229-
#ifdef TARGET_S390X
4230-
if (!mono_hwcap_s390x_has_ve1)
4231-
return NULL;
4232-
#endif
42334232
return emit_dot (cfg, klass, fsig->params [0], MONO_TYPE_R4, args [0]->dreg, args [1]->dreg);
42344233
}
42354234
case SN_Negate:
@@ -4248,10 +4247,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42484247
return emit_simd_ins_for_sig (cfg, cmethod->klass, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_FABS, MONO_TYPE_R4, fsig, args);
42494248
#endif
42504249
}
4251-
#ifdef TARGET_S390X
4252-
if (!mono_hwcap_s390x_has_ve1)
4253-
return NULL;
4254-
#endif
42554250
// MAX(x,0-x)
42564251
MonoInst *zero = emit_xzero (cfg, klass);
42574252
MonoInst *neg = emit_simd_ins (cfg, klass, OP_XBINOP, zero->dreg, args [0]->dreg);
@@ -4265,20 +4260,12 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42654260
case SN_op_Equality: {
42664261
if (!(fsig->param_count == 2 && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)))
42674262
return NULL;
4268-
#ifdef TARGET_S390X
4269-
if (!mono_hwcap_s390x_has_ve1)
4270-
return NULL;
4271-
#endif
42724263
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
42734264
return emit_xequal (cfg, arg_class, MONO_TYPE_R4, args [0], args [1]);
42744265
}
42754266
case SN_op_Inequality: {
42764267
if (!(fsig->param_count == 2 && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)))
42774268
return NULL;
4278-
#ifdef TARGET_S390X
4279-
if (!mono_hwcap_s390x_has_ve1)
4280-
return NULL;
4281-
#endif
42824269
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
42834270
return emit_not_xequal (cfg, arg_class, MONO_TYPE_R4, args [0], args [1]);
42844271
}
@@ -4290,8 +4277,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42904277
ins->inst_c0 = (IntrinsicId)INTRINS_SIMD_SQRT_R4;
42914278
return ins;
42924279
#elif defined(TARGET_S390X)
4293-
if (!mono_hwcap_s390x_has_ve1)
4294-
return NULL;
42954280
ins = emit_simd_ins (cfg, klass, OP_S390_VFSQSB, args [0]->dreg, -1);
42964281
return ins;
42974282
#else
@@ -4308,10 +4293,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
43084293
if (id == SN_Clamp)
43094294
return NULL;
43104295
#endif
4311-
#ifdef TARGET_S390X
4312-
if (!mono_hwcap_s390x_has_ve1)
4313-
return NULL;
4314-
#endif
43154296

43164297
MonoInst *max = emit_simd_ins (cfg, klass, OP_XBINOP, args[0]->dreg, args[1]->dreg);
43174298
max->inst_c0 = OP_FMAX;

0 commit comments

Comments
 (0)