[x86] Add _addcarry_u{32|64} and _subborrow_u{32|64}.

They are added to adxintrin.h but outside __ADX__ block.
These intrinics generates adc and sbb correspondingly that were available before ADX
            

llvm-svn: 218118
This commit is contained in:
Robert Khasanov 2014-09-19 10:29:22 +00:00
parent 83c419b349
commit 2c589bcc5e
3 changed files with 69 additions and 0 deletions

View File

@ -628,6 +628,10 @@ BUILTIN(__builtin_ia32_rdrand64_step, "UiULLi*", "")
// ADX
BUILTIN(__builtin_ia32_addcarryx_u32, "UcUcUiUiUi*", "")
BUILTIN(__builtin_ia32_addcarryx_u64, "UcUcULLiULLiULLi*", "")
BUILTIN(__builtin_ia32_addcarry_u32, "UcUcUiUiUi*", "")
BUILTIN(__builtin_ia32_addcarry_u64, "UcUcULLiULLiULLi*", "")
BUILTIN(__builtin_ia32_subborrow_u32, "UcUcUiUiUi*", "")
BUILTIN(__builtin_ia32_subborrow_u64, "UcUcULLiULLiULLi*", "")
// RDSEED
BUILTIN(__builtin_ia32_rdseed16_step, "UiUs*", "")

View File

@ -28,6 +28,7 @@
#ifndef __ADXINTRIN_H
#define __ADXINTRIN_H
/* Intrinsics that are available only if __ADX__ defined */
#ifdef __ADX__
static __inline unsigned char __attribute__((__always_inline__, __nodebug__))
_addcarryx_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
@ -46,4 +47,37 @@ _addcarryx_u64(unsigned char __cf, unsigned long __x, unsigned long __y,
#endif
#endif
/* Intrinsics that are also available if __ADX__ undefined */
static __inline unsigned char __attribute__((__always_inline__, __nodebug__))
_addcarry_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
unsigned int *__p)
{
return __builtin_ia32_addcarry_u32(__cf, __x, __y, __p);
}
#ifdef __x86_64__
static __inline unsigned char __attribute__((__always_inline__, __nodebug__))
_addcarry_u64(unsigned char __cf, unsigned long __x, unsigned long __y,
unsigned long long *__p)
{
return __builtin_ia32_addcarry_u64(__cf, __x, __y, __p);
}
#endif
static __inline unsigned char __attribute__((__always_inline__, __nodebug__))
_subborrow_u32(unsigned char __cf, unsigned int __x, unsigned int __y,
unsigned int *__p)
{
return __builtin_ia32_subborrow_u32(__cf, __x, __y, __p);
}
#ifdef __x86_64__
static __inline unsigned char __attribute__((__always_inline__, __nodebug__))
_subborrow_u64(unsigned char __cf, unsigned long __x, unsigned long __y,
unsigned long long *__p)
{
return __builtin_ia32_subborrow_u64(__cf, __x, __y, __p);
}
#endif
#endif /* __ADXINTRIN_H */

View File

@ -0,0 +1,31 @@
// RUN: %clang_cc1 -triple x86_64-unknown-unknown -ffreestanding -emit-llvm -o - %s | FileCheck %s
#include <x86intrin.h>
unsigned char test_addcarry_u32(unsigned char __cf, unsigned int __x,
unsigned int __y, unsigned int *__p) {
// CHECK-LABEL: test_addcarry_u32
// CHECK: call i8 @llvm.x86.addcarry.u32
return _addcarry_u32(__cf, __x, __y, __p);
}
unsigned char test_addcarry_u64(unsigned char __cf, unsigned long __x,
unsigned long __y, unsigned long long *__p) {
// CHECK-LABEL: test_addcarry_u64
// CHECK: call i8 @llvm.x86.addcarry.u64
return _addcarry_u64(__cf, __x, __y, __p);
}
unsigned char test_subborrow_u32(unsigned char __cf, unsigned int __x,
unsigned int __y, unsigned int *__p) {
// CHECK-LABEL: test_subborrow_u32
// CHECK: call i8 @llvm.x86.subborrow.u32
return _subborrow_u32(__cf, __x, __y, __p);
}
unsigned char test_subborrow_u64(unsigned char __cf, unsigned long __x,
unsigned long __y, unsigned long long *__p) {
// CHECK-LABEL: test_subborrow_u64
// CHECK: call i8 @llvm.x86.subborrow.u64
return _subborrow_u64(__cf, __x, __y, __p);
}