]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/asmcomp/mips/selection.ml
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / asmcomp / mips / selection.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                           Objective Caml                            *)
4 (*                                                                     *)
5 (*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
6 (*                                                                     *)
7 (*  Copyright 1997 Institut National de Recherche en Informatique et   *)
8 (*  en Automatique.  All rights reserved.  This file is distributed    *)
9 (*  under the terms of the Q Public License version 1.0.               *)
10 (*                                                                     *)
11 (***********************************************************************)
12
13 (* $Id: selection.ml 2553 1999-11-17 18:59:06Z xleroy $ *)
14
15 (* Instruction selection for the Mips processor *)
16
17 open Misc
18 open Cmm
19 open Reg
20 open Arch
21 open Mach
22
23 class selector = object
24
25 inherit Selectgen.selector_generic
26
27 method is_immediate (n : int) = true
28
29 method select_addressing = function
30     Cconst_symbol s ->
31       (Ibased(s, 0), Ctuple [])
32   | Cop(Cadda, [Cconst_symbol s; Cconst_int n]) ->
33       (Ibased(s, n), Ctuple [])
34   | Cop(Cadda, [arg; Cconst_int n]) ->
35       (Iindexed n, arg)
36   | Cop(Cadda, [arg1; Cop(Caddi, [arg2; Cconst_int n])]) ->
37       (Iindexed n, Cop(Cadda, [arg1; arg2]))
38   | arg ->
39       (Iindexed 0, arg)
40
41 end
42
43 let fundecl f = (new selector)#emit_fundecl f