summaryrefslogtreecommitdiff
path: root/ghc/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
...
* [project @ 2001-12-05 19:24:53 by sof]sof2001-12-051-1/+2
| | | | oops, changes not tested with a stage2 build
* [project @ 2001-12-05 17:35:12 by sewardj]sewardj2001-12-051-4/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------------- 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.
* [project @ 2001-12-05 00:06:32 by sof]sof2001-12-051-2/+10
| | | | reuse Panic.showGhcException
* [project @ 2001-11-27 00:18:59 by sof]sof2001-11-271-1/+6
| | | | track 5.03's change to PrelHandle.fillReadBuffer
* [project @ 2001-11-19 16:34:12 by simonpj]simonpj2001-11-192-11/+12
| | | | Tidy up imports
* [project @ 2001-11-08 12:56:00 by simonmar]simonmar2001-11-082-23/+32
| | | | | | | | | | | Updates to the native code generator following the changes to fix the large block allocation bug, and changes to use the new function-address cache in the register table to reduce code size. Also: I changed the pretty-printing machinery for assembly code to use Pretty rather than Outputable, since we don't make use of the styles and it should improve performance. Perhaps the same should be done for abstract C.
* [project @ 2001-10-31 12:26:17 by simonmar]simonmar2001-10-311-3/+8
| | | | Handle completely empty files without crashing in slurpFileExpandTabs.
* [project @ 2001-10-25 02:13:10 by sof]sof2001-10-252-6/+85
| | | | | | | | | | | | | | | | | | | | | | | | | - Pet peeve removal / code tidyup, replaced various sub-optimal uses of 'length' with something a bit better, i.e., replaced the following patterns * length as `cmpOp` length bs * length as `cmpOp` val -- incl. uses where val == 1 and val == 0 * {take,drop,splitAt} (length as) bs * length [ () | pat <- as ] with uses of misc Util functions. I'd be surprised if there's a noticeable reduction in running times as a result of these changes, but every little bit helps. [ The changes have been tested wrt testsuite/ - I'm seeing a couple of unexpected breakages coming from CorePrep, but I'm currently assuming that these are due to other recent changes. ] - compMan/CompManager.lhs: restored 4.08 compilability + some code cleanup. None of these changes are HEADworthy.
* [project @ 2001-10-23 22:25:46 by sof]sof2001-10-231-1/+1
| | | | | | | | | Deleted HsVersions.h #defines that were now past their use-by-dates; in particular, make the assumption that a post-Haskell 1.4 compiler is now used to compile ghc/compiler/ Hanging on to those FastString #defines is probably not worth it any longer, either, but I punted on making that (much bigger) change.
* [project @ 2001-10-01 13:28:40 by rrt]rrt2001-10-011-2/+0
| | | | Removed unused imports.
* [project @ 2001-09-26 15:12:33 by simonpj]simonpj2001-09-263-8/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------ Simon's big commit ------------------ This commit, which I don't think I can sensibly do piecemeal, consists of the things I've been doing recently, mainly directed at making Manuel, George, and Marcin happier with RULES. Reogranise the simplifier ~~~~~~~~~~~~~~~~~~~~~~~~~ 1. The simplifier's environment is now an explicit parameter. This makes it a bit easier to figure out where it is going. 2. Constructor arguments can now be arbitrary expressions, except when the application is the RHS of a let(rec). This makes it much easier to match rules like RULES "foo" f (h x, g y) = f' x y In the simplifier, it's Simplify.mkAtomicArgs that ANF-ises a constructor application where necessary. In the occurrence analyser, there's a new piece of context info (OccEncl) to say whether a constructor app is in a place where it should be in ANF. (Unless it knows this it'll give occurrence info which will inline the argument back into the constructor app.) 3. I'm experimenting with doing the "float-past big lambda" transformation in the full laziness pass, rather than mixed in with the simplifier (was tryRhsTyLam). 4. Arrange that case (coerce (S,T) (x,y)) of ... will simplify. Previous it didn't. A local change to CoreUtils.exprIsConApp_maybe. 5. Do a better job in CoreUtils.exprEtaExpandArity when there's an error function in one branch. Phase numbers, RULES, and INLINE pragmas ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1. Phase numbers decrease from N towards zero (instead of increasing). This makes it easier to add new earlier phases, which is what users want to do. 2. RULES get their own phase number, N, and are disabled in phases before N. e.g. {-# RULES "foo" [2] forall x y. f (x,y) = f' x y #-} Note the [2], which says "only active in phase 2 and later". 3. INLINE and NOINLINE pragmas have a phase number to. This is now treated in just the same way as the phase number on RULE; that is, the Id is not inlined in phases earlier than N. In phase N and later the Id *may* be inlined, and here is where INLINE and NOINLINE differ: INLNE makes the RHS look small, so as soon as it *may* be inlined it probably *will* be inlined. The syntax of the phase number on an INLINE/NOINLINE pragma has changed to be like the RULES case (i.e. in square brackets). This should also make sure you examine all such phase numbers; many will need to change now the numbering is reversed. Inlining Ids is no longer affected at all by whether the Id appears on the LHS of a rule. Now it's up to the programmer to put a suitable INLINE/NOINLINE pragma to stop it being inlined too early. Implementation notes: * A new data type, BasicTypes.Activation says when a rule or inline pragma is active. Functions isAlwaysActive, isNeverActive, isActive, do the obvious thing (all in BasicTypes). * Slight change in the SimplifierSwitch data type, which led to a lot of simplifier-specific code moving from CmdLineOpts to SimplMonad; a Good Thing. * The InlinePragma in the IdInfo of an Id is now simply an Activation saying when the Id can be inlined. (It used to be a rather bizarre pair of a Bool and a (Maybe Phase), so this is much much easier to understand.) * The simplifier has a "mode" environment switch, replacing the old black list. Unfortunately the data type decl has to be in CmdLineOpts, because it's an argument to the CoreDoSimplify switch data SimplifierMode = SimplGently | SimplPhase Int Here "gently" means "no rules, no inlining". All the crucial inlining decisions are now collected together in SimplMonad (preInlineUnconditionally, postInlineUnconditionally, activeInline, activeRule). Specialisation ~~~~~~~~~~~~~~ 1. Only dictionary *functions* are made INLINE, not dictionaries that have no parameters. (This inline-dictionary-function thing is Marcin's idea and I'm still not sure whether it's a good idea. But it's definitely a Bad Idea when there are no arguments.) 2. Be prepared to specialise an INLINE function: an easy fix in Specialise.lhs But there is still a problem, which is that the INLINE wins at the call site, so we don't use the specialised version anyway. I'm still unsure whether it makes sense to SPECIALISE something you want to INLINE. Random smaller things ~~~~~~~~~~~~~~~~~~~~~~ * builtinRules (there was only one, but may be more) in PrelRules are now incorporated. They were being ignored before... * OrdList.foldOL --> OrdList.foldrOL, OrdList.foldlOL * Some tidying up of the tidyOpenTyVar, tidyTyVar functions. I've forgotten exactly what!
* [project @ 2001-08-24 14:41:09 by simonmar]simonmar2001-08-241-4/+10
| | | | correct off-by-one error in hGetStringBuffer
* [project @ 2001-08-15 10:13:41 by qrczak]qrczak2001-08-151-1/+0
| | | | This one-line file must have been here by mistake.
* [project @ 2001-08-14 13:40:07 by sewardj]sewardj2001-08-142-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the story about POSIX headers in C compilation. Until now, all C code in the RTS and library cbits has by default been compiled with settings for POSIXness enabled, that is: #define _POSIX_SOURCE 1 #define _POSIX_C_SOURCE 199309L #define _ISOC9X_SOURCE If you wanted to negate this, you'd have to define NON_POSIX_SOURCE before including headers. This scheme has some bad effects: * It means that ccall-unfoldings exported via interfaces from a module compiled with -DNON_POSIX_SOURCE may not compile when imported into a module which does not -DNON_POSIX_SOURCE. * It overlaps with the feature tests we do with autoconf. * It seems to have caused borkage in the Solaris builds for some considerable period of time. The New Way is: * The default changes to not-being-in-Posix mode. * If you want to force a C file into Posix mode, #include as the **first** include the new file ghc/includes/PosixSource.h. Most of the RTS C sources have this include now. * NON_POSIX_SOURCE is almost totally expunged. Unfortunately we have to retain some vestiges of it in ghc/compiler so that modules compiled via C on Solaris using older compilers don't break.
* [project @ 2001-07-19 09:26:08 by simonpj]simonpj2001-07-191-1/+6
| | | | Move eqListBy to Util, and use it
* [project @ 2001-07-17 15:28:30 by simonpj]simonpj2001-07-171-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------- First cut at the demand analyser -------------------------------- This demand analyser is intended to replace the strictness/absence analyser, and the CPR analyser. This commit adds it to the compiler, but in an entirely non-invasive way. If you build the compiler without -DDEBUG, you won't get it at all. If you build the compiler with -DDEBUG, you'll get the demand analyser, but the existing strictness analyser etc are still there. All the demand analyser does is to compare its output with the existing stuff and report differences. There's no cross-module stuff for demand info yet. The strictness/demand info is put the IdInfo as newStrictnessInfo newDemandInfo Eventually we'll remove the old ones. Simon
* [project @ 2001-06-15 08:29:57 by simonpj]simonpj2001-06-151-0/+4
| | | | | | | | | | | | Some tidying up * Remove CmStaticInfo - GhciMode moves to HscTypes - The package stuff moves to new module main/Packages.lhs [put any package-related stuff in the new module] * Add Outputable.docToSDoc
* [project @ 2001-05-28 03:31:19 by sof]sof2001-05-281-11/+1
| | | | | | | | | | | | | | | | | Misc minor changes to integrate GHC a little bit better on Win32 platforms. Specifically, the commit does the following (assuming you've configured fptools/ with the option --enable-minimal-unix-deps on a mingw platform): * when GHC uses System.system, it expects an MSDOS command processor to interpret the command. This implies that 'normal' UNIX shell utils will no longer be used, but substituted with MSDOS equivalents. * the GHC backend relies on gcc and perl to handle .s/.hc/.o/.a files. GHC will now assume that these all live in one 'tool directory', making it easier to bundle these backend tools with GHC. The upshot of these changes is that it is now possible for the user not to have to install cygwin prior to installing GHC (as the upcoming ghc-win32 binary release will prove).
* [project @ 2001-05-23 16:47:09 by sewardj]sewardj2001-05-232-0/+3
| | | | | Add {-# OPTION -fvia-C #-} so that the compiler can compile itself in --make mode (yes, really!)
* [project @ 2001-05-21 14:03:05 by simonmar]simonmar2001-05-211-105/+10
| | | | | - remove support for GHC < 4.00 - fixed to work with GHC 5.01 (new I/O system)
* [project @ 2001-05-21 14:00:40 by simonmar]simonmar2001-05-211-108/+1
| | | | Remove support for GHC < 4.00
* [project @ 2001-05-19 20:20:56 by qrczak]qrczak2001-05-192-19/+55
| | | | | | | | | | | | | | | | | | | Make ghc compilable with itself after the implementation of handle IO changed, by changing an ugly mess of #ifdefs and low-level ghc-internals-specific kludges into a yet uglier mess with more #ifdefs and kludges. Wouldn't Haskell 98 implementation of a lexer be fast enough? :-) This won't compile with older versions of ghc-5.01. You may temporarily change 501 to 502 in #ifdefs here, or use an older ghc. The compiler still doesn't work at all when compiled with itself: it writes complete nonsense into .hc files. A remaining error: ghc/lib/std doesn't link PrelHandle_hsc.o into libHSstd.a. Function read_wrap is inline but for some reason it's needed for linking some programs (e.g. ghc itself).
* [project @ 2001-04-27 11:23:48 by simonmar]simonmar2001-04-271-1/+1
| | | | er.. wibble
* [project @ 2001-04-27 08:31:54 by simonmar]simonmar2001-04-271-2/+2
| | | | oops, can't use inCharRange here because of recursive dep.
* [project @ 2001-04-26 15:42:06 by sewardj]sewardj2001-04-261-0/+1
| | | | | | | Fix bug in which *primitive* string literals were being checked for Unicode-ness, even though they are not allowed to be; literals containing zero bytes were then unicodified, which crashes the bytecode generator.
* [project @ 2001-04-26 12:16:57 by simonmar]simonmar2001-04-261-3/+6
| | | | | Allow out-of-range character literals to appear in interface-file unfoldings. They occasionally pop up in Core.
* [project @ 2001-03-30 14:50:18 by rrt]rrt2001-03-301-57/+0
| | | | | | Nuke DirUtils, which used to reimplement getDirectoryContents for the benefit of older versions of GHC which implemented it incorrectly. It was already not used anywhere.
* [project @ 2001-03-28 16:45:35 by simonmar]simonmar2001-03-281-11/+28
| | | | | | | | | | | Clean up GHC's error reporting - the GhcException type has some more constructors: CmdLineError, ProgramError, and InstallationError. OtherError has gone. - most error messages should begin with "<location>:". When the error is on the command-line or in GHC itself, <location> is "ghc", for consistency with std Unix semantics.
* [project @ 2001-03-20 09:18:28 by simonmar]simonmar2001-03-201-3/+3
| | | | put the NUL terminator in the right place in stringToStringBuffer.
* [project @ 2001-03-01 15:59:51 by simonmar]simonmar2001-03-011-2/+3
| | | | use foldl' for addListToFM and delListFromFM
* [project @ 2001-03-01 15:58:28 by simonmar]simonmar2001-03-011-27/+13
| | | | add foldl', a strict foldl
* [project @ 2001-02-26 15:06:57 by simonmar]simonmar2001-02-261-1/+5
| | | | | | | | | | | | | | | | | Implement do-style bindings on the GHCi command line. The syntax for a command-line is exactly that of a do statement, with the following meanings: - `pat <- expr' performs expr, and binds each of the variables in pat. - `let pat = expr; ...' binds each of the variables in pat, doesn't do any evaluation - `expr' behaves as `it <- expr' if expr is IO-typed, or `let it = expr' followed by `print it' otherwise.
* [project @ 2001-02-23 12:25:05 by simonmar]simonmar2001-02-231-1/+3
| | | | print GHC's version in the panic message
* [project @ 2001-02-18 14:45:15 by qrczak]qrczak2001-02-181-14/+1
| | | | | | Recent Unicode and future ISO-10646 finally decided that the character code space ends at U+10FFFF. Let ghc follow the rules: maxBound::Char is now '\x10FFFF', etc.
* [project @ 2001-02-07 12:54:09 by sewardj]sewardj2001-02-071-4/+8
| | | | Try and fix the freeStringBuffer nightmare once and for all.
* [project @ 2001-01-31 15:38:02 by sewardj]sewardj2001-01-311-0/+5
| | | | | Give a clause for hPutFS on UnicodeStr. Apparently only needed so that -ddump-stix doesn't bomb when printing unicode strings.
* [project @ 2001-01-15 17:05:46 by sewardj]sewardj2001-01-151-4/+4
| | | | | More stuff to do with primop support in the interpreter. Also, track some changes to the libraries.
* [project @ 2001-01-12 07:44:50 by qrczak]qrczak2001-01-123-131/+25
| | | | | Adapt to the Addr/Ptr changes. Throw away mkFastSubStringFO, mkFastSubStringFO#, eqStrPrefixFO.
* [project @ 2000-12-13 11:30:12 by sewardj]sewardj2000-12-131-1/+4
| | | | Track renaming of newCharArray# to newByteArray#
* [project @ 2000-12-12 14:35:08 by simonmar]simonmar2000-12-121-8/+59
| | | | | Clean up the error handling a bit; the exception type is moved to Panic, and a new exception for panics has been added.
* [project @ 2000-12-11 16:42:26 by sewardj]sewardj2000-12-112-4/+1
| | | | head -> head bootability wibbles (rm disallowed OPTIONS pragmas)
* [project @ 2000-12-08 12:18:19 by rrt]rrt2000-12-081-0/+1
| | | | Add #include of ghc/includes/config.h so tests of TARGET_OS_mingw32 work.
* [project @ 2000-12-07 17:26:30 by simonmar]simonmar2000-12-071-2/+8
| | | | | | | | | | Figure out CafInfo during CoreTidy. This is the final piece of the puzzle in getting the final IdInfo from the Core2Core phases, rather than waiting for the STG code. This simplifies the SRT phase, in that it no longer has to have a complicated circular algorithm to figure out the CafInfo at the same time as the SRT layout.
* [project @ 2000-12-07 09:12:01 by simonpj]simonpj2000-12-071-15/+22
| | | | Add foldOL
* [project @ 2000-12-05 12:09:43 by sewardj]sewardj2000-12-051-3/+3
| | | | Partially fix driver breakage.
* [project @ 2000-11-20 16:28:29 by simonmar]simonmar2000-11-201-1/+1
| | | | | | Allow the root of the module tree to have a filename which is different from its module name. The argument to cmLoadModule is now a filename.
* [project @ 2000-11-20 14:48:52 by simonpj]simonpj2000-11-201-0/+4
| | | | | | | | | | When renaming, typechecking an expression from the user interface, we may suck in declarations from interface files (e.g. the Prelude). This commit takes account of that. To do so, I did some significant restructuring in TcModule, with consequential changes and tidy ups elsewhere in the type checker. I think there should be fewer lines in total than before.
* [project @ 2000-11-20 11:39:57 by sewardj]sewardj2000-11-201-3/+3
| | | | | | * (CompManager) recompile if in interactive mode and no old linkable exists * (HscMain) don't write interface files in interactive mode * (everywhere) switch arg order to unJust for PAP purposes
* [project @ 2000-11-17 16:53:27 by simonmar]simonmar2000-11-171-2/+25
| | | | | | | | | | | | | | | | Results of today's hacking: - We can now execute expressions from the GHCi prompt. However, a problem with the typechecker environment means that identifiers from outside the current module aren't resolved :-( - loading up a multi-module program in the interpreter seems to work. Interpreting is kinda slow (ok, very slow), but I'm hoping it'll get better when I compile the interpreter w/ optimisation. - :set sort of works - you can do ":set -dshow-passes", for example - lots of bugfixes, etc.
* [project @ 2000-11-14 17:41:04 by sewardj]sewardj2000-11-141-0/+5
| | | | Fixes to do with CM and module cycles. Also to do with OPTIONS pragmas.