Commit aeb3a618 authored by Maxime Perrotin's avatar Maxime Perrotin
Browse files

Merge branch 'llvm' of https://github.com/dbrabera/opengeode

parents ea3aad83 9b2eea26
This diff is collapsed.
......@@ -6,6 +6,9 @@ test-parse:
test-ada:
@python tests/test.py test-ada
test-llvm:
@python tests/test.py test-llvm
flake8:
@echo Generating flake8_report file
flake8 opengeode.py Pr.py sdlSymbols.py genericSymbols.py ogParser.py AdaGenerator.py Renderer.py Clipboard.py Lander.py ogAST.py undoCommands.py Connectors.py Asn1scc.py Helper.py Statechart.py >flake8_report
......
......@@ -55,6 +55,9 @@ You need to install the following dependencies before you can run Opengeode:
- gnat - if you want to build the code you generate in Ada
$ sudo apt-get install gnat
- llvmpy (tested with 0.12.4)
Follow the instructions here: http://www.llvmpy.org/llvmpy-doc/0.12.4/doc/getting_started.html#installation
To make a static binary on Linux with pyinstaller 2.0:
python pyinstaller.py ../../opengeode.py --onefile
......@@ -21,20 +21,20 @@ Features
--------
- Graphical editor of SDL processes and procedures.
- SDL2010 features: FOR loops in task symbols, hierarchical states
- SDL2010 features: FOR loops in task symbols, hierarchical states
- Works on pure PR+CIF files (textual SDL notation) - no fancy proprietary save format
- Full supports ASN.1 data types - using ESA Space Certified compiler (www.github.com/ttsiodras/asn1scc)
- Full supports ASN.1 data types - using ESA Space Certified compiler (www.github.com/ttsiodras/asn1scc)
- Generates Ada code
- Extensive syntax and semantic checks
- Automatic conversion to Statechart diagrams
- Extensive syntax and semantic checks
- Automatic conversion to Statechart diagrams
- Save the complete or parts of the model to PNG/SVG/PDF files
- Hyperlinks (link a symbol content to any external document or web page)
- Zoom in, zoom-out
- Context-dependent text auto-completion
- Syntax highlighting
- Undo/Redo, Copy-Paste
- Hyperlinks (link a symbol content to any external document or web page)
- Zoom in, zoom-out
- Context-dependent text auto-completion
- Syntax highlighting
- Undo/Redo, Copy-Paste
- (Limited) VIM mode - You can use :wq or :%s,search,replace,g, and /search pattern
- (In progress) SDL to LLVM code generation
- SDL to LLVM code generation
Installation
============
......@@ -53,6 +53,7 @@ Apart from pygraphviz, all of them exist for Linux, Windows, FreeBSD, and most l
- ASN1SCC
- (optional) GNAT to build the generated Ada code
- mono
- llvmpy for the LLVM backend (tested with 0.12.4)
On Debian, Ubuntu, and probably other distributions:
......@@ -78,6 +79,8 @@ Check that it works:
$ asn1.exe
```
To install llvmpy follow the instructions [here](http://www.llvmpy.org/llvmpy-doc/0.12.4/doc/getting_started.html#installation)
OpenGEODE installation
----------------------
......@@ -96,7 +99,7 @@ You can get the source from the TASTE repositories or from GitHub
```bash
$ git clone https://github.com/maxime-esa/opengeode.git
```
```
Then enter the opengeode directory and as root, type:
......
EXAMPLES=test1 test2 test3 test4 test5 test6 test7 test8 test9 test10 \
test11 test12 test-substrings test-expressions
test11 test12 test-substrings test-expressions test-controlflow
coverage:
for v in $(EXAMPLES) ; do make -C $$v coverage && mv $$v/.coverage* . \
......
all: test-ada
edit:
../../../opengeode.py controlflow.pr system_structure.pr
test-parse:
../../../opengeode.py controlflow.pr system_structure.pr --check
test-ada:
../../../opengeode.py controlflow.pr system_structure.pr --check --toAda
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
asn1.exe -c dataview-uniq.asn -typePrefix asn1Scc
gnatmake -c *.adb
gcc -c test_ada.c
gnatbind -n controlflow.ali
gnatlink test_ada.o controlflow.ali -lgnat -lm -o testcase
./testcase | diff expected -
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
./testcase | diff expected -
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
\ No newline at end of file
/* CIF PROCESS (151, 149), (150, 75) */
PROCESS controlflow;
/* CIF TEXT (376, 97), (303, 168) */
-- Declare your variables
-- Syntax: DCL <variable name> <type name>;
DCL n Integer;
DCL b Boolean;
DCL seq1 IntegerSeqOf;
DCL seq2 IntegerSeqOf;
/* CIF ENDTEXT */
/* CIF START (3, 0), (70, 35) */
START;
/* CIF NEXTSTATE (3, 50), (70, 35) */
NEXTSTATE Wait;
/* CIF LABEL (2, 1904), (75, 35) */
CONNECTION label2:
/* CIF PROCEDURECALL (-28, 1954), (136, 35) */
CALL writeln('label2');
/* CIF LABEL (2, 2004), (75, 35) */
label3:
/* CIF PROCEDURECALL (-28, 2054), (136, 35) */
CALL writeln('label3');
/* CIF NEXTSTATE (5, 2104), (70, 35) */
NEXTSTATE wait;
/* CIF End Label */
ENDCONNECTION;
/* CIF LABEL (0, 1747), (78, 35) */
CONNECTION label1:
/* CIF PROCEDURECALL (-31, 1797), (141, 35) */
CALL writeln('label1');
/* CIF JOIN (21, 1847), (35, 35) */
JOIN label2;
/* CIF End Label */
ENDCONNECTION;
/* CIF STATE (3, 50), (70, 35) */
STATE Wait;
/* CIF INPUT (3, 105), (70, 35) */
INPUT run;
/* CIF TASK (-133, 155), (343, 35) */
TASK '------------------------------- Decision -------------------------------';
/* CIF TASK (2, 205), (70, 35) */
TASK n := 2;
/* CIF DECISION (3, 255), (70, 50) */
DECISION n;
/* CIF ANSWER (-107, 325), (70, 24) */
(1):
/* CIF PROCEDURECALL (-148, 364), (153, 35) */
CALL fail('decision else');
/* CIF ANSWER (114, 325), (70, 24) */
else:
ENDDECISION;
/* CIF DECISION (3, 414), (70, 50) */
DECISION n;
/* CIF ANSWER (-143, 474), (70, 24) */
(1):
/* CIF PROCEDURECALL (-200, 513), (184, 35) */
CALL fail( 'decision constant');
/* CIF ANSWER (3, 474), (70, 24) */
(2):
/* CIF ANSWER (165, 474), (70, 24) */
else:
/* CIF PROCEDURECALL (107, 513), (184, 35) */
CALL fail( 'decision constant');
ENDDECISION;
/* CIF DECISION (3, 563), (70, 50) */
DECISION n;
/* CIF ANSWER (-79, 623), (70, 24) */
(<2):
/* CIF PROCEDURECALL (-142, 662), (197, 35) */
CALL fail('decision open range');
/* CIF ANSWER (95, 623), (70, 24) */
(>1):
ENDDECISION;
/* CIF DECISION (3, 712), (70, 50) */
DECISION n;
/* CIF ANSWER (-171, 772), (70, 24) */
(-1:1):
/* CIF PROCEDURECALL (-247, 811), (223, 35) */
CALL fail('decision closed range');
/* CIF ANSWER (3, 772), (70, 24) */
(2:5):
/* CIF ANSWER (177, 772), (70, 24) */
else:
/* CIF PROCEDURECALL (109, 811), (205, 35) */
CALL fail('decision closed range');
ENDDECISION;
/* CIF TASK (-136, 861), (348, 35) */
TASK '------------------------------- For loops -------------------------------';
/* CIF TASK (2, 911), (70, 35) */
TASK n := 0;
/* CIF TASK (-45, 961), (167, 56) */
TASK for x in range(10):
n := n + x mod 255
endfor;
/* CIF PROCEDURECALL (-80, 1032), (237, 35) */
CALL assert(n = 45, 'for x in range(10)');
/* CIF TASK (2, 1082), (70, 35) */
TASK n := 0;
/* CIF TASK (-45, 1132), (167, 56) */
TASK for x in range(4, 10):
n := n + x mod 255
endfor;
/* CIF PROCEDURECALL (-87, 1203), (251, 35) */
CALL assert(n = 39, 'for x in range(4, 10)');
/* CIF TASK (2, 1253), (70, 35) */
TASK n := 0;
/* CIF TASK (-66, 1303), (208, 56) */
TASK for x in range(4, 10, 2):
n := n + x mod 255
endfor;
/* CIF PROCEDURECALL (-96, 1374), (269, 35) */
CALL assert(n = 18, 'for x in range(4, 10, 2)');
/* CIF TASK (-37, 1424), (150, 35) */
TASK seq1 := {7, 8, 9, 10};
/* CIF TASK (2, 1474), (70, 35) */
TASK n := 0;
/* CIF TASK (-40, 1524), (157, 56) */
TASK for x in seq1:
n := n + x mod 255
endfor;
/* CIF PROCEDURECALL (-67, 1595), (210, 35) */
CALL assert(n = 34, 'for x in seq1' );
/* CIF TASK (-124, 1645), (325, 35) */
TASK '------------------------------- Join ------------------------------- ';
/* CIF JOIN (20, 1695), (35, 35) */
JOIN label1;
ENDSTATE;
ENDPROCESS controlflow;
\ No newline at end of file
TASTE-Dataview DEFINITIONS ::=
BEGIN
Boolean ::= BOOLEAN
Integer ::= INTEGER(-9223372036854775808..9223372036854775807)
Real ::= REAL (-100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0 .. 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.0)
CharString ::= OCTET STRING (SIZE(0..100))
IntegerSeqOf ::= SEQUENCE (SIZE (1..32)) OF Integer
END
/* CIF Keep Specific Geode ASNFilename 'dataview-uniq.asn' */
USE Datamodel;
SYSTEM controlflow;
SIGNAL run;
PROCEDURE assert;
FPAR
IN res Boolean,
IN msg CharString;
EXTERNAL;
PROCEDURE fail;
FPAR
IN msg CharString;
EXTERNAL;
CHANNEL c
FROM ENV TO controlflow WITH run;
ENDCHANNEL;
BLOCK basic;
SIGNALROUTE r
FROM ENV TO controlflow WITH run;
CONNECT c and r;
PROCESS controlflow REFERENCED;
ENDBLOCK;
ENDSYSTEM;
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void adainit();
extern void controlflow_run();
void controlflow_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
void controlflow_RI_fail(asn1SccCharString *msg) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
int main() {
adainit();
controlflow_run();
return 0;
}
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void controlflow_startup();
extern void controlflow_run();
void controlflow_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
void controlflow_RI_fail(asn1SccCharString *msg) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
int main() {
controlflow_startup();
controlflow_run();
return 0;
}
......@@ -16,6 +16,16 @@ test-ada:
gnatlink test_ada.o expressions.ali -lgnat -lm -o testcase
./testcase
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
./testcase
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 \
......
#include <stdio.h>
#include <stdlib.h>
#include "dataview-uniq.h"
extern void expressions_startup();
extern void expressions_run();
void expressions_RI_assert(asn1SccBoolean *res, asn1SccCharString *msg) {
if (!*res) {
fprintf(stderr, "%.*s\n", (int)msg->nCount, msg->arr);
exit(1);
}
}
int main() {
expressions_startup();
expressions_run();
return 0;
}
......@@ -19,9 +19,20 @@ test-ada:
gnatlink -o testcase test.o myfunction.ali -lgnat
./testcase | diff expected -
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
./testcase | diff expected -
coverage:
coverage run -p ../../../opengeode.py myfunction.pr system_structure.pr --toAda
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner bin *.wrn *.gpr datav*.? ber.c xer.c asn1crt.? acn.c real.c testcase
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner \
bin *.wrn *.gpr datav*.? ber.c xer.c asn1crt.? acn.c real.c *.ll *.s testcase
#include <stdio.h>
#include "dataview-uniq.h"
extern void myfunction_startup();
extern void myfunction_start_something(asn1SccT_Int32 *);
void myfunction_RI_result_data(long long *val)
{
printf("[C] result_data: %lld\n", *val);
}
int main()
{
asn1SccT_Int32 test = 5;
printf("[C Code] Running test\n");
myfunction_startup();
myfunction_start_something(&test);
return 0;
}
all: test-ada
all: test-ada test-llvm
edit:
../../../opengeode.py og.pr system_structure.pr
......@@ -11,8 +11,14 @@ test-ada:
asn1.exe -Ada dataview-uniq.asn -typePrefix asn1Scc -equal
gnatmake -c og.adb
test-llvm:
../../../opengeode.py og.pr system_structure.pr --llvm
llc og.ll
gcc -c og.s
coverage:
coverage run -p ../../../opengeode.py og.pr system_structure.pr --toAda
clean:
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner bin *.wrn *.gpr
rm -rf *.adb *.ads *.pyc runSpark.sh spark.idx *.o *.ali gnat.cfg examiner \
bin *.wrn *.gpr testcase *.ll *.s
all: test-ada
all: test-ada test-llvm
edit:
../../../opengeode.py challenge.pr system_structure.pr
......@@ -10,13 +10,25 @@ 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.c
gcc -c test_ada.c
gnatbind -n challenge.ali
gnatlink -o testcase test.o challenge.ali -lgnat -lm
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
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
./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
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
#include <math.h>
#include <stdio.h>
/* Ada code external interface */
extern void challenge_run();
extern void challenge_any_one();
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_run();
//printf("Internal state: %lld\n", l_result);
challenge_any_one();
challenge_run();
return 0;
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment