summaryrefslogtreecommitdiff
path: root/compiler/utils
Commit message (Collapse)AuthorAgeFilesLines
* Merge branch 'master' into late-lam-liftNicolas Frisby2014-08-1927-161/+211
|\ | | | | | | | | | | | | | | | | Silly conflicts because of new flags -- not sure how best to resolve/avoid this. git is requiring my commit to mention 'submodule' for some reason? Conflicts: compiler/main/DynFlags.hs
| * build: require GHC 7.6 for bootstrappingAustin Seipp2014-08-192-30/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Per the usual standards, a build of GHC is only compileable by the last two releases (e.g. 7.8 only by 7.4 and 7.6). To make sure we don't get suckered into supporting older compilers, let's remove this support now. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: Try to bootstrap with GHC 7.4, watch it fail. Bootstrap with 7.6 or better, and everything works. Reviewers: hvr Reviewed By: hvr Subscribers: simonmar, ezyang, carter Differential Revision: https://phabricator.haskell.org/D167
| * Give the Unique generated by strings a tag '$', fixes #9413.Edward Z. Yang2014-08-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, we allocated uniques for strings starting at zero, which means the tag bits in the unique are zero, which means that printing a Unique for a string will start with a null byte. This is bad. So instead, start our numbering with the tag byte as '$' (as in $tring). This is hard coded so we don't have to worry about the optimizer reducing the expression. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: hvr, simonmar, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D123 GHC Trac Issues: #9413
| * Add Output instance for OrdListSimon Peyton Jones2014-08-071-0/+4
| |
| * Package keys (for linking/type equality) separated from package IDs.Edward Z. Yang2014-08-051-13/+48
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch set makes us no longer assume that a package key is a human readable string, leaving Cabal free to "do whatever it wants" to allocate keys; we'll look up the PackageId in the database to display to the user. This also means we have a new level of qualifier decisions to make at the package level, and rewriting some Safe Haskell error reporting code to DTRT. Additionally, we adjust the build system to use a new ghc-cabal output Make variable PACKAGE_KEY to determine library names and other things, rather than concatenating PACKAGE/VERSION as before. Adds a new `-this-package-key` flag to subsume the old, erroneously named `-package-name` flag, and `-package-key` to select packages by package key. RFC: The md5 hashes are pretty tough on the eye, as far as the file system is concerned :( ToDo: safePkg01 test had its output updated, but the fix is not really right: the rest of the dependencies are truncated due to the fact the we're only grepping a single line, but ghc-pkg is wrapping its output. ToDo: In a later commit, update all submodules to stop using -package-name and use -this-package-key. For now, we don't do it to avoid submodule explosion. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D80
| * Implement OVERLAPPING and OVERLAPPABLE pragmas (see #9242)Iavor S. Diatchki2014-07-271-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This also removes the short-lived NO_OVERLAP pragama, and renames OVERLAP to OVERLAPS. An instance may be annotated with one of 4 pragams, to control its interaction with other overlapping instances: * OVERLAPPABLE: this instance is ignored if a more specific candidate exists * OVERLAPPING: this instance is preferred over more general candidates * OVERLAPS: both OVERLAPPING and OVERLAPPABLE (i.e., the previous GHC behavior). When compiling with -XOverlappingInstances, all instance are OVERLAPS. * INCOHERENT: same as before (see manual for details). When compiling with -XIncoherentInstances, all instances are INCOHERENT.
| * utils: detabify/dewhitespace DigraphAustin Seipp2014-07-201-43/+36
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Fix ghci tab completion of duplicate identifiers.Shachaf Ben-Kiki2014-07-131-1/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Currently, if the same identifier is imported via multiple modules, ghci shows multiple completions for it. Use the nub of the completions instead so that it only shows up once. Signed-off-by: Shachaf Ben-Kiki <shachaf@gmail.com> Test Plan: by hand Reviewers: simonmar, austin, hvr Reviewed By: austin, hvr Subscribers: hvr, simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D58
| * Factor-out the `OverlapMode` from `OverlapFlag`.Iavor S. Diatchki2014-06-291-9/+17
| | | | | | | | | | | | | | | | This seems a bit cleaner conceptually because the overlap mode and running in safety mode are quite orthogonal. More pragmatically, it also makes it possible to use `OverlapMode` to let programmers pick the overlap mode for individual instances.
| * Better debug printingSimon Peyton Jones2014-06-121-2/+9
| |
| * Fix discarding of unreachable code in the register allocator (#9155)Simon Marlow2014-06-061-20/+12
| | | | | | | | | | | | | | A previous fix to this was wrong: f5879acd018494b84233f26fba828ce376d0f81d and left some unreachable code behind. So rather than try to be clever and do this at the same time as the strongly-connected-component analysis, I'm doing a separate reachability pass first.
| * Only use UnicodeSytanx pretty printing if the locale supports itJoachim Breitner2014-06-061-4/+5
| | | | | | | | using the same check as for unicode quotes.
| * Use UnicodeSyntax when printingJoachim Breitner2014-06-061-9/+24
| | | | | | | | | | When printing Haskell source, and UnicodeSyntax is enabled, use the unicode sytax characters (#8959).
| * Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-1524-17/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In some cases, the layout of the LANGUAGE/OPTIONS_GHC lines has been reorganized, while following the convention, to - place `{-# LANGUAGE #-}` pragmas at the top of the source file, before any `{-# OPTIONS_GHC #-}`-lines. - Moreover, if the list of language extensions fit into a single `{-# LANGUAGE ... -#}`-line (shorter than 80 characters), keep it on one line. Otherwise split into `{-# LANGUAGE ... -#}`-lines for each individual language extension. In both cases, try to keep the enumeration alphabetically ordered. (The latter layout is preferable as it's more diff-friendly) While at it, this also replaces obsolete `{-# OPTIONS ... #-}` pragma occurences by `{-# OPTIONS_GHC ... #-}` pragmas.
| * Avoid trivial cases of NondecreasingIndentationHerbert Valerio Riedel2014-05-151-4/+3
| | | | | | | | | | | | | | This cleanup allows the following refactoring commit to avoid adding a few `{-# LANGUAGE NondecreasingIndentation #-}` pragmas. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
| * Be less verbose when printing Names when we don't know what's in scopeSimon Peyton Jones2014-04-241-13/+12
| | | | | | | | | | | | | | | | Previously we always printed qualified names, but that makes a lot of debug or warning output very verbose. So now we only print qualified names with -dppr-debug. Civilised output (from pukka error messages, with the environment available) is unaffected
| * ghc: initial AArch64 patchesColin Watson2014-04-211-0/+1
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* | Merge branch 'master' into late-lam-liftNicolas Frisby2014-06-1525-334/+1269
|\ \ | |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | It seems to be building, but I haven't tested it yet -- just now commiting before I run validate.sh Conflicts: compiler/basicTypes/VarEnv.lhs compiler/codeGen/StgCmmArgRep.hs compiler/codeGen/StgCmmHeap.hs compiler/coreSyn/CorePrep.lhs compiler/coreSyn/CoreUnfold.lhs compiler/main/DynFlags.hs compiler/main/StaticFlags.hs compiler/simplCore/SetLevels.lhs compiler/simplCore/SimplCore.lhs compiler/specialise/SpecConstr.lhs compiler/stgSyn/CoreToStg.lhs compiler/stranal/WwLib.lhs includes/Cmm.h rts/Linker.c
| * Major Call Arity reworkJoachim Breitner2014-03-052-0/+140
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch improves the call arity analysis in various ways. Most importantly, it enriches the analysis result information so that when looking at a call, we do not have to make a random choice about what side we want to take the information from. Instead we can combine the results in a way that does not lose valuable information. To do so, besides the incoming arities, we store remember "what can be called with what", i.e. an undirected graph between the (interesting) free variables of an expression. Of course it makes combining the results a bit more tricky (especially mutual recursion), but still doable. The actually implemation of the graph structure is abstractly put away in a module of its own (UnVarGraph.hs) The implementation is geared towards efficiently representing the graphs that we need (which can contain large complete and large complete bipartite graphs, which would be huge in other representations). If someone feels like designing data structures: There is surely some speed-up to be obtained by improving that data structure. Additionally, the analysis now takes into account that if a RHS stays a thunk, then its calls happen only once, even if the variables the RHS is bound to is evaluated multiple times, or is part of a recursive group.
| * Use U+2018 instead of U+201B quote mark in compiler messagesHerbert Valerio Riedel2014-02-251-1/+1
| | | | | | | | | | | | | | This matches GCC's choice of Unicode quotation marks (i.e. U+2018 and U+2019) and therefore looks more familiar on the console. This addresses #2507. Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
| * Fix Haddock formattingMateusz Kowalczyk2014-02-241-11/+13
| |
| * Cleaned up Maybes.lhsBaldur Blöndal2014-02-131-34/+4
| |
| * Fix inplace dynamic linking on OS X (#8266)Christiaan Baaj2014-01-281-0/+6
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Implement pattern synonymsDr. ERDI Gergo2014-01-202-0/+14
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch implements Pattern Synonyms (enabled by -XPatternSynonyms), allowing y ou to assign names to a pattern and abstract over it. The rundown is this: * Named patterns are introduced by the new 'pattern' keyword, and can be either *unidirectional* or *bidirectional*. A unidirectional pattern is, in the simplest sense, simply an 'alias' for a pattern, where the LHS may mention variables to occur in the RHS. A bidirectional pattern synonym occurs when a pattern may also be used in expression context. * Unidirectional patterns are declared like thus: pattern P x <- x:_ The synonym 'P' may only occur in a pattern context: foo :: [Int] -> Maybe Int foo (P x) = Just x foo _ = Nothing * Bidirectional patterns are declared like thus: pattern P x y = [x, y] Here, P may not only occur as a pattern, but also as an expression when given values for 'x' and 'y', i.e. bar :: Int -> [Int] bar x = P x 10 * Patterns can't yet have their own type signatures; signatures are inferred. * Pattern synonyms may not be recursive, c.f. type synonyms. * Pattern synonyms are also exported/imported using the 'pattern' keyword in an import/export decl, i.e. module Foo (pattern Bar) where ... Note that pattern synonyms share the namespace of constructors, so this disambiguation is required as a there may also be a 'Bar' type in scope as well as the 'Bar' pattern. * The semantics of a pattern synonym differ slightly from a typical pattern: when using a synonym, the pattern itself is matched, followed by all the arguments. This means that the strictness differs slightly: pattern P x y <- [x, y] f (P True True) = True f _ = False g [True, True] = True g _ = False In the example, while `g (False:undefined)` evaluates to False, `f (False:undefined)` results in undefined as both `x` and `y` arguments are matched to `True`. For more information, see the wiki: https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms https://ghc.haskell.org/trac/ghc/wiki/PatternSynonyms/Implementation Reviewed-by: Simon Peyton Jones <simonpj@microsoft.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Tidy up Outputable.printDoc, and add printDoc_Simon Peyton Jones2014-01-171-4/+11
| | | | | | | | | | | | The former adds a newline at the end (restoring the previous behaviour) while the latter does not (which previously happened by turning the thuing into a string and only then printing it).
| * Another AMP fix for StreamAustin Seipp2014-01-141-0/+9
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Fix AMP warnings for MaybeT/MaybeErrAustin Seipp2014-01-141-1/+13
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Fix new Haddock doc parse failures.Austin Seipp2014-01-121-7/+11
| | | | | | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Make showSDoc and friends respect -dppr-colsSimon Peyton Jones2014-01-102-49/+28
| | | | | | | | | | | | | | | | Previously they just used a fixed width of 100, ignoring -dppr-cols. I think this dates back to a time when the flag didn't exist, or wasn't conveniently available. Thanks to Andrew Gibiansky for pointing this out.
| * Re-work the naming story for the GHCi prompt (Trac #8649)Simon Peyton Jones2014-01-091-14/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The basic idea here is simple, and described in Note [The interactive package] in HscTypes, which starts thus: Note [The interactive package] ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Type and class declarations at the command prompt are treated as if they were defined in modules interactive:Ghci1 interactive:Ghci2 ...etc... with each bunch of declarations using a new module, all sharing a common package 'interactive' (see Module.interactivePackageId, and PrelNames.mkInteractiveModule). This scheme deals well with shadowing. For example: ghci> data T = A ghci> data T = B ghci> :i A data Ghci1.T = A -- Defined at <interactive>:2:10 Here we must display info about constructor A, but its type T has been shadowed by the second declaration. But it has a respectable qualified name (Ghci1.T), and its source location says where it was defined. So the main invariant continues to hold, that in any session an original name M.T only refers to oe unique thing. (In a previous iteration both the T's above were called :Interactive.T, albeit with different uniques, which gave rise to all sorts of trouble.) This scheme deals nicely with the original problem. It allows us to eliminate a couple of grotseque hacks - Note [Outputable Orig RdrName] in HscTypes - Note [interactive name cache] in IfaceEnv (both these comments have gone, because the hacks they describe are no longer necessary). I was also able to simplify Outputable.QueryQualifyName, so that it takes a Module/OccName as args rather than a Name. However, matters are never simple, and this change took me an unreasonably long time to get right. There are some details in Note [The interactive package] in HscTypes.
| * Clarify the default demand on demand environmentsJoachim Breitner2013-12-161-0/+28
| | | | | | | | by adding Notes and using easier to understand combinators.
| * Mask async exceptions in forkM_Edsko de Vries2013-12-031-1/+3
| | | | | | | | See #8006 for the reason why. This is not a fix as such; more of a workaround.
| * Remove unnecessary and deprecated inclusions of Typeable.hPatrick Palka2013-11-121-2/+0
| | | | | | | | | | The build system would've complained loudly about these inclusions if it weren't for #8527.
| * Remove old workaround for containers <= 0.3Patrick Palka2013-11-121-4/+0
| |
| * Placate clang (#8444, #8445)Austin Seipp2013-10-251-2/+2
| | | | | | | | | | | | | | | | Once again the whitespace rules (and the rules concerning expansion of tokens) have bitten us. Authored-by: Authored-by: Luke Iannini <lukexi@me.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Added comments to BooleanFormula to explain the expression simplifier. (#7633)Twan van Laarhoven2013-10-151-3/+47
| |
| * TyposKrzysztof Gogolewski2013-10-121-1/+1
| |
| * Globally replace "hackage.haskell.org" with "ghc.haskell.org"Simon Marlow2013-10-015-5/+5
| |
| * Discard unreachable code in the register allocator (#7574)Simon Marlow2013-09-231-5/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The problem with unreachable code is that it might refer to undefined registers. This happens accidentally: a block can be orphaned by an optimisation, for example when the result of a comparsion becomes known. The register allocator panics when it finds an undefined register, because they shouldn't occur in generated code. So we need to also discard unreachable code to prevent this panic being triggered by optimisations. The register alloator already does a strongly-connected component analysis, so it ought to be easy to make it discard unreachable code as part of that traversal. It turns out that we need a different variant of the scc algorithm to do that (see Digraph), however the new variant also generates slightly better code by putting the blocks within a loop in a better order for register allocation.
| * Comments onlyJan Stolarek2013-09-191-0/+1
| |
| * Restore old names of comparison primopsJan Stolarek2013-09-185-8/+299
| | | | | | | | | | | | | | | | | | | | | | | | In 6579a6c we removed existing comparison primops and introduced new ones returning Int# instead of Bool. This commit (and associated commits in array, base, dph, ghc-prim, integer-gmp, integer-simple, primitive, testsuite and template-haskell) restores old names of primops. This allows us to keep our API cleaner at the price of not having backwards compatibility. This patch also temporalily disables fix for #8317 (optimization of tagToEnum# at Core level). We need to fix #8326 first, otherwise our primops code will be very slow.
| * Trailing whitespacesJan Stolarek2013-09-183-11/+11
| |
| * Implement checkable "minimal complete definitions" (#7633)Twan van Laarhoven2013-09-181-0/+167
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit adds a `{-# MINIMAL #-}` pragma, which defines the possible minimal complete definitions for a class. The body of the pragma is a boolean formula of names. The old warning for missing methods is replaced with this new one. Note: The interface file format is changed to store the minimal complete definition. Authored-by: Twan van Laarhoven <twanvl@gmail.com> Signed-off-by: Herbert Valerio Riedel <hvr@gnu.org>
| * Outputable.isOrAre: "is" or "are" for correct grammarJoachim Breitner2013-09-131-1/+10
| |
| * Fix AMP warnings.Austin Seipp2013-09-111-1/+6
| | | | | | | | | | Authored-by: David Luposchainsky <dluposchainsky@gmail.com> Signed-off-by: Austin Seipp <austin@well-typed.com>
| * Merge remote-tracking branch 'origin/master' into ghc-parmake-gsocghc-parmake-gsocPatrick Palka2013-09-081-0/+1
| |\
| | * Add basic support for GHCJSAustin Seipp2013-09-061-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This patch encompasses most of the basic infrastructure for GHCJS. It includes: * A new extension, -XJavaScriptFFI * A new architecture, ArchJavaScript * Parser and lexer support for 'foreign import javascript', only available under -XJavaScriptFFI, using ArchJavaScript. * As a knock-on, there is also a new 'WayCustom' constructor in DynFlags, so clients of the GHC API can add custom 'tags' to their built files. This should be useful for other users as well. The remaining changes are really just the resulting fallout, making sure all the cases are handled appropriately for DynFlags and Platform. Authored-by: Luite Stegeman <stegeman@gmail.com> Signed-off-by: Austin Seipp <aseipp@pobox.com>
| | * Fix off-by-one error in FastString.getFastStringTable (#8110)Patrick Palka2013-08-301-1/+1
| | | | | | | | | | | | | | | The function was reading past the end of the FastString table, causing the -dfaststring-stats option to behave unpredictably.
| * | Binary: eradicate BinIO handlesPatrick Palka2013-08-261-44/+0
| | | | | | | | | | | | They are not used anywhere in the compiler.
| * | Binary: Make lazyGet more thread-safePatrick Palka2013-08-261-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | All values read lazily from the same BinHandle share the same mutable offset variable (_off_r). If two such lazy values are simultaneously evaluated, the two threads will step over each other when writing to _off_r. Fortunately, for BinMem handles, making lazyGet thread-safe is simple: just use a fresh off_r variable when deferring the call to getAt. For BinIO handles, a race condition still exists because IO handles contain their own mutable file pointer variable that gets clobbered in a similar way that _off_r would. But GHC doesn't use BinIO handles anywhere so this particular issue could be ignored for now.