| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
|
|
|
| |
#include "MachDeps.h" to get WORD_SIZE_IN_BITS (fixes profasm breakages)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
Tweaks to get the GHC sources through Haddock. Doesn't quite work
yet, because Haddock complains about the recursive modules. Haddock
needs to understand SOURCE imports (it can probably just ignore them
as a first attempt).
|
|
|
|
|
|
|
|
|
|
|
|
| |
Complete the transition of -split-objs into a dynamic flag (looks like I
half-finished it in the last commit).
Also: complete the transition of -tmpdir into a dynamic flag, which
involves some rearrangement of code from SysTools into DynFlags.
Someday, initSysTools should move wholesale into initDynFlags, because
most of the state that it initialises is now part of the DynFlags
structure, and the rest could be moved in easily.
|
|
|
|
| |
Undo rev. 1.6, these changes shouldn't have been in this tree
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Rationalise the BUILD,HOST,TARGET defines.
Recall that:
- build is the platform we're building on
- host is the platform we're running on
- target is the platform we're generating code for
The change is that now we take these definitions as applying from the
point of view of the particular source code being built, rather than
the point of view of the whole build tree.
For example, in RTS and library code, we were previously testing the
TARGET platform. But under the new rule, the platform on which this
code is going to run is the HOST platform. TARGET only makes sense in
the compiler sources.
In practical terms, this means that the values of BUILD, HOST & TARGET
may vary depending on which part of the build tree we are in.
Actual changes:
- new file: includes/ghcplatform.h contains platform defines for
the RTS and library code.
- new file: includes/ghcautoconf.h contains the autoconf settings
only (HAVE_BLAH). This is so that we can get hold of these
settings independently of the platform defines when necessary
(eg. in GHC).
- ghcconfig.h now #includes both ghcplatform.h and ghcautoconf.h.
- MachRegs.h, which is included into both the compiler and the RTS,
now has to cope with the fact that it might need to test either
_TARGET_ or _HOST_ depending on the context.
- the compiler's Makefile now generates
stage{1,2,3}/ghc_boot_platform.h
which contains platform defines for the compiler. These differ
depending on the stage, of course: in stage2, the HOST is the
TARGET of stage1. This was wrong before.
- The compiler doesn't get platform info from Config.hs any more.
Previously it did (sometimes), but unless we want to generate
a new Config.hs for each stage we can't do this.
- GHC now helpfully defines *_{BUILD,HOST}_{OS,ARCH} automatically
in CPP'd Haskell source.
- ghcplatform.h defines *_TARGET_* for backwards compatibility
(ghcplatform.h is included by ghcconfig.h, which is included by
config.h, so code which still #includes config.h will get the TARGET
settings as before).
- The Users's Guide is updated to mention *_HOST_* rather than
*_TARGET_*.
- coding-style.html in the commentary now contains a section on
platform defines. There are further doc updates to come.
Thanks to Wolfgang Thaller for pointing me in the right direction.
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Fix a bug in the register clobbering logic noticed by Wolfgang Thaller.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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).
|
|
|
|
| |
Fix a typo in the previous commit.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
Small optimisation: allow lookForInline to skip over CmmNop too
|
|
|
|
|
|
|
|
|
|
|
| |
Fix bug(s) in the register allocator: if a virtual register is both in
memory and in a register (perhaps because it was recently loaded from
a spill slot), and the current instruction writes it, we're supposed
to invalidate the memory slot. That wasn't happening properly.
This fixes two problems noticed when using -prof -fasm: 10queens in the
testsuite gives the wrong answer, and nofib/spectral/hartel/ida fails
with a 'head []' message. Interesting bug to track down!
|
|
|
|
|
| |
PowerPC Linux: Fix a slight ABI bug in genCCall
Double and I64 arguments on the stack were not properly aligned.
|
|
|
|
|
| |
Mac OS X: Explicitly align symbol stub sections in Mach-O files; Apple's as
doesn't seem to do that in all cases.
|
|
|
|
| |
trivial changes to correct a build-breaker that only affects linux/powerpc
|
|
|
|
|
|
|
|
| |
For platforms with no PIC method defined, use
LabelAccessStyle of AccessDirectly, in howToAccessLabel.
This seems to keep the ncg working on OpenBSD.
Is this the correct default, Wolfgang?
|
|
|
|
| |
Add missing final #else case for howToAccessLabel.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Fix an infinite loop in the cmm-optimiser in the native codegen, and
refactor: move isAssociativeMachOp into MachOp.
|
|
|
|
| |
Merge backend-hacking-branch onto HEAD. Yay!
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
----------------------------
Re-do kind inference (again)
----------------------------
[WARNING: interface file binary representation has
(as usual) changed slightly; recompile your libraries!]
Inspired by the lambda-cube, for some time GHC has used
type Kind = Type
That is, kinds were represented by the same data type as types.
But GHC also supports unboxed types and unboxed tuples, and these
complicate the kind system by requiring a sub-kind relationship.
Notably, an unboxed tuple is acceptable as the *result* of a
function but not as an *argument*. So we have the following setup:
?
/ \
/ \
?? (#)
/ \
* #
where * [LiftedTypeKind] means a lifted type
# [UnliftedTypeKind] means an unlifted type
(#) [UbxTupleKind] means unboxed tuple
?? [ArgTypeKind] is the lub of *,#
? [OpenTypeKind] means any type at all
In particular:
error :: forall a:?. String -> a
(->) :: ?? -> ? -> *
(\(x::t) -> ...) Here t::?? (i.e. not unboxed tuple)
All this has beome rather difficult to accommodate with Kind=Type, so this
commit splits the two.
* Kind is a distinct type, defined in types/Kind.lhs
* IfaceType.IfaceKind disappears: we just re-use Kind.Kind
* TcUnify.unifyKind is a distinct unifier for kinds
* TyCon no longer needs KindCon and SuperKindCon variants
* TcUnify.zapExpectedType takes an expected Kind now, so that
in TcPat.tcMonoPatBndr we can express that the bound variable
must have an argTypeKind (??).
The big change is really that kind inference is much more systematic and
well behaved. In particular, a kind variable can unify only with a
"simple kind", which is built from * and (->). This deals neatly
with awkward questions about how we can combine sub-kinding with type
inference.
Lots of small consequential changes, especially to the kind-checking
plumbing in TcTyClsDecls. (We played a bit fast and loose before, and
now we have to be more honest, in particular about how kind inference
works for type synonyms. They can have kinds like (* -> #), so
This cures two long-standing SourceForge bugs
* 753777 (tcfail115.hs), which used erroneously to pass,
but crashed in the code generator
type T a = Int -> (# Int, Int #)
f :: T a -> T a
f t = \x -> case t x of r -> r
* 753780 (tc167.hs), which used erroneously to fail
f :: (->) Int# Int#
Still, the result is not entirely satisfactory. In particular
* The error message from tcfail115 is pretty obscure
* SourceForge bug 807249 (Instance match failure on openTypeKind)
is not fixed. Alas.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
PowerPC Linux support for registerised compilation and native code
generation. (object splitting and GHCi are still unsupported).
Code for other platforms is not affected, so MERGE TO STABLE.
|
|
|
|
|
|
| |
PowerPC NCG bugfix: 2-byte data objects should be .short, not .byte
MERGE TO STABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-------------------------
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
|
|
|
|
|
| |
Change IF_OS_darwin to IF_ARCH_powerpc so addImportNat is imported in
exactly the case in which it is used.
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
Legacy Removal
~~~~~~~~~~~~~~
The following features have been consigned to the bit bucket:
_ccall_
_casm_
``....'' (lit-lits)
the CCallable class
the CReturnable class
|
|
|
|
|
|
|
| |
pprInstr{PPC}: insist on xori,ori,andi being fed non-negative immediate values.
GAS is barfing on neg. values.
[ Don't have access to a PPC box right now to really test the change, so beware.]
|
|
|
|
|
|
| |
gcc 3.3's cpp fix on sparc.
Could be merged to stable if it's not too late.
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
| |
Add support for the new AWAKEN_BQ_CLOSURE macro to the NCG. Fixes
broken HEAD builds.
|
|
|
|
|
| |
change trailing comments on #else/#endif lines to C style to avoid
warnings from gcc 3.3's preprocessor.
|
|
|
|
|
|
|
| |
fix for gcc 3.3 preprocessor: no layout, end-of-line comments or complex
Haskell comments in macro arguments.
please merge to STABLE
|
|
|
|
| |
Prune imports
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
| |
Fix two bugs in the PowerPC NCG:
1. it generated a 'subfi' (subtract from with immediate) instruction,
which doesn't exist in the PowerPC architecture.
2. didn't correctly handle switch tables (test case cg048.hs).
MERGE TO STABLE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
| |
update aLL_NON_PTRS for the new RET_DYN stack frame layout.
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
| |
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..
|
|
|
|
| |
support many more MachOps in the PowerPC NCG
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
-------------------------------------
Big upheaval to the way that constructors are named
-------------------------------------
This commit enshrines the new story for constructor names. We could never
really get External Core to work nicely before, but now it does.
The story is laid out in detail in the Commentary
ghc/docs/comm/the-beast/data-types.html
so I will not repeat it here.
[Manuel: the commentary isn't being updated, apparently.]
However, the net effect is that in Core and in External Core, contructors look
like constructors, and the way things are printed is all consistent.
It is a fairly pervasive change (which is why it has been so long postponed),
but I hope the question is now finally closed.
All the libraries compile etc, and I've run many tests, but doubtless there will
be some dark corners.
|
|
|
|
|
|
|
|
|
|
| |
Mac OS X:
Add support for dynamic linker "symbol stubs". For every function that might
be imported from a dynamic library, we have to generate a short piece of
assembly code.
Extend the NatM monad to keep track of the list of imports (for which stubs
will be generated later).
Fix a bug concerning 64 bit ints (hi and low words were swapped in one place).
|
|
|
|
|
| |
PowerPC: for ccalls, use the correct minimum size (32 bytes) for the
parameter area
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
| |
Repair the HEAD after some file adds/removes that were supposed to
happen on the eval-apply-branch yesterday mysteriously happened on the
HEAD instead.
|
|
|
|
|
|
| |
Snapshot of the Eval/Apply changes, c. 15 Nov 2002. This snapshot
should be relatively stable, although GHCi and profiling are currently
known to be broken.
|