Re: [fpc-devel] RTTI interface & variant late binding issue (mORMot)
I'll create a branch and commit the supplied patches so far, we can use this branch to bring things into a reasonable shape. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
[fpc-devel] Bug or Feature? Inline of code from Units does not work when types uses in code are defined in implementation
Take the following unit, my goal is to have the code called in the unit inlined in the main code. This works fine when type pLongWord = ^LongWord; is defined in the interface of the unit. if this is defined in Implementation then Inlining of the code does not work. Is this correct behaviour? Or should both ways work? Thank you, Michael Platform is arm-embedded, Compiler Commandline was: /usr/local/lib/fpc/3.1.1/ppcrossarm -MObjFPC -Tembedded -Parm -Cparmv6m -WpSTM32L053R8 -XParm-none-eabi- test.pas -a -g -B -Si unit utest2; {$inline on} {$modeswitch advancedrecords} interface type TBits_16 = 0..65535; // Independent watchdog TIWDG_KR_bits = record private function getKEY : TBits_16; inline; procedure setKEY(value : TBits_16); inline; public property KEY : TBits_16 read getKEY write setKEY;// [0:15] Key value (write only, read 0x) end; TIWDG_Registers = record KR_bits : TIWDG_KR_bits; KR : longWord; // 0x00 Key register end; const IWDG_BASE = $40003000; var IWDG : TIWDG_Registers absolute IWDG_BASE; //type // pLongWord = ^LongWord; implementation type pLongWord = ^LongWord; function TIWDG_KR_bits.getKEY : TBits_16; inline; begin getKEY := pLongWord(@self)^ shr 0 and %; end; procedure TIWDG_KR_bits.setKEY(value : TBits_16); inline; begin pLongWord(@self)^ := pLongWord(@self)^ and % or (value shl 0); end; end. Calling Prog: program test; {$INLINE ON} {$modeswitch advancedrecords} uses utest2; var a : longWord; begin IWDG.KR_bits.KEY := 1; a := IWDG.KR_bits.KEY; end. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Bug or Feature? Inline of code from Units does not work when types uses in code are defined in implementation
Am 06.04.2015 um 17:53 schrieb Michael Ring: > Take the following unit, my goal is to have the code called in the unit > inlined in the main code. > > This works fine when > > type > pLongWord = ^LongWord; > > is defined in the interface of the unit. > > if this is defined in Implementation then Inlining of the code does not > work. > > Is this correct behaviour? Or should both ways work? Inline is only a recommendation to the compiler. Such a definition in the implementation part prevents indeed inlining. In this particular case I recommend that you just leave the definition away so compiler uses that one of the system unit. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Bug or Feature? Inline of code from Units does not work when types uses in code are defined in implementation
Thanks, So do you think it is worth to extend documentation for inline? Or perhaps the compiler could give a warning when code is not suitable for inlining or is this decision done when a caller requests inlining and not when the inline function gets compiled? Michael Am 06.04.15 um 18:59 schrieb Florian Klaempfl: Am 06.04.2015 um 17:53 schrieb Michael Ring: Take the following unit, my goal is to have the code called in the unit inlined in the main code. This works fine when type pLongWord = ^LongWord; is defined in the interface of the unit. if this is defined in Implementation then Inlining of the code does not work. Is this correct behaviour? Or should both ways work? Inline is only a recommendation to the compiler. Such a definition in the implementation part prevents indeed inlining. In this particular case I recommend that you just leave the definition away so compiler uses that one of the system unit. ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
Re: [fpc-devel] Bug or Feature? Inline of code from Units does not work when types uses in code are defined in implementation
Am 06.04.2015 um 19:23 schrieb Michael Ring: > Thanks, > > So do you think it is worth to extend documentation for inline? Or perhaps > the compiler could give a > warning when code is not suitable for inlining or is this decision done when > a caller requests > inlining and not when the inline function gets compiled? If the situation is clear, the compiler gives a hint. In this case, the procedure is inlined if it is called in the same unit, otherwise not. The decision, if a procedure can be inlined is pretty difficult and changes also from time to time, so I prefer neither to document (situation might change and documentation gets wrong) it nor increase the hints regarding this (sometimes it is really hard to explain why something is not inlined). ___ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel