r/Compilers • • May 25 '26

What compiler/runtime intrinsics do developers typically rely on most?

Hi folks! I’m currently porting my systems language from my own OS environment to Linux/macOS and realized I may be missing important low-level intrinsics or builtin expectations across platforms.

What do modern systems-language users and compiler backends typically expect to exist natively?

0 Upvotes

28 comments sorted by

View all comments

Show parent comment

1

u/flatfinger May 28 '26

Use of intrinsics like 64-bit CompareExchange will facilitate migration of code among platforms which support such features, and allow code to be more efficient on such platforms than would otherwise be possible, but make it difficult to migrate code to platforms that cannot efficiently support them or would put special limitations on their use.

On the flip side, such intrinsics are superior to C11 atomics in cases where a program would only need to use a limited range of operations, and the operations a program would need to use coincide with those that target platforms will support.

If e.g. one needed to target a system using a 16-bit x86 microcontroller, an intrinsic for "decrement and report if value was zero, in a manner that must be atomic with respect to interrupts but not necessarily DMA" might be much cheaper to support than "atomically decrement and report resulting value". Worse, a need to have 16-bit "atomic" objects support the latter semantics at all may increase the cost of all operations on them.