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
c2ede186
Commit
c2ede186
authored
Jul 11, 2015
by
Maxime Perrotin
Browse files
Merge pull request #31 from lattuada/master
C Backend
parents
2b77c93e
5c8a87a0
Changes
69
Expand all
Hide whitespace changes
Inline
Side-by-side
.gitignore
View file @
c2ede186
...
...
@@ -7,4 +7,34 @@ install.record
antlr-3.1.3.tar.bz2
antlr-3.1.3/
test_c
tests/**/*.stg
tests/regression/test-controlflow/controlflow.*
tests/regression/test-debug/orchestrator.*
tests/regression/test-equal/og.*
tests/regression/test-exitnested/challenge.*
tests/regression/test-expressions/expressions.*
tests/regression/test-llvm/orchestrator.*
tests/regression/test-nocif/orchestrator.*
tests/regression/test-operators/operators.*
tests/regression/test-processfpar1/og.*
tests/regression/test-processfpar2/og.*
tests/regression/test-simu/orchestrator.*
tests/regression/test-standalone/og.*
tests/regression/test-strings/og.*
tests/regression/test-substrings/myfunction.*
tests/regression/test-types/function1.*
tests/regression/test1/og.*
tests/regression/test10/challenge.*
tests/regression/test11/og.*
tests/regression/test12/trafficlight.*
tests/regression/test2/orchestrator.*
tests/regression/test3/fce.*
tests/regression/test4/asn1crt.*
tests/regression/test4/orchestrator.*
tests/regression/test5/function0.*
tests/regression/test6/myfunction.*
tests/regression/test7/orchestrator.*
tests/regression/test8/orchestrator.*
tests/regression/test9/challenge.*
opengeode/CGenerator.py
0 → 100644
View file @
c2ede186
This diff is collapsed.
Click to expand it.
opengeode/opengeode.py
View file @
c2ede186
...
...
@@ -98,6 +98,11 @@ try:
except
ImportError
:
graphviz
=
False
try
:
import
CGenerator
except
ImportError
:
CGenerator
=
None
try
:
import
LlvmGenerator
except
ImportError
:
...
...
@@ -1977,6 +1982,8 @@ def parse_args():
help
=
'Generate Ada code for the .pr file'
)
parser
.
add_argument
(
'--llvm'
,
dest
=
'llvm'
,
action
=
'store_true'
,
help
=
'Generate LLVM IR code for the .pr file (experimental)'
)
parser
.
add_argument
(
'--toC'
,
dest
=
'toC'
,
action
=
'store_true'
,
help
=
'Generate C code .pr file (experimental)'
)
parser
.
add_argument
(
"-O"
,
dest
=
"optimization"
,
metavar
=
"level"
,
type
=
int
,
action
=
"store"
,
choices
=
[
0
,
1
,
2
,
3
],
default
=
0
,
help
=
"Set optimization level for the generated LLVM IR code"
)
...
...
@@ -2023,6 +2030,7 @@ def init_logging(options):
TextInteraction
,
Connectors
,
LlvmGenerator
,
CGenerator
,
StgBackend
)
for
module
in
modules
:
...
...
@@ -2063,7 +2071,14 @@ def generate(process, options):
LOG
.
error
(
str
(
err
))
LOG
.
debug
(
str
(
traceback
.
format_exc
()))
LOG
.
error
(
'Ada code generation failed'
)
if
options
.
toC
:
LOG
.
info
(
'Generating C code'
)
try
:
CGenerator
.
generate
(
process
,
simu
=
options
.
shared
,
options
=
options
)
except
(
TypeError
,
ValueError
,
NameError
)
as
err
:
LOG
.
error
(
str
(
err
))
LOG
.
debug
(
str
(
traceback
.
format_exc
()))
LOG
.
error
(
'C generation failed'
)
if
options
.
llvm
:
LOG
.
info
(
'Generating LLVM code'
)
try
:
...
...
@@ -2157,7 +2172,7 @@ def cli(options):
export
(
ast
,
options
)
if
any
((
options
.
toAda
,
options
.
llvm
,
options
.
shared
,
options
.
stg
,
options
.
dll
)):
options
.
stg
,
options
.
dll
,
options
.
toC
)):
if
not
errors
:
generate
(
ast
.
processes
[
0
],
options
)
else
:
...
...
@@ -2224,7 +2239,7 @@ def opengeode():
LOG
.
debug
(
'Starting OpenGEODE version '
+
__version__
)
if
any
((
options
.
check
,
options
.
toAda
,
options
.
png
,
options
.
pdf
,
options
.
svg
,
options
.
llvm
,
options
.
shared
,
options
.
stg
,
options
.
dll
)):
options
.
dll
,
options
.
toC
)):
return
cli
(
options
)
else
:
return
gui
(
options
)
...
...
tests/regression/Makefile
View file @
c2ede186
...
...
@@ -11,9 +11,15 @@ test-parse:
test-ada
:
@
python test.py test-ada
$(TEST_CASES)
test-c
:
@
python test.py test-c
$(TEST_CASES)
test-llvm
:
@
python test.py test-llvm
$(TEST_CASES)
test-vhdl
:
@
python test.py test-c
$(TEST_CASES)
benchmark
:
@
python benchmark.py
$(BENCHMARK_CASES)
...
...
tests/regression/shared.mk
View file @
c2ede186
...
...
@@ -18,6 +18,10 @@ clean:
$(LLC)
$*
.ll
$(CC)
-O
$(O)
-c
-g
$*
.s
%.c
:
%.pr FORCE
$(OPENGEODE)
$<
system_structure.pr
--toC
$(ASN1SCC)
-c
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
%.ali
:
%.pr FORCE
$(OPENGEODE)
$<
system_structure.pr
--toAda
$(ASN1SCC)
-Ada
dataview-uniq.asn
-typePrefix
asn1Scc
-equal
...
...
tests/regression/test-controlflow/Makefile
View file @
c2ede186
...
...
@@ -13,11 +13,19 @@ test-ada: controlflow.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
test_ada.o controlflow.ali
-lgnat
-lm
-o
test_ada
./test_ada | diff expected -
test-c
:
controlflow.c test_c.o dataview-uniq.o
$(CC)
controlflow.c
-c
-o
controlflow.o
$(CC)
test_c.o controlflow.c
-lm
-o
test_c
./test_c | diff expected -
test-llvm
:
controlflow.o dataview-uniq.o | test_llvm.o
$(CC)
controlflow.o dataview-uniq.o test_llvm.o
-o
test_llvm
-lm
./test_llvm | diff expected -
test-vhdl
:
test-c
bambu controlflow.c test_c.c
--experimental-setup
=
BAMBU
--debug-classes
=
MuxConnectionBinding
--print-dot
--no-clean
--pretty-print
=
a.c
-d2
coverage
:
coverage run
-p
$(OPENGEODE)
controlflow.pr system_structure.pr
--toAda
.PHONY
:
all edit test-parse test-ada test-llvm coverage
\ No newline at end of file
.PHONY
:
all edit test-parse test-ada test-llvm coverage
tests/regression/test-controlflow/test_c.c
0 → 100644
View file @
c2ede186
#include
<stdio.h>
#include
<stdlib.h>
#include
"dataview-uniq.h"
extern
void
run
();
void
controlflow_RI_assert
(
asn1SccBoolean
*
res
,
asn1SccCharString
*
msg
)
{
if
(
!*
res
)
{
printf
(
"%.*s
\n
"
,
(
int
)
msg
->
nCount
,
msg
->
arr
);
exit
(
1
);
}
}
void
controlflow_RI_fail
(
asn1SccCharString
*
msg
)
{
printf
(
"%.*s
\n
"
,
(
int
)
msg
->
nCount
,
msg
->
arr
);
exit
(
1
);
}
int
main
()
{
run
();
return
0
;
}
tests/regression/test-debug/Makefile
View file @
c2ede186
...
...
@@ -13,6 +13,11 @@ test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
-o
test_ada test_ada.o orchestrator.ali
-lgnat
./test_ada
test-c
:
orchestrator.c test_c.o dataview-uniq.o
$(CC)
-include
missing.h orchestrator.c
-c
-o
orchestrator.o
$(CC)
test_c.o dataview-uniq.o orchestrator.o
-lm
-o
test_c
./test_c | diff expected -
test-llvm
:
orchestrator.o
test-python
:
...
...
@@ -24,6 +29,9 @@ test-python:
$(CC)
-shared
-fPIC
-o
liborchestrator.so b~orchestrator.o orchestrator.o taste_basictypes.o adaasn1rtl.o
-lgnat
python
-c
"from ctypes import *; test=CDLL('./liborchestrator.so'); test.liborchestratorinit()"
test-vhdl
:
test-c
bambu orchestrator.c test_c.c
--experimental-setup
=
BAMBU
coverage
:
coverage run
-p
$(OPENGEODE)
orchestrator.pr system_structure.pr
--toAda
...
...
tests/regression/test-debug/dataview-uniq.asn
View file @
c2ede186
TASTE-BasicTypes DEFINITIONS ::=
BEGIN
Boolean ::= BOOLEAN
TASTE-Peek-id ::= INTEGER (0..4294967295)
TASTE-Peek-id-list ::= SEQUENCE (SIZE (1..10)) OF TASTE-Peek-id
...
...
tests/regression/test-debug/expected
0 → 100644
View file @
c2ede186
[C Code] Running test
0
0
0
1
0
0
0
1
FALSE
TRUE
TRUE
FALSE
HELLO!!!
HELLOHELLOHELLO
tests/regression/test-debug/missing.h
0 → 100644
View file @
c2ede186
#include
"dataview-uniq.h"
asn1SccMyChoice
asn1SccMyChoice_c1_set
(
asn1SccBoolean
itm
)
{
asn1SccMyChoice
temp
;
temp
.
kind
=
c1_PRESENT
;
temp
.
u
.
c1
=
itm
;
return
temp
;
}
asn1SccSeqOpt_c
asn1SccSeqOpt_c_Init
()
{
asn1SccSeqOpt_c
temp
;
asn1SccSeqOpt_c_Initialize
(
&
temp
);
return
temp
;
}
asn1SccSeqOpt_d
asn1SccSeqOpt_d_Init
()
{
asn1SccSeqOpt_d
temp
;
asn1SccSeqOpt_d_Initialize
(
&
temp
);
return
temp
;
}
int
asn1SccMyChoice_Kind
(
asn1SccMyChoice
val
)
{
return
val
.
kind
;
}
tests/regression/test-debug/test_c.c
0 → 100644
View file @
c2ede186
#include
<math.h>
#include
<stdio.h>
#include
"dataview-uniq.h"
extern
void
runTransition
(
int
Id
);
void
telemetry
(
asn1SccMyEnum
*
param
){}
int
main
()
{
printf
(
"[C Code] Running test
\n
"
);
CInit
();
runTransition
(
0
);
return
0
;
}
tests/regression/test-equal/Makefile
View file @
c2ede186
...
...
@@ -13,11 +13,18 @@ test-ada: og.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
-o
test_ada test_ada.o og.ali
-lgnat
./test_ada | diff expected -
test-c
:
og.c test_c.o dataview-uniq.o
$(CC)
-include
missing.h og.c
-c
-o
og.o
$(CC)
test_c.o og.o dataview-uniq.o
-lm
-o
test_c
./test_c | diff expected -
test-llvm
:
og.o dataview-uniq.o | test_llvm.o
$(CC)
og.o dataview-uniq.o test_llvm.o
-o
test_llvm
-lm
./test_llvm
test-vhdl
:
test-c
bambu og.c test_c.c
--experimental-setup
=
BAMBU
coverage
:
coverage run
-p
$(OPENGEODE)
og.pr system_structure.pr
--toAda
...
...
tests/regression/test-equal/missing.h
0 → 100644
View file @
c2ede186
#include
"dataview-uniq.h"
asn1SccSeqOf
asn1SccSeqOf_Init
()
{
asn1SccSeqOf
temp
;
asn1SccSeqOf_Initialize
(
&
temp
);
return
temp
;
}
asn1SccAChoice
asn1SccAChoice_b_set
(
asn1SccSeqOf
itm
)
{
asn1SccAChoice
temp
;
temp
.
kind
=
b_PRESENT
;
temp
.
u
.
b
=
itm
;
return
temp
;
}
asn1SccAChoice
asn1SccAChoice_a_set
(
asn1SccT_Bool
itm
)
{
asn1SccAChoice
temp
;
temp
.
kind
=
a_PRESENT
;
temp
.
u
.
a
=
itm
;
return
temp
;
}
tests/regression/test-equal/test_c.c
0 → 100644
View file @
c2ede186
#include
<stdio.h>
#include
"dataview-uniq.h"
int
main
()
{
asn1SccMy_OctStr
toto
;
CInit
();
runTransition
(
0
);
go
(
&
toto
);
return
0
;
}
tests/regression/test-exitnested/Makefile
View file @
c2ede186
...
...
@@ -13,11 +13,20 @@ test-ada: challenge.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
-o
test_ada test_ada.o challenge.ali
-lgnat
-lm
./test_ada | diff expected -
test-c
:
challenge.c test_c.o dataview-uniq.o
$(CC)
challenge.c
-c
-o
challenge.o
$(CC)
test_c.o dataview-uniq.o challenge.o
-lm
-o
test_c
./test_c
./test_c | diff expected -
test-llvm
:
challenge.o dataview-uniq.o | test_llvm.o
$(CC)
challenge.o dataview-uniq.o test_llvm.o
-o
test_llvm
-lm
./test_llvm | diff expected -
test-vhdl
:
test-c
bambu challenge.c test_c.c
--experimental-setup
=
BAMBU
coverage
:
coverage run
-p
$(OPENGEODE)
challenge.pr system_structure.pr
--toAda
.PHONY
:
all edit test-parse test-ada test-llvm coverage
\ No newline at end of file
.PHONY
:
all edit test-parse test-ada test-llvm coverage
tests/regression/test-exitnested/test_c.c
0 → 100644
View file @
c2ede186
int
main
()
{
// CInit();
runTransition
(
0
);
run
();
go_off
();
return
0
;
}
tests/regression/test-expressions/Makefile
View file @
c2ede186
...
...
@@ -13,11 +13,19 @@ test-ada: expressions.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
test_ada.o expressions.ali
-lgnat
-lm
-o
test_ada
./test_ada
test-c
:
expressions.c test_c.o dataview-uniq.o
$(CC)
expressions.c
-c
-o
expressions.o
$(CC)
test_c.o dataview-uniq.o expressions.o
-lm
-o
test_c
./test_c
test-llvm
:
expressions.o dataview-uniq.o | test_llvm.o
$(CC)
expressions.o dataview-uniq.o test_llvm.o
-o
test_llvm
-lm
./test_llvm
test-vhdl
:
test-c
bambu expressions.c test_c.c dataview-uniq.c
--experimental-setup
=
BAMBU
-v4
coverage
:
coverage run
-p
$(OPENGEODE)
expressions.pr system_structure.pr
--toAda
.PHONY
:
all edit test-parse test-ada test-llvm coverage
\ No newline at end of file
.PHONY
:
all edit test-parse test-ada test-llvm coverage
tests/regression/test-expressions/test_c.c
0 → 100644
View file @
c2ede186
#include
<stdio.h>
#include
<stdlib.h>
#include
"dataview-uniq.h"
void
expressions_RI_assert
(
asn1SccBoolean
*
res
,
asn1SccCharString
*
msg
)
{
if
(
!*
res
)
{
printf
(
"%.*s
\n
"
,
(
int
)
msg
->
nCount
,
msg
->
arr
);
exit
(
1
);
}
}
int
main
()
{
runTransition
(
0
);
run
();
return
0
;
}
tests/regression/test-llvm/Makefile
View file @
c2ede186
...
...
@@ -13,6 +13,11 @@ test-ada: orchestrator.ali dataview-uniq.o | test_ada.o
$(GNATLINK)
-o
test_ada test_ada.o orchestrator.ali
-lgnat
./test_ada
test-c
:
orchestrator.c test_c.o dataview-uniq.o
$(CC)
orchestrator.c
-c
-o
orchestrator.o
$(CC)
test_c.o orchestrator.c dataview-uniq.o
-lm
-o
test_c
./test_c | diff expected -
test-llvm
:
orchestrator.o dataview-uniq.o | test_llvm.o
$(CC)
orchestrator.o dataview-uniq.o test_llvm.o
-o
test_llvm
-lm
./test_llvm
...
...
Prev
1
2
3
4
Next
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