Commit Graph

77 Commits

Author SHA1 Message Date
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
Adam Sampson
3283b7db41 Remove the Type/AbbrevMode information from Actual*.
It's redundant, since you can always compute them from the variable, and it
makes the code that deals with actuals rather cleaner.

On the other hand, it slightly complicates some of the tests, because any names
you use in an Actual need to be defined...
2008-03-26 18:16:09 +00:00
Neil Brown
bbdb429498 Changed transformWaitFor (and its tests) to transform the new InputTimerFor into InputTimerAfter 2008-03-24 15:09:05 +00:00
Neil Brown
ebef4aaedf Fixed array constructors by adding an occam pass to figure out their type early on, and also corrected the ordering of the later passes 2008-03-21 18:23:42 +00:00
Adam Sampson
b1416bb0cf Change A.Dimension to take an Expression, not an Int.
This touches an awful lot of code, but cgtest07/17 (arrays and retyping) pass.

This is useful because there are going to be places in the future where we'll
want to represent dimensions that are known at runtime but not at compile time
-- for example, mobile allocations, or dynamically-sized arrays. It simplifies
the code in a number of places.

However, we do now need to be careful that expressions containing variables do
not leak into the State, since they won't be affected by later passes.

Two caveats (marked as FIXMEs in the source):

- Retypes checking in the occam parser is disabled, since the plan is to move
  it out to a pass anyway.
- There's some (now very obvious) duplication, particularly in the backend, of
  bits of code that construct expressions for the total size of an array
  (either in bytes or elements); this should be moved to a couple of helper
  functions that everything can use.
2008-03-18 16:45:38 +00:00
Adam Sampson
5156626ab0 Remove the identifyParProcs pass.
All it did was to make a list of the Procs generated by parsToProcs, so
parsToProcs may as well just do the same job itself.

The reason I'd made it a separate pass originally was that I wanted to
optimise out the wrapper when the child of a Par was already a ProcCall.
That optimisation isn't going to be possible any more with the new CCSP,
since wrappers have to fetch their arguments in a different way from
ordinary Procs.
2008-03-14 14:53:05 +00:00
Adam Sampson
006559271d Declare size arrays before the corresponding real arrays.
This is because we sometimes need the size array while initialising the real
array -- for example, if we're initialising a 2D array of channels.
2008-03-12 15:14:00 +00:00
Neil Brown
35b1ffdc51 Added a new pass to turn all array slices into the full FromFor form 2008-03-09 16:15:24 +00:00
Neil Brown
5c43172e46 Added an annotation to array subscripts to indicate whether they should have a run-time check added or not 2008-03-09 14:30:19 +00:00
Neil Brown
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Neil Brown
3f02caba7c Changed the handling of retypes with arrays to handle source items with unknown size 2008-03-08 00:06:35 +00:00