[PATCH] D46431: [x86] Introduce the pconfig intrinsic
This revision was automatically updated to reflect the committed changes. Closed by commit rC331740: [x86] Introduce the pconfig intrinsic (authored by GBuella, committed by ). Repository: rC Clang https://reviews.llvm.org/D46431 Files: include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/module.modulemap lib/Headers/pconfigintrin.h lib/Headers/x86intrin.h test/Driver/x86-target-features.c test/Headers/pconfigintin.c test/Preprocessor/predefined-arch-macros.c Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -105,4 +105,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/cpuid.h === --- lib/Headers/cpuid.h +++ lib/Headers/cpuid.h @@ -194,6 +194,7 @@ /* Features in %edx for leaf 7 sub-leaf 0 */ #define bit_AVX5124VNNIW 0x0004 #define bit_AVX5124FMAPS 0x0008 +#define bit_PCONFIG 0x0004 #define bit_IBT 0x0010 /* Features in %eax for leaf 13 sub-leaf 1 */ Index: lib/Headers/pconfigintrin.h === --- lib/Headers/pconfigintrin.h +++ lib/Headers/pconfigintrin.h @@ -0,0 +1,50 @@ +/*=== pconfigintrin.h - X86 platform configuration -=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PCONFIGINTRIN_H +#define __PCONFIGINTRIN_H + +#define __PCONFIG_KEY_PROGRAM 0x0001 + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("pconfig"))) + +static __inline unsigned int __DEFAULT_FN_ATTRS +_pconfig_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("pconfig" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +#undef __DEFAULT_FN_ATTRS + +#endif Index: lib/Headers/CMakeLists.txt === --- lib/Headers/CMakeLists.txt +++ lib/Headers/CMakeLists.txt @@ -73,6 +73,7 @@ opencl-c.h pkuintrin.h pmmintrin.h + pconfigintrin.h popcntintrin.h prfchwintrin.h rdseedintrin.h Index: lib/Headers/module.modulemap === --- lib/Headers/module.modulemap +++ lib/Headers/module.modulemap @@ -67,6 +67,7 @@ textual header "cldemoteintrin.h" textual header "waitpkgintrin.h" textual header "movdirintrin.h" +textual header "pconfigintrin.h" explicit module mm_malloc { requires !freestanding Index: lib/Basic/Targets/X86.cpp === --- lib/Basic/Targets/X86.cpp +++ lib/Basic/Targets/X86.cpp @@ -154,6 +154,7 @@ break; case CK_IcelakeServer: +setFeatureEnabledImpl(Features, "pconfig", true); setFeatureEnabledImpl(Features, "wbnoinvd", true); LLVM_FALLTHROUGH; case CK_IcelakeClient: @@ -827,6 +828,8 @@ HasMOVDIRI = true; } else if (Feature == "+movdir64b") { HasMOVDIR64B = true; +} else if (Feature == "+pconfig") { + HasPCONFIG = true; } X86SSEEnum Level = llvm::StringSwitch(Feature) @@ -1187,6 +1190,8 @@ Builder.defineMacro("__MOVDIRI__"); if (HasMOVDIR64B) Builder.defineMacro("__MOVDIR64B__"); + if (HasPCONFIG) +Builder.defineMac
[PATCH] D46431: [x86] Introduce the pconfig intrinsic
This revision was automatically updated to reflect the committed changes. Closed by commit rL331740: [x86] Introduce the pconfig intrinsic (authored by GBuella, committed by ). Herald added a subscriber: llvm-commits. Changed prior to commit: https://reviews.llvm.org/D46431?vs=145207&id=145634#toc Repository: rL LLVM https://reviews.llvm.org/D46431 Files: cfe/trunk/include/clang/Driver/Options.td cfe/trunk/lib/Basic/Targets/X86.cpp cfe/trunk/lib/Basic/Targets/X86.h cfe/trunk/lib/Headers/CMakeLists.txt cfe/trunk/lib/Headers/cpuid.h cfe/trunk/lib/Headers/module.modulemap cfe/trunk/lib/Headers/pconfigintrin.h cfe/trunk/lib/Headers/x86intrin.h cfe/trunk/test/Driver/x86-target-features.c cfe/trunk/test/Headers/pconfigintin.c cfe/trunk/test/Preprocessor/predefined-arch-macros.c Index: cfe/trunk/lib/Headers/pconfigintrin.h === --- cfe/trunk/lib/Headers/pconfigintrin.h +++ cfe/trunk/lib/Headers/pconfigintrin.h @@ -0,0 +1,50 @@ +/*=== pconfigintrin.h - X86 platform configuration -=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PCONFIGINTRIN_H +#define __PCONFIGINTRIN_H + +#define __PCONFIG_KEY_PROGRAM 0x0001 + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \ + __attribute__((__always_inline__, __nodebug__, __target__("pconfig"))) + +static __inline unsigned int __DEFAULT_FN_ATTRS +_pconfig_u32(unsigned int __leaf, __SIZE_TYPE__ __d[]) +{ + unsigned int __result; + __asm__ ("pconfig" + : "=a" (__result), "=b" (__d[0]), "=c" (__d[1]), "=d" (__d[2]) + : "a" (__leaf), "b" (__d[0]), "c" (__d[1]), "d" (__d[2]) + : "cc"); + return __result; +} + +#undef __DEFAULT_FN_ATTRS + +#endif Index: cfe/trunk/lib/Headers/CMakeLists.txt === --- cfe/trunk/lib/Headers/CMakeLists.txt +++ cfe/trunk/lib/Headers/CMakeLists.txt @@ -73,6 +73,7 @@ opencl-c.h pkuintrin.h pmmintrin.h + pconfigintrin.h popcntintrin.h prfchwintrin.h rdseedintrin.h Index: cfe/trunk/lib/Headers/module.modulemap === --- cfe/trunk/lib/Headers/module.modulemap +++ cfe/trunk/lib/Headers/module.modulemap @@ -67,6 +67,7 @@ textual header "cldemoteintrin.h" textual header "waitpkgintrin.h" textual header "movdirintrin.h" +textual header "pconfigintrin.h" explicit module mm_malloc { requires !freestanding Index: cfe/trunk/lib/Headers/x86intrin.h === --- cfe/trunk/lib/Headers/x86intrin.h +++ cfe/trunk/lib/Headers/x86intrin.h @@ -105,4 +105,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: cfe/trunk/lib/Headers/cpuid.h === --- cfe/trunk/lib/Headers/cpuid.h +++ cfe/trunk/lib/Headers/cpuid.h @@ -194,6 +194,7 @@ /* Features in %edx for leaf 7 sub-leaf 0 */ #define bit_AVX5124VNNIW 0x0004 #define bit_AVX5124FMAPS 0x0008 +#define bit_PCONFIG 0x0004 #define bit_IBT 0x0010 /* Features in %eax for leaf 13 sub-leaf 1 */ Index: cfe/trunk/lib/Basic/Targets/X86.h === --- cfe/trunk/lib/Basic/Targets/X86.h +++ cfe/trunk/lib/Basic/Targets/X86.h @@ -92,6 +92,7 @@ bool HasMWAITX = false; bool HasCLZERO = false; bool HasCLDEMOTE = false; + bool HasPCONFIG = false; bool HasPKU = false; bool HasCLFLUSHOPT = false; bool HasCLWB = false; Index: cfe/trunk
[PATCH] D46431: [x86] Introduce the pconfig intrinsic
craig.topper accepted this revision. craig.topper added a comment. This revision is now accepted and ready to land. LGTM https://reviews.llvm.org/D46431 ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[PATCH] D46431: [x86] Introduce the pconfig intrinsic
GBuella updated this revision to Diff 145207. https://reviews.llvm.org/D46431 Files: include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/module.modulemap lib/Headers/pconfigintrin.h lib/Headers/x86intrin.h test/Driver/x86-target-features.c test/Headers/pconfigintin.c test/Preprocessor/predefined-arch-macros.c Index: test/Preprocessor/predefined-arch-macros.c === --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -1204,6 +1204,7 @@ // CHECK_ICX_M32: #define __MMX__ 1 // CHECK_ICX_M32: #define __MPX__ 1 // CHECK_ICX_M32: #define __PCLMUL__ 1 +// CHECK_ICX_M32: #define __PCONFIG__ 1 // CHECK_ICX_M32: #define __PKU__ 1 // CHECK_ICX_M32: #define __POPCNT__ 1 // CHECK_ICX_M32: #define __PRFCHW__ 1 @@ -1261,6 +1262,7 @@ // CHECK_ICX_M64: #define __MMX__ 1 // CHECK_ICX_M64: #define __MPX__ 1 // CHECK_ICX_M64: #define __PCLMUL__ 1 +// CHECK_ICX_M64: #define __PCONFIG__ 1 // CHECK_ICX_M64: #define __PKU__ 1 // CHECK_ICX_M64: #define __POPCNT__ 1 // CHECK_ICX_M64: #define __PRFCHW__ 1 Index: test/Headers/pconfigintin.c === --- /dev/null +++ test/Headers/pconfigintin.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-64 +// RUN: %clang_cc1 %s -ffreestanding -triple i386 -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-32 + +#include +#include +#include + +uint32_t test_pconfig(uint32_t leaf, size_t data[3]) { +// CHECK-64: call { i32, i64, i64, i64 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) +// CHECK-32: call { i32, i32, i32, i32 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _pconfig_u32(leaf, data); +} Index: test/Driver/x86-target-features.c === --- test/Driver/x86-target-features.c +++ test/Driver/x86-target-features.c @@ -159,3 +159,8 @@ // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s // MOVDIR64B: "-target-feature" "+movdir64b" // NO-MOVDIR64B: "-target-feature" "-movdir64b" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PCONFIG %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-PCONFIG %s +// PCONFIG: "-target-feature" "+pconfig" +// NO-PCONFIG: "-target-feature" "-pconfig" Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -105,4 +105,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/pconfigintrin.h === --- /dev/null +++ lib/Headers/pconfigintrin.h @@ -0,0 +1,50 @@ +/*=== pconfigintrin.h - X86 platform configuration -=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PCONFIGINTRIN_H +#define __PCONFIGINTRIN_H + +#define __PCONFIG_KEY_PROGRAM 0x0001 + +/* Define the default attributes for the functions in this file. */ +#define __DEFAULT_FN_ATTRS \
[PATCH] D46431: [x86] Introduce the pconfig intrinsic
GBuella created this revision. GBuella added reviewers: craig.topper, zvi. Herald added subscribers: cfe-commits, mgorny. Repository: rC Clang https://reviews.llvm.org/D46431 Files: include/clang/Driver/Options.td lib/Basic/Targets/X86.cpp lib/Basic/Targets/X86.h lib/Headers/CMakeLists.txt lib/Headers/cpuid.h lib/Headers/module.modulemap lib/Headers/pconfigintrin.h lib/Headers/x86intrin.h test/Driver/x86-target-features.c test/Headers/pconfigintin.c test/Preprocessor/predefined-arch-macros.c Index: test/Preprocessor/predefined-arch-macros.c === --- test/Preprocessor/predefined-arch-macros.c +++ test/Preprocessor/predefined-arch-macros.c @@ -1204,6 +1204,7 @@ // CHECK_ICX_M32: #define __MMX__ 1 // CHECK_ICX_M32: #define __MPX__ 1 // CHECK_ICX_M32: #define __PCLMUL__ 1 +// CHECK_ICX_M32: #define __PCONFIG__ 1 // CHECK_ICX_M32: #define __PKU__ 1 // CHECK_ICX_M32: #define __POPCNT__ 1 // CHECK_ICX_M32: #define __PRFCHW__ 1 @@ -1261,6 +1262,7 @@ // CHECK_ICX_M64: #define __MMX__ 1 // CHECK_ICX_M64: #define __MPX__ 1 // CHECK_ICX_M64: #define __PCLMUL__ 1 +// CHECK_ICX_M64: #define __PCONFIG__ 1 // CHECK_ICX_M64: #define __PKU__ 1 // CHECK_ICX_M64: #define __POPCNT__ 1 // CHECK_ICX_M64: #define __PRFCHW__ 1 Index: test/Headers/pconfigintin.c === --- /dev/null +++ test/Headers/pconfigintin.c @@ -0,0 +1,12 @@ +// RUN: %clang_cc1 %s -ffreestanding -triple x86_64-unknown-unknown -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-64 +// RUN: %clang_cc1 %s -ffreestanding -triple i386 -target-feature +pconfig -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-32 + +#include +#include +#include + +uint32_t test_pconfig(uint32_t leaf, size_t data[3]) { +// CHECK-64: call { i32, i64, i64, i64 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}, i64 %{{.*}}) +// CHECK-32: call { i32, i32, i32, i32 } asm "pconfig", "={ax},={bx},={cx},={dx},{ax},{bx},{cx},{dx},~{cc},~{dirflag},~{fpsr},~{flags}"(i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}, i32 %{{.*}}) + return _pconfig_u32(leaf, data); +} Index: test/Driver/x86-target-features.c === --- test/Driver/x86-target-features.c +++ test/Driver/x86-target-features.c @@ -159,3 +159,8 @@ // RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-movdir64b %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-MOVDIR64B %s // MOVDIR64B: "-target-feature" "+movdir64b" // NO-MOVDIR64B: "-target-feature" "-movdir64b" + +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mpconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=PCONFIG %s +// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-pconfig %s -### -o %t.o 2>&1 | FileCheck -check-prefix=NO-PCONFIG %s +// PCONFIG: "-target-feature" "+pconfig" +// NO-PCONFIG: "-target-feature" "-pconfig" Index: lib/Headers/x86intrin.h === --- lib/Headers/x86intrin.h +++ lib/Headers/x86intrin.h @@ -105,4 +105,8 @@ #include #endif +#if !defined(_MSC_VER) || __has_feature(modules) || defined(__PCONFIG__) +#include +#endif + #endif /* __X86INTRIN_H */ Index: lib/Headers/pconfigintrin.h === --- /dev/null +++ lib/Headers/pconfigintrin.h @@ -0,0 +1,50 @@ +/*=== pconfigintrin.h - X86 platform configuration -=== + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + * + *===---=== + */ + +#ifndef __X86INTRIN_H +#error "Never use directly; include instead." +#endif + +#ifndef __PCONFIGINTRIN_H +#define __PCONFIGINTRIN_H + +#define __MKTME_KEY_PROGRAM 0x0001 + +