summaryrefslogtreecommitdiff
path: root/ghc/compiler/nativeGen/PprMach.hs
Commit message (Collapse)AuthorAgeFilesLines
* Reorganisation of the source treeSimon Marlow2006-04-071-2454/+0
| | | | | | | | | | | | | | | Most of the other users of the fptools build system have migrated to Cabal, and with the move to darcs we can now flatten the source tree without losing history, so here goes. The main change is that the ghc/ subdir is gone, and most of what it contained is now at the top level. The build system now makes no pretense at being multi-project, it is just the GHC build system. No doubt this will break many things, and there will be a period of instability while we fix the dependencies. A straightforward build should work, but I haven't yet fixed binary/source distributions. Changes to the Building Guide will follow, too.
* Darwin/x86: Print 64-bit literals in a way Apple understands.wolfgang.thaller@gmx.net2006-02-051-1/+9
|
* [project @ 2006-01-06 16:30:17 by simonmar]simonmar2006-01-061-9/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add support for UTF-8 source files GHC finally has support for full Unicode in source files. Source files are now assumed to be UTF-8 encoded, and the full range of Unicode characters can be used, with classifications recognised using the implementation from Data.Char. This incedentally means that only the stage2 compiler will recognise Unicode in source files, because I was too lazy to port the unicode classifier code into libcompat. Additionally, the following synonyms for keywords are now recognised: forall symbol (U+2200) forall right arrow (U+2192) -> left arrow (U+2190) <- horizontal ellipsis (U+22EF) .. there are probably more things we could add here. This will break some source files if Latin-1 characters are being used. In most cases this should result in a UTF-8 decoding error. Later on if we want to support more encodings (perhaps with a pragma to specify the encoding), I plan to do it by recoding into UTF-8 before parsing. Internally, there were some pretty big changes: - FastStrings are now stored in UTF-8 - Z-encoding has been moved right to the back end. Previously we used to Z-encode every identifier on the way in for simplicity, and only decode when we needed to show something to the user. Instead, we now keep every string in its UTF-8 encoding, and Z-encode right before printing it out. To avoid Z-encoding the same string multiple times, the Z-encoding is cached inside the FastString the first time it is requested. This speeds up the compiler - I've measured some definite improvement in parsing at least, and I expect compilations overall to be faster too. It also cleans up a lot of cruft from the OccName interface. Z-encoding is nicely hidden inside the Outputable instance for Names & OccNames now. - StringBuffers are UTF-8 too, and are now represented as ForeignPtrs. - I've put together some test cases, not by any means exhaustive, but there are some interesting UTF-8 decoding error cases that aren't obvious. Also, take a look at unicode001.hs for a demo.
* [project @ 2005-07-21 10:46:12 by simonmar]simonmar2005-07-211-48/+49
| | | | Sparc updates from Peter A Jonsson <pj at ludd.ltu.se>
* [project @ 2005-06-09 05:55:40 by wolfgang]wolfgang2005-06-091-7/+26
| | | | | | | | Registerised support for Darwin/x86, both NCG and mangled. *) -fPIC doesn't work yet with -fvia-C. *) Apple officially requires the stack to be 16-byte-aligned, GHC ignores this for now.
* [project @ 2005-04-27 09:57:14 by simonmar]simonmar2005-04-271-2/+2
| | | | | x86_64: hang register parameters off the call instruction, like powerpc does. This gives the register allocator better information.
* [project @ 2005-04-08 10:04:26 by simonmar]simonmar2005-04-081-2/+2
| | | | fix breakage in i386 native codegen
* [project @ 2005-04-08 09:54:54 by simonmar]simonmar2005-04-081-10/+16
| | | | | | | | | | | x86_64 hacking: - use %rip-relative addressing in a couple of places - floating-point comparisons handle NaN properly I believe the x86_64 NCG is now ready for prime time. It is successfully bootstrapping the compiler, and I think this fixes the last of the test failures.
* [project @ 2005-04-05 09:45:06 by simonmar]simonmar2005-04-051-11/+28
| | | | | | | | x86_64: generate 32-bit relative offset plus 32-bit padding instead of a 64-bit relative offset. This is probably not the best place to do it, but it'll do for now. Also reinstate some changes that accidentally got spammed yesterday.
* [project @ 2005-04-04 15:54:18 by simonmar]simonmar2005-04-041-24/+6
| | | | | | | Use the imul instruction natively, rather than the braindead wrapper around it. The register allocator has been able to handle the fixed register usage of imul for a while now. Also, the wrapper was broken on x86_64.
* [project @ 2005-04-03 22:01:32 by simonmar]simonmar2005-04-031-5/+6
| | | | x86_64: fix reg printing
* [project @ 2005-04-01 12:14:29 by simonmar]simonmar2005-04-011-63/+221
| | | | | | | | | | | | | | | | First cut at the x86_64 native code generator. Lots of code is shared with i386, but floating point uses SSE2. This more or less works, the things I know that don't work are: - the floating-point primitives (sin, cos etc.) are missing - floating-point comparisons involving NaN are wrong - there's no PIC support yet Also, I have a long list of small things to fix up to improve performance. I think the small memory model is assumed, for now.
* [project @ 2005-03-18 13:37:27 by simonmar]simonmar2005-03-181-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Flags cleanup. Basically the purpose of this commit is to move more of the compiler's global state into DynFlags, which is moving in the direction we need to go for the GHC API which can have multiple active sessions supported by a single GHC instance. Before: $ grep 'global_var' */*hs | wc -l 78 After: $ grep 'global_var' */*hs | wc -l 27 Well, it's an improvement. Most of what's left won't really affect our ability to host multiple sessions. Lots of static flags have become dynamic flags (yay!). Notably lots of flags that we used to think of as "driver" flags, like -I and -L, are now dynamic. The most notable static flags left behind are the "way" flags, eg. -prof. It would be nice to fix this, but it isn't urgent. On the way, lots of cleanup has happened. Everything related to static and dynamic flags lives in StaticFlags and DynFlags respectively, and they share a common command-line parser library in CmdLineParser. The flags related to modes (--makde, --interactive etc.) are now private to the front end: in fact private to Main itself, for now.
* [project @ 2005-01-23 18:50:40 by wolfgang]wolfgang2005-01-231-10/+9
| | | | | | | | | | Make the NCG distinguish between the read-only data section and the "relocatable read-only data" section. Read-only data is supposed to be _really_ read-only, whereas "relrodata" can have relocations, but should not be modified by the program at runtime. For Linux, put relrodata into ".data" by default, as the dynamic linker tends to do evil things to avoid relocating things in read-only sections.
* [project @ 2005-01-23 06:10:15 by wolfgang]wolfgang2005-01-231-3/+26
| | | | | | | | | | | | | | | | | | | | | | | Add support for the dead code stripping feature of recent Apple linkers. If your code is compiled using the NCG, you can now specify -optl-W,-dead_strip on the GHC command line when linking. It will have basically the same effect as using split-objs to build the libraries. Advantages over split-objs: * No evil perl script involved * Requires no special handling when building libraries Disadvantages: * The current version of Apple's linker is slow when given the -dead_strip flag. _REALLY_ slow. * Mac OS X only. This works by making the NCG emit the .subsections_via_symbols directive. Additionally, we have to add an extra label at the top of every info table, and make sure that the entry code references it (otherwise the info table will be considered part of the preceding entry code). The mangler just removes the .subsections_via_symbols directive.
* [project @ 2005-01-16 05:31:39 by wolfgang]wolfgang2005-01-161-0/+6
| | | | | | | | | | | | A first stab at position independent code generation for i386-linux. It doesn't work yet, but it shouldn't break anything. What we need now is one or both of the following: a) A volunteer to implement PIC for x86 -fvia-C (I definitely refuse to touch any piece of code that contains both Perl and x86 assembly). b) A volunteer to improve the NCG to the point where it can compile the RTS (so we won't need point a).
* [project @ 2005-01-14 22:12:54 by wolfgang]wolfgang2005-01-141-1/+10
| | | | | | | | | | | | | | | | | When -dynamic is specified but -fPIC is not, generate code that works around the ELF dynamic linker's misguided attempts to keep the main program unaware of dynamic linking. This involves generating indirect references and computed jumps for position dependent code, too, and making all constant data sections writable in order to persuade ld to not use "COPY" relocations. Tested on powerpc-linux; in theory, it also applies to i386-linux, but other parts of the PIC story are missing there. Note that the writable-const-data hack could be improved a bit by distinguishing between "really" constant data and "relocatable" constant data, which would be a nice thing to do anyway.
* [project @ 2004-10-07 15:54:03 by wolfgang]wolfgang2004-10-071-51/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Position Independent Code and Dynamic Linking Support, Part 1 This commit allows generation of position independent code (PIC) that fully supports dynamic linking on Mac OS X and PowerPC Linux. Other platforms are not yet supported, and there is no support for actually linking or using dynamic libraries - so if you use the -fPIC or -dynamic code generation flags, you have to type your (platform-specific) linker command lines yourself. nativeGen/PositionIndependentCode.hs: New file. Look here for some more comments on how this works. cmm/CLabel.hs: Add support for DynamicLinkerLabels and PIC base labels - for use inside the NCG. needsCDecl: Case alternative labels now need C decls, see the codeGen/CgInfoTbls.hs below for details cmm/Cmm.hs: Add CmmPicBaseReg (used in NCG), and CmmLabelDiffOff (used in NCG and for offsets in info tables) cmm/CmmParse.y: support offsets in info tables cmm/PprC.hs: support CmmLabelDiffOff Case alternative labels now need C decls (see the codeGen/CgInfoTbls.hs for details), so we need to pprDataExterns for info tables. cmm/PprCmm.hs: support CmmLabelDiffOff codeGen/CgInfoTbls.hs: no longer store absolute addresses in info tables, instead, we store offsets. Also, for vectored return points, emit the alternatives _after_ the vector table. This is to work around a limitation in Apple's as, which refuses to handle label differences where one label is at the end of a section. Emitting alternatives after vector info tables makes sure this never happens in GHC generated code. Case alternatives now require prototypes in hc code, though (see changes in PprC.hs, CLabel.hs). main/CmdLineOpts.lhs: Add a new option, -fPIC. main/DriverFlags.hs: Pass the correct options for PIC to gcc, depending on the platform. Only for powerpc for now. nativeGen/AsmCodeGen.hs: Many changes... Mac OS X-specific management of import stubs is no longer, it's now part of a general mechanism to handle such things for all platforms that need it (Darwin [both ppc and x86], Linux on ppc, and some platforms we don't support). Move cmmToCmm into its own monad which can accumulate a list of imported symbols. Make it call cmmMakeDynamicReference at the right places. nativeGen/MachCodeGen.hs: nativeGen/MachInstrs.hs: nativeGen/MachRegs.lhs: nativeGen/PprMach.hs: nativeGen/RegAllocInfo.hs: Too many changes to enumerate here, PowerPC specific. nativeGen/NCGMonad.hs: NatM still tracks imported symbols, as more labels can be created during code generation (float literals, jump tables; on some platforms all data access has to go through the dynamic linking mechanism). driver/mangler/ghc-asm.lprl: Mangle absolute addresses in info tables to offsets. Correctly pass through GCC-generated PIC for Mac OS X and powerpc linux. includes/Cmm.h: includes/InfoTables.h: includes/Storage.h: includes/mkDerivedConstants.c: rts/GC.c: rts/GCCompact.c: rts/HeapStackCheck.cmm: rts/Printer.c: rts/RetainerProfile.c: rts/Sanity.c: Adapt to the fact that info tables now contain offsets. rts/Linker.c: Mac-specific: change machoInitSymbolsWithoutUnderscore to support PIC.
* [project @ 2004-08-13 13:04:50 by simonmar]simonmar2004-08-131-0/+2257
Merge backend-hacking-branch onto HEAD. Yay!