summaryrefslogtreecommitdiff
path: root/ghc/compiler/nativeGen/StixPrim.lhs
Commit message (Collapse)AuthorAgeFilesLines
* [project @ 2004-08-13 13:04:50 by simonmar]simonmar2004-08-131-306/+0
| | | | Merge backend-hacking-branch onto HEAD. Yay!
* [project @ 2003-12-10 14:15:16 by simonmar]simonmar2003-12-101-2/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add accurate source location annotations to HsSyn ------------------------------------------------- Every syntactic entity in HsSyn is now annotated with a SrcSpan, which details the exact beginning and end points of that entity in the original source file. All honest compilers should do this, and it was about time GHC did the right thing. The most obvious benefit is that we now have much more accurate error messages; when running GHC inside emacs for example, the cursor will jump to the exact location of an error, not just a line somewhere nearby. We haven't put a huge amount of effort into making sure all the error messages are accurate yet, so there could be some tweaking still needed, although the majority of messages I've seen have been spot-on. Error messages now contain a column number in addition to the line number, eg. read001.hs:25:10: Variable not in scope: `+#' To get the full text span info, use the new option -ferror-spans. eg. read001.hs:25:10-11: Variable not in scope: `+#' I'm not sure whether we should do this by default. Emacs won't understand the new error format, for one thing. In a more elaborate editor setting (eg. Visual Studio), we can arrange to actually highlight the subexpression containing an error. Eventually this information will be used so we can find elements in the abstract syntax corresponding to text locations, for performing high-level editor functions (eg. "tell me the type of this expression I just highlighted"). Performance of the compiler doesn't seem to be adversely affected. Parsing is still quicker than in 6.0.1, for example. Implementation: This was an excrutiatingly painful change to make: both Simon P.J. and myself have been working on it for the last three weeks or so. The basic changes are: - a new datatype SrcSpan, which represents a beginning and end position in a source file. - To reduce the pain as much as possible, we also defined: data Located e = L SrcSpan e - Every datatype in HsSyn has an equivalent Located version. eg. type LHsExpr id = Located (HsExpr id) and pretty much everywhere we used to use HsExpr we now use LHsExpr. Believe me, we thought about this long and hard, and all the other options were worse :-) Additional changes/cleanups we made at the same time: - The abstract syntax for bindings is now less arcane. MonoBinds and HsBinds with their built-in list constructors have gone away, replaced by HsBindGroup and HsBind (see HsSyn/HsBinds.lhs). - The various HsSyn type synonyms have now gone away (eg. RdrNameHsExpr, RenamedHsExpr, and TypecheckedHsExpr are now HsExpr RdrName, HsExpr Name, and HsExpr Id respectively). - Utilities over HsSyn are now collected in a new module HsUtils. More stuff still needs to be moved in here. - MachChar now has a real Char instead of an Int. All GHC versions that can compile GHC now support 32-bit Chars, so this was a simplification.
* [project @ 2003-10-09 11:58:39 by simonpj]simonpj2003-10-091-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------- GHC heart/lung transplant ------------------------- This major commit changes the way that GHC deals with importing types and functions defined in other modules, during renaming and typechecking. On the way I've changed or cleaned up numerous other things, including many that I probably fail to mention here. Major benefit: GHC should suck in many fewer interface files when compiling (esp with -O). (You can see this with -ddump-rn-stats.) It's also some 1500 lines of code shorter than before. ** So expect bugs! I can do a 3-stage bootstrap, and run ** the test suite, but you may be doing stuff I havn't tested. ** Don't update if you are relying on a working HEAD. In particular, (a) External Core and (b) GHCi are very little tested. But please, please DO test this version! ------------------------ Big things ------------------------ Interface files, version control, and importing declarations ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * There is a totally new data type for stuff that lives in interface files: Original names IfaceType.IfaceExtName Types IfaceType.IfaceType Declarations (type,class,id) IfaceSyn.IfaceDecl Unfoldings IfaceSyn.IfaceExpr (Previously we used HsSyn for type/class decls, and UfExpr for unfoldings.) The new data types are in iface/IfaceType and iface/IfaceSyn. They are all instances of Binary, so they can be written into interface files. Previous engronkulation concering the binary instance of RdrName has gone away -- RdrName is not an instance of Binary any more. Nor does Binary.lhs need to know about the ``current module'' which it used to, which made it specialised to GHC. A good feature of this is that the type checker for source code doesn't need to worry about the possibility that we might be typechecking interface file stuff. Nor does it need to do renaming; we can typecheck direct from IfaceSyn, saving a whole pass (module TcIface) * Stuff from interface files is sucked in *lazily*, rather than being eagerly sucked in by the renamer. Instead, we use unsafeInterleaveIO to capture a thunk for the unfolding of an imported function (say). If that unfolding is every pulled on, TcIface will scramble over the unfolding, which may in turn pull in the interface files of things mentioned in the unfolding. The External Package State is held in a mutable variable so that it can be side-effected by this lazy-sucking-in process (which may happen way later, e.g. when the simplifier runs). In effect, the EPS is a kind of lazy memo table, filled in as we suck things in. Or you could think of it as a global symbol table, populated on demand. * This lazy sucking is very cool, but it can lead to truly awful bugs. The intent is that updates to the symbol table happen atomically, but very bad things happen if you read the variable for the table, and then force a thunk which updates the table. Updates can get lost that way. I regret this subtlety. One example of the way it showed up is that the top level of TidyPgm (which updates the global name cache) to be much more disciplined about those updates, since TidyPgm may itself force thunks which allocate new names. * Version numbering in interface files has changed completely, fixing one major bug with ghc --make. Previously, the version of A.f changed only if A.f's type and unfolding was textually different. That missed changes to things that A.f's unfolding mentions; which was fixed by eagerly sucking in all of those things, and listing them in the module's usage list. But that didn't work with --make, because they might have been already sucked in. Now, A.f's version changes if anything reachable from A.f (via interface files) changes. A module with unchanged source code needs recompiling only if the versions of any of its free variables changes. [This isn't quite right for dictionary functions and rules, which aren't mentioned explicitly in the source. There are extensive comments in module MkIface, where all version-handling stuff is done.] * We don't need equality on HsDecls any more (because they aren't used in interface files). Instead we have a specialised equality for IfaceSyn (eqIfDecl etc), which uses IfaceEq instead of Bool as its result type. See notes in IfaceSyn. * The horrid bit of the renamer that tried to predict what instance decls would be needed has gone entirely. Instead, the type checker simply sucks in whatever instance decls it needs, when it needs them. Easy! Similarly, no need for 'implicitModuleFVs' and 'implicitTemplateHaskellFVs' etc. Hooray! Types and type checking ~~~~~~~~~~~~~~~~~~~~~~~ * Kind-checking of types is far far tidier (new module TcHsTypes replaces the badly-named TcMonoType). Strangely, this was one of my original goals, because the kind check for types is the Right Place to do type splicing, but it just didn't fit there before. * There's a new representation for newtypes in TypeRep.lhs. Previously they were represented using "SourceTypes" which was a funny compromise. Now they have their own constructor in the Type datatype. SourceType has turned back into PredType, which is what it used to be. * Instance decl overlap checking done lazily. Consider instance C Int b instance C a Int These were rejected before as overlapping, because when seeking (C Int Int) one couldn't tell which to use. But there's no problem when seeking (C Bool Int); it can only be the second. So instead of checking for overlap when adding a new instance declaration, we check for overlap when looking up an Inst. If we find more than one matching instance, we see if any of the candidates dominates the others (in the sense of being a substitution instance of all the others); and only if not do we report an error. ------------------------ Medium things ------------------------ * The TcRn monad is generalised a bit further. It's now based on utils/IOEnv.lhs, the IO monad with an environment. The desugarer uses the monad too, so that anything it needs can get faulted in nicely. * Reduce the number of wired-in things; in particular Word and Integer are no longer wired in. The latter required HsLit.HsInteger to get a Type argument. The 'derivable type classes' data types (:+:, :*: etc) are not wired in any more either (see stuff about derivable type classes below). * The PersistentComilerState is now held in a mutable variable in the HscEnv. Previously (a) it was passed to and then returned by many top-level functions, which was painful; (b) it was invariably accompanied by the HscEnv. This change tidies up top-level plumbing without changing anything important. * Derivable type classes are treated much more like 'deriving' clauses. Previously, the Ids for the to/from functions lived inside the TyCon, but now the TyCon simply records their existence (with a simple boolean). Anyone who wants to use them must look them up in the environment. This in turn makes it easy to generate the to/from functions (done in types/Generics) using HsSyn (like TcGenDeriv for ordinary derivings) instead of CoreSyn, which in turn means that (a) we don't have to figure out all the type arguments etc; and (b) it'll be type-checked for us. Generally, the task of generating the code has become easier, which is good for Manuel, who wants to make it more sophisticated. * A Name now says what its "parent" is. For example, the parent of a data constructor is its type constructor; the parent of a class op is its class. This relationship corresponds exactly to the Avail data type; there may be other places we can exploit it. (I made the change so that version comparison in interface files would be a bit easier; but in fact it tided up other things here and there (see calls to Name.nameParent). For example, the declaration pool, of declararations read from interface files, but not yet used, is now keyed only by the 'main' name of the declaration, not the subordinate names. * New types OccEnv and OccSet, with the usual operations. OccNames can be efficiently compared, because they have uniques, thanks to the hashing implementation of FastStrings. * The GlobalRdrEnv is now keyed by OccName rather than RdrName. Not only does this halve the size of the env (because we don't need both qualified and unqualified versions in the env), but it's also more efficient because we can use a UniqFM instead of a FiniteMap. Consequential changes to Provenance, which has moved to RdrName. * External Core remains a bit of a hack, as it was before, done with a mixture of HsDecls (so that recursiveness and argument variance is still inferred), and IfaceExprs (for value declarations). It's not thoroughly tested. ------------------------ Minor things ------------------------ * DataCon fields dcWorkId, dcWrapId combined into a single field dcIds, that is explicit about whether the data con is a newtype or not. MkId.mkDataConWorkId and mkDataConWrapId are similarly combined into MkId.mkDataConIds * Choosing the boxing strategy is done for *source* type decls only, and hence is now in TcTyDecls, not DataCon. * WiredIn names are distinguished by their n_sort field, not by their location, which was rather strange * Define Maybes.mapCatMaybes :: (a -> Maybe b) -> [a] -> [b] and use it here and there * Much better pretty-printing of interface files (--show-iface) Many, many other small things. ------------------------ File changes ------------------------ * New iface/ subdirectory * Much of RnEnv has moved to iface/IfaceEnv * MkIface and BinIface have moved from main/ to iface/ * types/Variance has been absorbed into typecheck/TcTyDecls * RnHiFiles and RnIfaces have vanished entirely. Their work is done by iface/LoadIface * hsSyn/HsCore has gone, replaced by iface/IfaceSyn * typecheck/TcIfaceSig has gone, replaced by iface/TcIface * typecheck/TcMonoType has been renamed to typecheck/TcHsType * basicTypes/Var.hi-boot and basicTypes/Generics.hi-boot have gone altogether
* [project @ 2003-09-16 13:03:37 by simonmar]simonmar2003-09-161-11/+1
| | | | | | | | | | | | | Legacy Removal ~~~~~~~~~~~~~~ The following features have been consigned to the bit bucket: _ccall_ _casm_ ``....'' (lit-lits) the CCallable class the CReturnable class
* [project @ 2003-07-28 16:05:30 by simonmar]simonmar2003-07-281-4/+0
| | | | | | | | | | | Disable update-in-place. In its current form, it has a serious bug: if the thunk being updated happens to have turned into a BLACKHOLE_BQ, then the mutable list will be corrupted by the update. Disabling update-in-place has some performance implications: many programs are not affected, but one program in nofib (nucleic2) goes about 20% slower. However, I can get it to go 300% faster by adding a few strictness annotations and compiling with -funbox-strict-fields.
* [project @ 2003-06-02 13:27:33 by simonpj]simonpj2003-06-021-2/+1
| | | | Prune imports
* [project @ 2003-05-29 14:39:26 by sof]sof2003-05-291-0/+4
| | | | | | | | | | | | | | | | | | Support for interop'ing with .NET via FFI declarations along the lines of what Hugs98.NET offers, see http://haskell.org/pipermail/cvs-hugs/2003-March/001723.html for FFI decl details. To enable, configure with --enable-dotnet + have a look in ghc/rts/dotnet/Makefile for details of what tools are needed to build the .NET interop layer (tools from VS.NET / Framework SDK.) The commit doesn't include some library additions + wider-scale testing is required before this extension can be regarded as available for general use. 'foreign import dotnet' is currently only supported by the C backend.
* [project @ 2003-05-14 09:13:52 by simonmar]simonmar2003-05-141-3/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the way SRTs are represented: Previously, the SRT associated with a function or thunk would be a sub-list of the enclosing top-level function's SRT. But this approach can lead to lots of duplication: if a CAF is referenced in several different thunks, then it may appear several times in the SRT. Let-no-escapes compound the problem, because the occurrence of a let-no-escape-bound variable would expand to all the CAFs referred to by the let-no-escape. The new way is to describe the SRT associated with a function or thunk as a (pointer+offset,bitmap) pair, where the pointer+offset points into some SRT table (the enclosing function's SRT), and the bitmap indicates which entries in this table are "live" for this closure. The bitmap is stored in the 16 bits previously used for the length field, but this rarely overflows. When it does overflow, we store the bitmap externally in a new "SRT descriptor". Now the enclosing SRT can be a set, hence eliminating the duplicates. Also, we now have one SRT per top-level function in a recursive group, where previously we used to have one SRT for the whole group. This helps keep the size of SRTs down. Bottom line: very little difference most of the time. GHC itself got slightly smaller. One bad case of a module in GHC which had a huge SRT has gone away. While I was in the area: - Several parts of the back-end require bitmaps. Functions for creating bitmaps are now centralised in the Bitmap module. - We were trying to be independent of word-size in a couple of places in the back end, but we've now abandoned that strategy so I simplified things a bit.
* [project @ 2003-04-01 15:28:20 by sof]sof2003-04-011-1/+1
| | | | | | | | | | | | Have Literal.Literal support the representation of NULL pointers only, and not arbitrary pointer values. (MachAddr <some-pointer-value-as-an-Integer>) wasn't being used, except to handle nullAddr#. It (MachAddr) is a potential source of problems should the compiler start doing constant folding or other interesting operations over MachAddrs (think: interface files + cross-compilation), so we might as well scale back the representation of raw pointer values.
* [project @ 2003-03-27 17:59:09 by sof]sof2003-03-271-1/+4
| | | | | | | NCG support for f.e.d. stdcall -- Literal.MachLabels now optionally carry the size (in bytes) of the stack frame it expects, if known. That just so happens to match what stdcall labels need to be annotated with when emitting them in the NCG..
* [project @ 2002-12-11 15:36:20 by simonmar]simonmar2002-12-111-9/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Merge the eval-apply-branch on to the HEAD ------------------------------------------ This is a change to GHC's evaluation model in order to ultimately make GHC more portable and to reduce complexity in some areas. At some point we'll update the commentary to describe the new state of the RTS. Pending that, the highlights of this change are: - No more Su. The Su register is gone, update frames are one word smaller. - Slow-entry points and arg checks are gone. Unknown function calls are handled by automatically-generated RTS entry points (AutoApply.hc, generated by the program in utils/genapply). - The stack layout is stricter: there are no "pending arguments" on the stack any more, the stack is always strictly a sequence of stack frames. This means that there's no need for LOOKS_LIKE_GHC_INFO() or LOOKS_LIKE_STATIC_CLOSURE() any more, and GHC doesn't need to know how to find the boundary between the text and data segments (BIG WIN!). - A couple of nasty hacks in the mangler caused by the neet to identify closure ptrs vs. info tables have gone away. - Info tables are a bit more complicated. See InfoTables.h for the details. - As a side effect, GHCi can now deal with polymorphic seq. Some bugs in GHCi which affected primitives and unboxed tuples are now fixed. - Binary sizes are reduced by about 7% on x86. Performance is roughly similar, some programs get faster while some get slower. I've seen GHCi perform worse on some examples, but haven't investigated further yet (GHCi performance *should* be about the same or better in theory). - Internally the code generator is rather better organised. I've moved info-table generation from the NCG into the main codeGen where it is shared with the C back-end; info tables are now emitted as arrays of words in both back-ends. The NCG is one step closer to being able to support profiling. This has all been fairly thoroughly tested, but no doubt I've messed up the commit in some way.
* [project @ 2002-08-02 13:08:33 by simonmar]simonmar2002-08-021-22/+22
| | | | | | | | | | | | | | | | | | | | | PrimRep Cleanup - Remove all PrimReps which were just different flavours of PtrRep. Now, everything which is a pointer to a closure of some kind is always a PtrRep. - Three of the deleted PrimReps, namely ArrayRep, ByteArrayRep, and ForeignObj rep, had a subtle reason for their existence: the abstract C pretty-printer(!) used them to decide whether to apply a shim to an outgoing C-call argument: a ByteArrayRep argument would be adjusted to point past the object header, for example. I've changed this to happen in a much more reasonable and obvious way: there are now explict macros in AbsCSyn to do the adjustment, and the code generator makes calls to these as necessary. Slightly less hackery is necessary in the NCG as a result.
* [project @ 2002-04-29 14:03:38 by simonmar]simonmar2002-04-291-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | FastString cleanup, stage 1. The FastString type is no longer a mixture of hashed strings and literal strings, it contains hashed strings only with O(1) comparison (except for UnicodeStr, but that will also go away in due course). To create a literal instance of FastString, use FSLIT(".."). By far the most common use of the old literal version of FastString was in the pattern ptext SLIT("...") this combination still works, although it doesn't go via FastString any more. The next stage will be to remove the need to use this special combination at all, using a RULE. To convert a FastString into an SDoc, now use 'ftext' instead of 'ptext'. I've also removed all the FAST_STRING related macros from HsVersions.h except for SLIT and FSLIT, just use the relevant functions from FastString instead.
* [project @ 2002-04-05 23:24:25 by sof]sof2002-04-051-1/+2
| | | | Friday afternoon pet peeve removal: define (Util.notNull :: [a] -> Bool) and use it
* [project @ 2002-04-01 08:16:49 by simonpj]simonpj2002-04-011-2/+2
| | | | Import wibbles
* [project @ 2002-02-15 22:13:32 by sof]sof2002-02-151-6/+10
| | | | | | | | | | | | New call attribute on foreign imports, threadsafe. It indicates that a foreign import can(*) safely be called concurrently with the continued evaluation of other Haskell threads, i.e., when the foreign call is made by a Haskell thread, it won't hinder the progress of other threads. (*) - if the platform and RTS supports it, it _will be_ invoked concurrently.
* [project @ 2002-02-06 11:13:47 by sewardj]sewardj2002-02-061-2/+0
| | | | | | | | | | | | | | | | | | | | | | | | | Clean up the AbsC -> AbsC translation of array operations. * MachOps MO_ReadOSBI and MO_WriteOSBI, which previously did array indexing, are gone. We translate now just to plain memory references and explicit address computations. This has the happy side effect that all MachOps now return exactly one result (previously it was 0 or 1), cleaning up various bits of code. As a result the Abstract C structure now contains an unneccessary restriction, which is that the result of a MachOp can only be assigned to a temporary. This made sense when MachOps had variable numbers of results (0, 1 or 2, originally), but is no longer needed. MachOps applied to args could now be allowed to appear as arbitrary nodes in expression trees, but so far they are not. * Get rid of CAddrMode constructor CMem, since it is a special case of CVal with a RegRelative of CIndex. AbstractC is inconsistent and non-orthogonal. The StixStmt + StixExpr combination expresses a large part of what AbstractC does in a cleaner and simpler way, IMO.
* [project @ 2002-01-29 13:22:28 by sewardj]sewardj2002-01-291-10/+16
| | | | | Teach the NCG how to do f-i-dynamic. Nothing unexpected. sparc-side now needs fixing.
* [project @ 2002-01-08 10:36:24 by sewardj]sewardj2002-01-081-7/+19
| | | | | | | | | merge from the stable branch: 1.70.4.2 fptools/ghc/compiler/nativeGen/StixPrim.lhs 1.5.10.3 fptools/ghc/includes/mkNativeHdr.c Track recent changes to HpLim assignment in load_thread_state.
* [project @ 2001-12-10 18:04:51 by sewardj]sewardj2001-12-101-3/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add just enough infrastructure to the NCG that it can deal with simple 64-bit code on 32-bit platforms. Main changes are: * Addition of a simple 64-bit instruction selection fn iselExpr64 to MachCode. This generates code for a 64-bit value and places the results into two virtual registers, related thusly: * Add a new type VRegUnique, which is used to label Stix virtual registers. This type used to be a plain Unique, but that forces the assumption that each Abstract-C level C temporary corresponds to exactly one Stix virtual register, which is untrue when the C temporary is 64-bit sized on a 32-bit machine. In the new scheme, the Unique for the C temporary can turn into two related VRegUniques, related by having the same embedded unique. * Made a start on 'target metrics' by adding ncg_target_is_32bits to the end of Stix.lhs. * Cleaned up numerous other gruesomenesses in the NCG which never came to light before now. Got rid of MachMisc.sizeOf, which doesn't make sense in a 64-bit setting, and replaced it by calls to PrimRep.getPrimRepArrayElemSize, which, as far as I'm concerned, is the definitive answer to the questio `How Big Is This PrimRep Really?' Result: on x86-linux, at least, you can now compile the Entire Prelude with -fasm! At this stage I cannot claim that the resulting code is correct, but it's a start.
* [project @ 2001-12-06 11:50:07 by sewardj]sewardj2001-12-061-1/+5
| | | | | | | Add constructor CBytesPerWord to (the wildly-misnamed) CAddrMode, and use this in various places to remove word size dependencies in the C -> C simplification pass. Tart up the Stix constant folder a bit so as to be able to fold out the shift/mask literal expressions.
* [project @ 2001-12-05 17:35:12 by sewardj]sewardj2001-12-051-570/+97
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | -------------------------------------------- Translate out PrimOps at the AbstractC level -------------------------------------------- This is the first in what might be a series of changes intended to make GHC less dependent on its C back end. The main change is to translate PrimOps into vanilla abstract C inside the compiler, rather than having to duplicate that work in each code generation route. The main changes are: * A new type, MachOp, in compiler/absCSyn/MachOp.hs. A MachOp is a primitive operation which we can reasonably expect the native code generators to implement. The set is quite small and unlikely to change much, if at all. * Translations from PrimOps to MachOps, at the end of absCSyn/AbsCUtils. This should perhaps be moved to a different module, but it is hard to see how to do this without creating a circular dep between it and AbsCUtils. * The x86 insn selector has been updated to track these changes. The sparc insn selector remains to be done. As a result of this, it is possible to compile much more code via the NCG than before. Almost all the Prelude can be compiled with it. Currently it does not know how to do 64-bit code generation. Once this is fixed, the entire Prelude should be compilable that way. I also took the opportunity to clean up the NCG infrastructure. The old Stix data type has been split into StixStmt (statements) and StixExpr (now denoting values only). This removes a class of impossible constructions and clarifies the NCG. Still to do, in no particular order: * String and literal lifting, currently done in the NCG at the top of nativeGen/MachCode, should be done in the AbstractC flattener, for the benefit of all targets. * Further cleaning up of Stix assignments. * Remove word-size dependency from Abstract C. (should be easy). * Translate out MagicIds in the AbsC -> Stix translation, not in the Stix constant folder. (!) Testsuite failures caused by this: * memo001 - fails (segfaults) for some unknown reason now. * arith003 - wrong answer in gcdInt boundary cases. * arith011 - wrong answer for shifts >= word size. * cg044 - wrong answer for some FP boundary cases. These should be fixed, but I don't think they are mission-critical for anyone.
* [project @ 2001-11-20 16:43:18 by sof]sof2001-11-201-1/+0
| | | | | | | | Nuke #include of MachDeps.h - nothing in there that cannot be (better) gotten from the in-tree config.h This is the only (last?) use of MachDeps.h, so if anyone won't argue for its continued existence, I'll nuke it sometime soon.
* [project @ 2001-10-26 11:53:34 by sewardj]sewardj2001-10-261-5/+2
| | | | | | | | | | | | | | merge from stable, revs: 1.74.4.1 +12 -11 fptools/ghc/compiler/nativeGen/MachCode.lhs 1.30.4.1 +23 -0 fptools/ghc/compiler/nativeGen/Stix.lhs 1.70.4.1 +2 -5 fptools/ghc/compiler/nativeGen/StixPrim.lhs Route all NCG panics to do with missing primop implementations and any other panic which could be caused by compiling legitimate sources through the function Stix.ncgPrimopMoan. This emits a helpful message explaining what has happened, advises the use of -fvia-C as a workaround, and says please mail us.
* [project @ 2001-10-17 11:50:38 by simonpj]simonpj2001-10-171-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | -------------------------- nullAddr# fix for the HEAD [missed one file] -------------------------- *** DO NOT MERGE *** nullAddr# is simply a name for (Lit nullAddrLit). Up to now it has been a PrimOp with the rather stange type nullAddr# :: Int# -> Addr# which discards its argument. (I think the problem with nullary primops is to do with the top-level bindings in PrelPrimOpWrappers.) And there was a RULE in PrelRules to rewrite nullAddr _ ==> nullAddrLit It's excessive to make it a PrimOp. We can just treat it like unsafeCoerce#, which is made in MkId.lhs. So I've done that, and given it the more sensible type nullAddr# :: Addr# I fixed all the occurrences I could find.
* [project @ 2001-08-17 17:18:51 by apt]apt2001-08-171-12/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | How I spent my summer vacation. Primops ------- The format of the primops.txt.pp file has been enhanced to allow (latex-style) primop descriptions to be included. There is a new flag to genprimopcode that generates documentation including these descriptions. A first cut at descriptions of the more interesting primops has been made, and the file has been reordered a bit. 31-bit words ------------ The front end now can cope with the possibility of 31-bit (or even 30-bit) Int# and Word# types. The only current use of this is to generate external .core files that can be translated into OCAML source files (OCAML uses a one-bit tag to distinguish integers from pointers). The only way to get this right now is by hand-defining the preprocessor symbol WORD_SIZE_IN_BITS, which is normally set automatically from the familiar WORD_SIZE_IN_BYTES. Just in case 31-bit words are used, we now have Int32# and Word32# primitive types and an associated family of operators, paralleling the existing 64-bit stuff. Of course, none of the operators actually need to be implemented in the absence of a 31-bit backend. There has also been some minor re-jigging of the 32 vs. 64 bit stuff. See the description at the top of primops.txt.pp file for more details. Note that, for the first time, the *type* of a primop can now depend on the target word size. Also, the family of primops intToInt8#, intToInt16#, etc. have been renamed narrow8Int#, narrow16Int#, etc., to emphasize that they work on Int#'s and don't actually convert between types. Addresses --------- As another part of coping with the possibility of 31-bit ints, the addr2Int# and int2Addr# primops are now thoroughly deprecated (and not even defined in the 31-bit case) and all uses of them have been removed except from the (deprecated) module hslibs/lang/Addr Addr# should now be treated as a proper abstract type, and has these suitable operators: nullAddr# : Int# -> Addr# (ignores its argument; nullary primops cause problems at various places) plusAddr# : Addr# -> Int# -> Addr# minusAddr : Addr# -> Addr# -> Int# remAddr# : Addr# -> Int# -> Int# Obviously, these don't allow completely arbitrary offsets if 31-bit ints are in use, but they should do for all practical purposes. It is also still possible to generate an address constant, and there is a built-in rule that makes use of this to remove the nullAddr# calls. Misc ---- There is a new compile flag -fno-code that causes GHC to quit after generating .hi files and .core files (if requested) but before generating STG. Z-encoded names for tuples have been rationalized; e.g., Z3H now means an unboxed 3-tuple, rather than an unboxed tuple with 3 commas (i.e., a 4-tuple)! Removed misc. litlits in hslibs/lang Misc. small changes to external core format. The external core description has also been substantially updated, and incorporates the automatically-generated primop documentation; its in the repository at /papers/ext-core/core.tex. A little make-system addition to allow passing CPP options to compiler and library builds.
* [project @ 2001-05-24 15:01:33 by simonpj]simonpj2001-05-241-1/+1
| | | | wibble
* [project @ 2001-05-24 13:59:09 by simonpj]simonpj2001-05-241-6/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------------------ More stuff towards generalising 'foreign' declarations ------------------------------------------------------ This is the second step towards generalising 'foreign' declarations to handle langauges other than C. Now I can handle foreign import dotnet type T foreign import dotnet "void Foo.Baz.f( T )" f :: T -> IO () ** WARNING ** I believe that all the foreign stuff for C should work exactly as before, but I have not tested it thoroughly. Sven, Manuel, Marcin: please give it a whirl and compare old with new output. Lots of fiddling around with data types. The main changes are * HsDecls.lhs The ForeignDecl type and its friends Note also the ForeignType constructor to TyClDecl * ForeignCall.lhs Here's where the stuff that survives right through compilation lives * TcForeign.lhs DsForeign.lhs Substantial changes driven by the new data types * Parser.y ParseIface.y RnSource Just what you'd expect
* [project @ 2001-05-22 16:45:41 by qrczak]qrczak2001-05-221-3/+5
| | | | Fix small callconv-related import mismatches etc.
* [project @ 2001-05-22 13:43:14 by simonpj]simonpj2001-05-221-49/+73
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | ------------------------------------------- Towards generalising 'foreign' declarations ------------------------------------------- This is a first step towards generalising 'foreign' declarations to handle langauges other than C. Quite a lot of files are touched, but nothing has really changed. Everything should work exactly as before. But please be on your guard for ccall-related bugs. Main things Basic data types: ForeignCall.lhs ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Remove absCSyn/CallConv.lhs * Add prelude/ForeignCall.lhs. This defines the ForeignCall type and its variants * Define ForeignCall.Safety to say whether a call is unsafe or not (was just a boolean). Lots of consequential chuffing. * Remove all CCall stuff from PrimOp, and put it in ForeignCall Take CCallOp out of the PrimOp type (where it was always a glitch) ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * Add IdInfo.FCallId variant to the type IdInfo.GlobalIdDetails, along with predicates Id.isFCallId, Id.isFCallId_maybe * Add StgSyn.StgOp, to sum PrimOp with FCallOp, because it *is* useful to sum them together in Stg and AbsC land. If nothing else, it minimises changes. Also generally rename "CCall" stuff to "FCall" where it's generic to all foreign calls.
* [project @ 2001-04-27 15:38:39 by sewardj]sewardj2001-04-271-1/+49
| | | | | | | merge rev 1.63.2.2, which was: Remove x86-specific implementation of {intToInt,wordToWord}{8,16,32}# primops, and replace them with platform-independent versions expressed purely in Stix terms.
* [project @ 2001-04-20 14:53:15 by sewardj]sewardj2001-04-201-1/+22
| | | | merge rev 1.63.2.1
* [project @ 2001-02-28 00:01:01 by qrczak]qrczak2001-02-281-22/+70
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add {intToInt,wordToWord}{8,16,32}# primops. WARNING: Not implemented in ncg for Alpha and Sparc. But -O -fasm is not going to go far anyway because of other omissions. * Have full repertoire of 8,16,32-bit signed and unsigned MachMisc.Size values. Again only x86 is fully supported. They are used for {index,read,write}{Int,Word}{8,16,32}{OffAddr,Array}# and {intToInt,wordToWord}{8,16,32}# primops. * Have full repertoire of {index,read,write}\ {Char,WideChar,Int,Word,Addr,Float,Double,StablePtr,\ {Int,Word}{8,16,32,64}}\ {OffAddr,Array} primops and appropriate instances. There were various omissions in various places. * Add {plus,minus,times}Word# primops to avoid so many Word# <-> Int# coercions. * Rewrite modules PrelWord and PrelInt almost from scratch. * Simplify fromInteger and realToFrac rules. For each of {Int,Word}{8,16,32} there is just a pair of fromInteger rules replacing the source or target type with Int or Word. For {Int,Word,Int64,Word64} there are rules from any to any. Don't include rules which are derivable from inlining anyway, e.g. those mentioning Integer. Old explicit coercions are simply defined as appropriately typed fromInteger. * Various old coercion functions marked as deprecated. * Add instance Bits Int, and instance {Show,Num,Real,Enum,Integral,Bounded,Ix,Read,Bits} Word. * Coercions to sized integer types consistently behave as cutting the right amount of bits from the infinite two-complement representation. For example (fromIntegral (-1 :: Int8) :: Word64) == maxBound. * ghc/tests/numeric/should_run/arith011 tests {Int,Word}64 and instance Bits Int, and does not try to use overflowing toEnum. arith011.stdout is not updated yet because of a problem I will tell about soon. * Move fromInteger and realToFrac from Prelude to PrelReal. Move fromInt from PrelNum to PrelReal and define as fromInteger. Define toInt as fromInteger. fromInteger is the place to write integer conversion rules for. * Remove ArrayBase.newInitialisedArray, use default definition of newArray instead. * Bugs fixed: - {quot,rem}Word# primop attributes. - integerToInt64# for small negative values. - {min,max}Bound::Int on 64-bit platforms. - iShiftRL64#. - Various Bits instances. * Polishing: - Use 'ppr' instead of 'pprPrimOp' and 'text . showPrimRep'. - PrimRep.{primRepString,showPrimRepToUser} removed. - MachMisc.sizeOf returns Int instead of Integer. - Some eta reduction, parens, spacing, and reordering cleanups - sorry, couldn't resist. * Questions: - Should iShiftRL and iShiftRL64 be removed? IMHO they should, s/iShiftRA/iShiftR/, s/shiftRL/shiftR/. The behaviour on shifting is a property of the signedness of the type, not the operation! I haven't done this change.
* [project @ 2001-02-01 13:35:10 by sewardj]sewardj2001-02-011-0/+1
| | | | | | | | Fix a long-standing roaring bogon in mangleIndexTree, to do with not-necessarily-valid assumptions about PrimRep sizes. In future all enquiries about PrimRep sizes should go via MachMisc.primRepToSize and/or MachMisc.sizeOf. The Lord preserve us from random, unportable hacks in the NCG.
* [project @ 2001-01-31 12:27:24 by sewardj]sewardj2001-01-311-9/+9
| | | | | | | | | | | | | Create PrimReps: {Int|Word}{8|16|32}Rep, for use in the native code generator. And change the rep for character ops from Int8Rep to Word8Rep. This fixes a bug in the sparc NCG in which chars loaded from memory were incorrectly sign-extended to 32 bits. This problem appeared when CharRep was turned into a 32-bit quantity, and previous uses of it were replaced with Int8Rep, incorrectly, since Int8Rep is signed. Also undo the kludge in the x86 section which had (unknown to all) kept it working despite the change to Int8Rep. sparc NCG now appears to work; hope the x86 side isn't now broken.
* [project @ 2001-01-15 17:05:46 by sewardj]sewardj2001-01-151-0/+1
| | | | | More stuff to do with primop support in the interpreter. Also, track some changes to the libraries.
* [project @ 2001-01-15 16:55:24 by sewardj]sewardj2001-01-151-3/+0
| | | | | In interpreted code, basic support for routing primop calls through to functions in PrelPrimopWrappers.lhs.
* [project @ 2001-01-03 16:44:29 by sewardj]sewardj2001-01-031-0/+3
| | | | | Start getting the bytecode interpreter to work. A matching commit to compiler/ghci/ByteCodeGen.lhs follows ...
* [project @ 2000-12-04 12:31:19 by simonmar]simonmar2000-12-041-2/+9
| | | | merge recent changes from before-ghci-branch onto the HEAD
* [project @ 2000-11-06 08:15:20 by simonpj]simonpj2000-11-061-1/+1
| | | | Dealing with instance-decl imports; and removing unnecessary imports
* [project @ 2000-10-24 10:12:16 by sewardj]sewardj2000-10-241-3/+4
| | | | Make the back-end world compile.
* [project @ 2000-09-01 18:28:41 by qrczak]qrczak2000-09-011-1/+1
| | | | | ForeignObjs were incorrectly passed to foreign functions by the NCG. Fixed.
* [project @ 2000-08-21 13:34:44 by simonmar]simonmar2000-08-211-2/+13
| | | | Add touch# and foreignObjToAddr#.
* [project @ 2000-08-17 14:30:26 by simonmar]simonmar2000-08-171-7/+5
| | | | Complete the removal of tso->splim (these are the NCG bits).
* [project @ 2000-08-07 23:37:19 by qrczak]qrczak2000-08-071-15/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Now Char, Char#, StgChar have 31 bits (physically 32). "foo"# is still an array of bytes. CharRep represents 32 bits (on a 64-bit arch too). There is also Int8Rep, used in those places where bytes were originally meant. readCharArray, indexCharOffAddr etc. still use bytes. Storable and {I,M}Array use wide Chars. In future perhaps all sized integers should be primitive types. Then some usages of indexing primops scattered through the code could be changed to then-available Int8 ones, and then Char variants of primops could be made wide (other usages that handle text should use conversion that will be provided later). I/O and _ccall_ arguments assume ISO-8859-1. UTF-8 is internally used for string literals (only). Z-encoding is ready for Unicode identifiers. Ranges of intlike and charlike closures are more easily configurable. I've probably broken nativeGen/MachCode.lhs:chrCode for Alpha but I don't know the Alpha assembler to fix it (what is zapnot?). Generally I'm not sure if I've done the NCG changes right. This commit breaks the binary compatibility (of course). TODO: * is* and to{Lower,Upper} in Char (in progress). * Libraries for text conversion (in design / experiments), to be plugged to I/O and a higher level foreign library. * PackedString. * StringBuffer and accepting source in encodings other than ISO-8859-1.
* [project @ 2000-08-07 14:11:48 by sewardj]sewardj2000-08-071-56/+129
| | | | | | | | | | | Reorganise the way primops are done. Most of the information about primops, their types and relevant attributes is in prelude/primops.txt. A supporting program in fptools/ghc/utils/genprimopcode reads this file and generates various bits of code which are #include'd into prelude/PrimOp.lhs. Eventually this mechanism will be extended to generate PrelGHC.hi and C code for primops in the bytecode evaluator. Also, add a few primops for creating, reading and writing BCOs.
* [project @ 2000-07-11 15:26:33 by sewardj]sewardj2000-07-111-2/+5
| | | | | | | | | | | | | | | | | | Fix up the sparc native code generator. Mostly dull stuff. Notable changes: * Cleaned up ccall mechanism for sparc somewhat. * Rearranged assignment of sparc floating point registers (includes/MachRegs.h) so the NCG's register allocator can handle the double-single pairing issue without modification. Split VirtualRegF into VirtualRegF and VirtualRegD, and split RcFloating into RcFloat and RcDouble. Net effect is that there are now three register classes -- int, float and double, and we pretend that sparc has some float and some double real regs. * (A fix for all platforms): propagate MachFloats through as StFloats, not StDoubles. Amazingly, until now literal floats had been converted to and treated as doubles, including in ccalls.
* [project @ 2000-07-06 14:08:31 by simonmar]simonmar2000-07-061-16/+4
| | | | | | | | | | New form of literal: MachLabel, for addresses of labels. Used by foreign label instead of MachLitLit now. Real lit-lits now cause the NCG to panic. Also: removed CLitLit from AbsCSyn; it was only used in one place for a purpose it shouldn't have been used for in the first place.
* [project @ 2000-07-04 20:01:00 by panne]panne2000-07-041-1/+0
| | | | | | From the Ancient Book of Infinite CS Wisdom: "Thou shalt remove unused imports after dead code removal..." ;-)
* [project @ 2000-07-03 14:32:58 by simonmar]simonmar2000-07-031-7/+0
| | | | dead code removal