cpuex2019-1 / compiler

Other
0 stars 0 forks source link

アセンブリのライブラリ関数のインライン化 #16

Closed okuraofvegetable closed 4 years ago

okuraofvegetable commented 4 years ago

一時レジスタしか用いていないsqrt,ftoi,itof,floorを呼び出す際もレジスタの値の退避が起こるので、インライン化してこれをなくす。

okuraofvegetable commented 4 years ago

1引数1返り値のアセンブリ命令に対して

let rec sqrt x =
  ASM sqrt x
in ...

と書けるようにMinCaml文法を拡張することでインライン化できるようにする

okuraofvegetable commented 4 years ago

気づいてなかったがこれでprint_charもインライン化できる

okuraofvegetable commented 4 years ago

この方針は一旦やめてregAllocにライブラリ関数と使用レジスタを登録して退避を回避しておく方針にしようかと思う(インライン化できないがジャンプは妥協...)

okuraofvegetable commented 4 years ago

Asm構文を実装した。 新たにAsmを追加する際はtyping.ml,kNormal(asm_res_type),elim.ml(副作用判定),virtual.ml,regAlloc.ml,emit.ml,elim_asm.ml(副作用判定)をいじる必要あり。