Hello I confirm that it is implemented by “lock orl $0,($rsp)” and I also vote 
to include this intrinsic. Below here are asm and objdump results

 

C:>type foo.c && cl -nologo -Ox -Fa -c foo.c && type foo.asm && objdump -d 
foo.obj

void

foo() {

        __faststorefence();

}

foo.c

; Listing generated by Microsoft (R) Optimizing Compiler Version 19.29.30038.1

 

include listing.inc

 

INCLUDELIB LIBCMT

INCLUDELIB OLDNAMES

 

PUBLIC  foo

voltbl  SEGMENT

_volmd  DDSymXIndex:    FLAT:foo

        DD      00H

voltbl  ENDS

; Function compile flags: /Ogtpy

_TEXT   SEGMENT

foo     PROC

; File c:\usr\jullien\foo.c

; Line 3

        lock or DWORD PTR [rsp], 0

; Line 4

        ret     0

foo     ENDP

_TEXT   ENDS

END

 

foo.obj:     file format pe-x86-64

 

 

Disassembly of section .text$mn:

 

0000000000000000 <foo>:

   0:   f0 83 0c 24 00          lock orl $0x0,(%rsp)

   5:   c3                      ret

 

-----Original Message-----
From: Tinycc-devel [mailto:[email protected]] On 
Behalf Of Elijah Stone
Sent: Sunday, June 20, 2021 21:56
To: [email protected]
Subject: Re: [Tinycc-devel] sqlite on windows

 

On Sun, 20 Jun 2021, Tyge Løvset wrote:

 

> on win64 I get an undefined intrinsic symbol   __faststorefence().  It 

> can be implemented as an mfence instruction, but I think microsoft 

> implements it with xchgl or similar

 

It appears to be implemented as  lock or $0,(%rsp).

I would guess the reasoning that or with 0 is special-cased by the processor as 
a no-op, so it doesn't actually perform a write, but the lock still takes 
effect?

Regardless, I think it's a good idea to implement such intrinsics.

 

  -E

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to