Commit graph

143 commits

Author SHA1 Message Date
Cédric Pasteur c550b09805 Fixed code generated for alias types to arrays 2011-09-09 13:54:29 +02:00
Cédric Pasteur 53043b403c Small fixes in the C backend 2011-09-07 13:24:33 +02:00
Cédric Pasteur eec957cc6a Use underscores for generated variables 2011-09-06 14:42:34 +02:00
Cédric Pasteur 2147402a20 Const should be declared static
Otherwise the C compiler complains about multiple
definitions of the same symbol
2011-09-06 14:31:14 +02:00
Cédric Pasteur 4cd506f3db Added c ast for constant
Also print only short names for struct fields
2011-09-06 14:20:57 +02:00
Cédric Pasteur 8cc879be7a Generate code from interface (.epi) files
It includes the definition of types, constants
and prototypes defined in the interface.
2011-09-06 11:55:06 +02:00
Cédric Pasteur da8956e247 Revert changes
Bring back cvarlist_of_ovarlist with a more 
explicit name to show its specificity
2011-07-22 10:52:31 +02:00
Brice Gelineau 9fb42a5feb Removed unused functions in C generation 2011-07-21 18:01:32 +02:00
Cédric Pasteur a52e80bcad Fixed some TODOs 2011-07-21 11:54:52 +02:00
Cédric Pasteur 7d95b95ed7 Merge branch 'memalloc' into decade
Conflicts:
	compiler/global/signature.ml
	compiler/heptagon/analysis/typing.ml
	compiler/heptagon/hept_printer.ml
	compiler/heptagon/hept_utils.ml
	compiler/heptagon/heptagon.ml
	compiler/heptagon/parsing/hept_parser.mly
	compiler/heptagon/parsing/hept_parsetree.ml
	compiler/heptagon/parsing/hept_scoping.ml
	compiler/heptagon/transformations/switch.ml
	compiler/main/hept2mls.ml
	compiler/minils/minils.ml
	compiler/minils/mls_printer.ml
	compiler/obc/c/cgen.ml
	compiler/obc/control.ml
	compiler/utilities/misc.mli
2011-07-21 08:50:45 +02:00
Brice Gelineau 10115684d9 bugfix for reset calls in C 2011-07-08 10:51:10 +02:00
Cédric Pasteur bb6b9868b0 Use the variable type to add or not an indirection 2011-07-05 17:46:43 +02:00
Léonard Gérard 5837f3906f Multidimensional iterators in java. 2011-06-28 17:50:42 +02:00
Léonard Gérard c5fbcbe765 removing white spaces 2011-06-28 17:50:42 +02:00
Brice Gelineau c70d34ec06 Preliminary version of multidimensional iterators. 2011-06-28 17:50:42 +02:00
Léonard Gérard 83b0182874 Merge branch 'clocked_inputs' into decade
Conflicts:
	compiler/heptagon/analysis/typing.ml
	compiler/heptagon/parsing/hept_scoping.ml
	compiler/heptagon/parsing/hept_static_scoping.ml
	compiler/main/mls2obc.ml
	compiler/obc/c/cmain.ml
2011-06-28 14:46:43 +02:00
Adrien Guatto 4794045208 Reworked Obc AST: from right patterns to extvalues.
I introduced a notion of extended values in Obc expressions,
replacing the Epattern constructor. Patterns may now only
occur at their rightful place, on the left of an assignment.

This change allows to index global constant arrays.
2011-05-30 16:25:00 +02:00
Brice Gelineau 938e8897b2 n-ary Sarray_power Earray_fill 2011-05-26 18:43:30 +02:00
Léonard Gérard 87dc76f113 Code formating fixes (typos, tabs, spaces at endofline,...) 2011-05-26 15:56:59 +02:00
Cédric Pasteur d39e883e08 Filter outputs removed by memalloc 2011-05-25 09:12:16 +02:00
Cédric Pasteur 822e87605b One step closer to code generation with memalloc 2011-05-25 09:12:13 +02:00
Cédric Pasteur 96054a67b6 Correct order for indices in array declaration
In C, the order in the declaration of variables
is the same as for access
2011-05-24 11:16:27 +02:00
Adrien Guatto 36d93a411d Fix generated C code calling between(). 2011-05-12 16:32:52 +02:00
Gwenal Delaval acad16b98a Graphical simulator hepts
Added graphical simulator hepts

Added option -hepts to the compiler: this option formats the output of the simulation loop
to fit with hepts (currently working only on C target code). Typically, suppresses all
"decoration" output, like input or output names, and prints output on single lines.

Currently not implemented in hepts: array types.

Usage: to simulate the node Modulename.f:

heptc -target c -s f -hepts modulename.ept
gcc modulename_c/*.c -o ./f_sim
hepts -mod Modulename -node f -exec ./f_sim
2011-05-12 10:08:13 +02:00
Gwenal Delaval da648254d8 Added type string to pervasives, with string constants in AST 2011-05-10 17:07:17 +02:00
Cédric Pasteur 568dfc59fd Fixed generation of includes in C
The module names must be uncapitalized in includes
2011-05-09 09:50:18 +02:00
Cédric Pasteur c8055cd1ff Fixed bugs with static records in C generation 2011-05-03 13:21:27 +02:00
Adrien Guatto 10418197c8 Initial support for return-less external functions.
The compiler still does not support unsafe functions that well. For example, putting an assert()/exit() in an automaton's state does not work correctly.
2011-04-28 15:24:35 +02:00
Adrien Guatto aa1041319f C backend: do not use memory structs for combinatorial main() functions. 2011-04-27 15:29:33 +02:00
Adrien Guatto 00cb203dd9 Revert "C generation: fixed struct field name in step() call."
This reverts commit fc920d88ea.
2011-04-27 14:02:50 +02:00
Adrien Guatto fc920d88ea C generation: fixed struct field name in step() call. 2011-04-27 11:53:44 +02:00
Cédric Pasteur a2303ec7e1 Other compile fixes
The java backend is disabled temporarily
2011-04-19 09:49:00 +02:00
Cédric Pasteur 3c8fc39745 Fix C backend with new obc ast 2011-04-19 09:23:52 +02:00
Cédric Pasteur c6aa63b444 Heptc compiles again
AFor now expects expressions instead of static exps
2011-04-18 15:38:42 +02:00
Léonard Gérard 5d2f7dfa85 jeudi soir. still on mls2obc. 2011-04-14 20:14:21 +02:00
Léonard Gérard b8b16a7355 blop 2011-03-21 17:41:00 +01:00
Léonard Gérard c602eca062 cgen todo. 2011-03-21 17:41:00 +01:00
Cédric Pasteur 35775c4131 C backend ported to recent API changes in Obc 2011-03-09 09:46:00 +01:00
Léonard Gérard cab8bb706e backport from async. 2011-03-09 00:06:36 +01:00
Léonard Gérard 8f4411e145 Recursives Qualnames.
In order to have a correct handling of inner classes in Java, and to prepare for modules inside modules.
2011-02-07 14:24:17 +01:00
Léonard Gérard 09419a77a5 again 2011-01-24 16:09:28 +01:00
Léonard Gérard df469db394 New Java backend closing 2011-01-24 16:09:28 +01:00
Léonard Gérard fc08753bd9 tentative 1 de async dans C 2011-01-24 16:09:27 +01:00
Léonard Gérard 315527231c Async in Heptagon Minils Obc. 2011-01-24 16:09:27 +01:00
Cédric Pasteur 2b18fcab93 Generate C code for static records
This fixes the test t8.ept
2011-01-18 17:52:44 +01:00
Léonard Gérard 36ec30b3ff Removed unused generic Mmethod in obc. 2011-01-12 13:41:14 +01:00
Léonard Gérard 7d3b6a4679 Bug fix Cgen 2010-12-15 11:26:29 +01:00
Léonard Gérard 2ae809c971 Fresh vars, and ident refactoring.
Idents.enter_node should be called when entering a node, it is done automagically by the mapfold unless you call directly Hept_mapfold.node_dec.
2010-12-15 11:26:29 +01:00
Léonard Gérard 9998d7ea39 Added a unit type. Tunit. 2010-12-10 00:39:25 +01:00
Léonard Gérard 3e2fb0b4b1 Rename [lhs] to [pattern] in obc
lhs was verrrry bad.
2010-11-05 16:27:44 +01:00
Léonard Gérard 7b4f34a521 Cgen only stdbool.h booleans no more TRUE and FALSE. 2010-11-04 18:06:11 +01:00
Adrien Guatto 6ff8ed993f Switched back to plain strings for some compiler options.
To be consistent or to be convenient, that is the question.
2010-10-04 00:35:12 +02:00
Adrien Guatto 381e4e84f7 Csubst: added missing recursive call for array indexes. 2010-10-02 13:22:04 +02:00
Adrien Guatto 7b6690d443 Cgen: proper assignment from structs. 2010-10-02 13:19:21 +02:00
Adrien Guatto 0ce7b4efb0 Cgen: proper assignments from constant variables. 2010-10-02 13:17:12 +02:00
Adrien Guatto 412fd1f81b New operator: modulo (written (%))! 2010-10-02 13:01:35 +02:00
Adrien Guatto faf232ad64 Fixed silent error (missing @.) 2010-10-01 16:49:11 +02:00
Adrien Guatto a4c3d9e856 Relevant command-line options are now stored as qualnames. 2010-09-30 21:40:04 +02:00
Cédric Pasteur df12e081ae Refactored Misc
Created two new files: 
 - utilities/global/compiler_options.ml: contains
 the options that can be set using the cli
 - utilities/global/errors.ml: contains global
 errors definition

Misc now only contains helper functions that have 
nothing to do with the ast or the compiler.
2010-09-15 09:38:52 +02:00
Léonard Gérard 02db2ad6b4 Changed compile flags, and cleaned a bit.
Warn as error for partial match.
Warn for unused variables : added some TODO to check.
PS : I'll deal with callgraph which is doing things that Modules does.
2010-09-14 09:39:02 +02:00
Cédric Pasteur d8dffe15d8 Fixed remainings non exhaustive patterns
Now the only shown warnings are the X type that 
we don't care about
2010-09-13 16:02:33 +02:00
Cédric Pasteur 5aa83246ca Use qualnames for types and fields in C
We need qualnames because we try to find types and
fields in the environment during the generation of
the code.
2010-09-13 15:20:25 +02:00
Cédric Pasteur 50223653a4 Do not forget to flush the output
The end of some header files was not printed.
2010-09-13 15:20:17 +02:00
Cédric Pasteur 0b5d1cd471 Do not print Pervasives 2010-09-13 15:20:01 +02:00
Cédric Pasteur 0b12e6a4ae Enum in Obc should also be qualnames 2010-09-13 15:19:52 +02:00
Cédric Pasteur 3d02b85bd6 Fixed some non exhaustive pattern matchings
Added assert_n functions to decompose to get a
tuple from a list of known size, and assert_nmin
when the list has at least n elements.
2010-09-13 15:19:40 +02:00
Cédric Pasteur 653de74a9d Print qualnames with prefix in C code
A qualname is printed as Qual__name
2010-09-13 09:37:58 +02:00
Cédric Pasteur 36addab3cc Use qualnames in Obc too 2010-09-13 09:03:15 +02:00
Cédric Pasteur cc039ac42d Make heptc compile 2010-09-10 14:29:13 +02:00
Léonard Gérard 43b8bc15b0 Some Cgen fixes. 2010-09-10 11:53:55 +02:00
Léonard Gérard a54e570d0f Hept Scoping should be ok and documented,
Hept Parsing too,
all the reset to review carefully,
Typing to cut from all the scoping.
2010-09-09 19:48:20 +02:00
Cédric Pasteur 2956e6feb4 Fix printing of arrays in C code
It should be 
  f(int a[5])
instead of 
  f(int *a)
because the second one does not scale for 
multidimensional arrays, eg
  g(int b[10][5]) is ok
but
  g(int **b) is not.
2010-09-03 15:27:58 +02:00
Adrien Guatto 1d8f2f2a85 Removed useless code for old module handling in cgen. 2010-09-03 11:50:52 +02:00
Léonard Gérard 5c09abeb18 Revet last commit a5f89876c2 and gives the right fix.
Plus remove all the forbidden '\n', replaced with '@.' or '@\n' depending on context.
2010-09-01 14:40:31 +02:00
Léonard Gérard 9df4f625a2 Fixed location to use formatter instead of out_channel. 2010-08-24 17:29:00 +02:00
Adrien Guatto 41bad3d8c4 C backend: "bool" type mandates the inclusion of stdbool.h 2010-07-30 12:44:12 +02:00
Adrien Guatto f7d08ca221 C backend: put the C code for node_decs into the same file. 2010-07-27 16:28:23 +02:00
Cédric Pasteur 02dd7fa124 Added alias for types (aka typedef)
For instance:
type metres = int
type metres = MyLib.longueur
type matrice = metres^10^100

Code generation in C (with typedef) included. The 
code uses the aliases for traceability.
2010-07-27 09:23:16 +02:00
Léonard Gérard f124bb4fd7 Refactoring Ident -> Idents ( uniform with Names etc ) 2010-07-23 19:45:19 +02:00
Adrien Guatto 689a10a328 Cgen: $NODE_mem.h should not include itself. 2010-07-23 12:18:27 +02:00
Cédric Pasteur 89ceb8df76 Fixed duplicate declaration of local vars 2010-07-22 17:38:28 +02:00
Cédric Pasteur 1be9f1c789 Fixed code generation for Elambda
- Added block notion in Obc
- Correct translation to C
2010-07-22 09:36:22 +02:00
Adrien Guatto 9301ed0b09 Fixes for correct array literal C generation. 2010-07-19 15:16:14 +02:00
Cédric Pasteur b6583f22b6 Complete fix for the identifiers problem 2010-07-16 14:09:37 +02:00
Cédric Pasteur d42e56203b Fix for identifiers in C
Instead of calling cname_of_name before creating 
the C ast, keep original names and convert them
when pretty printing the code.
2010-07-16 13:48:37 +02:00
Cédric Pasteur cdc9b14a44 Fixed problem with multidimensional arrays in args 2010-07-16 12:38:45 +02:00
Cédric Pasteur 778dfdb3f9 Do not loop forever during code generation
- Detect when the computation of the static exp
using simplif failed and abort.
- Added a better way to compute operators in
Static
2010-07-16 12:04:51 +02:00
Cédric Pasteur 3f7564aaa6 Fix for code generation
A node declared with node is statefull (so has a
context struct) even though it is empty. Use
the global_name ref to get the name of the current 
module.
2010-07-16 11:28:01 +02:00
Cédric Pasteur 5440a073d6 Fixed generation of C code 2010-07-13 16:23:26 +02:00
Cédric Pasteur ee767064b1 Instantiation of parametrized nodes (v2)
- Many changes to make Hept2mls, mls2obc, etc
compile with the api changes
- Added Callgraph_mapfold: starting from a main
program, generates the list of instances of each
node necessary and creates them.
- Mls2seq deals with giving to the code generators
the correct source (mls or obc, wit or without
static parameters)

It is now possible to use parametrized nodes that 
are defined in other files. For that to work, the 
first file has to be compiled to an object file:
	heptc -c mylib.ept
which creates a mylib.epo file. Compiling the main
file will then generate all the instances of 
parametrized nodes from the lib (only the called 
nodes will be compiled, but all the nodes in the 
main file are compiled).
2010-07-13 14:03:39 +02:00
Cédric Pasteur 4598b29ad2 Forgot to move this file too 2010-07-13 08:47:02 +02:00
Cédric Pasteur ad2594ebfa Cgen compiles 2010-07-09 09:31:12 +02:00
Cédric Pasteur cee9eed24a Moved sequential/ to obc/ 2010-07-08 15:20:25 +02:00