aboutsummaryrefslogtreecommitdiffstats
path: root/arm/Machregsaux.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2015-05-09 09:00:51 +0200
committerXavier Leroy <xavier.leroy@inria.fr>2015-05-09 09:00:51 +0200
commita6b6bf31121d975c915c01f501618d97df7879fb (patch)
tree061cf73e547622695621fc05ce692c029991c9e0 /arm/Machregsaux.ml
parent56bac3dc3d45c219db5d9c7b6a97794c00f8115e (diff)
downloadcompcert-kvx-a6b6bf31121d975c915c01f501618d97df7879fb.tar.gz
compcert-kvx-a6b6bf31121d975c915c01f501618d97df7879fb.zip
Extended inline asm: revised treatment of clobbered registers.
- Treat clobbered registers as being destroyed by EF_inline_asm builtins (which is the truth, semantically). - To enable the above, represent clobbers as Coq strings rather than idents and move register_by_name from Machregsaux.ml to Machregs.v. - Side benefit: more efficient implementation of Machregsaux.name_of_register. -# Please enter the commit message for your changes. Lines starting
Diffstat (limited to 'arm/Machregsaux.ml')
-rw-r--r--arm/Machregsaux.ml35
1 files changed, 9 insertions, 26 deletions
diff --git a/arm/Machregsaux.ml b/arm/Machregsaux.ml
index 44e6b192..d59ec8b8 100644
--- a/arm/Machregsaux.ml
+++ b/arm/Machregsaux.ml
@@ -12,41 +12,24 @@
(** Auxiliary functions on machine registers *)
+open Camlcoq
open Machregs
-let register_names = [
- ("R0", R0); ("R1", R1); ("R2", R2); ("R3", R3);
- ("R4", R4); ("R5", R5); ("R6", R6); ("R7", R7);
- ("R8", R8); ("R9", R9); ("R10", R10); ("R11", R11);
- ("R12", R12);
- ("F0", F0); ("F1", F1); ("F2", F2); ("F3", F3);
- ("F4", F4); ("F5", F5); ("F6", F6); ("F7", F7);
- ("F8", F8); ("F9", F9); ("F10", F10); ("F11", F11);
- ("F12", F12);("F13", F13);("F14", F14); ("F15", F15)
-]
+let register_names : (mreg, string) Hashtbl.t = Hashtbl.create 31
+
+let _ =
+ List.iter
+ (fun (s, r) -> Hashtbl.add register_names r (camlstring_of_coqstring s))
+ Machregs.register_names
let scratch_register_names = [ "R14" ]
let name_of_register r =
- let rec rev_assoc = function
- | [] -> None
- | (a, b) :: rem -> if b = r then Some a else rev_assoc rem
- in rev_assoc register_names
+ try Some (Hashtbl.find register_names r) with Not_found -> None
let register_by_name s =
- try
- Some(List.assoc (String.uppercase s) register_names)
- with Not_found ->
- None
+ Machregs.register_by_name (coqstring_of_camlstring (String.uppercase s))
let can_reserve_register r =
List.mem r Conventions1.int_callee_save_regs
|| List.mem r Conventions1.float_callee_save_regs
-
-let mregs_of_clobber idl =
- List.fold_left
- (fun l c ->
- match register_by_name (Camlcoq.extern_atom c) with
- | Some r -> r :: l
- | None -> l)
- [] idl