[m-dev.] diff: GCC back-end: fix name mangling bug
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Feb 1 06:52:39 AEDT 2001
I'm just starting a bootcheck; if it passes, I'll
go ahead and commit this.
----------
Estimated hours taken: 1
Fix a bug that caused the GCC back-end to generate syntactically
invalid assembler code for tests/hard_coded/typeclasses/operator_classname.m.
compiler/gcc.m:
Add set_var_decl_asm_name, for use by mlds_to_gcc.m.
(Also wrap some long lines.)
compiler/mlds_to_gcc.m:
Mangle static variable names.
Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/gcc.m,v
retrieving revision 1.20
diff -u -d -r1.20 gcc.m
--- compiler/gcc.m 2001/01/30 13:34:03 1.20
+++ compiler/gcc.m 2001/01/31 19:23:58
@@ -170,9 +170,15 @@
% This can be used for either global variables
% or local static variables.
%
- % After calling this, the caller should call set_var_decl_public
- % and/or set_var_decl_readonly, if appropriate,
+ % After calling this, the caller should call set_var_decl_public,
+ % set_var_decl_readonly, and/or set_var_asm_name, if appropriate,
% and then finish_static_var_decl.
+ %
+ % The name passed in here should be the source level name.
+ % By default, this is also used as the assembler name.
+ % If that name contains special characters that might confuse
+ % the assembler, the caller needs call set_var_asm_name with
+ % a mangled name that is free of such characters.
:- pred build_static_var_decl(var_name::in, gcc__type::in, gcc__expr::in,
gcc__var_decl::out, io__state::di, io__state::uo) is det.
@@ -188,10 +194,16 @@
% mark a variable as being accessible from outside this
% translation unit
-:- pred set_var_decl_public(gcc__var_decl::in, io__state::di, io__state::uo) is det.
+:- pred set_var_decl_public(gcc__var_decl::in, io__state::di, io__state::uo)
+ is det.
% mark a variable as read-only
-:- pred set_var_decl_readonly(gcc__var_decl::in, io__state::di, io__state::uo) is det.
+:- pred set_var_decl_readonly(gcc__var_decl::in, io__state::di, io__state::uo)
+ is det.
+
+ % set the assembler name to use for a variable.
+:- pred set_var_decl_asm_name(gcc__var_decl::in, gcc__var_name::in,
+ io__state::di, io__state::uo) is det.
%
% Routines to start/end a block.
@@ -433,7 +445,8 @@
:- pred empty_arg_list(gcc__arg_list, io__state, io__state).
:- mode empty_arg_list(out, di, uo) is det.
-:- pred cons_arg_list(gcc__expr, gcc__arg_list, gcc__arg_list, io__state, io__state).
+:- pred cons_arg_list(gcc__expr, gcc__arg_list, gcc__arg_list,
+ io__state, io__state).
:- mode cons_arg_list(in, in, out, di, uo) is det.
% build an expression for a function call
@@ -819,6 +832,12 @@
TREE_READONLY((tree) Decl) = 1;
").
+:- pragma c_code(set_var_decl_asm_name(Decl::in, AsmName::in,
+ _IO0::di, _IO::uo), [will_not_call_mercury],
+"
+ DECL_ASSEMBLER_NAME((tree) Decl) = get_identifier(AsmName);
+").
+
%
% Stuff for function declarations
%
@@ -1216,8 +1235,9 @@
InitList = (MR_Word) merc_empty_init_list();
").
-:- pragma c_code(cons_init_list(Elem::in, Init::in, InitList0::in, InitList::out,
- _IO0::di, _IO::uo), [will_not_call_mercury],
+:- pragma c_code(cons_init_list(Elem::in, Init::in,
+ InitList0::in, InitList::out, _IO0::di, _IO::uo),
+ [will_not_call_mercury],
"
InitList = (MR_Word)
merc_cons_init_list((tree) Elem, (tree) Init, (tree) InitList0);
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.29
diff -u -d -r1.29 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m 2001/01/31 18:12:14 1.29
+++ compiler/mlds_to_gcc.m 2001/01/31 19:46:38
@@ -1306,6 +1306,8 @@
GCC_InitExpr),
gcc__build_static_var_decl(VarName, GCC_Type, GCC_InitExpr,
GCC_Defn),
+ { llds_out__name_mangle(VarName, MangledVarName) },
+ gcc__set_var_decl_asm_name(GCC_Defn, MangledVarName),
add_var_decl_flags(Flags, GCC_Defn),
gcc__finish_static_var_decl(GCC_Defn)
).
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
| of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list