aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYann Herklotz <git@yannherklotz.com>2021-11-09 09:27:57 +0000
committerYann Herklotz <git@yannherklotz.com>2021-11-09 09:27:57 +0000
commit36e0e45e7c8f93bf6f733197bf19f277a5e11248 (patch)
tree57fba6537eebccdac64adffd5b03f2ea0352bb8a
parent8125547cd8d74385a327fce26111f5e27c3d2b45 (diff)
downloadgsa-parser-36e0e45e7c8f93bf6f733197bf19f277a5e11248.tar.gz
gsa-parser-36e0e45e7c8f93bf6f733197bf19f277a5e11248.zip
Add new files
-rw-r--r--examples/cond_return.c7
-rw-r--r--examples/cond_return.gsa14
-rw-r--r--examples/double_for_loop.c13
-rw-r--r--examples/double_for_loop.gsa52
-rw-r--r--examples/simple_return.c4
-rw-r--r--examples/simple_return.gsa8
-rw-r--r--examples/tiny.gsa4
7 files changed, 102 insertions, 0 deletions
diff --git a/examples/cond_return.c b/examples/cond_return.c
new file mode 100644
index 0000000..74bd493
--- /dev/null
+++ b/examples/cond_return.c
@@ -0,0 +1,7 @@
+int f(int y) {
+ int x = 5;
+ if (y == 21) {
+ x = 20;
+ }
+ return x;
+}
diff --git a/examples/cond_return.gsa b/examples/cond_return.gsa
new file mode 100644
index 0000000..4b789b8
--- /dev/null
+++ b/examples/cond_return.gsa
@@ -0,0 +1,14 @@
+f(x8) {
+ 10: nop
+ 9: nop
+ 8: x20 = 5
+ 7: if (x8 ==s 21) goto 5 else goto 6
+ 6: goto 3
+ 5: x22 = 20
+ 4: nop
+ 3: x18 = γ((¬(x8 ==s 21),x20),((x8 ==s 21),x22))
+ nop
+ 2: x28 = x18
+ 1: return x28
+}
+
diff --git a/examples/double_for_loop.c b/examples/double_for_loop.c
new file mode 100644
index 0000000..c58301d
--- /dev/null
+++ b/examples/double_for_loop.c
@@ -0,0 +1,13 @@
+int f (int A[1000], int B[1000]) {
+ for (int i = 0; i < 1000; i++) {
+ if (i % 2) {
+ A[i] = B[i];
+ }
+ }
+ for (int i = 0; i < 1000; i++) {
+ if (! (i % 2)) {
+ A[i] = B[i];
+ }
+ }
+ return A[100];
+}
diff --git a/examples/double_for_loop.gsa b/examples/double_for_loop.gsa
new file mode 100644
index 0000000..f035e8a
--- /dev/null
+++ b/examples/double_for_loop.gsa
@@ -0,0 +1,52 @@
+f(x16, x8) {
+ 46: nop
+ 45: nop
+ 44: x36 = 0
+ 43: nop
+ 42: nop
+ 41: x34 = μ(x38, x36)
+ nop
+ 40: x140 = x34
+ 39: x156 = x140 >>x 1
+ 38: x148 = x156 * 2 + 0 (int)
+ 37: x132 = x140 - x148
+ 36: if (x132 !=u 0) goto 34 else goto 35
+ 35: goto 29
+ 34: x108 = long32signed(x34)
+ 33: x124 = x108
+ 32: x116 = int32[x8 + x124 * 4 + 0]
+ 31: int32[x16 + x108 * 4 + 0] = x116
+ 30: nop
+ 29: nop
+ 28: x38 = x34 + 1 (int)
+ 27: if (x38 <s 1000) goto 2 else goto 26
+ 26: x157 = η(((¬(x132 !=u 0) ∨ (x132 !=u 0)) ∧ ¬(x38 <s 1000)), x34)
+ nop
+ 25: x28 = 0
+ 24: nop
+ 23: nop
+ 22: x26 = μ(x28, x30)
+ nop
+ 21: x84 = x26
+ 20: x100 = x84 >>x 1
+ 19: x92 = x100 * 2 + 0 (int)
+ 18: x76 = x84 - x92
+ 17: if (x76 ==u 0) goto 15 else goto 16
+ 16: goto 10
+ 15: x52 = long32signed(x26)
+ 14: x68 = x52
+ 13: x60 = int32[x8 + x68 * 4 + 0]
+ 12: int32[x16 + x52 * 4 + 0] = x60
+ 11: nop
+ 10: nop
+ 9: x30 = x26 + 1 (int)
+ 8: if (x30 <s 1000) goto 4 else goto 7
+ 7: x158 = η(((¬(x76 ==u 0) ∨ (x76 ==u 0)) ∧ ¬(x30 <s 1000)), x26)
+ nop
+ 6: x44 = int32[x16 + 400]
+ 5: return x44
+ 4: nop
+ 3: goto 22
+ 2: nop
+ 1: goto 41
+}
diff --git a/examples/simple_return.c b/examples/simple_return.c
new file mode 100644
index 0000000..cb33687
--- /dev/null
+++ b/examples/simple_return.c
@@ -0,0 +1,4 @@
+int main() {
+ int x = 5;
+ return x;
+}
diff --git a/examples/simple_return.gsa b/examples/simple_return.gsa
new file mode 100644
index 0000000..dd48fe2
--- /dev/null
+++ b/examples/simple_return.gsa
@@ -0,0 +1,8 @@
+main() {
+ 5: nop
+ 4: nop
+ 3: x6 = 5
+ 2: x10 = x6
+ 1: return x10
+}
+
diff --git a/examples/tiny.gsa b/examples/tiny.gsa
new file mode 100644
index 0000000..5658c39
--- /dev/null
+++ b/examples/tiny.gsa
@@ -0,0 +1,4 @@
+f(x1, x2) {
+ 46: x1 = x2
+ 45: nop
+}