implement protocol ast and instruction-selection examples

This commit is contained in:
sneeker committed 2020-03-18 12:00:00 +00:00
1 parent d16ff1aa0d
commit 5e8bc13794
2 files changed
+19

No files matched your search

+9
View File
@@ -0,0 +1,9 @@
data Exp = Const Int | Reg Int | Plus Exp Exp | Times Exp Exp
data Instr = LoadImm Int | LoadReg Int | AddInstr | MulInstr
match select (e : Exp) : Instr =
| Plus (Reg a) (Reg b) -> AddInstr
| Times (Reg a) (Reg b) -> MulInstr
| Const n -> LoadImm n
| Reg n -> LoadReg n