From a7f49e1e55cdf648e7778c1fc12fbc3ac9782c1a Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 10 Feb 2015 14:33:47 +0100 Subject: Added new Mingw Printer. Currently the only difference to the Cygwin printer is that every symbol must start with an "_". --- ia32/PrintAsm.ml | 68 +++++++++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 55 insertions(+), 13 deletions(-) (limited to 'ia32') diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index b0ef0180..94d728e2 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -122,6 +122,55 @@ module Cygwin_System = end:SYSTEM) +(* Printer functions for cygwin *) +module Mingw_System = + (struct + + let raw_symbol oc s = + fprintf oc "_%s" s + + let symbol oc symb = + fprintf oc "_%s" (extern_atom symb) + + let label oc lbl = + fprintf oc "L%d" lbl + + let name_of_section = function + | Section_text -> ".text" + | Section_data i | Section_small_data i -> + if i then ".data" else "COMM" + | Section_const i | Section_small_const i -> + if i then ".section .rdata,\"dr\"" else "COMM" + | Section_string -> ".section .rdata,\"dr\"" + | Section_literal -> ".section .rdata,\"dr\"" + | Section_jumptable -> ".text" + | Section_user(s, wr, ex) -> + sprintf ".section \"%s\", \"%s\"\n" + s (if ex then "xr" else if wr then "d" else "dr") + + let stack_alignment = 8 (* minimum is 4, 8 is better for perfs *) + + let print_align oc n = + fprintf oc " .align %d\n" n + + let print_mov_ra oc rd id = + fprintf oc " movl $%a, %a\n" symbol id ireg rd + + let print_fun_info _ _ = () + + let print_var_info _ _ = () + + let print_epilogue _ = () + + let print_comm_decl oc name sz al = + fprintf oc " .comm %a, %s, %d\n" symbol name (Z.to_string sz) al + + let print_lcomm_decl oc name sz al = + fprintf oc " .local %a\n" symbol name; + print_comm_decl oc name sz al + + end:SYSTEM) + (* Printer functions for ELF *) module ELF_System = (struct @@ -1028,20 +1077,13 @@ let print_globdef oc (name, gdef) = | Gvar v -> print_var oc name v end) -type target = ELF | MacOS | Cygwin - let print_program oc p = - let target = - match Configuration.system with - | "macosx" -> MacOS - | "linux" -> ELF - | "bsd" -> ELF - | "cygwin" -> Cygwin - | _ -> invalid_arg ("System " ^ Configuration.system ^ " not supported") in - let module Target = (val (match target with - | MacOS -> (module MacOS_System:SYSTEM) - | ELF -> (module ELF_System:SYSTEM) - | Cygwin -> (module Cygwin_System:SYSTEM)):SYSTEM) in + let module Target = (val (match Configuration.system with + | "macosx" -> (module MacOS_System:SYSTEM) + | "linux" | "bsd" -> (module ELF_System:SYSTEM) + | "cygwin" -> (module Cygwin_System:SYSTEM) + | "mingw" -> (module Mingw_System:SYSTEM) + | _ -> invalid_arg ("System " ^ Configuration.system ^ " not supported")):SYSTEM) in let module Printer = AsmPrinter(Target) in PrintAnnot.print_version_and_options oc Printer.comment; PrintAnnot.reset_filenames(); -- cgit From 1772a8118fae5152439965b2f9c9887c60a57c37 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Tue, 10 Feb 2015 16:22:28 +0100 Subject: Use lcomm instead of .local for Mingw. --- ia32/PrintAsm.ml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'ia32') diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index 94d728e2..e6f905a3 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -166,8 +166,8 @@ module Mingw_System = fprintf oc " .comm %a, %s, %d\n" symbol name (Z.to_string sz) al let print_lcomm_decl oc name sz al = - fprintf oc " .local %a\n" symbol name; - print_comm_decl oc name sz al + fprintf oc " .lcomm %a, %s, %d\n" + symbol name (Z.to_string sz) al end:SYSTEM) -- cgit From 0921a0b5bafb179f18f94561bece26a4d184fa31 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 19 Feb 2015 10:04:26 +0100 Subject: Changed the symbol function back to its old definition. --- ia32/PrintAsm.ml | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) (limited to 'ia32') diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index b0ef0180..d064782e 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -60,7 +60,6 @@ let preg oc = function module type SYSTEM = sig val raw_symbol: out_channel -> string -> unit - val symbol: out_channel -> P.t -> unit val label: out_channel -> int -> unit val name_of_section: section_name -> string val stack_alignment: int @@ -80,9 +79,6 @@ module Cygwin_System = let raw_symbol oc s = fprintf oc "_%s" s - let symbol oc symb = - fprintf oc "%s" (extern_atom symb) - let label oc lbl = fprintf oc "L%d" lbl @@ -128,9 +124,6 @@ module ELF_System = let raw_symbol oc s = fprintf oc "%s" s - - let symbol oc symb = - fprintf oc "%s" (extern_atom symb) let label oc lbl = fprintf oc ".L%d" lbl @@ -182,9 +175,6 @@ module MacOS_System = let raw_symbol oc s = fprintf oc "_%s" s - let symbol oc symb = - fprintf oc "_%s" (extern_atom symb) - let label oc lbl = fprintf oc "L%d" lbl @@ -249,6 +239,9 @@ module AsmPrinter(Target: SYSTEM) = open Target (* On-the-fly label renaming *) +let symbol oc symb = + raw_symbol oc (extern_atom symb) + let next_label = ref 100 let new_label() = -- cgit From d4389977e95d3569ff0abb53e1b1fba20254b21e Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 19 Feb 2015 10:07:22 +0100 Subject: Added back symbol functions in the different printer, since they are still needed. --- ia32/PrintAsm.ml | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'ia32') diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index d064782e..036dbda8 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -60,6 +60,7 @@ let preg oc = function module type SYSTEM = sig val raw_symbol: out_channel -> string -> unit + val symbol: out_channel -> P.t -> unit val label: out_channel -> int -> unit val name_of_section: section_name -> string val stack_alignment: int @@ -79,6 +80,9 @@ module Cygwin_System = let raw_symbol oc s = fprintf oc "_%s" s + let symbol oc s = + raw_symbol oc (extern_atom symb) + let label oc lbl = fprintf oc "L%d" lbl @@ -125,6 +129,9 @@ module ELF_System = let raw_symbol oc s = fprintf oc "%s" s + let symbol oc s = + raw_symbol oc (extern_atom symb) + let label oc lbl = fprintf oc ".L%d" lbl @@ -175,6 +182,9 @@ module MacOS_System = let raw_symbol oc s = fprintf oc "_%s" s + let symbol oc s = + raw_symbol oc (extern_atom symb) + let label oc lbl = fprintf oc "L%d" lbl @@ -239,9 +249,6 @@ module AsmPrinter(Target: SYSTEM) = open Target (* On-the-fly label renaming *) -let symbol oc symb = - raw_symbol oc (extern_atom symb) - let next_label = ref 100 let new_label() = -- cgit From ed6e82f79383377aa2dc115fbbc74602a2a816b1 Mon Sep 17 00:00:00 2001 From: Bernhard Schommer Date: Thu, 19 Feb 2015 16:23:18 +0100 Subject: Removed the MinGW port. --- ia32/PrintAsm.ml | 56 +++----------------------------------------------------- 1 file changed, 3 insertions(+), 53 deletions(-) (limited to 'ia32') diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml index b42f4314..3bd614df 100644 --- a/ia32/PrintAsm.ml +++ b/ia32/PrintAsm.ml @@ -80,7 +80,7 @@ module Cygwin_System = let raw_symbol oc s = fprintf oc "_%s" s - let symbol oc s = + let symbol oc symb = raw_symbol oc (extern_atom symb) let label oc lbl = @@ -122,55 +122,6 @@ module Cygwin_System = end:SYSTEM) -(* Printer functions for cygwin *) -module Mingw_System = - (struct - - let raw_symbol oc s = - fprintf oc "_%s" s - - let symbol oc symb = - fprintf oc "_%s" (extern_atom symb) - - let label oc lbl = - fprintf oc "L%d" lbl - - let name_of_section = function - | Section_text -> ".text" - | Section_data i | Section_small_data i -> - if i then ".data" else "COMM" - | Section_const i | Section_small_const i -> - if i then ".section .rdata,\"dr\"" else "COMM" - | Section_string -> ".section .rdata,\"dr\"" - | Section_literal -> ".section .rdata,\"dr\"" - | Section_jumptable -> ".text" - | Section_user(s, wr, ex) -> - sprintf ".section \"%s\", \"%s\"\n" - s (if ex then "xr" else if wr then "d" else "dr") - - let stack_alignment = 8 (* minimum is 4, 8 is better for perfs *) - - let print_align oc n = - fprintf oc " .align %d\n" n - - let print_mov_ra oc rd id = - fprintf oc " movl $%a, %a\n" symbol id ireg rd - - let print_fun_info _ _ = () - - let print_var_info _ _ = () - - let print_epilogue _ = () - - let print_comm_decl oc name sz al = - fprintf oc " .comm %a, %s, %d\n" symbol name (Z.to_string sz) al - - let print_lcomm_decl oc name sz al = - fprintf oc " .lcomm %a, %s, %d\n" - symbol name (Z.to_string sz) al - - end:SYSTEM) - (* Printer functions for ELF *) module ELF_System = (struct @@ -178,7 +129,7 @@ module ELF_System = let raw_symbol oc s = fprintf oc "%s" s - let symbol oc s = + let symbol oc symb = raw_symbol oc (extern_atom symb) let label oc lbl = @@ -231,7 +182,7 @@ module MacOS_System = let raw_symbol oc s = fprintf oc "_%s" s - let symbol oc s = + let symbol oc symb = raw_symbol oc (extern_atom symb) let label oc lbl = @@ -1082,7 +1033,6 @@ let print_program oc p = | "macosx" -> (module MacOS_System:SYSTEM) | "linux" | "bsd" -> (module ELF_System:SYSTEM) | "cygwin" -> (module Cygwin_System:SYSTEM) - | "mingw" -> (module Mingw_System:SYSTEM) | _ -> invalid_arg ("System " ^ Configuration.system ^ " not supported")):SYSTEM) in let module Printer = AsmPrinter(Target) in PrintAnnot.print_version_and_options oc Printer.comment; -- cgit