diff options
author | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-11 04:00:39 +0000 |
---|---|---|
committer | jason <jason@138bc75d-0d04-0410-961f-82ee72b054a4> | 2011-11-11 04:00:39 +0000 |
commit | c0e76f1fce1aa6274b2e04988b81309a453eb6eb (patch) | |
tree | 048365acb120710e3f57953c76b1f455473b434d /gcc/varasm.c | |
parent | 15a4d99d7f699f35bcf8173219e53765c509e5bf (diff) | |
download | gcc-c0e76f1fce1aa6274b2e04988b81309a453eb6eb.tar.gz |
* final.c, output.h (fprint_whex, fprint_w, fprint_ul, sprint_ul):
New functions serving as fast replacements for fprintf() integer
to string conversions. They were used in the following changes.
* final.c (sprint_ul_rev): Internal helper for the above.
(output_addr_const): case CONST_INT: don't use fprintf().
* elfos.h (ASM_GENERATE_INTERNAL_LABEL): Don't use sprintf("%u"),
use sprint_ul() and stpcpy() which are much faster.
(TARGET_ASM_INTERNAL_LABEL): Define as default_elf_internal_label.
(ELF_ASCII_ESCAPES, ELF_STRING_LIMIT): Are the old ESCAPES and
STRING_LIMIT macros.
(ASM_OUTPUT_LIMITED_STRING, ASM_OUTPUT_ASCII): Macros now just
call respective functions that provide the same
functionality. Those are default_elf_asm_output_limited_string()
and default_elf_asm_output_ascii() in varasm.c.
* varasm.c: Fixed some whitespace inconsistencies.
(default_elf_asm_output_limited_string)
(default_elf_asm_output_ascii): The above macros from elfos.h are
implemented here as these functions, avoiding superfluous calls to
fprintf().
(default_elf_internal_label): Hook for
targetm.asm_out.internal_label and ASM_OUTPUT_DEBUG_LABEL.
* i386.c: Don't call fprintf("%u") but fprint_ul() instead.
* defaults.h (ASM_OUTPUT_LABEL, ASM_OUTPUT_INTERNAL_LABEL):
Expanded the macros on multiple lines for readability.
(ASM_OUTPUT_LABELREF): Have two calls to fputs() instead of one to
asm_fprintf().
* dwarf2asm.c (dw2_assemble_integer, dw2_asm_output_data)
(dw2_asm_data_uleb128, dw2_asm_delta_uleb128)
(dw2_asm_delta_sleb128): Convert fprintf() calls to the new
faster functions.
* dwarf2out.c (dwarf2out_source_line): Convert fprintf() calls to
the new faster functions.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181279 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc/varasm.c')
-rw-r--r-- | gcc/varasm.c | 136 |
1 files changed, 130 insertions, 6 deletions
diff --git a/gcc/varasm.c b/gcc/varasm.c index ed27dce7b0a..8762a2eb3ac 100644 --- a/gcc/varasm.c +++ b/gcc/varasm.c @@ -564,7 +564,7 @@ default_function_section (tree decl, enum node_frequency freq, /* Return the section for function DECL. If DECL is NULL_TREE, return the text section. We can be passed - NULL_TREE under some circumstances by dbxout.c at least. + NULL_TREE under some circumstances by dbxout.c at least. If FORCE_COLD is true, return cold function section ignoring the frequency info of cgraph_node. */ @@ -1928,7 +1928,7 @@ assemble_variable (tree decl, int top_level ATTRIBUTE_UNUSED, /* Emulated TLS had better not get this far. */ gcc_checking_assert (targetm.have_tls || !DECL_THREAD_LOCAL_P (decl)); - + last_assemble_variable_decl = 0; /* Normally no need to say anything here for external references, @@ -2852,7 +2852,7 @@ compare_constant (const tree t1, const tree t2) return 0; link2 = TREE_CHAIN (link2); } - + return 1; } @@ -5754,7 +5754,7 @@ finish_aliases_1 (void) && ! lookup_attribute ("weakref", DECL_ATTRIBUTES (p->decl))) { error ("%q+D aliased to external symbol %qE", - p->decl, p->target); + p->decl, p->target); p->emitted_diags |= ALIAS_DIAG_TO_EXTERN; } } @@ -5820,7 +5820,7 @@ assemble_alias (tree decl, tree target) if (lookup_attribute ("ifunc", DECL_ATTRIBUTES (decl))) error_at (DECL_SOURCE_LOCATION (decl), "ifunc is not supported in this configuration"); - else + else error_at (DECL_SOURCE_LOCATION (decl), "only weak aliases are supported in this configuration"); return; @@ -6019,7 +6019,7 @@ finish_tm_clone_pairs (void) the visibility type VIS, which must not be VISIBILITY_DEFAULT. */ void -default_assemble_visibility (tree decl ATTRIBUTE_UNUSED, +default_assemble_visibility (tree decl ATTRIBUTE_UNUSED, int vis ATTRIBUTE_UNUSED) { #ifdef HAVE_GAS_HIDDEN @@ -7519,6 +7519,130 @@ make_debug_expr_from_rtl (const_rtx exp) return dval; } +/* Default ASM_OUTPUT_LIMITED_STRING for ELF targets. */ + +void +default_elf_asm_output_limited_string (FILE *f, const char *s) +{ + int escape; + unsigned char c; + + fputs ("\t.string\t\"", f); + while (*s != '\0') + { + c = *s; + escape = ELF_ASCII_ESCAPES[c]; + switch (escape) + { + case 0: + putc (c, f); + break; + case 1: + /* TODO: Print in hex with fast function, important for -flto. */ + fprintf (f, "\\%03o", c); + break; + default: + putc ('\\', f); + putc (escape, f); + break; + } + s++; + } + putc ('\"', f); + putc ('\n', f); +} + +/* Default ASM_OUTPUT_ASCII for ELF targets. */ + +void +default_elf_asm_output_ascii (FILE *f, const char *s, unsigned int len) +{ + const char *limit = s + len; + const char *last_null = NULL; + unsigned bytes_in_chunk = 0; + unsigned char c; + int escape; + + for (; s < limit; s++) + { + const char *p; + + if (bytes_in_chunk >= 60) + { + putc ('\"', f); + putc ('\n', f); + bytes_in_chunk = 0; + } + + if (s > last_null) + { + for (p = s; p < limit && *p != '\0'; p++) + continue; + last_null = p; + } + else + p = last_null; + + if (p < limit && (p - s) <= (long) ELF_STRING_LIMIT) + { + if (bytes_in_chunk > 0) + { + putc ('\"', f); + putc ('\n', f); + bytes_in_chunk = 0; + } + + default_elf_asm_output_limited_string (f, s); + s = p; + } + else + { + if (bytes_in_chunk == 0) + fputs (ASCII_DATA_ASM_OP "\"", f); + + c = *s; + escape = ELF_ASCII_ESCAPES[c]; + switch (escape) + { + case 0: + putc (c, f); + bytes_in_chunk++; + break; + case 1: + /* TODO: Print in hex with fast function, important for -flto. */ + fprintf (f, "\\%03o", c); + bytes_in_chunk += 4; + break; + default: + putc ('\\', f); + putc (escape, f); + bytes_in_chunk += 2; + break; + } + + } + } + + if (bytes_in_chunk > 0) + { + putc ('\"', f); + putc ('\n', f); + } +} + +/* Default TARGET_ASM_INTERNAL_LABEL for ELF targets. */ + +void +default_elf_internal_label (FILE *f, const char *prefix, + unsigned long labelno) +{ + putc ('.', f); + fputs (prefix, f); + fprint_ul (f, labelno); + putc (':', f); + putc ('\n', f); +} + static GTY(()) section *elf_init_array_section; static GTY(()) section *elf_fini_array_section; |