Question about inline assembly in LDC

Cecil Ward cecil at cecilward.com
Mon Aug 21 14:19:38 UTC 2023


When I try a certain snippet of D containing GCC-style inline x86 
asm in LDC, it fails at compile-time with an error message. The 
code works fine in GDC though. Can anyone help me understand 
what’s going wrong.

the error message is:
      source>(231):2:15: error: unknown token in expression
         prefetcht0  [%rdi]

Note the % before the rdi, which shouldn’t be there and isn’t 
when I build under GDC.

The whole thing is:

void prefetcht0( in void * p ) @nogc nothrow @trusted
/* (temporal data)—prefetch data into all levels of the cache 
hierarchy.
*/	{
	asm nothrow @nogc {
		".intel_syntax"               ~ "\n\t" ~
		
	        "prefetcht0  [%0]"          ~ "\n\t" ~
		
	        ".att_syntax"                 ~ "\n"
	        : /* no outputs */
	        :  "r" ( p )
	        :
		;
	        }
	}




More information about the digitalmars-d-ldc mailing list