From 4b3255c08c87cf604e55eec57ae434b755c2513c Mon Sep 17 00:00:00 2001 From: ketmar Date: Sat, 20 Nov 2021 23:22:47 +0000 Subject: [PATCH] egra: use `naked` `memFillDW()` FossilOrigin-Name: 4c79cdac61b3b43a53c539bd4737dcfefb926ba80e597e4e55d23e6fd7631aaa --- egra/gfx/base.d | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/egra/gfx/base.d b/egra/gfx/base.d index 1a79b99..db36fed 100644 --- a/egra/gfx/base.d +++ b/egra/gfx/base.d @@ -1413,14 +1413,23 @@ public void gxDrawLine() (in auto ref GxPoint p0, auto ref GxPoint p1, in uint c // ////////////////////////////////////////////////////////////////////////// // +version (DigitalMars) { + version(X86) { + version = EGRA_USE_SSE_MEMFILL_DW; + } +} // size is in dwords -version(X86) { + +version(EGRA_USE_SSE_MEMFILL_DW) { +// for x86 naked functions, DMD will pass last arg in EAX public void memFillDW (void* mptr, in uint value, in int count) nothrow @trusted @nogc { asm nothrow @trusted @nogc { - mov EDX,EDI; - mov EDI,[mptr]; - mov EAX,[value]; - mov ECX,[count]; + naked; + mov ECX,EAX; // ECX=count (because last arg is in EAX) + mov EAX,SS:[ESP+8]; // mptr + mov SS:[ESP+8],EDI; // save EDI + mov EDI,EAX; // EDI=mptr + mov EAX,SS:[ESP+4]; // EAX=value cmp ECX,0; jle done; test EDI,0x03; @@ -1445,25 +1454,26 @@ alignedok: stosd; stosd; stosd; - // use ECX as a counter/4 - push ECX; - shr ECX,2; - dec ECX; + // use EDX as a counter/4 + mov EDX,ECX; + shr EDX,2; + dec EDX; // prepare XMM0 movaps XMM0,[EDI-16]; storeloop: movaps [EDI],XMM0; add EDI,16; - dec ECX; + dec EDX; jnz storeloop; // - pop ECX; and ECX,0x03; jz done; simplestore: rep; stosd; done: - mov EDI,EDX; + // restore EDI + mov EDI,SS:[ESP+8]; + ret 8; } } } else { -- 2.11.4.GIT