test/* をRISC-Vで動かす
#MinCaml #RISC-V
from MinCamlでRISC-Vのアセンブリコードを出力したい
動いた
ack
adder
even-odd
float(誤差あり)
print
sum
sum-tail
fib
funcomp
cls-reg-bug
funcomp
shuffle
spill
spill3
non-tail-if
non-tail-if2
cls-bug
cls-bug2
inprod
inprod-rec
inprod-loop
join-reg
join-reg2
join-stack
join-stack2
join-stack3
spill2
matmul-flat
matmul
動いてない
toomanyargs(これはまあいいや)
shootout/tak
non-tail-if 対応
code:diff
diff --git a/RV32/emit.ml b/RV32/emit.ml
index 2ef2c0e..096588a 100644
--- a/RV32/emit.ml
+++ b/RV32/emit.ml
@@ -168,14 +168,16 @@ and g' oc = function (* 各命令のアセンブリ生成 (caml2html: emit_gprim
(* 新しい if 実装済み *)
g'_non_tail_if_new oc (reg x) (reg y) (NonTail(z)) e1 e2 "ble" "bgt"
| NonTail(z), IfLE(x, C(y), e1, e2) ->
- Printf.fprintf oc "\tcmpwi\tcr7@@, %s, %d\n" (reg x) y;
- g'_non_tail_if oc (NonTail(z)) e1 e2 "ble" "bgt"
+ (* 新しい if 実装済み *)
+ Printf.fprintf oc "\tli %s, %d\n" (reg reg_tmp) y;
+ g'_non_tail_if_new oc (reg x) (reg reg_tmp) (NonTail(z)) e1 e2 "ble" "bgt"
| NonTail(z), IfGE(x, V(y), e1, e2) ->
Printf.fprintf oc "\tcmpw\tcr7@@, %s, %s\n" (reg x) (reg y);
g'_non_tail_if oc (NonTail(z)) e1 e2 "bge" "blt"
| NonTail(z), IfGE(x, C(y), e1, e2) ->
- Printf.fprintf oc "\tcmpwi\tcr7@@, %s, %d\n" (reg x) y;
- g'_non_tail_if oc (NonTail(z)) e1 e2 "bge" "blt"
+ (* 新しい if 実装済み *)
+ Printf.fprintf oc "\tli %s, %d\n" (reg reg_tmp) y;
+ g'_non_tail_if_new oc (reg x) (reg reg_tmp) (NonTail(z)) e1 e2 "bge" "blt"
| NonTail(z), IfFEq(x, y, e1, e2) ->
(* 新しい if 実装済み(浮動小数点数対応) *)
Printf.fprintf oc "\tfeq.s %s, %s, %s\n" (reg reg_tmp) (reg x) (reg y);
diff --git a/stub.c b/stub.c
index 7aacca3..ac59d84 100644
--- a/stub.c
+++ b/stub.c
@@ -103,4 +103,8 @@ int min_caml_int_of_float(float x) {
return (int)x;
}
+int min_caml_truncate(float x) {
+ return (int)x;
+}
+