diff options
author | Alina Sbirlea <asbirlea@google.com> | 2016-07-08 16:28:54 +0000 |
---|---|---|
committer | Alina Sbirlea <asbirlea@google.com> | 2016-07-08 16:28:54 +0000 |
commit | ecd733e28dae796e47ef4cc664e04face9cca664 (patch) | |
tree | ef7f7b92de51e08868b66fcd31489c5a7fb5ede3 /test/builtins | |
parent | f47f3dda3a83008ad90d36e531d0a2d1be9e79f9 (diff) |
Add runtime support for __cpu_model (__builtin_cpu_supports)
Summary:
This aims to add support for __cpu_model and address Bug 25510. It uses
the code from lib/Support/Host.cpp for cpu detection, and creates
__cpu_model with that info.
Tested on OSX, it builts successfully, but the current version does
*not* resolve Bug 25510. The __cpu_model symbol is present in the
library but it only gets loaded with -all_load. This patch will not land
until this issue is clarified.
Built on Linux as well (though libgcc is the default). The use of "asm"
required -std=gnu99, hence the cmake change. Corrections on better
addressing this are welcome.
Note: See additional comments on D20988 (committed as r271921).
Reviewers: llvm-commits, joerg, echristo, mehdi_amini
Subscribers: mehdi_amini
Differential revision: http://reviews.llvm.org/D21033
git-svn-id: https://llvm.org/svn/llvm-project/compiler-rt/trunk@274873 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/builtins')
-rw-r--r-- | test/builtins/Unit/cpu_model_test.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/builtins/Unit/cpu_model_test.c b/test/builtins/Unit/cpu_model_test.c new file mode 100644 index 000000000..5a918bde7 --- /dev/null +++ b/test/builtins/Unit/cpu_model_test.c @@ -0,0 +1,19 @@ +//===-- cpu_model_test.c - Test __builtin_cpu_supports -------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// This file tests __builtin_cpu_supports for the compiler_rt library. +// +//===----------------------------------------------------------------------===// + +int main (void) { + if(__builtin_cpu_supports("avx2")) + return 4; + else + return 3; +} |