Skip to content

Commit 9f2dad9

Browse files
committed
address review comments
1 parent 579eda9 commit 9f2dad9

File tree

3 files changed

+21
-30
lines changed

3 files changed

+21
-30
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 FALSE;
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 & 29 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

@@ -2147,7 +2149,6 @@ emit_sri_vector (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *fsi
21472149
return NULL;
21482150
#endif
21492151

2150-
21512152
return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, arg0_type, id);
21522153
}
21532154
case SN_Divide: {
@@ -3849,7 +3850,7 @@ emit_sri_vector_t (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
38493850
return NULL;
38503851
arg0_type = fsig->param_count > 0 ? get_underlying_type (fsig->params [0]) : MONO_TYPE_VOID;
38513852
#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)
3853+
if (!mono_hwcap_s390x_has_ve1 && arg0_type == MONO_TYPE_R4)
38533854
return NULL;
38543855
#endif
38553856
return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, arg0_type, id);
@@ -3968,6 +3969,11 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
39683969
return NULL;
39693970
#endif
39703971

3972+
#ifdef TARGET_S390X
3973+
if (!mono_hwcap_s390x_has_ve1)
3974+
return NULL;
3975+
#endif
3976+
39713977
if (!(cfg->opt & MONO_OPT_SIMD))
39723978
return NULL;
39733979

@@ -4218,18 +4224,10 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42184224
#ifndef TARGET_ARM64
42194225
if ((id == SN_Max) || (id == SN_Min))
42204226
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;
42254227
#endif
42264228
return emit_simd_ins_for_binary_op (cfg, klass, fsig, args, MONO_TYPE_R4, id);
42274229
}
42284230
case SN_Dot: {
4229-
#ifdef TARGET_S390X
4230-
if (!mono_hwcap_s390x_has_ve1)
4231-
return NULL;
4232-
#endif
42334231
return emit_dot (cfg, klass, fsig->params [0], MONO_TYPE_R4, args [0]->dreg, args [1]->dreg);
42344232
}
42354233
case SN_Negate:
@@ -4248,10 +4246,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42484246
return emit_simd_ins_for_sig (cfg, cmethod->klass, OP_XOP_OVR_X_X, INTRINS_AARCH64_ADV_SIMD_FABS, MONO_TYPE_R4, fsig, args);
42494247
#endif
42504248
}
4251-
#ifdef TARGET_S390X
4252-
if (!mono_hwcap_s390x_has_ve1)
4253-
return NULL;
4254-
#endif
42554249
// MAX(x,0-x)
42564250
MonoInst *zero = emit_xzero (cfg, klass);
42574251
MonoInst *neg = emit_simd_ins (cfg, klass, OP_XBINOP, zero->dreg, args [0]->dreg);
@@ -4265,20 +4259,12 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42654259
case SN_op_Equality: {
42664260
if (!(fsig->param_count == 2 && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)))
42674261
return NULL;
4268-
#ifdef TARGET_S390X
4269-
if (!mono_hwcap_s390x_has_ve1)
4270-
return NULL;
4271-
#endif
42724262
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
42734263
return emit_xequal (cfg, arg_class, MONO_TYPE_R4, args [0], args [1]);
42744264
}
42754265
case SN_op_Inequality: {
42764266
if (!(fsig->param_count == 2 && mono_metadata_type_equal (fsig->params [0], type) && mono_metadata_type_equal (fsig->params [1], type)))
42774267
return NULL;
4278-
#ifdef TARGET_S390X
4279-
if (!mono_hwcap_s390x_has_ve1)
4280-
return NULL;
4281-
#endif
42824268
MonoClass *arg_class = mono_class_from_mono_type_internal (fsig->params [0]);
42834269
return emit_not_xequal (cfg, arg_class, MONO_TYPE_R4, args [0], args [1]);
42844270
}
@@ -4290,8 +4276,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
42904276
ins->inst_c0 = (IntrinsicId)INTRINS_SIMD_SQRT_R4;
42914277
return ins;
42924278
#elif defined(TARGET_S390X)
4293-
if (!mono_hwcap_s390x_has_ve1)
4294-
return NULL;
42954279
ins = emit_simd_ins (cfg, klass, OP_S390_VFSQSB, args [0]->dreg, -1);
42964280
return ins;
42974281
#else
@@ -4308,10 +4292,6 @@ emit_vector_2_3_4 (MonoCompile *cfg, MonoMethod *cmethod, MonoMethodSignature *f
43084292
if (id == SN_Clamp)
43094293
return NULL;
43104294
#endif
4311-
#ifdef TARGET_S390X
4312-
if (!mono_hwcap_s390x_has_ve1)
4313-
return NULL;
4314-
#endif
43154295

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

0 commit comments

Comments
 (0)