[fpc-devel] Simplicity vs. Complexity

J. Gareth Moreton gareth at moreton-family.com
Tue Mar 26 16:18:37 CET 2019


This is a question regarding the compiler 
in general, and I sense there is no single 
correct answer.

As you may already know, FPC compiles 
source code into intermediate nodes. Most 
of these are quite straightforward, like 
addition and a procedure call, but then 
you get quite a few that map onto internal 
functions and intrinsics like "abs" and 
are otherwise handled directly by the 
compiler rather than calling a function in 
the System unit, say.

In your experience, and through theory, 
where should the line be drawn with 
internal routines and explicitly writing a 
function? I can see advantages in both 
approaches, like it's easier to assemble a 
node into a specific instruction set, but 
it can cause a lot of bloat in the 
compiler, while having an explicit 
function reduces this compiler complexity 
and allows for internal code improvements 
and better acceptance of features like 
pure functions, but may increase 
compilation time and make optimisation 
more difficult, depending on how it is 
implemented.

Just looking for discussion.

Gareth aka. Kit





More information about the fpc-devel mailing list