Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Lustrec - public version
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LustreC
Lustrec - public version
Commits
27dc3869
Commit
27dc3869
authored
7 years ago
by
Pierre Loic Garoche
Browse files
Options
Downloads
Patches
Plain Diff
Added a feature to alias ite contructs argument. To be used by EMF backend
parent
fa880262
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main_lustre_compiler.ml
+1
-4
1 addition, 4 deletions
src/main_lustre_compiler.ml
src/normalization.ml
+53
-6
53 additions, 6 deletions
src/normalization.ml
with
54 additions
and
10 deletions
src/main_lustre_compiler.ml
+
1
−
4
View file @
27dc3869
...
@@ -211,10 +211,7 @@ let stage1 prog dirname basename =
...
@@ -211,10 +211,7 @@ let stage1 prog dirname basename =
(* Normalization phase *)
(* Normalization phase *)
Log
.
report
~
level
:
1
(
fun
fmt
->
fprintf
fmt
".. normalization@,"
);
Log
.
report
~
level
:
1
(
fun
fmt
->
fprintf
fmt
".. normalization@,"
);
(* Special treatment of arrows in lustre backend. We want to keep them *)
let
prog
=
Normalization
.
normalize_prog
~
backend
:!
Options
.
output
prog
in
if
!
Options
.
output
=
"lustre"
then
Normalization
.
unfold_arrow_active
:=
false
;
let
prog
=
Normalization
.
normalize_prog
prog
in
Log
.
report
~
level
:
2
(
fun
fmt
->
fprintf
fmt
"@[<v 2>@ %a@]@,"
Printers
.
pp_prog
prog
);
Log
.
report
~
level
:
2
(
fun
fmt
->
fprintf
fmt
"@[<v 2>@ %a@]@,"
Printers
.
pp_prog
prog
);
let
prog
=
let
prog
=
...
...
This diff is collapsed.
Click to expand it.
src/normalization.ml
+
53
−
6
View file @
27dc3869
...
@@ -14,6 +14,26 @@ open LustreSpec
...
@@ -14,6 +14,26 @@ open LustreSpec
open
Corelang
open
Corelang
open
Format
open
Format
(** Normalisation iters through the AST of expressions and bind fresh definition
when some criteria are met. This creation of fresh definition is performed by
the function mk_expr_alias_opt when the alias argument is on.
Initial expressions, ie expressions attached a variable in an equation
definition are not aliased. This non-alias feature is propagated in the
expression AST for array access and power construct, tuple, and some special
cases of arrows.
Two global variables may impact the normalization process:
- unfold_arrow_active
- force_alias_ite: when set, bind a fresh alias for then and else
definitions.
*)
(* Two global variables *)
let
unfold_arrow_active
=
ref
true
let
force_alias_ite
=
ref
false
let
expr_true
loc
ck
=
let
expr_true
loc
ck
=
{
expr_tag
=
Utils
.
new_tag
()
;
{
expr_tag
=
Utils
.
new_tag
()
;
expr_desc
=
Expr_const
(
Const_tag
tag_true
);
expr_desc
=
Expr_const
(
Const_tag
tag_true
);
...
@@ -53,7 +73,6 @@ let unfold_arrow expr =
...
@@ -53,7 +73,6 @@ let unfold_arrow expr =
{
expr
with
expr_desc
=
Expr_ite
(
expr_once
loc
ck
,
e1
,
e2
)
}
{
expr
with
expr_desc
=
Expr_ite
(
expr_once
loc
ck
,
e1
,
e2
)
}
|
_
->
assert
false
|
_
->
assert
false
let
unfold_arrow_active
=
ref
true
let
cpt_fresh
=
ref
0
let
cpt_fresh
=
ref
0
(* Generate a new local [node] variable *)
(* Generate a new local [node] variable *)
...
@@ -294,8 +313,15 @@ and normalize_cond_expr ?(alias=true) node offsets defvars expr =
...
@@ -294,8 +313,15 @@ and normalize_cond_expr ?(alias=true) node offsets defvars expr =
|
Expr_merge
(
c
,
hl
)
->
|
Expr_merge
(
c
,
hl
)
->
let
defvars
,
norm_hl
=
normalize_branches
node
offsets
defvars
hl
in
let
defvars
,
norm_hl
=
normalize_branches
node
offsets
defvars
hl
in
defvars
,
mk_norm_expr
offsets
expr
(
Expr_merge
(
c
,
norm_hl
))
defvars
,
mk_norm_expr
offsets
expr
(
Expr_merge
(
c
,
norm_hl
))
|
_
->
normalize_expr
~
alias
:
alias
node
offsets
defvars
expr
|
_
when
!
force_alias_ite
->
(* Forcing alias creation for then/else expressions *)
let
defvars
,
norm_expr
=
normalize_expr
~
alias
:
alias
node
offsets
defvars
expr
in
mk_expr_alias_opt
true
node
defvars
norm_expr
|
_
->
(* default case without the force_alias_ite option *)
normalize_expr
~
alias
:
alias
node
offsets
defvars
expr
and
normalize_guard
node
defvars
expr
=
and
normalize_guard
node
defvars
expr
=
let
defvars
,
norm_expr
=
normalize_expr
node
[]
defvars
expr
in
let
defvars
,
norm_expr
=
normalize_expr
node
[]
defvars
expr
in
mk_expr_alias_opt
true
node
defvars
norm_expr
mk_expr_alias_opt
true
node
defvars
norm_expr
...
@@ -434,9 +460,30 @@ let normalize_decl decl =
...
@@ -434,9 +460,30 @@ let normalize_decl decl =
decl'
decl'
|
Open
_
|
ImportedNode
_
|
Const
_
|
TypeDef
_
->
decl
|
Open
_
|
ImportedNode
_
|
Const
_
|
TypeDef
_
->
decl
let
normalize_prog
decls
=
let
normalize_prog
?
(
backend
=
"C"
)
decls
=
List
.
map
normalize_decl
decls
let
old_unfold_arrow_active
=
!
unfold_arrow_active
in
let
old_force_alias_ite
=
!
force_alias_ite
in
(* Backend specific configurations for normalization *)
let
_
=
match
backend
with
|
"lustre"
->
(* Special treatment of arrows in lustre backend. We want to keep them *)
unfold_arrow_active
:=
false
;
|
"emf"
->
(* Forcing ite normalization *)
force_alias_ite
:=
true
;
|
_
->
()
(* No fancy options for other backends *)
in
(* Local Variables: *)
(* Main algorithm: iterates over nodes *)
let
res
=
List
.
map
normalize_decl
decls
in
(* Restoring previous settings *)
unfold_arrow_active
:=
old_unfold_arrow_active
;
force_alias_ite
:=
old_force_alias_ite
;
res
(* Local Variables: *)
(* compile-command:"make -C .." *)
(* compile-command:"make -C .." *)
(* End: *)
(* End: *)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment