From 4ca9013b031f5024bea15f92d073dad806976a06 Mon Sep 17 00:00:00 2001 From: Benjamin Kramer <benny.kra@googlemail.com> Date: Fri, 20 May 2016 15:21:08 +0000 Subject: [PATCH] Add all the avx512 flavors to __builtin_cpu_supports's list. This is matching what trunk gcc is accepting. Also adds a missing ssse3 case. PR27779. The amount of duplication here is annoying, maybe it should be factored into a separate .def file? git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@270224 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Basic/Targets.cpp | 11 ++++++++++ lib/CodeGen/CGBuiltin.cpp | 21 ++++++++++++++++++ test/CodeGen/target-builtin-noerror.c | 31 +++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) diff --git a/lib/Basic/Targets.cpp b/lib/Basic/Targets.cpp index f3ab8346b8e..2a018071000 100644 --- a/lib/Basic/Targets.cpp +++ b/lib/Basic/Targets.cpp @@ -3753,6 +3753,7 @@ bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const { .Case("sse", true) .Case("sse2", true) .Case("sse3", true) + .Case("ssse3", true) .Case("sse4.1", true) .Case("sse4.2", true) .Case("avx", true) @@ -3764,6 +3765,16 @@ bool X86TargetInfo::validateCpuSupports(StringRef FeatureStr) const { .Case("avx512f", true) .Case("bmi", true) .Case("bmi2", true) + .Case("aes", true) + .Case("pclmul", true) + .Case("avx512vl", true) + .Case("avx512bw", true) + .Case("avx512dq", true) + .Case("avx512cd", true) + .Case("avx512er", true) + .Case("avx512pf", true) + .Case("avx512vbmi", true) + .Case("avx512ifma", true) .Default(false); } diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index afc308d7f7a..81ae61857ad 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -6336,6 +6336,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, AVX512F, BMI, BMI2, + AES, + PCLMUL, + AVX512VL, + AVX512BW, + AVX512DQ, + AVX512CD, + AVX512ER, + AVX512PF, + AVX512VBMI, + AVX512IFMA, MAX }; @@ -6346,6 +6356,7 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, .Case("sse", X86Features::SSE) .Case("sse2", X86Features::SSE2) .Case("sse3", X86Features::SSE3) + .Case("ssse3", X86Features::SSSE3) .Case("sse4.1", X86Features::SSE4_1) .Case("sse4.2", X86Features::SSE4_2) .Case("avx", X86Features::AVX) @@ -6357,6 +6368,16 @@ Value *CodeGenFunction::EmitX86BuiltinExpr(unsigned BuiltinID, .Case("avx512f", X86Features::AVX512F) .Case("bmi", X86Features::BMI) .Case("bmi2", X86Features::BMI2) + .Case("aes", X86Features::AES) + .Case("pclmul", X86Features::PCLMUL) + .Case("avx512vl", X86Features::AVX512VL) + .Case("avx512bw", X86Features::AVX512BW) + .Case("avx512dq", X86Features::AVX512DQ) + .Case("avx512cd", X86Features::AVX512CD) + .Case("avx512er", X86Features::AVX512ER) + .Case("avx512pf", X86Features::AVX512PF) + .Case("avx512vbmi", X86Features::AVX512VBMI) + .Case("avx512ifma", X86Features::AVX512IFMA) .Default(X86Features::MAX); assert(Feature != X86Features::MAX && "Invalid feature!"); diff --git a/test/CodeGen/target-builtin-noerror.c b/test/CodeGen/target-builtin-noerror.c index 7d86b968462..2a7d69f1089 100644 --- a/test/CodeGen/target-builtin-noerror.c +++ b/test/CodeGen/target-builtin-noerror.c @@ -42,3 +42,34 @@ __m128 __attribute__((target("fma4"))) fma_2(__m128 a, __m128 b, __m128 c) { __m128 __attribute__((target("fma,fma4"))) fma_3(__m128 a, __m128 b, __m128 c) { return __builtin_ia32_vfmaddps(a, b, c); } + +void verifyfeaturestrings() { + (void)__builtin_cpu_supports("cmov"); + (void)__builtin_cpu_supports("mmx"); + (void)__builtin_cpu_supports("popcnt"); + (void)__builtin_cpu_supports("sse"); + (void)__builtin_cpu_supports("sse2"); + (void)__builtin_cpu_supports("sse3"); + (void)__builtin_cpu_supports("ssse3"); + (void)__builtin_cpu_supports("sse4.1"); + (void)__builtin_cpu_supports("sse4.2"); + (void)__builtin_cpu_supports("avx"); + (void)__builtin_cpu_supports("avx2"); + (void)__builtin_cpu_supports("sse4a"); + (void)__builtin_cpu_supports("fma4"); + (void)__builtin_cpu_supports("xop"); + (void)__builtin_cpu_supports("fma"); + (void)__builtin_cpu_supports("avx512f"); + (void)__builtin_cpu_supports("bmi"); + (void)__builtin_cpu_supports("bmi2"); + (void)__builtin_cpu_supports("aes"); + (void)__builtin_cpu_supports("pclmul"); + (void)__builtin_cpu_supports("avx512vl"); + (void)__builtin_cpu_supports("avx512bw"); + (void)__builtin_cpu_supports("avx512dq"); + (void)__builtin_cpu_supports("avx512cd"); + (void)__builtin_cpu_supports("avx512er"); + (void)__builtin_cpu_supports("avx512pf"); + (void)__builtin_cpu_supports("avx512vbmi"); + (void)__builtin_cpu_supports("avx512ifma"); +} -- GitLab