|
|
@@ -27,18 +27,30 @@ let rec peephole = function
|
|
|
* v v
|
|
|
* i{inc,dec} L C | i{inc,dec}_1 L
|
|
|
*)
|
|
|
- | (Load (Int, Current, index) :: LoadImm (IntVal i) :: Op (Add, Int) ::
|
|
|
+ | (Load (Int, Current, index) :: LoadConst (_, i) :: Op (Add, Int) ::
|
|
|
Store (Int, Current, store) :: tl
|
|
|
- | LoadImm (IntVal i) :: Load (Int, Current, index) :: Op (Add, Int) ::
|
|
|
+ | LoadConst (_, i) :: Load (Int, Current, index) :: Op (Add, Int) ::
|
|
|
Store (Int, Current, store) :: tl) when store = index ->
|
|
|
InlineComment (Inc (index, i), "add -> inc") :: (peephole tl)
|
|
|
|
|
|
- | (Load (Int, Current, index) :: LoadImm (IntVal i) :: Op (Sub, Int) ::
|
|
|
+ | (Load (Int, Current, index) :: LoadConst (_, i) :: Op (Sub, Int) ::
|
|
|
Store (Int, Current, store) :: tl
|
|
|
- | LoadImm (IntVal i) :: Load (Int, Current, index) :: Op (Sub, Int) ::
|
|
|
+ | LoadConst (_, i) :: Load (Int, Current, index) :: Op (Sub, Int) ::
|
|
|
Store (Int, Current, store) :: tl) when store = index ->
|
|
|
InlineComment (Dec (index, i), "sub -> dec") :: (peephole tl)
|
|
|
|
|
|
+ | (Load (Int, Current, index) :: LoadImm (IntVal 1) :: Op (Add, Int) ::
|
|
|
+ Store (Int, Current, store) :: tl
|
|
|
+ | LoadImm (IntVal 1) :: Load (Int, Current, index) :: Op (Add, Int) ::
|
|
|
+ Store (Int, Current, store) :: tl) when store = index ->
|
|
|
+ InlineComment (IncOne index, "add -> inc") :: (peephole tl)
|
|
|
+
|
|
|
+ | (Load (Int, Current, index) :: LoadImm (IntVal 1) :: Op (Sub, Int) ::
|
|
|
+ Store (Int, Current, store) :: tl
|
|
|
+ | LoadImm (IntVal 1) :: Load (Int, Current, index) :: Op (Sub, Int) ::
|
|
|
+ Store (Int, Current, store) :: tl) when store = index ->
|
|
|
+ InlineComment (DecOne index, "sub -> dec") :: (peephole tl)
|
|
|
+
|
|
|
| hd :: tl -> hd :: (peephole tl)
|
|
|
| [] -> []
|
|
|
|