Why doesn't the Delphi compiler perform built-in build functions?

Sometimes I write very short build functions like

function SeniorBit(Value: LongWord): Integer; asm OR EAX,EAX JZ @@Done BSR EAX,EAX INC EAX @@Done: end; 

which seems like the best candidate for investment:

 function SeniorBit(Value: LongWord): Integer; inline; 

but the Delphi compiler does not allow this. Why?


Updated:

Thanks to ldsandon, there is a 5.5 year open QC report . The report contains some suggestions (for example, extending the asm directive) to simplify embedding asm for the compiler. I would prefer to introduce a bare directive at the procedure / function level, which tells the compiler that he does not need to create a stack frame for the procedure and, possibly, which registers (among eax, edx and ecx) should be saved.

If the general task of efficient nesting procedures with BASM code is difficult (and may be inappropriate), it is a good idea to include nesting for the most important cases (for example, a bare function with explicitly declared use of the register).

+7
assembly delphi inlining basm
source share
2 answers

See Quality Center report No. 9283 (and vote for it). The main problem is that the compiler must be able to understand which registers to keep before the embedded code and what to recover after. While the compiler processes the register, it is easy when the use is not under control, it is not. Your example is pretty simple, but the compiler should be able to handle more complex cases. The report is in an open state, I hope that the new compiler can also embed BASM code.

+10
source share

You cannot embed a manual assembly code.

It would be very difficult to allow the embedding of these assembler elements; with normal nesting of all kinds of effects on the use of registers, local variables, etc., which the compiler cannot do with the built-in assembly.

+5
source share

All Articles