From e904137c0183a8200b1f4da3182d8a02ce4732cc Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Wed, 16 Oct 2013 21:04:49 +0000 Subject: [PATCH] [AArch64] Add support for NEON scalar absolute value instruction. llvm-svn: 192844 --- clang/include/clang/Basic/arm_neon.td | 4 ++++ clang/lib/CodeGen/CGBuiltin.cpp | 4 ++++ clang/test/CodeGen/aarch64-neon-intrinsics.c | 6 ++++++ 3 files changed, 14 insertions(+) diff --git a/clang/include/clang/Basic/arm_neon.td b/clang/include/clang/Basic/arm_neon.td index c65a99b3c1ee..bc989cde6718 100644 --- a/clang/include/clang/Basic/arm_neon.td +++ b/clang/include/clang/Basic/arm_neon.td @@ -855,6 +855,10 @@ def SCALAR_CMGTZ : SInst<"vcgtz", "ss", "Sl">; def SCALAR_CMHI : SInst<"vcgt", "sss", "SUl">; def SCALAR_CMTST : SInst<"vtst", "sss", "SlSUl">; +//////////////////////////////////////////////////////////////////////////////// +// Scalar Absolute Value +def SCALAR_ABS : SInst<"vabs", "ss", "Sl">; + //////////////////////////////////////////////////////////////////////////////// // Scalar Signed Saturating Absolute Value def SCALAR_SQABS : SInst<"vqabs", "ss", "ScSsSiSl">; diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp index f905595f5203..74ff2dd46399 100644 --- a/clang/lib/CodeGen/CGBuiltin.cpp +++ b/clang/lib/CodeGen/CGBuiltin.cpp @@ -2074,6 +2074,10 @@ static Value *EmitAArch64ScalarBuiltinExpr(CodeGenFunction &CGF, case AArch64::BI__builtin_neon_vtstd_u64: Int = Intrinsic::aarch64_neon_vtstd; s = "vtst"; OverloadInt = false; break; + // Scalar Absolute Value + case AArch64::BI__builtin_neon_vabsd_s64: + Int = Intrinsic::aarch64_neon_vabs; + s = "vabs"; OverloadInt = false; break; // Scalar Signed Saturating Absolute Value case AArch64::BI__builtin_neon_vqabsb_s8: case AArch64::BI__builtin_neon_vqabsh_s16: diff --git a/clang/test/CodeGen/aarch64-neon-intrinsics.c b/clang/test/CodeGen/aarch64-neon-intrinsics.c index 54b4e7536afb..37fb3775c3ef 100644 --- a/clang/test/CodeGen/aarch64-neon-intrinsics.c +++ b/clang/test/CodeGen/aarch64-neon-intrinsics.c @@ -7118,6 +7118,12 @@ uint64_t test_vtstd_u64(uint64_t a, uint64_t b) { return (uint64_t)vtstd_u64(a, b); } +int64_t test_vabsd_s64(int64_t a) { +// CHECK: test_vabsd_s64 +// CHECK: abs {{d[0-9]+}}, {{d[0-9]+}} + return (int64_t)vabsd_s64(a); +} + int8_t test_vqabsb_s8(int8_t a) { // CHECK: test_vqabsb_s8 // CHECK: sqabs {{b[0-9]+}}, {{b[0-9]+}}