summaryrefslogtreecommitdiff
path: root/ia32/Unusedglob1.ml
blob: eb0298bb994a4e3ec1a373c84ca0dd8ca3417b40 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
(* *********************************************************************)
(*                                                                     *)
(*              The Compcert verified compiler                         *)
(*                                                                     *)
(*          Xavier Leroy, INRIA Paris-Rocquencourt                     *)
(*                                                                     *)
(*  Copyright Institut National de Recherche en Informatique et en     *)
(*  Automatique.  All rights reserved.  This file is distributed       *)
(*  under the terms of the INRIA Non-Commercial License Agreement.     *)
(*                                                                     *)
(* *********************************************************************)

(* Identifiers referenced from an IA32 Asm instruction *)

open Datatypes
open AST
open Asm

let referenced_addr (Addrmode(base, ofs, const)) =
  match const with
  | Coq_inl n -> []
  | Coq_inr(s, ofs) -> [s]

let referenced_builtin ef =
  match ef with
  | EF_vload_global(chunk, id, ofs) -> [id]
  | EF_vstore_global(chunk, id, ofs) -> [id]
  | _ -> []

let referenced_instr = function
  | Pmov_rm (_, a) | Pmov_mr (a, _)
  | Pmov_rm_a (_, a) | Pmov_mr_a (a, _)
  | Pmovsd_fm (_, a) | Pmovsd_mf(a, _)
  | Pmovss_fm (_, a) | Pmovss_mf(a, _)
  | Pfldl_m a | Pflds_m a | Pfstpl_m a | Pfstps_m a
  | Pmovb_mr (a, _) | Pmovw_mr (a, _)
  | Pmovzb_rm (_, a) | Pmovsb_rm (_, a)
  | Pmovzw_rm (_, a) | Pmovsw_rm (_, a)
  | Plea (_, a) -> referenced_addr a
  | Pjmp_s(s, _) -> [s]
  | Pcall_s(s, _) -> [s]
  | Pbuiltin(ef, args, res) -> referenced_builtin ef
  | _ -> []

let code_of_function f = f.fn_code