Permalink
Browse files

2002-02-21 Dietmar Maurer <dietmar@ximian.com>

	* x86.brg: impl. SHR_UN for lreg, added new test, bug fix for BNE_UN

svn path=/trunk/mono/; revision=2559
  • Loading branch information...
1 parent 7f0868d commit a23a2ab6781c073442f8086e3105aa9fac8245ec Dietmar Maurer committed Feb 21, 2002
Showing with 143 additions and 11 deletions.
  1. +4 −0 mono/jit/ChangeLog
  2. +20 −1 mono/jit/jit.c
  3. +46 −3 mono/jit/x86.brg
  4. +73 −7 mono/tests/jit-long.cs
View
@@ -1,3 +1,7 @@
+2002-02-21 Dietmar Maurer <dietmar@ximian.com>
+
+ * x86.brg: impl. SHR_UN for lreg, added new test, bug fix for BNE_UN
+
2002-02-19 Dietmar Maurer <dietmar@ximian.com>
* emit-x86.c (arch_compile_method): add shared code to mono_root_domain
View
@@ -82,7 +82,6 @@ case CEE_##name: { \
++ip; \
sp -= 2; \
t1 = mono_ctree_new (mp, MB_TERM_##name, sp [0], sp [1]); \
- g_assert (sp [0]->svt == sp [1]->svt); \
PUSH_TREE (t1, sp [0]->svt); \
break; \
}
@@ -3214,6 +3213,20 @@ sigfpe_signal_handler (int _dummy)
}
static void
+sigill_signal_handler (int _dummy)
+{
+ MonoException *exc;
+ void **_p = (void **)&_dummy;
+ struct sigcontext *ctx = (struct sigcontext *)++_p;
+
+ exc = mono_get_exception_execution_engine ();
+
+ arch_handle_exception (ctx, exc);
+
+ g_error ("we should never reach this code");
+}
+
+static void
sigsegv_signal_handler (int _dummy)
{
MonoException *exc;
@@ -3323,6 +3336,12 @@ main (int argc, char *argv [])
sa.sa_flags = 0;
g_assert (syscall (SYS_sigaction, SIGFPE, &sa, NULL) != -1);
+ /* catch SIGILL */
+ sa.sa_handler = sigill_signal_handler;
+ sigemptyset (&sa.sa_mask);
+ sa.sa_flags = 0;
+ g_assert (syscall (SYS_sigaction, SIGILL, &sa, NULL) != -1);
+
/* catch SIGSEGV */
sa.sa_handler = sigsegv_signal_handler;
sigemptyset (&sa.sa_mask);
View
@@ -2116,12 +2116,28 @@ lreg: SHR (lreg, CONST_I4) {
if (tree->reg2 != tree->left->reg2)
x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
} else if (tree->right->data.i < 64) {
- x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
+ if (tree->reg1 != tree->left->reg2)
+ x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg2, 4);
+ if (tree->reg2 != tree->left->reg2)
+ x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
x86_shift_reg_imm (s->code, X86_SAR, tree->reg2, 31);
- x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg2, 4);
x86_shift_reg_imm (s->code, X86_SAR, tree->reg1, (tree->right->data.i - 32));
} /* else unspecified result */
+}
+lreg: SHR_UN (lreg, CONST_I4) {
+ if (tree->right->data.i < 32) {
+ x86_shrd_reg_imm (s->code, tree->left->reg1, tree->left->reg2, tree->right->data.i);
+ x86_shift_reg_imm (s->code, X86_SHR, tree->left->reg2, tree->right->data.i);
+ if (tree->reg1 != tree->left->reg1)
+ x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg1, 4);
+ if (tree->reg2 != tree->left->reg2)
+ x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
+ } else if (tree->right->data.i < 64) {
+ x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg2, 4);
+ x86_shift_reg_imm (s->code, X86_SHR, tree->reg1, (tree->right->data.i - 32));
+ x86_mov_reg_imm (s->code, tree->reg2, 0);
+ } /* else unspecified result */
}
lreg: SHR (lreg, reg) {
@@ -2151,6 +2167,33 @@ lreg: SHR (lreg, reg) {
x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
}
+lreg: SHR_UN (lreg, reg) {
+ guint8 *start = s->code;
+ gint32 o1, o2, i;
+
+ tree->is_jump = TRUE;
+
+ if (tree->right->reg1 != X86_ECX)
+ x86_mov_reg_reg (s->code, X86_ECX, tree->right->reg1, 4);
+
+ for (i = 0; i < 2; i ++) {
+ s->code = start;
+ x86_shrd_reg (s->code, tree->left->reg1, tree->left->reg2);
+ x86_shift_reg (s->code, X86_SHR, tree->left->reg2);
+ x86_test_reg_imm (s->code, X86_ECX, 32);
+ o1 = 2 + s->code - s->start;
+ x86_branch8 (s->code, X86_CC_EQ, o2 - o1, FALSE);
+ x86_mov_reg_reg (s->code, tree->left->reg1, tree->left->reg2, 4);
+ x86_shift_reg_imm (s->code, X86_SHR, tree->reg2, 31);
+ o2 = s->code - s->start;
+ }
+
+ if (tree->reg1 != tree->left->reg1)
+ x86_mov_reg_reg (s->code, tree->reg1, tree->left->reg1, 4);
+ if (tree->reg2 != tree->left->reg2)
+ x86_mov_reg_reg (s->code, tree->reg2, tree->left->reg2, 4);
+}
+
lreg: SHL (lreg, CONST_I4) {
if (tree->right->data.i < 32) {
x86_shld_reg_imm (s->code, tree->left->reg2, tree->left->reg1, tree->right->data.i);
@@ -2581,7 +2624,7 @@ stmt: BNE_UN (lreg, lreg) {
x86_alu_reg_reg (s->code, X86_CMP, tree->left->reg1, tree->right->reg1);
offset = 6 + s->code - s->start;
- x86_branch8 (s->code, X86_CC_NE, tree->data.bb->addr - offset, FALSE);
+ x86_branch32 (s->code, X86_CC_NE, tree->data.bb->addr - offset, FALSE);
x86_alu_reg_reg (s->code, X86_CMP, tree->left->reg2, tree->right->reg2);
offset = 6 + s->code - s->start;
x86_branch32 (s->code, X86_CC_NE, tree->data.bb->addr - offset, FALSE);
View
@@ -1,14 +1,16 @@
+using System;
+
public class TestJit {
public static long test_call (long a, long b) {
return a+b;
}
- public static int test_shift ()
+ public static int test_shift_1 ()
{
long a = 9;
int b = 1;
-
+
if ((a >> b) != 4)
return 1;
@@ -28,6 +30,63 @@ public static int test_shift ()
return 0;
}
+ public static int test_shift_2 ()
+ {
+ unchecked {
+ long c = (long)0x800000ff00000000;
+ long d = (long)0x8ef0abcd00000000;
+ long t;
+ int sa;
+
+ t = c>>4;
+ Console.WriteLine (t.ToString ("X"));
+ if (t != (long)0xf800000ff0000000)
+ return 1;
+
+ if ((t << 4) != c)
+ return 1;
+
+ t = d>>40;
+ Console.WriteLine (t.ToString ("X"));
+ if (t != (long)0xffffffffff8ef0ab)
+ return 1;
+
+ if ((t << 40) != (long)0x8ef0ab0000000000)
+ return 1;
+
+
+ }
+
+ return 0;
+ }
+
+ public static int test_shift_3 ()
+ {
+ checked {
+ ulong c = 0x800000ff00000000;
+ ulong d = 0x8ef0abcd00000000;
+ ulong t;
+
+ t = c >> 4;
+ Console.WriteLine (t.ToString ("X"));
+ if (t != 0x0800000ff0000000)
+ return 1;
+
+ if ((t << 4) != c)
+ return 1;
+
+ t = d >> 40;
+ Console.WriteLine (t.ToString ("X"));
+ if (t != 0x8ef0ab)
+ return 1;
+
+ if ((t << 40) != 0x8ef0ab0000000000)
+ return 1;
+ }
+
+ return 0;
+ }
+
public static int test_alu ()
{
long a = 9, b = 6;
@@ -89,22 +148,29 @@ public static int test_branch ()
}
public static int Main() {
- int num = 1;
+ int num = 0;
- if (test_shift () != 0)
+ num++;
+ if (test_shift_1 () != 0)
return num;
num++;
- if (test_call (3, 5) != 8)
+ if (test_shift_2 () != 0)
return num;
num++;
+ if (test_shift_3 () != 0)
+ return num;
+
+ num++;
+ if (test_call (3, 5) != 8)
+ return num;
+ num++;
if (test_branch () != 0)
return num;
+
num++;
-
if (test_alu () != 0)
return num;
- num++;
return 0;
}

0 comments on commit a23a2ab

Please sign in to comment.