Commit Graph

303 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
b76676eca8 Fixed a few more missing-static problems 2009-04-02 19:33:09 +00:00
Neil Brown
4ea3357129 Rolling back earlier patch, the header should come after the declarations, now that records are not in the headers 2009-04-02 16:51:11 +00:00
Neil Brown
aa2b31718a Moved the header inclusion to be before forward declarations, as often the latter use the former 2009-04-02 15:51:34 +00:00
Neil Brown
350057c314 Made sure that non-top-level specs still have forward declarations in the .c file (and not in the .h file) 2009-04-02 15:43:49 +00:00
Neil Brown
f69030df34 Changed the names of generated tock files to have ".tock" before the extension
This helps avoid collisions with pre-existing files, especially .inc files (but also .c and .h)
2009-04-02 15:40:39 +00:00
Neil Brown
ea14f568fa Removed genProcName
Everything that used it has now switched back to genName, as we don't need this occam_ prefix with the new name munging stuff from earlier patches.
2009-04-02 15:39:19 +00:00
Neil Brown
37ff130ec9 Stopped static being generated in front of typedef 2009-04-01 19:58:30 +00:00
Neil Brown
ef36c39c38 Stopped the C code generating extern declarations for occam PROCs (it should only do this for C PROCs) 2009-04-01 19:51:43 +00:00
Neil Brown
e28bff5a50 Added code to put static before every identifier that is not being exported, to avoid collisions between occam files 2009-04-01 19:50:15 +00:00
Neil Brown
a1d9fcdff2 Fixed a bug in the C types for arrays of channel-ends 2009-04-01 19:25:19 +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
8153cfc659 Added code for full compilation mode to include the relevant C files from occam #USE directives, and link to the relevant object files 2009-04-01 18:32:39 +00:00
Neil Brown
d457b793c0 Added code that allows any external PROCs not beginning with B or C to be handled as normal
This shows that my current scheme is a bit of a hack; if an occam programmer starts a normal PROC with B or C, it will be treated funny during separate compilation.  In future I probably need some new form of #PRAGMA to support separate compilation, different from that used to interface with C.
2009-04-01 17:29:32 +00:00
Neil Brown
db9b8e9d91 Changed where we generate the .inc file from being in the backend, to being a pass just after type-checking
We need to generate the externals after we've inferred channel directions, but before we do further work (like adding _sizes parameters and so on).
2009-04-01 16:54:07 +00:00
Neil Brown
abce001bab Added a command line option to indicate that there is no main PROC 2009-04-01 15:29:22 +00:00
Neil Brown
219bfd9ce1 Modified the C backend so that it will put the forward declarations into a header file and include that 2009-04-01 14:35:47 +00:00
Neil Brown
e9730bfe1e Got the C++ backend working again, on the cgtests at least 2009-04-01 15:25:18 +00:00
Neil Brown
e91c075bcf Fixed up a lot of the failing tests
I changed a little bit of the code, but mainly the tests.  Several of the remaining failures are actually real failures, so I need to dig through the rest carefully.  A lot are failing because the C++ backend is broken.
2009-04-01 11:49:37 +00:00
Neil Brown
bea4dcfd80 Took out some C garbage, which gets around 200 more tests passing 2009-03-31 18:02:39 +00:00
Neil Brown
2941cbd049 Fixed a problem with record abbreviations being pulled all the way up to the top (which C doesn't like) 2009-03-31 16:50:42 +00:00
Neil Brown
91ce2fe960 Fixed generation of actuals that are ActualExpression (ExprVariable {}) 2009-03-31 16:08:37 +00:00
Neil Brown
edc336de7a Fixed a bug when generating some no-arg PROCs 2009-03-31 10:50:52 +00:00
Neil Brown
dbf886996a Removed various bits of old code relating to the old sizes mechanism 2009-03-31 10:50:04 +00:00
Neil Brown
a10921d53a Fixed the last few uses of genSizeSuffix in GenerateC to use the new system instead 2009-03-31 09:35:59 +00:00
Neil Brown
f749967af4 Added some cases inside genVariable to handle the VariableSizes item
For mobile arrays, this uses the ->dimensions member.  For normal arrays, it uses the associated sizes array (by looking it up in CompState).
2009-03-31 09:34:36 +00:00
Neil Brown
298ba6465a Removed genSizeSuffix and turned most uses of it into calls to genDynamicDim 2009-03-31 09:29:55 +00:00
Neil Brown
b8daebfbc3 Made genDynamicDim a top-level function, and change its implementation to use VariableSizes rather than C-specific stuff 2009-03-31 09:28:45 +00:00
Neil Brown
ecc42f704d Fixed all the nasty hacks from earlier relating to running processes in parallel 2009-03-27 21:35:28 +00:00
Neil Brown
0ca5bb17d7 A collection of nasty hacks to get Tock's replicated PARs working, and to stop memory leaking
All the changes in this patch should be undone as soon as possible (building the list of workspaces, and how we sort out the enrollment counts -- that should be done by pulling up PAR replicator counts outside the whole PAR), but for now, it works.
2009-03-27 17:26:37 +00:00
Neil Brown
2237d15247 Various fixes in the C backend to get oak working 2009-03-27 16:29:06 +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
eb99480484 Finished off the support for external C functions 2009-03-26 22:37:28 +00:00
Neil Brown
733293745e Added a work-around for generating infinity and NaN in the C backend 2009-03-26 18:39:23 +00:00
Neil Brown
1c4d44b739 Fixed generation of C types for channels (somewhere, one is being abbreviated with ValAbbrev, so I'll allow it for now) 2009-03-25 18:27:13 +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
eaa8ece954 Fixed allocation of mobile channel bundles, as apparently a clone is unnecessary 2009-03-24 23:54:13 +00:00
Neil Brown
e269efe388 Added some quick hacks to make recursive PROCs work
This is along the lines of the Tock ticket.  cgtest90 (recursive FUNCTIONs) now passes, but cgtest91 (recursive PROCs) doesn't, because it uses barriers.
2009-03-24 00:14:14 +00:00
Neil Brown
e08197bbef Added various bits for shared channels, which now means that cgtest86 compiles and passes 2009-03-24 00:08:02 +00:00
Neil Brown
10b4cd7cfc Realised that allocating mobile arrays as arrays of bytes screws up the resize intrinsic, and gave it a helping hand 2009-03-23 21:28:28 +00:00
Neil Brown
d3f4ff1a9a Corrected BYTESIN for mobile arrays 2009-03-23 21:18:52 +00:00
Neil Brown
658bfd08e4 Added some code to deal with channel bundles 2009-03-23 21:14:10 +00:00
Neil Brown
7458014c2c Fixed the C types for records, again 2009-03-23 21:13:55 +00:00
Neil Brown
585a5ed477 Realised that mobile arrays should be allocated after all, unless they are missing a dimension 2009-03-23 21:13:13 +00:00
Neil Brown
3739ff7cbd Added some extra paranoid bracketing 2009-03-23 21:12:46 +00:00
Neil Brown
9c433b248a Tried using my new CCSP helper function to allocate arrays 2009-03-23 18:59:57 +00:00
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