Commit Graph

315 Commits

Author SHA1 Message Date
Neil Brown
6afbb80e9f Fixed some of the test modules to work with the new array literals and constructors 2009-02-03 11:19:21 +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
4f83187549 Fixed up all the tests in light of the new recursive procs 2009-01-29 00:56:32 +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
a4f0e85c72 Fixed a bug involving abbreviation of arrays of channels into arrays of channel-ends in the C++ backend
The array for the channel-ends was not being allocated storage, so the array (a pointer to some random location) was being written to and causing a seg-fault
2009-01-28 23:16:31 +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
dbc75ef0b1 Added a pass that helps stop some GCC warnings about literals equivalent to INT_MIN and similar 2009-01-27 13:00:08 +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
91f004a197 Realised that with channel-ends for C++CSP, I want to use AltChanin everywhere, not Chanin 2009-01-23 18:10:51 +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
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
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
8bae96f34e Took care of directed arrays in the passes that generate _sizes arrays 2009-01-20 17:38:18 +00:00
Neil Brown
cc70438c1b Added a pass to remove unneeded directions, i.e. c! where c is already an output end 2009-01-20 17:36:40 +00:00
Neil Brown
c6959ac854 Stopped removeDirections operating on the C++ backend, where we actually want to keep the directions 2009-01-20 17:36:02 +00:00
Neil Brown
0b75720e2e Fixed the TLP mechanisms to work with the new channel-end system 2009-01-20 17:35:31 +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
536d0b19a6 Fixed all the failing C++CSP tests for input and output so that they now pass 2009-01-17 22:20:52 +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
6cbdc0e13b Finally merged the list of warnings into CompState rather than having its own StateT monad 2008-11-20 13:35:44 +00:00
Neil Brown
9be287f157 Fixed the C++CSP backend's use of channels (this fixes occam but probably breaks Rain, but I can come back to it later) 2008-11-13 21:00:56 +00:00
Neil Brown
0d486f108f Added a value to indicate what type a warning is (to support future configurability) and streamlined the warning functions 2008-11-13 15:36:22 +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
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
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
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
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
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
Neil Brown
3aecc9be3f Quickly fixed an old broken GenerateC test for lists 2008-06-01 17:29:36 +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
Adam Sampson
b413cf3dc2 Fix some broken Haddock. 2008-05-25 18:49:15 +00:00
Adam Sampson
5d8d96fb7a GenerateC doesn't need Text.Regex any more. 2008-05-25 18:42:18 +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