diff options
author | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-03-03 08:17:40 +0100 |
---|---|---|
committer | David Monniaux <david.monniaux@univ-grenoble-alpes.fr> | 2020-03-03 08:17:40 +0100 |
commit | 1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68 (patch) | |
tree | 210ffc156c83f04fb0c61a40b4f9037d7ba8a7e1 /test/monniaux/k1_builtins | |
parent | 222c9047d61961db9c6b19fed5ca49829223fd33 (diff) | |
parent | 12be46d59a2483a10d77fa8ee67f7e0ca1bd702f (diff) | |
download | compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.tar.gz compcert-kvx-1ab7b51c30e1b10ac45b0bd64cefdc01da0f7f68.zip |
Merge branch 'mppa-cse2' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa-work
Diffstat (limited to 'test/monniaux/k1_builtins')
-rw-r--r-- | test/monniaux/k1_builtins/atomics.c | 11 | ||||
-rw-r--r-- | test/monniaux/k1_builtins/execute_code.c | 27 | ||||
-rw-r--r-- | test/monniaux/k1_builtins/sbmm8.c | 15 | ||||
-rwxr-xr-x | test/monniaux/k1_builtins/sbmm8_demo.sage | 21 | ||||
-rw-r--r-- | test/monniaux/k1_builtins/test_k1_builtins.c | 40 |
5 files changed, 114 insertions, 0 deletions
diff --git a/test/monniaux/k1_builtins/atomics.c b/test/monniaux/k1_builtins/atomics.c new file mode 100644 index 00000000..40c459e2 --- /dev/null +++ b/test/monniaux/k1_builtins/atomics.c @@ -0,0 +1,11 @@ +#include <stdio.h> + +int main() { + long lval = 45; + long lval2 = __builtin_k1_afaddd(&lval, 6); + printf("%ld %ld\n", lval, lval2); + int ival = 45; + int ival2 = __builtin_k1_afaddw(&ival, 6); + printf("%d %d\n", ival, ival2); + return 0; +} diff --git a/test/monniaux/k1_builtins/execute_code.c b/test/monniaux/k1_builtins/execute_code.c new file mode 100644 index 00000000..58580ed9 --- /dev/null +++ b/test/monniaux/k1_builtins/execute_code.c @@ -0,0 +1,27 @@ +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +typedef int fun_type(int x); + +int poulet(int x) { + return x*2; +} + +int canard(int x) { + return x*3; +} + +#define SIZE 1024 +int main() { + void *buf=malloc(SIZE); + memcpy(buf, poulet, SIZE); + int rpoulet = (*((fun_type*) buf))(33); + memcpy(buf, canard, SIZE); + int rcanard = (*((fun_type*) buf))(33); + __builtin_k1_iinval(); + int rcanard2 = (*((fun_type*) buf))(33); + free(buf); + printf("%d %d %d\n", rpoulet, rcanard, rcanard2); + return 0; +} diff --git a/test/monniaux/k1_builtins/sbmm8.c b/test/monniaux/k1_builtins/sbmm8.c new file mode 100644 index 00000000..3b2ac447 --- /dev/null +++ b/test/monniaux/k1_builtins/sbmm8.c @@ -0,0 +1,15 @@ +#include <stdio.h> + +int main() { + { + unsigned long a = 0x12345678ABCDEFUL, b=0x12345118ABCD32UL, c; + c = __builtin_k1_sbmm8(a, b); + printf("%lx\n", c); + } + { + unsigned long a = 0x0102040810204080UL, b=0x12345118ABCD32UL, c; + c = __builtin_k1_sbmm8(a, b); + printf("%lx\n", c); + } + return 0; +} diff --git a/test/monniaux/k1_builtins/sbmm8_demo.sage b/test/monniaux/k1_builtins/sbmm8_demo.sage new file mode 100755 index 00000000..4a4c9df0 --- /dev/null +++ b/test/monniaux/k1_builtins/sbmm8_demo.sage @@ -0,0 +1,21 @@ +#!/usr/bin/env sage +def mat_from_uint64(n): + return Matrix(GF(2), [[(n >> (i*8+j)) & 1 for j in range(8)] for i in range(8)]) + +def uint64_from_mat(m): + s = 0 + for i in range(8): + for j in range(8): + if m[i, j]: + s += 1 << (i*8 + j) + return s + +matA=mat_from_uint64(0x12345678ABCDEF) +matB=mat_from_uint64(0x12345118ABCD32) + +print hex(uint64_from_mat(matB * matA)) + +matA=mat_from_uint64(0x0201040810208040) +matB=mat_from_uint64(0x0102011701010133) + +print matA*matB diff --git a/test/monniaux/k1_builtins/test_k1_builtins.c b/test/monniaux/k1_builtins/test_k1_builtins.c new file mode 100644 index 00000000..e02c7f2e --- /dev/null +++ b/test/monniaux/k1_builtins/test_k1_builtins.c @@ -0,0 +1,40 @@ +#include <stdio.h> +#include <mppa_bare_runtime/k1c/registers.h> + +void test_system_regs(void) { + __builtin_k1_wfxl(K1_SFR_EV4, 0x1000ULL); + __builtin_k1_wfxm(K1_SFR_EV4, 0x2000ULL); + __builtin_k1_get(K1_SFR_EV4); + __builtin_k1_set(K1_SFR_EV4, 0x4000ULL); +} + +void test_loads(void *addr) { + __builtin_k1_alclrd(addr); + __builtin_k1_alclrw(addr); + __builtin_k1_lbzu(addr); + __builtin_k1_lhzu(addr); + __builtin_k1_lwzu(addr); + __builtin_k1_ldu(addr); + __builtin_k1_dinvall(addr); + __builtin_k1_dtouchl(addr); + __builtin_k1_dzerol(addr); + __builtin_k1_iinvals(addr); + /* __builtin_k1_itouchl(addr); */ + __builtin_k1_dzerol(addr); +} + +void test_stops(void) { + __builtin_k1_await(); + __builtin_k1_sleep(); + __builtin_k1_stop(); + __builtin_k1_barrier(); + __builtin_k1_fence(); + __builtin_k1_dinval(); + __builtin_k1_iinval(); +} + +int main() { + unsigned long long data = 45; + unsigned long long res = __builtin_k1_alclrd(&data); + printf("%llu %llu\n", res, data); +} |