From 8c82214b6edd099f8291aed93b7f8f8223573fc0 Mon Sep 17 00:00:00 2001 From: Sven Verdoolaege Date: Tue, 11 Sep 2012 15:34:00 +0200 Subject: [PATCH] support modulo operation in statements Signed-off-by: Sven Verdoolaege --- include/pet.h | 1 + scan.cc | 2 ++ scop.c | 1 + tests/mod2.c | 11 +++++++++++ tests/mod2.scop | 30 ++++++++++++++++++++++++++++++ 5 files changed, 45 insertions(+) create mode 100644 tests/mod2.c create mode 100644 tests/mod2.scop diff --git a/include/pet.h b/include/pet.h index 5bd2c9a..3938c45 100644 --- a/include/pet.h +++ b/include/pet.h @@ -44,6 +44,7 @@ enum pet_op_type { pet_op_sub, pet_op_mul, pet_op_div, + pet_op_mod, pet_op_eq, pet_op_le, pet_op_lt, diff --git a/scan.cc b/scan.cc index 1a00677..ec99699 100644 --- a/scan.cc +++ b/scan.cc @@ -1333,6 +1333,8 @@ static enum pet_op_type BinaryOperatorKind2pet_op_type(BinaryOperatorKind kind) return pet_op_mul; case BO_Div: return pet_op_div; + case BO_Rem: + return pet_op_mod; case BO_EQ: return pet_op_eq; case BO_LE: diff --git a/scop.c b/scop.c index c221992..9e6e519 100644 --- a/scop.c +++ b/scop.c @@ -58,6 +58,7 @@ static char *op_str[] = { [pet_op_sub] = "-", [pet_op_mul] = "*", [pet_op_div] = "/", + [pet_op_mod] = "%", [pet_op_eq] = "==", [pet_op_le] = "<=", [pet_op_lt] = "<", diff --git a/tests/mod2.c b/tests/mod2.c new file mode 100644 index 0000000..00a2e95 --- /dev/null +++ b/tests/mod2.c @@ -0,0 +1,11 @@ +void foo(int N) +{ + int i; + int a[N]; + +#pragma scop + for (i = 0; i < N; ++i) + if (i % 2 == 0) + a[i] = i % 3; +#pragma endscop +} diff --git a/tests/mod2.scop b/tests/mod2.scop new file mode 100644 index 0000000..2e1b332 --- /dev/null +++ b/tests/mod2.scop @@ -0,0 +1,30 @@ +context: '[N] -> { : N >= 0 and N <= 2147483647 }' +arrays: +- context: '[N] -> { : N >= 0 }' + extent: '[N] -> { a[i0] : i0 >= 0 and i0 <= -1 + N }' + element_type: int + element_size: 4 +statements: +- line: 9 + domain: '[N] -> { S_0[i] : exists (e0 = [(i)/2]: 2e0 = i and i >= 0 and i <= -1 + + N) }' + schedule: '[N] -> { S_0[i] -> [0, i] }' + body: + type: binary + operation: = + arguments: + - type: access + relation: '[N] -> { S_0[i] -> a[i] }' + read: 0 + write: 1 + - type: binary + operation: '%' + arguments: + - type: access + relation: '[N] -> { S_0[i] -> [i] }' + read: 1 + write: 0 + - type: access + relation: '[N] -> { S_0[i] -> [3] }' + read: 1 + write: 0 -- 2.11.4.GIT