Commit Graph

271 Commits

Author SHA1 Message Date
Neil Brown
8f767ff0d4 Made all the imports of Data.Generics have an import list
This makes sure that we catch all leftover instances of using SYB to do generic operations that we should be using Polyplate for instead.  Most modules should only import Data, and possibly Typeable.
2009-04-09 15:36:37 +00:00
Neil Brown
e61a23855a Fixed all the conflicts while merging into the Polyplate branch 2009-04-09 11:01:39 +00:00
Neil Brown
d49c7fad4a Fixed all the modules in the backends directory to work with the new Pass system 2008-12-14 18:32:34 +00:00
Neil Brown
47d565a3b9 Changed records to always use their original name in the C code
This fixes the problem with PROCs complaining that one munged version of the record name was not the same as another.

This will cause problems if two different record definitions for the same name are visible in the same file.
2009-04-12 13:06:49 +00:00
Neil Brown
7a7eefa33e Changed inline items to always be static
I'm not sure if this is a valid thing to do, but it solved a problem with the occam libraries where multiple occam files were including an inline FUNCTION from an include file, and this was causing problems at link time.
2009-04-12 13:02:58 +00:00
Neil Brown
2308c6571c Fixed assignment of arrays to work when dimensions are missing (helps with the initialisers for mobile allocations) 2009-04-09 17:09:50 +00:00
Neil Brown
98ffb74505 Corrected cgenVariableWithAM to work properly (and be a little cleaner) for generating VariableSizes 2009-04-09 17:09:23 +00:00
Neil Brown
229f2197af Turned findMeta into a member of a FindMeta type-class 2009-04-09 11:13:37 +00:00
Neil Brown
debdef4f4f Fixed the generation of directed channels for the C++ backend 2009-04-08 19:14:29 +00:00
Neil Brown
5a7f68a44f Removed some of the old C generation functions, and added a new one (genFunctionCall) to get the C++ backend compiling again 2009-04-08 16:07:01 +00:00
Neil Brown
7bd4e3d309 Added functions to the list of things that need stack sizes, even if they are external
I think this is not quite right, but for now it fixes stack sizes not being generated for any non-inlined standard operators.
2009-04-07 15:42:37 +00:00
Neil Brown
c4f625b1ba Overhauled the support headers to add most of the missing occam operators as inline functions 2009-04-06 00:56:06 +00:00
Neil Brown
6d6d26d5d6 Fixed the backends to work with the new system (mainly removing unnecessary code) 2009-04-05 23:06:47 +00:00
Neil Brown
e457d82f0c Changed FUNCTIONs and PROCs to have optional bodies, and put all the externals into the AST (without bodies)
This may seem like an odd change, but it simplifies the logic a lot.  I kept having problems with passes not operating on externals (e.g. functions-to-procs, adding array sizes, constant folding in array dimensions) and adding a special case every time to also process the externals was getting silly.

Putting the externals in the AST therefore made sense, but I didn't want to just add dummy bodies as this would cause them to throw up errors (e.g. in the type-checking for functions).  So I turned the bodies into a Maybe type, and that has worked out well.

I also stopped storing the formals in csExternals (since they are now in csNames, and the tree), which streamlined that nicely, and stopped me having to keep them up to date.
2009-04-04 14:56:35 +00:00
Neil Brown
b9cbcf0902 Added the intrinsic CAUSEERROR 2009-04-03 15:14:24 +00:00
Neil Brown
b803b1ec91 Reworked how stack sizes are calculated, and changed how we use them in the build process
Now that we support separate compilation, some of the stack sizes for PROCs depend on the stack sizes of other PROCs that were compiled in different files.  We can't just assume the default 512 bytes for these "foreign" PROCs, because that often won't be enough.  So instead, we must make the stack sizes for the current PROCs depend on (i.e. use in the calculation) the stack sizes of the foreign PROCs.

This dependence adds some issues though.  We cannot declare in one C file a const int that depends on the value of an extern const int from another C file (not valid C, it seems).  So instead, we move all the stack size declarations to header files, and use #includes and the preprocessor to make sure that the stack sizes are statically determined.

This in turn simplifies the build process in some ways.  These headers only need to be compiled by the .occ file that has the main process, by including them all into a C file and compiling that as before.  It means that each .occ file only has one .o file resulting (plus two C headers*, and a .inc file) so linking is a bit less confusing.

* I am keeping the two C headers for now, rather than appending the sizes one to the normal header, because I'm not entirely sure whether having one header that the C file depends on may trigger a recompilation that we don't want in some build systems.  I can always merge them later if that's not a valid worry.
2009-04-03 12:24:53 +00:00
Neil Brown
9bf32e339d Made sure that the names printed in TOCKEXTERNAL pragmas are fully munged (and thus equivalent to the exact C function name) 2009-04-03 12:22:19 +00:00
Neil Brown
ca332a0925 Changed the asm-analysis to only generate stack-sizes for PROCs, and not non-PROCs or external PROCs
This just about works, but it allocates the usual 512 bytes for all external PROCs being called, rather than using the actual stack_size for those external PROCs (this causes popcorn to overflow the stack if left with the default 512 bytes)
2009-04-02 20:04:21 +00:00
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