BUILTIN(__builtin_ia32_pext_si, "UiUiUi", "")
BUILTIN(__builtin_ia32_pext_di, "ULLiULLiULLi", "")
+// TBM
+BUILTIN(__builtin_ia32_bextri_u32, "UiUiIUi", "")
+BUILTIN(__builtin_ia32_bextri_u64, "ULLiULLiIUi", "")
+BUILTIN(__builtin_ia32_blcfill_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blcfill_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blci_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blci_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blcic_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blcic_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blcmsk_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blcmsk_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blcs_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blcs_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blsfill_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blsfill_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_blsic_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_blsic_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_t1mskc_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_t1mskc_u64, "ULLiULLi", "")
+BUILTIN(__builtin_ia32_tzmsk_u32, "UiUi", "")
+BUILTIN(__builtin_ia32_tzmsk_u64, "ULLiULLi", "")
+
// SHA
BUILTIN(__builtin_ia32_sha1rnds4, "V4iV4iV4iIc", "")
BUILTIN(__builtin_ia32_sha1nexte, "V4iV4iV4i", "")
--- /dev/null
+/*===---- tbmintrin.h - TBM intrinsics -------------------------------------===
+ *
+ * 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 __TBM__
+#error "TBM instruction set is not enabled"
+#endif
+
+#ifndef __X86INTRIN_H
+#error "Never use <tbmintrin.h> directly; include <x86intrin.h> instead."
+#endif
+
+#ifndef __TBMINTRIN_H
+#define __TBMINTRIN_H
+
+#define __bextri_u32(a, b) (__builtin_ia32_bextri_u32((a), (b)))
+
+#ifdef __x86_64__
+#define __bextri_u64(a, b) (__builtin_ia32_bextri_u64((a), (b)))
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blcfill_u32(unsigned int a)
+{
+ return __builtin_ia32_blcfill_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blcfill_u64(unsigned long long a)
+{
+ return __builtin_ia32_blcfill_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blci_u32(unsigned int a)
+{
+ return __builtin_ia32_blci_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blci_u64(unsigned long long a)
+{
+ return __builtin_ia32_blci_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blcic_u32(unsigned int a)
+{
+ return __builtin_ia32_blcic_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blcic_u64(unsigned long long a)
+{
+ return __builtin_ia32_blcic_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blcmsk_u32(unsigned int a)
+{
+ return __builtin_ia32_blcmsk_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blcmsk_u64(unsigned long long a)
+{
+ return __builtin_ia32_blcmsk_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blcs_u32(unsigned int a)
+{
+ return __builtin_ia32_blcs_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blcs_u64(unsigned long long a)
+{
+ return __builtin_ia32_blcs_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blsfill_u32(unsigned int a)
+{
+ return __builtin_ia32_blsfill_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blsfill_u64(unsigned long long a)
+{
+ return __builtin_ia32_blsfill_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blsic_u32(unsigned int a)
+{
+ return __builtin_ia32_blsic_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__blsic_u64(unsigned long long a)
+{
+ return __builtin_ia32_blsic_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__t1mskc_u32(unsigned int a)
+{
+ return __builtin_ia32_t1mskc_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__t1mskc_u64(unsigned long long a)
+{
+ return __builtin_ia32_t1mskc_u64(a);
+}
+#endif
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__tzmsk_u32(unsigned int a)
+{
+ return __builtin_ia32_tzmsk_u32(a);
+}
+
+#ifdef __x86_64__
+static __inline__ unsigned long long __attribute__((__always_inline__,
+ __nodebug__))
+__tzmsk_u64(unsigned long long a)
+{
+ return __builtin_ia32_tzmsk_u64(a);
+}
+#endif
+
+#endif /* __TBMINTRIN_H */
--- /dev/null
+// RUN: %clang_cc1 %s -triple=x86_64-unknown-unknown -target-feature +tbm -emit-llvm -o - | FileCheck %s
+
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+
+#include <x86intrin.h>
+
+unsigned int test__bextri_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.bextri.u32
+ return __bextri_u32(a, 1);
+}
+
+unsigned long long test__bextri_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.bextri.u64
+ return __bextri_u64(a, 2);
+}
+
+unsigned int test__blcfill_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blcfill.u32
+ return __blcfill_u32(a);
+}
+
+unsigned long long test__blcfill_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blcfill.u64
+ return __blcfill_u64(a);
+}
+
+unsigned int test__blci_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blci.u32
+ return __blci_u32(a);
+}
+
+unsigned long long test__blci_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blci.u64
+ return __blci_u64(a);
+}
+
+unsigned int test__blcic_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blcic.u32
+ return __blcic_u32(a);
+}
+
+unsigned long long test__blcic_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blcic.u64
+ return __blcic_u64(a);
+}
+
+unsigned int test__blcmsk_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blcmsk.u32
+ return __blcmsk_u32(a);
+}
+
+unsigned long long test__blcmsk_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blcmsk.u64
+ return __blcmsk_u64(a);
+}
+
+unsigned int test__blcs_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blcs.u32
+ return __blcs_u32(a);
+}
+
+unsigned long long test__blcs_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blcs.u64
+ return __blcs_u64(a);
+}
+
+unsigned int test__blsfill_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blsfill.u32
+ return __blsfill_u32(a);
+}
+
+unsigned long long test__blsfill_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blsfill.u64
+ return __blsfill_u64(a);
+}
+
+unsigned int test__blsic_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.blsic.u32
+ return __blsic_u32(a);
+}
+
+unsigned long long test__blsic_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.blsic.u64
+ return __blsic_u64(a);
+}
+
+unsigned int test__t1mskc_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.t1mskc.u32
+ return __t1mskc_u32(a);
+}
+
+unsigned long long test__t1mskc_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.t1mskc.u64
+ return __t1mskc_u64(a);
+}
+
+unsigned int test__tzmsk_u32(unsigned int a) {
+ // CHECK: call i32 @llvm.x86.tbm.tzmsk.u32
+ return __tzmsk_u32(a);
+}
+
+unsigned long long test__tzmsk_u64(unsigned long long a) {
+ // CHECK: call i64 @llvm.x86.tbm.tzmsk.u64
+ return __tzmsk_u64(a);
+}