1 (* Pasted from Pottier's PP compiler *)
6 (* Some of the instructions that we emit are in fact pseudo-instructions. *)
8 (* We use [addu], [addiu], and [subu] instead of [add], [addi], and
9 [sub]. The only difference is that the former never generate
10 overflow exceptions. This is what we desire, since the semantics
11 of Pseudo-Pascal says nothing about overflow exceptions. Overflow
14 let unop reg f (op, dst, src) =
17 sprintf "move %a, %a" reg dst reg src (* pseudo-instruction *)
19 sprintf "addi %a, %a, %ld" reg dst reg src i
21 sprintf "slti %a, %a, %ld" reg dst reg src i
23 sprintf "sltiu %a, %a, %ld" reg dst reg src i
25 sprintf "andi %a, %a, %ld" reg dst reg src i
27 sprintf "ori %a, %a, %ld" reg dst reg src i
29 sprintf "xori %a, %a, %ld" reg dst reg src i
31 sprintf "neg %a, %a" reg dst reg src
33 sprintf "not %a, %a" reg dst reg src
43 "div " (* pseudo-instruction *)
45 "divu " (* pseudo-instruction *)
47 "remu " (* pseudo-instruction *)
53 "sle " (* pseudo-instruction *)
55 "sleu " (* pseudo-instruction *)
57 "sgt " (* pseudo-instruction *)
59 "sgtu " (* pseudo-instruction *)
61 "sge " (* pseudo-instruction *)
63 "sgeu " (* pseudo-instruction *)
65 "seq " (* pseudo-instruction *)
67 "sne " (* pseudo-instruction *)
81 let uncon reg f (cond, src) =
84 sprintf "bgez %a" reg src
86 sprintf "bgtz %a" reg src
88 sprintf "blez %a" reg src
90 sprintf "bltz %a" reg src