-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI
Milestone
Description
movbe is an intrinsic that allows you to perform a big-endian read from or a big-endian write to main memory. It's approximately equivalent to a mov followed by a bswap (or vice versa) but is more efficient. It was introduced in the Intel Atom line and eventually made its way to later generations.
Proposal:
namespace System.Runtime.Intrinsics.X86 {
[Intrinsic]
public abstract class Movbe {
internal Movbe() { /* nobody can construct me */ }
public static bool IsSupported { get; }
public static void WriteBigEndian(ref ushort address, ushort value);
public static void WriteBigEndian(ref uint address, uint value);
public static ushort ReadBigEndianUInt16(ref ushort address);
public static uint ReadBigEndianUInt32(ref uint address);
[Intrinsic]
public abstract class X64 {
/* IsSupported and 64-bit overloads */
}
}
}Open questions:
- Do we need signed overloads?
- What about alignment? X86 processors don't care about alignment for this instruction, so I assume we'll document that it can accept unaligned refs no problem.
- The APIs proposed above take ref parameters of the same width as the values they're writing / reading, so they're 100% safe. Do we also need unsafe overloads? (I assume not but wanted to throw it out there.)
/cc @tannergooding
category:cq
theme:optimization
skill-level:intermediate
cost:medium
viktor-svub, scalablecory, PaulusParssinen, pentp, hexawyz and 2 more
Metadata
Metadata
Assignees
Labels
api-suggestionEarly API idea and discussion, it is NOT ready for implementationEarly API idea and discussion, it is NOT ready for implementationarea-CodeGen-coreclrCLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMICLR JIT compiler in src/coreclr/src/jit and related components such as SuperPMI