Commit Graph

65 Commits

Author SHA1 Message Date
Neil Brown
502c61b01e Fixed the expansion of array literals to be more like it used to be
All the usual cgtests now compile and run
2009-02-02 23:51:57 +00:00
Neil Brown
bf365ee41a Fixed the pass that turns array constructors into replicated loops so that it handles nested array constructors and inner-procthens properly
cgtest80 now compiles and passes
2009-02-02 18:27:38 +00:00
Neil Brown
96934c871d Changed the transformation of array constructors so that it also pulls out all the specs that were pulled up to be just inside them 2009-02-02 17:36:14 +00:00
Neil Brown
ebf8ae2d83 Added a pull up context just inside the replicators for array constructors 2009-02-02 17:35:46 +00:00
Neil Brown
51acf8abb5 Made sure to change the abbreviation for VAL array things that are now being assigned to via a loop as initialisation 2009-02-02 17:34:44 +00:00
Neil Brown
88d6136dcf Stopped the expansion of inner array literals into subscripted elements
This expansion was causing a big blow-up in the code, as things like:

VAL [2][1]INT as IS [[0,1]]

were getting transformed into:

VAL [2]INT n0 IS [0,1]:
VAL [2]INT n1 IS [0,1]:
VAL [2]INT n2 IS [n0[0], n1[1]]:
VAL [2][1]INT as IS [n2]:

Or something similar -- the inner arrays were pulled up into multiple definitions that were then subscripted, because the first pull-up did this:

VAL [2]INT n2 IS [[0,1][0], [0,1][1]]:

and then the inner arrays got pulled up again, separately.  The change hasn't immediately broken anything, but I haven't fully tested it yet
2009-02-02 17:30:39 +00:00
Neil Brown
460ee36247 Fixed the pulling up of array constructors into initialisers
Previously, this was only pulling up constructors that contained single elements, and not constructors that contained multiple elements
2009-02-02 16:17:00 +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
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
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
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
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
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
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
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
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
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
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
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
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
e2f5d18169 Added a case in pullRepCountSeq for ForEach replicators 2008-03-19 17:15:14 +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
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
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
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