From 7cbc68a8056ace840ef187156461a361554d5fef Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 3 Feb 2015 18:43:36 +0100 Subject: Started moving common backend functions into one file. --- backend/PrintAsmaux.ml | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 backend/PrintAsmaux.ml (limited to 'backend') diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml new file mode 100644 index 00000000..3493e912 --- /dev/null +++ b/backend/PrintAsmaux.ml @@ -0,0 +1,84 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Xavier Leroy, INRIA Paris-Rocquencourt *) +(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *) +(* *) +(* 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. *) +(* *) +(* *********************************************************************) + +open AST +open Asm +open Camlcoq +open Datatypes +open Printf +open Sections + +(** Auxiliary functions for printing of asm *) + +module type TARGET = + sig + val print_prologue: out_channel -> unit + val print_epilogue: out_channel -> unit + val print_align: out_channel -> int -> unit + val print_comm_symb: out_channel -> P.t -> int -> unit + val print_var_info: out_channel -> P.t -> unit + val print_fun_info: out_channel -> P.t -> unit + val print_init: out_channel -> init_data -> unit + val reset_constants: unit -> unit + val get_section_names: unit -> section_name * section_name * section_name + val print_file_line: out_channel -> string -> int -> unit + val print_optional_fun_info: out_channel -> unit + val cfi_startproc: out_channel -> unit + val print_instructions: out_channel -> code -> unit + val cfi_endproc: out_channel -> unit + val emit_constants: out_channel -> section_name -> unit + val print_jumptable: out_channel -> section_name -> unit + val section: out_channel -> section_name -> unit + end + +(* On-the-fly label renaming *) + +let next_label = ref 100 + +let new_label () = + let lbl = !next_label in incr next_label; lbl + +let current_function_labels = (Hashtbl.create 39 : (label, int) Hashtbl.t) + +let transl_label lbl = + try + Hashtbl.find current_function_labels lbl + with Not_found -> + let lbl' = new_label() in + Hashtbl.add current_function_labels lbl lbl'; + lbl' + + +(* List of literals and jumptables used in the code *) + +let float64_literals : (int * int64) list ref = ref [] +let float32_literals : (int * int32) list ref = ref [] +let jumptables : (int * label list) list ref = ref [] + +(* Variables used for the handling of varargs *) + +let current_function_stacksize = ref 0l +let current_function_sig = + ref { sig_args = []; sig_res = None; sig_cc = cc_default } + +(* Functions for printing of symbol names *) +let symbol oc symb = + fprintf oc "%s" (extern_atom symb) + +let symbol_offset oc (symb, ofs) = + symbol oc symb; + let ofs = camlint_of_coqint ofs in + if ofs <> 0l then fprintf oc " + %ld" ofs + +(* The comment deliminiter *) +let comment = "#" -- cgit From f6b9815685741a76fee78dfb58e8fb8dd70db8f0 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 4 Feb 2015 14:26:37 +0100 Subject: Moved more common functions into a seperate file. --- backend/PrintAsmaux.ml | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 46 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 3493e912..75ecfa40 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -26,8 +26,8 @@ module type TARGET = val print_epilogue: out_channel -> unit val print_align: out_channel -> int -> unit val print_comm_symb: out_channel -> P.t -> int -> unit - val print_var_info: out_channel -> P.t -> unit - val print_fun_info: out_channel -> P.t -> unit + val print_var_info: bool + val print_fun_info: bool val print_init: out_channel -> init_data -> unit val reset_constants: unit -> unit val get_section_names: unit -> section_name * section_name * section_name @@ -58,6 +58,8 @@ let transl_label lbl = Hashtbl.add current_function_labels lbl lbl'; lbl' +let label oc lbl = + fprintf oc ".L%d" lbl (* List of literals and jumptables used in the code *) @@ -82,3 +84,45 @@ let symbol_offset oc (symb, ofs) = (* The comment deliminiter *) let comment = "#" + +(* Functions for fun and var info *) +let print_fun_info oc name = + fprintf oc " .type %a, @function\n" symbol name; + fprintf oc " .size %a, . - %a\n" symbol name symbol name + +let print_var_info oc name = + fprintf oc " .type %a, @object\n" symbol name; + fprintf oc " .size %a, . - %a\n" symbol name symbol name + +(* Emit .cfi directives *) +let cfi_startproc = + if Configuration.asm_supports_cfi then + (fun oc -> fprintf oc " .cfi_startproc\n") + else + (fun _ -> ()) + +let cfi_endproc = + if Configuration.asm_supports_cfi then + (fun oc -> fprintf oc " .cfi_endproc\n") + else + (fun _ -> ()) + + +let cfi_adjust = + if Configuration.asm_supports_cfi then + (fun oc delta -> fprintf oc " .cfi_adjust_cfa_offset %ld\n" delta) + else + (fun _ _ -> ()) + +let cfi_rel_offset = + if Configuration.asm_supports_cfi then + (fun oc reg ofs -> fprintf oc " .cfi_rel_offset %s, %ld\n" reg ofs) + else + (fun _ _ _ -> ()) + +(* For handling of annotations *) +let re_file_line = Str.regexp "#line:\\(.*\\):\\([1-9][0-9]*\\)$" + +(* Basic printing functions *) +let coqint oc n = + fprintf oc "%ld" (camlint_of_coqint n) -- cgit From 20ee821830467d091984ccf9ed646de7975866a7 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 5 Feb 2015 13:02:29 +0100 Subject: Changed the ASM printer of the powerpc to the generalized backend. --- backend/PrintAsm.ml | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ backend/PrintAsm.mli | 16 ++++++++ backend/PrintAsmaux.ml | 6 ++- 3 files changed, 119 insertions(+), 2 deletions(-) create mode 100644 backend/PrintAsm.ml create mode 100644 backend/PrintAsm.mli (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml new file mode 100644 index 00000000..aa317a09 --- /dev/null +++ b/backend/PrintAsm.ml @@ -0,0 +1,99 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Xavier Leroy, INRIA Paris-Rocquencourt *) +(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *) +(* *) +(* 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. *) +(* *) +(* *********************************************************************) + +open AST +open Asm +open Camlcoq +open Datatypes +open PrintAsmaux +open Printf +open Sections +open TargetPrinter + +module Target = (val (sel_target ()):TARGET) + +let print_location oc loc = + if loc <> Cutil.no_loc then Target.print_file_line oc (fst loc) (snd loc) + +let print_function oc name fn = + Hashtbl.clear current_function_labels; + Target.reset_constants (); + let (text, lit, jmptbl) = Target.get_section_names name in + Target.section oc text; + let alignment = + match !Clflags.option_falignfunctions with Some n -> n | None -> 4 in + Target.print_align oc alignment; + if not (C2C.atom_is_static name) then + fprintf oc " .globl %a\n" symbol name; + Target.print_optional_fun_info oc; + fprintf oc "%a:\n" symbol name; + print_location oc (C2C.atom_location name); + Target.cfi_startproc oc; + Target.print_instructions oc fn.fn_code; + Target.cfi_endproc oc; + if Target.print_fun_info then + print_fun_info oc name; + Target.emit_constants oc lit; + Target.print_jumptable oc jmptbl + + +let print_init_data oc name id = + if Str.string_match PrintCsyntax.re_string_literal (extern_atom name) 0 + && List.for_all (function Init_int8 _ -> true | _ -> false) id + then + fprintf oc " .ascii \"%s\"\n" (PrintCsyntax.string_of_init id) + else + List.iter (Target.print_init oc) id + +let print_var oc name v = + match v.gvar_init with + | [] -> () + | _ -> + let sec = + match C2C.atom_sections name with + | [s] -> s + | _ -> Section_data true + and align = + match C2C.atom_alignof name with + | Some a -> a + | None -> 8 in (* 8-alignment is a safe default *) + let name_sec = Target.name_of_section sec in + if name_sec <> "COMM" then begin + fprintf oc " %s\n" name_sec; + Target.print_align oc align; + if not (C2C.atom_is_static name) then + fprintf oc " .global %a\n" symbol name; + fprintf oc "%a:\n" symbol name; + print_init_data oc name v.gvar_init; + if Target.print_var_info then + print_var_info oc name; + end else + let sz = + match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in + Target.print_comm_symb oc sz name align + + +let print_globdef oc (name,gdef) = + match gdef with + | Gfun (Internal code) -> print_function oc name code + | Gfun (External ef) -> () + | Gvar v -> print_var oc name v + + +let print_program oc p = + PrintAnnot.reset_filenames (); + PrintAnnot.print_version_and_options oc Target.comment; + Target.print_prologue oc; + List.iter (print_globdef oc) p.prog_defs; + Target.print_epilogue oc; + PrintAnnot.close_filenames () diff --git a/backend/PrintAsm.mli b/backend/PrintAsm.mli new file mode 100644 index 00000000..eb63f1be --- /dev/null +++ b/backend/PrintAsm.mli @@ -0,0 +1,16 @@ +(* *********************************************************************) +(* *) +(* The Compcert verified compiler *) +(* *) +(* Xavier Leroy, INRIA Paris-Rocquencourt *) +(* Bernhard Schommer, AbsInt Angewandte Informatik GmbH *) +(* *) +(* 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. *) +(* *) +(* *********************************************************************) + +open PrintAsmaux + +val print_program: out_channel -> Asm.program -> unit diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 75ecfa40..381ef5df 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -25,12 +25,12 @@ module type TARGET = val print_prologue: out_channel -> unit val print_epilogue: out_channel -> unit val print_align: out_channel -> int -> unit - val print_comm_symb: out_channel -> P.t -> int -> unit + val print_comm_symb: out_channel -> Z.t -> P.t -> int -> unit val print_var_info: bool val print_fun_info: bool val print_init: out_channel -> init_data -> unit val reset_constants: unit -> unit - val get_section_names: unit -> section_name * section_name * section_name + val get_section_names: P.t -> section_name * section_name * section_name val print_file_line: out_channel -> string -> int -> unit val print_optional_fun_info: out_channel -> unit val cfi_startproc: out_channel -> unit @@ -39,6 +39,8 @@ module type TARGET = val emit_constants: out_channel -> section_name -> unit val print_jumptable: out_channel -> section_name -> unit val section: out_channel -> section_name -> unit + val name_of_section: section_name -> string + val comment: string end (* On-the-fly label renaming *) -- cgit From 47a77e398dd3815a20622934cdeeb4f0e076f42b Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Fri, 6 Feb 2015 13:19:59 +0100 Subject: Changed the ia32 backend to the new Printer. --- backend/PrintAsmaux.ml | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'backend') diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 381ef5df..8812d320 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -69,6 +69,11 @@ let float64_literals : (int * int64) list ref = ref [] let float32_literals : (int * int32) list ref = ref [] let jumptables : (int * label list) list ref = ref [] +let reset_constants () = + float64_literals := []; + float32_literals := []; + jumptables := [] + (* Variables used for the handling of varargs *) let current_function_stacksize = ref 0l -- cgit From a3c0094508f9f4985de4509380dada5f5c85e115 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Mon, 9 Feb 2015 14:54:42 +0100 Subject: Changed arm backend to the common backend printer. --- backend/PrintAsm.ml | 2 +- backend/PrintAsmaux.ml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index aa317a09..0860c1d4 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -39,7 +39,7 @@ let print_function oc name fn = fprintf oc "%a:\n" symbol name; print_location oc (C2C.atom_location name); Target.cfi_startproc oc; - Target.print_instructions oc fn.fn_code; + Target.print_instructions oc fn; Target.cfi_endproc oc; if Target.print_fun_info then print_fun_info oc name; diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 8812d320..3f619d84 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -34,7 +34,7 @@ module type TARGET = val print_file_line: out_channel -> string -> int -> unit val print_optional_fun_info: out_channel -> unit val cfi_startproc: out_channel -> unit - val print_instructions: out_channel -> code -> unit + val print_instructions: out_channel -> coq_function -> unit val cfi_endproc: out_channel -> unit val emit_constants: out_channel -> section_name -> unit val print_jumptable: out_channel -> section_name -> unit -- cgit From 8677f50de8515bd83221e6a3d79b0f3d6dae4cbf Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 18 Feb 2015 12:52:54 +0100 Subject: Removed some style issues. --- backend/PrintAsm.ml | 136 +++++++++++++++++++++++++++------------------------- 1 file changed, 71 insertions(+), 65 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index 0860c1d4..532de044 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -22,78 +22,84 @@ open TargetPrinter module Target = (val (sel_target ()):TARGET) -let print_location oc loc = - if loc <> Cutil.no_loc then Target.print_file_line oc (fst loc) (snd loc) - -let print_function oc name fn = - Hashtbl.clear current_function_labels; - Target.reset_constants (); - let (text, lit, jmptbl) = Target.get_section_names name in - Target.section oc text; - let alignment = - match !Clflags.option_falignfunctions with Some n -> n | None -> 4 in - Target.print_align oc alignment; - if not (C2C.atom_is_static name) then - fprintf oc " .globl %a\n" symbol name; - Target.print_optional_fun_info oc; - fprintf oc "%a:\n" symbol name; - print_location oc (C2C.atom_location name); - Target.cfi_startproc oc; - Target.print_instructions oc fn; - Target.cfi_endproc oc; - if Target.print_fun_info then - print_fun_info oc name; - Target.emit_constants oc lit; - Target.print_jumptable oc jmptbl - +module Printer(Target:TARGET) = + struct -let print_init_data oc name id = - if Str.string_match PrintCsyntax.re_string_literal (extern_atom name) 0 - && List.for_all (function Init_int8 _ -> true | _ -> false) id - then - fprintf oc " .ascii \"%s\"\n" (PrintCsyntax.string_of_init id) - else - List.iter (Target.print_init oc) id - -let print_var oc name v = - match v.gvar_init with - | [] -> () - | _ -> - let sec = - match C2C.atom_sections name with - | [s] -> s - | _ -> Section_data true - and align = - match C2C.atom_alignof name with - | Some a -> a - | None -> 8 in (* 8-alignment is a safe default *) - let name_sec = Target.name_of_section sec in - if name_sec <> "COMM" then begin - fprintf oc " %s\n" name_sec; - Target.print_align oc align; - if not (C2C.atom_is_static name) then - fprintf oc " .global %a\n" symbol name; - fprintf oc "%a:\n" symbol name; - print_init_data oc name v.gvar_init; - if Target.print_var_info then - print_var_info oc name; - end else - let sz = - match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in - Target.print_comm_symb oc sz name align + let print_location oc loc = + if loc <> Cutil.no_loc then Target.print_file_line oc (fst loc) (snd loc) - -let print_globdef oc (name,gdef) = - match gdef with - | Gfun (Internal code) -> print_function oc name code - | Gfun (External ef) -> () - | Gvar v -> print_var oc name v + let print_function oc name fn = + Hashtbl.clear current_function_labels; + Target.reset_constants (); + let (text, lit, jmptbl) = Target.get_section_names name in + Target.section oc text; + let alignment = + match !Clflags.option_falignfunctions with Some n -> n | None -> 4 in + Target.print_align oc alignment; + if not (C2C.atom_is_static name) then + fprintf oc " .globl %a\n" symbol name; + Target.print_optional_fun_info oc; + fprintf oc "%a:\n" symbol name; + print_location oc (C2C.atom_location name); + Target.cfi_startproc oc; + Target.print_instructions oc fn; + Target.cfi_endproc oc; + if Target.print_fun_info then + print_fun_info oc name; + Target.emit_constants oc lit; + Target.print_jumptable oc jmptbl + let print_init_data oc name id = + if Str.string_match PrintCsyntax.re_string_literal (extern_atom name) 0 + && List.for_all (function Init_int8 _ -> true | _ -> false) id + then + fprintf oc " .ascii \"%s\"\n" (PrintCsyntax.string_of_init id) + else + List.iter (Target.print_init oc) id + + let print_var oc name v = + match v.gvar_init with + | [] -> () + | _ -> + let sec = + match C2C.atom_sections name with + | [s] -> s + | _ -> Section_data true + and align = + match C2C.atom_alignof name with + | Some a -> a + | None -> 8 in (* 8-alignment is a safe default *) + let name_sec = Target.name_of_section sec in + if name_sec <> "COMM" then begin + fprintf oc " %s\n" name_sec; + Target.print_align oc align; + if not (C2C.atom_is_static name) then + fprintf oc " .global %a\n" symbol name; + fprintf oc "%a:\n" symbol name; + print_init_data oc name v.gvar_init; + if Target.print_var_info then + print_var_info oc name; + end else + let sz = + match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in + Target.print_comm_symb oc sz name align + + + let print_globdef oc (name,gdef) = + match gdef with + | Gfun (Internal code) -> print_function oc name code + | Gfun (External ef) -> () + | Gvar v -> print_var oc name v + + end + let print_program oc p = + let module Target = (val (sel_target ()):TARGET) in + let module Printer = Printer(Target) in PrintAnnot.reset_filenames (); PrintAnnot.print_version_and_options oc Target.comment; Target.print_prologue oc; - List.iter (print_globdef oc) p.prog_defs; + List.iter (Printer.print_globdef oc) p.prog_defs; Target.print_epilogue oc; PrintAnnot.close_filenames () -- cgit From 71260eff997f5d3c25d9ccda92b8176c893be26d Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 18 Feb 2015 13:06:58 +0100 Subject: Changed print_fun/var_info to be functions instead of booleans. --- backend/PrintAsm.ml | 6 ++---- backend/PrintAsmaux.ml | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index 532de044..fb03d96b 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -44,8 +44,7 @@ module Printer(Target:TARGET) = Target.cfi_startproc oc; Target.print_instructions oc fn; Target.cfi_endproc oc; - if Target.print_fun_info then - print_fun_info oc name; + Target.print_fun_info oc name; Target.emit_constants oc lit; Target.print_jumptable oc jmptbl @@ -78,8 +77,7 @@ module Printer(Target:TARGET) = fprintf oc " .global %a\n" symbol name; fprintf oc "%a:\n" symbol name; print_init_data oc name v.gvar_init; - if Target.print_var_info then - print_var_info oc name; + Target.print_var_info oc name; end else let sz = match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 3f619d84..f3d95f87 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -26,8 +26,8 @@ module type TARGET = val print_epilogue: out_channel -> unit val print_align: out_channel -> int -> unit val print_comm_symb: out_channel -> Z.t -> P.t -> int -> unit - val print_var_info: bool - val print_fun_info: bool + val print_var_info: out_channel -> P.t -> unit + val print_fun_info: out_channel -> P.t -> unit val print_init: out_channel -> init_data -> unit val reset_constants: unit -> unit val get_section_names: P.t -> section_name * section_name * section_name -- cgit From fcd5ba10674f499d4e270bfb68fa40da8857fb47 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Wed, 18 Feb 2015 15:06:53 +0100 Subject: Added an elf prefix to all common elf functions in PrintAsmaux. --- backend/PrintAsm.ml | 8 ++++---- backend/PrintAsmaux.ml | 24 +++++++++++------------- 2 files changed, 15 insertions(+), 17 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index fb03d96b..c356d7e5 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -37,9 +37,9 @@ module Printer(Target:TARGET) = match !Clflags.option_falignfunctions with Some n -> n | None -> 4 in Target.print_align oc alignment; if not (C2C.atom_is_static name) then - fprintf oc " .globl %a\n" symbol name; + fprintf oc " .globl %a\n" Target.symbol name; Target.print_optional_fun_info oc; - fprintf oc "%a:\n" symbol name; + fprintf oc "%a:\n" Target.symbol name; print_location oc (C2C.atom_location name); Target.cfi_startproc oc; Target.print_instructions oc fn; @@ -74,8 +74,8 @@ module Printer(Target:TARGET) = fprintf oc " %s\n" name_sec; Target.print_align oc align; if not (C2C.atom_is_static name) then - fprintf oc " .global %a\n" symbol name; - fprintf oc "%a:\n" symbol name; + fprintf oc " .global %a\n" Target.symbol name; + fprintf oc "%a:\n" Target.symbol name; print_init_data oc name v.gvar_init; Target.print_var_info oc name; end else diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index f3d95f87..925add9e 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -41,6 +41,7 @@ module type TARGET = val section: out_channel -> section_name -> unit val name_of_section: section_name -> string val comment: string + val symbol: out_channel -> P.t -> unit end (* On-the-fly label renaming *) @@ -60,7 +61,7 @@ let transl_label lbl = Hashtbl.add current_function_labels lbl lbl'; lbl' -let label oc lbl = +let elf_label oc lbl = fprintf oc ".L%d" lbl (* List of literals and jumptables used in the code *) @@ -81,25 +82,22 @@ let current_function_sig = ref { sig_args = []; sig_res = None; sig_cc = cc_default } (* Functions for printing of symbol names *) -let symbol oc symb = +let elf_symbol oc symb = fprintf oc "%s" (extern_atom symb) -let symbol_offset oc (symb, ofs) = - symbol oc symb; +let elf_symbol_offset oc (symb, ofs) = + elf_symbol oc symb; let ofs = camlint_of_coqint ofs in if ofs <> 0l then fprintf oc " + %ld" ofs -(* The comment deliminiter *) -let comment = "#" - (* Functions for fun and var info *) -let print_fun_info oc name = - fprintf oc " .type %a, @function\n" symbol name; - fprintf oc " .size %a, . - %a\n" symbol name symbol name +let elf_print_fun_info oc name = + fprintf oc " .type %a, @function\n" elf_symbol name; + fprintf oc " .size %a, . - %a\n" elf_symbol name elf_symbol name -let print_var_info oc name = - fprintf oc " .type %a, @object\n" symbol name; - fprintf oc " .size %a, . - %a\n" symbol name symbol name +let elf_print_var_info oc name = + fprintf oc " .type %a, @object\n" elf_symbol name; + fprintf oc " .size %a, . - %a\n" elf_symbol name elf_symbol name (* Emit .cfi directives *) let cfi_startproc = -- cgit From cb1da9d8176ea397b833f56ee49af5c75338676f Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 19 Feb 2015 10:12:16 +0100 Subject: Removed unused sel_target, changed cygwin symbol names and changed the default function aligment to be target dependent. --- backend/PrintAsm.ml | 4 +--- backend/PrintAsmaux.ml | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) (limited to 'backend') diff --git a/backend/PrintAsm.ml b/backend/PrintAsm.ml index c356d7e5..a6883339 100644 --- a/backend/PrintAsm.ml +++ b/backend/PrintAsm.ml @@ -20,8 +20,6 @@ open Printf open Sections open TargetPrinter -module Target = (val (sel_target ()):TARGET) - module Printer(Target:TARGET) = struct @@ -34,7 +32,7 @@ module Printer(Target:TARGET) = let (text, lit, jmptbl) = Target.get_section_names name in Target.section oc text; let alignment = - match !Clflags.option_falignfunctions with Some n -> n | None -> 4 in + match !Clflags.option_falignfunctions with Some n -> n | None -> Target.default_falignment in Target.print_align oc alignment; if not (C2C.atom_is_static name) then fprintf oc " .globl %a\n" Target.symbol name; diff --git a/backend/PrintAsmaux.ml b/backend/PrintAsmaux.ml index 925add9e..64db2cb0 100644 --- a/backend/PrintAsmaux.ml +++ b/backend/PrintAsmaux.ml @@ -42,6 +42,7 @@ module type TARGET = val name_of_section: section_name -> string val comment: string val symbol: out_channel -> P.t -> unit + val default_falignment: int end (* On-the-fly label renaming *) -- cgit