1998-10-09 07:43:30 -07:00
|
|
|
(***********************************************************************)
|
|
|
|
(* *)
|
|
|
|
(* Objective Caml *)
|
|
|
|
(* *)
|
|
|
|
(* Xavier Leroy, projet Cristal, INRIA Rocquencourt *)
|
|
|
|
(* *)
|
|
|
|
(* Copyright 1998 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. *)
|
1998-10-09 07:43:30 -07:00
|
|
|
(* *)
|
|
|
|
(***********************************************************************)
|
|
|
|
|
|
|
|
(* $Id$ *)
|
|
|
|
|
|
|
|
(* Specific operations for the ARM processor *)
|
|
|
|
|
|
|
|
open Misc
|
2000-04-21 01:13:22 -07:00
|
|
|
open Format
|
1998-10-09 07:43:30 -07:00
|
|
|
|
2002-11-29 07:03:37 -08:00
|
|
|
(* Machine-specific command-line options *)
|
|
|
|
|
|
|
|
let command_line_options = []
|
|
|
|
|
1998-10-09 07:43:30 -07:00
|
|
|
(* Addressing modes *)
|
|
|
|
|
|
|
|
type addressing_mode =
|
|
|
|
Iindexed of int (* reg + displ *)
|
|
|
|
|
|
|
|
(* We do not support the reg + shifted reg addressing mode, because
|
|
|
|
what we really need is reg + shifted reg + displ,
|
|
|
|
and this is decomposed in two instructions (reg + shifted reg -> tmp,
|
|
|
|
then addressing tmp + displ). *)
|
|
|
|
|
|
|
|
(* Specific operations *)
|
|
|
|
|
|
|
|
type specific_operation =
|
|
|
|
Ishiftarith of arith_operation * int
|
1998-10-14 10:08:57 -07:00
|
|
|
| Ishiftcheckbound of int
|
|
|
|
| Irevsubimm of int
|
1998-10-09 07:43:30 -07:00
|
|
|
|
|
|
|
and arith_operation =
|
|
|
|
Ishiftadd
|
|
|
|
| Ishiftsub
|
|
|
|
| Ishiftsubrev
|
|
|
|
|
|
|
|
(* Sizes, endianness *)
|
|
|
|
|
|
|
|
let big_endian = false
|
|
|
|
|
|
|
|
let size_addr = 4
|
|
|
|
let size_int = 4
|
|
|
|
let size_float = 8
|
|
|
|
|
|
|
|
(* Operations on addressing modes *)
|
|
|
|
|
|
|
|
let identity_addressing = Iindexed 0
|
|
|
|
|
|
|
|
let offset_addressing (Iindexed n) delta = Iindexed(n + delta)
|
|
|
|
|
|
|
|
let num_args_addressing (Iindexed n) = 1
|
|
|
|
|
|
|
|
(* Printing operations and addressing modes *)
|
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
let print_addressing printreg addr ppf arg =
|
1998-10-09 07:43:30 -07:00
|
|
|
match addr with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Iindexed n ->
|
|
|
|
printreg ppf arg.(0);
|
|
|
|
if n <> 0 then fprintf ppf " + %i" n
|
1998-10-09 07:43:30 -07:00
|
|
|
|
2000-04-21 01:13:22 -07:00
|
|
|
let print_specific_operation printreg op ppf arg =
|
1998-10-09 07:43:30 -07:00
|
|
|
match op with
|
2000-04-21 01:13:22 -07:00
|
|
|
| Ishiftarith(op, shift) ->
|
|
|
|
let op_name = function
|
|
|
|
| Ishiftadd -> "+"
|
|
|
|
| Ishiftsub -> "-"
|
|
|
|
| Ishiftsubrev -> "-rev" in
|
|
|
|
let shift_mark =
|
|
|
|
if shift >= 0
|
|
|
|
then sprintf "<< %i" shift
|
|
|
|
else sprintf ">> %i" (-shift) in
|
|
|
|
fprintf ppf "%a %s %a %s"
|
|
|
|
printreg arg.(0) (op_name op) printreg arg.(1) shift_mark
|
1998-10-14 10:08:57 -07:00
|
|
|
| Ishiftcheckbound n ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf "check %a >> %i > %a" printreg arg.(0) n printreg arg.(1)
|
1998-10-14 10:08:57 -07:00
|
|
|
| Irevsubimm n ->
|
2000-04-21 01:13:22 -07:00
|
|
|
fprintf ppf "%i %s %a" n "-" printreg arg.(0)
|