2016-02-18 07:11:59 -08:00
|
|
|
(**************************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* OCaml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Gallium, INRIA Rocquencourt *)
|
|
|
|
(* Bill O'Farrell, IBM *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 2015 Institut National de Recherche en Informatique et *)
|
|
|
|
(* en Automatique. *)
|
|
|
|
(* Copyright 2015 IBM (Bill O'Farrell with help from Tristan Amini). *)
|
|
|
|
(* *)
|
|
|
|
(* All rights reserved. This file is distributed under the terms of *)
|
|
|
|
(* the GNU Lesser General Public License version 2.1, with the *)
|
|
|
|
(* special exception on linking described in the file LICENSE. *)
|
|
|
|
(* *)
|
|
|
|
(**************************************************************************)
|
2015-10-28 07:41:31 -07:00
|
|
|
|
|
|
|
(* Specific operations for the Z processor *)
|
|
|
|
|
|
|
|
open Format
|
|
|
|
|
|
|
|
(* Machine-specific command-line options *)
|
|
|
|
|
|
|
|
let pic_code = ref true
|
|
|
|
|
|
|
|
let command_line_options =
|
|
|
|
[ "-fPIC", Arg.Set pic_code,
|
|
|
|
" Generate position-independent machine code (default)";
|
|
|
|
"-fno-PIC", Arg.Clear pic_code,
|
|
|
|
" Generate position-dependent machine code" ]
|
|
|
|
|
|
|
|
(* Specific operations *)
|
|
|
|
|
|
|
|
type specific_operation =
|
|
|
|
Imultaddf (* multiply and add *)
|
|
|
|
| Imultsubf (* multiply and subtract *)
|
|
|
|
|
|
|
|
(* Addressing modes *)
|
|
|
|
|
|
|
|
type addressing_mode =
|
|
|
|
| Iindexed of int (* reg + displ *)
|
2015-10-29 07:09:09 -07:00
|
|
|
| Iindexed2 of int (* reg + reg + displ *)
|
2015-10-28 07:41:31 -07:00
|
|
|
|
|
|
|
(* Sizes, endianness *)
|
|
|
|
|
|
|
|
let big_endian = true
|
|
|
|
|
|
|
|
let size_addr = 8
|
|
|
|
let size_int = size_addr
|
|
|
|
let size_float = 8
|
|
|
|
|
|
|
|
let allow_unaligned_access = false
|
|
|
|
|
|
|
|
(* Behavior of division *)
|
|
|
|
|
|
|
|
let division_crashes_on_overflow = true
|
|
|
|
|
|
|
|
(* Operations on addressing modes *)
|
|
|
|
|
|
|
|
let identity_addressing = Iindexed 0
|
|
|
|
|
|
|
|
let offset_addressing addr delta =
|
|
|
|
match addr with
|
|
|
|
| Iindexed n -> Iindexed(n + delta)
|
2015-10-29 07:09:09 -07:00
|
|
|
| Iindexed2 n -> Iindexed2(n + delta)
|
2015-10-28 07:41:31 -07:00
|
|
|
|
|
|
|
let num_args_addressing = function
|
2016-03-09 02:40:16 -08:00
|
|
|
| Iindexed _ -> 1
|
|
|
|
| Iindexed2 _ -> 2
|
2015-10-28 07:41:31 -07:00
|
|
|
|
|
|
|
(* Printing operations and addressing modes *)
|
|
|
|
|
|
|
|
let print_addressing printreg addr ppf arg =
|
|
|
|
match addr with
|
|
|
|
| Iindexed n ->
|
|
|
|
let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
|
|
|
|
fprintf ppf "%a%s" printreg arg.(0) idx
|
2015-10-29 07:09:09 -07:00
|
|
|
| Iindexed2 n ->
|
|
|
|
let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
|
|
|
|
fprintf ppf "%a + %a%s" printreg arg.(0) printreg arg.(1) idx
|
2015-10-28 07:41:31 -07:00
|
|
|
|
|
|
|
let print_specific_operation printreg op ppf arg =
|
|
|
|
match op with
|
|
|
|
| Imultaddf ->
|
|
|
|
fprintf ppf "%a *f %a +f %a"
|
|
|
|
printreg arg.(0) printreg arg.(1) printreg arg.(2)
|
|
|
|
| Imultsubf ->
|
|
|
|
fprintf ppf "%a *f %a -f %a"
|
|
|
|
printreg arg.(0) printreg arg.(1) printreg arg.(2)
|