Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
0c0cf5fb
Commit
0c0cf5fb
authored
Aug 15, 2014
by
dbarbera
Browse files
Merge remote-tracking branch 'upstream/master' into operators
Conflicts: tests/regression/Makefile tests/test.py
parents
c17badb7
86794e45
Changes
17
Show whitespace changes
Inline
Side-by-side
LlvmGenerator.py
View file @
0c0cf5fb
...
...
@@ -33,6 +33,7 @@ __all__ = ['generate']
class
Context
():
def
__init__
(
self
,
process
):
self
.
name
=
str
(
process
.
processName
)
self
.
process
=
process
self
.
module
=
core
.
Module
.
new
(
self
.
name
)
self
.
target_data
=
ee
.
TargetData
.
new
(
self
.
module
.
data_layout
)
self
.
dataview
=
process
.
dataview
...
...
@@ -388,7 +389,7 @@ def _process(process, ctx=None):
ctx
=
Context
(
process
)
# In case model has nested states, flatten everything
Helper
.
flatten
(
process
)
Helper
.
flatten
(
process
,
'.'
)
# Make an maping {input: {state: transition...}} in order to easily
# generate the lookup tables for the state machine runtime
...
...
@@ -559,22 +560,32 @@ def generate_input_signal(signal, inputs, ctx):
for
state_name
,
state_id
in
ctx
.
states
.
iteritems
():
if
state_name
.
endswith
(
'start'
):
continue
state_block
=
func
.
append_basic_block
(
'input:state_%s'
%
str
(
state_name
))
switch
.
add_case
(
state_id
,
state_block
)
ctx
.
builder
.
position_at_end
(
state_block
)
# TODO: Nested states
state_input
=
inputs
.
get
(
state_name
)
if
not
state_input
:
ctx
.
builder
.
ret_void
()
continue
trans
=
state_input
.
transition
for
exit_func_name
in
exit_list
(
state_name
,
ctx
.
process
):
if
trans
and
all
(
exit_func_name
.
startswith
(
trans_st
)
for
trans_st
in
trans
.
possible_states
):
sdl_call
(
exit_func_name
,
[],
ctx
)
input
=
inputs
.
get
(
state_name
)
if
input
:
for
var_name
in
input
.
parameters
:
for
var_name
in
state_input
.
parameters
:
var_ptr
=
ctx
.
scope
.
resolve
(
str
(
var_name
))
if
is_struct_ptr
(
var_ptr
)
or
is_array_ptr
(
var_ptr
):
sdl_assign
(
var_ptr
,
func
.
args
[
0
],
ctx
)
else
:
sdl_assign
(
var_ptr
,
ctx
.
builder
.
load
(
func
.
args
[
0
]),
ctx
)
if
input
.
transition
:
id_val
=
core
.
Constant
.
int
(
ctx
.
i32
,
input
.
transition_id
)
if
trans
:
id_val
=
core
.
Constant
.
int
(
ctx
.
i32
,
state_input
.
transition_id
)
sdl_call
(
'run_transition'
,
[
id_val
],
ctx
)
ctx
.
builder
.
ret_void
()
...
...
@@ -587,6 +598,26 @@ def generate_input_signal(signal, inputs, ctx):
func
.
verify
()
def
exit_list
(
state_name
,
process
):
''' Calculate the exit call list of a state '''
context
=
process
exitlist
=
[]
current
=
''
state_tree
=
state_name
.
split
(
'.'
)
while
state_tree
:
current
=
current
+
state_tree
.
pop
(
0
)
for
comp
in
context
.
composite_states
:
if
current
.
lower
()
==
comp
.
statename
.
lower
():
if
comp
.
exit_procedure
:
exitlist
.
append
(
current
+
'.exit'
)
context
=
comp
current
=
current
+
'.'
break
return
reversed
(
exitlist
)
@
generate
.
register
(
ogAST
.
Output
)
def
_output
(
output
,
ctx
):
''' Generate the IR for an output '''
...
...
tests/regression/Makefile
View file @
0c0cf5fb
EXAMPLES
=
test1 test2 test3 test4 test5 test6 test7 test8 test9 test10
\
test11 test12 test-substrings test-expressions test-controlflow
\
test-operators
test-exitnested
test-operators
coverage
:
for
v
in
$(EXAMPLES)
;
do
make
-C
$$
v coverage
&&
mv
$$
v/.coverage
*
.
\
...
...
tests/regression/test-controlflow/Makefile
View file @
0c0cf5fb
...
...
@@ -20,10 +20,10 @@ test-llvm:
../../../opengeode.py controlflow.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc controlflow.ll
clang
-c
controlflow.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
controlflow.o dataview-uniq.o test_llvm.o
-o
testcase
gcc
-c
controlflow.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
controlflow.o dataview-uniq.o test_llvm.o
-o
testcase
./testcase | diff expected -
clean
:
...
...
tests/regression/test-exitnested/Makefile
0 → 100644
View file @
0c0cf5fb
all
:
test-ada test-llvm
edit
:
../../../opengeode.py challenge.pr system_structure.pr
test-parse
:
../../../opengeode.py challenge.pr system_structure.pr
--check
test-ada
:
../../../opengeode.py
--toAda
challenge.pr system_structure.pr
asn1.exe
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
gnatmake
-c
*
.adb
gcc
-c
test_ada.c
gnatbind
-n
challenge.ali
gnatlink
-o
testcase test_ada.o challenge.ali
-lgnat
-lm
./testcase | diff expected -
test-llvm
:
../../../opengeode.py challenge.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc challenge.ll
gcc
-c
challenge.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc challenge.o dataview-uniq.o test_llvm.o
-o
testcase
-lm
./testcase | diff expected -
coverage
:
coverage run
-p
../../../opengeode.py challenge.pr system_structure.pr
--toAda
clean
:
rm
-rf
*
.adb
*
.ads
*
.pyc runSpark.sh spark.idx
*
.o
*
.ali gnat.cfg examiner
\
bin
*
.wrn
*
.gpr testcase
*
.ll
*
.s dataview-uniq.c dataview-uniq.h real.c xer.c
\
ber.c acn.c asn1crt.c asn1crt.h
tests/regression/test-exitnested/challenge.pr
0 → 100644
View file @
0c0cf5fb
/* CIF PROCESS (150, 150), (150, 75) */
PROCESS challenge;
STATE nested;
SUBSTRUCTURE
STATE nested_1;
SUBSTRUCTURE
/* CIF PROCEDURE (110, 183), (74, 35) */
PROCEDURE entry;
/* CIF START (105, 54), (70, 35) */
START;
/* CIF PROCEDURECALL (34, 104), (210, 35) */
CALL writeln('entering nested_1');
/* CIF RETURN (122, 154), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (104, 101), (70, 35) */
PROCEDURE exit;
/* CIF START (198, 116), (70, 35) */
START;
/* CIF PROCEDURECALL (142, 166), (181, 35) */
CALL writeln('exit nested_1');
/* CIF RETURN (215, 216), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (245, 55), (70, 35) */
START;
/* CIF NEXTSTATE (234, 105), (93, 35) */
NEXTSTATE nested_2;
/* CIF STATE (276, 165), (93, 35) */
STATE nested_2;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF PROCEDURE (340, 134), (74, 35) */
PROCEDURE entry;
/* CIF START (121, 85), (70, 35) */
START;
/* CIF PROCEDURECALL (57, 135), (196, 35) */
CALL writeln('entering nested');
/* CIF RETURN (138, 185), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF PROCEDURE (334, 58), (70, 35) */
PROCEDURE exit;
/* CIF START (76, 53), (70, 35) */
START;
/* CIF PROCEDURECALL (27, 103), (167, 35) */
CALL writeln('exit nested');
/* CIF RETURN (93, 153), (35, 35) */
RETURN ;
ENDPROCEDURE;
/* CIF START (136, 68), (70, 35) */
START;
/* CIF NEXTSTATE (124, 118), (93, 35) */
NEXTSTATE nested_1;
/* CIF STATE (124, 118), (93, 35) */
STATE nested_1;
/* CIF INPUT (130, 173), (80, 35) */
INPUT go_off;
/* CIF RETURN (153, 223), (35, 35) */
RETURN ;
ENDSTATE;
ENDSUBSTRUCTURE;
/* CIF START (92, 76), (68, 37) */
START;
/* CIF NEXTSTATE (86, 128), (79, 35) */
NEXTSTATE nested;
/* CIF STATE (389, 131), (70, 35) */
STATE well;
ENDSTATE;
/* CIF STATE (86, 128), (79, 35) */
STATE nested;
/* CIF CONNECT (51, 183), (0, 35) */
CONNECT ;
/* CIF NEXTSTATE (12, 233), (78, 35) */
NEXTSTATE well;
/* CIF INPUT (145, 183), (70, 35) */
INPUT run;
/* CIF NEXTSTATE (145, 233), (70, 35) */
NEXTSTATE -;
ENDSTATE;
ENDPROCESS challenge;
\ No newline at end of file
tests/regression/test-exitnested/dataview-uniq.asn
0 → 100644
View file @
0c0cf5fb
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
-- Set of TASTE predefined basic types
T-Int32 ::= INTEGER (-2147483648 .. 2147483647)
T-UInt32 ::= INTEGER (0 .. 4294967295)
T-Int8 ::= INTEGER (-128 .. 127)
T-UInt8 ::= INTEGER (0 .. 255)
T-Boolean ::= BOOLEAN
BitString ::= BIT STRING (SIZE(32))
OctString ::= OCTET STRING (SIZE(4))
SeqBit ::= SEQUENCE (SIZE(32)) OF BOOLEAN
SeqBit2 ::= SEQUENCE (SIZE(1..32)) OF BOOLEAN
END
TASTE-Dataview DEFINITIONS ::=
BEGIN
IMPORTS T-Int32, T-UInt32, T-Int8, T-UInt8, T-Boolean FROM TASTE-BasicTypes;
-- A few simple types to start with ASN.1
challenge T-UInt32 ::= 18
bound T-UInt32 ::= 1000000
nb-bit T-UInt32 ::= 20
val-max T-UInt32 ::= 1048575
count-max T-UInt32 ::= 524288
exceed-nb T-UInt32 ::= 48575
CountTab ::= SEQUENCE (SIZE(nb-bit)) OF T-UInt32
END
tests/regression/test-exitnested/expected
0 → 100644
View file @
0c0cf5fb
entering nested
entering nested_1
exit nested_1
exit nested
entering nested
entering nested_1
exit nested_1
exit nested
tests/regression/test-exitnested/system_structure.pr
0 → 100644
View file @
0c0cf5fb
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM challenge;
PROCEDURE pow COMMENT '#c_predef';
FPAR
IN a T_UInt32,
IN b T_UInt32,
IN/OUT res T_UInt32;
EXTERNAL;
SIGNAL run;
SIGNAL go_off;
SIGNAL any_one;
signal any_two;
CHANNEL c
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
ENDCHANNEL;
BLOCK challenge;
SIGNALROUTE r
FROM ENV TO challenge WITH run, go_off, any_one, any_two;
CONNECT c and r;
PROCESS challenge REFERENCED;
ENDBLOCK;
ENDSYSTEM;
tests/regression/test-exitnested/test.c
0 → 100644
View file @
0c0cf5fb
#include
<math.h>
#include
<stdio.h>
/* Ada code external interface */
extern
void
challenge_run
();
extern
void
challenge_any_one
();
extern
int
adainit
();
//extern long long l_result;
/* Provide code called by the Ada state machine as external procedure */
void
challenge_RI_pow
(
long
long
*
a
,
long
long
*
b
,
long
long
*
res
)
{
*
res
=
(
long
long
)
pow
((
double
)
*
a
,
(
double
)
*
b
);
}
int
main
()
{
adainit
();
challenge_run
();
challenge_run
();
//printf("Internal state: %lld\n", l_result);
challenge_any_one
();
challenge_run
();
return
0
;
}
tests/regression/test-exitnested/test_ada.c
0 → 100644
View file @
0c0cf5fb
#include
<math.h>
#include
<stdio.h>
/* Ada code external interface */
extern
void
challenge_run
();
extern
void
challenge_go_off
();
extern
int
adainit
();
//extern long long l_result;
/* Provide code called by the Ada state machine as external procedure */
void
challenge_RI_pow
(
long
long
*
a
,
long
long
*
b
,
long
long
*
res
)
{
*
res
=
(
long
long
)
pow
((
double
)
*
a
,
(
double
)
*
b
);
}
int
main
()
{
adainit
();
challenge_run
();
challenge_go_off
();
return
0
;
}
tests/regression/test-exitnested/test_llvm.c
0 → 100644
View file @
0c0cf5fb
#include
<math.h>
#include
<stdio.h>
/* Ada code external interface */
extern
void
challenge_run
();
extern
void
challenge_go_off
();
extern
int
challenge_startup
();
//extern long long l_result;
/* Provide code called by the Ada state machine as external procedure */
void
challenge_RI_pow
(
long
long
*
a
,
long
long
*
b
,
long
long
*
res
)
{
*
res
=
(
long
long
)
pow
((
double
)
*
a
,
(
double
)
*
b
);
}
int
main
()
{
challenge_startup
();
challenge_run
();
challenge_go_off
();
return
0
;
}
tests/regression/test-expressions/Makefile
View file @
0c0cf5fb
...
...
@@ -20,10 +20,10 @@ test-llvm:
../../../opengeode.py expressions.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc expressions.ll
clang
-c
expressions.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
expressions.o dataview-uniq.o test_llvm.o
-o
testcase
gcc
-c
expressions.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
expressions.o dataview-uniq.o test_llvm.o
-o
testcase
./testcase
clean
:
...
...
tests/regression/test-substrings/Makefile
View file @
0c0cf5fb
...
...
@@ -23,10 +23,10 @@ test-llvm:
../../../opengeode.py myfunction.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-equal
-typePrefix
asn1Scc
llc myfunction.ll
clang
-c
myfunction.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
myfunction.o dataview-uniq.o test_llvm.o
-o
testcase
gcc
-c
myfunction.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
myfunction.o dataview-uniq.o test_llvm.o
-o
testcase
./testcase | diff expected -
coverage
:
...
...
tests/regression/test10/Makefile
View file @
0c0cf5fb
...
...
@@ -19,10 +19,10 @@ test-llvm:
../../../opengeode.py challenge.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc challenge.ll
clang
-c
challenge.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
challenge.o dataview-uniq.o test_llvm.o
-o
testcase
-lm
gcc
-c
challenge.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
challenge.o dataview-uniq.o test_llvm.o
-o
testcase
-lm
./testcase | diff expected -
coverage
:
...
...
tests/regression/test6/Makefile
View file @
0c0cf5fb
...
...
@@ -17,10 +17,10 @@ test-llvm:
../../../opengeode.py myfunction.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc myfunction.ll
clang
-c
myfunction.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
myfunction.o dataview-uniq.o test_llvm.o
-o
testcase
gcc
-c
myfunction.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
myfunction.o dataview-uniq.o test_llvm.o
-o
testcase
./testcase | diff expected -
coverage
:
...
...
tests/regression/test8/Makefile
View file @
0c0cf5fb
...
...
@@ -20,10 +20,10 @@ test-llvm:
../../../opengeode.py orchestrator.pr system_structure.pr
--check
--llvm
asn1.exe
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
llc orchestrator.ll
clang
-c
orchestrator.s
clang
-c
dataview-uniq.c
clang
-c
test_llvm.c
clang
orchestrator.o dataview-uniq.o test_llvm.o
-o
testcase
-lm
gcc
-c
orchestrator.s
gcc
-c
dataview-uniq.c
gcc
-c
test_llvm.c
gcc
orchestrator.o dataview-uniq.o test_llvm.o
-o
testcase
-lm
./testcase | diff expected -
coverage
:
...
...
tests/test.py
View file @
0c0cf5fb
...
...
@@ -23,6 +23,7 @@ paths = [
'regression/test-expressions'
,
'regression/test-operators'
,
'regression/test-substrings'
,
'regression/test-exitnested'
,
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment