Re: bignums and native back end

Top Pagina
Bijlagen:
Bericht als e-mail
+ (text/plain)
Delete this message
Reply to this message
Auteur: Stephen Weeks
Datum:  
Aan: MLton
Onderwerp: Re: bignums and native back end

> I was thinking about what makes a constant `small'. I.e., is 100 small?
> Is 1000000? I remember a hack for translating constants, and I guess that
> you remember that.


      val minSmall: IntInf.t = IntInf.fromInt ~0x40000000
      val maxSmall: IntInf.t = IntInf.fromInt 0x3FFFFFFF


      fun isSmall (i: IntInf.t): bool =
     let open IntInf
     in minSmall <= i andalso i <= maxSmall
     end


This is a modified version of your code from a while back.

I've changed the internals of the compiler so that all IntInf constants are
represented as IntInfs internally. The smallness is only relevant to the
isSmall and areSmall primitives, and when translating to the backend, which
needs to emit the word format for small IntInfs. All of the usual constant
folding (+, -, *, ...) happens on IntInfs, both large and small.