From 66f236124907af065fc8396f8cefd5726a46b06a Mon Sep 17 00:00:00 2001 From: Cyril SIX Date: Fri, 8 Feb 2019 15:39:48 +0100 Subject: Added indirect tailcalls --- test/mppa/instr/indirect_tailcall.c | 33 +++++++++++++++++++++++++++++++++ test/mppa/instr/tailcall.c | 16 ++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/mppa/instr/indirect_tailcall.c create mode 100644 test/mppa/instr/tailcall.c (limited to 'test/mppa') diff --git a/test/mppa/instr/indirect_tailcall.c b/test/mppa/instr/indirect_tailcall.c new file mode 100644 index 00000000..69295117 --- /dev/null +++ b/test/mppa/instr/indirect_tailcall.c @@ -0,0 +1,33 @@ +#include "framework.h" + +long long sum(long long a, long long b){ + return a+b; +} + +long long diff(long long a, long long b){ + return a-b; +} + +long long mul(long long a, long long b){ + return a*b; +} + +long long random_op(long long a, long long b){ + long long d = 3; + long long (*op)(long long, long long); + + if (a % d == 0) + op = sum; + else if (a % d == 1) + op = diff; + else + op = mul; + + return op(a, b); +} + +BEGIN_TEST(long long) +{ + c += random_op(a, b); +} +END_TEST() diff --git a/test/mppa/instr/tailcall.c b/test/mppa/instr/tailcall.c new file mode 100644 index 00000000..0d15d9e0 --- /dev/null +++ b/test/mppa/instr/tailcall.c @@ -0,0 +1,16 @@ +#include "framework.h" + +int make(int a){ + return a; +} + +int sum(int a, int b){ + return make(a+b); +} + +BEGIN_TEST(int) +{ + c = sum(a, b); +} +END_TEST() +/* RETURN VALUE: 60 */ -- cgit