_BitScan intrinsics (and some others, for example _Interlocked and _bittest) are supposed to work on both ARM and x86. This is an attempt to isolate them, avoiding repeating their code or writing separate function for each builtin.
Details
Diff Detail
- Build Status
Buildable 180 Build 180: arc lint + arc unit
Event Timeline
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2640–2647 | This should be in an anonymous namespace. Also, consider using an enum class instead of an enum nested inside a namespace. | |
| 2656–2684 | Does this do the right thing if the arg is zero? I think it would if you gave the call to the intrinsic an operand of false instead of true. | |
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2656–2684 | MSDN doesn't specify what should be put under the "Index" address when the argument is zero; as I checked, VS2015 with optimizations puts undefined value there, and I hope that's what I'm doing here. | |
Nice, probably ready to land with one revision.
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2640–2647 | Let's also use a more specific name than MSVC, maybe MSVCIntrin or something. | |
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2640–2647 | I can see three options: | |
change enum in MSVC namespace to enum class MSVCIntrin in CodeGenFunction; cover all control paths
| lib/CodeGen/CodeGenFunction.h | ||
|---|---|---|
| 2964 | Does this work on Linux? I thought you had to give it an explicit underlying type (enum class MSVCIntrin : unsigned;) to make that work. | |
| lib/CodeGen/CodeGenFunction.h | ||
|---|---|---|
| 2964 | Yes, it seems to work on Linux too. According to the cppreference.com, it "declares a scoped enumeration type whose underlying type is int". | |
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2656–2684 | Intel (https://software.intel.com/en-us/node/523362) says the following: This seems to mesh with this Mozilla bug report: https://bugzilla.mozilla.org/show_bug.cgi?id=1182370 | |
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2665 | Is this line needed? I took it from __builtin_fpclassify, but I don't know what could be its purpose (it's repeated below, where the "bitscan_end" block really starts). | |
| lib/CodeGen/CGBuiltin.cpp | ||
|---|---|---|
| 2665 | It's needed for the call to CreatePHI to be in the correct basic block. | |
This should be in an anonymous namespace. Also, consider using an enum class instead of an enum nested inside a namespace.