1997-07-24 04:49:12 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1997 Institut National de Recherche en Informatique et *)
|
1999-11-17 10:59:06 -08:00
|
|
|
(* en Automatique. All rights reserved. This file is distributed *)
|
|
|
|
(* under the terms of the Q Public License version 1.0. *)
|
1997-07-24 04:49:12 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Instruction selection for the Mips processor *)
|
|
|
|
|
|
|
|
open Misc
|
|
|
|
open Cmm
|
|
|
|
open Reg
|
|
|
|
open Arch
|
|
|
|
open Mach
|
|
|
|
|
1998-06-25 06:14:07 -07:00
|
|
|
class selector = object
|
1997-07-24 04:49:12 -07:00
|
|
|
|
1998-06-24 12:22:26 -07:00
|
|
|
inherit Selectgen.selector_generic
|
1997-07-24 04:49:12 -07:00
|
|
|
|
|
|
|
method is_immediate (n : int) = true
|
|
|
|
|
|
|
|
method select_addressing = function
|
|
|
|
Cconst_symbol s ->
|
|
|
|
(Ibased(s, 0), Ctuple [])
|
|
|
|
| Cop(Cadda, [Cconst_symbol s; Cconst_int n]) ->
|
|
|
|
(Ibased(s, n), Ctuple [])
|
|
|
|
| Cop(Cadda, [arg; Cconst_int n]) ->
|
|
|
|
(Iindexed n, arg)
|
|
|
|
| Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int n])]) ->
|
|
|
|
(Iindexed n, Cop(Cadda, [arg1; arg2]))
|
|
|
|
| arg ->
|
|
|
|
(Iindexed 0, arg)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
1998-06-24 12:22:26 -07:00
|
|
|
let fundecl f = (new selector)#emit_fundecl f
|