aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--mppa_k1c/Asm.v5
-rw-r--r--mppa_k1c/Asmexpand.ml14
-rw-r--r--mppa_k1c/CBuiltins.ml6
-rw-r--r--mppa_k1c/TargetPrinter.ml11
-rw-r--r--test/monniaux/int128/test_swap.c13
-rw-r--r--test/monniaux/k1_builtins/sbmm8.c13
-rwxr-xr-xtest/monniaux/k1_builtins/sbmm8_demo.sage5
-rw-r--r--test/monniaux/k1_builtins/test_k1_builtins.c12
8 files changed, 59 insertions, 20 deletions
diff --git a/mppa_k1c/Asm.v b/mppa_k1c/Asm.v
index a9a88d75..f679335c 100644
--- a/mppa_k1c/Asm.v
+++ b/mppa_k1c/Asm.v
@@ -80,6 +80,9 @@ Inductive instruction : Type :=
| Pwfxl (n: int) (src: ireg)
| Pwfxm (n: int) (src: ireg)
| Pldu (dst: ireg) (addr: ireg)
+ | Plbzu (dst: ireg) (addr: ireg)
+ | Plhzu (dst: ireg) (addr: ireg)
+ | Plwzu (dst: ireg) (addr: ireg)
| Pawait
| Psleep
| Pstop
@@ -94,6 +97,8 @@ Inductive instruction : Type :=
| Pdzerol (addr: ireg)
| Pafaddd (addr: ireg) (incr_res: ireg)
| Pafaddw (addr: ireg) (incr_res: ireg)
+ | Palclrd (dst: ireg) (addr: ireg)
+ | Palclrw (dst: ireg) (addr: ireg)
(** Loads **)
| Plb (rd: ireg) (ra: ireg) (ofs: addressing) (**r load byte *)
diff --git a/mppa_k1c/Asmexpand.ml b/mppa_k1c/Asmexpand.ml
index 872a29f5..ba771bcb 100644
--- a/mppa_k1c/Asmexpand.ml
+++ b/mppa_k1c/Asmexpand.ml
@@ -381,6 +381,16 @@ let expand_builtin_inline name args res = let open Asmvliw in
else emit (Pwfxm(n, src)))
| "__builtin_k1_ldu", [BA(IR addr)], BR(IR res) ->
emit (Pldu(res, addr))
+ | "__builtin_k1_lbzu", [BA(IR addr)], BR(IR res) ->
+ emit (Plbzu(res, addr))
+ | "__builtin_k1_lhzu", [BA(IR addr)], BR(IR res) ->
+ emit (Plhzu(res, addr))
+ | "__builtin_k1_lwzu", [BA(IR addr)], BR(IR res) ->
+ emit (Plwzu(res, addr))
+ | "__builtin_k1_alclrd", [BA(IR addr)], BR(IR res) ->
+ emit (Palclrd(res, addr))
+ | "__builtin_k1_alclrw", [BA(IR addr)], BR(IR res) ->
+ emit (Palclrw(res, addr))
| "__builtin_k1_await", [], _ ->
emit Pawait
| "__builtin_k1_sleep", [], _ ->
@@ -413,6 +423,10 @@ let expand_builtin_inline name args res = let open Asmvliw in
(if res <> incr_res
then (emit (Pmv(res, incr_res)); emit Psemi));
emit (Pafaddw(addr, res))
+ | "__builtin_alclrd", [BA(IR addr)], BR(IR res) ->
+ emit (Palclrd(res, addr))
+ | "__builtin_alclrw", [BA(IR addr)], BR(IR res) ->
+ emit (Palclrw(res, addr))
(* Byte swaps *)
(*| "__builtin_bswap16", [BA(IR a1)], BR(IR res) ->
diff --git a/mppa_k1c/CBuiltins.ml b/mppa_k1c/CBuiltins.ml
index 914d1aa8..dfa11ba4 100644
--- a/mppa_k1c/CBuiltins.ml
+++ b/mppa_k1c/CBuiltins.ml
@@ -42,9 +42,9 @@ let builtins = {
"__builtin_k1_set", (TVoid [], [TInt(IInt, []); TInt(IULongLong, [])], false); (* DONE *)
(* LSU Instructions *)
- (* No ACWS - __int128 *)
- "__builtin_k1_afaddd", (TInt(IULongLong, []), [TPtr(TVoid [], []); TInt(ILongLong, [])], false);
- "__builtin_k1_afaddw", (TInt(IUInt, []), [TPtr(TVoid [], []); TInt(IInt, [])], false);
+ (* afaddd and afaddw done using headers and assembly *)
+ "__builtin_k1_alclrd", (TInt(IULongLong, []), [TPtr(TVoid [], [])], false); (* DONE *)
+ "__builtin_k1_alclrw", (TInt(IUInt, []), [TPtr(TVoid [], [])], false); (* DONE *)
"__builtin_k1_dinval", (TVoid [], [], false); (* DONE *)
"__builtin_k1_dinvall", (TVoid [], [TPtr(TVoid [], [])], false); (* DONE *)
"__builtin_k1_dtouchl", (TVoid [], [TPtr(TVoid [], [])], false); (* DONE *)
diff --git a/mppa_k1c/TargetPrinter.ml b/mppa_k1c/TargetPrinter.ml
index 4599f2a1..ca158cb9 100644
--- a/mppa_k1c/TargetPrinter.ml
+++ b/mppa_k1c/TargetPrinter.ml
@@ -288,6 +288,12 @@ module Target (*: TARGET*) =
fprintf oc " wfxm $s%ld = %a\n" (camlint_of_coqint n) ireg dst
| Pldu(dst, addr) ->
fprintf oc " ld.u %a = 0[%a]\n" ireg dst ireg addr
+ | Plbzu(dst, addr) ->
+ fprintf oc " lbz.u %a = 0[%a]\n" ireg dst ireg addr
+ | Plhzu(dst, addr) ->
+ fprintf oc " lhz.u %a = 0[%a]\n" ireg dst ireg addr
+ | Plwzu(dst, addr) ->
+ fprintf oc " lwz.u %a = 0[%a]\n" ireg dst ireg addr
| Pawait ->
fprintf oc " await\n"
| Psleep ->
@@ -316,7 +322,10 @@ module Target (*: TARGET*) =
fprintf oc " afaddd 0[%a] = %a\n" ireg addr ireg incr_res
| Pafaddw(addr, incr_res) ->
fprintf oc " afaddw 0[%a] = %a\n" ireg addr ireg incr_res
-
+ | Palclrd(res, addr) ->
+ fprintf oc " alclrd %a = 0[%a]\n" ireg res ireg addr
+ | Palclrw(res, addr) ->
+ fprintf oc " alclrw %a = 0[%a]\n" ireg res ireg addr
| Pjumptable (idx_reg, tbl) ->
let lbl = new_label() in
(* jumptables := (lbl, tbl) :: !jumptables; *)
diff --git a/test/monniaux/int128/test_swap.c b/test/monniaux/int128/test_swap.c
deleted file mode 100644
index 4841f040..00000000
--- a/test/monniaux/int128/test_swap.c
+++ /dev/null
@@ -1,13 +0,0 @@
-#include <stdio.h>
-
-int main() {
- unsigned long long loc=10, next=12, current=11;
- union {
- __int128 i128;
- struct {
- unsigned long low, high;
- } i64_2;
- } ret;
- ret.i128 = __builtin_k1_acswapd(&loc, next, current);
- printf("%lx %lx\n", ret.i64_2.low, ret.i64_2.high);
-}
diff --git a/test/monniaux/k1_builtins/sbmm8.c b/test/monniaux/k1_builtins/sbmm8.c
index da1178dc..3b2ac447 100644
--- a/test/monniaux/k1_builtins/sbmm8.c
+++ b/test/monniaux/k1_builtins/sbmm8.c
@@ -1,8 +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 = 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
index 45948668..4a4c9df0 100755
--- a/test/monniaux/k1_builtins/sbmm8_demo.sage
+++ b/test/monniaux/k1_builtins/sbmm8_demo.sage
@@ -14,3 +14,8 @@ 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
index 94509131..e02c7f2e 100644
--- a/test/monniaux/k1_builtins/test_k1_builtins.c
+++ b/test/monniaux/k1_builtins/test_k1_builtins.c
@@ -1,3 +1,4 @@
+#include <stdio.h>
#include <mppa_bare_runtime/k1c/registers.h>
void test_system_regs(void) {
@@ -8,6 +9,11 @@ void test_system_regs(void) {
}
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);
@@ -26,3 +32,9 @@ void test_stops(void) {
__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);
+}