Commit Graph

335 Commits

Author SHA1 Message Date
Neil Brown
8a28d765e7 Implemented recursive procs
This works fine in the C++ backend, not tested with the C backend yet
2009-01-29 00:43:24 +00:00
Neil Brown
10e6b4ce02 Updated all the tests to work with the new recursive functions 2009-01-29 00:34:12 +00:00
Neil Brown
7722e95dfd Added support for recursive functions (not procs, yet)
At the moment, the information is only needed in the parser, which must define recursive names before parsing the body of the function.  But in future, we should keep the information when the function becomes a proc, and then the C/C++ backends may need to use it (for example, when calculating stack space usage)
2009-01-29 00:27:11 +00:00
Neil Brown
6693a8b8b9 Changed things in the transformations directory in light of the new step count 2009-01-28 23:46:04 +00:00
Neil Brown
15a4a59bcf Stopped the pass that removes unused variables removing unused replicators 2009-01-23 14:24:44 +00:00
Neil Brown
1f4796e07f Fixed all the tests to reflect the new channel-end system, such that they all pass again
This is the last patch (for now) of the set implementing the new channel-end system
2009-01-20 17:41:44 +00:00
Neil Brown
766cb09dcf Changed pullUp to pull up channel arrays that have direction specifiers applied to the whole array
For example, a call like foo(6, cs!) will have cs! pulled up, iff cs was of type CHAN X.  If cs was of type CHAN! X, nothing is done (and the needless direction will be removed later on).
2009-01-20 17:33:24 +00:00
Neil Brown
6f22d8a573 Stopped the pulling up of fully-resolved array expressions where one of the subscripts is a slice
This was causing a problem in the C/C++ backends, where the slice function call was having _sizes appended to it.  So now we pull up anything that results in an array, or is a slice.
2009-01-15 22:44:11 +00:00
Neil Brown
9d1dfb7f5f Stopped arrays being pulled up when all the indices have been supplied 2009-01-15 21:36:05 +00:00
Neil Brown
b48129d4e5 Fixed some uses of Map.lookup that used the old system of it working with any monad (in GHC 6.10, it's always Maybe) 2008-11-28 11:38:06 +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
Neil Brown
2a15f4ef5f Filled in all the gaps such that the CheckTest tests now run (including some debug output, for now)
One of the tests fails at the moment because the specification node has two entries associated with it in the flowgraph.  One is the scope-in and one is the scope-out.  I think the analysis is currently picking the scope-out node and looking beyond that, where -- surprise, surprise -- the variable is not used again.  So I need some easy way of telling the flow analyses which of the two nodes I want to start from, in this case and other ones where I also add two nodes related to the same point in the AST.
2008-11-12 16:54:00 +00:00
Neil Brown
dc030acabe Changed the FlowGraph stuff to use the new Route type (that includes identifiers) rather than the bare functions as it used to 2008-11-10 14:01:30 +00:00
Neil Brown
bcad0c225f Converted the other pullRepCounts test over to the new system 2008-11-16 19:40:27 +00:00
Neil Brown
fe3dd78db3 Realised that pullRepCounts should pull the counts for PAR and ALT after all, and adjusted one test to reflect this 2008-11-16 18:43:34 +00:00
Neil Brown
bfacb526fb Converted one of the tests for pullRepCounts to use the new mechanism, which in turn exposed that the pass was not altering the definition in the state (which it may as well) 2008-11-16 18:25:53 +00:00
Neil Brown
771297632d Finished converting all the cases in testInputCase to use the new occam EDSL 2008-11-16 16:57:52 +00:00
Neil Brown
b82395dc81 Tried changing an existing test from using oZ to oA which revealed a problem with the csNames comparison (and matching the map orderings) 2008-11-16 13:05:30 +00:00
Neil Brown
278b80932e Converted one of the input case tests to use the occam EDSL, making it much clearer 2008-11-16 12:24:41 +00:00
Neil Brown
42e4ca5c92 Adjusted an existing testcase for the changes in OccamEDSL 2008-11-16 12:24:24 +00:00
Neil Brown
a570f2eff3 Renamed the variables in the occam EDSL to be less likely to clash in other modules 2008-11-15 20:11:52 +00:00
Neil Brown
f4d9c791ef Simplified the occam EDSL by removing the unnecessary monad in favour of plain lists, and added a way to separate expected output from input 2008-11-15 20:06:47 +00:00
Neil Brown
7764ed9326 Added a module for easily knocking up fragments of occam code to test, but need to remove some of the extravagance in the design (including an unnecessary monad) 2008-11-15 19:29:56 +00:00
Neil Brown
73d1bdc711 Fixed the flow algorithms to discard nodes that should not feature (e.g. nodes with no onward path in backward data flow) 2008-09-11 21:46:03 +00:00
Adam Sampson
3eeda5d821 Add a unit tests file for SimplifyTypes.
The tests in there at the moment are pretty trivial, but I'm going to
want to add more stuff to SimplifyTypes later.
2008-06-11 15:56:24 +00:00
Adam Sampson
8545b08aee Tidy up resolveNamedTypes. 2008-06-11 15:46:11 +00:00
Adam Sampson
02c444be95 Update abbrevation types in the state too.
This makes cgtest82 work, although I'm not very happy with it as a fix. I'd
rather have a way of ensuring the state's definitions are kept up to date when
we change something in the AST.
2008-06-10 13:57:01 +00:00
Neil Brown
7e0bc775bf Changed the writtenVars entry of Vars to be a map from variables to (assigned-from) expressions
The expressions are optional (wrapped in a Maybe type)
2008-06-05 20:30:44 +00:00
Neil Brown
936382a3ca Renamed labelFunctions to labelUsageFunctions, to make it clearer what the functions are for 2008-06-05 20:16:02 +00:00
Neil Brown
069cfd9a9f Fixed the pulling up of replicators when they are free names (something that was broken in the original Rep change) 2008-06-04 19:06:05 +00:00
Neil Brown
e2dac3aa76 Simplified freeNamesIn by removing what is an unnecessary case for replicators 2008-06-04 19:05:31 +00:00
Neil Brown
5bc88ec1fc Fixed another test that was broken during the change to Rep 2008-06-04 18:43:50 +00:00
Neil Brown
41ff60cb78 Removed the Rep constructor from Structured and instead added a Rep constructor to SpecType
This way, all replicators are declared like other names, and their scope is considered replicated.  This simplifies the code a little.

Fixes #55
2008-06-04 17:00:43 +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
Adam Sampson
f2352019ab Implement INITIAL and RESULT abbreviations.
This adds the passes to transform INITIAL into the correct form.

Fixes #42.
2008-06-03 14:57:24 +00:00
Adam Sampson
6ee21f76c9 Initial work on supporting INITIAL and RESULT abbreviations.
This fixes the AST, parser and typechecker, and adds a pass to
transform Result back into Abbrev, but doesn't transform Initial yet.
(It actually works for trivial stuff anyway, but it won't do the right
thing for complex types or PROC parameters.)

It appears (to me) to make sense to support INITIAL/RESULT reshaping
and retyping too, so this does.

Refs #42.
2008-06-02 20:41:37 +00:00
Adam Sampson
f811d2cdc9 Clean up some remaining messy code after the passes rework. 2008-06-02 17:04:30 +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
Neil Brown
0adbdda126 Moved all the pass information about the Rain passes into their definition (rather than the pass list at the top)
As part of this patch, I have also introduced a helper function that fiddles the type system for those passes that must run at the top-level (i.e. on A.AST) rather than on any Data t.  They will give an error if not applied at the top-level.
2008-06-02 12:51:14 +00:00
Adam Sampson
cf79f9c284 Get rid of the nasty ghost names hack.
Rather than prefixing the names, there's now a set of ghost names in
CompState.

Fixes #66.
2008-06-02 10:58:26 +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
Neil Brown
5301b83148 Added code to actually make the implicit mobility decisions take effect in the tree 2008-06-01 19:28:22 +00:00
Neil Brown
600ce667cb Refactored the code for making and printing out the move/copy decisions in the ImplicitMobility module 2008-05-30 18:28:40 +00:00
Neil Brown
947f252e66 Corrected the implicit mobility so that it now works properly on the Rain move testcase 2008-05-30 17:29:21 +00:00
Neil Brown
a5fca4816b Added the beginnings of support for implicit mobility for Rain (just printing out the decisions for now) 2008-05-30 17:16:10 +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
8943b767eb Fixed the SimplifyTypes module
This fixes Trac ticket #46.  The pass for masking out state bodies has been moved to PassList (since it's so small and should be run first) for now, and SimplifyTypes has had its previous two passes merged into one.
2008-05-21 13:12:49 +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
11588b34a3 Fixed a bug where transformConstr would skip over the second of two nested definitions of array constructors 2008-05-20 23:44:32 +00:00
Neil Brown
48fbf5f3e1 Added pulling up of list literals and list-constructed expressions 2008-05-20 23:44:07 +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
1977e7880b Move evalIntExpression into EvalConstants, now that Types doesn't need it.
It now uses the full expression evaluator rather than the literal-only version.
2008-04-06 13:31:37 +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
cbbafffbd2 Changed Rain to use the new timer type rather than things like the GetTime statement 2008-03-24 13:50:14 +00:00
Neil Brown
0ed18c933f Fixed pullUp to not pull up list expressions
This patch looks like I removed the wrong line above, but it was identical to the line I actually removed, so the patch is fine, it just looks odd.
2008-03-23 11:49:42 +00:00
Neil Brown
dd7b0268b2 Added a new property (functionTypesChecked) to help fix the pass ordering 2008-03-23 00:09:01 +00:00
Neil Brown
4e9a00a5b7 Added support for for-each replicators to the freeNamesIn function 2008-03-23 00:08:48 +00:00
Adam Sampson
e23a12c71d Don't resolve user types until after type checking.
This is important -- a user type defined as INT in occam must not be treated
the same as INT when typechecking.
2008-03-22 00:12:54 +00:00
Adam Sampson
9cea36257e Make functionsToProcs depend on expressionTypesChecked.
I think in general typechecking needs to happen before any other pass runs,
else the user's likely to get rather confusing error messages.
2008-03-22 00:04:53 +00:00
Neil Brown
f7141bda6f Corrected transformConstr0 2008-03-21 20:02:33 +00:00
Neil Brown
14e375247c Added an error message to transformConstr for when the type is not supported 2008-03-21 19:32:07 +00:00
Neil Brown
cfccd38c51 Changed transformConstr to transform list-typed array constructors to build up a list rather than subscripting it 2008-03-21 19:22:29 +00:00
Neil Brown
a1daf15576 Pulled up list expressions in a similar way to array expressions 2008-03-21 19:21:46 +00:00
Neil Brown
da5801ad03 Refactored transformConstr to pull out some of its working into helper functions 2008-03-21 19:13:54 +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
Neil Brown
b496912c51 Fixed conflicts with Adam's dimension changes 2008-03-19 17:49:32 +00:00
Neil Brown
e2f5d18169 Added a case in pullRepCountSeq for ForEach replicators 2008-03-19 17:15:14 +00:00
Neil Brown
722499b05d Adjusted the test for transformConstr to work properly with the new array constructor type 2008-03-19 13:29:02 +00:00
Neil Brown
db0467f1ca Adjusted the rain passes to use the new array constructor type, and weaned a few of them off everywhereM 2008-03-19 13:24:15 +00:00
Neil Brown
cb819d142a Altered transformConstr to handle array constructors with types in them 2008-03-19 13:23:20 +00:00
Adam Sampson
52d72647ae Fix the transformConstr0 test by defining x. 2008-03-20 11:23:45 +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
b21f020862 Make SimplifyExprs compute the type of the variable it declares.
This lets you say things like:
  VAL []INT xs IS [i = 0 FOR 20 | i]:
and have it figure out that the type of xs is really [20]INT.

This also cleans up the code a very small amount.
2008-03-17 18:33:04 +00:00
Adam Sampson
ca230be268 Use Prop.agg_typesDone rather than listing its members. 2008-03-17 15:47:29 +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
Neil Brown
c1f0ff92c9 Corrected the transformation of AFTER for the BYTE type 2008-03-09 16:26:50 +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
f0fceb5aee Stopped array literals being pulled up out of record literals in C++, now that the array handling has been changed 2008-03-07 15:48:24 +00:00
Neil Brown
08d02bfb17 Changed the behaviour of assignment for records
Previously, assignments of records were directly flattened into assignment of each of the fields.  Now, we instead generate a copy_<recordname> inline procedure for each record definition, and compile code that uses that (for C++, we could even make this an operator= implementation later on).  This allows us to re-use the proc later in the C/C++ backends if needed.
2008-02-29 16:36:47 +00:00
Neil Brown
9ab6cbc0b4 Changed the pullUp function to behave differently for C than C++ (pulling up of array literals inside record literals) 2008-02-29 03:05:52 +00:00
Neil Brown
6d4f1dd702 Added labels to all the top-level tests that didn't have one 2008-02-28 16:11:01 +00:00
Neil Brown
a4424ee82d Fixed a few dependencies in the pass lists relating to functions 2008-02-27 20:05:47 +00:00
Neil Brown
46de1956b3 Corrected the pulling up of SEQ replicator counts to descend properly into nested functions 2008-02-27 19:58:09 +00:00
Neil Brown
86c17fed99 Added a pass for pulling up the replicator counts in SEQs so that the count is constant for the whole loop 2008-02-27 19:33:44 +00:00
Neil Brown
cfc3577c21 Fixed the pre-condition of flattenAssign to include the types being resolved 2008-02-27 18:24:33 +00:00
Neil Brown
b0fac1f82a Made sure that definitions are only pulled up after protocol inputs have been flattened 2008-02-27 17:20:52 +00:00
Neil Brown
af7a15b4df Changed testTransformProtocolInput so that it does transform protocol inputs in ALT guards 2008-02-27 17:20:19 +00:00
Neil Brown
9b521c9b07 Added tests for testing that testTransformProtocolInput transformed protocol inputs in ALTs 2008-02-27 17:19:47 +00:00
Neil Brown
5c7bb1296b Altered transformProtocolInput to only bother flattening inputs with more than one item 2008-02-27 17:01:19 +00:00
Neil Brown
9b570996ca Added a pass to flatten protocol inputs down into multiple sequential input statements 2008-02-27 16:45:27 +00:00
Neil Brown
5dbf7fea7a Changed functionsToProcs to work on the new style of function, and made sure parallel assignment isn't removed first 2008-02-25 22:05:53 +00:00
Neil Brown
f9625ce495 Adjusted the tests for functionsToProcs to include the new style of functions 2008-02-25 22:02:21 +00:00
Neil Brown
1edaacae89 Altered the AST to allow a function to be either an ExpressionList (classical occam) or a Process (Rain/proposed new occam) 2008-02-24 19:29:31 +00:00
Neil Brown
74f3cb7fc2 Removed the export of "m" in TestUtils, instead moving the definition to each module that uses it (less confusing that way) 2008-02-24 18:55:44 +00:00
Neil Brown
5d9e2d8e33 Changed rntState so that it "nulls" the bodies of procs and functions first 2008-02-24 15:54:18 +00:00
Neil Brown
147d799563 Changed the replaceNames function so that it doesn't use everywhere 2008-02-23 18:34:02 +00:00