[m-rev.] diff: mlds_to_c.m: avoid unnecessary casts
Fergus Henderson
fjh at cs.mu.OZ.AU
Wed Jun 27 21:02:12 AEST 2001
I'm still running a bootcheck for this one,
but if it passes then I'll go ahead and commit it.
Estimated hours taken: 2
Branches: main, release
compiler/mlds_to_c.m:
Avoid generating some unnecessary casts.
This avoids a problem where we were generating non-ANSI code
that `lcc' rejected because it contained casts from pointers
to integers (and then back to pointers again) in static
initializers.
Workspace: /home/mars/fjh/ws1/mercury
Index: compiler/mlds_to_c.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/mlds_to_c.m,v
retrieving revision 1.89
diff -u -d -r1.89 mlds_to_c.m
--- compiler/mlds_to_c.m 2001/06/22 09:14:35 1.89
+++ compiler/mlds_to_c.m 2001/06/27 10:26:01
@@ -2686,7 +2686,7 @@
****/
mlds_output_rval(mkword(Tag, Rval)) -->
- io__write_string("(MR_Word) MR_mkword("),
+ io__write_string("MR_mkword("),
mlds_output_tag(Tag),
io__write_string(", "),
mlds_output_rval(Rval),
@@ -2741,6 +2741,12 @@
mlds_output_boxed_rval(Type, Exprn) -->
(
+ { Exprn = unop(cast(OtherType), InnerExprn) },
+ { Type = OtherType }
+ ->
+ % avoid unnecessary double-casting -- strip away the inner cast
+ mlds_output_boxed_rval(Type, InnerExprn)
+ ;
{ Type = mlds__mercury_type(term__functor(term__atom("float"),
[], _), _)
; Type = mlds__native_float_type
--
Fergus Henderson <fjh at cs.mu.oz.au> | "I have always known that the pursuit
The University of Melbourne | of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh> | -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-reviews mailing list
post: mercury-reviews at cs.mu.oz.au
administrative address: owner-mercury-reviews at cs.mu.oz.au
unsubscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-reviews-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the reviews
mailing list