[m-rev.] for review: disable equiv_type special pred and type_ctor_info generation for il backend

Peter Ross peter.ross at miscrit.be
Mon Nov 11 03:12:18 AEDT 2002


On Sun, Nov 10, 2002 at 07:22:01PM +1100, Fergus Henderson wrote:
> On 09-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > fjh wrote:
> > 
> > > On 09-Nov-2002, Peter Ross <pro at missioncriticalit.com> wrote:
> > > > +  % Equivalence types are fully expanded on the IL and Java
> > > > +  % backends, so the special predicates aren't required.
> > > > + { ( Target = il ; Target = java),
> > >
> > > This test occurs twice in your diff.  It should be abstracted out into
> > > a single predicate rather than being duplicated.
> >
> > Which module should this test go in?  I was thinking code_util, do you
> > agree?
> 
> I think it should code in hlds_code_util.
> (So should much of the code currently in code_util...)
> 
> The reason to avoid putting it in code_util is that
> code_util is part of the LLDS back-end, which should
> not be referred to from the front-end.
> 

===================================================================



Estimated hours taken: 0.5
Branches: main

The java and il backends don't have a typedef mechanism so all types
must have all the equivalence types in them expanded fully, thus the
type_ctor_info and special preds for equivalence types are not needed.

compiler/make_hlds.m:
    Don't output the special predicates for types defined as
    equivalence types on the il and java backends.

compiler/type_ctor_info.m:
    Don't output the type_ctor_infos for types defined as equivalence
    types on the il and java backends.

compiler/hlds_code_util.m:
	Add the predicate are_equivalence_types_expanded.

Index: compiler/hlds_code_util.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/hlds_code_util.m,v
retrieving revision 1.1
diff -u -r1.1 hlds_code_util.m
--- compiler/hlds_code_util.m	20 Mar 2002 12:36:16 -0000	1.1
+++ compiler/hlds_code_util.m	10 Nov 2002 15:42:15 -0000
@@ -1,7 +1,25 @@
 :- module hlds__hlds_code_util.
 :- interface.
 
+:- import_module hlds__hlds_module.
+
 % XXX some of the stuff from code_util.m should be moved here.
 
 :- type hlds_code_util ---> suppress_warning_about_nothing_exported.
 
+	% Are equivalence types fully expanded on this backend?
+:- pred are_equivalence_types_expanded(module_info::in) is semidet.
+
+:- implementation.
+
+:- import_module libs__globals, libs__options.
+:- import_module bool.
+
+are_equivalence_types_expanded(ModuleInfo) :-
+	module_info_globals(ModuleInfo, Globals),
+	globals__lookup_bool_option(Globals, highlevel_data, HighLevelData),
+	HighLevelData = yes,
+	globals__get_target(Globals, Target),
+	( Target = il ; Target = java).
+
+	
Index: compiler/make_hlds.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/make_hlds.m,v
retrieving revision 1.425
diff -u -r1.425 make_hlds.m
--- compiler/make_hlds.m	24 Oct 2002 04:36:45 -0000	1.425
+++ compiler/make_hlds.m	10 Nov 2002 15:42:20 -0000
@@ -112,6 +112,7 @@
 :- import_module transform_hlds__term_util.
 :- import_module ll_backend, ll_backend__llds.
 :- import_module ll_backend__code_util, ll_backend__fact_table.
+:- import_module hlds__hlds_code_util.
 :- import_module backend_libs__export, backend_libs__foreign.
 :- import_module recompilation.
 :- import_module libs__options, libs__globals.
@@ -2102,9 +2103,19 @@
 	;
 		{ Module3 = Module0 }
 	),
-	{ construct_type(TypeCtor, Args, Type) },
-	{ add_special_preds(Module3, TVarSet, Type, TypeCtor,
-		Body, Context, Status, Module) }.
+
+		% Equivalence types are fully expanded on the IL and Java
+		% backends, so the special predicates aren't required.
+	{
+		are_equivalence_types_expanded(Module3),
+		Body = eqv_type(_)
+	->
+		Module = Module3
+	;
+		construct_type(TypeCtor, Args, Type),
+		add_special_preds(Module3, TVarSet, Type, TypeCtor,
+			Body, Context, Status, Module)
+	}.
 
 	% check_foreign_type ensures that if we are generating code for
 	% a specific backend that the foreign type has a representation
Index: compiler/type_ctor_info.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/type_ctor_info.m,v
retrieving revision 1.30
diff -u -r1.30 type_ctor_info.m
--- compiler/type_ctor_info.m	1 Aug 2002 11:52:22 -0000	1.30
+++ compiler/type_ctor_info.m	10 Nov 2002 15:42:22 -0000
@@ -62,6 +62,7 @@
 :- import_module hlds__make_tags, parse_tree__prog_data.
 :- import_module parse_tree__prog_util, parse_tree__prog_out.
 :- import_module ll_backend__code_util, hlds__special_pred.
+:- import_module hlds__hlds_code_util, hlds__special_pred.
 :- import_module check_hlds__type_util, libs__globals, libs__options.
 :- import_module backend_libs__builtin_ops, hlds__error_util.
 
@@ -100,7 +101,9 @@
 			map__lookup(TypeTable, TypeCtor, TypeDefn),
 			hlds_data__get_type_defn_body(TypeDefn, TypeBody),
 			TypeBody \= abstract_type,
-			\+ type_ctor_has_hand_defined_rtti(TypeCtor)
+			\+ type_ctor_has_hand_defined_rtti(TypeCtor),
+			( are_equivalence_types_expanded(ModuleInfo)
+					=> TypeBody \= eqv_type(_) )
 		->
 			type_ctor_info__gen_type_ctor_gen_info(TypeCtor,
 				TypeName, TypeArity, TypeDefn,
--------------------------------------------------------------------------
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