From ecd733e28dae796e47ef4cc664e04face9cca664 Mon Sep 17 00:00:00 2001 From: Alina Sbirlea Date: Fri, 8 Jul 2016 16:28:54 +0000 Subject: 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 --- test/builtins/Unit/cpu_model_test.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/builtins/Unit/cpu_model_test.c (limited to 'test') 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; +} -- cgit v1.2.3