]> granicus.if.org Git - clang/commitdiff
Add the rest of the BMI intrinsics.
authorCraig Topper <craig.topper@gmail.com>
Sun, 25 Dec 2011 07:27:12 +0000 (07:27 +0000)
committerCraig Topper <craig.topper@gmail.com>
Sun, 25 Dec 2011 07:27:12 +0000 (07:27 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@147265 91177308-0d34-0410-b5e6-96231b3b80d8

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

index 5498ccfddc8508f078947e71248e4a578b06ae45..9ca671df55b0b658e1eb698a8d0a0eb2484caf4d 100644 (file)
@@ -601,5 +601,7 @@ BUILTIN(__builtin_clzs, "UsUs", "")
 
 // BMI
 BUILTIN(__builtin_ctzs, "UsUs", "")
+BUILTIN(__builtin_ia32_bextr_u32, "UiUiUi", "")
+BUILTIN(__builtin_ia32_bextr_u64, "ULLiULLiULLi", "")
 
 #undef BUILTIN
index f2aae6549c8d436d38b72f93084fc4e03a60002c..2f7db73a7d98756e12808fc7cfd077f31632a64f 100644 (file)
@@ -38,6 +38,36 @@ __tzcnt16(unsigned short __X)
   return __builtin_ctzs(__X);
 }
 
+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)
 {
@@ -45,6 +75,36 @@ __tzcnt32(unsigned int __X)
 }
 
 #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)
 {
index b44a125ba50811e36674892158fda8f989b13d24..2a3bcc9fc5f8085a18d3e02a31563802093b4b32 100644 (file)
@@ -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);
 }