This is an archive of the discontinued LLVM Phabricator instance.

test-suite: add cpu architecture detection in cmake configuration
ClosedPublic

Authored by itaraban on Oct 2 2017, 5:18 PM.

Details

Summary

This patch adds opportunity to identify cpu target using cpuid, when you use cmake configuration. Then this CPU_ARCH variable can be used for adding options, disabling or enabling tests for given cpu architectures.

Patch with similar feature for make+configure approach -D38182.

Diff Detail

Event Timeline

itaraban created this revision.Oct 2 2017, 5:18 PM
MatzeB edited edge metadata.Oct 2 2017, 5:26 PM

This seems to be all x86 specific, so I think you should have x86 in the names of CPU_ARCH, DetectCPUArchitecture.c and detect_cpu_architecture.

MatzeB added inline comments.Oct 2 2017, 5:31 PM
cmake/modules/DetectCPUArchitecture.c
1–4 ↗(On Diff #117454)

Those are system includes, better use #include <>.

6 ↗(On Diff #117454)

Add a space after () to match llvm coding style.

15–18 ↗(On Diff #117454)

Maybe move the variable declarations up so this becomes compilable in C89 as well? (try_run doesn't seem to give any C99 guarantees even though it probably works fine with most compilers).

15–18 ↗(On Diff #117454)

Would be neat to add a comment with a reference to the Intel documentation on how to interpret the cpuid bits.

20–23 ↗(On Diff #117454)

According to LLVM coding style cases are not indented further.

100 ↗(On Diff #117454)

should we return 1 in the unknown case?

104 ↗(On Diff #117454)

LLVM coding style would use

} else {

here.

132–133 ↗(On Diff #117454)

see above.

134 ↗(On Diff #117454)

should we return 1 in the unknown case?

itaraban updated this revision to Diff 126979.Dec 14 2017, 9:06 AM

Sorry for late response. Thanks for your remarks. I changed names and formated DetectX86CPUArchitecture.c.
Soon I'll create review with first cpu-specific tests.

Patch which uses this feature: D41249

MatzeB accepted this revision.Dec 15 2017, 11:15 AM

LGTM

This revision is now accepted and ready to land.Dec 15 2017, 11:15 AM
itaraban updated this revision to Diff 127557.Dec 19 2017, 10:14 AM

Fixed typo in main CMakeLists.txt

This revision was automatically updated to reflect the committed changes.