diff options
author | vhscampos <Victor.Campos@arm.com> | 2019-10-17 14:10:30 +0100 |
---|---|---|
committer | vhscampos <Victor.Campos@arm.com> | 2019-10-28 11:06:58 +0000 |
commit | f6e11a36c49c065cd71e9c54e4fba917da5bbf2e (patch) | |
tree | 111c1c361e799280cad8866d7715d2169feeb901 /clang/lib/Headers | |
parent | 3cb5764f900284666dbb0342c487edb1fde4d7fc (diff) | |
download | bcm5719-llvm-f6e11a36c49c065cd71e9c54e4fba917da5bbf2e.tar.gz bcm5719-llvm-f6e11a36c49c065cd71e9c54e4fba917da5bbf2e.zip |
[ARM][AArch64] Implement __cls, __clsl and __clsll intrinsics from ACLE
Summary:
Writing support for three ACLE functions:
unsigned int __cls(uint32_t x)
unsigned int __clsl(unsigned long x)
unsigned int __clsll(uint64_t x)
CLS stands for "Count number of leading sign bits".
In AArch64, these two intrinsics can be translated into the 'cls'
instruction directly. In AArch32, on the other hand, this functionality
is achieved by implementing it in terms of clz (count number of leading
zeros).
Reviewers: compnerd
Reviewed By: compnerd
Subscribers: kristof.beyls, hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D69250
Diffstat (limited to 'clang/lib/Headers')
-rw-r--r-- | clang/lib/Headers/arm_acle.h | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/clang/lib/Headers/arm_acle.h b/clang/lib/Headers/arm_acle.h index 942172f9f8e..137092fb9d7 100644 --- a/clang/lib/Headers/arm_acle.h +++ b/clang/lib/Headers/arm_acle.h @@ -139,6 +139,26 @@ __clzll(uint64_t __t) { return __builtin_clzll(__t); } +/* CLS */ +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__cls(uint32_t __t) { + return __builtin_arm_cls(__t); +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__clsl(unsigned long __t) { +#if __SIZEOF_LONG__ == 4 + return __builtin_arm_cls(__t); +#else + return __builtin_arm_cls64(__t); +#endif +} + +static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) +__clsll(uint64_t __t) { + return __builtin_arm_cls64(__t); +} + /* REV */ static __inline__ uint32_t __attribute__((__always_inline__, __nodebug__)) __rev(uint32_t __t) { |