open MIPSOps
open Printf
let unop reg f (op, dst, src) =
match op with
| UOpAddi 0l ->
sprintf "move %a, %a" reg dst reg src
| UOpAddi i ->
sprintf "addiu %a, %a, %ld" reg dst reg src i
| UOpSlli i ->
sprintf "sll %a, %a, %ld" reg dst reg src i
| UOpSlti i ->
sprintf "slti %a, %a, %ld" reg dst reg src i
let binop = function
| OpAdd ->
"addu "
| OpSub ->
"subu "
| OpMul ->
"mul "
| OpDiv ->
"div "
| OpLt ->
"slt "
| OpLe ->
"sle "
| OpGt ->
"sgt "
| OpGe ->
"sge "
| OpEq ->
"seq "
| OpNe ->
"sne "
let uncon reg f (cond, src) =
match cond with
| UConGez ->
sprintf "bgez %a" reg src
| UConGtz ->
sprintf "bgtz %a" reg src
| UConLez ->
sprintf "blez %a" reg src
| UConLtz ->
sprintf "bltz %a" reg src
let bincon = function
| ConEq ->
"beq "
| ConNe ->
"bne "