Commit Graph

1278 Commits

Author SHA1 Message Date
Neil Brown
81ea069707 Added a dummy implementation of a new pass, declareSizesArray, and the tests for it 2008-03-03 15:02:07 +00:00
Adam Sampson
2f7539bcdb Convert the C backend to the new CIF API (mostly).
Most of this is mechanical: changing function names, and carrying the "wptr"
argument around. I've made the code for computing Expressions from Structureds
a bit more generic too.

The only complex bit is the handling of PAR processes, which I'm not very happy
with at the moment; they used to use the normal C calling convention, but now
you need to pack the arguments into the workspace. I'm handling this at the
moment by generating wrapper functions that do the unpacking, but it would be
better in the future to make the wrapper PROCs that we already generate have
the right interface.

This won't work for programs that use any of the top-level channels yet, since
there are no handlers for them.
2008-03-07 17:50:10 +00:00
Adam Sampson
87a1c39411 Fix recursion in identifyParProcs that broke testcases/par.occ.
It wasn't looking for PROC definitions inside Specs. This is a good example of
a pass that really wants a trimmed "everywhere"/"contexts" rather than explicit
recursion.
2008-03-07 17:28:30 +00:00
Adam Sampson
8aabb0c98e Add a missing fold marker. 2008-03-07 17:02:03 +00:00
Adam Sampson
337527a544 Remove obsolete comment -- Structured is parametric now. 2008-03-07 14:42:46 +00:00
Neil Brown
20f7666044 Refactored cgenArraySubscript ready to add support for static dimensions 2008-03-01 20:39:45 +00:00
Neil Brown
60daa07b93 Renamed one of the array functions in the function table to be clearer 2008-03-01 20:22:34 +00:00
Neil Brown
01ac2ef21d Fixed an odd monomorphism restriction warning 2008-03-01 20:13:11 +00:00
Adam Sampson
50967cba95 Split the common C99/C++ support code out into a separate header.
Or, rather, add a new CIF-specific header, so tock_support.h is now the common
code and each of the backends has its own. This means some of the conditional
stuff can go away.
2008-03-05 16:54:29 +00:00
Adam Sampson
bb419d28b7 Move the headers into their own directory, and install them.
This should make it possible to use Tock from outside its own source directory.
2008-03-05 16:43:15 +00:00
Adam Sampson
a621daac9f Make the backend a variable in cgtests.mk. 2008-03-05 16:30:06 +00:00
Adam Sampson
aff90d8d45 Some initial shuffling to get Tock working with the new CIF.
This changes the TLP code to use CCSP's stand-alone mode, and gets rid of the
old KRoC wrapper stuff. It also changes occam_stop everywhere in order to pass
the number of arguments (since ExternalCallN needs that now), and cleans up the
interaction with the C++ backend a bit.
2008-03-05 16:21:20 +00:00
Adam Sampson
10d17f4b23 Remove a chunk of dead code from the C support header. 2008-03-04 14:05:55 +00:00
Adam Sampson
d2c0fd674e Rework the code for getting errors through the parser.
This used to work by adding a magic prefix to the error message, but it appears
that doesn't work with the GHC 6.6 version of Parsec. It now searches for a
magic substring anywhere in the error message.

It uses // as a delimeter rather than \0 now, since including nulls in Strings
causes problems -- for example, putStr "a\0b" will only print "a".
2008-03-04 12:52:25 +00:00
Adam Sampson
7ec6566495 Return sensible Meta from ParseOccam failures.
This means we get the nice annotated source display on a parser failure --
although we still get not-very-useful descriptions of errors sometimes...
2008-03-04 11:59:13 +00:00
Adam Sampson
168628576d Rework how temporary files are named.
The temporary files used during compilation are now just the output name with
an appropriate extension added (so when compiling to cgtest02, it'll produce
cgtest02.cpp, etc.). This is what GCC and KRoC do; it keeps the temp files with
the binaries that were produced from them, and avoids having to pick a sensible
directory to put randomly-named temp files in.
2008-02-29 22:53:45 +00:00
Adam Sampson
d048a0ef71 Clean up Main.hs.
This particular file was badly in need of some love, being some of the first
code I wrote on Tock, and thus being a mix of my early style, my late style,
and Neil's style. I've cleaned it up quite a bit, fixing whitespace damage and
dodgy indentation, and making sure lists are alphabetised.
2008-02-29 22:06:37 +00:00
Adam Sampson
58f0775411 Add a checkout target to cgtests.mk. 2008-02-29 21:46:45 +00:00
Neil Brown
49585a1922 Added a constructor to record types to help build record literals (especially those that contain array literals) 2008-02-29 16:44:00 +00:00
Neil Brown
08d02bfb17 Changed the behaviour of assignment for records
Previously, assignments of records were directly flattened into assignment of each of the fields.  Now, we instead generate a copy_<recordname> inline procedure for each record definition, and compile code that uses that (for C++, we could even make this an operator= implementation later on).  This allows us to re-use the proc later in the C/C++ backends if needed.
2008-02-29 16:36:47 +00:00
Neil Brown
f5022228ba Fixed typeOfSpec to use the recorded type rather than trying to dig it out of the inner expression/variable 2008-02-29 16:33:33 +00:00
Neil Brown
9ab6cbc0b4 Changed the pullUp function to behave differently for C than C++ (pulling up of array literals inside record literals) 2008-02-29 03:05:52 +00:00
Neil Brown
55ed3e9984 Fixed the shift helper functions to work for int 2008-02-29 03:05:36 +00:00
Neil Brown
79b5e8edb0 Fixed the signed/unsigned comparison warnings in the shift helper functions 2008-02-29 00:28:31 +00:00
Neil Brown
24dc839cfb Added helper functions for PLUS, MINUS and TIMES to help constrain the result types and prevent surprising integer promotions 2008-02-29 00:20:52 +00:00
Neil Brown
2ca965ebf0 Added a missing definition of the lshift/rshift C helper functions for bytes (uint8_t) 2008-02-28 16:55:41 +00:00
Neil Brown
1e92333778 Added a try to fix the parsing of BYTESIN with a not obviously constant array dimension 2008-02-28 16:55:11 +00:00
Adam Sampson
6456dad42e Add cgtests.mk, which builds the cgtests using GNU make.
This may go away, or it may end up as a replacement for compile-cgtests.
2008-02-29 17:13:19 +00:00
Adam Sampson
d021edbd48 Add some reserved words that show up in ASM blocks. 2008-02-29 17:11:17 +00:00
Adam Sampson
a2a15cab64 Split include file expansion out into a separate pass.
The order of initial passes is now:
  lex -> preprocess -> structure -> expand-include -> parse
which means that #IFing out structurally-invalid code (like inline VALOF) now
works.  This also cleans up the preprocessor code a bit.
2008-02-29 15:01:19 +00:00
Adam Sampson
d7fbd93816 Add some tests for structureOccam. 2008-02-29 14:08:57 +00:00
Adam Sampson
2f407fc2cd Pass CFLAGS/CXXFLAGS/CPPFLAGS/LDFLAGS through into Tock's built-in options. 2008-02-29 11:16:35 +00:00
Adam Sampson
cbcccae96c Don't clobber CFLAGS/CPPFLAGS while configuring. 2008-02-29 11:09:18 +00:00
Adam Sampson
c8b6be34e1 Implement comparisons in preprocessor expressions.
This brings Tock's conditional compilation facilities up to par with occ21.
2008-02-29 00:23:49 +00:00
Adam Sampson
a5fd73130a Use Parsec to parse #DEFINE directives.
This is much neater, and I'll need most of the code to implement comparisons anyway.
2008-02-28 23:47:06 +00:00
Neil Brown
6d4f1dd702 Added labels to all the top-level tests that didn't have one 2008-02-28 16:11:01 +00:00
Neil Brown
cb8327451d Added the ability to apply a filter to which HUnit tests you run 2008-02-28 16:08:36 +00:00
Neil Brown
b3458ec541 Corrected the pointer indirection for records inside records 2008-02-28 16:08:06 +00:00
Neil Brown
62e45a8909 Added a missed new C/C++ test to the list of tests to run 2008-02-28 15:33:08 +00:00
Neil Brown
d73f2f509c Added some template types to one of the uses of tockArrayView to please the C++ compiler, and adjusted the tests accordingly 2008-02-28 15:32:26 +00:00
Adam Sampson
8f2575819b Initial implementation of the occam-pi preprocessor.
This implements #DEFINE, #UNDEF, #IF, #ELSE and #ENDIF, macro expansion with
##, and TRUE, FALSE, AND, OR, NOT and DEFINED within #IF expressions, with the
same semantics as occ21.

The macro COMPILER.TOCK is always defined by default, so you can now say things
like "#IF NOT DEFINED (COMPILER.TOCK) ... #ENDIF".
2008-02-28 20:27:30 +00:00
Adam Sampson
62b9c9b105 Prefix pass test output with the pass name ++ ": " consistently. 2008-02-28 16:51:53 +00:00
Adam Sampson
06ad1e5e06 Clean up the documentation hack a bit.
We now postprocess all the generated HTML using M4, so we can hide the SVG
images behind macros (and we can now use images inside the main documentation
too).
2008-02-28 14:43:53 +00:00
Adam Sampson
8d06c3d180 Various tweaks to the Haddock comments to get it building with 0.8 again. 2008-02-28 14:20:34 +00:00
Neil Brown
0ecb7146e4 Fixed the implementation of REM for floating point types 2008-02-27 20:56:13 +00:00
Neil Brown
8da136a3b6 Added the -v flag when compiling the cgtests, so that I have something to look at 2008-02-27 20:35:26 +00:00
Neil Brown
a4424ee82d Fixed a few dependencies in the pass lists relating to functions 2008-02-27 20:05:47 +00:00
Neil Brown
4a0d199406 Fixed the keep temporaries thing so that it still keeps them when the compilation succeeds, not just when it dies 2008-02-27 19:58:32 +00:00
Neil Brown
46de1956b3 Corrected the pulling up of SEQ replicator counts to descend properly into nested functions 2008-02-27 19:58:09 +00:00
Neil Brown
86c17fed99 Added a pass for pulling up the replicator counts in SEQs so that the count is constant for the whole loop 2008-02-27 19:33:44 +00:00