* pragma Inline in generic
@ 2005-07-20 17:10 nicolas.b
2005-07-20 19:40 ` Manuel G. R.
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: nicolas.b @ 2005-07-20 17:10 UTC (permalink / raw)
This is my program (a short example) :
-- A generic package
generic
type T_Real is digits <>;
Default_Real : T_Real;
package Toto is
type T_Toto is private;
function Length (Toto : in T_Toto) return T_Real;
pragma Inline (Length);
private
type T_Toto is record
Length : T_Real := Default_Real;
end record;
end Toto;
-- the implementation :
package body Toto is
function Length (Toto : in T_Toto) return T_Real is
begin
return Toto.Length;
end Length;
end Toto;
-- The instanciation :
with Toto;
pragma Elaborate_All (Toto);
package Test is
package Instance_Toto is new Toto (
T_Real => Float,
Default_Real => 0.0);
procedure Test;
end Test;
-- the implementation of this instanciation :
package body Test is
procedure Test is
T : Instance_Toto.T_Toto;
L : float;
begin
L := Instance_Toto.Length (T);
end Test;
end Test;
I use gnat 5.02a1 : function "Length" seems not be Inline in generate
code. Why? Thank you for your answer.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pragma Inline in generic
2005-07-20 17:10 pragma Inline in generic nicolas.b
@ 2005-07-20 19:40 ` Manuel G. R.
2005-07-20 20:45 ` Damien
2005-07-27 13:52 ` Simon Wright
2 siblings, 0 replies; 5+ messages in thread
From: Manuel G. R. @ 2005-07-20 19:40 UTC (permalink / raw)
Try the -gnatn switch. GNAT by default does not inline subprograms calls
outside of the package where they are defined.
-gnatn
Activate inlining across unit boundaries for subprograms for which
pragma `inline' is specified.
nicolas.b wrote:
> I use gnat 5.02a1 : function "Length" seems not be Inline in generate
> code. Why? Thank you for your answer.
>
--
Ada programming tutorial: http://en.wikibooks.org/wiki/Programming:Ada
Tutorial de programaci�n en Ada:
http://es.wikibooks.org/wiki/Programaci%C3%B3n_en_Ada
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pragma Inline in generic
2005-07-20 17:10 pragma Inline in generic nicolas.b
2005-07-20 19:40 ` Manuel G. R.
@ 2005-07-20 20:45 ` Damien
2005-07-20 20:51 ` Damien
2005-07-27 13:52 ` Simon Wright
2 siblings, 1 reply; 5+ messages in thread
From: Damien @ 2005-07-20 20:45 UTC (permalink / raw)
nicolas.b a �crit :
>
> I use gnat 5.02a1 : function "Length" seems not be Inline in generate
> code. Why? Thank you for your answer.
>
I have never used gnat 5.02a1 but it must certainly behave like other
versions of gnat with regard to inlining. Inlining depends on compiler
options. IIRC, one needs -O2 optimisation level (at least) to obtain
inlining.
The best is to read gnat user guide and search for inline.
Damien
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pragma Inline in generic
2005-07-20 20:45 ` Damien
@ 2005-07-20 20:51 ` Damien
0 siblings, 0 replies; 5+ messages in thread
From: Damien @ 2005-07-20 20:51 UTC (permalink / raw)
gnat 3.15p user guide contains:
3.2.13 Subprogram Inlining Control
-gnatn
The n here is intended to suggest the first syllable of the word
"inline". GNAT recognizes and processes Inline pragmas. However, for the
inlining to actually occur, optimization must be enabled. To enable
inlining across unit boundaries, this is, inlining a call in one unit of
a subprogram declared in a with'ed unit, you must also specify this
switch. In the absence of this switch, GNAT does not attempt inlining
across units and does not need to access the bodies of subprograms for
which pragma Inline is specified if they are not in the current unit.
If you specify this switch the compiler will access these bodies,
creating an extra source dependency for the resulting object file, and
where possible, the call will be inlined. For further details on when
inlining is possible see See section 25.4 Inlining of Subprograms.
-gnatN
The front end inlining activated by this switch is generally more
extensive, and quite often more effective than the standard -gnatn
inlining mode. It will also generate additional dependencies.
As indicated, you should also read section 25.4 Inlining of Subprograms.
Damien
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: pragma Inline in generic
2005-07-20 17:10 pragma Inline in generic nicolas.b
2005-07-20 19:40 ` Manuel G. R.
2005-07-20 20:45 ` Damien
@ 2005-07-27 13:52 ` Simon Wright
2 siblings, 0 replies; 5+ messages in thread
From: Simon Wright @ 2005-07-27 13:52 UTC (permalink / raw)
"nicolas.b" <nicolas.blanpain@fr.thalesgroup.com> writes:
> function Length (Toto : in T_Toto) return T_Real;
> pragma Inline (Length);
Try pragma Inline_Always ... not sure of the exact rules involved, but
it does have an effect!
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2005-07-27 13:52 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-07-20 17:10 pragma Inline in generic nicolas.b
2005-07-20 19:40 ` Manuel G. R.
2005-07-20 20:45 ` Damien
2005-07-20 20:51 ` Damien
2005-07-27 13:52 ` Simon Wright
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox