summaryrefslogtreecommitdiff
path: root/compiler
Commit message (Collapse)AuthorAgeFilesLines
* Implement new CLZ and CTZ primops (re #9340)Herbert Valerio Riedel2014-08-149-1/+152
| | | | | | | | | | | | | | | | | | | | | | | | This implements the new primops clz#, clz32#, clz64#, ctz#, ctz32#, ctz64# which provide efficient implementations of the popular count-leading-zero and count-trailing-zero respectively (see testcase for a pure Haskell reference implementation). On x86, NCG as well as LLVM generates code based on the BSF/BSR instructions (which need extra logic to make the 0-case well-defined). Test Plan: validate and succesful tests on i686 and amd64 Reviewers: rwbarton, simonmar, ezyang, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D144 GHC Trac Issues: #9340
* StgCmmPrim: add note to stop using fixed size signed types for sizesJohan Tibell2014-08-121-0/+5
| | | | | We use fixed size signed types to e.g. represent array sizes. This means that the size can overflow.
* Add some Haddocks to SMRepJohan Tibell2014-08-121-2/+13
|
* shouldInlinePrimOp: Fix Int overflowJohan Tibell2014-08-122-24/+43
| | | | | | | | | | | | | | | | There were two overflow issues in shouldInlinePrimOp. The first one is due to a negative CmmInt literal being created if the array size was given as larger than 2^63-1 (on a 64-bit platform.) This meant that large array sizes could compare as being smaller than maxInlineAllocSize. The second issue is that we casted the Integer to an Int in the comparison, which again meant that large array sizes could compare as being smaller than maxInlineAllocSize. The attempt to allocate a large array inline then caused a segfault. Fixes #9416.
* Remove NonParametricKinds (#9200)Richard Eisenberg2014-08-124-226/+77
| | | | | This commit also removes 'KindCheckingStrategy' and related gubbins, instead including the notion of a CUSK into HsDecls.
* Change treatment of CUSKs for synonyms and families (#9200).Richard Eisenberg2014-08-121-4/+23
|
* Change definition of CUSK for data and class definitions (#9200).Richard Eisenberg2014-08-122-6/+20
| | | | | Now, a CUSK is when (and only when) all type variables are annotated. This allows classes to participate in polymorphic recursion.
* Fix #9415.Richard Eisenberg2014-08-121-1/+16
| | | | | | Abort typechecking when we detect a superclass cycle error, as ambiguity checking in the presence of superclass cycle errors can cause a loop.
* Fix Trac #9371.Richard Eisenberg2014-08-121-1/+21
| | | | | This was very simple: lists of different lengths are *maybe* apart, not *surely* apart.
* x86: zero extend the result of 16-bit popcnt instructions (#9435)Reid Barton2014-08-121-4/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: The 'popcnt r16, r/m16' instruction only writes the low 16 bits of the destination register, so we have to zero-extend the result to a full word as popCnt16# is supposed to return a Word#. For popCnt8# we could instead zero-extend the input to 32 bits and then do a 32-bit popcnt, and not have to zero-extend the result. LLVM produces the 16-bit popcnt sequence with two zero extensions, though, and who am I to argue? Test Plan: - ran "make TEST=cgrun071 EXTRA_HC_OPTS=-msse42" - then ran again adding "WAY=optasm", and verified that the popcnt sequences we generate match the ones produced by LLVM for its @llvm.ctpop.* intrinsics Reviewers: austin, hvr, tibbe Reviewed By: austin, hvr, tibbe Subscribers: phaskell, hvr, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D147 GHC Trac Issues: #9435
* Add CMOVcc insns to x86 NCGHerbert Valerio Riedel2014-08-122-0/+18
| | | | | | | | | | | | | | This is a pre-requisite for implementing count-{leading,trailing}-zero prim-ops (re #9340) and may be useful to NCG to help turn some code into branch-less code sequences. Test Plan: Compiles and validates in combination with clz/ctz primop impl Reviewers: ezyang, rwbarton, simonmar, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D141
* Add bit scan {forward,reverse} insns to x86 NCGHerbert Valerio Riedel2014-08-122-2/+10
| | | | | | | | | | | This is a pre-requisite for implementing count-{leading,trailing}-zero prim-ops (re #9340) Reviewers: ezyang, rwbarton, simonmar, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D141
* x86: Always generate add instruction in MO_Add2 (#9013)Reid Barton2014-08-113-2/+14
| | | | | | | | | | | | | Test Plan: - ran validate - ran T9013 test with all ways - ran CarryOverflow test with all ways, for good measure Reviewers: austin, simonmar Reviewed By: simonmar Differential Revision: https://phabricator.haskell.org/D137
* Make IntAddCOp, IntSubCOp into GenericOpsReid Barton2014-08-101-57/+65
| | | | | | | | | ... in preparation for backend-specific implementations. No functional changes in this commit (except in panic messages for ill-formed Cmm). Differential Revision: https://phabricator.haskell.org/D138
* Eliminate some code duplication in x86 backend (genCCall32/64)Reid Barton2014-08-101-101/+13
| | | | | | | | | | | | | | | | | | | | | | | | Summary: No functional changes except in panic messages. These functions were identical except for - x87 operations in genCCall32 - the fallback to genCCall32'/64' - "32" vs "64" in panic messages (one case was wrong!) - minor syntactic or otherwise non-functional differences. Test Plan: Ran "validate --no-dph --slow" before and after the change. Only differences were two tests that failed before the change but not after, further investigation revealed that those tests are in fact erratic. Reviewers: simonmar, austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D139
* fix darwin threaded static linking by removing -lpthread option #9189Bob Ippolito2014-08-101-1/+1
| | | | | | | | | | | | | | | | Summary: Signed-off-by: Bob Ippolito <bob@redivi.com> Test Plan: See repro instructions in trac #9189 Reviewers: austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D120 GHC Trac Issues: #9189
* systools info: fix warning about C compiler (message said about linker)Sergei Trofimovich2014-08-101-2/+2
| | | | | | | | | | | | | | Summary: Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: build-tested Reviewers: austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D132
* Clarify documentation of addIntC#, subIntC#Reid Barton2014-08-091-4/+10
|
* Implement the final change to INCOHERENT from Trac #9242Simon Peyton Jones2014-08-081-34/+49
| | | | | | | | | | | | | | | | The change here is to make INCOHERENT slightly more permissive: if the selected candidate is incoherent then ignore all unifying candidates This allows us to move the {-# INCOHERENT #-} pragma from from instance Typeable (f a) to Typeable (n:Nat) and Typable (s:Symbol) where it belongs, and where Trac #9242 said it should be. I don't think this will affect anyone. I've updated the user manual.
* 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
* Fix some typos in recent comments/notesGabor Greif2014-08-073-12/+12
|
* Add has_side_effets to the raise# primopSimon Peyton Jones2014-08-071-0/+5
| | | | | | | According to the definition of has_side_effets in PrimOp, raise# clearly has side effects! In practice it makes little difference becuase the fact that it returns bottom is more important... but still it's better to say it right.
* Refactor the handling of case-eliminationSimon Peyton Jones2014-08-071-59/+60
| | | | | | Mainly in Simplify.rebuildCase. The old code wasn't wrong, but I kept mis-understanding it. This patch cuts splits out "pure seq" from "strict let", which makes it much easier to grok.
* Extensive Notes on can_fail and has_side_effectsSimon Peyton Jones2014-08-073-52/+121
| | | | | | | | | | | | | | | | | | | | In fixing Trac #9390 I discovered that I *still* didn't really understand what the can_fail and has_side_effects properties of a PrimOp mean, precisely. The big new things I learned are * has_side_effects needs to be true only of *write* effects, Reads (which are, strictly speaking, effects) don't matter here. * has_side_effects must be true of primops that can throw a synchronous Haskell exception (eg raiseIO#) * can_fail is true only of primops that can cause an *unchecked* (not Haskell) system exception, like divide by zero, or accessing memory out of range through an array read or write. I've documented all this now. The changes in this patch are only in comments.
* Document the maintenance of the let/app invariant in the simplifierSimon Peyton Jones2014-08-074-49/+68
| | | | | | | | | It's not obvious why the simplifier generates code that correctly satisfies the let/app invariant. This patch does some minor refactoring, but the main point is to document pre-conditions to key functions, namely that the rhs passed in satisfies the let/app invariant. There shouldn't be any change in behaviour.
* Make buildToArrPReprs obey the let/app invariantSimon Peyton Jones2014-08-071-3/+8
| | | | | | | | | Vectorise.Generic.PAMethods.buildToArrPReprs was building an expression like pvoids# (lengthSels2# sels) which does not satisfy the let/app invariant. It should be more like case lengthSels2# sels of l -> pvoids# l This was caught by Core Lint (once it was taught to check for the invariant)
* When desugaring Use the smart mkCoreConApps and friendsSimon Peyton Jones2014-08-075-11/+11
| | | | | | | | This is actually the bug that triggered Trac #9390. We had an unboxed tuple (# writeArray# ..., () #), and that writeArray# argument isn't ok-for-speculation, so disobeys the invariant. The desugaring of unboxed tuples was to blame; the fix is easy.
* Don't float into unlifted function argumentsSimon Peyton Jones2014-08-071-20/+52
| | | | | We were inadvertently destroying the let/app invariant, by floating into an unlifted function argument.
* Make Core Lint check the let/app invariantSimon Peyton Jones2014-08-071-1/+10
| | | | | | | If we have an invariant, Lint should jolly well check it. (And indeed, adding this test throws up Lint errors that are fixed in separate patches.)
* Add Output instance for OrdListSimon Peyton Jones2014-08-071-0/+4
|
* Tiny refactoring, plus comments; no change in behaviourSimon Peyton Jones2014-08-071-4/+8
|
* Move Outputable instance for FloatBind to the data type definitionSimon Peyton Jones2014-08-072-7/+7
|
* Comments and white spaceSimon Peyton Jones2014-08-073-28/+28
|
* Thinning and renaming modules from packages on the command line.Edward Z. Yang2014-08-055-269/+512
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This patch set adds support for extra syntax on -package and related arguments which allow you to thin and rename modules from a package. For example, this argument: -package "base (Data.Bool as Bam, Data.List)" adds two more modules into scope, Bam and Data.List, without adding any of base's other modules to scope. These flags are additive: so, for example, saying: -hide-all-packages -package base -package "base (Data.Bool as Bam)" will provide both the normal bindings for modules in base, as well as the module Bam. There is also a new debug flag -ddump-mod-map which prints the state of the module mapping database. H = hidden, E = exposed (so for example EH says the module in question is exported, but in a hidden package.) Module suggestions have been minorly overhauled to work better with reexports: if you have -package "base (Data.Bool as Bam)" and mispell Bam, GHC will suggest "Did you mean Bam (defined via package flags to be base:Data.Bool)"; and generally you will get more accurate information. Also, fix a bug where we suggest the -package flag when we really need the -package-key flag. NB: The renaming afforded here does *not* affect what wired in symbols GHC generates. (But it does affect implicit prelude!) ToDo: add 'hiding' functionality, to make it easier to support the alternative prelude use-case. ToDo: Cabal support Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: new tests and validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D113 GHC Trac Issues: #9375
* Refactor PackageFlags so that ExposePackage is a single constructor.Edward Z. Yang2014-08-052-44/+39
| | | | | | | You can parametrize over the different selection by using a different PackageArg. This helps reduce code duplication. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Refactor package state, also fixing a module reexport bug.Edward Z. Yang2014-08-053-153/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Instead of building a multiply indirected data structure and querying it on every import, we now have two data structures moduleToPkgConf and moduleToPkgConfAll. moduleToPkgConf is a single-level UniqFM that is intended to be used for most valid imports; however, it does not contain any information useful for error reporting. If an error is occurred, we then query moduleToPkgConfAll, which contains a more comprehensive view of the package database. This field is lazily initialized (so this means we're retaining the package database list, but this should be fine because we're already maintaining the entries of the list.) Additionally, the full view doesn't keep track of a boolean toggle for visibility/exposure anymore, but instead tracks the *provenance* of how the module binding came to be (the ModuleOrigin data type). Additionally, we move the logic for determining if a module is exposed or not from Finder.lhs and put it in Packages.lhs; this information is communicated via the LookupResult data type. Unfortunately, we can't directly return a FindResult, because this data type is defined in HscTypes which depends on Packages. This is going to change some more in the near future when I add thinning/renaming to package flags; the error messages will need to be more flexible. I've also slightly changed the semantics of error messages for package qualified imports. Previously, if we didn't find any package qualified imports, but there were hidden modules in a *different* package, the error message would prefer mentioning those as opposed to providing suggestions. Now, if a module is hidden but in the wrong package, we won't mention it; instead, it will get mentioned with the other module suggestions. I was too lazy to write a test, but I can add one if people would like. The module reexport bug was, package q reexported p:P as Conflict, and package r reexported p:P2 as Conflict, this was *not* reported as a conflict, because the old logic incorrectly decided that P and P2 were the same module on account of being from the same package. The logic here has been corrected. Contains haddock submodule update. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu>
* Make PackageState an abstract type.Edward Z. Yang2014-08-058-57/+80
| | | | | | | | | | | | Summary: Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D107
* Package keys (for linking/type equality) separated from package IDs.Edward Z. Yang2014-08-0514-62/+211
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Disable package auto-hiding if -hide-all-packages is passedEdward Z. Yang2014-08-041-3/+14
| | | | | | | | | | | | | | | | | | Summary: This is in preparation for thinning/renaming package arguments, which allow users to rename modules of packages they import. In situations like this, it may be desirable to load multiple copies of a package at different versions explicitly under different names. Signed-off-by: Edward Z. Yang <ezyang@cs.stanford.edu> Test Plan: validate Reviewers: simonpj, simonmar, hvr, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D106
* ghc --make: add nicer names to RTS threads (threaded IO manager, make workers)Sergei Trofimovich2014-08-041-0/+14
| | | | | | | | | | | | | | | | | | | | Summary: The patch names most of RTS threads and ghc (the tool) threads. It makes nicer debug and eventlog output for ghc itself. Signed-off-by: Sergei Trofimovich <slyfox@gentoo.org> Test Plan: ran debugged ghc under '+RTS -Ds' Reviewers: simonmar, austin Reviewed By: austin Subscribers: phaskell, simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D101
* Infer safety of modules correctly with new overlapping pragmas.David Terei2014-08-011-0/+3
|
* Allow warning if could have been infered safe instead of explicitDavid Terei2014-08-014-71/+89
| | | | Trustworthy label.
* Dont allow hand-written Generic instances in Safe Haskell.David Terei2014-08-012-10/+24
| | | | | | | While they aren't strictly unsafe, it is a similar situation to Typeable. There are few instances where a programmer will write their own instance, and having compiler assurance that the Generic implementation is correct brings a lot of benefits.
* Fix-up to d4d4bef2 'Improve the desugaring of RULES'Simon Peyton Jones2014-08-011-2/+8
| | | | | I'd forgotten the possiblity that desugaring could generate dead dictionary bindings; easily fixed by calling occurAnalyseExpr
* Improve the desugaring of RULES, esp those from SPECIALISE pragmasSimon Peyton Jones2014-08-011-11/+64
| | | | | | | | | | | | In the code for Trac #8331 we were not getting a complaint, but we *were* getting a terrible (and virtually useless) RULE, looking like useAbstractMonad (complicated-dictionary-expresion) = $fuseAbstractMonad where we wanted useAbstractMonad d = $fuseAbstractMonad This commit improves the desugaring algorithm. More comments explain; see Note [Drop dictionary bindings on rule LHS]
* A panic in CmmBuildInfoTables.bundle shouldn't be a panic (#9329)Simon Marlow2014-08-011-4/+8
| | | | | | | | | | | | | | | | | Summary: This code needs more comments, but I believe this is safe. By definition I can't have broken anything that was working by turning a panic into a non-panic anyway. Test Plan: validate Reviewers: hvr, simonpj, austin Subscribers: simonmar, relrod, ezyang, carter Differential Revision: https://phabricator.haskell.org/D105 GHC Trac Issues: #9329
* add a commentSimon Marlow2014-08-011-0/+3
|
* update commentSimon Marlow2014-08-011-4/+3
|
* Fix reference to noteSimon Marlow2014-08-011-1/+1
|
* refactor to fix 80column overflowSimon Marlow2014-08-011-16/+20
|