Commit Graph

87 Commits

Author SHA1 Message Date
Neil Brown
c8b724d2be Merged the latest set of changes from the trunk into the Polyplate branch
I also added the import list to all the Data.Generics imports in the tests (as I did for the other modules recently)
2009-04-10 20:38:29 +00:00
Neil Brown
e61a23855a Fixed all the conflicts while merging into the Polyplate branch 2009-04-09 11:01:39 +00:00
Neil Brown
d49c7fad4a Fixed all the modules in the backends directory to work with the new Pass system 2008-12-14 18:32:34 +00:00
Neil Brown
f58c8fc2e8 Fixed lots of issues in declare array sizes so that it works properly with various nested mobiles 2009-04-09 17:08:42 +00:00
Neil Brown
a400b3e4f6 Added a pass to pull up values used as initialisers in mobile allocations 2009-04-09 17:08:27 +00:00
Neil Brown
6d6d26d5d6 Fixed the backends to work with the new system (mainly removing unnecessary code) 2009-04-05 23:06:47 +00:00
Neil Brown
172e331a9c Made sure that constants pulled up into sizes arrays are resolved into integers, rather than still referring to named constants 2009-04-04 15:23:40 +00:00
Neil Brown
e457d82f0c Changed FUNCTIONs and PROCs to have optional bodies, and put all the externals into the AST (without bodies)
This may seem like an odd change, but it simplifies the logic a lot.  I kept having problems with passes not operating on externals (e.g. functions-to-procs, adding array sizes, constant folding in array dimensions) and adding a special case every time to also process the externals was getting silly.

Putting the externals in the AST therefore made sense, but I didn't want to just add dummy bodies as this would cause them to throw up errors (e.g. in the type-checking for functions).  So I turned the bodies into a Maybe type, and that has worked out well.

I also stopped storing the formals in csExternals (since they are now in csNames, and the tree), which streamlined that nicely, and stopped me having to keep them up to date.
2009-04-04 14:56:35 +00:00
Neil Brown
923b9700d8 Stopped fixed-sizes being added for TOCKEXTERNAL PROCs 2009-04-04 13:44:56 +00:00
Neil Brown
03bfe593cb Fixed a bug in determining the sizes for RETYPES 2009-04-04 12:31:25 +00:00
Neil Brown
dbc1b461a4 Made makeNonce use the munged meta-tag, to stop wrapper PROCs from different files having name clashes at link-time 2009-04-02 20:02:11 +00:00
Neil Brown
f5e0288ad0 Added an error message for a backend pass that should never be needed -- but just was 2009-04-02 17:18:34 +00:00
Neil Brown
7e7a437a3b Switched to using a different kind of pragma for occam externals, and munged the names to avoid collisions
The separately compiled occam PROCs now use #PRAGMA OCCAMEXTERNAL, which also discards the "= number" thing at the end.  These PROCs then need to be processed differently when adding on the sizes (C externals have one size per dimension, occam externals have the normal array of sizes).

We also now record which processes were originally at the top-level, and keep their original names (i.e. minus the _u43 suffixes) plus an "occam_" prefix to avoid collisions.
2009-04-01 19:21:40 +00:00
Neil Brown
56e5b8da8e A mega-patch that gets tocktest compiling again
However, around a quarter of the tests currently fail...
2009-03-31 17:56:56 +00:00
Neil Brown
3566c6206f Fixed retyping non-packed records into arrays 2009-03-31 16:08:24 +00:00
Neil Brown
4d2cdc0a9d Altered the backend passes to use all the new VariableSizes mechanisms rather than the old stuff
This is quite a big patch, as it reworks a large pass.  The three backend passes dealing with sizes stuff have now been merged into one (because the traversal order is important).

Instead of generating sizes arrays by blindly appending "_sizes", we now create nonces and store them in the csArraySizes map in CompState, which is a bit less hacky.

Added to that, we also generate constant-size arrays (e.g. for [8]) -- which are needed in case we pass the array to a PROC that has a flexible dimension -- at the top of the whole program, and use that array for every variable with that size (so if foo and bar have the same size, we use the same sizes array from the top of the program).
2009-03-31 10:22:34 +00:00
Neil Brown
dbf0b90601 Fixed array sizes for external procs to have one extra formal per dimension, rather than passing the whole array in a single formal (this is now how it should work!) 2009-03-27 16:28:23 +00:00
Neil Brown
574694d078 Fixed some stuff on external PROCs (the adding of sizes parameters) 2009-03-26 23:58:08 +00:00
Neil Brown
45b22472c3 Changed the rest of tock to reflect the changes to the Is constructor 2009-03-24 23:57:24 +00:00
Neil Brown
4493b3d9e4 Removed some of the mobile passes at Carl's suggestion that I didn't need them anyway 2009-03-23 15:51:11 +00:00
Neil Brown
0fc7266c29 Fixed various things to do with abbreviating sizes arrays, and corrected array assignment and the mobile type for Bool 2009-03-22 22:32:56 +00:00
Neil Brown
8492dc03d4 Introduced a ShareMode in the AST, and used it in the channel attributes (rather than Bool) 2009-03-22 22:29:39 +00:00
Neil Brown
12b3c4cd89 Added a pass (and adjusted the backends) to deal with the move-in move-out semantics of mobiles
Also known as communication semantics, I think.  The pass adds an extra channel parameter per mobile (perhaps in future this could be a single extra channel?) that is used to send back the mobile value, and hacked the backend so that the communications to receive these mobiles are done in the right place (after the processes have been run, but before waiting on the barrier for them to complete).

cgtest83 now compiles, runs and passes without a segfault.
2009-03-22 18:28:42 +00:00
Neil Brown
20f2fb2c14 Renamed squashArrays to backendPasses, since that's what it has become 2009-03-22 18:27:10 +00:00
Neil Brown
65550b705e Added an AllSizesVariable item to the AST so that the backend inserts the right code for mobiles and non-mobiles 2009-03-20 11:31:14 +00:00
Neil Brown
4bc15aae48 Bashed the backend until it works with the new mobility passes (standard occam may be broken though) 2009-02-27 17:12:17 +00:00
Neil Brown
4041284feb Renamed a slightly confusing backend pass 2009-02-27 17:04:41 +00:00
Neil Brown
14df1e09b7 Corrected some problems caused by moving the direction specifiers up to the whole array (the array wasn't then being pulled up) 2009-02-10 00:28:45 +00:00
Neil Brown
3458a9197a Adjusted the backends and transformations module to match the new array literal changes 2009-02-01 21:53:17 +00:00
Neil Brown
dbc75ef0b1 Added a pass that helps stop some GCC warnings about literals equivalent to INT_MIN and similar 2009-01-27 13:00:08 +00:00
Neil Brown
8bae96f34e Took care of directed arrays in the passes that generate _sizes arrays 2009-01-20 17:38:18 +00:00
Neil Brown
cc70438c1b Added a pass to remove unneeded directions, i.e. c! where c is already an output end 2009-01-20 17:36:40 +00:00
Neil Brown
c6959ac854 Stopped removeDirections operating on the C++ backend, where we actually want to keep the directions 2009-01-20 17:36:02 +00:00
Neil Brown
0e7a6c5b98 Added a NameSource field for NameDef that indicates where a name comes from 2008-11-25 17:36:42 +00:00
Adam Sampson
62a0873d3d Implement channel direction decorators.
This is mostly straightforward: modify the parser to allow direction
decorators in the right places, and extend the type checker to match.
There's some slight awkwardness in that some of the Types functions
have to perform the same checks as the type checker (e.g. directing a
non-channel), so I've tidied up their error messages a bit.

At the backend, I've just added a little pass to strip out all the
DirectedVariables, since the other backend passes don't handle them
gracefully. From the occam/C point of view this is fine, but I'm not
sure if it's going to cause problems for C++.
2008-06-09 21:35:20 +00:00
Adam Sampson
04f72a62db Handle IsChannelArray when adding _sizes.
This also refactors the sizes-array-declaring code, pulling the
declaration of static sizes out to a helper function, and does a
couple of other minor cleanups to match.
2008-06-09 21:32:04 +00:00
Neil Brown
21329287e2 Fixed a problem with GHC 6.6 and the new pass mechanism by removing all the dollars that were confusing the type-checker 2008-06-03 16:16:26 +00:00
Neil Brown
ba66cce89f Moved all the remaining pass information to be with the passes themselves, and adjusted the tests accordingly
All the passes now have their information (name, pre-requisites and post- properties) stored at the point where the pass is declared, which means the pass lists are just a simple list of pass functions.

The main consequence of this change was that the tests had to be changed.  Now, instead of taking a "pass applied to data" item (type: PassM b), they take both the pass (type: Pass) and source data (type: b), and apply them later.  This was the decision that involved the simplest changes to the existing tests (simply unbracketing the application of the pass to the source).  I also had to include a few old-style versions though (testPass', testPassShouldFail') for where the functions were being used to test things that weren't actually passes (mainly StructureOccam).

Fixes #48
2008-06-02 14:31:19 +00:00
Adam Sampson
36e7353ee7 Take NameType out of NameDef.
NameType is only really needed in the parser, so this takes it out of
NameDef, meaning that later passes defining names no longer need to
set an arbitrary NameType for them. The parser gets slightly more
complicated (because some productions now have to return a SpecType
and a NameType too), but lots of other code gets simpler.

The code that removed free names was the only thing outside the parser
using NameType, and it now makes a more sensible decision based on the
SpecType. Since unscoped names previously didn't have a SpecType at
all, I've added an Unscoped constructor to it and arranged matters
such that unscoped names now get a proper entry in csNames.

Fixes #61.
2008-06-02 10:13:14 +00:00
Adam Sampson
8b3eba594d Add SubscriptCheck field to SubscriptFromFor etc.
This makes it possible to mark a slice as not needing runtime
checking, which is immediately useful for _sizes arrays.

This fixes cgtest03, which was previously failing to compile because
the _sizes array for one of the constants in it contained a runtime
check and thus wasn't itself constant. I've added a testcase file for
the relevant bit of code.
2008-05-26 17:36:26 +00:00
Adam Sampson
d8d6ab12cc Generate size arrays using IsExpr rather than Is.
This wasn't actually wrong, but everywhere else uses IsExpr for Val
abbreviations.
2008-05-26 17:19:25 +00:00
Adam Sampson
d9e00294f9 Format a NameDef constant more nicely. 2008-05-26 17:17:59 +00:00
Adam Sampson
a7877ecd68 Make applyToOnly more general, and use it in more places.
This simplifies several bits of code that are doing things with Structureds.
2008-05-25 22:36:54 +00:00
Adam Sampson
6debf9292f Rework Traversal, and convert all passes to use it.
This changes the Traversal API to the one that I've been working on in
the Polyplate branch, but implemented in terms of Data. The
performance isn't as good as the Polyplate version, but the code is a
lot simpler because it doesn't need all the type constraints (and it
doesn't make GHC struggle).

This also reworks all the passes in Tock to use the new API, including
those that previously used makeGeneric (which I've now removed) or
everywhereM. Most of the passes are simpler because of this, and I
suspect it's fixed a few subtle bugs resulting from missing recursion
in makeGeneric code.

I haven't yet profiled this, but subjectively it seems about the same
as the old Traversal (and thus faster for all the passes that didn't
yet use it).
2008-05-25 20:13:57 +00:00
Neil Brown
d044b51335 Renamed ndType to ndSpecType, as per Trac ticket #59 2008-05-21 13:38:51 +00:00
Neil Brown
4537cd205c Fixed the occam pass list so that it now has the correct order in respect to all the pre-requisite properties 2008-05-21 12:30:04 +00:00
Neil Brown
89c25e3f6c Added a type-class for retrieving the (AST) type of things
This patch hides all the old typeOfExpression, typeOfName, typeOfVariable, etc, and unifies them into a single type-class with an "astTypeOf" function.  The type-class is currently named Typed, but that can easily be changed (it's only explicitly referred to in the Types module).  The patch is essentially the type-class with a giant find-and-replace on the other modules.
2008-05-17 11:41:52 +00:00
Neil Brown
3daf82d318 Merged Alternative and AlternativeCond into a single Alternative item that always has a pre-condition 2008-04-03 14:52:37 +00:00
Adam Sampson
6fb8780cae Make a pattern match more explicit.
This is looking at array dimensions in literals. By this point unknown
dimensions should have been inferred; if they haven't, I'd rather it blew up
here than caused bizarre behaviour later on.

(This is a good candidate for a property check.)
2008-04-06 15:38:59 +00:00
Neil Brown
cba72045d7 Added a missing base case for transformActualVariable, when a subscripted variable is passed to a procedure 2008-04-03 11:24:47 +00:00