* Q: inlining @ 1996-06-15 0:00 Hannes Haug 1996-06-15 0:00 ` Jon S Anthony ` (4 more replies) 0 siblings, 5 replies; 12+ messages in thread From: Hannes Haug @ 1996-06-15 0:00 UTC (permalink / raw) Hi, I'm new to Ada and have a question on inlining. Does inlining work across compilation units ? In C I can write the function definition in a header file. How can I do this in Ada ? Thanks - hannes ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 Q: inlining Hannes Haug @ 1996-06-15 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Robert Dewar ` (2 more replies) 1996-06-16 0:00 ` Hannes Haug ` (3 subsequent siblings) 4 siblings, 3 replies; 12+ messages in thread From: Jon S Anthony @ 1996-06-15 0:00 UTC (permalink / raw) In article <uvv20jh9j7p.fsf@chaq.informatik.uni-tuebingen.de> Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: > Hi, > > I'm new to Ada and have a question on inlining. Does > inlining work across compilation units ? In C I can It can, yes. I'm not sure if this is working in GNAT 3.05 yet or not. > write the function definition in a header file. How > can I do this in Ada ? In a package specification. In fact, this is virtually a requirement to getting any "real" work done. You might want to check out the following for online tutorials, references, a good Ada for C++ programmers paper, etc: http://lglwww.epfl.ch/Ada/ /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 ` Jon S Anthony @ 1996-06-16 0:00 ` Robert Dewar 1996-06-17 0:00 ` Tucker Taft 1996-06-18 0:00 ` Jon S Anthony 2 siblings, 0 replies; 12+ messages in thread From: Robert Dewar @ 1996-06-16 0:00 UTC (permalink / raw) Jon Anthony said (of inter-unit inlining): "It can, yes. I'm not sure if this is working in GNAT 3.05 yet or not." Certainly it is! Once again Robert consults his secret source of GNAT information (namely the standard documentation in gnatinfo.txt :-) and provides the full answer: Inlining of Subprograms ----------------------- A call to a subprogram in the current unit is inlined if all the following conditions are met: o The optimization level is at least -O1 o The called subprogram is suitable for inlining. It must be small enough and not contain nested subprograms or anything else that GCC cannot support in inlined subprograms. o The call occurs after the definition of the body of the subprogram. o Either pragma Inline applies to the subprogram, or it is very small and automatic inlining (optimization level -O3) is specified. Calls to subprograms in with'ed units are normally not inlined. To achieve this level of inlining, the following conditions must be true. o The optimization level is at least -O1 o The called subprogram is suitable for inlining. It must be small enough and not contain nested subprograms or anything else that GCC cannot support in inlined subprograms. o The call appears in a body (not in a package spec). o There is a pragma Inline for the subprogram o The -gnatn switch is used in the GCC command line Note that specifying the -gnatn switch causes additional compilation dependencies. Consider the following: package R is procedure Q; pragma Inline Q; end R; package body R is ... end R; with R; procedure Main is begin ... R.Q; end Main; With the default behavior (no -gnatn switch specified), the compilation of the Main procedure depends only on its own source, main.adb, and the spec of the package in file r.ads. This means that editing the body of R does not require recompiling Main. On the other hand, the call R.Q is not inlined under these circumstances. If the -gnatn switch is present when Main is compiled, then the call will be inlined if the body of Q is small enough, but now Main depends on the body of R in r.adb as well as the spec. This means that if the body is edited, then the main program must be recompiled. Note that this extra dependency occurs whether or not the call is in fact inlined by GCC. Note: the GCC switch -fno-inline can be used to prevent all inlining. This switch overrides all other conditions, and ensures that no inlining occurs. The extra dependencies resulting from -gnatn will still be active, even if the -fno-inline switch is used. ------------------ All this is in the section: PERFORMANCE CONSIDERATIONS which contains lots of useful stuff. In fact there is all sorts of useful stuff in gnatinfo.txt, recommended reading for all GNAT users! ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Robert Dewar @ 1996-06-17 0:00 ` Tucker Taft 1996-06-18 0:00 ` Jon S Anthony 2 siblings, 0 replies; 12+ messages in thread From: Tucker Taft @ 1996-06-17 0:00 UTC (permalink / raw) Jon S Anthony (jsa@organon.com) wrote: : In article <uvv20jh9j7p.fsf@chaq.informatik.uni-tuebingen.de> : Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: : > Hi, : > : > I'm new to Ada and have a question on inlining. Does : > inlining work across compilation units ? In C I can : It can, yes. I'm not sure if this is working in GNAT 3.05 yet or not. : > write the function definition in a header file. How : > can I do this in Ada ? : In a package specification. In fact, this is virtually a requirement : to getting any "real" work done. This answer could be confusing. In C++, the function *definition* usually needs to be in the header file for inlining to work. In Ada, only the function *declaration* is allowed in the package spec. The function body ("definition" in C parlance) goes in the package body, even if there is a pragma inline on the function declaration. The Ada compiler needs to be smart enough to find the function body when it is needed. Most Ada compilers do this (I don't know of any that don't, other than older versions of GNAT). : You might want to check out the following for online tutorials, : references, a good Ada for C++ programmers paper, etc: : http://lglwww.epfl.ch/Ada/ : Jon Anthony : Organon Motives, Inc. : 1 Williston Road, Suite 4 : Belmont, MA 02178 : 617.484.3383 : jsa@organon.com -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Robert Dewar 1996-06-17 0:00 ` Tucker Taft @ 1996-06-18 0:00 ` Jon S Anthony 2 siblings, 0 replies; 12+ messages in thread From: Jon S Anthony @ 1996-06-18 0:00 UTC (permalink / raw) In article <Dt4F36.1pG.0.-s@inmet.camb.inmet.com> stt@henning.camb.inmet.com (Tucker Taft) writes: > Jon S Anthony (jsa@organon.com) wrote: > : In article <uvv20jh9j7p.fsf@chaq.informatik.uni-tuebingen.de> > : Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: > > : > Hi, > : > > : > I'm new to Ada and have a question on inlining. Does > : > inlining work across compilation units ? In C I can > > : It can, yes. I'm not sure if this is working in GNAT 3.05 yet or not. > > > : > write the function definition in a header file. How > : > can I do this in Ada ? > > : In a package specification. In fact, this is virtually a requirement > : to getting any "real" work done. > > This answer could be confusing. In C++, the function *definition* > usually needs to be in the header file for inlining to work. In Ada, > only the function *declaration* is allowed in the package spec. The I see that I have _COMPLETELY_ misunderstood the question. Duh! I apologize to all... /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 Q: inlining Hannes Haug 1996-06-15 0:00 ` Jon S Anthony @ 1996-06-16 0:00 ` Hannes Haug 1996-06-18 0:00 ` Jon S Anthony ` (2 subsequent siblings) 4 siblings, 0 replies; 12+ messages in thread From: Hannes Haug @ 1996-06-16 0:00 UTC (permalink / raw) >>>>> "Jon" == Jon S Anthony <jsa@organon.com> writes: Jon> In article <uvv20jh9j7p.fsf@chaq.informatik.uni-tuebingen.de> Jon> Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: >> Hi, >> >> I'm new to Ada and have a question on inlining. Does inlining >> work across compilation units ? In C I can Jon> It can, yes. I'm not sure if this is working in GNAT 3.05 Jon> yet or not. I know that this is possible. I just wanted to know if compilers actually do it. I finally found the option for GNAT: -gnatn. >> write the function definition in a header file. How can I do >> this in Ada ? Jon> In a package specification. In fact, this is virtually a Jon> requirement to getting any "real" work done. I know. This made me look at Ada. It's really ugly to put all the stuff in header files. - hannes ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 Q: inlining Hannes Haug 1996-06-15 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Hannes Haug @ 1996-06-18 0:00 ` Jon S Anthony 1996-06-19 0:00 ` Tucker Taft 1996-06-20 0:00 ` Hannes Haug 1996-06-24 0:00 ` Hannes Haug 4 siblings, 1 reply; 12+ messages in thread From: Jon S Anthony @ 1996-06-18 0:00 UTC (permalink / raw) In article <uvvd92zuczi.fsf@chaq.informatik.uni-tuebingen.de> Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: > >> I'm new to Ada and have a question on inlining. Does inlining > >> work across compilation units ? In C I can > > Jon> It can, yes. I'm not sure if this is working in GNAT 3.05 > Jon> yet or not. > > I know that this is possible. I just wanted to know if compilers actually do > it. I finally found the option for GNAT: -gnatn. Great. There were Ada83 compilers that did this also. Does anyone know if ObjectAda/AdaMagic does this? > >> write the function definition in a header file. How can I do > >> this in Ada ? > > Jon> In a package specification. In fact, this is virtually a > Jon> requirement to getting any "real" work done. > > I know. This made me look at Ada. It's really ugly to put all the stuff > in header files. Oh. I guess I misunderstood that you already knew this... /Jon -- Jon Anthony Organon Motives, Inc. 1 Williston Road, Suite 4 Belmont, MA 02178 617.484.3383 jsa@organon.com ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-18 0:00 ` Jon S Anthony @ 1996-06-19 0:00 ` Tucker Taft 1996-06-20 0:00 ` Robert Dewar 0 siblings, 1 reply; 12+ messages in thread From: Tucker Taft @ 1996-06-19 0:00 UTC (permalink / raw) Jon S Anthony (jsa@organon.com) wrote: : In article <uvvd92zuczi.fsf@chaq.informatik.uni-tuebingen.de> : Hannes Haug <Hannes.Haug@Student.Uni-Tuebingen.de> writes: : > >> I'm new to Ada and have a question on inlining. Does inlining : > >> work across compilation units ? In C I can : > : > Jon> It can, yes. I'm not sure if this is working in GNAT 3.05 : > Jon> yet or not. : > : > I know that this is possible. I just wanted to know if compilers actually do : > it. I finally found the option for GNAT: -gnatn. : Great. There were Ada83 compilers that did this also. Does anyone : know if ObjectAda/AdaMagic does this? Yes, ObjectAda/AdaMagic does inlining across compilation units. It requires that the source file containing the body already be "registered" in the program library when you compile a call to the subprogram. : Jon Anthony : Organon Motives, Inc. : 1 Williston Road, Suite 4 : Belmont, MA 02178 : 617.484.3383 : jsa@organon.com -Tucker Taft stt@inmet.com http://www.inmet.com/~stt/ Intermetrics, Inc. Cambridge, MA USA ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-19 0:00 ` Tucker Taft @ 1996-06-20 0:00 ` Robert Dewar 0 siblings, 0 replies; 12+ messages in thread From: Robert Dewar @ 1996-06-20 0:00 UTC (permalink / raw) Tucker said "Yes, ObjectAda/AdaMagic does inlining across compilation units. It requires that the source file containing the body already be "registered" in the program library when you compile a call to the subprogram." Tuck, you might want to emphasize that this registration has nothing to do with compilation, so, as is the case with GNAT, Ada Magic allows completely general inlining without having to worry about the order in which things are compiled (at least I assume this is the case!) Note that the registration in Ada Magic is essentially similar to placing Source_File_Name pragmas in gnat.adc in GNAT, the only difference is that in GNAT you can if you like avoid this step by using the default file names (which is what most, but not all, GNAT users prefer to do). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 Q: inlining Hannes Haug ` (2 preceding siblings ...) 1996-06-18 0:00 ` Jon S Anthony @ 1996-06-20 0:00 ` Hannes Haug 1996-06-20 0:00 ` Robert Dewar 1996-06-24 0:00 ` Hannes Haug 4 siblings, 1 reply; 12+ messages in thread From: Hannes Haug @ 1996-06-20 0:00 UTC (permalink / raw) >>>>> "Robert" == Robert Dewar <dewar@cs.nyu.edu> writes: Robert> [...] Robert> In fact there is all sorts of useful stuff in gnatinfo.txt, Robert> recommended reading for all GNAT users! Gnat.info would be even better ;-) But there is a lot of stuff for which you have to read the sources of the lib. How to mix Ada and C I/O ? That's implementation specific and should be in the docs. It would be nice if all that goes beyond ARM would be documented. And a TODO would be fine. Will support for machine intrinsic subprograms be available soon ? Perhaps I need "ldstub" and "ta" on Sparc. -hannes ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-20 0:00 ` Hannes Haug @ 1996-06-20 0:00 ` Robert Dewar 0 siblings, 0 replies; 12+ messages in thread From: Robert Dewar @ 1996-06-20 0:00 UTC (permalink / raw) Hannes asks "Gnat.info would be even better ;-) But there is a lot of stuff for which you have to read the sources of the lib. How to mix Ada and C I/O ? That's implementation specific and should be in the docs. It would be nice if all that goes beyond ARM would be documented. And a TODO would be fine. Will support for machine intrinsic subprograms be available soon ? Perhaps I need "ldstub" and "ta" on Sparc." Yes, there is a lot more documentatoin needed, for some idea, see the SGI GNAT manuals, which are the model for the full GNAT documenation currently being written. Intrinsics will be available soon. (meanwhile you can always write a C function that uses the gcc instrinsic feature). ^ permalink raw reply [flat|nested] 12+ messages in thread
* Re: Q: inlining 1996-06-15 0:00 Q: inlining Hannes Haug ` (3 preceding siblings ...) 1996-06-20 0:00 ` Hannes Haug @ 1996-06-24 0:00 ` Hannes Haug 4 siblings, 0 replies; 12+ messages in thread From: Hannes Haug @ 1996-06-24 0:00 UTC (permalink / raw) >>>>> "Robert" == Robert Dewar <dewar@cs.nyu.edu> writes: Robert> Hannes asks "Gnat.info would be even better ;-) But there Robert> is a lot of stuff for which you have to read the sources Robert> of the lib. How to mix Ada and C I/O ? That's Robert> implementation specific and should be in the docs. It Robert> would be nice if all that goes beyond ARM would be Robert> documented. And a TODO would be fine. Will support for Robert> machine intrinsic subprograms be available soon ? Perhaps Robert> I need "ldstub" and "ta" on Sparc." Robert> Yes, there is a lot more documentatoin needed, for some Robert> idea, see the SGI GNAT manuals, which are the model for Robert> the full GNAT documenation currently being written. Where can I find it? I looked at the Ada FAQs, GNAT docs and www.gnat.com. But I found no hint. Robert> Intrinsics will be available soon. (meanwhile you can Robert> always write a C function that uses the gcc instrinsic Robert> feature). I'm looking forward to it. But C isn't an option. Ldstub has to be instrinsic. I'd like to use it for fast synchronization. It think gnat uses mutexes or semaphores for synchronization. That's quite slow. It would slow down consing. I have to care about this at the low level. Otherwise I'd have to care about this stuff at the high level, i.e. algorithms. :-( Perhaps gnat-4 will have faster synchronization? Tasks seem to be quite expensive, too. But I think my demands (not only in this area) are a little bit unusual for Ada. -hannes ^ permalink raw reply [flat|nested] 12+ messages in thread
end of thread, other threads:[~1996-06-24 0:00 UTC | newest] Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed) -- links below jump to the message on this page -- 1996-06-15 0:00 Q: inlining Hannes Haug 1996-06-15 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Robert Dewar 1996-06-17 0:00 ` Tucker Taft 1996-06-18 0:00 ` Jon S Anthony 1996-06-16 0:00 ` Hannes Haug 1996-06-18 0:00 ` Jon S Anthony 1996-06-19 0:00 ` Tucker Taft 1996-06-20 0:00 ` Robert Dewar 1996-06-20 0:00 ` Hannes Haug 1996-06-20 0:00 ` Robert Dewar 1996-06-24 0:00 ` Hannes Haug
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox