Commit Graph

53 Commits

Author SHA1 Message Date
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
Neil Brown
5ae8aca68e Fixed the sizes of retyping a multi-dimensional array 2008-03-07 22:46:39 +00:00
Neil Brown
8d44077891 Refactored and enhanced the declareSizesArray pass 2008-03-07 15:54:10 +00:00
Neil Brown
8d411184c1 Corrected the size of array slices 2008-03-07 10:00:02 +00:00
Neil Brown
a751531b4e Added some comments in declareSizesArray and renamed a variable to be clearer 2008-03-06 19:08:09 +00:00
Neil Brown
588381ee06 Fixed declareArraySizes to also use the size of an array element in its calculations for resizing 2008-03-06 18:40:20 +00:00
Neil Brown
0d638c690a Added some support for declaring sizes for retypes abbreviations (so far, only where the sizes are known at compile-time) 2008-03-06 18:30:29 +00:00
Neil Brown
41eda81ee7 Added some comments to declareSizesArray 2008-03-06 18:23:02 +00:00
Neil Brown
c3e1a32909 Rearranged declareSizesArray to easily support IsExpr 2008-03-06 18:03:49 +00:00
Neil Brown
8518860cd3 Fixed the handling of Is abbreviations (declaring array sizes) 2008-03-06 17:52:26 +00:00
Neil Brown
3d823fb1b5 Fixed the handling of actual array parameters to include array variables inside ActualExpression 2008-03-06 17:34:54 +00:00
Neil Brown
807b219a39 Implemented adding array sizes for Is abbreviations 2008-03-06 15:25:05 +00:00
Neil Brown
a9c2643ad4 Fixed some horribly exponential speculative recursion in one of the passes 2008-03-06 14:20:21 +00:00
Neil Brown
60c7a2dde3 Added a preliminary pass-list for the work on flattening arrays 2008-03-06 09:59:18 +00:00
Neil Brown
a2106a98e7 Fixed some incorrect recursion in the pass for declaring array _sizes 2008-03-06 01:50:01 +00:00
Neil Brown
70a207fe6c Implemented the addSizesActualParameters pass 2008-03-05 23:40:17 +00:00
Neil Brown
6a5d84ffcd Implemented the addSizesFormalParameters pass 2008-03-05 22:10:21 +00:00
Neil Brown
1fef1e64ed Added the beginnings of testing for adding _sizes parameters to PROC definitions (formals) 2008-03-05 17:31:14 +00:00
Neil Brown
2ea7c37abe Added the implementation of declaring _sizes arrays for record fields 2008-03-04 15:22:24 +00:00
Neil Brown
41303eb993 Altered the code and the tests for declareSizesArray to approach what it should be doing 2008-03-03 17:50:57 +00:00
Neil Brown
81ea069707 Added a dummy implementation of a new pass, declareSizesArray, and the tests for it 2008-03-03 15:02:07 +00:00
Adam Sampson
87a1c39411 Fix recursion in identifyParProcs that broke testcases/par.occ.
It wasn't looking for PROC definitions inside Specs. This is a good example of
a pass that really wants a trimmed "everywhere"/"contexts" rather than explicit
recursion.
2008-03-07 17:28:30 +00:00
Neil Brown
feabd450f0 Fixed a conflict between the prolifing-related changes and the dependence graph 2008-02-24 11:23:29 +00:00
Neil Brown
635f7bf1b0 Changed the backend passes in BackendPasses to not use the everywhere(M) function 2008-02-23 18:33:16 +00:00
Neil Brown
3ce0eaf452 Made the first adjustment to the Pass system, ready to introduce properties and a dependency graph. For now passes are still executed in list order 2008-02-16 10:19:14 +00:00