summaryrefslogtreecommitdiff
path: root/compiler/codeGen/StgCmmLayout.hs
Commit message (Collapse)AuthorAgeFilesLines
...
* Pass DynFlags down to wordWidthIan Lynagh2012-09-121-2/+2
|
* Pass DynFlags down to bWordIan Lynagh2012-09-121-20/+17
| | | | | | I've switched to passing DynFlags rather than Platform, as (a) it's simpler to not have to extract targetPlatform in so many places, and (b) it may be useful to have DynFlags around in future.
* Pass Platform down to halfWordWidthIan Lynagh2012-09-101-6/+8
| | | | We don't actually use it yet
* Add "Unregisterised" as a field in the settings fileIan Lynagh2012-08-071-7/+9
| | | | | | To explicitly choose whether you want an unregisterised build you now need to use the "--enable-unregisterised"/"--disable-unregisterised" configure flags.
* Make tablesNextToCode "dynamic"Ian Lynagh2012-08-061-7/+7
| | | | | This is a bit odd by itself, but it's a stepping stone on the way to putting "target unregisterised" into the settings file.
* Explicitly share some return continuationsSimon Marlow2012-08-021-12/+19
| | | | | | | Instead of relying on common-block-elimination to share return continuations in the common case (case-alternative heap checks) we do it explicitly. This isn't hard to do, is more robust, and saves some compilation time. Full commentary in Note [sharing continuations].
* New codegen: do not split proc-points when using the NCGSimon Marlow2012-07-301-1/+1
| | | | | | | | | Proc-point splitting is only required by backends that do not support having proc-points within a code block (that is, everything except the native backend, i.e. LLVM and C). Not doing proc-point splitting saves some compilation time, and might produce slightly better code in some cases.
* Make -fscc-profiling a dynamic flagIan Lynagh2012-07-241-57/+64
| | | | All the flags that 'ways' imply are now dynamic
* Track liveness of GlobalRegs in the new code generatorSimon Marlow2012-07-091-12/+17
| | | | | | This gives the register allocator access to R1.., F1.., D1.. etc. for the new code generator, and is a cheap way to eliminate all the extra "x = R1" assignments that we get from copyIn.
* Merge remote-tracking branch 'origin/master' into newcgSimon Marlow2012-07-041-16/+11
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * origin/master: (756 commits) don't crash if argv[0] == NULL (#7037) -package P was loading all versions of P in GHCi (#7030) Add a Note, copying text from #2437 improve the --help docs a bit (#7008) Copy Data.HashTable's hashString into our Util module Build fix Build fixes Parse error: suggest brackets and indentation. Don't build the ghc DLL on Windows; works around trac #5987 On Windows, detect if DLLs have too many symbols; trac #5987 Add some more Integer rules; fixes #6111 Fix PA dfun construction with silent superclass args Add silent superclass parameters to the vectoriser Add silent superclass parameters (again) Mention Generic1 in the user's guide Make the GHC API a little more powerful. tweak llvm version warning message New version of the patch for #5461. Fix Word64ToInteger conversion rule. Implemented feature request on reconfigurable pretty-printing in GHCi (#5461) ... Conflicts: compiler/basicTypes/UniqSupply.lhs compiler/cmm/CmmBuildInfoTables.hs compiler/cmm/CmmLint.hs compiler/cmm/CmmOpt.hs compiler/cmm/CmmPipeline.hs compiler/cmm/CmmStackLayout.hs compiler/cmm/MkGraph.hs compiler/cmm/OldPprCmm.hs compiler/codeGen/CodeGen.lhs compiler/codeGen/StgCmm.hs compiler/codeGen/StgCmmBind.hs compiler/codeGen/StgCmmLayout.hs compiler/codeGen/StgCmmUtils.hs compiler/main/CodeOutput.lhs compiler/main/HscMain.hs compiler/nativeGen/AsmCodeGen.lhs compiler/simplStg/SimplStg.lhs
| * Remove some unnecessary platform argumentsIan Lynagh2012-06-131-4/+2
| |
| * Remove PlatformOutputableIan Lynagh2012-06-131-6/+3
| | | | | | | | | | We can now get the Platform from the DynFlags inside an SDoc, so we no longer need to pass the Platform in.
| * Pass DynFlags down to showSDocIan Lynagh2012-06-121-3/+3
| |
| * Support code generation for unboxed-tuple function argumentsunboxed-tuple-arguments2Max Bolingbroke2012-05-151-4/+4
| | | | | | | | | | | | | | | | | | | | | | This is done by a 'unarisation' pre-pass at the STG level which translates away all (live) binders binding something of unboxed tuple type. This has the following knock-on effects: * The subkind hierarchy is vastly simplified (no UbxTupleKind or ArgKind) * Various relaxed type checks in typechecker, 'foreign import prim' etc * All case binders may be live at the Core level
* | Lower safe foreign calls in the new CmmLayoutStackSimon Marlow2012-03-061-67/+75
| | | | | | | | | | | | | | | | We also generate much better code for safe foreign calls (and maybe also unsafe foreign calls) than previously. See the two new Notes: Note [lower safe foreign calls] Note [safe foreign call convention]
* | New stack layout algorithmSimon Marlow2012-02-081-24/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | Also: - improvements to code generation: push slow-call continuations on the stack instead of generating explicit continuations - remove unused CmmInfo wrapper type (replace with CmmInfoTable) - squash Area and AreaId together, remove now-unused RegSlot - comment out old unused stack-allocation code that no longer compiles after removal of RegSlot
* | Different implementation of MkGraphSimon Marlow2012-01-251-5/+5
|/
* Use -fwarn-tabs when validatingIan Lynagh2011-11-041-0/+7
| | | | | We only use it for "compiler" sources, i.e. not for libraries. Many modules have a -fno-warn-tabs kludge for now.
* More CPP removal: pprDynamicLinkerAsmLabel in CLabelIan Lynagh2011-10-021-7/+14
| | | | And some knock-on changes
* refactoring and fixing the stage 2 compilationSimon Marlow2011-08-251-1/+1
|
* Refactoring: reduce usage of mkConInfo, with a view to killing itSimon Marlow2011-08-251-18/+10
|
* avoid record selector error on closureProfSimon Marlow2011-08-251-1/+1
|
* rename LRep to ArgRepSimon Marlow2011-08-251-37/+37
|
* More refactoring (CgRep)Simon Peyton Jones2011-08-251-2/+4
| | | | | | * Move CgRep (private to old codgen) from SMRep to ClosureInfo * Avoid using CgRep in new codegen * Move SMRep and Bitmap from codeGen/ to cmm/
* Snapshot of codegen refactoring to share with simonpjSimon Marlow2011-08-251-147/+18
|
* Put the info CLabel in CmmInfoTable rather than a localness flag, tidy up ↵Max Bolingbroke2011-07-281-4/+2
| | | | some info<->entry conversions
* Don't export the _info symbol for the data constructor worker bindingsMax Bolingbroke2011-07-071-1/+1
| | | | | | | This is safe because GHC never generates a fast call to a data constructor worker: if the call is seen statically it will be eta-expanded and the allocation of the data will be inlined. We still need to export the _closure in case the constructor is used in an unapplied fashion.
* Merge in new code generator branch.Simon Marlow2011-01-241-28/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | 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 unncessary fromIntegral callssimonpj@microsoft.com2010-11-161-1/+1
|
* Fixed calling convention for unboxed tuplesdias@cs.tufts.edu2009-09-181-5/+6
| | | | | | Apparently, the arguments should be sorted by pointerhood. While we're at it, I rewrote the code that assigns registers and stack space to function call and return parameters.
* Merge RtsLabelInfo.Rts* with RtsLabelInfo.Rts*FSBen.Lippmeier@anu.edu.au2009-10-181-18/+18
|
* RTS tidyup sweep, first phaseSimon Marlow2009-08-021-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first phase of this tidyup is focussed on the header files, and in particular making sure we are exposinng publicly exactly what we need to, and no more. - Rts.h now includes everything that the RTS exposes publicly, rather than a random subset of it. - Most of the public header files have moved into subdirectories, and many of them have been renamed. But clients should not need to include any of the other headers directly, just #include the main public headers: Rts.h, HsFFI.h, RtsAPI.h. - All the headers needed for via-C compilation have moved into the stg subdirectory, which is self-contained. Most of the headers for the rest of the RTS APIs have moved into the rts subdirectory. - I left MachDeps.h where it is, because it is so widely used in Haskell code. - I left a deprecated stub for RtsFlags.h in place. The flag structures are now exposed by Rts.h. - Various internal APIs are no longer exposed by public header files. - Various bits of dead code and declarations have been removed - More gcc warnings are turned on, and the RTS code is more warning-clean. - More source files #include "PosixSource.h", and hence only use standard POSIX (1003.1c-1995) interfaces. There is a lot more tidying up still to do, this is just the first pass. I also intend to standardise the names for external RTS APIs (e.g use the rts_ prefix consistently), and declare the internal APIs as hidden for shared libraries.
* Remove unused importsIan Lynagh2009-07-071-1/+0
|
* Debugging by Sesame Street:dias@eecs.tufts.edu2009-04-031-1/+1
| | | | | | | | | | | | | | | | One of these things is not like the others: stdPattern :: [LRep] -> Maybe StgHalfWord stdPattern reps = case reps of [] -> Just ARG_NONE -- just void args, probably [N] -> Just ARG_N [P] -> Just ARG_N [F] -> Just ARG_F [D] -> Just ARG_D [L] -> Just ARG_L Today's debugging session was brought to you by the letter P.
* Better handling of node parameter in calling conventionsdias@eecs.tufts.edu2009-03-251-3/+7
| | | | | | - Previously, the node was taken as a parameter, then ignored, for static closures. Goofy. Now, the vestigial node parameters are gone.
* Calls with and without passing node arguments more clearly separateddias@eecs.tufts.edu2009-03-231-2/+2
|
* Another small step: call and return conventions specified separately when ↵dias@eecs.tufts.edu2009-03-231-6/+6
| | | | making calls
* Small step toward call-conv improvement: separate out calls and returnsdias@eecs.tufts.edu2009-03-231-2/+2
|
* A few bug fixes; some improvements spurred by paper writingdias@eecs.harvard.edu2009-03-031-2/+2
| | | | | | | | | | | | Among others: - Fixed Stg->C-- translation of let-no-escapes -- it's important to use the right continuation... - Fixed infinite recursion in X86 backend (shortcutJump mishandled infinite loops) - Fixed yet another wrong calling convention -- primops take args only in vanilla regs, but they may return results on the stack! - Removed StackInfo from LGraph and Block -- now in LastCall and CmmZ - Updated avail-variable and liveness code
* drop some debugging traces and use only one flag for new codegendias@eecs.harvard.edu2008-11-261-3/+1
|
* Removed warnings, made Haddock happy, added examples in documentationdias@eecs.harvard.edu2008-10-171-3/+0
| | | | | The interesting examples talk about our story with heap checks in case alternatives and our story with the case scrutinee as a Boolean.
* Don't adjust hp up when the case scrutinee won't allocatedias@eecs.harvard.edu2008-10-141-12/+16
| | | | | | | | If the case scrutinee can't allocate, we don't need to do a heap check in the case alternatives. (A previous patch got that right.) In that case, we had better not adjust the heap pointer to recover unused stack space before evaluating the scrutinee -- because we aren't going to reallocate for the case alternative.
* Big collection of patches for the new codegen branch.dias@eecs.harvard.edu2008-10-131-33/+79
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | o Fixed bug that emitted the copy-in code for closure entry in the wrong place -- at the initialization of the closure. o Refactored some of the closure entry code. o Added code to check that no LocalRegs are live-in to a procedure -- trip up some buggy programs earlier o Fixed environment bindings for thunks -- we weren't (re)binding the free variables in a thunk o Fixed a bug in proc-point splitting that dropped some updates to the entry block in a procedure. o Fixed improper calls to code that generates CmmLit's for strings o New invariant on cg_loc in CgIdInfo: the expression is always tagged o Code to load free vars on entry to a thunk was (wrongly) placed before the heap check. o Some of the StgCmm code was redundantly passing around Id's along with CgIdInfo's; no more. o Initialize the LocalReg's that point to a closure before allocating and initializing the closure itself -- otherwise, we have problems with recursive closure bindings o BlockEnv and BlockSet types are now abstract. o Update frames: - push arguments in Old call area - keep track of the return sp in the FCode monad - keep the return sp in every call, tail call, and return (because it might be different at different call sites, e.g. tail calls to the gc after a heap check are performed before pushing the update frame) - set the sp appropriately on returns and tail calls o Reduce call, tail call, and return to a single LastCall node o Added slow entry code, using different calling conventions on entry and tail call o More fixes to the calling convention code. The tricky stuff is all about the closure environment: it must be passed in R1, but in non-closures, there is no such argument, so we can't treat all arguments the same way: the closure environment is special. Maybe the right step forward would be to define a different calling convention for closure arguments. o Let-no-escapes need to be emitted out-of-line -- otherwise, we drop code. o Respect RTS requirement of word alignment for pointers My stack allocation can pack sub-word values into a single word on the stack, but it wasn't requiring word-alignment for pointers. It does now, by word-aligning both pointer registers and call areas. o CmmLint was over-aggresively ruling out non-word-aligned memory references, which may be kosher now that we can spill small values into a single word. o Wrong label order on a conditional branch when compiling switches. o void args weren't dropped in many cases. To help prevent this kind of mistake, I defined a NonVoid wrapper, which I'm applying only to Id's for now, although there are probably other good candidates. o A little code refactoring: separate modules for procpoint analysis splitting, stack layout, and building infotables. o Stack limit check: insert along with the heap limit check, using a symbolic constant (a special CmmLit), then replace it when the stack layout is known. o Removed last node: MidAddToContext o Adding block id as a literal: means that the lowering of the calling conventions no longer has to produce labels early, which was inhibiting common-block elimination. Will also make it easier for the non-procpoint-splitting path. o Info tables: don't try to describe the update frame! o Over aggressive use of NonVoid!!!! Don't drop the non-void args before setting the type of the closure!!! o Sanity checking: Added a pass to stub dead dead slots on the stack (only ~10 lines with the dataflow framework) o More sanity checking: Check that incoming pointer arguments are non-stubbed. Note: these checks are still subject to dead-code removal, but they should still be quite helpful. o Better sanity checking: why stop at function arguments? Instead, in mkAssign, check that _any_ assignment to a pointer type is non-null -- the sooner the crash, the easier it is to debug. Still need to add the debugging flag to turn these checks on explicitly. o Fixed yet another calling convention bug. This time, the calls to the GC were wrong. I've added a new convention for GC calls and invoked it where appropriate. We should really straighten out the calling convention stuff: some of the code (and documentation) is spread across the compiler, and there's some magical use of the node register that should really be handled (not avoided) by calling conventions. o Switch bug: the arms in mkCmmLitSwitch weren't returning to a single join point. o Environment shadowing problem in Stg->Cmm: When a closure f is bound at the top-level, we should not bind f to the node register on entry to the closure. Why? Because if the body of f contains a let-bound closure g that refers to f, we want to make sure that it refers to the static closure for f. Normally, this would all be fine, because when we compile a closure, we rebind free variables in the environment. But f doesn't look like a free variable because it's a static value. So, the binding for f remains in the environment when we compile g, inconveniently referring to the wrong thing. Now, I bind the variable in the local environment only if the closure is not bound at the top level. It's still okay to make assumptions about the node holding the closure environment; we just won't find the binding in the environment, so code that names the closure will now directly get the label of the static closure, not the node register holding a pointer to the static closure. o Don't generate bogus Cmm code containing SRTs during the STG -> Cmm pass! The tables made reference to some labels that don't exist when we compute and generate the tables in the back end. o Safe foreign calls need some special treatment (at least until we have the integrated codegen). In particular: o they need info tables o they are not procpoints -- the successor had better be in the same procedure o we cannot (yet) implement the calling conventions early, which means we have to carry the calling-conv info all the way to the end o We weren't following the old convention when registering a module. Now, we use update frames to push any new modules that have to be registered and enter the youngest one on the stack. We also use the update frame machinery to specify that the return should pop the return address off the stack. o At each safe foreign call, an infotable must be at the bottom of the stack, and the TSO->sp must point to it. o More problems with void args in a direct call to a function: We were checking the args (minus voids) to check whether the call was saturated, which caused problems when the function really wasn't saturated because it took an extra void argument. o Forgot to distinguish integer != from floating != during Stg->Cmm o Updating slotEnv and areaMap to include safe foreign calls The dataflow analyses that produce the slotEnv and areaMap give results for each basic block, but we also need the results for a safe foreign call, which is a middle node. After running the dataflow analysis, we have another pass that updates the results to includ any safe foreign calls. o Added a static flag for the debugging technique that inserts instructions to stub dead slots on the stack and crashes when a stubbed value is loaded into a pointer-typed LocalReg. o C back end expects to see return continuations before their call sites. Sorted the flowgraphs appropriately after splitting. o PrimOp calling conventions are special -- unlimited registers, no stack Yet another calling convention... o More void value problems: if the RHS of a case arm is a void-typed variable, don't try to return it. o When calling some primOp, they may allocate memory; if so, we need to do a heap check when we return from the call.
* Merging in the new codegen branchdias@eecs.harvard.edu2008-08-141-0/+618
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