Hi, sanitize_hsa_name attracted my attention because it had no comment but then I found out we had two copies of the function in two different files. So I moved the definition to hsa.c.
Martin 2015-06-19 Martin Jambor <mjam...@suse.cz> * hsa.c (hsa_sanitize_name): Moved here from... * hsa-gen.c (sanitize_hsa_name): ...here... * hsa-brig.c (sanitize_hsa_name): ...and here. * hsa.h (hsa_sanitize_name): Declare. --- gcc/ChangeLog.hsa | 8 ++++++++ gcc/hsa-brig.c | 10 +--------- gcc/hsa-gen.c | 10 +--------- gcc/hsa.c | 10 ++++++++++ gcc/hsa.h | 1 + 5 files changed, 21 insertions(+), 18 deletions(-) diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c index 53a11aa7..18d53d4 100644 --- a/gcc/hsa-brig.c +++ b/gcc/hsa-brig.c @@ -307,14 +307,6 @@ brig_string_slot_hasher::remove (value_type ds) static hash_table<brig_string_slot_hasher> *brig_string_htab; -static void -sanitize_hsa_name (char *p) -{ - for (; *p; p++) - if (*p == '.') - *p = '_'; -} - /* Emit a null terminated string STR to the data section and return its offset in it. If PREFIX is non-zero, output it just before STR too. */ @@ -330,7 +322,7 @@ brig_emit_string (const char *str, char prefix = 0) /* XXX Sanitize the names without all the strdup. */ str2 = xstrdup (str); - sanitize_hsa_name (str2); + hsa_sanitize_name (str2); s_slot.s = str2; s_slot.len = slen; s_slot.prefix = prefix; diff --git a/gcc/hsa-gen.c b/gcc/hsa-gen.c index 169b62b..0f05abd 100644 --- a/gcc/hsa-gen.c +++ b/gcc/hsa-gen.c @@ -2266,14 +2266,6 @@ gen_function_parameters (vec <hsa_op_reg_p> ssa_map) } } -static void -sanitize_hsa_name (char *p) -{ - for (; *p; p++) - if (*p == '.') - *p = '_'; -} - /* Genrate HSAIL reprezentation of the current function and write into a special section of the output file. If KERNEL is set, the function will be considered an HSA kernel callable from the host, otherwise it will be @@ -2290,7 +2282,7 @@ generate_hsa (bool kernel) ssa_map.safe_grow_cleared (SSANAMES (cfun)->length ()); hsa_cfun.name = xstrdup (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (current_function_decl))); - sanitize_hsa_name (hsa_cfun.name); + hsa_sanitize_name (hsa_cfun.name); if (hsa_cfun.kern_p) hsa_add_kern_decl_mapping (current_function_decl, hsa_cfun.name); diff --git a/gcc/hsa.c b/gcc/hsa.c index 3212205..5cb7975 100644 --- a/gcc/hsa.c +++ b/gcc/hsa.c @@ -292,4 +292,14 @@ hsa_free_decl_kernel_mapping (void) ggc_free (hsa_decl_kernel_mapping); } +/* Modify the name P in-place so that it is a valid HSA identifier. */ + +void +hsa_sanitize_name (char *p) +{ + for (; *p; p++) + if (*p == '.') + *p = '_'; +} + #include "gt-hsa.h" diff --git a/gcc/hsa.h b/gcc/hsa.h index 05a6aa3..336608e 100644 --- a/gcc/hsa.h +++ b/gcc/hsa.h @@ -619,6 +619,7 @@ unsigned hsa_get_number_decl_kernel_mappings (void); tree hsa_get_decl_kernel_mapping_decl (unsigned i); char *hsa_get_decl_kernel_mapping_name (unsigned i); void hsa_free_decl_kernel_mapping (void); +void hsa_sanitize_name (char *p); /* In hsa-gen.c. */ void hsa_build_append_simple_mov (hsa_op_reg *, hsa_op_base *, hsa_bb *); -- 2.1.4