From 5dcf421950d08eacb7fc70b348d4fc153447ce9e Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 10 Mar 2016 18:42:08 +0100 Subject: Cleanup of ARM dependedn code. Removed unused functions and avoid warnings. Bug 18394. --- arm/Asmexpand.ml | 3 +-- arm/TargetPrinter.ml | 71 ++++++---------------------------------------------- 2 files changed, 8 insertions(+), 66 deletions(-) (limited to 'arm') diff --git a/arm/Asmexpand.ml b/arm/Asmexpand.ml index 5415f78e..e2b0cb6c 100644 --- a/arm/Asmexpand.ml +++ b/arm/Asmexpand.ml @@ -16,7 +16,6 @@ open Asm open Asmexpandaux -open Asmgen open AST open Camlcoq open Integers @@ -382,7 +381,7 @@ let expand_instruction instr = else emit (Pldr (IR13,IR13,SOimm ofs)) | Pbuiltin (ef,args,res) -> begin match ef with - | EF_builtin (name,sg) -> + | EF_builtin (name,_) -> expand_builtin_inline (camlstring_of_coqstring name) args res | EF_vload chunk -> expand_builtin_vload chunk args res diff --git a/arm/TargetPrinter.ml b/arm/TargetPrinter.ml index 6536bc55..214e789c 100644 --- a/arm/TargetPrinter.ml +++ b/arm/TargetPrinter.ml @@ -13,11 +13,10 @@ (* Printing ARM assembly code in asm syntax *) open Printf -open Datatypes +open !Datatypes open Camlcoq open Sections open AST -open Memdata open Asm open PrintAsmaux open Fileinfo @@ -68,12 +67,6 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = | FR8 -> "d8" | FR9 -> "d9" | FR10 -> "d10" | FR11 -> "d11" | FR12 -> "d12" | FR13 -> "d13" | FR14 -> "d14" | FR15 -> "d15" - let single_float_reg_index = function - | FR0 -> 0 | FR1 -> 2 | FR2 -> 4 | FR3 -> 6 - | FR4 -> 8 | FR5 -> 10 | FR6 -> 12 | FR7 -> 14 - | FR8 -> 16 | FR9 -> 18 | FR10 -> 20 | FR11 -> 22 - | FR12 -> 24 | FR13 -> 26 | FR14 -> 28 | FR15 -> 30 - let single_float_reg_name = function | FR0 -> "s0" | FR1 -> "s2" | FR2 -> "s4" | FR3 -> "s6" | FR4 -> "s8" | FR5 -> "s10" | FR6 -> "s12" | FR7 -> "s14" @@ -130,7 +123,7 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = orr rsb sub (but not sp - imm) - On the other hand, "mov rd, rs" and "mov rd, #imm" have shorter + On the other hand, "mov rd, rs" and "mov rd, #imm" have shorter encodings if they do not have the "S" flag. Moreover, the "S" flag is not supported if rd or rs is sp. @@ -257,39 +250,6 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = ireg r lbl symbol_offset (id, ofs); 1 end -(* Emit instruction sequences that set or offset a register by a constant. *) -(* No S suffix because they are applied to SP most of the time. *) - - let movimm oc dst n = - match Asmgen.decompose_int n with - | [] -> assert false - | hd::tl as l -> - fprintf oc " mov %s, #%a\n" dst coqint hd; - List.iter - (fun n -> fprintf oc " orr %s, %s, #%a\n" dst dst coqint n) - tl; - List.length l - - let addimm oc dst src n = - match Asmgen.decompose_int n with - | [] -> assert false - | hd::tl as l -> - fprintf oc " add %s, %s, #%a\n" dst src coqint hd; - List.iter - (fun n -> fprintf oc " add %s, %s, #%a\n" dst dst coqint n) - tl; - List.length l - - let subimm oc dst src n = - match Asmgen.decompose_int n with - | [] -> assert false - | hd::tl as l -> - fprintf oc " sub %s, %s, #%a\n" dst src coqint hd; - List.iter - (fun n -> fprintf oc " sub %s, %s, #%a\n" dst dst coqint n) - tl; - List.length l - (* Recognition of float constants appropriate for VMOV. a normalized binary floating point encoding with 1 sign bit, 4 bits of fraction and a 3-bit exponent *) @@ -310,23 +270,6 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = let print_file_line oc file line = print_file_line oc comment file line - let print_location oc loc = - if loc <> Cutil.no_loc then print_file_line oc (fst loc) (snd loc) - -(* Auxiliary for 64-bit integer arithmetic built-ins. They expand to - two instructions, one computing the low 32 bits of the result, - followed by another computing the high 32 bits. In cases where - the first instruction would overwrite arguments to the second - instruction, we must go through IR14 to hold the low 32 bits of the result. - *) - - let print_int64_arith oc conflict rl fn = - if conflict then begin - let n = fn IR14 in - fprintf oc " mov %a, %a\n" ireg rl ireg IR14; - n + 1 - end else - fn rl (* Fixing up calling conventions *) @@ -747,9 +690,9 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = | Pfsts(r1, r2, n) -> fprintf oc " vstr %a, [%a, #%a]\n" freg_single r1 ireg r2 coqint n; 1 (* Pseudo-instructions *) - | Pallocframe(sz, ofs) -> + | Pallocframe _ -> assert false - | Pfreeframe(sz, ofs) -> + | Pfreeframe _ -> assert false | Plabel lbl -> fprintf oc "%a:\n" print_label lbl; 0 @@ -782,15 +725,15 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = end | Pbuiltin(ef, args, res) -> begin match ef with - | EF_annot(txt, targs) -> + | EF_annot(txt, _) -> fprintf oc "%s annotation: " comment; print_annot_text preg "sp" oc (camlstring_of_coqstring txt) args; 0 - | EF_debug(kind, txt, targs) -> + | EF_debug(kind, txt, _) -> print_debug_info comment print_file_line preg "sp" oc (P.to_int kind) (extern_atom txt) args; 0 - | EF_inline_asm(txt, sg, clob) -> + | EF_inline_asm(txt, sg, _) -> fprintf oc "%s begin inline assembly\n\t" comment; print_inline_asm preg oc (camlstring_of_coqstring txt) sg args res; fprintf oc "%s end inline assembly\n" comment; -- cgit From 7a8a7b225321b70d7a4a2ca5f6e1ba811bd378ab Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 10 Mar 2016 19:00:53 +0100 Subject: Clean up of ia32 target dependend code. Removed some unused functions and opens. Bug 18394 --- arm/AsmToJSON.ml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'arm') diff --git a/arm/AsmToJSON.ml b/arm/AsmToJSON.ml index bb0c0c04..c895bfb2 100644 --- a/arm/AsmToJSON.ml +++ b/arm/AsmToJSON.ml @@ -14,5 +14,4 @@ (* Dummy function *) -let p_program oc prog = - () +let p_program _ _ = () -- cgit From 272a5b812b72f4c3e409ccdbeaf3476d95c4b552 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 15 Mar 2016 15:07:47 +0100 Subject: Deactivate warning 27 and added back removed code. The code was mostly there for documentation effort. So warning 27 is deactivated again. Bug 18349 --- arm/AsmToJSON.ml | 3 ++- arm/Asmexpand.ml | 2 +- arm/TargetPrinter.ml | 10 +++++----- 3 files changed, 8 insertions(+), 7 deletions(-) (limited to 'arm') diff --git a/arm/AsmToJSON.ml b/arm/AsmToJSON.ml index c895bfb2..bb0c0c04 100644 --- a/arm/AsmToJSON.ml +++ b/arm/AsmToJSON.ml @@ -14,4 +14,5 @@ (* Dummy function *) -let p_program _ _ = () +let p_program oc prog = + () diff --git a/arm/Asmexpand.ml b/arm/Asmexpand.ml index e2b0cb6c..3283bb09 100644 --- a/arm/Asmexpand.ml +++ b/arm/Asmexpand.ml @@ -381,7 +381,7 @@ let expand_instruction instr = else emit (Pldr (IR13,IR13,SOimm ofs)) | Pbuiltin (ef,args,res) -> begin match ef with - | EF_builtin (name,_) -> + | EF_builtin (name,sg) -> expand_builtin_inline (camlstring_of_coqstring name) args res | EF_vload chunk -> expand_builtin_vload chunk args res diff --git a/arm/TargetPrinter.ml b/arm/TargetPrinter.ml index 214e789c..87f1057c 100644 --- a/arm/TargetPrinter.ml +++ b/arm/TargetPrinter.ml @@ -690,9 +690,9 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = | Pfsts(r1, r2, n) -> fprintf oc " vstr %a, [%a, #%a]\n" freg_single r1 ireg r2 coqint n; 1 (* Pseudo-instructions *) - | Pallocframe _ -> + | Pallocframe(sz, ofs) -> assert false - | Pfreeframe _ -> + | Pfreeframe(sz, ofs) -> assert false | Plabel lbl -> fprintf oc "%a:\n" print_label lbl; 0 @@ -725,15 +725,15 @@ module Target (Opt: PRINTER_OPTIONS) : TARGET = end | Pbuiltin(ef, args, res) -> begin match ef with - | EF_annot(txt, _) -> + | EF_annot(txt, targs) -> fprintf oc "%s annotation: " comment; print_annot_text preg "sp" oc (camlstring_of_coqstring txt) args; 0 - | EF_debug(kind, txt, _) -> + | EF_debug(kind, txt, targs) -> print_debug_info comment print_file_line preg "sp" oc (P.to_int kind) (extern_atom txt) args; 0 - | EF_inline_asm(txt, sg, _) -> + | EF_inline_asm(txt, sg, clob) -> fprintf oc "%s begin inline assembly\n\t" comment; print_inline_asm preg oc (camlstring_of_coqstring txt) sg args res; fprintf oc "%s end inline assembly\n" comment; -- cgit From 7035f06bf453bdf2f9f09fd8a392778e9ad3cd43 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 16 Mar 2016 11:06:54 +0100 Subject: Cleanup of AsmToJSON. Removed unused code, factored out common functions and added an interface file. Bug 18394 --- arm/AsmToJSON.mli | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 arm/AsmToJSON.mli (limited to 'arm') diff --git a/arm/AsmToJSON.mli b/arm/AsmToJSON.mli new file mode 100644 index 00000000..20bcba5e --- /dev/null +++ b/arm/AsmToJSON.mli @@ -0,0 +1,13 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *) +(* *) +(* AbsInt Angewandte Informatik GmbH. All rights reserved. This file *) +(* is distributed under the terms of the INRIA Non-Commercial *) +(* License Agreement. *) +(* *) +(* *********************************************************************) + +val p_program: out_channel -> (Asm.coq_function AST.fundef, 'a) AST.program -> unit -- cgit From 1e08d4adb241e076a96f9525fdb8359cf8845527 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 16 Mar 2016 13:51:33 +0100 Subject: Added interface for the Asmexpansion. Hide the reference used internally behind the interface and added some functions to access the needed values. Bug 18394 --- arm/Asmexpand.ml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'arm') diff --git a/arm/Asmexpand.ml b/arm/Asmexpand.ml index 3283bb09..e114ab28 100644 --- a/arm/Asmexpand.ml +++ b/arm/Asmexpand.ml @@ -267,11 +267,11 @@ let rec next_arg_location ir ofs = function else next_arg_location 4 (align ofs 8 + 8) l let expand_builtin_va_start r = - if not !current_function.fn_sig.sig_cc.cc_vararg then + if not (is_current_function_variadic ()) then invalid_arg "Fatal error: va_start used in non-vararg function"; let ofs = Int32.add - (next_arg_location 0 0 !current_function.fn_sig.sig_args) + (next_arg_location 0 0 (get_current_function_args ())) !PrintAsmaux.current_function_stacksize in expand_addimm IR14 IR13 (coqint_of_camlint ofs); emit (Pstr (IR14,r,SOimm _0)) @@ -363,7 +363,7 @@ let expand_instruction instr = match instr with | Pallocframe (sz, ofs) -> emit (Pmov (IR12,SOreg IR13)); - if (!current_function).fn_sig.sig_cc.cc_vararg then begin + if (is_current_function_variadic ()) then begin emit (Ppush [IR0;IR1;IR2;IR3]); emit (Pcfi_adjust _16); end; @@ -373,7 +373,7 @@ let expand_instruction instr = PrintAsmaux.current_function_stacksize := camlint_of_coqint sz | Pfreeframe (sz, ofs) -> let sz = - if (!current_function).fn_sig.sig_cc.cc_vararg + if (is_current_function_variadic ()) then coqint_of_camlint (Int32.add 16l (camlint_of_coqint sz)) else sz in if Asmgen.is_immed_arith sz -- cgit