aboutsummaryrefslogtreecommitdiffstats
path: root/powerpc/Asmexpand.ml
diff options
context:
space:
mode:
authorBernhard Schommer <bernhardschommer@gmail.com>2015-06-10 10:07:02 +0200
committerBernhard Schommer <bernhardschommer@gmail.com>2015-06-10 10:07:02 +0200
commit929c0ea6f02713f59c0862fa0c3a53e0cb89c334 (patch)
tree168677dd7c66fc02e871d4d11d4519e32c5f07ed /powerpc/Asmexpand.ml
parent744dc278d24b15a72ef471fc25c1c8a8df62cc4e (diff)
downloadcompcert-kvx-929c0ea6f02713f59c0862fa0c3a53e0cb89c334.tar.gz
compcert-kvx-929c0ea6f02713f59c0862fa0c3a53e0cb89c334.zip
Moved the printing of the builtin functions etc. into Asmexpand for ARM in the same way as it is done for PPC.
Diffstat (limited to 'powerpc/Asmexpand.ml')
-rw-r--r--powerpc/Asmexpand.ml55
1 files changed, 11 insertions, 44 deletions
diff --git a/powerpc/Asmexpand.ml b/powerpc/Asmexpand.ml
index aec8f66e..7f413661 100644
--- a/powerpc/Asmexpand.ml
+++ b/powerpc/Asmexpand.ml
@@ -19,48 +19,10 @@ open Integers
open AST
open Memdata
open Asm
+open Asmexpandaux
-(* Buffering the expanded code *)
-let current_code = ref ([]: instruction list)
-
-let emit i = current_code := i :: !current_code
-
-let emit_loadimm r n =
- List.iter emit (Asmgen.loadimm r n [])
-
-let emit_addimm rd rs n =
- List.iter emit (Asmgen.addimm rd rs n [])
-
-let get_code () =
- let c = List.rev !current_code in current_code := []; c
-
-(* Generation of fresh labels *)
-
-let dummy_function = { fn_code = []; fn_sig = signature_main }
-let current_function = ref dummy_function
-let next_label = ref (None : label option)
-
-let new_label () =
- let lbl =
- match !next_label with
- | Some l -> l
- | None ->
- (* on-demand computation of the next available label *)
- List.fold_left
- (fun next instr ->
- match instr with
- | Plabel l -> if P.lt l next then next else P.succ l
- | _ -> next)
- P.one (!current_function).fn_code
- in
- next_label := Some (P.succ lbl);
- lbl
-
-let set_current_function f =
- current_function := f; next_label := None
-
-(* Useful constants *)
+(* Useful constants and helper functions *)
let _0 = Integers.Int.zero
let _1 = Integers.Int.one
@@ -71,6 +33,14 @@ let _8 = coqint_of_camlint 8l
let _m4 = coqint_of_camlint (-4l)
let _m8 = coqint_of_camlint (-8l)
+let emit_loadimm r n =
+ List.iter emit (Asmgen.loadimm r n [])
+
+let emit_addimm rd rs n =
+ List.iter emit (Asmgen.addimm rd rs n [])
+
+
+
(* Handling of annotations *)
let expand_annot_val txt targ args res =
@@ -533,11 +503,8 @@ let expand_instruction instr =
let expand_function fn =
set_current_function fn;
- current_code := [];
List.iter expand_instruction fn.fn_code;
- let c = get_code() in
- set_current_function dummy_function;
- { fn with fn_code = c }
+ get_current_function ()
let expand_fundef = function
| Internal f -> Internal (expand_function f)