summaryrefslogtreecommitdiff
path: root/compiler/cmm/CmmCallConv.hs
Commit message (Collapse)AuthorAgeFilesLines
* Module hierarchy: Cmm (cf #13009)Sylvain Henry2020-01-251-212/+0
|
* Remove unused imports of the form 'import foo ()' (Fixes #17065)James Foster2019-08-151-1/+1
| | | | | | | | | | | These kinds of imports are necessary in some cases such as importing instances of typeclasses or intentionally creating dependencies in the build system, but '-Wunused-imports' can't detect when they are no longer needed. This commit removes the unused ones currently in the code base (not including test files or submodules), with the hope that doing so may increase parallelism in the build system by removing unnecessary dependencies.
* Revert "Add support for SIMD operations in the NCG"Ben Gamari2019-07-161-25/+15
| | | | | | | Unfortunately this will require more work; register allocation is quite broken. This reverts commit acd795583625401c5554f8e04ec7efca18814011.
* Add support for SIMD operations in the NCGAbhiroop Sarkar2019-07-031-15/+25
| | | | | | | This adds support for constructing vector types from Float#, Double# etc and performing arithmetic operations on them Cleaned-Up-By: Ben Gamari <ben@well-typed.com>
* Move 'Platform' to ghc-bootJohn Ericson2019-06-191-1/+1
| | | | | | | ghc-pkg needs to be aware of platforms so it can figure out which subdire within the user package db to use. This is admittedly roundabout, but maybe Cabal could use the same notion of a platform as GHC to good affect too.
* removing x87 register support from native code genCarter Schonwald2019-04-101-1/+1
| | | | | | | | | | | | | | | | * simplifies registers to have GPR, Float and Double, by removing the SSE2 and X87 Constructors * makes -msse2 assumed/default for x86 platforms, fixing a long standing nondeterminism in rounding behavior in 32bit haskell code * removes the 80bit floating point representation from the supported float sizes * theres still 1 tiny bit of x87 support needed, for handling float and double return values in FFI calls wrt the C ABI on x86_32, but this one piece does not leak into the rest of NCG. * Lots of code thats not been touched in a long time got deleted as a consequence of all of this all in all, this change paves the way towards a lot of future further improvements in how GHC handles floating point computations, along with making the native code gen more accessible to a larger pool of contributors.
* Deprecate -fllvm-pass-vectors-in-regsBen Gamari2018-10-151-12/+5
| | | | | | | | | | | | Summary: The behavior previously enabled by this flag is as been the default since 8.6.1. Reviewers: simonmar Subscribers: rwbarton, carter Differential Revision: https://phabricator.haskell.org/D5193
* cmm: Remove unnecessary HsVersion.h includesMichal Terepeta2018-02-061-4/+0
| | | | | | | | | | | | Test Plan: ./validate Reviewers: goldfire, bgamari, simonmar Reviewed By: bgamari Subscribers: rwbarton, thomie, carter Differential Revision: https://phabricator.haskell.org/D4367
* Allow packing constructor fieldsMichal Terepeta2017-10-291-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is another step for fixing #13825 and is based on D38 by Simon Marlow. The change allows storing multiple constructor fields within the same word. This currently applies only to `Float`s, e.g., ``` data Foo = Foo {-# UNPACK #-} !Float {-# UNPACK #-} !Float ``` on 64-bit arch, will now store both fields within the same constructor word. For `WordX/IntX` we'll need to introduce new primop types. Main changes: - We now use sizes in bytes when we compute the offsets for constructor fields in `StgCmmLayout` and introduce padding if necessary (word-sized fields are still word-aligned) - `ByteCodeGen` had to be updated to correctly construct the data types. This required some new bytecode instructions to allow pushing things that are not full words onto the stack (and updating `Interpreter.c`). Note that we only use the packed stuff when constructing data types (i.e., for `PACK`), in all other cases the behavior should not change. - `RtClosureInspect` was changed to handle the new layout when extracting subterms. This seems to be used by things like `:print`. I've also added a test for this. - I deviated slightly from Simon's approach and use `PrimRep` instead of `ArgRep` for computing the size of fields. This seemed more natural and in the future we'll probably want to introduce new primitive types (e.g., `Int8#`) and `PrimRep` seems like a better place to do that (where we already have `Int64Rep` for example). `ArgRep` on the other hand seems to be more focused on calling functions. Signed-off-by: Michal Terepeta <michal.terepeta@gmail.com> Test Plan: ./validate Reviewers: bgamari, simonmar, austin, hvr, goldfire, erikd Reviewed By: bgamari Subscribers: maoe, rwbarton, thomie GHC Trac Issues: #13825 Differential Revision: https://phabricator.haskell.org/D3809
* compiler: introduce custom "GhcPrelude" PreludeHerbert Valerio Riedel2017-09-191-0/+2
| | | | | | | | | | | | | | | | | | This switches the compiler/ component to get compiled with -XNoImplicitPrelude and a `import GhcPrelude` is inserted in all modules. This is motivated by the upcoming "Prelude" re-export of `Semigroup((<>))` which would cause lots of name clashes in every modulewhich imports also `Outputable` Reviewers: austin, goldfire, bgamari, alanz, simonmar Reviewed By: bgamari Subscribers: goldfire, rwbarton, thomie, mpickering, bgamari Differential Revision: https://phabricator.haskell.org/D3989
* Update User's Guide, cleanup DynFlagsJan Stolarek2014-11-061-1/+1
|
* Add LANGUAGE pragmas to compiler/ source filesHerbert Valerio Riedel2014-05-151-0/+1
| | | | | | | | | | | | | | | | | | 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.
* By default, only pass 128-bit SIMD vectors in registers on X86-64.Geoffrey Mainland2013-09-221-3/+20
| | | | | | | LLVM's GHC calling convention only allows 128-bit SIMD vectors to be passed in machine registers on X86-64. This may change in LLVM 3.4; the hidden flag -fllvm-pass-vectors-in-regs causes all SIMD vector widths to be passed in registers on both X86-64 and on X86-32.
* Pass 512-bit-wide vectors in registers.Geoffrey Mainland2013-09-221-0/+1
|
* Pass 256-bit-wide vectors in registers.Geoffrey Mainland2013-09-221-0/+1
|
* Do not assume that XMM registers are used to pass floating point arguments.Geoffrey Mainland2013-09-221-15/+24
| | | | | | | | | | | On x86-32, the C calling convention specifies that when SSE2 is enabled, vector arguments are passed in xmm* registers; however, float and double arguments are still passed on the stack. This patch allows us to make the same choice for GHC. Even when SSE2 is enabled, we don't want to pass Float and Double arguments in registers because this would change the ABI and break the ability to link with code that was compiled without -msse2. The next patch will enable passing vector arguments in xmm registers on x86-32.
* Remove dead codeJan Stolarek2013-09-101-7/+1
|
* Only use real XMM registers when assigning arguments.Geoffrey Mainland2013-08-061-5/+4
| | | | | | | | My original change to the calling convention mistakenly used all 6 XMM registers---which live in the global register table---on x86 (32 bit). This royally screwed up the floating point code generated for that platform because floating point arguments were passed in global registers instead of on the stack!
* Rename SSE -> XMM for consistency.Geoffrey Mainland2013-08-061-13/+13
| | | | | We were using SSE is some places and XMM in others. Better to keep a consistent naming scheme.
* Detab modules with tabs on 5 lines or fewerIan Lynagh2013-04-061-8/+2
|
* Add support for passing SSE vectors in registers.Geoffrey Mainland2013-02-011-1/+3
| | | | | | | This patch adds support for 6 XMM registers on x86-64 which overlap with the F and D registers and may hold 128-bit wide SIMD vectors. Because there is not a good way to attach type information to STG registers, we aggressively bitcast in the LLVM back-end.
* Add Cmm support for representing 128-bit-wide SIMD vectors.Geoffrey Mainland2013-02-011-2/+5
|
* Fix the Slow calling convention (#7192)Simon Marlow2012-11-131-3/+3
| | | | | | | | The Slow calling convention passes the closure in R1, but we were ignoring this and hoping it would work, which it often did. However, this bug seems to have been the cause of #7192, because the graph-colouring allocator is more sensitive to having correct liveness information on jumps.
* Draw STG F and D registers from the same pool of available SSE registers on ↵Geoffrey Mainland2012-10-301-16/+41
| | | | | | | | | | | | x86-64. On x86-64 F and D registers are both drawn from SSE registers, so there is no reason not to draw them from the same pool of available SSE registers. This means that whereas previously a function could only receive two Double arguments in registers even if it did not have any Float arguments, now it can receive up to 6 arguments that are any mix of Float and Double in registers. This patch breaks the LLVM back end. The next patch will fix this breakage.
* Produce new-style Cmm from the Cmm parserSimon Marlow2012-10-081-26/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The main change here is that the Cmm parser now allows high-level cmm code with argument-passing and function calls. For example: foo ( gcptr a, bits32 b ) { if (b > 0) { // we can make tail calls passing arguments: jump stg_ap_0_fast(a); } return (x,y); } More details on the new cmm syntax are in Note [Syntax of .cmm files] in CmmParse.y. The old syntax is still more-or-less supported for those occasional code fragments that really need to explicitly manipulate the stack. However there are a couple of differences: it is now obligatory to give a list of live GlobalRegs on every jump, e.g. jump %ENTRY_CODE(Sp(0)) [R1]; Again, more details in Note [Syntax of .cmm files]. I have rewritten most of the .cmm files in the RTS into the new syntax, except for AutoApply.cmm which is generated by the genapply program: this file could be generated in the new syntax instead and would probably be better off for it, but I ran out of enthusiasm. Some other changes in this batch: - The PrimOp calling convention is gone, primops now use the ordinary NativeNodeCall convention. This means that primops and "foreign import prim" code must be written in high-level cmm, but they can now take more than 10 arguments. - CmmSink now does constant-folding (should fix #7219) - .cmm files now go through the cmmPipeline, and as a result we generate better code in many cases. All the object files generated for the RTS .cmm files are now smaller. Performance should be better too, but I haven't measured it yet. - RET_DYN frames are removed from the RTS, lots of code goes away - we now have some more canned GC points to cover unboxed-tuples with 2-4 pointers, which will reduce code size a little.
* Move wORD_SIZE into platformConstantsIan Lynagh2012-09-161-2/+1
|
* Move more constants into platformConstantsIan Lynagh2012-09-141-37/+42
|
* Pass DynFlags down to wordWidthIan Lynagh2012-09-121-2/+2
|
* Node calling convs should use R1 even if it isn't a registerSimon Marlow2012-08-071-28/+20
|
* Add "Unregisterised" as a field in the settings fileIan Lynagh2012-08-071-23/+33
| | | | | | To explicitly choose whether you want an unregisterised build you now need to use the "--enable-unregisterised"/"--disable-unregisterised" configure flags.
* Allow the register allocator access to argument regs (R1.., F1.., etc.)Simon Marlow2012-07-061-9/+17
| | | | | | | | | | | | | | | This was made possible by the recent change to codeGen to attach the live GlobalRegs to every CmmJump, and we'll be relying on it quite heavily in the new code generator too. What this means essentially is that when we see x = R1 the register allocator will automatically assign x to R1 and generate no code at all (also known as "coalescing"). It wasn't possible before because the register allocator had to assume that R1 was always live, because it didn't have access to accurate liveness information.
* Remove "fuel", adapt to Hoopl changes, fix warningsSimon Marlow2012-07-051-1/+0
|
* Use -fwarn-tabs when validatingIan Lynagh2011-11-041-0/+7
| | | | | We only use it for "compiler" sources, i.e. not for libraries. Many modules have a -fno-warn-tabs kludge for now.
* Bake in ByteOff to ParamLocation, and remove ArgumentFormat synonym.Edward Z. Yang2011-06-131-8/+5
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Remove unused assignArguments and argumentsSize.Edward Z. Yang2011-06-131-15/+1
| | | | Signed-off-by: Edward Z. Yang <ezyang@mit.edu>
* Comments, layout and cmm-notesSimon Peyton Jones2011-06-101-1/+3
| | | | ...all to do with the new codgen path
* New codegen: GC calling convention must use registers.Edward Z. Yang2011-02-181-1/+3
| | | | | | | | | | | | | | Previously, on register-deficient architectures like x86-32, the new code generator would emit code for calls to stg_gc_l1, stg_gc_d1 and stg_gc_f1 that pushed their single argument on to the stack, while the functions themselves expected the argument to live in L1, D1 and F1 (respectively). This was because cmmCall with the GC calling convention allocated real registers, not virtual registers. This patch modifies the code for assigning registers/stack slots to use the right calling convention for GC and adds an assertion to ensure it did it properly.
* Merge in new code generator branch.Simon Marlow2011-01-241-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Morguing dead codedias@cs.tufts.edu2009-09-181-85/+8
|
* Fixed calling convention for unboxed tuplesdias@cs.tufts.edu2009-09-181-4/+50
| | | | | | Apparently, the arguments should be sorted by pointerhood. While we're at it, I rewrote the code that assigns registers and stack space to function call and return parameters.
* Remove unused importsIan Lynagh2009-07-071-1/+0
|
* eliminate warningsdias@eecs.tufts.edu2009-04-031-1/+1
|
* Better handling of node parameter in calling conventionsdias@eecs.tufts.edu2009-03-251-4/+3
| | | | | | - Previously, the node was taken as a parameter, then ignored, for static closures. Goofy. Now, the vestigial node parameters are gone.
* Code simplifications due to call/return separation; some improvements to how ↵dias@eecs.tufts.edu2009-03-231-34/+2
| | | | node argument is managed
* Code simplification due to separate call/return conventionsdias@eecs.tufts.edu2009-03-231-18/+30
|
* Calls with and without passing node arguments more clearly separateddias@eecs.tufts.edu2009-03-231-2/+13
|
* Another small step: call and return conventions specified separately when ↵dias@eecs.tufts.edu2009-03-231-2/+1
| | | | making calls
* Small step toward call-conv improvement: separate out calls and returnsdias@eecs.tufts.edu2009-03-231-6/+8
|
* Calling convention bug and cleanupdias@eecs.tufts.edu2009-03-171-39/+58
| | | | | - yet another wrong calling convention; this one was a special case for returning one value.
* A few bug fixes; some improvements spurred by paper writingdias@eecs.harvard.edu2009-03-031-2/+3
| | | | | | | | | | | | Among others: - Fixed Stg->C-- translation of let-no-escapes -- it's important to use the right continuation... - Fixed infinite recursion in X86 backend (shortcutJump mishandled infinite loops) - Fixed yet another wrong calling convention -- primops take args only in vanilla regs, but they may return results on the stack! - Removed StackInfo from LGraph and Block -- now in LastCall and CmmZ - Updated avail-variable and liveness code