• Julian Seward's avatar
    [project @ 2001-12-05 17:35:12 by sewardj] · d11e681f
    Julian Seward authored
            Translate out PrimOps at the AbstractC level
    This is the first in what might be a series of changes intended
    to make GHC less dependent on its C back end.  The main change is
    to translate PrimOps into vanilla abstract C inside the compiler,
    rather than having to duplicate that work in each code generation
    route.  The main changes are:
    * A new type, MachOp, in compiler/absCSyn/MachOp.hs.  A MachOp
      is a primitive operation which we can reasonably expect the
      native code generators to implement.  The set is quite small
      and unlikely to change much, if at all.
    * Translations from PrimOps to MachOps, at the end of
      absCSyn/AbsCUtils.  This should perhaps be moved to a different
      module, but it is hard to see how to do this without creating
      a circular dep between it and AbsCUtils.
    * The x86 insn selector has been updated to track these changes.  The
      sparc insn selector remains to be done.
    As a result of this, it is possible to compile much more code via the
    NCG than before.  Almost all the Prelude can be compiled with it.
    Currently it does not know how to do 64-bit code generation.  Once
    this is fixed, the entire Prelude should be compilable that way.
    I also took the opportunity to clean up the NCG infrastructure.
    The old Stix data type has been split into StixStmt (statements)
    and StixExpr (now denoting values only).  This removes a class
    of impossible constructions and clarifies the NCG.
    Still to do, in no particular order:
    * String and literal lifting, currently done in the NCG at the top
      of nativeGen/MachCode, should be done in the AbstractC flattener,
      for the benefit of all targets.
    * Further cleaning up of Stix assignments.
    * Remove word-size dependency from Abstract C.  (should be easy).
    * Translate out MagicIds in the AbsC -> Stix translation, not
      in the Stix constant folder. (!)
    Testsuite failures caused by this:
    * memo001 - fails (segfaults) for some unknown reason now.
    * arith003 - wrong answer in gcdInt boundary cases.
    * arith011 - wrong answer for shifts >= word size.
    * cg044 - wrong answer for some FP boundary cases.
    These should be fixed, but I don't think they are mission-critical for