[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

workaround gcc-4 assembly constraint bug



I've been working on getting the ocaml extras package compiled on devel:
  https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=156238
There appears to be a bug in gcc4's inline assembly constraints:
  http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21291
that's keeping the compiler from selecting memory when we run out of
registers.  Here's the affected ocaml code from:
ocaml-3.08.3/otherlibs/num/bng_ia32.c:bngdigit bng_ia32_mult_sub_digit:

    asm("1: \n\t"
        "movl (%1), %%eax \n\t"
        "movl (%0), %4 \n\t"
        "mull %5\n\t"           /* edx:eax = d * next digit of b */
        "subl %%eax, %4 \n\t"   /* subtract eax from next digit of a */
        "adcl $0, %%edx \n\t"   /* accumulate carry in edx */
        "subl %3, %4 \n\t"      /* subtract out */
        "adcl $0, %%edx \n\t"   /* accumulate carry in edx */
        "movl %4, (%0) \n\t"    /* store next digit of result */
        "movl %%edx, %3 \n\t"   /* edx is next out */
        "leal 4(%0), %0 \n\t"
        "leal 4(%1), %1 \n\t"
        "decl %2 \n\t"
        "jnz 1b"
        : "+&r" (a), "+&r" (b), "+&rm" (blen), "+&rm" (out), "=&r" (tmp)
        : "rm" (d)
        : "eax", "edx");

I think that the solution should be to change the constraints to specify
memory only rather than a register with memory fallback:

        : "+&r" (a), "+&r" (b), "+m" (blen), "+m" (out), "=&r" (tmp)
        : "rm" (d)
        : "eax", "edx");

I'm not too familiar with gcc's constraints, though.  Would anyone with
a bit more experience be willing to tell me if that looks right or not?

Thanks,
Toshio
-- 

toshio \ 25th March, 1999:  Cold rain in Georgia.  Blustery blowing wind.
 @tiki  \ Freezing fingers and tired body.  Hiking on because the shelters
 -lounge \ are filled with other hikers.
 .com     \__________Life is miserable -- Life is grand!_______ GA->ME 1999

Attachment: signature.asc
Description: This is a digitally signed message part


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]