summaryrefslogtreecommitdiff
path: root/compiler/llvmGen/LlvmCodeGen.hs
Commit message (Collapse)AuthorAgeFilesLines
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-2/+2
| | | | | | | | | | | | | | | | | | 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.
* Validate inferred theta. Fixes #8883Jan Stolarek2014-04-191-0/+1
| | | | | | | This checks that all the required extensions are enabled for the inferred type signature. Updates binary and vector submodules.
* LLVM refactor cleanupsPeter Wortmann2013-06-271-3/+1
| | | | | Slightly more documentation, removed unused label map (huh), removed MonadIO instance on LlvmM to improve encapsulation.
* Major Llvm refactoringPeter Wortmann2013-06-271-110/+143
| | | | | | | | | | | | | | | | | | | | | | This combined patch reworks the LLVM backend in a number of ways: 1. Most prominently, we introduce a LlvmM monad carrying the contents of the old LlvmEnv around. This patch completely removes LlvmEnv and refactors towards standard library monad combinators wherever possible. 2. Support for streaming - we can now generate chunks of Llvm for Cmm as it comes in. This might improve our speed. 3. To allow streaming, we need a more flexible way to handle forward references. The solution (getGlobalPtr) unifies LlvmCodeGen.Data and getHsFunc as well. 4. Skip alloca-allocation for registers that are actually never written. LLVM will automatically eliminate these, but output is smaller and friendlier to human eyes this way. 5. We use LlvmM to collect references for llvm.used. This allows places other than cmmProcLlvmGens to generate entries.
* Extend globals to aliasesPeter Wortmann2013-06-271-2/+3
| | | | | Also give them a proper constructor - getGlobalVar and getGlobalValue map directly to the accessors.
* Avoid generating empty llvm.used definitions.Geoffrey Mainland2013-06-121-12/+12
| | | | | LLVM 3.3rc3 complains when the llvm.used global is an empty array, so don't define llvm.used at all when it would be empty.
* Output LLVM version in use at -V2.David Terei2013-01-171-0/+2
|
* Add -f[no-]warn-unsupported-llvm-version. Closes Trac #7579.Austin Seipp2013-01-161-2/+3
| | | | | | | | | | | | This controls whether or not the compiler warns if we're using an LLVM version that's too old or too new. It's mostly useful when building the compiler knowingly with an unsupported version, so you don't get a lot of warnings in the build process. There's no documentation for this since it's a flag only a few developers would care about anyway. Signed-off-by: Austin Seipp <mad.one@gmail.com>
* Fix warningsSimon Marlow2012-11-121-1/+1
|
* Remove OldCmm, convert backends to consume new CmmSimon Marlow2012-11-121-9/+8
| | | | | | | | | | | | | | | | | | This removes the OldCmm data type and the CmmCvt pass that converts new Cmm to OldCmm. The backends (NCGs, LLVM and C) have all been converted to consume new Cmm. The main difference between the two data types is that conditional branches in new Cmm have both true/false successors, whereas in OldCmm the false case was a fallthrough. To generate slightly better code we occasionally need to invert a conditional to ensure that the branch-not-taken becomes a fallthrough; this was previously done in CmmCvt, and it is now done in CmmContFlowOpt. We could go further and use the Hoopl Block representation for native code, which would mean that we could use Hoopl's postorderDfs and analyses for native code, but for now I've left it as is, using the old ListGraph representation for native code.
* Generate correct LLVM for the new register allocation scheme.Geoffrey Mainland2012-10-301-2/+2
| | | | | | | | | | | | | We now have accurate global register liveness information attached to all Cmm procedures and jumps. With this patch, the LLVM back end uses this information to pass only the live floating point (F and D) registers on tail calls. This makes the LLVM back end compatible with the new register allocation strategy. Ideally the GHC LLVM calling convention would put all registers that are always live first in the parameter sequence. Unfortunately the specification is written so that on x86-64 SpLim (always live) is passed after the R registers. Therefore we must always pass *something* in the R registers, so we pass the LLVM value undef.
* Attach global register liveness info to Cmm procedures.Geoffrey Mainland2012-10-301-2/+2
| | | | | | | All Cmm procedures now include the set of global registers that are live on procedure entry, i.e., the global registers used to pass arguments to the procedure. Only global registers that are use to pass arguments are included in this list.
* Pass DynFlags down to bWordIan Lynagh2012-09-121-1/+1
| | | | | | 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.
* Move activeStgRegs into CodeGen.PlatformIan Lynagh2012-08-211-1/+1
|
* Add "Unregisterised" as a field in the settings fileIan Lynagh2012-08-071-1/+1
| | | | | | To explicitly choose whether you want an unregisterised build you now need to use the "--enable-unregisterised"/"--disable-unregisterised" configure flags.
* New codegen: do not split proc-points when using the NCGSimon Marlow2012-07-301-2/+2
| | | | | | | | | 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.
* tweak llvm version warning messageDavid Terei2012-06-251-2/+2
|
* Warn if using unsupported version of LLVM.David Terei2012-06-251-3/+18
|
* Remove some more redundant Platform argumentsIan Lynagh2012-06-201-1/+1
|
* Add DynFlags to the SDoc stateIan Lynagh2012-06-121-5/+5
|
* Use SDoc rather than Doc in LLVMIan Lynagh2012-06-121-7/+9
| | | | | In particular, this makes life simpler when we want to use a general GHC SDoc in the middle of some LLVM.
* Only use TBAA when LLVM > 2.8. (#5782)David Terei2012-01-171-1/+4
|
* Add '-freg-liveness' flag to control if STG liveness informationDavid Terei2012-01-121-1/+1
| | | | is used for optimisation. (enabled by default)
* Improve style of '-ddump-llvm' output. (#5750)David Terei2012-01-101-0/+1
|
* Fix ugly complexity issue in LLVM backend (#5652)David Terei2011-12-031-9/+14
| | | | | | | | Compile time still isn't as good as I'd like but no easy changes available. LLVM backend could do with a big rewrite to improve performance as there are some ugly designs in it. At least the test case isn't 10min anymore, just a few seconds now.
* Add CCS for llvmDavid Terei2011-12-031-9/+17
|
* Show LLVM mangler and code gen passes at v2David Terei2011-11-221-0/+1
|
* More CPP removal: pprDynamicLinkerAsmLabel in CLabelIan Lynagh2011-10-021-4/+4
| | | | And some knock-on changes
* Renaming onlySimon Peyton Jones2011-08-251-7/+7
| | | | | CmmTop -> CmmDecl CmmPgm -> CmmGroup
* Snapshot of codegen refactoring to share with simonpjSimon Marlow2011-08-251-3/+3
|
* More work towards cross-compilationIan Lynagh2011-07-151-1/+1
| | | | | | | | | | | | There's now a variant of the Outputable class that knows what platform we're targetting: class PlatformOutputable a where pprPlatform :: Platform -> a -> SDoc pprPlatformPrec :: Platform -> Rational -> a -> SDoc and various instances have had to be converted to use that class, and we pass Platform around accordingly.
* Refactoring: explicitly mark whether we have an info table in RawCmmMax Bolingbroke2011-07-061-4/+3
| | | | | | | | | | | | I introduced this to support explicitly recording the info table label in RawCmm for another patch I am working on, but it turned out to lead to significant simplification in those parts of the compiler that consume RawCmm. Now, instead of lots of tests for null [CmmStatic] we have a simple test of a Maybe, and have reduced the number of guys that need to know how to convert entry->info labels by a TON. There are only 3 callers of that function now!
* Some general code cleaning in LLVM backendDavid Terei2011-07-061-17/+16
|
* Refactoring: use a structured CmmStatics type rather than [CmmStatic]Max Bolingbroke2011-07-051-1/+1
| | | | | | | | | | | | | | | | | | I observed that the [CmmStatics] within CmmData uses the list in a very stylised way. The first item in the list is almost invariably a CmmDataLabel. Many parts of the compiler pattern match on this list and fail if this is not true. This patch makes the invariant explicit by introducing a structured type CmmStatics that holds the label and the list of remaining [CmmStatic]. There is one wrinkle: the x86 backend sometimes wants to output an alignment directive just before the label. However, this can be easily fixed up by parameterising the native codegen over the type of CmmStatics (though the GenCmmTop parameterisation) and using a pair (Alignment, CmmStatics) there instead. As a result, I think we will be able to remove CmmAlign and CmmDataLabel from the CmmStatic data type, thus nuking a lot of code and failing pattern matches. This change will come as part of my next patch.
* Add new mem{cpy,set,move} cmm prim ops.David Terei2011-05-311-2/+5
|
* Merge in new code generator branch.Simon Marlow2011-01-241-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* LLVM: Use mangler to fix up stack alignment issues on OSXDavid Terei2010-07-181-17/+11
|
* LLVM: Add in new LLVM mangler for implementing TNTC on OSXDavid Terei2010-07-131-1/+3
|
* LLVM: Fix various typos in commentsDavid Terei2010-07-071-4/+4
|
* Declare some top level globals to be constant when appropriateDavid Terei2010-06-211-16/+5
| | | | | | | This involved removing the old constant handling mechanism which was fairly hard to use. Now being constant or not is simply a property of a global variable instead of a separate type.
* Reduce the number of passes over the cmm in llvm BEDavid Terei2010-06-211-87/+46
|
* Add support of TNTC to llvm backendDavid Terei2010-06-181-14/+30
| | | | | | | We do this through a gnu as feature called subsections, where you can put data/code into a numbered subsection and those subsections will be joined together in descending order by gas at compile time.
* Add new LLVM code generator to GHC. (Version 2)David Terei2010-06-151-0/+166
This was done as part of an honours thesis at UNSW, the paper describing the work and results can be found at: http://www.cse.unsw.edu.au/~pls/thesis/davidt-thesis.pdf A Homepage for the backend can be found at: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Compiler/Backends/LLVM Quick summary of performance is that for the 'nofib' benchmark suite, runtimes are within 5% slower than the NCG and generally better than the C code generator. For some code though, such as the DPH projects benchmark, the LLVM code generator outperforms the NCG and C code generator by about a 25% reduction in run times.