[m-dev.] for review: bootstrap with DEC Alpha `cc'
Fergus Henderson
fjh at cs.mu.OZ.AU
Thu Nov 23 03:44:25 AEDT 2000
Estimated hours taken: 6
Various changes to get things to work with the DEC Alpha OSF1 C
compiler in grades hlc.gc and none.gc.
compiler/equiv_type.m:
Change the code for equiv_type__replace_item_in_item_list
so that it is tail recursive, by using an accumulator and
calling list__reverse at the end. This is needed to avoid
a stack overflow (with the default 2M stack limit) when
bootstrapping with the DEC Alpha OSF1 C compiler in grade hlc.gc.
The dec-alpha-osf3.2 `cc' was generating code that used
280 bytes of space per stack frame for this procedure.
compiler/fact_table.m:
Ensure that there is a statement after every label, since
ANSI/ISO C doesn't allow labels at the end of a block without
an empty statement following them.
library/exception.m:
Use a different name for the local typedef in different functions.
This allows the code to work with the DEC Alpha OSF1 C in
`-std' ("ANSI C with popular extensions") mode, rather than
the `-std1' (strict ANSI/ISO C). The supposedly popular
extension here is treating local typedefs as if they were
global. It's probably not worth expending much effort to
cater for non-ANSI modes of compilers, but in this case the
effort is small and arguably the different names are more
descriptive anyway.
runtime/mercury.c:
Avoid the use of a GNU C extension (returning void values).
runtime/mercury_deep_copy.c:
Change `#undef FOO(ARGS)' to `#undef FOO', since the former
is not allowed in ANSI/ISO C.
trace/mercury_trace_internal.c:
Change `#endif FOO' to `#endif /* FOO */', since the former
is not allowed in ANSI/ISO C.
tests/hard_coded/pragma_c_code.m:
tests/hard_coded/type_tables.m:
Use `\\n' rather than `\n' for newlines in strings inside
`pragma c_code'. This is needed because the first level of
slashes gets processed when converting from Mercury to C, and
ANSI/ISO C doesn't allow literal newlines in strings.
Workspace: /home/mercury0/fjh/mercury
Index: compiler/equiv_type.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/equiv_type.m,v
retrieving revision 1.23
diff -u -d -r1.23 equiv_type.m
--- compiler/equiv_type.m 2000/11/01 05:11:50 1.23
+++ compiler/equiv_type.m 2000/11/21 10:30:47
@@ -53,13 +53,14 @@
{ map__init(EqvMap0) },
{ equiv_type__build_eqv_map(Items0, EqvMap0, EqvMap) },
{ equiv_type__replace_in_item_list(Items0, EqvMap,
- Items, [], CircularTypeList0) },
- { list__reverse(CircularTypeList0, CircularTypeList) },
+ [], RevItems, [], RevCircularTypeList) },
+ { list__reverse(RevItems, Items) },
(
- { CircularTypeList = [] }
+ { RevCircularTypeList = [] }
->
{ CircularTypes = no }
;
+ { list__reverse(RevCircularTypeList, CircularTypeList) },
equiv_type__report_circular_types(CircularTypeList),
{ CircularTypes = yes },
io__set_exit_status(1)
@@ -88,24 +89,28 @@
% follow perform substitution of equivalence types on <foo>s.
:- pred equiv_type__replace_in_item_list(list(item_and_context), eqv_map,
- list(item_and_context), list(item_and_context), list(item_and_context)).
-:- mode equiv_type__replace_in_item_list(in, in, out, in, out) is det.
+ list(item_and_context), list(item_and_context),
+ list(item_and_context), list(item_and_context)).
+:- mode equiv_type__replace_in_item_list(in, in, in, out, in, out) is det.
-equiv_type__replace_in_item_list([], _, [], Circ, Circ).
-equiv_type__replace_in_item_list([Item0 - Context | Items0], EqvMap,
- [Item - Context | Items], Circ0, Circ) :-
- ( equiv_type__replace_in_item(Item0, EqvMap, Item1, ContainsCirc) ->
- Item = Item1,
+equiv_type__replace_in_item_list([], _, Items, Items, Circ, Circ).
+equiv_type__replace_in_item_list([ItemAndContext0 | Items0], EqvMap,
+ ReplItems0, ReplItems, Circ0, Circ) :-
+ ItemAndContext0 = Item0 - Context,
+ ( equiv_type__replace_in_item(Item0, EqvMap, Item, ContainsCirc) ->
+ ItemAndContext = Item - Context,
( ContainsCirc = yes ->
- Circ1 = [Item - Context | Circ0]
+ Circ1 = [ItemAndContext | Circ0]
;
Circ1 = Circ0
)
;
- Item = Item0,
+ ItemAndContext = ItemAndContext0,
Circ1 = Circ0
),
- equiv_type__replace_in_item_list(Items0, EqvMap, Items, Circ1, Circ).
+ ReplItems1 = [ItemAndContext | ReplItems0],
+ equiv_type__replace_in_item_list(Items0, EqvMap, ReplItems1, ReplItems,
+ Circ1, Circ).
:- pred equiv_type__replace_in_item(item, eqv_map, item, bool).
:- mode equiv_type__replace_in_item(in, in, out, out) is semidet.
Index: compiler/fact_table.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/fact_table.m,v
retrieving revision 1.33
diff -u -d -r1.33 fact_table.m
--- compiler/fact_table.m 2000/10/27 06:26:49 1.33
+++ compiler/fact_table.m 2000/11/22 05:30:04
@@ -2686,6 +2686,7 @@
failure_code_%s:
SUCCESS_INDICATOR = FALSE;
skip_%s:
+ ;
",
string__format(SuccessCodeTemplate, [s(LabelName), s(LabelName),
s(LabelName), s(LabelName)], SuccessCode),
@@ -2722,9 +2723,10 @@
FailCodeTemplate = "
goto skip_%s;
- failure_code_%s:
+ failure_code_%s:
SUCCESS_INDICATOR = FALSE;
- skip_%s:
+ skip_%s:
+ ;
",
string__format(FailCodeTemplate, [s(LabelName), s(LabelName),
s(LabelName)], FailCode),
Index: library/exception.m
===================================================================
RCS file: /home/mercury1/repository/mercury/library/exception.m,v
retrieving revision 1.32
diff -u -d -r1.32 exception.m
--- library/exception.m 2000/11/05 12:04:12 1.32
+++ library/exception.m 2000/11/21 06:22:34
@@ -533,8 +533,8 @@
ML_call_goal_det(MR_Mercury_Type_Info type_info,
MR_Pred closure, MR_Box *result)
{
- typedef void FuncType(void *, MR_Box *);
- FuncType *code = (FuncType *)
+ typedef void DetFuncType(void *, MR_Box *);
+ DetFuncType *code = (DetFuncType *)
MR_field(MR_mktag(0), closure, (MR_Integer) 1);
(*code)((void *) closure, result);
}
@@ -543,8 +543,8 @@
ML_call_goal_semi(MR_Mercury_Type_Info type_info,
MR_Pred closure, MR_Box *result)
{
- typedef bool FuncType(void *, MR_Box *);
- FuncType *code = (FuncType *)
+ typedef bool SemidetFuncType(void *, MR_Box *);
+ SemidetFuncType *code = (SemidetFuncType *)
MR_field(MR_mktag(0), closure, (MR_Integer) 1);
return (*code)((void *) closure, result);
}
@@ -555,8 +555,8 @@
ML_call_goal_non(MR_Mercury_Type_Info type_info,
MR_Pred closure, MR_Box *result, MR_NestedCont cont)
{
- typedef void FuncType(void *, MR_Box *, MR_NestedCont);
- FuncType *code = (FuncType *)
+ typedef void NondetFuncType(void *, MR_Box *, MR_NestedCont);
+ NondetFuncType *code = (NondetFuncType *)
MR_field(MR_mktag(0), closure, (MR_Integer) 1);
(*code)((void *) closure, result, cont);
}
@@ -567,8 +567,8 @@
ML_call_goal_non(MR_Mercury_Type_Info type_info,
MR_Pred closure, MR_Box *result, MR_Cont cont, void *cont_env)
{
- typedef void FuncType(void *, MR_Box *, MR_Cont, void *);
- FuncType *code = (FuncType *)
+ typedef void NondetFuncType(void *, MR_Box *, MR_Cont, void *);
+ NondetFuncType *code = (NondetFuncType *)
MR_field(MR_mktag(0), closure, (MR_Integer) 1);
(*code)((void *) closure, result, cont, cont_env);
}
@@ -581,8 +581,8 @@
ML_call_handler_det(MR_Mercury_Type_Info type_info,
MR_Pred closure, MR_Univ exception, MR_Box *result)
{
- typedef void FuncType(void *, MR_Box, MR_Box *);
- FuncType *code = (FuncType *)
+ typedef void HandlerFuncType(void *, MR_Box, MR_Box *);
+ HandlerFuncType *code = (HandlerFuncType *)
MR_field(MR_mktag(0), closure, (MR_Integer) 1);
(*code)((void *) closure, (MR_Box) exception, result);
}
Index: runtime/mercury.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury.c,v
retrieving revision 1.15
diff -u -d -r1.15 mercury.c
--- runtime/mercury.c 2000/11/14 16:28:33 1.15
+++ runtime/mercury.c 2000/11/20 19:24:46
@@ -623,7 +623,7 @@
return;
}
- return mercury__builtin__compare_3_p_0((MR_Mercury_Type_Info) typeinfo_x,
+ mercury__builtin__compare_3_p_0((MR_Mercury_Type_Info) typeinfo_x,
result, (MR_Box) value_x, (MR_Box) value_y);
}
Index: runtime/mercury_deep_copy.c
===================================================================
RCS file: /home/mercury1/repository/mercury/runtime/mercury_deep_copy.c,v
retrieving revision 1.20
diff -u -d -r1.20 mercury_deep_copy.c
--- runtime/mercury_deep_copy.c 2000/11/07 08:58:33 1.20
+++ runtime/mercury_deep_copy.c 2000/11/20 18:49:55
@@ -27,7 +27,7 @@
#define in_range(X) (lower_limit == NULL || \
((X) >= lower_limit && (X) <= upper_limit))
-#undef in_traverse_range(X)
+#undef in_traverse_range
#define in_traverse_range(X) (FALSE)
#undef maybeconst
Index: tests/hard_coded/pragma_c_code.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/pragma_c_code.m,v
retrieving revision 1.5
diff -u -d -r1.5 pragma_c_code.m
--- tests/hard_coded/pragma_c_code.m 1997/02/12 03:49:03 1.5
+++ tests/hard_coded/pragma_c_code.m 2000/11/22 05:25:07
@@ -37,7 +37,7 @@
:- pred c_write_integer(int::in, io__state::di, io__state::uo) is det.
:- pragma(c_code, c_write_integer(Int::in, IO0::di, IO::uo), "
- printf(""%ld\n"", (long) Int);
+ printf(""%ld\\n"", (long) Int);
IO = IO0;
").
@@ -48,7 +48,7 @@
:- pred c_write_float(float::in, io__state::di, io__state::uo) is det.
:- pragma(c_code, c_write_float(X::in, IO0::di, IO::uo), "
- printf(""%.1f\n"", X);
+ printf(""%.1f\\n"", X);
IO = IO0;
").
@@ -57,6 +57,6 @@
:- pred c_write_cosine(float::in, io__state::di, io__state::uo) is det.
:- pragma(c_code, c_write_cosine(X::in, IO0::di, IO::uo), "
- printf(""%.3f\n"", cos(X));
+ printf(""%.3f\\n"", cos(X));
IO = IO0;
").
Index: tests/hard_coded/type_tables.m
===================================================================
RCS file: /home/mercury1/repository/tests/hard_coded/type_tables.m,v
retrieving revision 1.2
diff -u -d -r1.2 type_tables.m
--- tests/hard_coded/type_tables.m 2000/10/13 02:40:32 1.2
+++ tests/hard_coded/type_tables.m 2000/11/22 10:47:10
@@ -26,7 +26,7 @@
tc1 = MR_lookup_type_ctor_info(""list"", ""list"", 1);
tc2 = MR_lookup_type_ctor_info(""type_tables"", ""list"", 0);
- printf(""%s %s\n"", tc1->type_ctor_module_name, tc1->type_ctor_name);
- printf(""%s %s\n"", tc2->type_ctor_module_name, tc2->type_ctor_name);
+ printf(""%s %s\\n"", tc1->type_ctor_module_name, tc1->type_ctor_name);
+ printf(""%s %s\\n"", tc2->type_ctor_module_name, tc2->type_ctor_name);
IO = IO0;
").
Index: trace/mercury_trace_internal.c
===================================================================
RCS file: /home/mercury1/repository/mercury/trace/mercury_trace_internal.c,v
retrieving revision 1.87
diff -u -d -r1.87 mercury_trace_internal.c
--- trace/mercury_trace_internal.c 2000/11/18 11:28:50 1.87
+++ trace/mercury_trace_internal.c 2000/11/20 18:51:21
@@ -226,7 +226,7 @@
if (MR_trace_decl_mode != MR_TRACE_INTERACTIVE) {
return MR_trace_decl_debug(cmd, event_info);
}
-#endif MR_USE_DECLARATIVE_DEBUGGER
+#endif /* MR_USE_DECLARATIVE_DEBUGGER */
/*
** We want to make sure that the Mercury code used to implement some
--
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