X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=mono%2Fmini%2Fmini-ppc.h;h=dcc1c5fae282ceb718968eb76979057494613a5a;hb=fd12271ce38cea612b0fa3161af9b725ceeb904a;hp=fb35e2a60f85f02b92a9bd822ccbbdc1dfb9e045;hpb=bb48a6163d88ce95bb401d20212a2d55be54a86a;p=mono.git diff --git a/mono/mini/mini-ppc.h b/mono/mini/mini-ppc.h index fb35e2a60f8..dcc1c5fae28 100644 --- a/mono/mini/mini-ppc.h +++ b/mono/mini/mini-ppc.h @@ -2,6 +2,8 @@ #define __MONO_MINI_PPC_H__ #include +#include +#include #include #ifdef __mono_ppc64__ @@ -26,27 +28,21 @@ void ppc_patch (guchar *code, const guchar *target); void ppc_patch_full (guchar *code, const guchar *target, gboolean is_fd); struct MonoLMF { + /* + * If the second lowest bit is set to 1, then this is a MonoLMFExt structure, and + * the other fields are not valid. + */ gpointer previous_lmf; gpointer lmf_addr; MonoMethod *method; gulong ebp; gulong eip; - gulong iregs [MONO_SAVED_GREGS]; /* 13..31 */ + /* Add a dummy field to force iregs to be aligned when cross compiling from x86 */ + gulong dummy; + mgreg_t iregs [MONO_SAVED_GREGS]; /* 13..31 */ gdouble fregs [MONO_SAVED_FREGS]; /* 14..31 */ }; -/* we define our own structure and we'll copy the data - * from sigcontext/ucontext/mach when we need it. - * This also makes us save stack space and time when copying - * We might also want to add an additional field to propagate - * the original context from the signal handler. - */ -typedef struct { - gulong sc_ir; // pc - gulong sc_sp; // r1 - gulong regs [MONO_SAVED_GREGS]; - double fregs [MONO_SAVED_FREGS]; -} MonoContext; typedef struct MonoCompileArch { int fp_conv_var_offset; @@ -54,15 +50,24 @@ typedef struct MonoCompileArch { /* * ILP32 uses a version of the ppc64 abi with sizeof(void*)==sizeof(long)==4. - * To support this, code which needs the size of a pointer needs to use - * sizeof (gpointer), while code which needs the size of a register/stack slot - * needs to use SIZEOF_REGISTER. + * To support this, code needs to follow the following conventions: + * - for the size of a pointer use sizeof (gpointer) + * - for the size of a register/stack slot use SIZEOF_REGISTER. + * - for variables which contain values of registers, use mgreg_t. + * - for loading/saving pointers/ints, use the normal ppc_load_reg/ppc_save_reg () + * macros. + * - for loading/saving register sized quantities, use the ppc_ldr/ppc_str + * macros. + * - make sure to not mix the two kinds of macros for the same memory location, + * since ppc is big endian, so a 8 byte store followed by a 4 byte load will + * load the upper 32 bit of the value. + * - use OP_LOADR_MEMBASE/OP_STORER_MEMBASE to load/store register sized + * quantities. */ #ifdef __mono_ppc64__ #define MONO_ARCH_NO_EMULATE_LONG_SHIFT_OPS #define MONO_ARCH_NO_EMULATE_LONG_MUL_OPTS -#define MONO_ARCH_HAVE_ATOMIC_ADD 1 #define PPC_USES_FUNCTION_DESCRIPTOR #ifndef __mono_ilp32__ @@ -89,7 +94,6 @@ typedef struct MonoCompileArch { #define MONO_ARCH_EMULATE_LCONV_TO_R8_UN 1 #define MONO_ARCH_EMULATE_FREM 1 #define MONO_ARCH_BIGMUL_INTRINS 1 -#define MONO_ARCH_HAVE_ATOMIC_CAS 1 /* Parameters used by the register allocator */ #define MONO_ARCH_CALLEE_REGS ((0xff << ppc_r3) | (1 << ppc_r11) | (1 << ppc_r12)) @@ -165,40 +169,34 @@ typedef struct MonoCompileArch { #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_VTABLE_REG ppc_r12 -#define MONO_ARCH_RGCTX_REG ppc_r12 +#define MONO_ARCH_RGCTX_REG MONO_ARCH_IMT_REG #define MONO_ARCH_NO_IOV_CHECK 1 #define MONO_ARCH_HAVE_DECOMPOSE_OPTS 1 #define MONO_ARCH_HAVE_DECOMPOSE_LONG_OPTS 1 #define MONO_ARCH_HAVE_GENERALIZED_IMT_THUNK 1 -#define MONO_ARCH_HAVE_THROW_CORLIB_EXCEPTION 1 -#define MONO_ARCH_HAVE_STATIC_RGCTX_TRAMPOLINE 1 #define MONO_ARCH_HAVE_FULL_AOT_TRAMPOLINES 1 +#define MONO_ARCH_HAVE_XP_UNWIND 1 #define MONO_ARCH_GSHARED_SUPPORTED 1 #define MONO_ARCH_NEED_DIV_CHECK 1 #define MONO_ARCH_AOT_SUPPORTED 1 #define MONO_ARCH_NEED_GOT_VAR 1 +#if !defined(MONO_CROSS_COMPILE) && !defined(TARGET_PS3) +#define MONO_ARCH_SOFT_DEBUG_SUPPORTED 1 +#endif +#define MONO_ARCH_THIS_AS_FIRST_ARG 1 +#define MONO_ARCH_HAVE_OP_TAIL_CALL 1 #define PPC_NUM_REG_ARGS (PPC_LAST_ARG_REG-PPC_FIRST_ARG_REG+1) #define PPC_NUM_REG_FPARGS (PPC_LAST_FPARG_REG-PPC_FIRST_FPARG_REG+1) -/* we have the stack pointer, not the base pointer in sigcontext */ -#define MONO_CONTEXT_SET_IP(ctx,ip) do { (ctx)->sc_ir = (gulong)ip; } while (0); -/* FIXME: should be called SET_SP */ -#define MONO_CONTEXT_SET_BP(ctx,bp) do { (ctx)->sc_sp = (gulong)bp; } while (0); - -#define MONO_CONTEXT_GET_IP(ctx) ((gpointer)((ctx)->sc_ir)) -#define MONO_CONTEXT_GET_BP(ctx) ((gpointer)((ctx)->regs [ppc_r31-13])) -#define MONO_CONTEXT_GET_SP(ctx) ((gpointer)((ctx)->sc_sp)) - #ifdef MONO_CROSS_COMPILE typedef struct { @@ -227,11 +225,11 @@ typedef struct { #else typedef struct { - unsigned long sp; + mgreg_t sp; #ifdef __mono_ppc64__ - unsigned long cr; + mgreg_t cr; #endif - unsigned long lr; + mgreg_t lr; } MonoPPCStackFrame; #ifdef G_COMPILER_CODEWARRIOR @@ -253,6 +251,8 @@ typedef struct { #endif #endif +#define MONO_ARCH_INIT_TOP_LMF_ENTRY(lmf) do { (lmf)->ebp = -1; } while (0) + typedef struct { gint8 reg; gint8 size; @@ -275,59 +275,42 @@ extern guint8* mono_ppc_create_pre_code_ftnptr (guint8 *code) MONO_INTERNAL; #endif #if defined(__linux__) - typedef struct ucontext os_ucontext; - #define MONO_ARCH_USE_SIGACTION 1 - -#ifdef __mono_ppc64__ - #define UCONTEXT_REG_Rn(ctx, n) ((ctx)->uc_mcontext.gp_regs [(n)]) - #define UCONTEXT_REG_FPRn(ctx, n) ((ctx)->uc_mcontext.fp_regs [(n)]) - #define UCONTEXT_REG_NIP(ctx) ((ctx)->uc_mcontext.gp_regs [PT_NIP]) - #define UCONTEXT_REG_LNK(ctx) ((ctx)->uc_mcontext.gp_regs [PT_LNK]) -#else - #define UCONTEXT_REG_Rn(ctx, n) ((ctx)->uc_mcontext.uc_regs->gregs [(n)]) - #define UCONTEXT_REG_FPRn(ctx, n) ((ctx)->uc_mcontext.uc_regs->fpregs.fpregs [(n)]) - #define UCONTEXT_REG_NIP(ctx) ((ctx)->uc_mcontext.uc_regs->gregs [PT_NIP]) - #define UCONTEXT_REG_LNK(ctx) ((ctx)->uc_mcontext.uc_regs->gregs [PT_LNK]) -#endif #elif defined (__APPLE__) && defined (_STRUCT_MCONTEXT) #define MONO_ARCH_USE_SIGACTION 1 - typedef struct __darwin_ucontext os_ucontext; - - #define UCONTEXT_REG_Rn(ctx, n) ((&(ctx)->uc_mcontext->__ss.__r0) [(n)]) - #define UCONTEXT_REG_FPRn(ctx, n) ((ctx)->uc_mcontext->__fs.__fpregs [(n)]) - #define UCONTEXT_REG_NIP(ctx) ((ctx)->uc_mcontext->__ss.__srr0) - #define UCONTEXT_REG_LNK(ctx) ((ctx)->uc_mcontext->__ss.__lr) #elif defined (__APPLE__) && !defined (_STRUCT_MCONTEXT) #define MONO_ARCH_USE_SIGACTION 1 - typedef struct ucontext os_ucontext; - - #define UCONTEXT_REG_Rn(ctx, n) ((&(ctx)->uc_mcontext->ss.r0) [(n)]) - #define UCONTEXT_REG_FPRn(ctx, n) ((ctx)->uc_mcontext->fs.fpregs [(n)]) - #define UCONTEXT_REG_NIP(ctx) ((ctx)->uc_mcontext->ss.srr0) - #define UCONTEXT_REG_LNK(ctx) ((ctx)->uc_mcontext->ss.lr) #elif defined(__NetBSD__) #define MONO_ARCH_USE_SIGACTION 1 - typedef ucontext_t os_ucontext; +#elif defined(__FreeBSD__) +#define MONO_ARCH_USE_SIGACTION 1 +#elif defined(MONO_CROSS_COMPILE) + typedef MonoContext ucontext_t; +/* typedef struct { + int dummy; + } ucontext_t;*/ + #define UCONTEXT_REG_Rn(ctx, n) + #define UCONTEXT_REG_FPRn(ctx, n) + #define UCONTEXT_REG_NIP(ctx) + #define UCONTEXT_REG_LNK(ctx) - #define UCONTEXT_REG_Rn(ctx, n) ((ctx)->uc_mcontext.__gregs [(n)]) - #define UCONTEXT_REG_FPRn(ctx, n) ((ctx)->uc_mcontext.__fpregs.__fpu_regs [(n)]) - #define UCONTEXT_REG_NIP(ctx) _UC_MACHINE_PC(ctx) - #define UCONTEXT_REG_LNK(ctx) ((ctx)->uc_mcontext.__gregs [_REG_LR]) #else /* For other operating systems, we pull the definition from an external file */ #include "mini-ppc-os.h" #endif +gboolean +mono_ppc_tail_call_supported (MonoMethodSignature *caller_sig, MonoMethodSignature *callee_sig) MONO_INTERNAL; + void mono_ppc_patch (guchar *code, const guchar *target) MONO_INTERNAL; void -mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, gulong *int_regs, gdouble *fp_regs, gboolean rethrow) MONO_INTERNAL; +mono_ppc_throw_exception (MonoObject *exc, unsigned long eip, unsigned long esp, mgreg_t *int_regs, gdouble *fp_regs, gboolean rethrow) MONO_INTERNAL; #ifdef __mono_ppc64__ #define MONO_PPC_32_64_CASE(c32,c64) c64 -extern void mono_ppc_emitted (guint8 *code, ssize_t length, const char *format, ...); +extern void mono_ppc_emitted (guint8 *code, gint64 length, const char *format, ...); #else #define MONO_PPC_32_64_CASE(c32,c64) c32 #endif @@ -336,4 +319,6 @@ gboolean mono_ppc_is_direct_call_sequence (guint32 *code) MONO_INTERNAL; void mono_ppc_patch_plt_entry (guint8 *code, gpointer *got, mgreg_t *regs, guint8 *addr) MONO_INTERNAL; +void mono_ppc_set_func_into_sigctx (void *sigctx, void *func) MONO_INTERNAL; + #endif /* __MONO_MINI_PPC_H__ */