summaryrefslogtreecommitdiff
path: root/compiler/nativeGen/MachCodeGen.hs
Commit message (Collapse)AuthorAgeFilesLines
* NCG: Split up the native code generator into arch specific modulesBen.Lippmeier@anu.edu.au2009-02-151-5199/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | - nativeGen/Instruction defines a type class for a generic instruction set. Each of the instruction sets we have, X86, PPC and SPARC are instances of it. - The register alloctors use this type class when they need info about a certain register or instruction, such as regUsage, mkSpillInstr, mkJumpInstr, patchRegs.. - nativeGen/Platform defines some data types enumerating the architectures and operating systems supported by the native code generator. - DynFlags now keeps track of the current build platform, and the PositionIndependentCode module uses this to decide what to do instead of relying of #ifdefs. - It's not totally retargetable yet. Some info info about the build target is still hardwired, but I've tried to contain most of it to a single module, TargetRegs. - Moved the SPILL and RELOAD instructions into LiveInstr. - Reg and RegClass now have their own modules, and are shared across all architectures.
* When generating C, don't pretend functions are dataIan Lynagh2009-02-061-3/+4
| | | | | | | | | | | | | | | We used to generated things like: extern StgWordArray (newCAF) __attribute__((aligned (8))); ((void (*)(void *))(W_)&newCAF)((void *)R1.w); (which is to say, pretend that newCAF is some data, then cast it to a function and call it). This goes wrong on at least IA64, where: A function pointer on the ia64 does not point to the first byte of code. Intsead, it points to a structure that describes the function. The first quadword in the structure is the address of the first byte of code so we end up dereferencing function pointers one time too many, and segfaulting.
* NCG: Rename MachRegs, MachInstrs -> Regs, Instrs to reflect arch specific namingBen.Lippmeier@anu.edu.au2009-02-041-4/+3
|
* SPARC NCG: Add Pwr callish mach opBen.Lippmeier@anu.edu.au2009-02-041-0/+2
|
* SPARC NCG: Keep track of destinations when doing a tabled jumpBen.Lippmeier@anu.edu.au2009-01-231-2/+2
|
* SPARC NCG: Do general 64 bit addition and conversionBen.Lippmeier@anu.edu.au2009-01-231-0/+37
|
* SPARC NCG: Don't need a write barrier for store synchronisation on SPARC ↵Ben.Lippmeier@anu.edu.au2009-01-231-0/+10
| | | | under TSO.
* Fix #2961: we lost some of the generated code for stack args in genCCallSimon Marlow2009-01-261-2/+3
| | | | | | | | | A real bug in the x86_64 native code gen: nice! This bug would have been caught by -Wall, and I would have gone though and Walled this file but I know Ben is hacking on this file quite heavily and I don't want to create undue conflicts. Ben: it would be nice to enable -Wall here when you have time.
* SPARC NCG: Reenable out of line 32 bit float opsBen.Lippmeier@anu.edu.au2009-01-211-33/+33
|
* SPARC NCG: Clean up formatting and add comments in genCCallBen.Lippmeier@anu.edu.au2009-01-211-170/+226
|
* SPARC NCG: Fix format problem when converting float to intBen.Lippmeier@anu.edu.au2009-01-211-14/+26
|
* SPARC NCG: fill branch delay slot after tabled jump (doh!)Ben.Lippmeier@anu.edu.au2009-01-211-1/+2
|
* SPARC NCG: Add tabled switchBen.Lippmeier@anu.edu.au2009-01-201-4/+31
|
* SPARC NCG: Fix 64bit integers returned from ccallsBen.Lippmeier@anu.edu.au2009-01-201-2/+4
|
* SPARC NCG: Fix warningsBen.Lippmeier@anu.edu.au2009-01-201-0/+4
|
* SPARC NCG: Fix generation of 64 bit ops on 32 bit sparcBen.Lippmeier@anu.edu.au2009-01-201-21/+54
|
* SPARC NCG: Add support for hardware divideBen.Lippmeier@anu.edu.au2009-01-201-9/+114
|
* SPARC NCG: Redo code for integer sign extensionBen.Lippmeier@anu.edu.au2009-01-151-15/+38
|
* More fixes to the SPARC native code generatorBen.Lippmeier@anu.edu.au2009-01-151-9/+9
| | | | | * Fix loading of 64bit floats * Put SRT and other read only static data in the .text segment
* Start fixing the SPARC native code generatorBen.Lippmeier@anu.edu.au2009-01-141-20/+48
| | | | | | | * Use BlockIds in branch instructions instead of Imms. * Assign FP values returned from C calls to the right regs * Fix loading of F32s * Add a SPARC version of the FreeRegs map to the linear allcator.
* Fix some holes in the SPARC native code generator.Ben.Lippmeier@anu.edu.au2009-01-121-5/+19
| | | | This makes about half the tests in codeGen/should_run work.
* Make the SPARC NCG compile again - it's still broken though.Ben.Lippmeier@anu.edu.au2009-01-101-30/+42
|
* Merging in the new codegen branchdias@eecs.harvard.edu2008-08-141-799/+774
| | | | | | | | | | | | | | | | | | This merge does not turn on the new codegen (which only compiles a select few programs at this point), but it does introduce some changes to the old code generator. The high bits: 1. The Rep Swamp patch is finally here. The highlight is that the representation of types at the machine level has changed. Consequently, this patch contains updates across several back ends. 2. The new Stg -> Cmm path is here, although it appears to have a fair number of bugs lurking. 3. Many improvements along the CmmCPSZ path, including: o stack layout o some code for infotables, half of which is right and half wrong o proc-point splitting
* FIX #2388: check that the operand fits before using the 'test' opcodeSimon Marlow2008-07-301-1/+1
|
* oops, fix a small pessimisation made in previous refactoringSimon Marlow2008-07-301-1/+1
|
* refactoring/tidyup: (not.is64BitInteger) -> is32BitIntegerSimon Marlow2008-07-221-18/+18
|
* Replacing copyins and copyouts with data-movement instructionsdias@eecs.harvard.edu2008-05-291-0/+1
| | | | | | | | | | | | | | o Moved BlockId stuff to a new file to avoid module recursion o Defined stack areas for parameter-passing locations and spill slots o Part way through replacing copy in and copy out nodes - added movement instructions for stack pointer - added movement instructions for call and return parameters (but not with the proper calling conventions) o Inserting spills and reloads for proc points is now procpoint-aware (it was relying on the presence of a CopyIn node as a proxy for procpoint knowledge) o Changed ZipDataflow to expect AGraphs (instead of being polymorphic in the type of graph)
* Cmm back end upgradesdias@eecs.harvard.edu2008-05-291-0/+2
| | | | | | | | | | | | | | | | | | | | | Several changes in this patch, partially bug fixes, partially new code: o bug fixes in ZipDataflow - added some checks to verify that facts converge - removed some erroneous checks of convergence on entry nodes - added some missing applications of transfer functions o changed dataflow clients to use ZipDataflow, making ZipDataflow0 obsolete o eliminated DFA monad (no need for separate analysis and rewriting monads with ZipDataflow) o started stack layout changes - no longer generating CopyIn and CopyOut nodes (not yet fully expunged though) - still not using proper calling conventions o simple new optimizations: - common block elimination -- have not yet tried to move the Adams opt out of CmmProcPointZ - block concatenation o piped optimization fuel up to the HscEnv - can be limited by a command-line flag - not tested, and probably not yet properly used by clients o added unique supply to FuelMonad, also lifted unique supply to DFMonad
* Fix sin/cos/tan on x86; trac #2059Ian Lynagh2008-05-031-6/+8
| | | | | If the value is > 2^63 then we need to work out its value mod 2pi, and apply the operation to that instead.
* replace Cmm 'hint' with 'kind'Norman Ramsey2008-05-031-18/+18
| | | | | | C-- no longer has 'hints'; to guide parameter passing, it has 'kinds'. Renamed type constructor, data constructor, and record fields accordingly
* (F)SLIT -> (f)sLit in MachCodeGenIan Lynagh2008-04-121-113/+113
|
* Remove some redundant importsIan Lynagh2008-03-291-4/+0
|
* Make more arch-specific #if's exclusive with #else #error casesDuncan Coutts2008-02-071-3/+3
| | | | | | | | | | | | | So when the next person compiles the Sparc NCG it should fail more obviously at compile time rather than panicing at runtime. Plus one obvious fix for LocalReg gaining an extra param Missing bits of Sparc NCG: * genSwitch for generating jump tables. This is the most tricky one. * ALLOCATABLE_REGS_INTEGER and ALLOCATABLE_REGS_DOUBLE just requires finding and verifying the values. The nearby comment describes how. * isRegRegMove and mkRegRegMoveInstr. Sparc uses Or for int move, check what this is supposed to do for single and double float types. * regDotColor. Probably just copy the ppc impl.
* remove a bogus assertionSimon Marlow2008-02-071-2/+1
|
* Fix warnings in utils/FastTypesIan Lynagh2008-01-131-1/+1
| | | | Split off a FastBool module, to avoid a circular import with Panic
* change CmmActual, CmmFormal to use a data CmmHinted rather than tuple (#1405)Isaac Dupree2008-01-041-18/+19
| | | | | | | This allows the instance of UserOfLocalRegs to be within Haskell98, and IMHO makes the code a little cleaner generally. This is one small (though tedious) step towards making GHC's code more portable...
* FIX #1843: Generate different instructions on PPCIan Lynagh2007-12-031-2/+2
| | | | | | The old ones caused lots of unknown scattered relocation type 4 errors. Patch from Chris Kuklewicz.
* Move OPTIONS pragmas above commentsIan Lynagh2007-09-211-7/+7
| | | | Fixes building with -Werror (i.e. validate) and GHC < 6.6
* Sign extension hack to work around PC64 relocation limitation for binutils ↵Clemens Fruhwirth2007-09-121-1/+19
| | | | | | | | | | | | | | <2.17 for x86_64. binutils <2.17 can't generate PC64 relocations for x86_64. Hence we emit only 32 bit PC relative offsets, and artifically stick a zero in front of them to make them 64 bit (see PprMach.sh ppr_item in pprDataItem). This works as long as the offset is <32bit AND it's positive. This is not the case for offsets in jump tables, they are all negative. This hack sign extends them with a MOVSXL instruction into the dead index register, then adding the properly sign extended offset to the jump table base label giving the correct target address for the following jump.
* a good deal of salutory renamingNorman Ramsey2007-09-071-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I've renamed a number of type and data constructors within Cmm so that the names used in the compiler may more closely reflect the C-- specification 2.1. I've done a bit of other renaming as well. Highlights: CmmFormal and CmmActual now bear a CmmKind (which for now is a MachHint as before) CmmFormals = [CmmFormal] and CmmActuals = [CmmActual] suitable changes have been made to both code and nonterminals in the Cmm parser (which is as yet untested) For reasons I don't understand, parts of the code generator use a sequence of 'formal parameters' with no C-- kinds. For these we now have the types type CmmFormalWithoutKind = LocalReg type CmmFormalsWithoutKinds = [CmmFormalWithoutKind] A great many appearances of (Tau, MachHint) have been simplified to the appropriate CmmFormal or CmmActual, though I'm sure there are more opportunities. Kind and its data constructors are now renamed to data GCKind = GCKindPtr | GCKindNonPtr to avoid confusion with the Kind used in the type checker and with CmmKind. Finally, in a somewhat unrelated bit (and in honor of Simon PJ, who thought of the name), the Whalley/Davidson 'transaction limit' is now called 'OptimizationFuel' with the net effect that there are no longer two unrelated uses of the abbreviation 'tx'.
* change of representation for GenCmm, GenCmmTop, CmmProcNorman Ramsey2007-09-051-2/+2
| | | | | | | | | The type parameter to a C-- procedure now represents a control-flow graph, not a single instruction. The newtype ListGraph preserves the current representation while enabling other representations and a sensible way of prettyprinting. Except for a few changes in the prettyprinter the new compiler binary should be bit-for-bit identical to the old.
* Fix CodingStyle#Warnings URLsIan Lynagh2007-09-041-1/+1
|
* Use OPTIONS rather than OPTIONS_GHC for pragmasIan Lynagh2007-09-031-2/+2
| | | | | | | Older GHCs can't parse OPTIONS_GHC. This also changes the URL referenced for the -w options from WorkingConventions#Warnings to CodingStyle#Warnings for the compiler modules.
* Add {-# OPTIONS_GHC -w #-} and some blurb to all compiler modulesIan Lynagh2007-09-011-0/+7
|
* put CmmReturnInfo into a CmmCall (and related types)Norman Ramsey2007-08-201-3/+3
|
* Rename a constructor CmmForeignCall to CmmCallee, and tidy Cmm codesimonpj@microsoft.com2007-08-091-9/+9
| | | | | | This patch should have no effect; it's mainly comments, layout, plus this contructor name change.
* Change the strategy to determine dynamic data accessClemens Fruhwirth2007-07-311-9/+20
| | | | | | | | | | | | | Instead of attaching the information whether a Label is going to be accessed dynamically or not (distinction between IdLabel/DynLabel and additional flags in ModuleInitLabel and PlainModuleInitLabel), we hand dflags through the CmmOpt monad and the NatM monad. Before calling labelDynamic in PositionIndependentCode, we extract thisPackage from dflags and supply the current package to labelDynamic, so it can take this information into account instead of extracting it from the labels itself. This simplifies a lot of code in codeGen that just hands through this_pkg.
* Pointer TaggingSimon Marlow2007-07-271-0/+12
| | | | | | | | | | | | | | | | | | | | | | This patch implements pointer tagging as per our ICFP'07 paper "Faster laziness using dynamic pointer tagging". It improves performance by 10-15% for most workloads, including GHC itself. The original patches were by Alexey Rodriguez Yakushev <mrchebas@gmail.com>, with additions and improvements by me. I've re-recorded the development as a single patch. The basic idea is this: we use the low 2 bits of a pointer to a heap object (3 bits on a 64-bit architecture) to encode some information about the object pointed to. For a constructor, we encode the "tag" of the constructor (e.g. True vs. False), for a function closure its arity. This enables some decisions to be made without dereferencing the pointer, which speeds up some common operations. In particular it enables us to avoid costly indirect jumps in many cases. More information in the commentary: http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/HaskellExecution/PointerTagging
* FIX rts build failure for powerPC buildandy@galois.com2007-07-101-0/+7
| | | | | | | | | | | | The rts was failing with ../compiler/ghc-inplace -H64m -Onot -fasm -optc-O2 -static -I../gmp/gmpbuild -I. -#include HCIncludes.h -dcmm-lint -hisuf thr_p_hi -hcsuf thr_p_hc -osuf thr_p_o -optc-DTHREADED_RTS -prof -#include posix/Itimer.h -c PrimOps.cmm -o PrimOps.thr_p_o ghc-6.7.20070709: panic! (the 'impossible' happened) (GHC version 6.7.20070709 for powerpc-apple-darwin): iselExpr64(powerpc) %MO_U_Conv_I32_I64(16 / 4 - 2) There was a special case for x86; so it has been transliterated to the PPC, and the output code looks plausable.
* Fixing native code generator for PowerPCandy@galois.com2007-07-081-4/+4
|