[m-dev.] GCC back-end: fix some omissions in mlds_to_gcc.m
Fergus Henderson
fjh at cs.mu.OZ.AU
Fri Jan 19 15:10:02 AEDT 2001
Estimated hours taken: 0.75
compiler/mlds_to_gcc.m:
Fix a couple of bugs / unimplemented features:
- handle pointers to functions with no (i.e. void) return type
- handle the references to `private_builtin:dummy_word'
that the MLDS code generator generates
With these changes, the GCC back-end now builds `samples/diff'
and passes the tests in samples/tests/diff.
Workspace: /home/hg/fjh/gcc-cvs/gcc/mercury
Index: compiler/mlds_to_gcc.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_gcc.m,v
retrieving revision 1.21
diff -u -d -r1.21 mlds_to_gcc.m
--- compiler/mlds_to_gcc.m 2001/01/18 15:43:42 1.21
+++ compiler/mlds_to_gcc.m 2001/01/18 16:21:16
@@ -1794,7 +1794,9 @@
build_type(mlds__func_type(Params), _, GlobalInfo, GCC_FuncPtrType) -->
{ Signature = mlds__get_func_signature(Params) },
{ Signature = mlds__func_signature(ArgTypes, RetTypes) },
- ( { RetTypes = [RetType] } ->
+ ( { RetTypes = [] } ->
+ { GCC_RetType = gcc__void_type_node }
+ ; { RetTypes = [RetType] } ->
build_type(RetType, no_size, GlobalInfo, GCC_RetType)
;
{ sorry(this_file, "multiple return types") }
@@ -2967,13 +2969,24 @@
->
{ Expr = gcc__var_expr(GlobalVarDecl) }
;
- % check if its in the private_builtin module
+ % check if it's in the private_builtin module
% and is an RTTI enumeration constant
{ mercury_private_builtin_module(PrivateBuiltin) },
{ mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName },
{ rtti_enum_const(VarName, IntVal) }
->
gcc__build_int(IntVal, Expr)
+ ;
+ % check if it's private_builtin:dummy_var
+ { mercury_private_builtin_module(PrivateBuiltin) },
+ { mercury_module_name_to_mlds(PrivateBuiltin) = ModuleName },
+ { VarName = "dummy_var" }
+ ->
+ % if so, generate an extern declaration for it, and use that.
+ { GCC_VarName = build_data_var_name(ModuleName, var(VarName)) },
+ { Type = 'MR_Word' },
+ gcc__build_extern_var_decl(GCC_VarName, Type, Decl),
+ { Expr = gcc__var_expr(Decl) }
;
{ unexpected(this_file, "undeclared variable: " ++
build_qualified_name(Name)) }
--
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