[project @ 2001-12-05 17:35:12 by sewardj]
authorsewardj <unknown>
Wed, 5 Dec 2001 17:35:15 +0000 (17:35 +0000)
committersewardj <unknown>
Wed, 5 Dec 2001 17:35:15 +0000 (17:35 +0000)
commitd11e681f219f6e38c2e5bc87adfb66f82de5ea65
treec85c4bf1beac4d7150c6a95c42839273b688f315
parentc967a54e648292f79d9480a95ff1e9e87323530c
[project @ 2001-12-05 17:35:12 by sewardj]
--------------------------------------------
        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
anyone.
33 files changed:
ghc/compiler/absCSyn/AbsCSyn.lhs
ghc/compiler/absCSyn/AbsCUtils.lhs
ghc/compiler/absCSyn/CLabel.lhs
ghc/compiler/absCSyn/MachOp.hs [new file with mode: 0644]
ghc/compiler/absCSyn/PprAbsC.lhs
ghc/compiler/codeGen/CgCase.lhs
ghc/compiler/main/ErrUtils.lhs
ghc/compiler/nativeGen/AbsCStixGen.lhs
ghc/compiler/nativeGen/AsmCodeGen.lhs
ghc/compiler/nativeGen/MachCode.lhs
ghc/compiler/nativeGen/MachMisc.lhs
ghc/compiler/nativeGen/MachRegs.lhs
ghc/compiler/nativeGen/PprMach.lhs
ghc/compiler/nativeGen/RegAllocInfo.lhs
ghc/compiler/nativeGen/Stix.lhs
ghc/compiler/nativeGen/StixInfo.lhs
ghc/compiler/nativeGen/StixInteger.lhs [deleted file]
ghc/compiler/nativeGen/StixMacro.lhs
ghc/compiler/nativeGen/StixPrim.hi-boot
ghc/compiler/nativeGen/StixPrim.hi-boot-5
ghc/compiler/nativeGen/StixPrim.lhs
ghc/compiler/prelude/PrimOp.lhs
ghc/compiler/prelude/PrimRep.lhs
ghc/compiler/prelude/primops.txt.pp
ghc/compiler/utils/Maybes.lhs
ghc/includes/PrimOps.h
ghc/includes/Stg.h
ghc/lib/std/PrelGHC.hi-boot.pp
ghc/lib/std/PrelInt.lhs
ghc/lib/std/PrelWord.lhs
ghc/lib/std/cbits/longlong.c
ghc/rts/Exception.hc
ghc/rts/PrimOps.hc