1. 20 Dec, 2001 4 commits
    • sewardj's avatar
      [project @ 2001-12-20 16:12:09 by sewardj] · 791d890c
      sewardj authored
      Outline freeStablePtr, so NCG-generated code actually has something to call :)
      
      Also remove the presumably-defunct splitStablePtr.
      791d890c
    • sewardj's avatar
      [project @ 2001-12-20 15:20:37 by sewardj] · 0cc54eac
      sewardj authored
      Generate floating-point comparisons on x86 which deal with NaNs in what
      I assume is an IEEE854 compliant fashion.  For
         == >= > <= <
      if either arg is a NaN, produce False, and for
         /=
      if either arg is a NaN, produce True.
      
      This is the behaviour that gcc has, by default.
      
      Requires some ultramagical x86 code frags to be emitted.  A big comment
      in PprMach explains how it works.
      0cc54eac
    • sewardj's avatar
      [project @ 2001-12-20 15:16:13 by sewardj] · 5aaf7975
      sewardj authored
      nano-comment-wibble
      5aaf7975
    • simonpj's avatar
      [project @ 2001-12-20 11:19:05 by simonpj] · 91c750cb
      simonpj authored
      ---------------------------------------------
      	More type system extensions (for John Hughes)
      	---------------------------------------------
      
      1.  Added a brand-new extension that lets you derive ARBITRARY CLASSES
      for newtypes.  Thus
      
      	newtype Age = Age Int deriving( Eq, Ord, Shape, Ix )
      
      The idea is that the dictionary for the user-defined class Shape Age
      is *identical* to that for Shape Int, so there is really no deriving
      work to do.   This saves you writing the very tiresome instance decl:
      
      	instance Shape Age where
      	   shape_op1 (Age x) = shape_op1 x
      	   shape_op2 (Age x1) (Age x2) = shape_op2 x1 x2
      	   ...etc...
      
      It's more efficient, too, becuase the Shape Age dictionary really
      will be identical to the Shape Int dictionary.
      
      There's an exception for Read and Show, because the derived instance
      *isn't* the same.
      
      There is a complication where higher order stuff is involved.  Here is
      the example John gave:
      
         class StateMonad s m | m -> s where ...
      
         newtype Parser tok m a = Parser (State [tok] (Failure m) a)
      			  deriving( Monad, StateMonad )
      
      Then we want the derived instance decls to be
      
         instance Monad (State [tok] (Failure m)) => Monad (Parser tok m)
         instance StateMonad [tok] (State [tok] (Failure m))
      	 => StateMonad [tok] (Parser tok m)
      
      John is writing up manual entry for all of this, but this commit
      implements it.   I think.
      
      
      2.  Added -fallow-incoherent-instances, and documented it.  The idea
      is that sometimes GHC is over-protective about not committing to a
      particular instance, and the programmer may want to say "commit anyway".
      Here's the example:
      
          class Sat a where
            dict :: a
      
          data EqD a = EqD {eq :: a->a->Bool}
      
          instance Sat (EqD a) => Eq a where
            (==) = eq dict
      
          instance Sat (EqD Integer) where
            dict = EqD{eq=(==)}
      
          instance Eq a => Sat (EqD a) where
            dict = EqD{eq=(==)}
      
          class Collection c cxt | c -> cxt where
            empty :: Sat (cxt a) => c a
            single :: Sat (cxt a) => a -> c a
            union :: Sat (cxt a) => c a -> c a -> c a
            member :: Sat (cxt a) => a -> c a -> Bool
      
          instance Collection [] EqD where
            empty = []
            single x = [x]
            union = (++)
            member = elem
      
      It's an updated attempt to model "Restricted Data Types", if you
      remember my Haskell workshop paper. In the end, though, GHC rejects
      the program (even with fallow-overlapping-instances and
      fallow-undecideable-instances), because there's more than one way to
      construct the Eq instance needed by elem.
      
      Yet all the ways are equivalent! So GHC is being a bit over-protective
      of me, really: I know what I'm doing and I would LIKE it to pick an
      arbitrary one. Maybe a flag fallow-incoherent-instances would be a
      useful thing to add?
      91c750cb
  2. 19 Dec, 2001 3 commits
  3. 18 Dec, 2001 8 commits
  4. 17 Dec, 2001 6 commits
  5. 15 Dec, 2001 1 commit
  6. 14 Dec, 2001 5 commits
    • simonpj's avatar
      [project @ 2001-12-14 17:24:19 by simonpj] · 145958bf
      simonpj authored
      Add a rule for foldr k z [x]
      145958bf
    • simonpj's avatar
      [project @ 2001-12-14 17:24:03 by simonpj] · 5f087cf4
      simonpj authored
      -------------------------
      	Performance tuning things
      	-------------------------
      
      I did some nofib tests, and fixed a number of performance problems.
      
      1.  Things were getting floated to top level, and that prevented
      some useful fusion happening.
      	y = build g
      	x = foldr k z y
      
      Fixed by arranging that we only get really keen on floating to top
      level in the second run of the let-float-out pass.
      
      
      2.  Some fettling up on the let-floater itself.  It had some parameters
      that weren't even being used!  And it was stupidly floating things out
      of a one-shot lambda, and the float-in pass didn't float them back in.
      I think I fixed both of these problems.
      
      
      3.  The eta-reducer was not eta-reducing (/\a -> g a) to g.  In general
      it has to be a bit careful because "seq" means that (\x -> g x) is
      not in general the same as g ---- but it *is* the same for a type lambda.
      
      This turned out to be important in rule matching, where the foldr/build
      rule was not firing because the LHS of the rule looked like
      	foldr k z (/\ a -> g a) = ...
      which never matched!  Result, no fusion to speak of!
      
      
      4.  The simplifier was a bit too gung ho about inlining used-once
      things bound to constructor args.  The comment is with Simplify.simplNonRecX.
      5f087cf4
    • sewardj's avatar
      [project @ 2001-12-14 16:57:36 by sewardj] · 5a387d82
      sewardj authored
      Sparc NCG changes to track recent mulIntC# changes.  The Prelude
      can now finally be compiled with the sparc NCG.
      
      Also (incidentally) emit sparc integer multiply insns directly
      rather than calling a helper routine.  Most sparcs should implement
      them by now :)
      5a387d82
    • sewardj's avatar
      [project @ 2001-12-14 15:26:14 by sewardj] · 7dee9e10
      sewardj authored
      Get rid of multiple-result MachOps (MO_NatS_AddC, MO_NatS_SubC,
      MO_NatS_MulC) which implement {add,sub,mul}IntC#.  Supporting gunk
      in the NCG disappears as a result.
      
      Instead:
      
      * {add,sub}IntC# are translated out during abstract C simplification,
        turning into the xor-xor-invert-and-shift sequence previously defined
        in PrimOps.h.
      
      * mulIntC# is more difficult to get rid of portably.  Instead we have
        a new single-result PrimOp, mulIntMayOflo, with corresponding MachOp
        MO_NatS_MulMayOflo.  This tells you whether a W x W -> W signed
        multiply might overflow, where W is the word size.  When W=32, is
        implemented by computing a 2W-long result.  When W=64, we use the
        previous approximation.
      
      PrelNum.lhs' implementation of timesInteger changes slightly, to use
      the new PrimOp.
      7dee9e10
    • simonmar's avatar
      [project @ 2001-12-14 12:05:15 by simonmar] · 8cb83b66
      simonmar authored
      shiftR# --> shiftRL#
      8cb83b66
  7. 13 Dec, 2001 9 commits
  8. 12 Dec, 2001 4 commits
    • sewardj's avatar
      [project @ 2001-12-12 18:12:45 by sewardj] · 0b447a84
      sewardj authored
      Make the sparc native code generator work again after recent
      primop hackery.
      
      * Track the change from PrimOp to MachOp at the Stix level.
      
      * Teach the sparc insn selector how to generate 64-bit code.
      
      * Fix various bogons in sparc {Int,Double,Float} <-> {Int,Double,Float}
        conversions which only happened to generate correct code by
        accident, so far.
      
      * Synthesise BaseReg from &MainCapability.r on archs which do not
        have BaseReg in a regiser (eg sparc :)
      
      At the moment {add,sub,mul}Int# are not implemented.  To be fixed.
      0b447a84
    • simonmar's avatar
      [project @ 2001-12-12 15:59:33 by simonmar] · 7738ad97
      simonmar authored
      Include the CCS ID in the heap profile, so you can find the full CCS
      description in <foo>.prof or the XML profile output.
      7738ad97
    • simonmar's avatar
      [project @ 2001-12-12 15:13:20 by simonmar] · 57c676e4
      simonmar authored
      Include the cost-centre-stack ID in the time profiling output.
      57c676e4
    • simonmar's avatar
      [project @ 2001-12-12 15:01:25 by simonmar] · 8098d689
      simonmar authored
      Fix a couple of assertions.
      8098d689