[m-dev.] for review: GCC back-end interface

Fergus Henderson fjh at cs.mu.OZ.AU
Tue Jan 9 23:49:45 AEDT 2001


On 09-Jan-2001, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 09-Jan-2001, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > Is this broken at the moment?  I see no changes to inlining.m to disable
> > inlining of pragma_foreign -- if you set your preferred backend foreign
> > language to C, you will probably get inlining of foreign C by default.
> 
> Sorry, I did change inlining.m -- I forgot to include that change in
> the set that I posted.  I'll post that separately.

Estimated hours taken: 0.5

mercury/compiler/inlining.m:
	Don't inline foreign_code unless it is appropriate
	for the target language.  Define a table of which
	languages it is appropriate to inline for each target.

Workspace: /home/pgrad/fjh/ws/gcc/mercury
Index: inlining.m
===================================================================
RCS file: /home/mercury1/repository/mercury/compiler/inlining.m,v
retrieving revision 1.94.4.1
diff -u -d -u -r1.94.4.1 inlining.m
--- inlining.m	2000/12/29 06:09:46	1.94.4.1
+++ inlining.m	2001/01/01 19:34:59
@@ -835,12 +835,16 @@
 		( Detism = nondet ; Detism = multidet )
 	),
 
-	% don't inline foreign_code if we are generating IL
+	% only inline foreign_code if it is appropriate for
+	% the target language
 	module_info_globals(ModuleInfo, Globals),
 	globals__get_target(Globals, Target),
-	\+ (
-		Target = il,
-		CalledGoal = pragma_foreign_code(_,_,_,_,_,_,_) - _
+	(
+		CalledGoal = pragma_foreign_code(ForeignAttributes,
+			_,_,_,_,_,_) - _,
+		foreign_language(ForeignAttributes, ForeignLanguage)
+	=>
+		ok_to_inline_language(ForeignLanguage, Target)
 	),
 
 	% Don't inline memoed Aditi predicates.
@@ -865,6 +869,20 @@
 	;
 		set__member(proc(PredId, ProcId), InlinedProcs)
 	).
+
+	% Succeed iff it is appropriate to inline `pragma foreign_code'
+	% in the specified language for the given compilation_target.
+	% Generally that will only be the case if the target directly
+	% supports inline code in that language.
+:- pred ok_to_inline_language(foreign_language::in, compilation_target::in)
+	is semidet.
+ok_to_inline_language(c, c).
+% ok_to_inline_language(java, java). % foreign_language = java not implemented
+% ok_to_inline_language(asm, asm).   % foreign_language = asm not implemented
+% We could define a language "C/C++" (c_slash_cplusplus) which was the
+% intersection of "C" and "C++", and then we'd have
+%	ok_to_inline_language(c_slash_cplusplus, c).
+%	ok_to_inline_language(c_slash_cplusplus, cplusplus).
 
 %-----------------------------------------------------------------------------%
 %-----------------------------------------------------------------------------%
-- 
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