Port-next68k archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Nested functions on next68k



Back on Monday, I wrote

> So I changed gcc to use [trap #12], rebuilt one of my tools with the
> resulting cc1, and it no logner crashes.  I'm now doing a rebuild of
> the whole system with this change and will then rebuild the affected
> tools with that; if they then work as well as I expect, I'll post the
> patch here - it's small.

It seems to work, so here's the change.  This is for next68k/1.4T; I
don't see any unique version ID strings in the affected files, so it's
difficult for me to cite them.

diff --git a/gnu/dist/gcc/config/m68k/m68k.h b/gnu/dist/gcc/config/m68k/m68k.h
index 629c62e..107b3e8 100644
--- a/gnu/dist/gcc/config/m68k/m68k.h
+++ b/gnu/dist/gcc/config/m68k/m68k.h
@@ -1235,12 +1235,14 @@ while(0)
 
 #define INITIALIZE_TRAMPOLINE(TRAMP, FNADDR, CXT)                      \
 {                                                                      \
+  rtx a1;                                                              \
+  a1 = force_reg(SImode,TRAMP);                                                
\
   emit_move_insn (gen_rtx_MEM (HImode, TRAMP), GEN_INT(0x207C));       \
   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 2)), CXT); \
   emit_move_insn (gen_rtx_MEM (HImode, plus_constant (TRAMP, 6)),      \
                  GEN_INT(0x4EF9));                                     \
   emit_move_insn (gen_rtx_MEM (SImode, plus_constant (TRAMP, 8)), FNADDR); \
-  FINALIZE_TRAMPOLINE(TRAMP);                                          \
+  emit_insn(gen_trampcachefix(a1));                                    \
 }
 
 /* This is the library routine that is used
diff --git a/gnu/dist/gcc/config/m68k/m68k.md b/gnu/dist/gcc/config/m68k/m68k.md
index 3c836d4..6e7b9ab 100644
--- a/gnu/dist/gcc/config/m68k/m68k.md
+++ b/gnu/dist/gcc/config/m68k/m68k.md
@@ -7910,3 +7910,14 @@
        (unspec:XF [(match_operand:XF 1 "nonimmediate_operand" "fm")] 2))]
   "TARGET_68881 && flag_fast_math"
   "fcos%.x %1,%0")
+
+(define_insn "trampcachefix"
+  [(unspec_volatile [(const_int 1)] 0)
+   (use (mem:SI (match_operand:SI 0 "register_operand" "a")))
+   (clobber (match_dup 0))
+   (clobber (reg:SI 0))
+   (clobber (reg:SI 1))
+   (clobber (reg:SI 8))
+   (clobber (reg:SI 9))]
+  ""
+  "move%.l %0,a1; move%.l %#12,d1; move%.l %#0x80000004,d0; trap %#12")

I'm not sure all of the above is right.  I do not really understand
this stuff, so it's reasonably likely I've got something wrong; about
all I'm sure of is that it mostly works for me.  Improvements welcome.

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML                mouse%rodents-montreal.org@localhost
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B


Home | Main Index | Thread Index | Old Index