Les nouveaux flags pour ICC sont :
# Don't use CXXFLAGS, it's CPP and LD stuffs.
export CPPFLAGS="-D_LINUX -I/home/lrde/admin/lrde/usr/intel/compiler90/include/c++/"
export LDFLAGS="-cxxlib-icc"
export LD_LIBRARY_PATH=/home/lrde/admin/lrde/usr/intel/compiler90/include/lib/
PATH=/home/lrde/admin/lrde/usr/intel/compiler90/bin:$PATH
test_tree vaucanson-icc bootstrap configure build demos install distcheck
C'est obligatoire car VCSN détruit les CXXFLAGS pour une partie du
make check.
--
| Would someone please DTRT with this, Michaël `Micha' Cadilhac |
| then ACK? cadilh_m - Epita 2007 - CSI |
| -- Richard Stallman JID: micha(a)amessage.be |
`-- - - - - --'
https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Add formulas in constant propagation.
* src/str/xrm-to-prism.str: Fix the traversals collecting static
* const decls and add formulas collections. Update comments.
* src/str/prism-desugar.str: Expand formulas.
* tests/xrm/static-const-arrays-desugar.xpm: New.
* TODO: Update. New idea: array initializations a la C :).
TODO | 18 +++++++++++-------
src/str/prism-desugar.str | 20 +++++++++++++-------
src/str/xrm-to-prism.str | 26 ++++++++++++++++++++------
tests/xrm/static-const-arrays-desugar.xpm | 26 ++++++++++++++++++++++++++
4 files changed, 70 insertions(+), 20 deletions(-)
Index: src/str/xrm-to-prism.str
--- src/str/xrm-to-prism.str (revision 36)
+++ src/str/xrm-to-prism.str (working copy)
@@ -14,6 +14,9 @@
** with a value and an annotated type. Only constants with a static value
** provided will be put here (constants can have their value defined in
** init blocks and chosen at random at runtime).
+** - ExpandFormulas: created by the strategy collect-formulas and used by
+** prism-desugar for constant propagation. Maps an identifier with an
+** expression.
*/
module xrm-to-prism
imports
@@ -30,15 +33,19 @@
/* remove XRM sugar, normalize some nodes */
innermost(xrm-to-prism-desugar)
- /* Two things in one traversal:
- * 1/ Desugar array declarations
+ /* Collect static const variables
+ * Two goals: expand them if needed, look for variable name conflicts. */
+ ; topdown(try(collect-static-const-decl); try(collect-formulas))
+
+ /* Desugar array declarations
* eg: x[4][5] is transformed into two nested meta for loops
* We can't do this in xrm-to-prism-desugar because the innermost
- * traversal is bottomup and won't recurse into generated code
- * 2/ Collect static const variables
- * Two goals: expand them if needed, look for variable name conflicts.
+ * traversal is bottomup and won't recurse into generated code.
+ *
+ * This must come AFTER collect-static-const-decl since we might need
+ * to expand an array which relies on static const variables.
*/
- ; topdown(try(array-decl-desugar); try(collect-static-const-decl))
+ ; topdown(try(array-decl-desugar))
/* Check that meta vars are always defined in the current scope when used
* and that they are not redefined twice in the same scope */
@@ -95,6 +102,13 @@
; where(!value{Type("bool")} => v)
; rules(ExpandStaticConsts: idf -> v)
+rules
+
+ collect-formulas =
+ //?|[ formula x = e; ]|
+ ?FormulaDef(x, e)
+ ; rules(ExpandFormulas: x -> e)
+
strategies
/**
Index: src/str/prism-desugar.str
--- src/str/prism-desugar.str (revision 36)
+++ src/str/prism-desugar.str (working copy)
@@ -29,19 +29,25 @@
/**
** Main goal: Transform all Int(_) -> Double(_)
- ** In this first pass we also want to expand static consts. However, we
- ** must be careful as to where these expansions occur. For instance, say
- ** that N=10 (we know it thanks to the DR ExpandStaticConsts). If we are
- ** on the node where N is declared (that is: |[ const int N = 10; ]|) we
- ** should NOT expand `N' here. Otherwise we'll end up with
- ** |[ const int 10 = 10; ]|.
+ **
+ ** In this first pass we also want to expand static consts and formulas.
+ ** However, we must be careful as to where these expansions occur. For
+ ** instance, say that N=10 (we know it thanks to the DR ExpandStaticConsts).
+ **
+ ** If we are on the node where N is declared (that is:
+ ** |[ const int N = 10; ]|) we should NOT expand `N' here. Otherwise
+ ** we'll end up with |[ const int 10 = 10; ]|. The same thing applies for
+ ** formulas and ExpandFormulas.
*/
prism-desugar-first-pass =
ConstInt(id, prism-desugar)
<+ ConstDouble(id, prism-desugar)
<+ ConstBool(id, prism-desugar)
+ <+ FormulaDef(id, prism-desugar)
<+ ?Int(_); IntToDouble
- <+ all(try(ExpandStaticConsts); prism-desugar-first-pass)
+ <+ all(try(ExpandStaticConsts)
+ ; try(ExpandFormulas)
+ ; prism-desugar-first-pass)
rules
Index: tests/xrm/static-const-arrays-desugar.xpm
--- tests/xrm/static-const-arrays-desugar.xpm (revision 0)
+++ tests/xrm/static-const-arrays-desugar.xpm (revision 0)
@@ -0,0 +1,26 @@
+const int N = 3;
+const int array[N] = 42;
+
+module test
+ x[N] : [0..N] init array[N];
+
+ [] x[array[N]]=0 -> (x[array[N]]'=1);
+endmodule
+
+// The above code will generate the following code once
+// collect-static-const-decl and array-decl-desugar have runned.
+// The problem is that the loop "hides" static const variables which
+// are not caught by collect-static-const-decl.
+
+// const int N = 3;
+//
+// for __meta_i_0 from 0 to 2 step 1 do
+// const int array[__meta_i_0] = 42;
+// end
+//
+// module test
+// for __meta_i_2 from 0 to 2 step 1 do
+// x[__meta_i_2] : [0..N] init array[N];
+// end
+// [] x[array[N]]=0 -> (x[array[N]]'=1);
+// endmodule
Index: TODO
--- TODO (revision 36)
+++ TODO (working copy)
@@ -37,9 +37,8 @@
* Add the following at the meta-level:
- Let's have the possibility to generate other ModulesFileSection such as:
- o Formula // add it in the grammar. should be
- // automagically handled
- o Constant // ditto
+ o Formula // done (automagically handled)
+ o Constant // done (automagically handled)
o Global // done (automagically handled)
o RenamedModule // need to be investigated
o RewardStruct // ditto
@@ -48,10 +47,6 @@
* Add a sanity check before check-meta-vars to collect all statically
declared variables (globals, formulas, local declarations etc.) and ensure
(in check-meta-vars) that their identifiers are unique.
- Keep the (static) constant globals somewhere in order to allow
- prism-desugar to take these values into account (which will automagically
- allow things such as x[N] to declare an array for instance, where N is a
- global const)
* Add a sanity check after xrm-front has finished to generate everything in
order to ensure that each module/var decl has a unique name.
@@ -95,6 +90,10 @@
variables and their type + domain and might be quite challenging to
handle.
+ * Add array initializations a la C:
+ x[3] : [0..4] init {0, 1, 2};
+ const int array[3] = {0, 1, 2};
+
## -------------- ##
## Desugarisation ##
## -------------- ##
@@ -171,3 +170,8 @@
* Evaluate constant calls to built-in functions, eg
func(min, 4, 5)
==> 4
+
+ * Keep the (static) constant globals somewhere in order to allow
+ prism-desugar to take these values into account (which will automagically
+ allow things such as x[N] to declare an array for instance, where N is a
+ global const)
https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Fix the size of generated arrays.
* src/str/array-decl-desugar.str: Stick with the C-style array
convention. (that is: array[N] has values ranging from array[0]
to array[N-1])
array-decl-desugar.str | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
Index: src/str/array-decl-desugar.str
--- src/str/array-decl-desugar.str (revision 34)
+++ src/str/array-decl-desugar.str (working copy)
@@ -45,13 +45,17 @@
/* find the first element in the list which matches ?Int(_)
* eg: [Identifier("..."), Int("1"), Int("2")] will be transformed in
* ([Identifier("...")], Int("1"), [Int("2")]) */
- ; <split-fetch-keep(?Int(_))> dims' => (dims-done, current-dim, dims-todo)
+ ; <split-fetch-keep(?Int(_))> dims'
+ => (dims-done, Int(current-dim), dims-todo)
+
+ /* array[N] has N elements ranging from 0 to N-1 */
+ ; <subtS>(current-dim, "1") => current-dim'
/* replace the dimension we're working on by the meta-var */
; <concat> [dims-done, [Identifier(x)], dims-todo]
/* return the result in a tuple */
- ; !(x, current-dim, <id>)
+ ; !(x, Int(current-dim'), <id>)
rules
// FIXME: Try to figure out why concrete syntax fails to work here
https://svn.lrde.epita.fr/svn/xrm/trunk
Index: ChangeLog
from SIGOURE Benoit <sigoure.benoit(a)lrde.epita.fr>
Use static const variables in constant propagation.
* src/sig/Makefile.am: Patch a possible dependency problem.
* src/str/xrm-front.str: Change some comments.
* src/str/xrm-to-prism.str: Collect static const variables.
* src/str/prism-desugar.str: Use the known values of static const
variables in constant propagation if possible.
* TODO: Update things done. Add a question about PRISM's behavior.
TODO | 13 +++++++++----
src/sig/Makefile.am | 8 +++++---
src/str/prism-desugar.str | 21 +++++++++++++++++++--
src/str/xrm-front.str | 6 +++---
src/str/xrm-to-prism.str | 45 +++++++++++++++++++++++++++++++++++++++++----
5 files changed, 77 insertions(+), 16 deletions(-)
Index: src/sig/Makefile.am
--- src/sig/Makefile.am (revision 33)
+++ src/sig/Makefile.am (working copy)
@@ -5,7 +5,7 @@
## Mail <sigoure.benoit(a)lrde.epita.fr>
##
## Started on Mon May 8 18:38:32 2006 SIGOURE Benoit
-## Last update Tue May 9 20:39:39 2006 SIGOURE Benoit
+## Last update Thu May 25 23:41:55 2006 SIGOURE Benoit
##
include $(top_srcdir)/config/Transformers.mk
@@ -18,8 +18,10 @@
SDF2RTG_FLAGS = --main $*
-PRISM.def:
+PRISM.def: $(top_builddir)/src/syn/prism/PRISM.def
+ rm -f $@
$(LN_S) $(top_builddir)/src/syn/prism/$@ $@
-XRM.def:
+XRM.def: $(top_builddir)/src/syn/xrm/XRM.def
+ rm -f $@
$(LN_S) $(top_builddir)/src/syn/xrm/$@ $@
Index: src/str/xrm-front.str
--- src/str/xrm-front.str (revision 33)
+++ src/str/xrm-front.str (working copy)
@@ -36,7 +36,7 @@
end
end
- // pipeline of transformations performed by xrm-front
+ /** pipeline of transformations performed by xrm-front */
xrm-front-pipeline =
dbg(|"xrm-front-pipeline starting")
; xrm-to-prism
@@ -47,14 +47,14 @@
end
; id // FIXME: add more transformations here
- // list of available options for xrm-front
+ /** list of available options for xrm-front */
xrm-front-options =
pp-aterm-option
+ add-pos-option
+ keep-attributes-option
+ desugar-option
- // check the options are consistent
+ /** checks the options are consistent */
check-options =
if <get-config> "-b" then
// if we're asked for binary output, don't bother with pretty printing
Index: src/str/xrm-to-prism.str
--- src/str/xrm-to-prism.str (revision 33)
+++ src/str/xrm-to-prism.str (working copy)
@@ -1,6 +1,19 @@
/*
** This sub-module does the real work of the front-end. It transforms the
** program into a valid PRISM AST.
+**
+** Dynamic rules inventory:
+** - DeclarationList: used by the strategy reorder-module-contents to
+** store all the declarations within a given module. This way declarations
+** can be grouped together in the module (as required by the PRISM grammar)
+** - CommandList: used by the strategy reorder-module-contents to
+** store all the commands within a given module. This way commands can
+** be grouped together in the module (as required by the PRISM grammar)
+** - ExpandStaticConsts: created by the strategy collect-static-const-decl
+** and used by prism-desugar for constant propagation. Maps an identifier
+** with a value and an annotated type. Only constants with a static value
+** provided will be put here (constants can have their value defined in
+** init blocks and chosen at random at runtime).
*/
module xrm-to-prism
imports
@@ -17,11 +30,15 @@
/* remove XRM sugar, normalize some nodes */
innermost(xrm-to-prism-desugar)
- /* Desugar array declarations
+ /* Two things in one traversal:
+ * 1/ Desugar array declarations
* eg: x[4][5] is transformed into two nested meta for loops
* We can't do this in xrm-to-prism-desugar because the innermost
- * traversal is bottomup and won't recurse into generated code */
- ; topdown(try(array-decl-desugar))
+ * traversal is bottomup and won't recurse into generated code
+ * 2/ Collect static const variables
+ * Two goals: expand them if needed, look for variable name conflicts.
+ */
+ ; topdown(try(array-decl-desugar); try(collect-static-const-decl))
/* Check that meta vars are always defined in the current scope when used
* and that they are not redefined twice in the same scope */
@@ -48,7 +65,7 @@
xrm-to-prism-desugar:
|[ e1 << e2 ]| -> |[ e1 * func(pow, 2, e2) ]|
- // if the step is not specified, it is implicitely set to 1
+ /** if the step is not specified, it is implicitly set to 1 */
xrm-to-prism-desugar:
MetaFor(identifier, from, to, body)
-> MetaFor(identifier, from, to, Int("1"), body)
@@ -58,6 +75,26 @@
//|[ if e then s* end ]| -> |[ if e then s* else end ]|
MetaIf(e, m*) -> MetaIf(e, m*, [])
+signature constructors
+ Type : String -> Type
+
+strategies
+
+ collect-static-const-decl =
+ ?ConstInt(idf, value)
+ ; where(!value{Type("int")} => v)
+ ; rules(ExpandStaticConsts: idf -> v)
+
+ collect-static-const-decl =
+ ?ConstDouble(idf, value)
+ ; where(!value{Type("double")} => v)
+ ; rules(ExpandStaticConsts: idf -> v)
+
+ collect-static-const-decl =
+ ?ConstBool(idf, value)
+ ; where(!value{Type("bool")} => v)
+ ; rules(ExpandStaticConsts: idf -> v)
+
strategies
/**
Index: src/str/prism-desugar.str
--- src/str/prism-desugar.str (revision 33)
+++ src/str/prism-desugar.str (working copy)
@@ -9,13 +9,14 @@
** 1. First convert all literal ints to doubles. This makes the
** simplifications easier to write since there is less cases to
** address (eg: int + int, int + double, double + int,
- ** double + double etc.).
+ ** double + double etc.). This first pass works in a slightly
+ ** special way, see prism-desugar-first-pass for more info.
** 2. Desugar the AST
** 3. Convert the doubles which are round numbers back to ints.
** Simplify doubles (round them up and remove trailing zeros)
*/
prism-desugar =
- topdown(try(IntToDouble))
+ prism-desugar-first-pass
; innermost(
RemoveUnconditionnalUpdates
<+ AddZero <+ MulOne <+ MulZero <+ DivOne <+ catch-div-by-zero
@@ -26,6 +27,22 @@
)
; topdown(try(SimplifyDoubles <+ TruncateDouble))
+ /**
+ ** Main goal: Transform all Int(_) -> Double(_)
+ ** In this first pass we also want to expand static consts. However, we
+ ** must be careful as to where these expansions occur. For instance, say
+ ** that N=10 (we know it thanks to the DR ExpandStaticConsts). If we are
+ ** on the node where N is declared (that is: |[ const int N = 10; ]|) we
+ ** should NOT expand `N' here. Otherwise we'll end up with
+ ** |[ const int 10 = 10; ]|.
+ */
+ prism-desugar-first-pass =
+ ConstInt(id, prism-desugar)
+ <+ ConstDouble(id, prism-desugar)
+ <+ ConstBool(id, prism-desugar)
+ <+ ?Int(_); IntToDouble
+ <+ all(try(ExpandStaticConsts); prism-desugar-first-pass)
+
rules
IntToDouble: Int(i) -> Double(i)
Index: TODO
--- TODO (revision 33)
+++ TODO (working copy)
@@ -17,6 +17,11 @@
* Add more tests. Add tests which actually do check that the generated code
is correct (which is not done ATM).
+ * How are handled mutually recursive static constant variables in PRISM?
+ eg: const int x = y;
+ const int y = x;
+ Is it even possible to define a static const variable from another one?
+
## ---------- ##
## Extensions ##
## ---------- ##
@@ -91,10 +96,6 @@
x = 1..5,7,10..13
==> (x>=1 & x<=5) | (x=7) | (x>=10 & x<=13)
- * Evaluate constant calls to built-in functions, eg
- func(min, 4, 5)
- ==> 4
-
* Expand formulas, eg
formula lfree = p2=0..4,6,10;
// ...
@@ -159,3 +160,7 @@
[] x[0]=0 -> ... => ... <=> end
endmodule => [] x_0=0 -> ... <=> [] x_0=0 -> ...
=> endmodule <=> endmodule
+
+ * Evaluate constant calls to built-in functions, eg
+ func(min, 4, 5)
+ ==> 4