1(**************************************************************************) 2(* *) 3(* OCaml *) 4(* *) 5(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *) 6(* *) 7(* Copyright 1996 Institut National de Recherche en Informatique et *) 8(* en Automatique. *) 9(* *) 10(* All rights reserved. This file is distributed under the terms of *) 11(* the GNU Lesser General Public License version 2.1, with the *) 12(* special exception on linking described in the file LICENSE. *) 13(* *) 14(**************************************************************************) 15 16(* Reloading for the Z Processor *) 17 18open Arch 19open Mach 20 21class reload = object (self) 22 23inherit Reloadgen.reload_generic as super 24 25(* For 2-address instructions, reloading must make sure that the 26 temporary result register is the same as the appropriate 27 argument register. *) 28 29method! reload_operation op arg res = 30 match op with 31 (* Two-address binary operations: arg.(0) and res.(0) must be the same *) 32 | Iintop(Iadd|Isub|Imul|Iand|Ior|Ixor) | Iaddf|Isubf|Imulf|Idivf -> 33 let res = self#makereg res.(0) in 34 ([|res; self#makereg arg.(1)|], [|res|]) 35 (* Three-address ternary operations: arg.(2) and res.(0) must be the same *) 36 | Ispecific(Imultaddf|Imultsubf) -> 37 let res = self#makereg res.(0) in 38 ([|self#makereg arg.(0); self#makereg arg.(1); res|], [|res|]) 39 (* One-address unary operations: arg.(0) and res.(0) must be the same *) 40 | Iintop_imm((Imul|Iand|Ior|Ixor), _) -> 41 let res = self#makereg res.(0) in 42 ([|res|], [|res|]) 43 (* Other instructions are regular *) 44 | _ -> 45 super#reload_operation op arg res 46 47end 48 49let fundecl f = 50 (new reload)#fundecl f 51