Matthias Urlichs wrote:
> 
> Hi,
> 
> Bernd Paysan wrote:
> > The code to be moved is all in one function. Linkers don't rearrange code
> > within functions, compilers do that (and that's what GCC 3.3 apparently
> > does).
> 
> Umm, OK, that was misremembered on my part. 
> 
> I still think, though, that a code start-end table would work, e.g.
> 
> big_block_function():
>       [...]
> start_3117:
>       [ code to be copied ]
> end_3117:
>       asm("");
> start_3118: [...]
> 
> The empty asm statements should prevent GCC from moving code around at the end 
> of the blocks -- otherwise it might let all end_* labels point to the end of 
> the function.
> 
> That should be much more portable than assuming that start_3118 directly 
> follows start_3117.

I have now installed gcc-3.3 and done a few tests.

First of all, there is now a -fno-crossjumping option.

Unfortunately, it does not help with the problem at hand.  For some
reason, gcc-3.3 thinks its a good idea to arrange all the primitives
for the gforth engine in the reverse order wrt the source code.

I am currently thinking of the following test to check the validity
and completeness of the arrangements of a particular primitive: Take
all the labels we have, and sort them.  If the labels of one primitive
(we have three, one at the start, one near the end, and one at the end
just before a superfluous asm statement) are consecutive, without an
intervening label of another primitive, then we assume that it is ok,
otherwise it is not.  I fear this assumption will not be conservative
enough for gcc-3.4, but that's the best I can think of right now.  Any
other ideas?

If it is ok, we use the start and end labels as suggested by Matthias.

Other news: --enable-force-reg does not work on the 386 architecture:

engine.c: In function `engine':
engine.c:479: error: unable to find a register to spill in class `CREG'
engine.c:479: error: this is the insn:
(insn:HI 14121 18320 14122 1033 0x4050bb84 (parallel [
            (set (reg:SI 0 eax [2500])
                (const_int 0 [0x0]))
            (set (reg/f:SI 1 edx [2497])
                (plus:SI (ashift:SI (reg:SI 6 ebp [2499])
                        (const_int 2 [0x2]))
                    (reg/f:SI 1 edx [2497])))
            (set (mem:BLK (reg/f:SI 1 edx [2497]) [0 A8])
                (const_int 0 [0x0]))
            (use (reg:SI 0 eax [2498]))
            (use (reg:SI 6 ebp [2499]))
            (use (reg:SI 19 dirflag))
        ]) 456 {rep_stossi} (insn_list 14116 (insn_list 14117 (insn_list 14118 
(insn_list 14119 (nil)))))
    (expr_list:REG_DEAD (reg:SI 19 dirflag)
        (expr_list:REG_DEAD (reg:SI 0 eax [2498])
            (expr_list:REG_DEAD (reg:SI 6 ebp [2499])
                (expr_list:REG_UNUSED (reg:SI 0 eax [2500])
                    (expr_list:REG_UNUSED (reg/f:SI 1 edx [2497])
                        (nil)))))))

My guess is that the rep_stos wants ecx as count register, and we have
explicitly used it (this is probably FILL).  We might work around that
by de-inlining FILL or whatever word is the cause.

gcc-3.3 still does badly without explicit registers:

see + \ for gforth-fast
Code +  
( $804E719 )  mov     edi , dword ptr 4 [esp]  \ $8B $7C $24 $4 
( $804E71D )  add     ebp , # 4  \ $83 $C5 $4 
( $804E720 )  mov     edx , dword ptr [edi]  \ $8B $17 
( $804E722 )  mov     eax , dword ptr 4 [edi]  \ $8B $47 $4 
( $804E725 )  add     edi , # 4  \ $83 $C7 $4 
( $804E728 )  add     eax , edx  \ $1 $D0 
( $804E72A )  mov     dword ptr 4 [esp] , edi  \ $89 $7C $24 $4 
( $804E72E )  mov     dword ptr [edi] , eax  \ $89 $7 
( $804E730 )  mov     eax , dword ptr FC [ebp]  \ $8B $45 $FC 
( $804E733 )  jmp     eax  \ $FF $E0 
end-code

As for a workaround for gforth-0.6.1 on gcc-3.3, the simplest one I
can think of is to apply the following patch and then configure and
make again:

---
diff -r -u gforth-0.6.1/configure gforth-0.6.1-patched/configure
--- gforth-0.6.1/configure      Tue Mar 11 22:05:57 2003
+++ gforth-0.6.1-patched/configure      Thu Jul 31 20:11:25 2003
@@ -1357,7 +1357,7 @@
 
 
 #default setting that may be changed later:
-no_dynamic_default=0
+no_dynamic_default=1
 
 # Check whether --enable-force-reg or --disable-force-reg was given.
 if test "${enable_force_reg+set}" = set; then
diff -r -u gforth-0.6.1/configure.in gforth-0.6.1-patched/configure.in
--- gforth-0.6.1/configure.in   Tue Mar 11 22:05:47 2003
+++ gforth-0.6.1-patched/configure.in   Thu Jul 31 20:12:12 2003
@@ -30,7 +30,7 @@
 AC_CONFIG_HEADERS(engine/config.h)
 
 #default setting that may be changed later:
-no_dynamic_default=0
+no_dynamic_default=1
 
 AC_ARG_ENABLE(force-reg,
 [  --enable-force-reg    Use explicit register declarations if they appear in
Only in gforth-0.6.1-patched/: kernel.tags
Only in gforth-0.6.1-patched/: machpc.fs
---

- anton

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to