1996-01-06 10:56:39 -08:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Objective Caml *)
|
1996-01-06 10:56:39 -08:00
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
1996-04-30 07:53:58 -07:00
|
|
|
(* Copyright 1996 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. *)
|
1996-01-06 10:56:39 -08:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Specific operations for the PowerPC processor *)
|
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
open Format
|
1996-01-06 10:56:39 -08:00
|
|
|
|
|
|
|
type specific_operation =
|
|
|
|
Imultaddf (* multiply and add *)
|
|
|
|
| Imultsubf (* multiply and subtract *)
|
|
|
|
|
|
|
|
(* Addressing modes *)
|
|
|
|
|
|
|
|
type addressing_mode =
|
1996-07-03 09:14:11 -07:00
|
|
|
Ibased of string * int (* symbol + displ *)
|
|
|
|
| Iindexed of int (* reg + displ *)
|
|
|
|
| Iindexed2 (* reg + reg *)
|
1996-01-06 10:56:39 -08:00
|
|
|
|
|
|
|
(* Sizes, endianness *)
|
|
|
|
|
|
|
|
let big_endian = true
|
|
|
|
|
|
|
|
let size_addr = 4
|
|
|
|
let size_int = 4
|
|
|
|
let size_float = 8
|
|
|
|
|
|
|
|
(* Operations on addressing modes *)
|
|
|
|
|
|
|
|
let identity_addressing = Iindexed 0
|
|
|
|
|
|
|
|
let offset_addressing addr delta =
|
|
|
|
match addr with
|
1996-07-03 09:14:11 -07:00
|
|
|
Ibased(s, n) -> Ibased(s, n + delta)
|
|
|
|
| Iindexed n -> Iindexed(n + delta)
|
|
|
|
| Iindexed2 -> Misc.fatal_error "Arch_power.offset_addressing"
|
1996-01-06 10:56:39 -08:00
|
|
|
|
|
|
|
let num_args_addressing = function
|
1996-07-03 09:14:11 -07:00
|
|
|
Ibased(s, n) -> 0
|
|
|
|
| Iindexed n -> 1
|
|
|
|
| Iindexed2 -> 2
|
1996-01-06 10:56:39 -08:00
|
|
|
|
|
|
|
(* Printing operations and addressing modes *)
|
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
let print_addressing printreg addr ppf arg =
|
1996-01-06 10:56:39 -08:00
|
|
|
match addr with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Ibased(s, n) ->
|
|
|
|
let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
|
|
|
|
fprintf ppf "\"%s\"%s" s idx
|
1996-07-03 09:14:11 -07:00
|
|
|
| Iindexed n ->
|
2000-04-21 01:13:22 -07:00
|
|
|
let idx = if n <> 0 then Printf.sprintf " + %i" n else "" in
|
|
|
|
fprintf ppf "%a%s" printreg arg.(0) idx
|
1996-07-03 09:14:11 -07:00
|
|
|
| Iindexed2 ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf "%a + %a" printreg arg.(0) printreg arg.(1)
|
1996-01-06 10:56:39 -08:00
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
let print_specific_operation printreg op ppf arg =
|
1996-01-06 10:56:39 -08:00
|
|
|
match op with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Imultaddf ->
|
|
|
|
fprintf ppf "%a *f %a +f %a"
|
|
|
|
printreg arg.(0) printreg arg.(1) printreg arg.(2)
|
1996-01-06 10:56:39 -08:00
|
|
|
| Imultsubf ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf "%a *f %a -f %a"
|
|
|
|
printreg arg.(0) printreg arg.(1) printreg arg.(2)
|
1997-07-24 04:49:12 -07:00
|
|
|
|
|
|
|
(* Distinguish between the PowerPC and the Power/RS6000 submodels *)
|
|
|
|
|
|
|
|
let powerpc =
|
|
|
|
match Config.model with
|
2000-04-21 01:13:22 -07:00
|
|
|
| "ppc" -> true
|
1997-07-24 04:49:12 -07:00
|
|
|
| "rs6000" -> false
|
|
|
|
| _ -> Misc.fatal_error "wrong $(MODEL)"
|
|
|
|
|
|
|
|
(* Distinguish between the PowerOpen (AIX, MacOS) TOC-based,
|
1998-03-13 05:57:35 -08:00
|
|
|
relative-addressing model and the SVR4 (Solaris, MkLinux, Rhapsody)
|
1997-07-24 04:49:12 -07:00
|
|
|
absolute-addressing model. *)
|
|
|
|
|
|
|
|
let toc =
|
|
|
|
match Config.system with
|
2000-04-21 01:13:22 -07:00
|
|
|
| "aix" -> true
|
1997-07-24 04:49:12 -07:00
|
|
|
| "elf" -> false
|
1998-03-13 05:57:35 -08:00
|
|
|
| "rhapsody" -> false
|
1997-07-24 04:49:12 -07:00
|
|
|
| _ -> Misc.fatal_error "wrong $(SYSTEM)"
|
|
|
|
|