[MLton-devel] Fwd: C back end for MLton

Brad Lucier lucier@math.purdue.edu
Tue, 5 Nov 2002 11:37:22 -0500 (EST)


> 
> > > At some point (3.* ?) gcc became much more careful about inline asms.
> > > Perhaps you want to build gcc-3.2 (the latest release) and try it.
> > 
> > I just built gcc 3.2 on my machine and used it to recompile the MLton
> > runtime system without any warnings or errors.  Is it plausible that
> > something has changed between 3.2 and 3.3 to introduce the error
> > message?
> 
> I'll send it to the gcc mail list and see what comes back.

Here's what I got back from the gcc mail list:

>From aph@cambridge.redhat.com  Tue Nov  5 11:31:02 2002
Return-Path: <aph@cambridge.redhat.com>
Received: from executor.cambridge.redhat.com (dell-paw-3.cambridge.redhat.com [1
95.224.55.237])
        by newton.math.purdue.edu (8.10.1/8.10.1/PURDUE_MATH-4.0) with ESMTP id
gA5GV1903570
        for <lucier@math.purdue.edu>; Tue, 5 Nov 2002 11:31:01 -0500 (EST)
Received: from cuddles.cambridge.redhat.com (vpn50-32.rdu.redhat.com [172.16.50.
32])
        by executor.cambridge.redhat.com (Postfix) with ESMTP
        id 7D8FCABAF8; Tue,  5 Nov 2002 16:30:50 +0000 (GMT)
Received: (from aph@localhost)
        by cuddles.cambridge.redhat.com (8.11.6/8.11.0) id gA5GUpa11406;
        Tue, 5 Nov 2002 16:30:51 GMT
From: Andrew Haley <aph@redhat.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <15815.62011.480716.907166@cuddles.cambridge.redhat.com>
Date: Tue, 5 Nov 2002 16:30:51 +0000 (GMT)
To: Brad Lucier <lucier@math.purdue.edu>
Cc: gcc@gcc.gnu.org
Subject: help with different treatment of asms in 3.2 and 3.3?
In-Reply-To: <200211051557.gA5FvNl16890@banach.math.purdue.edu>
References: <200211051557.gA5FvNl16890@banach.math.purdue.edu>
X-Mailer: VM 6.75 under Emacs 21.2.1

Brad Lucier writes:
 > 3.2 compiles the following code without complaint (beyond the warnings)
 > and 3.3 rejects it.  The code is from the MLton ML compiler runtime; I
 > know nothing about inline asms; could someone offer some advice?
 >
 > int Int_quot(int numerator, int denominator) {
 >         register int eax asm("eax");
 >
 >         eax = numerator ;
 >
 >         __asm__ __volatile__ ("cdq\n        idivl %1"
 >                 :
 >                 : "r" (eax), "m" (denominator)
 >                 : "eax", "edx");
 >
 >         return eax;
 > }

Do this:

int Int_quot(int numerator, int denominator) {
  int eax;

  __asm__ __volatile__ ("cdq\n        idivl %2"
                        : "=a" (eax)
                        : "0" (numerator), "rm" (denominator)
                        : "edx");

  return eax;
}

Andrew.

>From matz@suse.de  Tue Nov  5 11:21:19 2002
Return-Path: <matz@suse.de>
Received: from Cantor.suse.de (ns.suse.de [213.95.15.193])
        by newton.math.purdue.edu (8.10.1/8.10.1/PURDUE_MATH-4.0) with ESMTP id
gA5GLI903087
        for <lucier@math.purdue.edu>; Tue, 5 Nov 2002 11:21:18 -0500 (EST)
Received: from Hermes.suse.de (Charybdis.suse.de [213.95.15.201])
        by Cantor.suse.de (Postfix) with ESMTP
        id 713611675A; Tue,  5 Nov 2002 17:21:17 +0100 (MET)
Date: Tue, 5 Nov 2002 17:21:17 +0100 (CET)
From: Michael Matz <matz@suse.de>
To: Brad Lucier <lucier@math.purdue.edu>
Cc: <gcc@gcc.gnu.org>
Subject: Re: help with different treatment of asms in 3.2 and 3.3?
In-Reply-To: <Pine.LNX.4.33.0211051712480.20702-100000@wotan.suse.de>
Message-ID: <Pine.LNX.4.33.0211051719500.20702-100000@wotan.suse.de>
MIME-Version: 1.0
Content-Type: TEXT/PLAIN; charset=US-ASCII

Hi again,

On Tue, 5 Nov 2002, Michael Matz wrote:

> GCC is right here.  You don't need (or want) to use register variables
> here.  A better way is:
>
> int Int_quot(int numerator, int denominator) {
>         __asm__ __volatile__ ("cdq\n        idivl %2"
>                 : "=a" (numerator)
>                 : "0" (numerator), "rm" (denominator)
>                 : "edx");
>
>         return numerator;
> }

I forgot to mention:  The use of asm is nonsensical here anyway.  A simple
  int Int_quot (int n, int d) { return n / d; }
produces exactly the same code.


Ciao,
Michael.



-------------------------------------------------------
This sf.net email is sponsored by: See the NEW Palm 
Tungsten T handheld. Power & Color in a compact size!
http://ads.sourceforge.net/cgi-bin/redirect.pl?palm0001en
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel