r218118 - [x86] Add _addcarry_u{32|64} and _subborrow_u{32|64}.
Robert Khasanov
rob.khasanov at gmail.com
Fri Sep 19 03:29:23 PDT 2014
Author: rkhasanov
Date: Fri Sep 19 05:29:22 2014
New Revision: 218118
URL: http://llvm.org/viewvc/llvm-project?rev=218118&view=rev
Log:
[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
Added:
cfe/trunk/test/CodeGen/adc-builtins.c
Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/adxintrin.h
Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=218118&r1=218117&r2=218118&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Fri Sep 19 05:29:22 2014
@@ -628,6 +628,10 @@ BUILTIN(__builtin_ia32_rdrand64_step, "U
// 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*", "")
Modified: cfe/trunk/lib/Headers/adxintrin.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/adxintrin.h?rev=218118&r1=218117&r2=218118&view=diff
==============================================================================
--- cfe/trunk/lib/Headers/adxintrin.h (original)
+++ cfe/trunk/lib/Headers/adxintrin.h Fri Sep 19 05:29:22 2014
@@ -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, unsig
#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 */
Added: cfe/trunk/test/CodeGen/adc-builtins.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/adc-builtins.c?rev=218118&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/adc-builtins.c (added)
+++ cfe/trunk/test/CodeGen/adc-builtins.c Fri Sep 19 05:29:22 2014
@@ -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);
+}
More information about the cfe-commits
mailing list