mono/mono-5.18.1-s390x-build.patch
2019-03-27 07:12:57 -04:00

125 lines
4.9 KiB
Diff

From 6d07dd66f1412b8f7eaadbcd9d660859d4227954 Mon Sep 17 00:00:00 2001
From: Neale Ferguson <neale@sinenomine.net>
Date: Sat, 11 Aug 2018 19:33:58 -0400
Subject: [PATCH] =?UTF-8?q?Fix=20s390x=20build=20broken=20by=20incorrect?=
=?UTF-8?q?=20specification=20of=20the=20msgfi=20instuc=E2=80=A6=20(#10026?=
=?UTF-8?q?)?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fix s390x build broken by incorrect specification of the msgfi instruction used in MUL_IMM type operations. The instruction had been encoded as its 32-bit counterpart (msfi).
In addition, the s390x microcode makes the mono_strength_reduction_division unnecessary so this can be bypassed.
The change to basic.make is just to avoid error messages when basic-profile-check.exe hasn't been built yet.
---
mcs/build/profiles/basic.make | 2 +-
mono/arch/s390x/s390x-codegen.h | 4 ++--
mono/mini/local-propagation.c | 9 +++------
mono/mini/mini-s390x.h | 1 +
mono/mini/mini.c | 3 +++
mono/mini/mini.h | 1 +
6 files changed, 11 insertions(+), 9 deletions(-)
diff --git a/mcs/build/profiles/basic.make b/mcs/build/profiles/basic.make
index eb2264efd457..7dd7770fc512 100644
--- a/mcs/build/profiles/basic.make
+++ b/mcs/build/profiles/basic.make
@@ -122,7 +122,7 @@ $(PROFILE_EXE): $(topdir)/build/common/basic-profile-check.cs $(GENSOURCES_CS)
$(BOOTSTRAP_MCS) /noconfig /langversion:latest /r:mscorlib.dll /r:System.dll /r:System.Core.dll /out:$(GENSOURCES_EXE).tmp $(GENSOURCES_CS)
- rm $(GENSOURCES_EXE)
mv $(GENSOURCES_EXE).tmp $(GENSOURCES_EXE)
- - rm $@
+ - rm -f $@
mv $@.tmp $@
$(PROFILE_OUT): $(PROFILE_EXE)
diff --git a/mono/arch/s390x/s390x-codegen.h b/mono/arch/s390x/s390x-codegen.h
index 49fc120f7d49..12fdd2894eaa 100644
--- a/mono/arch/s390x/s390x-codegen.h
+++ b/mono/arch/s390x/s390x-codegen.h
@@ -1393,8 +1393,8 @@ typedef struct {
#define s390_mlr(c, r1, r2) S390_RRE(c, 0xb996, r1, r2)
#define s390_mr(c, r1, r2) S390_RR(c, 0x1c, r1, r2)
#define s390_ms(c, r, x, b, d) S390_RX(c, 0x71, r, x, b, d)
-#define s390_msfi(c, r, v) S390_RIL_1(c, 0xc20, r, v)
-#define s390_msgfi(c, r, v) S390_RIL_1(c, 0xc21, r, v)
+#define s390_msfi(c, r, v) S390_RIL_1(c, 0xc21, r, v)
+#define s390_msgfi(c, r, v) S390_RIL_1(c, 0xc20, r, v)
#define s390_msgfr(c, r1, r2) S390_RRE(c, 0xb91c, r1, r2)
#define s390_msgr(c, r1, r2) S390_RRE(c, 0xb90c, r1, r2)
#define s390_msgrkc(c, r1, r2, r3) S390_RRF_1(c, 0xb9ed, r1, r2, r3)
diff --git a/mono/mini/local-propagation.c b/mono/mini/local-propagation.c
index 4b5e02ff28f0..d8e8461291aa 100644
--- a/mono/mini/local-propagation.c
+++ b/mono/mini/local-propagation.c
@@ -370,7 +370,7 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
}
case OP_IDIV_UN_IMM:
case OP_IDIV_IMM: {
- if (!COMPILE_LLVM (cfg))
+ if ((!COMPILE_LLVM (cfg)) && (!cfg->backend->optimized_div))
allocated_vregs = mono_strength_reduction_division (cfg, ins);
break;
}
@@ -383,10 +383,8 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
ins->opcode = OP_ICONST;
MONO_INST_NULLIFY_SREGS (ins);
ins->inst_c0 = 0;
-#if __s390__
- }
-#else
- } else if ((ins->inst_imm > 0) && (ins->inst_imm < (1LL << 32)) && (power != -1)) {
+ } else if ((ins->inst_imm > 0) && (ins->inst_imm < (1LL << 32)) &&
+ (power != -1) && (!cfg->backend->optimized_div)) {
gboolean is_long = ins->opcode == OP_LREM_IMM;
int compensator_reg = alloc_ireg (cfg);
int intermediate_reg;
@@ -411,7 +409,6 @@ mono_strength_reduction_ins (MonoCompile *cfg, MonoInst *ins, const char **spec)
allocated_vregs = TRUE;
}
-#endif
break;
}
#if SIZEOF_REGISTER == 4
diff --git a/mono/mini/mini-s390x.h b/mono/mini/mini-s390x.h
index 464ddb117894..9323182c0cc7 100644
--- a/mono/mini/mini-s390x.h
+++ b/mono/mini/mini-s390x.h
@@ -65,6 +65,7 @@ typedef struct
#define MONO_ARCH_HAVE_OP_GENERIC_CLASS_INIT 1
#define MONO_ARCH_HAVE_SETUP_ASYNC_CALLBACK 1
#define MONO_ARCH_HAVE_TRACK_FPREGS 1
+#define MONO_ARCH_HAVE_OPTIMIZED_DIV 1
#define S390_STACK_ALIGNMENT 8
#define S390_FIRST_ARG_REG s390_r2
diff --git a/mono/mini/mini.c b/mono/mini/mini.c
index 9fdf34bd2a98..fa7608daebfe 100644
--- a/mono/mini/mini.c
+++ b/mono/mini/mini.c
@@ -3045,6 +3045,9 @@ init_backend (MonoBackend *backend)
#ifdef MONO_ARCH_EXPLICIT_NULL_CHECKS
backend->explicit_null_checks = 1;
#endif
+#ifdef MONO_ARCH_HAVE_OPTIMIZED_DIV
+ backend->optimized_div = 1;
+#endif
}
/*
diff --git a/mono/mini/mini.h b/mono/mini/mini.h
index 780208ed8a57..fb217b3194b7 100644
--- a/mono/mini/mini.h
+++ b/mono/mini/mini.h
@@ -1150,6 +1150,7 @@ typedef struct {
guint no_unaligned_access : 1;
guint disable_div_with_mul : 1;
guint explicit_null_checks : 1;
+ guint optimized_div : 1;
int monitor_enter_adjustment;
int dyn_call_param_area;
} MonoBackend;