3 * Author: Kaustuv Chaudhuri <kaustuv+@cs.cmu.edu>
4 * Modified: Alex Vaynberg <alv@andrew.cmu.edu>
5 * Modified: Frank Pfenning <fp@cs.cmu.edu>
11 datatype binop = ADD | SUB | MUL | DIV | MOD | LSH | RSH | LOGOR | LOGAND | BITOR | BITAND | BITXOR | NEQ | EQ | LT | GT | LE | GE
12 datatype unop = NEG | BITNOT | BANG
17 | BINOP of binop * exp * exp
22 | LABEL of Label.label
23 | JUMPIFN of exp * Label.label
26 type program = stm list
30 val pp_exp : exp -> string
31 val pp_stm : stm -> string
32 val pp_program : program -> string
36 structure Tree :> TREE =
39 datatype binop = ADD | SUB | MUL | DIV | MOD | LSH | RSH | LOGOR | LOGAND | BITOR | BITAND | BITXOR | NEQ | EQ | LT | GT | LE | GE
40 datatype unop = NEG | BITNOT | BANG
45 | BINOP of binop * exp * exp
50 | LABEL of Label.label
51 | JUMPIFN of exp * Label.label
54 type program = stm list
59 fun pp_binop ADD = "+"
66 | pp_binop LOGOR = "||"
67 | pp_binop LOGAND = "&&"
68 | pp_binop BITOR = "|"
69 | pp_binop BITAND = "&"
70 | pp_binop BITXOR = "^"
79 | pp_unop BITNOT = "~"
82 fun pp_exp (CONST(x)) = Word32Signed.toString x
83 | pp_exp (TEMP(t)) = Temp.name t
84 | pp_exp (BINOP (binop, e1, e2)) =
85 "(" ^ pp_exp e1 ^ " " ^ pp_binop binop ^ " " ^ pp_exp e2 ^ ")"
86 | pp_exp (UNOP (unop, e1)) =
87 pp_unop unop ^ "(" ^ pp_exp e1 ^ ")"
89 fun pp_stm (MOVE (e1,e2)) =
90 pp_exp e1 ^ " <-- " ^ pp_exp e2
97 | pp_stm (JUMPIFN (e, l)) =
98 "jump "^Label.name l^" if! "^pp_exp e
100 fun pp_program (nil) = ""
101 | pp_program (stm::stms) = pp_stm stm ^ "\n" ^ pp_program stms