Commit Graph

2327 Commits

Author SHA1 Message Date
Neil Brown
0466a50dfa Changed the build process to support a directory to put modules and includes in, and added a dummy lib (occamutl) 2009-04-04 12:28:47 +00:00
Neil Brown
18f37a0d96 Made it easier to print out a plain String after processing the command-line options 2009-04-04 12:27:56 +00:00
Neil Brown
c9f9eb8587 Added a couple of filter calls to the usage checking to speed it up
It now removes empty sets of (relevant) background knowledge to avoid needlessly creating lots of problems (thousands!) when it only needs one, and also stopped it checking array usage when there's at most one written-to/read-from index.

Fixes #90
2009-04-04 08:52:41 +00:00
Neil Brown
f755458545 Turned *EXTERNAL pragmas into specifications in the occam parser
There was a bug where things scoped in via pragmas were never scoped out again, which was screwing up the local names stack.  I then realised/decided that pragmas were really specifications, and decided to put them there in the parser.

The rest of this patch is just some rewiring to allow the special name munging involved in pragmas (they have already got a munged version of their name) and to stop the scoped in pragmas appearing in the AST.
2009-04-03 21:06:24 +00:00
Neil Brown
4a36d578c0 Added a check that the names being scoped out match the names that were scoped in, which helps find bugs in the parser 2009-04-03 21:03:19 +00:00
Neil Brown
45db9cdd27 Realised that my bits and bytes per word were somewhat mixed up 2009-04-03 20:19:48 +00:00
Neil Brown
c0ead7b5a8 Added some of the standard occam defines, such as TARGET.BITS.PER.WORD
For the moment, TARGET.HAS.FPU is left out, because a lot of occam libraries seem to do ASM if it's defined, and we can't handle ASM
2009-04-03 17:55:12 +00:00
Neil Brown
8170d9569d Added some code to Tock to be able to handle unlexable ASM blocks in source files 2009-04-03 17:54:13 +00:00
Neil Brown
9fbbe87fd4 Fixed the reading of floating point literals to work for negative numbers 2009-04-03 17:53:10 +00:00
Neil Brown
5f124636fb Fixed the name munged to be stable for #USE directives, but use the old name counter for #INCLUDE directives
This is necessary because occam files often #INCLUDE something multiple times (e.g. cgtests) and want different names, but this is not the case for #USE.
2009-04-03 16:52:40 +00:00
Neil Brown
38ffed2bda Stopped the .o file being removed after compilation when the -c flag was given 2009-04-03 16:52:16 +00:00
Neil Brown
081e4f79d4 Added more recognised suffixes to knock off in #USE directives 2009-04-03 16:52:00 +00:00
Neil Brown
427938039c Implemented a search path for Tock (for #INCLUDE and #USE directives) 2009-04-03 16:51:00 +00:00
Neil Brown
8220630426 Attempted to fix a problem with parsing pragmas, but I suspect it's still a bit haphazard 2009-04-03 16:50:41 +00:00
Neil Brown
0d63eeb400 Fixed a small parser bug involving variant 2009-04-03 15:34:33 +00:00
Neil Brown
b9cbcf0902 Added the intrinsic CAUSEERROR 2009-04-03 15:14:24 +00:00
Neil Brown
471c3a1ef5 Allowed #INCLUDE and #USE directives to have comments after the quoted part
I couldn't decide whether to fix this in the parser or the preprocessing code.  I went for the latter, as it was the simplest option.
2009-04-03 14:37:10 +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
d6ad0ba202 Made the name of record-copying PROCs different for each file that generates them, to avoid clashes at link time 2009-04-03 10:25:55 +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
098c4e5ef4 Added -c as an alternative for --no-main 2009-04-02 18:15:02 +00:00
Neil Brown
0e31e98bb2 Made Tock draw in the post-analysis object files when linking 2009-04-02 18:14:40 +00:00
Neil Brown
70789661f1 Got pragma-declared FUNCTIONS to be turned into PROCs and handled properly 2009-04-02 18:13:51 +00:00
Neil Brown
460c3e287f Changed names to be uniquified based on their source position, and fixed the source position for things in pragmas
The second part of the patch is essential, given the first.  Otherwise names in different pragmas in the same file can overlap -- this already happened in oak!
2009-04-02 17:45:31 +00:00
Neil Brown
f5e0288ad0 Added an error message for a backend pass that should never be needed -- but just was 2009-04-02 17:18:34 +00:00
Neil Brown
a843d07463 Changed the pragmas to support FUNCTIONs, and to order the names the other way (as Adam wanted) 2009-04-02 16:57:11 +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
5024e0d615 Fixed the generation of formals that are arrays of channel-ends 2009-04-02 15:58:35 +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
dbd315abd6 Allowed underscores in occam identifiers
I must admit, this was mainly done to allow munged names back in again as valid identifiers.

OEP 144 suggests replacing dot with underscore; this change just allows underscore alongside dot.  It won't break any existing code, and seems like something we want anyway, so I think it's a valid thing to do.
2009-04-02 15:42:26 +00:00
Neil Brown
9e3e71c70a Added a bit of extra help when a name is not found (suggesting other names) 2009-04-02 15:42:02 +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
1cb17a85c4 Removed a lot of the junk from the lexer I'd recently added
The lexer is now roughly as it was a couple of weeks ago.
2009-04-02 15:36:42 +00:00
Neil Brown
51f67f59b4 Reworked the pragma generation again for occam PROCs
One change, based on Adam's suggestion, was to rename the pragma to TOCKEXTERNAL.

Another, also based on Adam's suggestion, was to generate both the munged name and the original name, which allows (along with a previous patch) different files to declare the same PROC, and will remove the need for the occam_ prefix in the backend.

I also stopped using specific states in the lexer, in favour of just using the normal lexing function (which has had its type generalised slightly).
2009-04-02 15:33:32 +00:00
Neil Brown
ca818d423c Made the munging of the names include the file name, to help with separate compilation
This will allow (along with a few patches in a minute) different occam files to declare the same PROC, and have it resolved correctly based on the order of their declaration, just like if it was all in one file.
2009-04-02 15:31:50 +00:00
Neil Brown
c79fd70959 Made sure that warnings are shown along with errors in the parser
The solution is a bit hacky, but this was an important problem.  If your PRAGMA failed to parse, that was worthy of a warning.  But if that then caused the parse to fail, all you would get is the parser error (could not find name), and you would never see the warnings about the pragmas not being recognised.  So now the pragmas are shoved into the error (using a basic encoding) and pulled out and issued if the parser dies.
2009-04-02 15:07:39 +00:00
Neil Brown
a307e39d47 Added a Read instance for Meta (taken from my benchmarks for the ICFP paper) 2009-04-02 15:07:17 +00:00
Neil Brown
3a0b251235 Fixed rangetest to work with the new support headers (it doesn't need the CIF header, only the plain header) 2009-04-02 13:20:35 +00:00
Neil Brown
ba2f62114a Fixed the C tests to compile again after the most recent changes 2009-04-01 19:58:47 +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
c85dc01842 Changed the cgtests Makefile to use the new separate compilation for cglib 2009-04-01 19:25:40 +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