www.digitalmars.com         C & C++   DMDScript  

D - custom intrinsics?

reply "chris jones" <flak clara.co.uk> writes:
It would be very powerfull and usefull if we could add our own intrinsic
functions. For example...

intrinsic Clip(int32 val) {
cmp val,1;
cmovlt val,1;
cmp val,-1;
cmovht val,-1;
}

so you can call this two ways..

from normal D code

Clip(x);

or from asm

Clip(eax);

The idea is to add very simple inlineable functions with extra info so the
compiler can optimise them better. So limitations could be they have to be
pure asm and less than 3 parametrs. In the above example the compiler can
easily inline and choose which register to use for val. This being an idea
to make it easy for the compiler to change the assignment of the registers
as its one thing you have to be mindfull of with pure asm functions because
you have to be minfull of which registers you use.

I use quite a bit of asembler for high performance stuff and i realy think
this would be an awsome feature. The compiler already does this for some
functions doesnt it? It would be nice if this was availible to use.

chris
Dec 20 2002
parent "Walter" <walter digitalmars.com> writes:
I think it's a great idea, but wouldn't just making asm functions inlineable
fit the bill too?

"chris jones" <flak clara.co.uk> wrote in message
news:atv2se$akv$1 digitaldaemon.com...
 It would be very powerfull and usefull if we could add our own intrinsic
 functions. For example...

 intrinsic Clip(int32 val) {
 cmp val,1;
 cmovlt val,1;
 cmp val,-1;
 cmovht val,-1;
 }

 so you can call this two ways..

 from normal D code

 Clip(x);

 or from asm

 Clip(eax);

 The idea is to add very simple inlineable functions with extra info so the
 compiler can optimise them better. So limitations could be they have to be
 pure asm and less than 3 parametrs. In the above example the compiler can
 easily inline and choose which register to use for val. This being an idea
 to make it easy for the compiler to change the assignment of the registers
 as its one thing you have to be mindfull of with pure asm functions
because
 you have to be minfull of which registers you use.

 I use quite a bit of asembler for high performance stuff and i realy think
 this would be an awsome feature. The compiler already does this for some
 functions doesnt it? It would be nice if this was availible to use.

 chris
Dec 24 2002