bignums and native back end

Stephen Weeks MLton@sourcelight.com
Wed, 8 Nov 2000 17:03:48 -0800 (PST)


> 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.