From 4e791093f9e0652aa684b8abca80cc03585d0859 Mon Sep 17 00:00:00 2001 From: Fan Yang Date: Mon, 1 Mar 2021 08:28:09 -0500 Subject: [PATCH] Initial change for supporting 4-arg ops --- src/mono/mono/mini/genmdesc.py | 8 ++++++-- src/mono/mono/mini/helpers.c | 9 +++++++++ src/mono/mono/mini/method-to-ir.c | 11 +++++++++-- src/mono/mono/mini/mini-llvm.c | 9 +++++++-- src/mono/mono/mini/mini.h | 9 +++++++-- 5 files changed, 38 insertions(+), 8 deletions(-) diff --git a/src/mono/mono/mini/genmdesc.py b/src/mono/mono/mini/genmdesc.py index 305bee2e1cc2e..58b25e0cb9407 100755 --- a/src/mono/mono/mini/genmdesc.py +++ b/src/mono/mono/mini/genmdesc.py @@ -91,8 +91,12 @@ def parse_mini_ops (target_define): if m != None: opcodes [m.group (1)] = OpDef(opcode_id, m.group (1), m.group (2), m.group (3), m.group (4)) else: - print ("Unable to parse line: '{0}'".format (line)) - exit (1) + m = re.search (r"MINI_OP4\(\w+\s*\,\s*\"([^\"]+)\", (\w+), (\w+), (\w+), (\w+), (\w+)\)", line) + if m != None: + opcodes [m.group (1)] = OpDef(opcode_id, m.group (1), m.group (2), m.group (3), m.group (4)) + else: + print ("Unable to parse line: '{0}'".format (line)) + exit (1) opcode_id += 1 opcode_file.close () return opcodes diff --git a/src/mono/mono/mini/helpers.c b/src/mono/mono/mini/helpers.c index 0a7b0d9b43373..fd3cf33b5a134 100644 --- a/src/mono/mono/mini/helpers.c +++ b/src/mono/mono/mini/helpers.c @@ -25,6 +25,9 @@ #ifdef MINI_OP3 #undef MINI_OP3 #endif +#ifdef MINI_OP4 +#undef MINI_OP4 +#endif // This, instead of an array of pointers, to optimize away a pointer and a relocation per string. #define MSGSTRFIELD(line) MSGSTRFIELD1(line) @@ -32,22 +35,28 @@ static const struct msgstr_t { #define MINI_OP(a,b,dest,src1,src2) char MSGSTRFIELD(__LINE__) [sizeof (b)]; #define MINI_OP3(a,b,dest,src1,src2,src3) char MSGSTRFIELD(__LINE__) [sizeof (b)]; +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) char MSGSTRFIELD(__LINE__) [sizeof (b)]; #include "mini-ops.h" #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 } opstr = { #define MINI_OP(a,b,dest,src1,src2) b, #define MINI_OP3(a,b,dest,src1,src2,src3) b, +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) b, #include "mini-ops.h" #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 }; static const gint16 opidx [] = { #define MINI_OP(a,b,dest,src1,src2) offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)), #define MINI_OP3(a,b,dest,src1,src2,src3) offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)), +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) offsetof (struct msgstr_t, MSGSTRFIELD(__LINE__)), #include "mini-ops.h" #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 }; #endif /* DISABLE_LOGGING */ diff --git a/src/mono/mono/mini/method-to-ir.c b/src/mono/mono/mini/method-to-ir.c index 1b900f43040c1..66208d256e256 100644 --- a/src/mono/mono/mini/method-to-ir.c +++ b/src/mono/mono/mini/method-to-ir.c @@ -201,8 +201,12 @@ static GENERATE_GET_CLASS_WITH_CACHE (geqcomparer, "System.Collections.Generic", #ifdef MINI_OP3 #undef MINI_OP3 #endif -#define MINI_OP(a,b,dest,src1,src2) dest, src1, src2, ' ', -#define MINI_OP3(a,b,dest,src1,src2,src3) dest, src1, src2, src3, +#ifdef MINI_OP4 +#undef MINI_OP4 +#endif +#define MINI_OP(a,b,dest,src1,src2) dest, src1, src2, ' ', ' ', +#define MINI_OP3(a,b,dest,src1,src2,src3) dest, src1, src2, src3, ' ', +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) dest, src1, src2, src3, src4, #define NONE ' ' #define IREG 'i' #define FREG 'f' @@ -220,9 +224,11 @@ mini_ins_info[] = { }; #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 #define MINI_OP(a,b,dest,src1,src2) ((src2) != NONE ? 2 : ((src1) != NONE ? 1 : 0)), #define MINI_OP3(a,b,dest,src1,src2,src3) ((src3) != NONE ? 3 : ((src2) != NONE ? 2 : ((src1) != NONE ? 1 : 0))), +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) ((src4) != NONE ? 4 : ((src3) != NONE ? 3 : ((src2) != NONE ? 2 : ((src1) != NONE ? 1 : 0)))), /* * This should contain the index of the last sreg + 1. This is not the same * as the number of sregs for opcodes like IA64_CMP_EQ_IMM. @@ -232,6 +238,7 @@ const gint8 mini_ins_sreg_counts[] = { }; #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 guint32 mono_alloc_ireg (MonoCompile *cfg) diff --git a/src/mono/mono/mini/mini-llvm.c b/src/mono/mono/mini/mini-llvm.c index 7dcc4b71a810d..7c2498b5942a5 100644 --- a/src/mono/mono/mini/mini-llvm.c +++ b/src/mono/mono/mini/mini-llvm.c @@ -210,8 +210,12 @@ typedef struct { #ifdef MINI_OP3 #undef MINI_OP3 #endif -#define MINI_OP(a,b,dest,src1,src2) dest, src1, src2, ' ', -#define MINI_OP3(a,b,dest,src1,src2,src3) dest, src1, src2, src3, +#ifdef MINI_OP4 +#undef MINI_OP4 +#endif +#define MINI_OP(a,b,dest,src1,src2) dest, src1, src2, ' ', ' ', +#define MINI_OP3(a,b,dest,src1,src2,src3) dest, src1, src2, src3, ' ', +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) dest, src1, src2, src3, src4, #define NONE ' ' #define IREG 'i' #define FREG 'f' @@ -225,6 +229,7 @@ mini_llvm_ins_info[] = { }; #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 #if TARGET_SIZEOF_VOID_P == 4 #define GET_LONG_IMM(ins) ((ins)->inst_l) diff --git a/src/mono/mono/mini/mini.h b/src/mono/mono/mini/mini.h index ee3d184189a19..8c37552583eeb 100644 --- a/src/mono/mono/mini/mini.h +++ b/src/mono/mono/mini/mini.h @@ -717,7 +717,7 @@ typedef struct { LLVMArgInfo args [1]; } LLVMCallInfo; -#define MONO_MAX_SRC_REGS 3 +#define MONO_MAX_SRC_REGS 4 struct MonoInst { guint16 opcode; @@ -725,7 +725,7 @@ struct MonoInst { guint8 flags; /* used by the register allocator */ - gint32 dreg, sreg1, sreg2, sreg3; + gint32 dreg, sreg1, sreg2, sreg3, sreg4; MonoInst *next, *prev; @@ -1728,8 +1728,12 @@ extern MonoJitStats mono_jit_stats; #ifdef MINI_OP3 #undef MINI_OP3 #endif +#ifdef MINI_OP4 +#undef MINI_OP4 +#endif #define MINI_OP(a,b,dest,src1,src2) a, #define MINI_OP3(a,b,dest,src1,src2,src3) a, +#define MINI_OP4(a,b,dest,src1,src2,src3,src4) a, enum { OP_START = MONO_CEE_LAST - 1, #include "mini-ops.h" @@ -1737,6 +1741,7 @@ enum { }; #undef MINI_OP #undef MINI_OP3 +#undef MINI_OP4 #if TARGET_SIZEOF_VOID_P == 8 #define OP_PCONST OP_I8CONST