- | munch_exp d (T.BINOP(T.MUL, T.TEMP t, T.CONST n)) = let val s = Tm.size t in ([X.IMUL3((d,s), (X.TEMP t,s), n)], Tm.size t) end
- | munch_exp d (T.BINOP(T.MUL, T.CONST n, T.TEMP t)) = let val s = Tm.size t in ([X.IMUL3((d,s), (X.TEMP t,s), n)], Tm.size t) end
- | munch_exp d (T.BINOP(T.MUL, e1, T.CONST n)) = binophit_c d X.IMUL e1 n
- | munch_exp d (T.BINOP(T.MUL, T.CONST n, e1)) = binophit_c d X.IMUL e1 n
- | munch_exp d (T.BINOP(T.MUL, e1, e2)) = binophit d X.IMUL e1 e2
- | munch_exp d (T.BINOP(T.DIV, e1, e2)) =
- let
- val t1 = X.TEMP (Temp.new ("div") Tm.Long)
- val (i1, s1) = munch_exp t1 e1
- val (i2, s2) = munch_exp d e2
- in
- (i1 @ i2 @ [X.MOV ((X.REG X.EAX, s1), (t1, s1)), X.CLTD, X.IDIV (d, s2), X.MOV ((d, s2), (X.REG X.EAX, s2))], Tm.Long)
- end
- | munch_exp d (T.BINOP(T.MOD, e1, e2)) =
- let
- val t1 = X.TEMP (Temp.new ("div") Tm.Long)
- val (i1, s1) = munch_exp t1 e1
- val (i2, s2) = munch_exp d e2
- in
- (i1 @ i2 @ [X.MOV ((X.REG X.EAX, s1), (t1, s1)), X.CLTD, X.IDIV (d, s2), X.MOV ((d, s2), (X.REG X.EDX, s2))], Tm.Long)
- end
- | munch_exp d (T.BINOP(T.LSH, e1, T.CONST n)) = let val (i,s) = munch_exp d e1 in (i @ [X.SAL ((d,s), (X.CONST (n mod 0w32),s))],s) end
- | munch_exp d (T.BINOP(T.LSH, e1, T.TEMP t)) =
- let
- val (i,s) = munch_exp d e1
- in
- (i @ [X.MOV ((X.REG X.ECX, s), (X.TEMP t, s)), X.SAL ((d,s), (X.REG X.ECX, Tm.Byte))], s)
- end
- | munch_exp d (T.BINOP(T.LSH, e1, e2)) =
- let
- val t = X.TEMP (Temp.new ("lsh") Tm.Long)
- val (i1, s1) = munch_exp d e1
- val (i2, s2) = munch_exp t e2
- in
- (i1 @ i2 @ [X.MOV ((X.REG X.ECX, s1), (t, s1)), X.SAL ((d, s2), (X.REG X.ECX, Tm.Byte))], s2)
- end
- | munch_exp d (T.BINOP(T.RSH, e1, T.CONST n)) = let val (i,s) = munch_exp d e1 in (i @ [X.SAR ((d,s), (X.CONST (n mod 0w32),s))],s) end
- | munch_exp d (T.BINOP(T.RSH, e1, T.TEMP t)) =
- let
- val (i,s) = munch_exp d e1
- in
- (i @ [X.MOV ((X.REG X.ECX, s), (X.TEMP t, s)), X.SAR ((d,s), (X.REG X.ECX, Tm.Byte))], s)
- end
- | munch_exp d (T.BINOP(T.RSH, e1, e2)) =
- let
- val t = X.TEMP (Temp.new ("lsh") Tm.Long)
- val (i1, s1) = munch_exp d e1
- val (i2, s2) = munch_exp t e2
- in
- (i1 @ i2 @ [X.MOV ((X.REG X.ECX, s1), (t, s1)), X.SAR ((d, s2), (X.REG X.ECX, Tm.Byte))], s2)
- end
- | munch_exp d (T.BINOP(T.BITAND, T.CONST n, e1)) = binophit_c d X.AND e1 n
- | munch_exp d (T.BINOP(T.BITAND, e1, T.CONST n)) = binophit_c d X.AND e1 n
- | munch_exp d (T.BINOP(T.BITAND, T.TEMP t, e1)) = binophit_t d X.AND e1 t
- | munch_exp d (T.BINOP(T.BITAND, e1, T.TEMP t)) = binophit_t d X.AND e1 t