This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[trans-mem] mangling for clones
- From: Richard Henderson <rth at redhat dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Wed, 05 Nov 2008 17:00:31 -0800
- Subject: [trans-mem] mangling for clones
I'm changing to a C++-style of mangling for the transactional clones,
with the extension
special-name ::
...
| "GT" <transaction-letter> <encoding>
transaction-letter ::
't' -> software transactional clone
'n' -> non-transactional function entry point
[^tn] -> platform-specific hardware transactional clone(s)
At the moment I'm not generating the non-transactional entry points.
I need to give that some more thought as to how I want to handle the
thunks that the Intel ABI is specifying for i386/x86_64.
r~
gcc/
* trans-mem.c (ipa_tm_create_version): Use C++ style mangling.
* Makefile.in (trans-mem.o): Update dependencies.
include/
* demangle.h (DEMANGLE_COMPONENT_TRANSACTION_CLONE): New.
(DEMANGLE_COMPONENT_NONTRANSACTION_CLONE): New.
libiberty/
* cp-demangle.c (d_dump): Handle DEMANGLE_COMPONENT_TRANSACTION_CLONE
and DEMANGLE_COMPONENT_NONTRANSACTION_CLONE.
(d_make_comp, d_print_comp): Likewise.
(d_special_name): Generate them.
--- gcc/Makefile.in (revision 141637)
+++ gcc/Makefile.in (local)
@@ -2039,7 +2039,7 @@ gtype-desc.o: gtype-desc.c $(CONFIG_H) $
trans-mem.o : trans-mem.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) \
$(TREE_H) $(GIMPLE_H) $(TREE_FLOW_H) tree-pass.h except.h \
- $(DIAGNOSTIC_H)
+ $(DIAGNOSTIC_H) $(TOPLEV_H) $(FLAGS_H) $(DEMANGLE_H)
ggc-common.o: ggc-common.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(GGC_H) \
$(HASHTAB_H) $(TOPLEV_H) $(PARAMS_H) hosthooks.h $(HOSTHOOKS_DEF_H)
--- gcc/trans-mem.c (revision 141637)
+++ gcc/trans-mem.c (local)
@@ -29,6 +29,7 @@
#include "diagnostic.h"
#include "toplev.h"
#include "flags.h"
+#include "demangle.h"
#define PROB_VERY_UNLIKELY (REG_BR_PROB_BASE / 2000 - 1)
@@ -1318,7 +1319,10 @@ ipa_tm_create_version (struct cgraph_nod
VEC (cgraph_edge_p, heap) *redirections)
{
struct cgraph_node *new_node;
+ const char *old_asm_name;
+ struct demangle_component *dc;
char *tm_name;
+ void *alloc = NULL;
new_node = cgraph_function_versioning (old_node, redirections,
NULL, NULL);
@@ -1347,23 +1351,51 @@ ipa_tm_create_version (struct cgraph_nod
of debugging. */
DECL_NAME (new_node->decl) = DECL_NAME (old_node->decl);
- /* ??? The current Intel ABI for these symbols uses this first variant.
- I believe we ought to be considering _ZGT{t,n,m} extensions to the
- C++ name mangling ABI. */
-#if !defined(NO_DOT_IN_LABEL) && !defined(NO_DOLLAR_IN_LABEL)
-# define TM_SUFFIX ".$TXN"
-#elif !defined(NO_DOT_IN_LABEL)
-# define TM_SUFFIX ".TXN"
-#elif !defined(NO_DOLLAR_IN_LABEL)
-# define TM_SUFFIX "$TXN"
-#else
-# define TM_SUFFIX "__TXN"
-#endif
+ /* Determine if the symbol is already a valid C++ mangled name. Do this
+ even for C, which might be interfacing with C++ code via appropriately
+ ugly identifiers. */
+ /* ??? We could probably do just as well checking for "_Z" and be done. */
+ old_asm_name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (old_node->decl));
+ dc = cplus_demangle_v3_components (old_asm_name, DMGL_NO_OPTS, &alloc);
+
+ if (dc == NULL)
+ {
+ char length[8];
+
+ do_unencoded:
+ sprintf (length, "%u",
+ IDENTIFIER_LENGTH (DECL_ASSEMBLER_NAME (old_node->decl)));
+ tm_name = concat ("_ZGTt", length, old_asm_name, NULL);
+ }
+ else
+ {
+ old_asm_name += 2; /* Skip _Z */
+
+ switch (dc->type)
+ {
+ case DEMANGLE_COMPONENT_TRANSACTION_CLONE:
+ case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE:
+ /* Don't play silly games, you! */
+ goto do_unencoded;
+
+ case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
+ /* I'd really like to know if we can ever be passed one of
+ these from the C++ front end. The Logical Thing would
+ seem that hidden-alias should be outer-most, so that we
+ get hidden-alias of a transaction-clone and not vice-versa. */
+ old_asm_name += 2;
+ break;
+
+ default:
+ break;
+ }
+
+ tm_name = concat ("_ZGTt", old_asm_name, NULL);
+ }
- tm_name = concat (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (old_node->decl)),
- TM_SUFFIX, NULL);
SET_DECL_ASSEMBLER_NAME (new_node->decl, get_identifier (tm_name));
free (tm_name);
+ free (alloc);
}
static void
--- include/demangle.h (revision 141637)
+++ include/demangle.h (local)
@@ -374,7 +374,14 @@ enum demangle_component_type
/* A decltype type. */
DEMANGLE_COMPONENT_DECLTYPE,
/* A pack expansion. */
- DEMANGLE_COMPONENT_PACK_EXPANSION
+ DEMANGLE_COMPONENT_PACK_EXPANSION,
+ /* A transactional clone. This has one subtree, the encoding for
+ which it is providing alternative linkage. */
+ DEMANGLE_COMPONENT_TRANSACTION_CLONE,
+ /* A non-transactional clone entry point. In the i386/x86_64 abi,
+ the unmangled symbol of a tm_callable becomes a thunk and the
+ non-transactional function version is mangled thus. */
+ DEMANGLE_COMPONENT_NONTRANSACTION_CLONE
};
/* Types which are only used internally. */
--- libiberty/cp-demangle.c (revision 141637)
+++ libiberty/cp-demangle.c (local)
@@ -573,6 +573,12 @@ d_dump (struct demangle_component *dc, i
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
printf ("hidden alias\n");
break;
+ case DEMANGLE_COMPONENT_TRANSACTION_CLONE:
+ printf ("transaction clone\n");
+ break;
+ case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE:
+ printf ("non-transaction clone\n");
+ break;
case DEMANGLE_COMPONENT_RESTRICT:
printf ("restrict\n");
break;
@@ -806,6 +812,8 @@ d_make_comp (struct d_info *di, enum dem
case DEMANGLE_COMPONENT_GUARD:
case DEMANGLE_COMPONENT_REFTEMP:
case DEMANGLE_COMPONENT_HIDDEN_ALIAS:
+ case DEMANGLE_COMPONENT_TRANSACTION_CLONE:
+ case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE:
case DEMANGLE_COMPONENT_POINTER:
case DEMANGLE_COMPONENT_REFERENCE:
case DEMANGLE_COMPONENT_RVALUE_REFERENCE:
@@ -1635,6 +1643,8 @@ d_java_resource (struct d_info *di)
::= GR <name>
::= GA <encoding>
::= Gr <resource name>
+ ::= GTt <encoding>
+ ::= GTn <encoding>
*/
static struct demangle_component *
@@ -1726,6 +1736,23 @@ d_special_name (struct d_info *di)
return d_make_comp (di, DEMANGLE_COMPONENT_HIDDEN_ALIAS,
d_encoding (di, 0), NULL);
+ case 'T':
+ switch (d_next_char (di))
+ {
+ case 'n':
+ return d_make_comp (di, DEMANGLE_COMPONENT_NONTRANSACTION_CLONE,
+ d_encoding (di, 0), NULL);
+ default:
+ /* ??? The proposal is that other letters (such as 'h') stand
+ for different variants of transaction cloning, such as
+ compiling directly for hardware transaction support. But
+ they still should all be transactional clones of some sort
+ so go ahead and call them that. */
+ case 't':
+ return d_make_comp (di, DEMANGLE_COMPONENT_TRANSACTION_CLONE,
+ d_encoding (di, 0), NULL);
+ }
+
case 'r':
return d_java_resource (di);
@@ -3521,6 +3548,16 @@ d_print_comp (struct d_print_info *dpi,
d_print_comp (dpi, d_left (dc));
return;
+ case DEMANGLE_COMPONENT_TRANSACTION_CLONE:
+ d_append_string (dpi, "tranaction clone for ");
+ d_print_comp (dpi, d_left (dc));
+ return;
+
+ case DEMANGLE_COMPONENT_NONTRANSACTION_CLONE:
+ d_append_string (dpi, "non-tranaction clone for ");
+ d_print_comp (dpi, d_left (dc));
+ return;
+
case DEMANGLE_COMPONENT_SUB_STD:
d_append_buffer (dpi, dc->u.s_string.string, dc->u.s_string.len);
return;