[Mono-dev] JIT: MonoReg to replace gssize for registers

Zoltan Varga vargaz at gmail.com
Tue Dec 16 08:27:41 EST 2008


Hi,

  It looks ugly, but if it is really needed on mips, then its ok.

                    Zoltan

On Mon, Dec 15, 2008 at 11:30 PM, Mark Mason <mmason at upwardaccess.com> wrote:
> Hello,
>
> On Sun, 2008-12-14 at 10:13 +0100, Zoltan Varga wrote:
>> Hi,
>>
>>   There is already a type for this called 'greg_t' on linux. So it
>> might be useful to name the
>> new type something similar, like mgreg_t, or something. Other than
>> that, based on the
>> discussion, I think this is ok to check in.
>
> With this in mind, here is the updated patch. I'm still not entirely
> comfortable with the type aliasing between inst_p* and inst_c*, but I
> think this will come the closest to doing the right thing with minimal
> changes.
>
> /Mark
>
> Index: mini.h
> ===================================================================
> --- mini.h      (revision 121486)
> +++ mini.h      (working copy)
> @@ -400,6 +400,16 @@
>        int size, align;
>  } MonoMemcpyArgs;
>
> +/* C type matching the size of a machine register. Not always the same
> as 'int' */
> +/* Note that member 'p' of MonoInst must be the same type, as OP_PCONST
> is defined
> + * as one of the OP_ICONST types, so inst_c0 must be the same as
> inst_p0
> + */
> +#if SIZEOF_REGISTER == 4
> +typedef gint32 mgreg_t;
> +#elif SIZEOF_REGISTER == 8
> +typedef gint64 mgreg_t;
> +#endif
> +
>  struct MonoInst {
>        guint16 opcode;
>        guint8  type; /* stack type */
> @@ -415,8 +425,14 @@
>                union {
>                        MonoInst *src;
>                        MonoMethodVar *var;
> -                       gssize const_val;
> +                       mgreg_t const_val;
> +#if (SIZEOF_REGISTER > SIZEOF_VOID_P) && (G_BYTE_ORDER == G_BIG_ENDIAN)
> +                       struct {
> +                               gpointer p[SIZEOF_REGISTER/SIZEOF_VOID_P];
> +                       } pdata;
> +#else
>                        gpointer p;
> +#endif
>                        MonoMethod *method;
>                        MonoMethodSignature *signature;
>                        MonoBasicBlock **many_blocks;
> @@ -511,8 +527,13 @@
>  #define inst_c1 data.op[1].const_val
>  #define inst_i0 data.op[0].src
>  #define inst_i1 data.op[1].src
> +#if (SIZEOF_REGISTER > SIZEOF_VOID_P) && (G_BYTE_ORDER == G_BIG_ENDIAN)
> +#define inst_p0 data.op[0].pdata.p[SIZEOF_REGISTER/SIZEOF_VOID_P]
> +#define inst_p1 data.op[1].pdata.p[SIZEOF_REGISTER/SIZEOF_VOID_P]
> +#else
>  #define inst_p0 data.op[0].p
>  #define inst_p1 data.op[1].p
> +#endif
>  #define inst_l  data.i8const
>  #define inst_r  data.r8const
>  #define inst_left  data.op[0].src
>
>
>


More information about the Mono-devel-list mailing list