[clang] [clang] Add `intrin0.h` header to mimic `intrin0.h` used by MSVC STL for clang-cl (PR #75711)

Max Winkler via cfe-commits cfe-commits at lists.llvm.org
Mon Dec 18 13:39:28 PST 2023


MaxEW707 wrote:

> Is intrin0.h a header that ships with MSVC's compiler, or with MS's STL? If the latter, shouldn't everything just work already?

It ships with MSVC.

`intrin0.h` from MSVC doesn't work currently due to some declarations not matching declarations in clang's own `intrin.h`.
For example `_addcary_u64`. Which I now realize I am missing since that is inside `adxintrin.h` which I mistakenly assumed only included adx instriniscs and not adc intrinsics as well.

> What I'd like to see is a pull request sent to https://github.com/microsoft/stl with some agreement about how to structure the ifdefs so we can use intrin0.h when it is available.

Sounds good I'll do that.

> We probably can't use __has_include(<intrin0.h>) because MSVC ships its own copy of intrin0.h, and they can't be distinguished.

I was thinking I could use `__has_include_next`. If `_has_include_next(<intrin0.h>)` is true then we know clang is providing its own `intrin0.h`.

Another option I had was to preemptively get a PR up to MSVC STL with a `__clang_major__` check for clang 18 assuming this PR gets in before the release window.

A custom name like `intrin_msstl.h` works for me as well.

https://github.com/llvm/llvm-project/pull/75711


More information about the cfe-commits mailing list