Re: [PATCH] Runtime memory barrier patching

Jamie Lokier
2003-04-21T23:54:01Z

Chuck Ebbert wrote:
> > Does anybody have the preferred Intel sequence somewhere?
>
> These are in Intel ASM form (i.e. dest first) from the 486 manual:
>
> 2-bytes mov reg,reg
> 3-bytes lea reg, 0[reg] ; 8-bit displacement

Look in the GAS source code for opcodes.

At least on the 486 and Pentium (I remember that part of GAS in those
days), it makes sense to select a register that is not set in the
preceding few instructions or used in the subsequent few. Otherwise,
lea's use of a register adds an address generation delay (worse than
just a mov).

Hence use of %esi and %edi in GAS - registers allocated last by the
compiler, so least likely to be used/set in surrounding instructions.

The register selection is probably too difficult to automate, though.

-- Jamie