Commit Graph

257 Commits

Author SHA1 Message Date
Neil Brown
e8fec8585b Stopped mobile arrays being allocated after declaration (with random size!) 2009-03-23 15:56:04 +00:00
Neil Brown
919781eabc Fixed the generation of mobile array dereferences 2009-03-23 15:55:38 +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
228523e7e7 Added the generation of IsDefined checks, and stopped them being applied to derefenced arrays 2009-03-23 15:48:24 +00:00
Neil Brown
fae0d6d6a2 Made intrinsic PROCs take the workspace as a parameter, and turned . to _ in their names (and implemented the RESIZE.MOBILE.ARRAY.1D intrinsic) 2009-03-23 15:46:24 +00:00
Neil Brown
3ae4824184 Added a missing case to the C backend 2009-03-22 22:49:10 +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
7b52565270 Fixed a few things that work around the user data types problem 2009-03-22 21:06:31 +00:00
Neil Brown
0a97946fbf Fixed various type-checking things related to mobile types 2009-03-22 21:05:36 +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
d12d630de1 Added some code to allocate a mobile before a dereferenced input 2009-03-22 18:28:19 +00:00
Neil Brown
4f6050069c Moved isMobileType into the Types module where it belongs 2009-03-22 18:26:14 +00:00
Neil Brown
854a1fca50 Fixed various things in the C backend and made genVariable more flexible, for functions that want to specify the C type desired 2009-03-22 14:49:35 +00:00
Neil Brown
3801857817 Fixed a bug in the C backend (using the wrong type in a call) 2009-03-22 14:27:46 +00:00
Neil Brown
2fc327287a Fixed various conflicts in the backends directory while merging one of my branches 2009-03-21 23:43:04 +00:00
Neil Brown
90634ff1d6 Improved the error message for getting the C type to leave the mobile wrapper on 2009-03-21 23:41:54 +00:00
Neil Brown
f5fa5e5caf Fiddled with the code supplying the mobile types to MTAlloc 2009-03-20 21:20:43 +00:00
Neil Brown
1d43b9d7bd Poked the mobile and record stuff until cgtest83 compiles (it blows up on running, but it compiles) 2009-03-20 19:24:54 +00:00
Neil Brown
bbabef868c Moved the comma-related helper functions to the GenerateCBased module 2009-03-20 19:24:20 +00:00
Neil Brown
1044a94730 Changed most of the rest of Tock (except some tests) to understand the new record attributes 2009-03-20 15:18:29 +00:00
Neil Brown
e79fa43fa2 Fixed the last few of the channel uses to request abbreviations of channels when using them 2009-03-21 23:24:21 +00:00
Neil Brown
bf2f50ba2c Removed a lot of commented out old code in the C backend 2009-03-21 23:03:46 +00:00
Neil Brown
defca6e34d Started simplifying some of the C backend in light of the new changes, and made a few fixes
The first few cgtests (at least) now pass with the new system in the C backend.
2009-03-21 22:59:25 +00:00
Neil Brown
b6b0577ecd Fixed directed variables (for the C++ backend) 2009-03-21 21:01:25 +00:00
Neil Brown
8e768e2b25 Started fixing up the new variable stuff to work with mobiles 2009-03-21 20:50:06 +00:00
Neil Brown
87fefcb66d Fiddled with the new variable stuff in the C backend, and now variable subscripts seem to work 2009-03-21 19:30:29 +00:00
Neil Brown
ca207f7291 Quickly implemented the first version of a revamp of the genVariable code in the C backend
Surprisingly, the generated code seems to be compiled by GCC without warnings.  Array subscripts are currently unimplemented (a star, i.e. equivalent of subscript 0) is used wherever there should be a subscript.

The new mechanism is based on working out the C type of the original variable/abbrev-mode, the C type of the desired variable/abbrev-mode, and works out how many *s or &s to insert to coerce it to the right type.
2009-03-21 18:43:32 +00:00
Neil Brown
56cd7d73c4 Changed the channel-output code generation so that it knows the desired type being sent 2009-03-20 11:37:52 +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
3c4f76ed46 Fixed the memory leaks arising from not clearing mobiles before an input 2009-03-19 18:18:17 +00:00
Neil Brown
7d3e9e8648 Stopped MTRelease being called with a NULL pointer 2009-03-19 16:59:19 +00:00
Neil Brown
65875f523f Added mobile cloning rather than using dereferencing to copy mobiles 2009-03-19 16:47:31 +00:00
Neil Brown
8e5e73e3a2 Fixed the support in the backends for mobile channel stuff 2009-03-19 15:23:35 +00:00
Neil Brown
a995d29c32 Moved the mobile stuff across to use the CCSP API 2009-03-19 11:33:09 +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
9614d5f7f9 Fixed the intrinsic PROCs to be generated correctly 2009-02-27 17:13:18 +00:00
Neil Brown
18f23bf767 Fixed a small problem with the types of arrays of channel-ends in the C++ generation 2009-02-10 22:21:13 +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
1cde2bd959 Added a few useful error messages in the C backend 2009-02-02 18:26:12 +00:00
Neil Brown
cbeeef486e Fixed the C backend putting too many braces in array literals, and removed some old comments 2009-02-01 22:27:43 +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
3e8273f4f6 Adjusted the C backend to work with the new step count 2009-01-28 23:51:19 +00:00
Neil Brown
9b1368ffe7 Implemented all but one (RAN) of the intrinsic functions in appendix N by mapping them directly to the C versions 2009-01-27 13:38:00 +00:00
Neil Brown
0b2708b2ed Fixed a few small things related to generating intrinsic calls in the C and C++ backends 2009-01-25 20:43:39 +00:00
Neil Brown
0189ba3793 Began implementing the occam intrinsics (some of them, at least) in the C support header 2009-01-23 19:20:26 +00:00
Neil Brown
1410e80fb1 Added support for intrinsic functions with multiple return values
Previously, such a function was an IntrinsicFunctionCall inside one expression of an ExpressionList, which the type-checker rejected.  I've had to add a new constructor to ExpressionList, and I've quickly hacked together the line in the C backend to make it work -- but it does seem to work.
2009-01-23 18:58:52 +00:00
Neil Brown
7457d894f8 Tweaked the C and C++ backends to take the replacement for Int from the TypeSizes module rather than calculate it locally 2009-01-23 15:52:28 +00:00
Neil Brown
492091030d Fixed the C and C++ backends to work with the new channel-end system 2009-01-20 17:41:25 +00:00
Neil Brown
d3fc6a1a90 Made the size of INT vary between 16-,32- and 64-bit platforms
Fixes #37.  The change itself was very easy, but the main problem was to then go and change everything in GenerateCTest that had been written using A.Int as a test type.
2009-01-18 20:10:19 +00:00
Neil Brown
24f646f5b8 Changed if statements so that they generate a simpler if when no specs are involved
Fixes #16.  If there are no Spec or ProcThen items in an if, a much simpler if (without gotos or similar) is generated.
2009-01-18 19:33:01 +00:00
Neil Brown
4e582d8c3a Quickly added poison to the C++ backend 2008-09-12 21:05:11 +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
ad875bd477 Fix abbreviation of channel ends in the C backend.
I'm pretty sure this test used to fail and got fixed, but I think the
test was fixed to match the incorrect code rather than the other way
around. What it's testing is the abbreviation of a channel end as an
identically-typed channel end, which (since they're both pointers)
should look something like:

Channel *c;
Channel *d = c;

Instead it was generating "d = &c", which broke cgtest87.

The change made to GenerateC to fix this feels a bit awkward to me --
it's very simple, but it's yet another special case in genVariableAM.
All of the genVariable code could really use reworking (again),
perhaps to use some internal representation of the C expression...
2008-06-09 21:19:01 +00:00
Neil Brown
cfbdfc555e Fixed a discrepancy between the C and C++ backends over generating the code for replicators 2008-06-04 18:53:42 +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
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
Neil Brown
104bdf5d0a Fixed genBytesIn for mobile and list types in the C backend 2008-06-01 19:50:53 +00:00
Neil Brown
4e6b166696 Fixed implicit mobility to work in the (C++, at least) backend 2008-06-01 19:46:32 +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
5d8d96fb7a GenerateC doesn't need Text.Regex any more. 2008-05-25 18:42:18 +00:00
Neil Brown
20a142839f Added the beginnings of list support for CCSP (using glib) 2008-03-25 18:44:49 +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
9e9459cb4a Clean up EvalLiterals.
In particular, evalSimpleLiteral is now much nicer, and the error
messages should be a bit more comprehensible.

The signed types previously used a different version of fromRead that
passed an extra argument that it then didn't use; I've switched back to
the old version now, since it appears not to need it any more.
2008-04-08 00:29:23 +00:00
Adam Sampson
28f329dd07 Don't assume an empty array literal can be a string literal. 2008-04-06 15:33:18 +00:00
Adam Sampson
17da4db956 Make genActual(s) use the correct abbreviation mode. 2008-04-01 13:16:23 +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
2d0d6463d5 Removed the handling of the old Rain Wait/GetTime items from the backends 2008-03-24 15:08:05 +00:00
Neil Brown
c68aa42277 Added a sub-type to Timers, to support multiple types 2008-03-23 22:20:16 +00:00
Neil Brown
fc4cac736b Added the helper functions for adding and subtracting Times in C++CSP 2008-03-23 13:29:22 +00:00
Neil Brown
cc6dce5ead Tidied up the export/import lists for GenerateC and GenerateCPPCSP 2008-03-23 12:40:06 +00:00
Neil Brown
bc7e682119 Added a Concat operator for lists, and added support for it (and list assignment) to the backends 2008-03-21 19:20:15 +00:00
Neil Brown
b496912c51 Fixed conflicts with Adam's dimension changes 2008-03-19 17:49:32 +00:00
Neil Brown
839d92546b Altered the backends to support lists and foreach loops over lists (at least in the C++ part) 2008-03-19 17:20:52 +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
1124bb5a44 Use either Alt or TimerAlt as appropriate. 2008-03-15 15:15:21 +00:00
Adam Sampson
54668d3ba2 Implement the RESCHEDULE intrinsic. 2008-03-15 11:00:11 +00:00
Adam Sampson
4a68dda2b5 Clean up the generation of wrapper Procs for Pars.
Procs that are in csParProcs are now generated with the correct calling
convention directly, rather than having a second wrapper function generated
around them.
2008-03-14 22:01:59 +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
88af6a29d2 Abstract CCSP setup into a function, and set up terminal properly.
If stdin is in use, it'll now be put into non-canonical mode. This is almost
the same as libkrocif's behaviour, except I've set VTIME to 0, since I don't
think there's a good reason to have a terminal read complete if no characters
are available.

This also sets CCSP's branding to "Tock", so error messages now start "Tock: ".
2008-03-12 14:38:58 +00:00
Adam Sampson
f2d3280cee Abstract killing TLP channel handlers out into a function. 2008-03-12 10:47:19 +00:00
Adam Sampson
8880413128 Use TimerAlt rather than Alt.
It really ought to pick the right one depending on whether there are any timer
guards.
2008-03-11 18:52:35 +00:00
Adam Sampson
7eaab68f04 Implement TLP output channels using a CIF helper process.
Input channels will be similar, but are stubbed out for now.
2008-03-11 18:47:48 +00:00
Adam Sampson
882d0c002a Remove debugging code. 2008-03-11 17:43:54 +00:00
Adam Sampson
8aae275895 Fix ALT enabling in the C backend. 2008-03-10 11:38:25 +00:00
Neil Brown
9533fa9926 Reversed the effect of an earlier patch (to put timers back in the C++ backend) now that I've seen Adam's patch that fixes it anyway 2008-03-09 19:04:34 +00:00
Neil Brown
76aeabe747 Fixed genRetypesSizes to work properly again with arrays with a non-fixed dimension (oops) 2008-03-09 18:54:37 +00:00
Neil Brown
3189c066b5 Fixed genRetypeSizes and its associated tests in light of the new array sizes passes 2008-03-09 16:58:05 +00:00
Neil Brown
0265063250 Re-added the index checking for array slices in the backend 2008-03-09 16:19:01 +00:00
Neil Brown
3d1945b517 Changed the code handling SizeVariable to output the size as an integer if it is known 2008-03-09 16:18:13 +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
c733ac2cff Fixed the C++ backends so that it continues to declare timer variables, even though the C backend doesn't any more 2008-03-09 12:48:26 +00:00
Neil Brown
ba75f5b06c Removed the initialiser expression on the Declaration item in the AST 2008-03-09 00:23:13 +00:00
Adam Sampson
f8d4efa0e9 Go back to generating Time variables for timers.
This is for two reasons: first, the C++CSP backend still needs them, and
second, the way I'd done the removal wasn't correct; since you can have arrays
of them, abbreviate them, etc., they need to be stripped out by an earlier
pass so that other passes don't try to operate upon them.
2008-03-09 11:57:43 +00:00
Adam Sampson
35538cda36 Resolve conflicts.
This simplifies the formals/actuals stuff enough that most of it can probably
go away (once it's made to work again).
2008-03-08 17:18:22 +00:00
Neil Brown
ba9ac70d7c Changed the C and C++ backends to write directly to the output file, to save building up the strings in memory 2008-03-08 14:10:05 +00:00
Neil Brown
c87581e490 Tidied up the export list for the GenerateC module 2008-03-08 14:03:10 +00:00
Neil Brown
e1fd001322 Fixed a bug relating to not initialising C channel arrays properly (an over-enthusiastic trimming earlier) 2008-03-08 13:42:36 +00:00