]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ocaml/ocaml/contrib/asmcomp/sparc/arch.ml
Update
[l4.git] / l4 / pkg / ocaml / ocaml / contrib / asmcomp / sparc / arch.ml
1 (***********************************************************************)
2 (*                                                                     *)
3 (*                           Objective Caml                            *)
4 (*                                                                     *)
5 (*            Xavier Leroy, projet Cristal, INRIA Rocquencourt         *)
6 (*                                                                     *)
7 (*  Copyright 1996 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: arch.ml 5303 2002-11-29 15:03:08Z xleroy $ *)
14
15 (* Specific operations for the Sparc processor *)
16
17 open Misc
18 open Format
19
20 (* SPARC V8 adds multiply and divide.
21    SPARC V9 adds double precision float operations, conditional
22    move, and more instructions that are only useful in 64 bit mode.
23    Sun calls 32 bit V9 "V8+". *)
24 type arch_version = SPARC_V7 | SPARC_V8 | SPARC_V9
25
26 let arch_version = ref SPARC_V7
27
28 let command_line_options =
29   [ "-march=v8", Arg.Unit (fun () -> arch_version := SPARC_V8),
30         " Generate code for SPARC V8 processors";
31     "-march=v9", Arg.Unit (fun () -> arch_version := SPARC_V9),
32         " Generate code for SPARC V9 processors" ]
33
34 type specific_operation = unit          (* None worth mentioning *)
35
36 (* Addressing modes *)
37
38 type addressing_mode =
39     Ibased of string * int              (* symbol + displ *)
40   | Iindexed of int                     (* reg + displ *)
41
42 (* Sizes, endianness *)
43
44 let big_endian = true
45
46 let size_addr = 4
47 let size_int = 4
48 let size_float = 8
49
50 (* Operations on addressing modes *)
51
52 let identity_addressing = Iindexed 0
53
54 let offset_addressing addr delta =
55   match addr with
56     Ibased(s, n) -> Ibased(s, n + delta)
57   | Iindexed n -> Iindexed(n + delta)
58
59 let num_args_addressing = function
60     Ibased(s, n) -> 0
61   | Iindexed n -> 1
62
63 (* Printing operations and addressing modes *)
64
65 let print_addressing printreg addr ppf arg =
66   match addr with
67   | Ibased(s, n) ->
68       let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
69       fprintf ppf "\"%s\"%s" s idx
70   | Iindexed n ->
71       let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
72       fprintf ppf "%a%s" printreg arg.(0) idx
73
74 let print_specific_operation printreg op ppf arg =
75   Misc.fatal_error "Arch_sparc.print_specific_operation"