That's true. Given I specialise in optimisation, I've started to
venture towards the node level to see where improvements can be made.
One question I do have in that regard... are platform-specific nodes
allowed? What I mean is, for example, a node's 'simplify' routine may
transmute a set of nodes to a platform-specific node that may better
benefit, say, vectorisation on an AMD64 processor. (A swap node will be
platform-independent, and if platform-specific assembly isn't available,
then to just create the equivalent Pascal code as you laid out below).
So many exciting challenges ahead! Got to fix bugs in the existing
stuff first though.
Gareth aka. Kit
On 11/12/2019 21:43, Sven Barth via fpc-devel wrote:
Am 11.12.2019 um 07:26 schrieb J. Gareth Moreton:
Hi everyone,
I was wondering... is there an intrinsic in Free Pascal that swaps
the pointers stored in two object or pointer variables? That is...
something like "procedure SwapAddresses(var Obj1: TObject; var Obj2:
TObject);" so after it is called, Obj2 now points to Obj1 and vice
versa? Under x86-64, for example, it can be implemented as (Intel
notation):
XOR RCX, RDX
XOR RDX, RCX
XOR RCX, RDX
Or just
XCHG RCX, RDX
It might be more useful to try to write high level optimization that
detects the typical swap sequence of
tmp := a;
a := b;
b := tmp;
And optimizes that to the most optimal CPU instructions (by converting
it to an internal "Swap" intrinsic, similar as it is done for the
load/modify/store optimizations).
Then any existing code would profit from that as well.
And for your specific use case you could then add such swap procedures
to cutils.pas or so...
Regards,
Sven
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel
_______________________________________________
fpc-devel maillist - fpc-devel@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-devel