[cfe-commits] r147265 - in /cfe/trunk: include/clang/Basic/BuiltinsX86.def lib/Headers/bmiintrin.h test/CodeGen/bmi-builtins.c

Craig Topper craig.topper at gmail.com
Sat Dec 24 23:27:13 PST 2011


Author: ctopper
Date: Sun Dec 25 01:27:12 2011
New Revision: 147265

URL: http://llvm.org/viewvc/llvm-project?rev=147265&view=rev
Log:
Add the rest of the BMI intrinsics.

Modified:
    cfe/trunk/include/clang/Basic/BuiltinsX86.def
    cfe/trunk/lib/Headers/bmiintrin.h
    cfe/trunk/test/CodeGen/bmi-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=147265&r1=147264&r2=147265&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Sun Dec 25 01:27:12 2011
@@ -601,5 +601,7 @@
 
 // BMI
 BUILTIN(__builtin_ctzs, "UsUs", "")
+BUILTIN(__builtin_ia32_bextr_u32, "UiUiUi", "")
+BUILTIN(__builtin_ia32_bextr_u64, "ULLiULLiULLi", "")
 
 #undef BUILTIN

Modified: cfe/trunk/lib/Headers/bmiintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/bmiintrin.h?rev=147265&r1=147264&r2=147265&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/bmiintrin.h (original)
+++ cfe/trunk/lib/Headers/bmiintrin.h Sun Dec 25 01:27:12 2011
@@ -39,6 +39,36 @@
 }
 
 static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__andn_u32(unsigned int __X, unsigned int __Y)
+{
+  return ~__X & __Y;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__bextr_u32(unsigned int __X, unsigned int __Y)
+{
+  return __builtin_ia32_bextr_u32(__X, __Y);
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blsi_u32(unsigned int __X)
+{
+  return __X & -__X;
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blsmsk_u32(unsigned int __X)
+{
+  return __X ^ (__X - 1);
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
+__blsr_u32(unsigned int __X)
+{
+  return __X & (__X - 1);
+}
+
+static __inline__ unsigned int __attribute__((__always_inline__, __nodebug__))
 __tzcnt32(unsigned int __X)
 {
   return __builtin_ctz(__X);
@@ -46,6 +76,36 @@
 
 #ifdef __x86_64__
 static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__andn_u64 (unsigned long long __X, unsigned long long __Y)
+{
+  return ~__X & __Y;
+}
+
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__bextr_u64(unsigned long long __X, unsigned long long __Y)
+{
+  return __builtin_ia32_bextr_u64(__X, __Y);
+}
+
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__blsi_u64(unsigned long long __X)
+{
+  return __X & -__X;
+}
+
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__blsmsk_u64(unsigned long long __X)
+{
+  return __X ^ (__X - 1);
+}
+
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
+__blsr_u64(unsigned long long __X)
+{
+  return __X & (__X - 1);
+}
+
+static __inline__ unsigned long long __attribute__((__always_inline__, __nodebug__))
 __tzcnt64(unsigned long long __X)
 {
   return __builtin_ctzll(__X);

Modified: cfe/trunk/test/CodeGen/bmi-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bmi-builtins.c?rev=147265&r1=147264&r2=147265&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/bmi-builtins.c (original)
+++ cfe/trunk/test/CodeGen/bmi-builtins.c Sun Dec 25 01:27:12 2011
@@ -5,20 +5,67 @@
 
 #include <x86intrin.h>
 
-unsigned short test__tzcnt16(unsigned short __X)
-{
+unsigned short test__tzcnt16(unsigned short __X) {
   // CHECK: tzcntw
   return __tzcnt16(__X);
 }
 
-unsigned int test_tzcnt32(unsigned int __X)
-{
+unsigned int test__andn_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK: andnl
+  return __andn_u32(__X, __Y);
+}
+
+unsigned int test__bextr_u32(unsigned int __X, unsigned int __Y) {
+  // CHECK: bextrl
+  return __bextr_u32(__X, __Y);
+}
+
+unsigned int test__blsi_u32(unsigned int __X) {
+  // CHECK: blsil
+  return __blsi_u32(__X);
+}
+
+unsigned int test__blsmsk_u32(unsigned int __X) {
+  // CHECK: blsmskl
+  return __blsmsk_u32(__X);
+}
+
+unsigned int test__blsr_u32(unsigned int __X) {
+  // CHECK: blsrl
+  return __blsr_u32(__X);
+}
+
+unsigned int test_tzcnt32(unsigned int __X) {
   // CHECK: tzcntl
   return __tzcnt32(__X);
 }
 
-unsigned long long test__tzcnt64(unsigned long long __X)
-{
+unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
+  // CHECK: andnq
+  return __andn_u64(__X, __Y);
+}
+
+unsigned long long test__bextr_u64(unsigned long __X, unsigned long __Y) {
+  // CHECK: bextrq
+  return __bextr_u64(__X, __Y);
+}
+
+unsigned long long test__blsi_u64(unsigned long long __X) {
+  // CHECK: blsiq
+  return __blsi_u64(__X);
+}
+
+unsigned long long test__blsmsk_u64(unsigned long long __X) {
+  // CHECK: blsmskq
+  return __blsmsk_u64(__X);
+}
+
+unsigned long long test__blsr_u64(unsigned long long __X) {
+  // CHECK: blsrq
+  return __blsr_u64(__X);
+}
+
+unsigned long long test__tzcnt64(unsigned long long __X) {
   // CHECK: tzcntq
   return __tzcnt64(__X);
 }





More information about the cfe-commits mailing list