diff options
author | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-08-22 17:35:49 +0200 |
---|---|---|
committer | Xavier Leroy <xavier.leroy@college-de-france.fr> | 2022-08-29 13:55:35 +0200 |
commit | 169007c52e27ce1fce6ca5fdd5fc7f43071b8841 (patch) | |
tree | 86e52680d32759cf4c78219fb245bd0467c070a1 /powerpc | |
parent | 50836f2a04575402aa61a256fe7047c16610992f (diff) | |
download | compcert-169007c52e27ce1fce6ca5fdd5fc7f43071b8841.tar.gz compcert-169007c52e27ce1fce6ca5fdd5fc7f43071b8841.zip |
Support mergeable sections for fixed-size literals
On platforms that support them (ELF, macOS), use mergeable sections
(like `.rodata.cst8`) for 4-, 8- and 16-byte wide literals.
Works only if the LITERAL section is the default one. If the user
provided their own LITERAL section, all literals are put in it
regardless of their sizes.
Support for mergeable string sections is introduced in this commit too
but needs further changes in C2C.ml .
Diffstat (limited to 'powerpc')
-rw-r--r-- | powerpc/TargetPrinter.ml | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/powerpc/TargetPrinter.ml b/powerpc/TargetPrinter.ml index 5c414b56..567b0598 100644 --- a/powerpc/TargetPrinter.ml +++ b/powerpc/TargetPrinter.ml @@ -128,8 +128,10 @@ module Linux_System : SYSTEM = variable_section ~sec:".rodata" i | Section_small_const i -> variable_section ~sec:".section .sdata2,\"a\",@progbits" i - | Section_string -> ".rodata" - | Section_literal -> ".section .rodata" + | Section_string sz -> + elf_mergeable_string_section sz ".section .rodata" + | Section_literal sz -> + elf_mergeable_literal_section sz ".section .rodata" | Section_jumptable -> ".text" | Section_user(s, wr, ex) -> sprintf ".section \"%s\",\"a%s%s\",@progbits" @@ -218,8 +220,8 @@ module Diab_System : SYSTEM = variable_section ~sec:".sdata" ~bss:".sbss" ~common:false i | Section_const _ -> ".text" | Section_small_const _ -> ".sdata2" - | Section_string -> ".text" - | Section_literal -> ".text" + | Section_string _ -> ".text" + | Section_literal _ -> ".text" | Section_jumptable -> ".text" | Section_user(s, wr, ex) -> sprintf ".section \"%s\",,%c" @@ -919,21 +921,20 @@ module Target (System : SYSTEM):TARGET = let print_fun_info = elf_print_fun_info let emit_constants oc lit = - if exists_constants () then begin - section oc lit; + if Hashtbl.length literal64_labels > 0 then begin + section oc (Sections.with_size 8 lit); fprintf oc " .balign 8\n"; - Hashtbl.iter (print_literal64 oc) literal64_labels; - Hashtbl.iter (print_literal32 oc) literal32_labels; + Hashtbl.iter (print_literal64 oc) literal64_labels + end; + if Hashtbl.length literal32_labels > 0 then begin + section oc (Sections.with_size 4 lit); + fprintf oc " .balign 4\n"; + Hashtbl.iter (print_literal32 oc) literal32_labels end; reset_literals () let print_optional_fun_info _ = () - let get_section_names name = - match C2C.atom_sections name with - | [t;l;j] -> (t, l, j) - | _ -> (Section_text, Section_literal, Section_jumptable) - let print_var_info = elf_print_var_info let print_comm_symb oc sz name align = |