aboutsummaryrefslogtreecommitdiffstats
path: root/ia32/PrintAsm.ml
diff options
context:
space:
mode:
authorXavier Leroy <xavier.leroy@inria.fr>2014-12-17 15:28:01 +0100
committerXavier Leroy <xavier.leroy@inria.fr>2014-12-17 15:28:01 +0100
commit4461db2bd92973b83bbd74c8f2eec16d702cffed (patch)
treeb02c8d646631662a5309238c13306a7d1f3e72db /ia32/PrintAsm.ml
parent20c70573181f81c99ea4e8797615dac8308a9b18 (diff)
parentc1daedb244d1f7586c12749642b0d78ae910e60a (diff)
downloadcompcert-4461db2bd92973b83bbd74c8f2eec16d702cffed.tar.gz
compcert-4461db2bd92973b83bbd74c8f2eec16d702cffed.zip
Merge branch 'master' into pure-makefiles
Diffstat (limited to 'ia32/PrintAsm.ml')
-rw-r--r--ia32/PrintAsm.ml68
1 files changed, 50 insertions, 18 deletions
diff --git a/ia32/PrintAsm.ml b/ia32/PrintAsm.ml
index 5c84af6b..649fd292 100644
--- a/ia32/PrintAsm.ml
+++ b/ia32/PrintAsm.ml
@@ -57,7 +57,7 @@ let preg oc = function
(* System dependend printer functions *)
-module type SYSTEM=
+module type SYSTEM =
sig
val raw_symbol: out_channel -> string -> unit
val symbol: out_channel -> P.t -> unit
@@ -69,6 +69,8 @@ module type SYSTEM=
val print_fun_info: out_channel -> P.t -> unit
val print_var_info: out_channel -> P.t -> unit
val print_epilogue: out_channel -> unit
+ val print_comm_decl: out_channel -> P.t -> Z.t -> int -> unit
+ val print_lcomm_decl: out_channel -> P.t -> Z.t -> int -> unit
end
(* Printer functions for cygwin *)
@@ -86,8 +88,10 @@ module Cygwin_System =
let name_of_section = function
| Section_text -> ".text"
- | Section_data _ | Section_small_data _ -> ".data"
- | Section_const | Section_small_const -> ".section .rdata,\"dr\""
+ | 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"
@@ -108,6 +112,14 @@ module Cygwin_System =
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 *)
@@ -125,8 +137,10 @@ module ELF_System =
let name_of_section = function
| Section_text -> ".text"
- | Section_data i | Section_small_data i -> if i then ".data" else "COMM"
- | Section_const | Section_small_const -> ".section .rodata"
+ | Section_data i | Section_small_data i ->
+ if i then ".data" else "COMM"
+ | Section_const i | Section_small_const i ->
+ if i then ".section .rodata" else "COMM"
| Section_string -> ".section .rodata"
| Section_literal -> ".section .rodata.cst8,\"aM\",@progbits,8"
| Section_jumptable -> ".text"
@@ -151,6 +165,14 @@ module ELF_System =
fprintf oc " .size %a, . - %a\n" symbol name symbol name
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 MacOS *)
@@ -161,15 +183,17 @@ module MacOS_System =
fprintf oc "_%s" s
let symbol oc symb =
- fprintf oc "%s" (extern_atom 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 _ | Section_small_data _ -> ".data"
- | Section_const | Section_small_const -> ".const"
+ | Section_data i | Section_small_data i ->
+ if i then ".data" else "COMM"
+ | Section_const i | Section_small_const i ->
+ if i then ".const" else "COMM"
| Section_string -> ".const"
| Section_literal -> ".literal8"
| Section_jumptable -> ".const"
@@ -206,7 +230,16 @@ module MacOS_System =
fprintf oc "L%a$non_lazy_ptr:\n" raw_symbol s;
fprintf oc " .indirect_symbol %a\n" raw_symbol s;
fprintf oc " .long 0\n")
- !indirect_symbols
+ !indirect_symbols;
+ indirect_symbols := StringSet.empty
+
+ let print_comm_decl oc name sz al =
+ fprintf oc " .comm %a, %s, %d\n"
+ symbol name (Z.to_string sz) (log2 al)
+
+ let print_lcomm_decl oc name sz al =
+ fprintf oc " .lcomm %a, %s, %d\n"
+ symbol name (Z.to_string sz) (log2 al)
end:SYSTEM)
@@ -638,7 +671,6 @@ let print_builtin_inline oc name args res =
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 indirect_symbols : StringSet.t ref = ref StringSet.empty
(* Reminder on AT&T syntax: op source, dest *)
@@ -996,12 +1028,9 @@ let print_var oc name v =
end else begin
let sz =
match v.gvar_init with [Init_space sz] -> sz | _ -> assert false in
- if C2C.atom_is_static name then
- fprintf oc " .local %a\n" symbol name;
- fprintf oc " .comm %a, %s, %d\n"
- symbol name
- (Z.to_string sz)
- align
+ if C2C.atom_is_static name
+ then Target.print_lcomm_decl oc name sz align
+ else Target.print_comm_decl oc name sz align
end
let print_globdef oc (name, gdef) =
@@ -1032,7 +1061,8 @@ let print_program oc p =
Hashtbl.clear Printer.filename_num;
List.iter (Printer.print_globdef oc) p.prog_defs;
if !Printer.need_masks then begin
- Printer.section oc Section_const; (* not Section_literal because not 8-bytes *)
+ Printer.section oc (Section_const true);
+ (* not Section_literal because not 8-bytes *)
Target.print_align oc 16;
fprintf oc "%a: .quad 0x8000000000000000, 0\n"
Target.raw_symbol "__negd_mask";
@@ -1042,4 +1072,6 @@ let print_program oc p =
Target.raw_symbol "__negs_mask";
fprintf oc "%a: .long 0x7FFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF\n"
Target.raw_symbol "__abss_mask"
- end
+ end;
+ Target.print_epilogue oc
+