Remove type synonyms for CmmFormals, CmmActuals (and hinted versions). Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Port "Make array copy primops inline" and related patches to new codegen. The following patches were ported: d0faaa6 Fix segfault in array copy primops on 32-bit 18691d4 Make assignTemp_ less pessimistic 9c23f06 Make array copy primops inline Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
Merge in new code generator branch. This changes the new code generator to make use of the Hoopl package for dataflow analysis. Hoopl is a new boot package, and is maintained in a separate upstream git repository (as usual, GHC has its own lagging darcs mirror in http://darcs.haskell.org/packages/hoopl). During this merge I squashed recent history into one patch. I tried to rebase, but the history had some internal conflicts of its own which made rebase extremely confusing, so I gave up. The history I squashed was: - Update new codegen to work with latest Hoopl - Add some notes on new code gen to cmm-notes - Enable Hoopl lag package. - Add SPJ note to cmm-notes - Improve GC calls on new code generator. Work in this branch was done by: - Milan Straka <fox@ucw.cz> - John Dias <dias@cs.tufts.edu> - David Terei <davidterei@gmail.com> Edward Z. Yang <ezyang@mit.edu> merged in further changes from GHC HEAD and fixed a few bugs.
Remove unnecessary imports
New implementation of BLACKHOLEs This replaces the global blackhole_queue with a clever scheme that enables us to queue up blocked threads on the closure that they are blocked on, while still avoiding atomic instructions in the common case. Advantages: - gets rid of a locked global data structure and some tricky GC code (replacing it with some per-thread data structures and different tricky GC code :) - wakeups are more prompt: parallel/concurrent performance should benefit. I haven't seen anything dramatic in the parallel benchmarks so far, but a couple of threading benchmarks do improve a bit. - waking up a thread blocked on a blackhole is now O(1) (e.g. if it is the target of throwTo). - less sharing and better separation of Capabilities: communication is done with messages, the data structures are strictly owned by a Capability and cannot be modified except by sending messages. - this change will utlimately enable us to do more intelligent scheduling when threads block on each other. This is what started off the whole thing, but it isn't done yet (#3838). I'll be documenting all this on the wiki in due course.
* Refactor CLabel.RtsLabel to CLabel.CmmLabel The type of the CmmLabel ctor is now CmmLabel :: PackageId -> FastString -> CmmLabelInfo -> CLabel - When you construct a CmmLabel you have to explicitly say what package it is in. Many of these will just use rtsPackageId, but I've left it this way to remind people not to pretend labels are in the RTS package when they're not. - When parsing a Cmm file, labels that are not defined in the current file are assumed to be in the RTS package. Labels imported like import label are assumed to be in a generic "foreign" package, which is different from the current one. Labels imported like import "package-name" label are marked as coming from the named package. This last one is needed for the integer-gmp library as we want to refer to labels that are not in the same compilation unit, but are in the same non-rts package. This should help remove the nasty #ifdef __PIC__ stuff from integer-gmp/cbits/gmp-wrappers.cmm
Support for -fwarn-unused-do-bind and -fwarn-wrong-do-bind, as per #3263
Fix warnings in CgMonad
Merging in the new codegen branch This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
Replacing copyins and copyouts with data-movement instructions o Moved BlockId stuff to a new file to avoid module recursion o Defined stack areas for parameter-passing locations and spill slots o Part way through replacing copy in and copy out nodes - added movement instructions for stack pointer - added movement instructions for call and return parameters (but not with the proper calling conventions) o Inserting spills and reloads for proc points is now procpoint-aware (it was relying on the presence of a CopyIn node as a proxy for procpoint knowledge) o Changed ZipDataflow to expect AGraphs (instead of being polymorphic in the type of graph)
get freshBlockId out of ZipCfg and bury it in MkZipCfg where it belongs
a good deal of salutory renaming I've renamed a number of type and data constructors within Cmm so that the names used in the compiler may more closely reflect the C-- specification 2.1. I've done a bit of other renaming as well. Highlights: CmmFormal and CmmActual now bear a CmmKind (which for now is a MachHint as before) CmmFormals = [CmmFormal] and CmmActuals = [CmmActual] suitable changes have been made to both code and nonterminals in the Cmm parser (which is as yet untested) For reasons I don't understand, parts of the code generator use a sequence of 'formal parameters' with no C-- kinds. For these we now have the types type CmmFormalWithoutKind = LocalReg type CmmFormalsWithoutKinds = [CmmFormalWithoutKind] A great many appearances of (Tau, MachHint) have been simplified to the appropriate CmmFormal or CmmActual, though I'm sure there are more opportunities. Kind and its data constructors are now renamed to data GCKind = GCKindPtr | GCKindNonPtr to avoid confusion with the Kind used in the type checker and with CmmKind. Finally, in a somewhat unrelated bit (and in honor of Simon PJ, who thought of the name), the Whalley/Davidson 'transaction limit' is now called 'OptimizationFuel' with the net effect that there are no longer two unrelated uses of the abbreviation 'tx'.
massive changes to add a 'zipper' representation of C-- Changes too numerous to comment on, but here is some old history that I saved: Wed Aug 15 11:07:13 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * type synonyms made consistent with new Cmm types M ./compiler/nativeGen/MachInstrs.hs -2 +2 Mon Aug 20 19:22:14 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * pushing return info beyond cmm into codegen M ./compiler/codeGen/Bitmap.hs r3 M ./compiler/codeGen/CgBindery.lhs r3 M ./compiler/codeGen/CgCallConv.hs r3 M ./compiler/codeGen/CgCase.lhs r3 M ./compiler/codeGen/CgClosure.lhs r3 M ./compiler/codeGen/CgCon.lhs r3 M ./compiler/codeGen/CgExpr.lhs r3 M ./compiler/codeGen/CgForeignCall.hs -6 +7 r3 M ./compiler/codeGen/CgHeapery.lhs r3 M ./compiler/codeGen/CgHpc.hs +1 r3 M ./compiler/codeGen/CgInfoTbls.hs r3 M ./compiler/codeGen/CgLetNoEscape.lhs r3 M ./compiler/codeGen/CgMonad.lhs r3 M ./compiler/codeGen/CgParallel.hs r3 M ./compiler/codeGen/CgPrimOp.hs +3 r3 M ./compiler/codeGen/CgProf.hs r3 M ./compiler/codeGen/CgStackery.lhs r3 M ./compiler/codeGen/CgTailCall.lhs r3 M ./compiler/codeGen/CgTicky.hs r3 M ./compiler/codeGen/CgUtils.hs -1 +1 r3 M ./compiler/codeGen/ClosureInfo.lhs r3 M ./compiler/codeGen/CodeGen.lhs r3 M ./compiler/codeGen/SMRep.lhs r3 M ./compiler/nativeGen/AsmCodeGen.lhs -2 +2 r1 M ./compiler/nativeGen/MachCodeGen.hs -3 +3 r1 M ./compiler/nativeGen/MachInstrs.hs r1 M ./compiler/nativeGen/MachRegs.lhs r1 M ./compiler/nativeGen/NCGMonad.hs r1 M ./compiler/nativeGen/PositionIndependentCode.hs r1 M ./compiler/nativeGen/PprMach.hs r1 M ./compiler/nativeGen/RegAllocInfo.hs r1 M ./compiler/nativeGen/RegisterAlloc.hs r1 Mon Aug 20 20:54:41 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * put CmmReturnInfo into a CmmCall (and related types) M ./compiler/cmm/Cmm.hs -2 +1 r3 M ./compiler/cmm/CmmBrokenBlock.hs -13 +12 r1 M ./compiler/cmm/CmmCPS.hs -3 +3 M ./compiler/cmm/CmmCPSGen.hs -8 +6 r1 M ./compiler/cmm/CmmLint.hs -1 +1 M ./compiler/cmm/CmmLive.hs -1 +1 M ./compiler/cmm/CmmOpt.hs -3 +3 M ./compiler/cmm/CmmParse.y -6 +6 r3 M ./compiler/cmm/PprC.hs -3 +3 M ./compiler/cmm/PprCmm.hs -7 +4 r2 M ./compiler/codeGen/CgForeignCall.hs -7 +6 r2 M ./compiler/codeGen/CgHpc.hs -1 r1 M ./compiler/codeGen/CgPrimOp.hs -3 r1 M ./compiler/codeGen/CgUtils.hs -1 +1 r1 M ./compiler/nativeGen/AsmCodeGen.lhs -2 +2 M ./compiler/nativeGen/MachCodeGen.hs -3 +3 r1 Tue Aug 21 18:09:13 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * add call info in nativeGen M ./compiler/nativeGen/AsmCodeGen.lhs r1 M ./compiler/nativeGen/MachInstrs.hs r1 M ./compiler/nativeGen/MachRegs.lhs r1 M ./compiler/nativeGen/NCGMonad.hs r1 M ./compiler/nativeGen/PositionIndependentCode.hs r1 M ./compiler/nativeGen/PprMach.hs r1 M ./compiler/nativeGen/RegAllocInfo.hs r1 Wed Aug 22 16:41:58 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * ListGraph is now a newtype, not a synonym The resultant bookkeepping is unenviable, but the change greatly simplifies our ability to make Cmm things propertly Outputable for both list-graph and zipper-graph representations. M ./compiler/cmm/Cmm.hs -5 +3 M ./compiler/cmm/CmmCPS.hs -2 +2 M ./compiler/cmm/CmmCPSGen.hs -1 +1 M ./compiler/cmm/CmmContFlowOpt.hs -3 +3 M ./compiler/cmm/CmmCvt.hs -2 +2 M ./compiler/cmm/CmmInfo.hs -2 +3 M ./compiler/cmm/CmmLint.hs -1 +1 M ./compiler/cmm/CmmOpt.hs -2 +2 M ./compiler/cmm/PprC.hs -1 +1 M ./compiler/cmm/PprCmm.hs -5 +8 M ./compiler/cmm/PprCmmZ.hs -7 +1 M ./compiler/codeGen/CgMonad.lhs -1 +1 M ./compiler/nativeGen/AsmCodeGen.lhs -15 +15 M ./compiler/nativeGen/MachCodeGen.hs -2 +2 M ./compiler/nativeGen/PositionIndependentCode.hs -6 +6 M ./compiler/nativeGen/PprMach.hs -3 +2 M ./compiler/nativeGen/RegAllocColor.hs +1 M ./compiler/nativeGen/RegAllocLinear.hs -4 +5 M ./compiler/nativeGen/RegCoalesce.hs -6 +6 M ./compiler/nativeGen/RegLiveness.hs -12 +12 Thu Aug 23 13:44:49 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * diagnostic assistance in case fromJust fails M ./compiler/nativeGen/MachCodeGen.hs -2 +5 Thu Aug 23 14:07:28 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * give every block, even the first, a label With branch-chain elimination, the first block of a procedure might be the target of a branch. This actually happens to a dozen or more procedures in the run-time system. M ./compiler/nativeGen/PprMach.hs -8 +3 Fri Aug 24 17:27:04 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * clean up the code in PprMach M ./compiler/nativeGen/PprMach.hs -16 +14 Fri Aug 24 19:35:03 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * a bunch of impedance matching to get the compiler to build, plus * the plus is diagnostics for unreachable code, which required moving a lot of prettyprinting code M ./compiler/cmm/Cmm.hs -7 +5 M ./compiler/cmm/CmmCPSZ.hs -1 +1 M ./compiler/cmm/CmmCvt.hs -8 +8 M ./compiler/cmm/CmmParse.y -4 +3 M ./compiler/cmm/MkZipCfg.hs -19 +9 M ./compiler/cmm/PprCmmZ.hs -118 +4 M ./compiler/cmm/ZipCfg.hs -1 +13 M ./compiler/cmm/ZipCfgCmm.hs -10 +129 M ./compiler/main/HscMain.lhs -4 +4 M ./compiler/nativeGen/NCGMonad.hs -2 +2 M ./compiler/nativeGen/RegAllocInfo.hs -3 +3 Fri Aug 31 14:38:02 BST 2007 Norman Ramsey <nr@eecs.harvard.edu> * fix a warning about an import M ./compiler/nativeGen/RegAllocColor.hs -1 +1
change of representation for GenCmm, GenCmmTop, CmmProc The type parameter to a C-- procedure now represents a control-flow graph, not a single instruction. The newtype ListGraph preserves the current representation while enabling other representations and a sensible way of prettyprinting. Except for a few changes in the prettyprinter the new compiler binary should be bit-for-bit identical to the old.
Fix CodingStyle#Warnings URLs
Use OPTIONS rather than OPTIONS_GHC for pragmas Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modules
Ensure no statements after CmmReturn are emitted
Remove mapAccumL, mapAccumR, mapAccumB mapAccumL and mapAccumR are in Data.List now. mapAccumB is unused.
Added support for update frames to the CPS pass (This required a bit of refactoring of CmmInfo.)