summaryrefslogtreecommitdiff
path: root/compiler/nativeGen
Commit message (Collapse)AuthorAgeFilesLines
* Place static closures in their own section.Edward Z. Yang2014-10-013-0/+6
| | | | | | | | | | | | | | | | | | | | | | | Summary: The primary reason for doing this is assisting debuggability: if static closures are all in the same section, they are guaranteed to be adjacent to one another. This will help later when we add some code that takes section start/end and uses this to sanity-check the sections. Part of remove HEAP_ALLOCED patch set (#8199) Signed-off-by: Edward Z. Yang <ezyang@mit.edu> Test Plan: validate Reviewers: simonmar, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D263 GHC Trac Issues: #8199
* Stop exporting, and stop using, functions marked as deprecatedThomas Miedema2014-09-275-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | Don't export `getUs` and `getUniqueUs`. `UniqSM` has a `MonadUnique` instance: instance MonadUnique UniqSM where getUniqueSupplyM = getUs getUniqueM = getUniqueUs getUniquesM = getUniquesUs Commandline-fu used: git grep -l 'getUs\>' | grep -v compiler/basicTypes/UniqSupply.lhs | xargs sed -i 's/getUs/getUniqueSupplyM/g git grep -l 'getUniqueUs\>' | grep -v combiler/basicTypes/UniqSupply.lhs | xargs sed -i 's/getUniqueUs/getUniqueM/g' Follow up on b522d3a3f970a043397a0d6556ca555648e7a9c3 Reviewed By: austin, hvr Differential Revision: https://phabricator.haskell.org/D220
* Delete hack that was once needed to fix the buildThomas Miedema2014-09-252-0/+2
| | | | | | | | | | | | | | | | | Summary: Introduced in 6c7b41cc2b24f533697a62bf1843507ae043fc97. I checked the rest of that commit, and this is all that was left to revert. Test Plan: x Reviewers: ezyang, austin Reviewed By: ezyang, austin Subscribers: simonmar, ezyang, carter, thomie Differential Revision: https://phabricator.haskell.org/D241
* Make Applicative a superclass of MonadAustin Seipp2014-09-093-5/+11
| | | | | | | | | | | | | | | | | | | | | Summary: This includes pretty much all the changes needed to make `Applicative` a superclass of `Monad` finally. There's mostly reshuffling in the interests of avoid orphans and boot files, but luckily we can resolve all of them, pretty much. The only catch was that Alternative/MonadPlus also had to go into Prelude to avoid this. As a result, we must update the hsc2hs and haddock submodules. Signed-off-by: Austin Seipp <austin@well-typed.com> Test Plan: Build things, they might not explode horribly. Reviewers: hvr, simonmar Subscribers: simonmar Differential Revision: https://phabricator.haskell.org/D13
* `M-x delete-trailing-whitespace` & `M-x untabify`...Herbert Valerio Riedel2014-08-311-2/+2
| | | | | | ...some files more or less recently touched by me [ci skip]
* Add MO_AddIntC, MO_SubIntC MachOps and implement in X86 backendReid Barton2014-08-235-0/+29
| | | | | | | | | | | | | | | | | | | | | | | | Summary: These MachOps are used by addIntC# and subIntC#, which in turn are used in integer-gmp when adding or subtracting small Integers. The following benchmark shows a ~6% speedup after this commit on x86_64 (building GHC with BuildFlavour=perf). {-# LANGUAGE MagicHash #-} import GHC.Exts import Criterion.Main count :: Int -> Integer count (I# n#) = go n# 0 where go :: Int# -> Integer -> Integer go 0# acc = acc go n# acc = go (n# -# 1#) $! acc + 1 main = defaultMain [bgroup "count" [bench "100" $ whnf count 100]] Differential Revision: https://phabricator.haskell.org/D140
* Implement new CLZ and CTZ primops (re #9340)Herbert Valerio Riedel2014-08-144-0/+89
| | | | | | | | | | | | | | | | | | | | | | | | 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
* 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
* 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
* refactor to fix 80column overflowSimon Marlow2014-08-011-16/+20
|
* Allow multiple entry points when allocating recursive groups (#9303)Simon Marlow2014-07-312-35/+39
| | | | | | | | | | | | | | | | | Summary: In this example we ended up with some code that was only reachable via an info table, because a branch had been optimised away by the native code generator. The register allocator then got confused because it was only considering the first block of the proc to be an entry point, when actually any of the info tables are entry points. Test Plan: validate Reviewers: simonpj, austin Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D88
* Add missing memory fence to atomicWriteIntArray#Johan Tibell2014-07-233-1/+7
|
* X86 codegen: make LOCK a real instruction prefixJohan Tibell2014-07-233-12/+8
| | | | | | | | | | Before LOCK was a separate instruction and this led to the register allocator separating it from the instruction it was supposed to be a prefix of, leading to illegal assembly such as lock mov Fix contributed by PÁLI Gábor János.
* Rename PackageId to PackageKey, distinguishing it from Cabal's PackageId.Edward Z. Yang2014-07-212-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Previously, both Cabal and GHC defined the type PackageId, and we expected them to be roughly equivalent (but represented differently). This refactoring separates these two notions. A package ID is a user-visible identifier; it's the thing you write in a Cabal file, e.g. containers-0.9. The components of this ID are semantically meaningful, and decompose into a package name and a package vrsion. A package key is an opaque identifier used by GHC to generate linking symbols. Presently, it just consists of a package name and a package version, but pursuant to #9265 we are planning to extend it to record other information. Within a single executable, it uniquely identifies a package. It is *not* an InstalledPackageId, as the choice of a package key affects the ABI of a package (whereas an InstalledPackageId is computed after compilation.) Cabal computes a package key for the package and passes it to GHC using -package-name (now *extremely* misnamed). As an added bonus, we don't have to worry about shadowing anymore. As a follow on, we should introduce -current-package-key having the same role as -package-name, and deprecate the old flag. This commit is just renaming. The haddock submodule needed to be updated. 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/D79 Conflicts: compiler/main/HscTypes.lhs compiler/main/Packages.lhs utils/haddock
* nativeGen: detabify/dewhitespace SPARC/CodeGen/BaseAustin Seipp2014-07-201-53/+41
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CodeGen/Gen32Austin Seipp2014-07-201-373/+361
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CodeGen/SanityAustin Seipp2014-07-201-53/+42
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CodeGen/ExpandAustin Seipp2014-07-201-106/+91
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CodeGen/AmodeAustin Seipp2014-07-201-23/+15
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CodeGen/CondCodeAustin Seipp2014-07-201-29/+21
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/CondAustin Seipp2014-07-201-29/+21
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/RegsAustin Seipp2014-07-201-145/+137
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/InstrAustin Seipp2014-07-201-311/+302
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/ShortcutJumpAustin Seipp2014-07-201-21/+10
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/ImmAustin Seipp2014-07-201-42/+32
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SPARC/StackAustin Seipp2014-07-201-29/+20
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace TargetRegAustin Seipp2014-07-201-22/+12
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace RegClassAustin Seipp2014-07-201-28/+20
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace PPC/RegInfoAustin Seipp2014-07-201-16/+7
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace PPC/CondAustin Seipp2014-07-201-25/+17
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace X86/RegInfoAustin Seipp2014-07-201-19/+11
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace RegAustin Seipp2014-07-201-127/+116
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* nativeGen: detabify/dewhitespace SizeAustin Seipp2014-07-201-51/+44
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* remove SPARC related comment in PPC code generatorPeter Trommler2014-07-101-9/+0
| | | | | | | | | | | | | | | | Summary: PowerPC does not do delay slots and there is also no requirement to put extra instructions between FP operations and branches. Test Plan: None. Comment change only. Reviewers: austin, simonmar Reviewed By: austin, simonmar Subscribers: simonmar, relrod, carter Differential Revision: https://phabricator.haskell.org/D40
* Re-add more primops for atomic ops on byte arraysJohan Tibell2014-06-306-2/+212
| | | | | | | | | | | | | | | | | | | | | | | This is the second attempt to add this functionality. The first attempt was reverted in 950fcae46a82569e7cd1fba1637a23b419e00ecd, due to register allocator failure on x86. Given how the register allocator currently works, we don't have enough registers on x86 to support cmpxchg using complicated addressing modes. Instead we fall back to a simpler addressing mode on x86. Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Revert "Add more primops for atomic ops on byte arrays"Johan Tibell2014-06-266-194/+2
| | | | | | | | This commit caused the register allocator to fail on i386. This reverts commit d8abf85f8ca176854e9d5d0b12371c4bc402aac3 and 04dd7cb3423f1940242fdfe2ea2e3b8abd68a177 (the second being a fix to the first).
* Add more primops for atomic ops on byte arraysJohan Tibell2014-06-246-2/+194
| | | | | | | | | | | | | | | | | | | Summary: Add more primops for atomic ops on byte arrays Adds the following primops: * atomicReadIntArray# * atomicWriteIntArray# * fetchSubIntArray# * fetchOrIntArray# * fetchXorIntArray# * fetchAndIntArray# Makes these pre-existing out-of-line primops inline: * fetchAddIntArray# * casIntArray#
* Some typos in commentsGabor Greif2014-06-111-1/+1
|
* Make better use of the x86 addressing modeJohan Tibell2014-06-101-0/+9
| | | | | | | | | | | | | We now emit movq %rdi,16(%r14,%rsi,8) instead of leaq 16(%r14),%rax movq %rdi,(%rax,%rsi,8) This helps e.g. byte array indexing.
* Fix discarding of unreachable code in the register allocator (#9155)Simon Marlow2014-06-061-4/+10
| | | | | | | 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.
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-1538-31/+64
| | | | | | | | | | | | | | | | | | 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.
* ghc: initial AArch64 patchesColin Watson2014-04-215-0/+12
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Validate inferred theta. Fixes #8883Jan Stolarek2014-04-192-0/+2
| | | | | | | This checks that all the required extensions are enabled for the inferred type signature. Updates binary and vector submodules.
* Use the correct callClobberedRegs on Windows/x64 (#8834)Simon Marlow2014-03-271-0/+3
| | | | Signed-off-by: Austin Seipp <austin@well-typed.com>
* Add flags to control memcpy and memset inliningJohan Tibell2014-03-261-26/+30
| | | | | | | This adds -fmax-inline-memcpy-insns and -fmax-inline-memset-insns. These flags control when we inline calls to memcpy/memset with statically known arguments. The flag naming style is taken from GCC and the same limit is used by both GCC and LLVM.
* PPC: Fix loads of PIC data with > 16 bit offsets (#7830).Erik de Castro Lopo2014-02-281-2/+3
| | | | Loads should now handle up to 32 bit offsets.
* Manual hlinting: or (map f) = any fJoachim Breitner2014-02-131-1/+1
|