diff --git a/mono-core-ppc64le-swr11r12.diff b/0001-ppc64le-fixes.patch similarity index 66% rename from mono-core-ppc64le-swr11r12.diff rename to 0001-ppc64le-fixes.patch index 824ee35..0ba8f21 100644 --- a/mono-core-ppc64le-swr11r12.diff +++ b/0001-ppc64le-fixes.patch @@ -1,19 +1,45 @@ -Switch ppc_r11 with ppc_r12 +From efbddc02e76b3a532984de4237f77ba084899175 Mon Sep 17 00:00:00 2001 +From: Dinar Valeev +Date: Mon, 23 Mar 2015 23:19:48 +0100 +Subject: [PATCH] ppc64le fixes -This is a preliminary patch for ppc64le ELFv2 support. That one requires -r12 to hold a functions address at calls to normal (global) C functions. -As is r12 is also used by mini for its IMT_REG, VTABLE_REG and RGCTX_REG -to pass around values to functions outside the normal argument registers -(ugh!), so there's a conflict. This mechanical (by sed) patch simply switches -ppc_r11 and ppc_r12 everywhere, r11 doesn't have any special use in the ABI. +--- + mono/arch/ppc/ppc-codegen.h | 12 +- + mono/metadata/sgen-archdep.h | 7 + + mono/metadata/sgen-marksweep.c | 5 + + mono/mini/aot-compiler.c | 16 +- + mono/mini/cpu-ppc64.md | 4 +- + mono/mini/exceptions-ppc.c | 44 ++--- + mono/mini/mini-gc.c | 7 + + mono/mini/mini-mips.c | 12 +- + mono/mini/mini-ppc.c | 405 ++++++++++++++++++++++------------------- + mono/mini/mini-ppc.h | 15 +- + mono/mini/mini.c | 5 +- + mono/mini/tramp-ppc.c | 64 +++---- + mono/utils/mono-context.c | 27 +++ + mono/utils/strtod.c | 9 + + 14 files changed, 352 insertions(+), 280 deletions(-) -Index: mono-3.4.0/mono/arch/ppc/ppc-codegen.h -=================================================================== ---- mono-3.4.0.orig/mono/arch/ppc/ppc-codegen.h -+++ mono-3.4.0/mono/arch/ppc/ppc-codegen.h -@@ -810,9 +810,9 @@ my and Ximian's copyright to this code. - #define ppc_load_func(c,D,V) ppc_load_sequence ((c), (D), (V)) - #else +diff --git a/mono/arch/ppc/ppc-codegen.h b/mono/arch/ppc/ppc-codegen.h +index 55b5060..d4d25a2 100644 +--- a/mono/arch/ppc/ppc-codegen.h ++++ b/mono/arch/ppc/ppc-codegen.h +@@ -123,7 +123,7 @@ enum { + PPC_TRAP_GE_UN = 16 + PPC_TRAP_EQ + }; + +-#define ppc_emit32(c,x) do { *((guint32 *) (c)) = GUINT32_TO_BE (x); (c) = (gpointer)((guint8 *)(c) + sizeof (guint32));} while (0) ++#define ppc_emit32(c,x) do { *((guint32 *) (c)) = (guint32) (x); (c) = (gpointer)((guint8 *)(c) + sizeof (guint32));} while (0) + + #define ppc_is_imm16(val) ((((val)>> 15) == 0) || (((val)>> 15) == -1)) + #define ppc_is_uimm16(val) ((glong)(val) >= 0L && (glong)(val) <= 65535L) +@@ -806,11 +806,15 @@ my and Ximian's copyright to this code. ;) + } \ + } G_STMT_END + ++#if _CALL_ELF == 2 ++#define ppc_load_func(c,D,V) ppc_load_sequence ((c), (D), (V)) ++#else #define ppc_load_func(c,D,v) G_STMT_START { \ - ppc_load_sequence ((c), ppc_r11, (guint64)(gsize)(v)); \ - ppc_ldptr ((c), ppc_r2, sizeof (gpointer), ppc_r11); \ @@ -22,13 +48,51 @@ Index: mono-3.4.0/mono/arch/ppc/ppc-codegen.h + ppc_ldptr ((c), ppc_r2, sizeof (gpointer), ppc_r12); \ + ppc_ldptr ((c), (D), 0, ppc_r12); \ } G_STMT_END - #endif ++#endif -Index: mono-3.4.0/mono/mini/aot-compiler.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/aot-compiler.c -+++ mono-3.4.0/mono/mini/aot-compiler.c -@@ -1842,14 +1842,14 @@ arch_emit_imt_thunk (MonoAotCompile *acf + #define ppc_load_multiple_regs(c,D,d,A) G_STMT_START { \ + int __i, __o = (d); \ +diff --git a/mono/metadata/sgen-archdep.h b/mono/metadata/sgen-archdep.h +index 420dc96..410ba6a 100644 +--- a/mono/metadata/sgen-archdep.h ++++ b/mono/metadata/sgen-archdep.h +@@ -87,6 +87,13 @@ + ((a)[__i]) = (gpointer) UCONTEXT_REG_Rn((ctx), __i); \ + } while (0) + ++/* MS_BLOCK_SIZE must be a multiple of the system pagesize, which for some ++ archs is 64k. */ ++#if defined(TARGET_POWERPC64) && _CALL_ELF == 2 ++#define ARCH_MIN_MS_BLOCK_SIZE (64*1024) ++#define ARCH_MIN_MS_BLOCK_SIZE_SHIFT 16 ++#endif ++ + #elif defined(TARGET_ARM) + + #define REDZONE_SIZE 0 +diff --git a/mono/metadata/sgen-marksweep.c b/mono/metadata/sgen-marksweep.c +index 8980687..a115aad 100644 +--- a/mono/metadata/sgen-marksweep.c ++++ b/mono/metadata/sgen-marksweep.c +@@ -44,8 +44,13 @@ + + #define SGEN_HAVE_CONCURRENT_MARK + ++#if defined(ARCH_MIN_MS_BLOCK_SIZE) && defined(ARCH_MIN_MS_BLOCK_SIZE_SHIFT) ++#define MS_BLOCK_SIZE ARCH_MIN_MS_BLOCK_SIZE ++#define MS_BLOCK_SIZE_SHIFT ARCH_MIN_MS_BLOCK_SIZE_SHIFT ++#else + #define MS_BLOCK_SIZE (16*1024) + #define MS_BLOCK_SIZE_SHIFT 14 ++#endif + #define MAJOR_SECTION_SIZE MS_BLOCK_SIZE + #define CARDS_PER_BLOCK (MS_BLOCK_SIZE / CARD_SIZE_IN_BYTES) + +diff --git a/mono/mini/aot-compiler.c b/mono/mini/aot-compiler.c +index bb3b34a..526ea23 100644 +--- a/mono/mini/aot-compiler.c ++++ b/mono/mini/aot-compiler.c +@@ -1941,14 +1941,14 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size) code = buf; /* Load the mscorlib got address */ @@ -46,7 +110,7 @@ Index: mono-3.4.0/mono/mini/aot-compiler.c ppc_cmp (code, 0, sizeof (gpointer) == 8 ? 1 : 0, ppc_r0, MONO_ARCH_IMT_REG); labels [2] = code; ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0); -@@ -1860,18 +1860,18 @@ arch_emit_imt_thunk (MonoAotCompile *acf +@@ -1959,18 +1959,18 @@ arch_emit_imt_thunk (MonoAotCompile *acfg, int offset, int *tramp_size) ppc_bc (code, PPC_BR_TRUE, PPC_BR_EQ, 0); /* Loop footer */ @@ -70,11 +134,25 @@ Index: mono-3.4.0/mono/mini/aot-compiler.c ppc_bcctr (code, PPC_BR_ALWAYS, 0); /* Fail */ -Index: mono-3.4.0/mono/mini/exceptions-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/exceptions-ppc.c -+++ mono-3.4.0/mono/mini/exceptions-ppc.c -@@ -381,13 +381,13 @@ mono_arch_get_throw_exception_generic (i +diff --git a/mono/mini/cpu-ppc64.md b/mono/mini/cpu-ppc64.md +index 114bc3c..c47c6e2 100644 +--- a/mono/mini/cpu-ppc64.md ++++ b/mono/mini/cpu-ppc64.md +@@ -380,7 +380,7 @@ vcall2_membase: src1:b len:16 clob:c + + jump_table: dest:i len:20 + +-atomic_add_i4: src1:b src2:i dest:i len:20 +-atomic_add_i8: src1:b src2:i dest:i len:20 ++atomic_add_i4: src1:b src2:i dest:i len:28 ++atomic_add_i8: src1:b src2:i dest:i len:28 + atomic_cas_i4: src1:b src2:i src3:i dest:i len:38 + atomic_cas_i8: src1:b src2:i src3:i dest:i len:38 +diff --git a/mono/mini/exceptions-ppc.c b/mono/mini/exceptions-ppc.c +index 6c3878e..8850b75 100644 +--- a/mono/mini/exceptions-ppc.c ++++ b/mono/mini/exceptions-ppc.c +@@ -381,18 +381,18 @@ mono_arch_get_throw_exception_generic (int size, MonoTrampInfo **info, int corli if (aot) { code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_IMAGE, mono_defaults.corlib); @@ -92,7 +170,14 @@ Index: mono-3.4.0/mono/mini/exceptions-ppc.c ppc_bcctrl (code, PPC_BR_ALWAYS, 0); } else { ppc_load (code, ppc_r3, (gulong)mono_defaults.corlib); -@@ -420,10 +420,10 @@ mono_arch_get_throw_exception_generic (i +- ppc_load_func (code, ppc_r0, mono_exception_from_token); +- ppc_mtctr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, mono_exception_from_token); ++ ppc_mtctr (code, PPC_CALL_REG); + ppc_bcctrl (code, PPC_BR_ALWAYS, 0); + } + } +@@ -420,14 +420,14 @@ mono_arch_get_throw_exception_generic (int size, MonoTrampInfo **info, int corli code = mono_arch_emit_load_got_addr (start, code, NULL, &ji); code = mono_arch_emit_load_aotconst (start, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_ppc_throw_exception"); #ifdef PPC_USES_FUNCTION_DESCRIPTOR @@ -105,12 +190,70 @@ Index: mono-3.4.0/mono/mini/exceptions-ppc.c + ppc_mtctr (code, ppc_r12); ppc_bcctrl (code, PPC_BR_ALWAYS, 0); } else { - ppc_load_func (code, ppc_r0, mono_ppc_throw_exception); -Index: mono-3.4.0/mono/mini/mini-mips.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-mips.c -+++ mono-3.4.0/mono/mini/mini-mips.c -@@ -3298,8 +3298,8 @@ emit_reserve_param_area (MonoCompile *cf +- ppc_load_func (code, ppc_r0, mono_ppc_throw_exception); +- ppc_mtctr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, mono_ppc_throw_exception); ++ ppc_mtctr (code, PPC_CALL_REG); + ppc_bcctrl (code, PPC_BR_ALWAYS, 0); + } + /* we should never reach this breakpoint */ +@@ -600,31 +600,13 @@ mono_arch_find_jit_info (MonoDomain *domain, MonoJitTlsData *jit_tls, + void + mono_arch_sigctx_to_monoctx (void *ctx, MonoContext *mctx) + { +-#ifdef MONO_CROSS_COMPILE +- g_assert_not_reached (); +-#else +- os_ucontext *uc = ctx; +- +- mctx->sc_ir = UCONTEXT_REG_NIP(uc); +- mctx->sc_sp = UCONTEXT_REG_Rn(uc, 1); +- memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 13), sizeof (mgreg_t) * MONO_SAVED_GREGS); +- memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 14), sizeof (double) * MONO_SAVED_FREGS); +-#endif ++ return mono_sigctx_to_monoctx (ctx, mctx); + } + + void + mono_arch_monoctx_to_sigctx (MonoContext *mctx, void *ctx) + { +-#ifdef MONO_CROSS_COMPILE +- g_assert_not_reached (); +-#else +- os_ucontext *uc = ctx; +- +- UCONTEXT_REG_NIP(uc) = mctx->sc_ir; +- UCONTEXT_REG_Rn(uc, 1) = mctx->sc_sp; +- memcpy (&UCONTEXT_REG_Rn(uc, 13), &mctx->regs, sizeof (mgreg_t) * MONO_SAVED_GREGS); +- memcpy (&UCONTEXT_REG_FPRn(uc, 14), &mctx->fregs, sizeof (double) * MONO_SAVED_FREGS); +-#endif ++ return mono_monoctx_to_sigctx (mctx, ctx); + } + + gpointer +diff --git a/mono/mini/mini-gc.c b/mono/mini/mini-gc.c +index a528b3f..d0004b6 100644 +--- a/mono/mini/mini-gc.c ++++ b/mono/mini/mini-gc.c +@@ -436,6 +436,13 @@ static int callee_saved_regs [] = { ARMREG_V1, ARMREG_V2, ARMREG_V3, ARMREG_V4, + static int callee_saved_regs [] = { }; + #elif defined(TARGET_S390X) + static int callee_saved_regs [] = { s390_r6, s390_r7, s390_r8, s390_r9, s390_r10, s390_r11, s390_r12, s390_r13, s390_r14 }; ++#elif defined(TARGET_POWERPC64) && _CALL_ELF == 2 ++static int callee_saved_regs [] = { ++ ppc_r13, ppc_r14, ppc_r15, ppc_r16, ++ ppc_r17, ppc_r18, ppc_r19, ppc_r20, ++ ppc_r21, ppc_r22, ppc_r23, ppc_r24, ++ ppc_r25, ppc_r26, ppc_r27, ppc_r28, ++ ppc_r29, ppc_r30, ppc_r31 }; + #elif defined(TARGET_POWERPC) + static int callee_saved_regs [] = { ppc_r6, ppc_r7, ppc_r8, ppc_r9, ppc_r10, ppc_r11, ppc_r12, ppc_r13, ppc_r14 }; + #endif +diff --git a/mono/mini/mini-mips.c b/mono/mini/mini-mips.c +index 2aa6bd1..1eb61e9 100644 +--- a/mono/mini/mini-mips.c ++++ b/mono/mini/mini-mips.c +@@ -3305,8 +3305,8 @@ emit_reserve_param_area (MonoCompile *cfg, guint8 *code) if (ppc_is_imm16 (-size)) { ppc_stwu (code, ppc_r0, -size, ppc_sp); } else { @@ -121,7 +264,7 @@ Index: mono-3.4.0/mono/mini/mini-mips.c } #endif return code; -@@ -3320,8 +3320,8 @@ emit_unreserve_param_area (MonoCompile * +@@ -3327,8 +3327,8 @@ emit_unreserve_param_area (MonoCompile *cfg, guint8 *code) if (ppc_is_imm16 (size)) { ppc_stwu (code, ppc_r0, size, ppc_sp); } else { @@ -132,7 +275,7 @@ Index: mono-3.4.0/mono/mini/mini-mips.c } #endif return code; -@@ -3712,8 +3712,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3719,8 +3719,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_DIV_IMM: g_assert_not_reached (); #if 0 @@ -143,11 +286,11 @@ Index: mono-3.4.0/mono/mini/mini-mips.c ppc_mfspr (code, ppc_r0, ppc_xer); ppc_andisd (code, ppc_r0, ppc_r0, (1<<14)); /* FIXME: use OverflowException for 0x80000000/-1 */ -Index: mono-3.4.0/mono/mini/mini-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.c -+++ mono-3.4.0/mono/mini/mini-ppc.c -@@ -103,11 +103,11 @@ offsets_from_pthread_key (guint32 key, i +diff --git a/mono/mini/mini-ppc.c b/mono/mini/mini-ppc.c +index a7c8398..594a72e 100644 +--- a/mono/mini/mini-ppc.c ++++ b/mono/mini/mini-ppc.c +@@ -104,11 +104,11 @@ offsets_from_pthread_key (guint32 key, int *offset2) /* FIXME: ensure the sc call preserves all but r3 */ #define emit_darwing4_tls(code,dreg,key) do {\ int off1 = 0x48 + key * sizeof (gpointer); \ @@ -161,7 +304,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } while (0); #ifdef PPC_THREAD_PTR_REG -@@ -118,8 +118,8 @@ offsets_from_pthread_key (guint32 key, i +@@ -119,8 +119,8 @@ offsets_from_pthread_key (guint32 key, int *offset2) ppc_ldptr ((code), (dreg), off1, PPC_THREAD_PTR_REG); \ } else { \ int off3 = (off2 + 1) > 1; \ @@ -172,7 +315,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } \ } while (0); #else -@@ -190,29 +190,29 @@ emit_memcpy (guint8 *code, int size, int +@@ -191,29 +191,29 @@ emit_memcpy (guint8 *code, int size, int dreg, int doffset, int sreg, int soffse ppc_load (code, ppc_r0, shifted); ppc_mtctr (code, ppc_r0); @@ -211,7 +354,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c size -= 16; soffset += 16; doffset += 16; -@@ -226,12 +226,12 @@ emit_memcpy (guint8 *code, int size, int +@@ -227,12 +227,12 @@ emit_memcpy (guint8 *code, int size, int dreg, int doffset, int sreg, int soffse doffset += 8; } #else @@ -227,7 +370,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c size -= 8; soffset += 8; doffset += 8; -@@ -737,7 +737,7 @@ mono_arch_get_global_int_regs (MonoCompi +@@ -744,7 +744,7 @@ mono_arch_get_global_int_regs (MonoCompile *cfg) for (i = 14; i < top; ++i) { /* * Reserve r29 for holding the vtable address for virtual calls in AOT mode, @@ -236,27 +379,96 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c */ if (!(cfg->compile_aot && i == 29)) regs = g_list_prepend (regs, GUINT_TO_POINTER (i)); -@@ -2922,7 +2922,7 @@ ppc_patch_full (guchar *code, const guch +@@ -1789,8 +1789,8 @@ mono_arch_instrument_prolog (MonoCompile *cfg, void *func, void *p, gboolean ena + + ppc_load_ptr (code, ppc_r3, cfg->method); + ppc_li (code, ppc_r4, 0); /* NULL ebp for now */ +- ppc_load_func (code, ppc_r0, func); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, func); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + return code; + } +@@ -1887,8 +1887,8 @@ mono_arch_instrument_epilog_full (MonoCompile *cfg, void *func, void *p, gboolea + } + + ppc_load_ptr (code, ppc_r3, cfg->method); +- ppc_load_func (code, ppc_r0, func); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, func); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + + switch (save_mode) { +@@ -2822,14 +2822,14 @@ handle_thunk (int absolute, guchar *code, const guchar *target) { + static void + patch_ins (guint8 *code, guint32 ins) + { +- *(guint32*)code = GUINT32_TO_BE (ins); ++ *(guint32*)code = ins; + mono_arch_flush_icache (code, 4); + } + + void + ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) + { +- guint32 ins = GUINT32_FROM_BE (*(guint32*)code); ++ guint32 ins = *(guint32*)code; + guint32 prim = ins >> 26; + guint32 ovf; + +@@ -2912,7 +2912,13 @@ ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) + else + code -= 24; + } else { +- if (ppc_is_load_op (seq [5]) || ppc_opcode (seq [5]) == 31) /* ld || lwz || mr */ ++ if (ppc_is_load_op (seq [5]) ++#ifdef PPC_USES_FUNCTION_DESCRIPTOR ++ /* With function descs we need to do more careful ++ matches. */ ++ || ppc_opcode (seq [5]) == 31 /* ld || lwz || mr */ ++#endif ++ ) + branch_ins = seq + 8; + else + branch_ins = seq + 6; +@@ -2927,7 +2933,7 @@ ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) if (!is_fd) { guint8 *buf = (guint8*)&seq [5]; - ppc_mr (buf, ppc_r0, ppc_r11); -+ ppc_mr (buf, ppc_r0, ppc_r12); ++ ppc_mr (buf, PPC_CALL_REG, ppc_r12); ppc_nop (buf); } } else { -@@ -2932,8 +2932,8 @@ ppc_patch_full (guchar *code, const guch +@@ -2936,8 +2942,12 @@ ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) + } /* FIXME: make this thread safe */ - #ifdef PPC_USES_FUNCTION_DESCRIPTOR - /* FIXME: we're assuming we're using r11 here */ - ppc_load_ptr_sequence (code, ppc_r11, target); ++#ifdef PPC_USES_FUNCTION_DESCRIPTOR + /* FIXME: we're assuming we're using r12 here */ + ppc_load_ptr_sequence (code, ppc_r12, target); ++#else ++ ppc_load_ptr_sequence (code, PPC_CALL_REG, target); ++#endif + mono_arch_flush_icache ((guint8*)seq, 28); #else - ppc_load_ptr_sequence (code, ppc_r0, target); + guint32 *seq; +@@ -2952,8 +2962,8 @@ ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) + g_assert ((seq [2] >> 26) == 31); + g_assert (seq [3] == 0x4e800021 || seq [3] == 0x4e800020 || seq [3] == 0x4e800420); + /* FIXME: make this thread safe */ +- ppc_lis (code, ppc_r0, (guint32)(target) >> 16); +- ppc_ori (code, ppc_r0, ppc_r0, (guint32)(target) & 0xffff); ++ ppc_lis (code, PPC_CALL_REG, (guint32)(target) >> 16); ++ ppc_ori (code, PPC_CALL_REG, PPC_CALL_REG, (guint32)(target) & 0xffff); + mono_arch_flush_icache (code - 8, 8); #endif -@@ -3009,8 +3009,8 @@ emit_reserve_param_area (MonoCompile *cf + } else { +@@ -3010,8 +3020,8 @@ emit_reserve_param_area (MonoCompile *cfg, guint8 *code) if (ppc_is_imm16 (-size)) { ppc_stptr_update (code, ppc_r0, -size, ppc_sp); } else { @@ -267,7 +479,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } return code; -@@ -3031,8 +3031,8 @@ emit_unreserve_param_area (MonoCompile * +@@ -3032,8 +3042,8 @@ emit_unreserve_param_area (MonoCompile *cfg, guint8 *code) if (ppc_is_imm16 (size)) { ppc_stptr_update (code, ppc_r0, size, ppc_sp); } else { @@ -278,7 +490,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } return code; -@@ -3106,8 +3106,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3107,8 +3117,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) * a breakpoint is hit will step to the next IL offset. */ if (ins->flags & MONO_INST_SINGLE_STEP_LOC) { @@ -289,7 +501,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } mono_add_seq_point (cfg, bb, ins, code - cfg->native_code); -@@ -3141,8 +3141,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3142,8 +3152,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_stb (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -300,7 +512,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_stbx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0); -@@ -3154,8 +3154,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3155,8 +3165,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_sth (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -311,7 +523,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_sthx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0); -@@ -3167,8 +3167,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3168,8 +3178,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_stptr (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -322,7 +534,18 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_stptr_indexed (code, ins->sreg1, ins->inst_destbasereg, ppc_r0); -@@ -3724,7 +3724,7 @@ mono_arch_output_basic_block (MonoCompil +@@ -3371,8 +3381,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) + mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, + (gpointer)"mono_break"); + if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } else { + ppc_bl (code, 0); +@@ -3725,7 +3735,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) */ g_assert (!cfg->method->save_lmf); /* @@ -331,7 +554,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c * we're leaving the method. */ if (1 || cfg->flags & MONO_CFG_HAS_CALLS) { -@@ -3732,26 +3732,26 @@ mono_arch_output_basic_block (MonoCompil +@@ -3733,26 +3743,26 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if (ppc_is_imm16 (ret_offset)) { ppc_ldptr (code, ppc_r0, ret_offset, cfg->frame_reg); } else { @@ -364,7 +587,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } } else { -@@ -3760,27 +3760,27 @@ mono_arch_output_basic_block (MonoCompil +@@ -3761,27 +3771,27 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) /* Copy arguments on the stack to our argument area */ if (call->stack_usage) { @@ -400,7 +623,18 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c #else ppc_ldptr_indexed (code, ppc_r0, ppc_r30, ppc_r0); #endif -@@ -3852,7 +3852,7 @@ mono_arch_output_basic_block (MonoCompil +@@ -3819,8 +3829,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) + else + mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_ABS, call->fptr); + if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } else { + ppc_bl (code, 0); +@@ -3853,7 +3863,7 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) case OP_VCALL2_MEMBASE: case OP_VOIDCALL_MEMBASE: case OP_CALL_MEMBASE: @@ -409,7 +643,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /* The trampolines clobber this */ ppc_mr (code, ppc_r29, ins->sreg1); ppc_ldptr (code, ppc_r0, ins->inst_offset, ppc_r29); -@@ -3870,9 +3870,9 @@ mono_arch_output_basic_block (MonoCompil +@@ -3871,9 +3881,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) int alloca_waste = PPC_STACK_PARAM_OFFSET + cfg->param_area + 31; int area_offset = alloca_waste; area_offset &= ~31; @@ -421,7 +655,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /* use ctr to store the number of words to 0 if needed */ if (ins->flags & MONO_INST_INIT) { /* we zero 4 bytes at a time: -@@ -3885,8 +3885,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3886,8 +3896,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_mtctr (code, ppc_r0); } ppc_ldptr (code, ppc_r0, 0, ppc_sp); @@ -432,7 +666,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /* FIXME: make this loop work in 8 byte increments on PPC64 */ -@@ -3896,9 +3896,9 @@ mono_arch_output_basic_block (MonoCompil +@@ -3897,9 +3907,9 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) * run at least once */ ppc_addi (code, ins->dreg, ppc_sp, (area_offset - 8)); @@ -444,7 +678,29 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c zero_loop_jump = code; ppc_bc (code, PPC_BR_DEC_CTR_NONZERO, 0, 0); ppc_patch (zero_loop_jump, zero_loop_start); -@@ -3942,8 +3942,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3913,8 +3923,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) + mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, + (gpointer)"mono_arch_throw_exception"); + if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } else { + ppc_bl (code, 0); +@@ -3927,8 +3937,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) + mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, + (gpointer)"mono_arch_rethrow_exception"); + if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } else { + ppc_bl (code, 0); +@@ -3943,8 +3953,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if (ppc_is_imm16 (spvar->inst_offset)) { ppc_stptr (code, ppc_r0, spvar->inst_offset, spvar->inst_basereg); } else { @@ -455,7 +711,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } break; } -@@ -3956,8 +3956,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -3957,8 +3967,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) if (ppc_is_imm16 (spvar->inst_offset)) { ppc_ldptr (code, ppc_r0, spvar->inst_offset, spvar->inst_basereg); } else { @@ -466,7 +722,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } ppc_mtlr (code, ppc_r0); ppc_blr (code); -@@ -4063,11 +4063,11 @@ mono_arch_output_basic_block (MonoCompil +@@ -4064,11 +4074,11 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) /* FIXME: Optimize this */ ppc_bl (code, 1); @@ -480,7 +736,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c break; case OP_R4CONST: g_assert_not_reached (); -@@ -4077,8 +4077,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -4078,8 +4088,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_stfd (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -491,7 +747,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_stfdx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0); -@@ -4090,8 +4090,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -4091,8 +4101,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_lfd (code, ins->dreg, ins->inst_offset, ins->inst_basereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -502,7 +758,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_lfdx (code, ins->dreg, ins->inst_destbasereg, ppc_r0); -@@ -4104,8 +4104,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -4105,8 +4115,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_stfs (code, ins->sreg1, ins->inst_offset, ins->inst_destbasereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -513,7 +769,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_stfsx (code, ins->sreg1, ins->inst_destbasereg, ppc_r0); -@@ -4117,8 +4117,8 @@ mono_arch_output_basic_block (MonoCompil +@@ -4118,8 +4128,8 @@ mono_arch_output_basic_block (MonoCompile *cfg, MonoBasicBlock *bb) ppc_lfs (code, ins->dreg, ins->inst_offset, ins->inst_basereg); } else { if (ppc_is_imm32 (ins->inst_offset)) { @@ -524,7 +780,34 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else { ppc_load (code, ppc_r0, ins->inst_offset); ppc_lfsx (code, ins->dreg, ins->inst_destbasereg, ppc_r0); -@@ -4723,12 +4723,12 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4509,6 +4519,16 @@ mono_arch_register_lowlevel_calls (void) + } + + #ifdef __mono_ppc64__ ++#ifdef _LITTLE_ENDIAN ++#define patch_load_sequence(ip,val) do {\ ++ guint16 *__load = (guint16*)(ip); \ ++ g_assert (sizeof (val) == sizeof (gsize)); \ ++ __load [0] = (((guint64)(gsize)(val)) >> 48) & 0xffff; \ ++ __load [2] = (((guint64)(gsize)(val)) >> 32) & 0xffff; \ ++ __load [6] = (((guint64)(gsize)(val)) >> 16) & 0xffff; \ ++ __load [8] = ((guint64)(gsize)(val)) & 0xffff; \ ++ } while (0) ++#elif defined _BIG_ENDIAN + #define patch_load_sequence(ip,val) do {\ + guint16 *__load = (guint16*)(ip); \ + g_assert (sizeof (val) == sizeof (gsize)); \ +@@ -4518,6 +4538,9 @@ mono_arch_register_lowlevel_calls (void) + __load [9] = ((guint64)(gsize)(val)) & 0xffff; \ + } while (0) + #else ++#error huh? No endianess defined by compiler ++#endif ++#else + #define patch_load_sequence(ip,val) do {\ + guint16 *__lis_ori = (guint16*)(ip); \ + __lis_ori [1] = (((gulong)(val)) >> 16) & 0xffff; \ +@@ -4728,12 +4751,12 @@ mono_arch_emit_prolog (MonoCompile *cfg) code = save_registers (cfg, code, alloc_size - pos, ppc_sp, method->save_lmf, cfg->used_int_regs, cfa_offset); } else { if (pos) @@ -539,7 +822,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } if (cfg->frame_reg != ppc_sp) { -@@ -4774,8 +4774,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4779,8 +4802,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) if (ppc_is_imm16 (inst->inst_offset)) { ppc_stptr (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { @@ -550,7 +833,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } -@@ -4792,8 +4792,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4797,8 +4820,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) else if (ainfo->regtype == RegTypeFP) ppc_fmr (code, inst->dreg, ainfo->reg); else if (ainfo->regtype == RegTypeBase) { @@ -561,7 +844,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } else g_assert_not_reached (); -@@ -4808,11 +4808,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4813,11 +4836,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stb (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -577,7 +860,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4821,11 +4821,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4826,11 +4849,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_sth (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -593,7 +876,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4835,11 +4835,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4840,11 +4863,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -609,7 +892,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4847,8 +4847,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4852,8 +4875,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) if (ppc_is_imm16 (inst->inst_offset)) { ppc_str (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { @@ -620,7 +903,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } break; #else -@@ -4857,10 +4857,10 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4862,10 +4885,10 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stw (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); ppc_stw (code, ainfo->reg + 1, inst->inst_offset + 4, inst->inst_basereg); } else { @@ -635,7 +918,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } break; #endif -@@ -4869,31 +4869,31 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4874,31 +4897,31 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stptr (code, ainfo->reg, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -678,7 +961,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4902,11 +4902,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4907,11 +4930,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_sth (code, ppc_r0, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -694,7 +977,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4916,11 +4916,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4921,11 +4944,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stw (code, ppc_r0, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -710,7 +993,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -4928,8 +4928,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4933,8 +4956,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) if (ppc_is_imm16 (inst->inst_offset)) { ppc_str (code, ppc_r0, inst->inst_offset, inst->inst_basereg); } else { @@ -721,7 +1004,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } break; #else -@@ -4937,15 +4937,15 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4942,15 +4965,15 @@ mono_arch_emit_prolog (MonoCompile *cfg) g_assert (ppc_is_imm16 (ainfo->offset + 4)); if (ppc_is_imm16 (inst->inst_offset + 4)) { ppc_stw (code, ppc_r0, inst->inst_offset, inst->inst_basereg); @@ -744,7 +1027,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } break; #endif -@@ -4954,11 +4954,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -4959,11 +4982,11 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_stptr (code, ppc_r0, inst->inst_offset, inst->inst_basereg); } else { if (ppc_is_imm32 (inst->inst_offset)) { @@ -760,7 +1043,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } break; -@@ -5017,39 +5017,39 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -5022,39 +5045,39 @@ mono_arch_emit_prolog (MonoCompile *cfg) /* FIXME: we need to do the shifting here, too */ if (ainfo->bytes) NOT_IMPLEMENTED; @@ -810,7 +1093,18 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /*g_print ("copy in %s: %d bytes from %d to offset: %d\n", method->name, ainfo->vtsize, ainfo->reg, inst->inst_offset);*/ } else g_assert_not_reached (); -@@ -5081,25 +5081,25 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -5075,8 +5098,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) + mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, + (gpointer)"mono_get_lmf_addr"); + if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } else { + ppc_bl (code, 0); +@@ -5086,25 +5109,25 @@ mono_arch_emit_prolog (MonoCompile *cfg) /* lmf_offset is the offset from the previous stack pointer, * alloc_size is the total stack space allocated, so the offset * of MonoLMF from the current stack ptr is alloc_size - lmf_offset. @@ -844,7 +1138,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /* save the current IP */ if (cfg->compile_aot) { ppc_bl (code, 1); -@@ -5112,7 +5112,7 @@ mono_arch_emit_prolog (MonoCompile *cfg) +@@ -5117,7 +5140,7 @@ mono_arch_emit_prolog (MonoCompile *cfg) ppc_load_sequence (code, ppc_r0, (gulong)0x01010101L); #endif } @@ -853,7 +1147,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } if (tracing) -@@ -5164,21 +5164,21 @@ mono_arch_emit_epilog (MonoCompile *cfg) +@@ -5169,21 +5192,21 @@ mono_arch_emit_epilog (MonoCompile *cfg) lmf_offset = pos; /* save the frame reg in r8 */ ppc_mr (code, ppc_r8, cfg->frame_reg); @@ -880,7 +1174,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c }*/ g_assert (ppc_is_imm16 (cfg->stack_usage + PPC_RET_ADDR_OFFSET)); /* use the saved copy of the frame reg in r8 */ -@@ -5193,8 +5193,8 @@ mono_arch_emit_epilog (MonoCompile *cfg) +@@ -5198,8 +5221,8 @@ mono_arch_emit_epilog (MonoCompile *cfg) if (ppc_is_imm16 (return_offset)) { ppc_ldr (code, ppc_r0, return_offset, cfg->frame_reg); } else { @@ -891,7 +1185,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } ppc_mtlr (code, ppc_r0); } -@@ -5205,7 +5205,7 @@ mono_arch_emit_epilog (MonoCompile *cfg) +@@ -5210,7 +5233,7 @@ mono_arch_emit_epilog (MonoCompile *cfg) offset -= sizeof (mgreg_t); } if (cfg->frame_reg != ppc_sp) @@ -900,7 +1194,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c /* note r31 (possibly the frame register) is restored last */ for (i = 13; i <= 31; i++) { if (cfg->used_int_regs & (1 << i)) { -@@ -5214,22 +5214,22 @@ mono_arch_emit_epilog (MonoCompile *cfg) +@@ -5219,22 +5242,22 @@ mono_arch_emit_epilog (MonoCompile *cfg) } } if (cfg->frame_reg != ppc_sp) @@ -929,7 +1223,18 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } } -@@ -5618,15 +5618,15 @@ mono_arch_build_imt_thunk (MonoVTable *v +@@ -5385,8 +5408,8 @@ mono_arch_emit_exceptions (MonoCompile *cfg) + patch_info->data.name = "mono_arch_throw_corlib_exception"; + patch_info->ip.i = code - cfg->native_code; + if (FORCE_INDIR_CALL || cfg->method->dynamic) { +- ppc_load_func (code, ppc_r0, 0); +- ppc_mtctr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, 0); ++ ppc_mtctr (code, PPC_CALL_REG); + ppc_bcctr (code, PPC_BR_ALWAYS, 0); + } else { + ppc_bl (code, 0); +@@ -5621,15 +5644,15 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI start = code; /* @@ -949,7 +1254,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c for (i = 0; i < count; ++i) { MonoIMTCheckItem *item = imt_entries [i]; -@@ -5642,8 +5642,8 @@ mono_arch_build_imt_thunk (MonoVTable *v +@@ -5645,8 +5668,8 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI if (item->has_target_code) { ppc_load_ptr (code, ppc_r0, item->value.target_code); } else { @@ -960,7 +1265,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c } ppc_mtctr (code, ppc_r0); ppc_bcctr (code, PPC_BR_ALWAYS, 0); -@@ -5675,8 +5675,8 @@ mono_arch_build_imt_thunk (MonoVTable *v +@@ -5678,8 +5701,8 @@ mono_arch_build_imt_thunk (MonoVTable *vtable, MonoDomain *domain, MonoIMTCheckI item->jmp_code = code; ppc_bc (code, PPC_BR_FALSE, PPC_BR_EQ, 0); #endif @@ -971,7 +1276,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c ppc_mtctr (code, ppc_r0); ppc_bcctr (code, PPC_BR_ALWAYS, 0); #if ENABLE_WRONG_METHOD_CHECK -@@ -5802,17 +5802,17 @@ mono_arch_emit_load_got_addr (guint8 *st +@@ -5804,17 +5827,17 @@ mono_arch_emit_load_got_addr (guint8 *start, guint8 *code, MonoCompile *cfg, Mon * Emit code to load the contents of the GOT slot identified by TRAMP_TYPE and * TARGET from the mscorlib GOT in full-aot code. * On PPC, the GOT address is assumed to be in r30, and the result is placed into @@ -992,7 +1297,7 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c return code; } -@@ -5835,8 +5835,8 @@ mono_arch_set_breakpoint (MonoJitInfo *j +@@ -5837,8 +5860,8 @@ mono_arch_set_breakpoint (MonoJitInfo *ji, guint8 *ip) guint8 *code = ip; guint8 *orig_code = code; @@ -1003,11 +1308,33 @@ Index: mono-3.4.0/mono/mini/mini-ppc.c g_assert (code - orig_code == BREAKPOINT_SIZE); -Index: mono-3.4.0/mono/mini/mini-ppc.h -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.h -+++ mono-3.4.0/mono/mini/mini-ppc.h -@@ -105,7 +105,7 @@ typedef struct MonoCompileArch { +diff --git a/mono/mini/mini-ppc.h b/mono/mini/mini-ppc.h +index 4b39b7a..9e5c02e 100644 +--- a/mono/mini/mini-ppc.h ++++ b/mono/mini/mini-ppc.h +@@ -4,6 +4,7 @@ + #include + #include + #include ++#include + #include + + #ifdef __mono_ppc64__ +@@ -68,7 +69,13 @@ typedef struct MonoCompileArch { + #ifdef __mono_ppc64__ + #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS + #define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS ++ ++/* ELFv2 ABI doesn't use function descriptors. */ ++#if _CALL_ELF == 2 ++#undef PPC_USES_FUNCTION_DESCRIPTOR ++#else + #define PPC_USES_FUNCTION_DESCRIPTOR ++#endif + + #ifndef __mono_ilp32__ + #define MONO_ARCH_HAVE_TLS_GET 1 +@@ -97,7 +104,7 @@ typedef struct MonoCompileArch { #define MONO_ARCH_GC_MAPS_SUPPORTED 1 /* Parameters used by the register allocator */ @@ -1016,10 +1343,18 @@ Index: mono-3.4.0/mono/mini/mini-ppc.h #define MONO_ARCH_CALLEE_SAVED_REGS (0xfffff << ppc_r13) /* ppc_13 - ppc_31 */ #if defined(__APPLE__) || defined(__mono_ppc64__) -@@ -179,9 +179,9 @@ typedef struct MonoCompileArch { +@@ -164,15 +171,17 @@ typedef struct MonoCompileArch { + #define PPC_FIRST_FPARG_REG ppc_f1 + #endif + ++#define PPC_CALL_REG ppc_r12 ++ + #if defined(HAVE_WORKING_SIGALTSTACK) && !defined(__APPLE__) + #define MONO_ARCH_SIGSEGV_ON_ALTSTACK 1 + #define MONO_ARCH_SIGNAL_STACK_SIZE (12 * 1024) + #endif /* HAVE_WORKING_SIGALTSTACK */ #define MONO_ARCH_HAVE_CREATE_DELEGATE_TRAMPOLINE - #define MONO_ARCH_HAVE_IMT 1 -#define MONO_ARCH_IMT_REG ppc_r12 +#define MONO_ARCH_IMT_REG ppc_r11 @@ -1028,11 +1363,36 @@ Index: mono-3.4.0/mono/mini/mini-ppc.h #define MONO_ARCH_RGCTX_REG MONO_ARCH_IMT_REG #define MONO_ARCH_NO_IOV_CHECK 1 -Index: mono-3.4.0/mono/mini/tramp-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/tramp-ppc.c -+++ mono-3.4.0/mono/mini/tramp-ppc.c -@@ -300,10 +300,10 @@ mono_arch_create_generic_trampoline (Mon +diff --git a/mono/mini/mini.c b/mono/mini/mini.c +index d7ee5ba..bd3dbb5 100755 +--- a/mono/mini/mini.c ++++ b/mono/mini/mini.c +@@ -7085,10 +7085,9 @@ mini_get_debug_options (void) + static gpointer + mini_create_ftnptr (MonoDomain *domain, gpointer addr) + { +-#if !defined(__ia64__) && !defined(__ppc64__) && !defined(__powerpc64__) ++#if !defined(__ia64__) && (!defined(__ppc64__) && !defined(__powerpc64__) || _CALL_ELF == 2) + return addr; + #else +- + gpointer* desc = NULL; + + if ((desc = g_hash_table_lookup (domain->ftnptrs_hash, addr))) +@@ -7114,7 +7113,7 @@ mini_create_ftnptr (MonoDomain *domain, gpointer addr) + static gpointer + mini_get_addr_from_ftnptr (gpointer descr) + { +-#if defined(__ia64__) || defined(__ppc64__) || defined(__powerpc64__) ++#if defined(__ia64__) || ((defined(__ppc64__) || defined(__powerpc64__)) && _CALL_ELF != 2) + return *(gpointer*)descr; + #else + return descr; +diff --git a/mono/mini/tramp-ppc.c b/mono/mini/tramp-ppc.c +index 6fac1a1..1b2cc1d 100644 +--- a/mono/mini/tramp-ppc.c ++++ b/mono/mini/tramp-ppc.c +@@ -295,44 +295,44 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf if (aot) { code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "mono_get_lmf_addr"); #ifdef PPC_USES_FUNCTION_DESCRIPTOR @@ -1045,8 +1405,10 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c + ppc_mtlr (code, ppc_r12); ppc_blrl (code); } else { - ppc_load_func (code, ppc_r0, mono_get_lmf_addr); -@@ -311,33 +311,33 @@ mono_arch_create_generic_trampoline (Mon +- ppc_load_func (code, ppc_r0, mono_get_lmf_addr); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, mono_get_lmf_addr); ++ ppc_mtlr (code, PPC_CALL_REG); ppc_blrl (code); } /* we build the MonoLMF structure on the stack - see mini-ppc.h @@ -1090,7 +1452,7 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c /* * Now we're ready to call trampoline (mgreg_t *regs, guint8 *code, gpointer value, guint8 *tramp) -@@ -361,10 +361,10 @@ mono_arch_create_generic_trampoline (Mon +@@ -356,15 +356,15 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf if (aot) { code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("trampoline_func_%d", tramp_type)); #ifdef PPC_USES_FUNCTION_DESCRIPTOR @@ -1104,7 +1466,14 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c ppc_blrl (code); } else { tramp_handler = mono_get_trampoline_func (tramp_type); -@@ -389,20 +389,20 @@ mono_arch_create_generic_trampoline (Mon +- ppc_load_func (code, ppc_r0, tramp_handler); +- ppc_mtlr (code, ppc_r0); ++ ppc_load_func (code, PPC_CALL_REG, tramp_handler); ++ ppc_mtlr (code, PPC_CALL_REG); + ppc_blrl (code); + } + +@@ -384,20 +384,20 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf * Now we restore the MonoLMF (see emit_epilogue in mini-ppc.c) * and the rest of the registers, so the method called will see * the same state as before we executed. @@ -1131,7 +1500,7 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c /* restore the volatile registers, we skip r1, of course */ offset = STACK - sizeof (MonoLMF) - (14 * sizeof (double)); -@@ -424,8 +424,8 @@ mono_arch_create_generic_trampoline (Mon +@@ -419,8 +419,8 @@ mono_arch_create_generic_trampoline (MonoTrampolineType tramp_type, MonoTrampInf */ /* Restore stack pointer and LR and jump to the code */ ppc_ldr (code, ppc_r1, 0, ppc_r1); @@ -1142,7 +1511,7 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c if (MONO_TRAMPOLINE_TYPE_MUST_RETURN (tramp_type)) ppc_blr (code); else -@@ -596,9 +596,9 @@ mono_arch_create_rgctx_lazy_fetch_trampo +@@ -591,9 +591,9 @@ mono_arch_create_rgctx_lazy_fetch_trampoline (guint32 slot, MonoTrampInfo **info code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, g_strdup_printf ("specific_trampoline_lazy_fetch_%u", slot)); /* Branch to the trampoline */ #ifdef PPC_USES_FUNCTION_DESCRIPTOR @@ -1154,7 +1523,7 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c ppc_bcctr (code, PPC_BR_ALWAYS, 0); } else { tramp = mono_arch_create_specific_trampoline (GUINT_TO_POINTER (slot), -@@ -658,9 +658,9 @@ mono_arch_create_generic_class_init_tram +@@ -653,9 +653,9 @@ mono_arch_create_generic_class_init_trampoline (MonoTrampInfo **info, gboolean a code = mono_arch_emit_load_aotconst (buf, code, &ji, MONO_PATCH_INFO_JIT_ICALL_ADDR, "specific_trampoline_generic_class_init"); /* Branch to the trampoline */ #ifdef PPC_USES_FUNCTION_DESCRIPTOR @@ -1166,3 +1535,72 @@ Index: mono-3.4.0/mono/mini/tramp-ppc.c ppc_bcctr (code, PPC_BR_ALWAYS, 0); } else { tramp = mono_arch_create_specific_trampoline (NULL, MONO_TRAMPOLINE_GENERIC_CLASS_INIT, +diff --git a/mono/utils/mono-context.c b/mono/utils/mono-context.c +index c52d044..0db9dce 100644 +--- a/mono/utils/mono-context.c ++++ b/mono/utils/mono-context.c +@@ -421,4 +421,31 @@ mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx) + } + } + ++#elif (((defined(__ppc__) || defined(__powerpc__) || defined(__ppc64__)) && !defined(MONO_CROSS_COMPILE))) || (defined(TARGET_POWERPC)) ++ ++#include ++#include ++ ++void ++mono_sigctx_to_monoctx (void *sigctx, MonoContext *mctx) ++{ ++ os_ucontext *uc = sigctx; ++ ++ mctx->sc_ir = UCONTEXT_REG_NIP(uc); ++ mctx->sc_sp = UCONTEXT_REG_Rn(uc, 1); ++ memcpy (&mctx->regs, &UCONTEXT_REG_Rn(uc, 13), sizeof (mgreg_t) * MONO_SAVED_GREGS); ++ memcpy (&mctx->fregs, &UCONTEXT_REG_FPRn(uc, 14), sizeof (double) * MONO_SAVED_FREGS); ++} ++ ++void ++mono_monoctx_to_sigctx (MonoContext *mctx, void *sigctx) ++{ ++ os_ucontext *uc = sigctx; ++ ++ UCONTEXT_REG_NIP(uc) = mctx->sc_ir; ++ UCONTEXT_REG_Rn(uc, 1) = mctx->sc_sp; ++ memcpy (&UCONTEXT_REG_Rn(uc, 13), &mctx->regs, sizeof (mgreg_t) * MONO_SAVED_GREGS); ++ memcpy (&UCONTEXT_REG_FPRn(uc, 14), &mctx->fregs, sizeof (double) * MONO_SAVED_FREGS); ++} ++ + #endif /* #if defined(__i386__) */ +diff --git a/mono/utils/strtod.c b/mono/utils/strtod.c +index f20acdc..1ba4b72 100644 +--- a/mono/utils/strtod.c ++++ b/mono/utils/strtod.c +@@ -173,6 +173,12 @@ + * #define NO_ERRNO if strtod should not assign errno = ERANGE when + * the result overflows to +-Infinity or underflows to 0. + */ ++#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN ++# define IEEE_MC68k ++#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN ++# define IEEE_8087 ++#else ++ + #if defined(TARGET_X86) || defined(mips) && defined(MIPSEL) || defined (__arm__) || defined(__aarch64__) + + # define IEEE_8087 +@@ -194,9 +200,12 @@ + # define IEEE_MC68k + + #else ++#warning byte order unknown, assuming big endian + #define IEEE_MC68k + #endif + ++#endif ++ + #define Long gint32 + #define ULong guint32 + +-- +1.8.5.2 + diff --git a/mono-core-ppc64le-callreg.diff b/mono-core-ppc64le-callreg.diff deleted file mode 100644 index cfaaf70..0000000 --- a/mono-core-ppc64le-callreg.diff +++ /dev/null @@ -1,198 +0,0 @@ -Use ppc_r12 for some global call sequences - -After the mechanical exchange of ppc_r11 and ppc_r12 we now can use -ppc_r12 for global calls to hold the callees address without clobbering -r11 (which potentially contains IMT_REG, VTABLE_REG and RGCTX_REG). -We don't need to change all indirect calls, only those potentially reaching -functions containing a TOC setup based on r12 (in particular functions -in shared libs). As the instruction sequence patcher can only deal -with one destination register we also need to make some additional -calls use r12. We probably should convert all calls that currently -use r0 to use r12 if no other conflicts arise but this is enough to build. - -Index: mono-3.4.0/mono/mini/exceptions-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/exceptions-ppc.c -+++ mono-3.4.0/mono/mini/exceptions-ppc.c -@@ -391,8 +391,8 @@ mono_arch_get_throw_exception_generic (i - ppc_bcctrl (code, PPC_BR_ALWAYS, 0); - } else { - ppc_load (code, ppc_r3, (gulong)mono_defaults.corlib); -- ppc_load_func (code, ppc_r0, mono_exception_from_token); -- ppc_mtctr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, mono_exception_from_token); -+ ppc_mtctr (code, PPC_CALL_REG); - ppc_bcctrl (code, PPC_BR_ALWAYS, 0); - } - } -@@ -426,8 +426,8 @@ mono_arch_get_throw_exception_generic (i - ppc_mtctr (code, ppc_r12); - ppc_bcctrl (code, PPC_BR_ALWAYS, 0); - } else { -- ppc_load_func (code, ppc_r0, mono_ppc_throw_exception); -- ppc_mtctr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, mono_ppc_throw_exception); -+ ppc_mtctr (code, PPC_CALL_REG); - ppc_bcctrl (code, PPC_BR_ALWAYS, 0); - } - /* we should never reach this breakpoint */ -Index: mono-3.4.0/mono/mini/mini-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.c -+++ mono-3.4.0/mono/mini/mini-ppc.c -@@ -1782,8 +1782,8 @@ mono_arch_instrument_prolog (MonoCompile - - ppc_load_ptr (code, ppc_r3, cfg->method); - ppc_li (code, ppc_r4, 0); /* NULL ebp for now */ -- ppc_load_func (code, ppc_r0, func); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, func); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - return code; - } -@@ -1880,8 +1880,8 @@ mono_arch_instrument_epilog_full (MonoCo - } - - ppc_load_ptr (code, ppc_r3, cfg->method); -- ppc_load_func (code, ppc_r0, func); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, func); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - - switch (save_mode) { -@@ -2922,7 +2922,7 @@ ppc_patch_full (guchar *code, const guch - - if (!is_fd) { - guint8 *buf = (guint8*)&seq [5]; -- ppc_mr (buf, ppc_r0, ppc_r12); -+ ppc_mr (buf, PPC_CALL_REG, ppc_r12); - ppc_nop (buf); - } - } else { -@@ -2935,7 +2935,7 @@ ppc_patch_full (guchar *code, const guch - /* FIXME: we're assuming we're using r12 here */ - ppc_load_ptr_sequence (code, ppc_r12, target); - #else -- ppc_load_ptr_sequence (code, ppc_r0, target); -+ ppc_load_ptr_sequence (code, PPC_CALL_REG, target); - #endif - mono_arch_flush_icache ((guint8*)seq, 28); - #else -@@ -2951,8 +2951,8 @@ ppc_patch_full (guchar *code, const guch - g_assert ((seq [2] >> 26) == 31); - g_assert (seq [3] == 0x4e800021 || seq [3] == 0x4e800020 || seq [3] == 0x4e800420); - /* FIXME: make this thread safe */ -- ppc_lis (code, ppc_r0, (guint32)(target) >> 16); -- ppc_ori (code, ppc_r0, ppc_r0, (guint32)(target) & 0xffff); -+ ppc_lis (code, PPC_CALL_REG, (guint32)(target) >> 16); -+ ppc_ori (code, PPC_CALL_REG, PPC_CALL_REG, (guint32)(target) & 0xffff); - mono_arch_flush_icache (code - 8, 8); - #endif - } else { -@@ -3370,8 +3370,8 @@ mono_arch_output_basic_block (MonoCompil - mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, - (gpointer)"mono_break"); - if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } else { - ppc_bl (code, 0); -@@ -3818,8 +3818,8 @@ mono_arch_output_basic_block (MonoCompil - else - mono_add_patch_info (cfg, offset, MONO_PATCH_INFO_ABS, call->fptr); - if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } else { - ppc_bl (code, 0); -@@ -3912,8 +3912,8 @@ mono_arch_output_basic_block (MonoCompil - mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, - (gpointer)"mono_arch_throw_exception"); - if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } else { - ppc_bl (code, 0); -@@ -3926,8 +3926,8 @@ mono_arch_output_basic_block (MonoCompil - mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, - (gpointer)"mono_arch_rethrow_exception"); - if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } else { - ppc_bl (code, 0); -@@ -5070,8 +5070,8 @@ mono_arch_emit_prolog (MonoCompile *cfg) - mono_add_patch_info (cfg, code - cfg->native_code, MONO_PATCH_INFO_INTERNAL_METHOD, - (gpointer)"mono_get_lmf_addr"); - if ((FORCE_INDIR_CALL || cfg->method->dynamic) && !cfg->compile_aot) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } else { - ppc_bl (code, 0); -@@ -5380,8 +5380,8 @@ mono_arch_emit_exceptions (MonoCompile * - patch_info->data.name = "mono_arch_throw_corlib_exception"; - patch_info->ip.i = code - cfg->native_code; - if (FORCE_INDIR_CALL || cfg->method->dynamic) { -- ppc_load_func (code, ppc_r0, 0); -- ppc_mtctr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, 0); -+ ppc_mtctr (code, PPC_CALL_REG); - ppc_bcctr (code, PPC_BR_ALWAYS, 0); - } else { - ppc_bl (code, 0); -Index: mono-3.4.0/mono/mini/mini-ppc.h -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.h -+++ mono-3.4.0/mono/mini/mini-ppc.h -@@ -172,6 +172,8 @@ typedef struct MonoCompileArch { - #define PPC_FIRST_FPARG_REG ppc_f1 - #endif - -+#define PPC_CALL_REG ppc_r12 -+ - #if defined(HAVE_WORKING_SIGALTSTACK) && !defined(__APPLE__) - #define MONO_ARCH_SIGSEGV_ON_ALTSTACK 1 - #define MONO_ARCH_SIGNAL_STACK_SIZE (12 * 1024) -Index: mono-3.4.0/mono/mini/tramp-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/tramp-ppc.c -+++ mono-3.4.0/mono/mini/tramp-ppc.c -@@ -306,8 +306,8 @@ mono_arch_create_generic_trampoline (Mon - ppc_mtlr (code, ppc_r12); - ppc_blrl (code); - } else { -- ppc_load_func (code, ppc_r0, mono_get_lmf_addr); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, mono_get_lmf_addr); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } - /* we build the MonoLMF structure on the stack - see mini-ppc.h -@@ -368,8 +368,8 @@ mono_arch_create_generic_trampoline (Mon - ppc_blrl (code); - } else { - tramp_handler = mono_get_trampoline_func (tramp_type); -- ppc_load_func (code, ppc_r0, tramp_handler); -- ppc_mtlr (code, ppc_r0); -+ ppc_load_func (code, PPC_CALL_REG, tramp_handler); -+ ppc_mtlr (code, PPC_CALL_REG); - ppc_blrl (code); - } - diff --git a/mono-core-ppc64le.diff b/mono-core-ppc64le.diff deleted file mode 100644 index 6a71196..0000000 --- a/mono-core-ppc64le.diff +++ /dev/null @@ -1,256 +0,0 @@ -Basic ppc64le support - -This adds initial support for ppc64le to the ppc64 port. That is: -* little endian aware (also in strtod), -* and ELFv2 aware (not using function descriptors) -* adjust various block sizes to be multiple of 64k, the default - pagesize on ppc64le. The sources should have used the system function - to ensure alignment on pagesize, so this is just a stop-gap - -It also corrects the list of registers for the precise GC, but that isn't -used in mini at all on any architecture currently. - -Index: mono-3.4.0/mono/arch/ppc/ppc-codegen.h -=================================================================== ---- mono-3.4.0.orig/mono/arch/ppc/ppc-codegen.h -+++ mono-3.4.0/mono/arch/ppc/ppc-codegen.h -@@ -123,7 +123,7 @@ enum { - PPC_TRAP_GE_UN = 16 + PPC_TRAP_EQ - }; - --#define ppc_emit32(c,x) do { *((guint32 *) (c)) = GUINT32_TO_BE (x); (c) = (gpointer)((guint8 *)(c) + sizeof (guint32));} while (0) -+#define ppc_emit32(c,x) do { *((guint32 *) (c)) = (guint32) (x); (c) = (gpointer)((guint8 *)(c) + sizeof (guint32));} while (0) - - #define ppc_is_imm16(val) ((((val)>> 15) == 0) || (((val)>> 15) == -1)) - #define ppc_is_uimm16(val) ((glong)(val) >= 0L && (glong)(val) <= 65535L) -@@ -806,11 +806,15 @@ my and Ximian's copyright to this code. - } \ - } G_STMT_END - -+#if _CALL_ELF == 2 -+#define ppc_load_func(c,D,V) ppc_load_sequence ((c), (D), (V)) -+#else - #define ppc_load_func(c,D,v) G_STMT_START { \ - ppc_load_sequence ((c), ppc_r11, (guint64)(gsize)(v)); \ - ppc_ldptr ((c), ppc_r2, sizeof (gpointer), ppc_r11); \ - ppc_ldptr ((c), (D), 0, ppc_r11); \ - } G_STMT_END -+#endif - - #define ppc_load_multiple_regs(c,D,d,A) G_STMT_START { \ - int __i, __o = (d); \ -Index: mono-3.4.0/mono/metadata/sgen-marksweep.c -=================================================================== ---- mono-3.4.0.orig/mono/metadata/sgen-marksweep.c -+++ mono-3.4.0/mono/metadata/sgen-marksweep.c -@@ -45,8 +45,10 @@ - #define SGEN_HAVE_CONCURRENT_MARK - #endif - --#define MS_BLOCK_SIZE (16*1024) --#define MS_BLOCK_SIZE_SHIFT 14 -+/* MS_BLOCK_SIZE must be a multiple of the system pagesize, which for some -+ archs is 64k. */ -+#define MS_BLOCK_SIZE (64*1024) -+#define MS_BLOCK_SIZE_SHIFT 16 - #define MAJOR_SECTION_SIZE MS_BLOCK_SIZE - #define CARDS_PER_BLOCK (MS_BLOCK_SIZE / CARD_SIZE_IN_BYTES) - -Index: mono-3.4.0/mono/mini/mini-gc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-gc.c -+++ mono-3.4.0/mono/mini/mini-gc.c -@@ -439,7 +439,12 @@ static int callee_saved_regs [] = { ARMR - #elif defined(TARGET_S390X) - static int callee_saved_regs [] = { s390_r6, s390_r7, s390_r8, s390_r9, s390_r10, s390_r11, s390_r12, s390_r13, s390_r14 }; - #elif defined(TARGET_POWERPC) --static int callee_saved_regs [] = { ppc_r6, ppc_r7, ppc_r8, ppc_r9, ppc_r10, ppc_r11, ppc_r12, ppc_r13, ppc_r14 }; -+static int callee_saved_regs [] = { -+ ppc_r13, ppc_r14, ppc_r15, ppc_r16, -+ ppc_r17, ppc_r18, ppc_r19, ppc_r20, -+ ppc_r21, ppc_r22, ppc_r23, ppc_r24, -+ ppc_r25, ppc_r26, ppc_r27, ppc_r28, -+ ppc_r29, ppc_r30, ppc_r31 }; - #endif - - static guint32 -Index: mono-3.4.0/mono/mini/mini-ppc.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.c -+++ mono-3.4.0/mono/mini/mini-ppc.c -@@ -2811,14 +2811,14 @@ handle_thunk (int absolute, guchar *code - static void - patch_ins (guint8 *code, guint32 ins) - { -- *(guint32*)code = GUINT32_TO_BE (ins); -+ *(guint32*)code = ins; - mono_arch_flush_icache (code, 4); - } - - void - ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd) - { -- guint32 ins = GUINT32_FROM_BE (*(guint32*)code); -+ guint32 ins = *(guint32*)code; - guint32 prim = ins >> 26; - guint32 ovf; - -@@ -2901,7 +2901,13 @@ ppc_patch_full (guchar *code, const guch - else - code -= 24; - } else { -- if (ppc_is_load_op (seq [5]) || ppc_opcode (seq [5]) == 31) /* ld || lwz || mr */ -+ if (ppc_is_load_op (seq [5]) -+#ifdef PPC_USES_FUNCTION_DESCRIPTOR -+ /* With function descs we need to do more careful -+ matches. */ -+ || ppc_opcode (seq [5]) == 31 /* ld || lwz || mr */ -+#endif -+ ) - branch_ins = seq + 8; - else - branch_ins = seq + 6; -@@ -2925,8 +2931,12 @@ ppc_patch_full (guchar *code, const guch - } - - /* FIXME: make this thread safe */ -+#ifdef PPC_USES_FUNCTION_DESCRIPTOR - /* FIXME: we're assuming we're using r11 here */ - ppc_load_ptr_sequence (code, ppc_r11, target); -+#else -+ ppc_load_ptr_sequence (code, ppc_r0, target); -+#endif - mono_arch_flush_icache ((guint8*)seq, 28); - #else - guint32 *seq; -@@ -4481,6 +4491,16 @@ mono_arch_register_lowlevel_calls (void) - } - - #ifdef __mono_ppc64__ -+#ifdef _LITTLE_ENDIAN -+#define patch_load_sequence(ip,val) do {\ -+ guint16 *__load = (guint16*)(ip); \ -+ g_assert (sizeof (val) == sizeof (gsize)); \ -+ __load [0] = (((guint64)(gsize)(val)) >> 48) & 0xffff; \ -+ __load [2] = (((guint64)(gsize)(val)) >> 32) & 0xffff; \ -+ __load [6] = (((guint64)(gsize)(val)) >> 16) & 0xffff; \ -+ __load [8] = ((guint64)(gsize)(val)) & 0xffff; \ -+ } while (0) -+#elif defined _BIG_ENDIAN - #define patch_load_sequence(ip,val) do {\ - guint16 *__load = (guint16*)(ip); \ - g_assert (sizeof (val) == sizeof (gsize)); \ -@@ -4490,6 +4510,9 @@ mono_arch_register_lowlevel_calls (void) - __load [9] = ((guint64)(gsize)(val)) & 0xffff; \ - } while (0) - #else -+#error huh? No endianess defined by compiler -+#endif -+#else - #define patch_load_sequence(ip,val) do {\ - guint16 *__lis_ori = (guint16*)(ip); \ - __lis_ori [1] = (((gulong)(val)) >> 16) & 0xffff; \ -Index: mono-3.4.0/mono/mini/mini-ppc.h -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini-ppc.h -+++ mono-3.4.0/mono/mini/mini-ppc.h -@@ -69,7 +69,13 @@ typedef struct MonoCompileArch { - #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS - #define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS - #define MONO_ARCH_HAVE_ATOMIC_ADD 1 -+ -+/* ELFv2 ABI doesn't use function descriptors. */ -+#if _CALL_ELF == 2 -+#undef PPC_USES_FUNCTION_DESCRIPTOR -+#else - #define PPC_USES_FUNCTION_DESCRIPTOR -+#endif - - #ifndef __mono_ilp32__ - #define MONO_ARCH_HAVE_TLS_GET 1 -Index: mono-3.4.0/mono/mini/mini.c -=================================================================== ---- mono-3.4.0.orig/mono/mini/mini.c -+++ mono-3.4.0/mono/mini/mini.c -@@ -7004,10 +7004,9 @@ mini_get_debug_options (void) - static gpointer - mini_create_ftnptr (MonoDomain *domain, gpointer addr) - { --#if !defined(__ia64__) && !defined(__ppc64__) && !defined(__powerpc64__) -+#if !defined(__ia64__) && (!defined(__ppc64__) && !defined(__powerpc64__) || _CALL_ELF == 2) - return addr; - #else -- - gpointer* desc = NULL; - - if ((desc = g_hash_table_lookup (domain->ftnptrs_hash, addr))) -@@ -7033,7 +7032,7 @@ mini_create_ftnptr (MonoDomain *domain, - static gpointer - mini_get_addr_from_ftnptr (gpointer descr) - { --#if defined(__ia64__) || defined(__ppc64__) || defined(__powerpc64__) -+#if defined(__ia64__) || ((defined(__ppc64__) || defined(__powerpc64__)) && _CALL_ELF != 2) - return *(gpointer*)descr; - #else - return descr; -Index: mono-3.4.0/mono/utils/lock-free-alloc.c -=================================================================== ---- mono-3.4.0.orig/mono/utils/lock-free-alloc.c -+++ mono-3.4.0/mono/utils/lock-free-alloc.c -@@ -123,7 +123,9 @@ struct _MonoLockFreeAllocDescriptor { - - #define NUM_DESC_BATCH 64 - --#define SB_SIZE 16384 -+/* SB_SIZE must be a multiple of the system pagesize, which for some -+ archs is 64k. */ -+#define SB_SIZE 65536 - #define SB_HEADER_SIZE 16 - #define SB_USABLE_SIZE (SB_SIZE - SB_HEADER_SIZE) - -Index: mono-3.4.0/mono/utils/mono-mmap.c -=================================================================== ---- mono-3.4.0.orig/mono/utils/mono-mmap.c -+++ mono-3.4.0/mono/utils/mono-mmap.c -@@ -332,6 +332,11 @@ mono_valloc (void *addr, size_t length, - int - mono_vfree (void *addr, size_t length) - { -+/*if ( (length & (mono_pagesize () - 1)) != 0) -+ printf ("XXXX vfree: length not multiple of pagesize\n"); -+if ( aligned_address (addr, length, mono_pagesize()) != addr) -+ printf ("XXXX vfree: addr not aligned to pagesize\n");*/ -+ - return munmap (addr, length); - } - -Index: mono-3.4.0/mono/utils/strtod.c -=================================================================== ---- mono-3.4.0.orig/mono/utils/strtod.c -+++ mono-3.4.0/mono/utils/strtod.c -@@ -173,6 +173,12 @@ - * #define NO_ERRNO if strtod should not assign errno = ERANGE when - * the result overflows to +-Infinity or underflows to 0. - */ -+#if defined __BIG_ENDIAN__ || defined _BIG_ENDIAN -+# define IEEE_MC68k -+#elif defined __LITTLE_ENDIAN__ || defined _LITTLE_ENDIAN -+# define IEEE_8087 -+#else -+ - #if defined(TARGET_X86) || defined(mips) && defined(MIPSEL) || defined (__arm__) - - # define IEEE_8087 -@@ -194,9 +200,12 @@ - # define IEEE_MC68k - - #else -+#warning byte order unknown, assuming big endian - #define IEEE_MC68k - #endif - -+#endif -+ - #define Long gint32 - #define ULong guint32 - diff --git a/mono-core.changes b/mono-core.changes index 6d83469..4f047bb 100644 --- a/mono-core.changes +++ b/mono-core.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Mon Mar 23 22:04:47 UTC 2015 - dvaleev@suse.com + +- Cleanup patch numbers +- Rebase ppc64 patches based on upstream (commits are 173eaf1dfaf, + 7e056cd346c, PR#1479) - 0001-ppc64le-fixes.patch bsc#923558 + ------------------------------------------------------------------- Tue Mar 17 17:37:18 UTC 2015 - astieger@suse.com diff --git a/mono-core.spec b/mono-core.spec index 59c9395..0ae9a55 100644 --- a/mono-core.spec +++ b/mono-core.spec @@ -30,20 +30,16 @@ Url: http://www.mono-project.com Source0: http://download.mono-project.com/sources/mono/mono-%{version}.tar.bz2 Source1: mono-core.rpmlintrc # PATCH-FIX-UPSTREAM Use runtime 4.5 as default for nunit -Patch5: mono-nunit-default-runtime-4.5.patch -# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch7: mono-core-ppc64le.diff -# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch8: mono-core-ppc64le-swr11r12.diff -# PATCH-MISSING-TAG -- See http://en.opensuse.org/openSUSE:Packaging_Patches_guidelines -Patch9: mono-core-ppc64le-callreg.diff +Patch0: mono-nunit-default-runtime-4.5.patch # PATCH-FIX-UPSTREAM resources/keyboards.resources exists on x86_64, # so cp won't work, should add -r argument -Patch10: mono-3.x-keyboards.resources-cp_r.patch +Patch1: mono-3.x-keyboards.resources-cp_r.patch # PATCH-FIX-UPSTREAM https://github.com/mono/mono/commit/b27d0248772e0b3288fba4f7328bfea1a6693689.patch -Patch11: gc-64bit-portability-warning.patch +Patch2: gc-64bit-portability-warning.patch # PATCH-FIX-UPSTREAM https://github.com/mono/mono/pull/1514.patch -Patch12: X509Certificate-workaround.patch +Patch3: X509Certificate-workaround.patch +# PATCH-FIX-UPSTREAM 173eaf1dfaf,7e056cd346c, PR#1479 +Patch4: 0001-ppc64le-fixes.patch BuildRequires: autoconf BuildRequires: automake BuildRequires: bison @@ -106,15 +102,11 @@ technologies that have been submitted to the ECMA for standardization. %prep %setup -q -n mono-%{version} -%patch5 -p1 -%ifarch ppc64 -%patch7 -p1 -%patch8 -p1 -%patch9 -p1 -%endif -%patch10 -p1 -%patch11 -p1 -%patch12 -p1 +%patch0 -p1 +%patch1 -p1 +%patch2 -p1 +%patch3 -p1 +%patch4 -p1 %build ./autogen.sh @@ -1204,10 +1196,7 @@ Requires: mono-web = %{version} Requires: mono-winforms = %{version} Requires: pkgconfig Provides: mono-xbuild = %{version} -# We build natively on ppc64 now -%ifarch ppc64 Provides: mono-biarchcompat = %{version} -%endif Provides: mono(PEAPI) = 1.0.5000.0 Provides: mono(resgen) = 1.0.5000.0