r195789 - [AArch64] Add support for NEON scalar floating-point to integer convert
Chad Rosier
mcrosier at codeaurora.org
Tue Nov 26 14:17:51 PST 2013
Author: mcrosier
Date: Tue Nov 26 16:17:51 2013
New Revision: 195789
URL: http://llvm.org/viewvc/llvm-project?rev=195789&view=rev
Log:
[AArch64] Add support for NEON scalar floating-point to integer convert
instructions.
Added:
cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=195789&r1=195788&r2=195789&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Tue Nov 26 16:17:51 2013
@@ -1123,6 +1123,30 @@ def SCALAR_UCVTFS : SInst<"vcvt_f32", "y
def SCALAR_UCVTFD : SInst<"vcvt_f64", "os", "SUl">;
////////////////////////////////////////////////////////////////////////////////
+// Scalar Floating-point Converts
+def SCALAR_FCVTXN : IInst<"vcvtx_f32", "ys", "Sd">;
+def SCALAR_FCVTNSS : SInst<"vcvtn_s32", "$s", "Sf">;
+def SCALAR_FCVTNUS : SInst<"vcvtn_u32", "bs", "Sf">;
+def SCALAR_FCVTNSD : SInst<"vcvtn_s64", "$s", "Sd">;
+def SCALAR_FCVTNUD : SInst<"vcvtn_u64", "bs", "Sd">;
+def SCALAR_FCVTMSS : SInst<"vcvtm_s32", "$s", "Sf">;
+def SCALAR_FCVTMUS : SInst<"vcvtm_u32", "bs", "Sf">;
+def SCALAR_FCVTMSD : SInst<"vcvtm_s64", "$s", "Sd">;
+def SCALAR_FCVTMUD : SInst<"vcvtm_u64", "bs", "Sd">;
+def SCALAR_FCVTASS : SInst<"vcvta_s32", "$s", "Sf">;
+def SCALAR_FCVTAUS : SInst<"vcvta_u32", "bs", "Sf">;
+def SCALAR_FCVTASD : SInst<"vcvta_s64", "$s", "Sd">;
+def SCALAR_FCVTAUD : SInst<"vcvta_u64", "bs", "Sd">;
+def SCALAR_FCVTPSS : SInst<"vcvtp_s32", "$s", "Sf">;
+def SCALAR_FCVTPUS : SInst<"vcvtp_u32", "bs", "Sf">;
+def SCALAR_FCVTPSD : SInst<"vcvtp_s64", "$s", "Sd">;
+def SCALAR_FCVTPUD : SInst<"vcvtp_u64", "bs", "Sd">;
+def SCALAR_FCVTZSS : SInst<"vcvt_s32", "$s", "Sf">;
+def SCALAR_FCVTZUS : SInst<"vcvt_u32", "bs", "Sf">;
+def SCALAR_FCVTZSD : SInst<"vcvt_s64", "$s", "Sd">;
+def SCALAR_FCVTZUD : SInst<"vcvt_u64", "bs", "Sd">;
+
+////////////////////////////////////////////////////////////////////////////////
// Scalar Floating-point Reciprocal Estimate
def SCALAR_FRECPE : IInst<"vrecpe", "ss", "SfSd">;
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=195789&r1=195788&r2=195789&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Tue Nov 26 16:17:51 2013
@@ -1759,6 +1759,7 @@ static Value *EmitAArch64ScalarBuiltinEx
bool ExtendEle = false;
bool OverloadInt = false;
bool OverloadCmpInt = false;
+ bool OverloadCvtInt = false;
bool OverloadWideInt = false;
bool OverloadNarrowInt = false;
const char *s = NULL;
@@ -2121,6 +2122,50 @@ static Value *EmitAArch64ScalarBuiltinEx
case AArch64::BI__builtin_neon_vcvtd_f64_u64:
Int = Intrinsic::aarch64_neon_vcvtf64_u64,
s = "vcvtf"; OverloadInt = false; break;
+ // Scalar Floating-point Converts
+ case AArch64::BI__builtin_neon_vcvtxd_f32_f64:
+ Int = Intrinsic::aarch64_neon_fcvtxn;
+ s = "vcvtxn"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtas_s32_f32:
+ case AArch64::BI__builtin_neon_vcvtad_s64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtas;
+ s = "vcvtas"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtas_u32_f32:
+ case AArch64::BI__builtin_neon_vcvtad_u64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtau;
+ s = "vcvtau"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtms_s32_f32:
+ case AArch64::BI__builtin_neon_vcvtmd_s64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtms;
+ s = "vcvtms"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtms_u32_f32:
+ case AArch64::BI__builtin_neon_vcvtmd_u64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtmu;
+ s = "vcvtmu"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtns_s32_f32:
+ case AArch64::BI__builtin_neon_vcvtnd_s64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtns;
+ s = "vcvtns"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtns_u32_f32:
+ case AArch64::BI__builtin_neon_vcvtnd_u64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtnu;
+ s = "vcvtnu"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtps_s32_f32:
+ case AArch64::BI__builtin_neon_vcvtpd_s64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtps;
+ s = "vcvtps"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvtps_u32_f32:
+ case AArch64::BI__builtin_neon_vcvtpd_u64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtpu;
+ s = "vcvtpu"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvts_s32_f32:
+ case AArch64::BI__builtin_neon_vcvtd_s64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtzs;
+ s = "vcvtzs"; OverloadCvtInt = true; break;
+ case AArch64::BI__builtin_neon_vcvts_u32_f32:
+ case AArch64::BI__builtin_neon_vcvtd_u64_f64:
+ Int = Intrinsic::aarch64_neon_fcvtzu;
+ s = "vcvtzu"; OverloadCvtInt = true; break;
// Scalar Floating-point Reciprocal Estimate
case AArch64::BI__builtin_neon_vrecpes_f32:
case AArch64::BI__builtin_neon_vrecped_f64:
@@ -2540,6 +2585,18 @@ static Value *EmitAArch64ScalarBuiltinEx
Tys.push_back(VTy);
F = CGF.CGM.getIntrinsic(Int, Tys);
+ } else if (OverloadCvtInt) {
+ // Determine the types of this overloaded AArch64 intrinsic
+ SmallVector<llvm::Type *, 2> Tys;
+ const Expr *Arg = E->getArg(E->getNumArgs()-1);
+ llvm::Type *Ty = CGF.ConvertType(E->getCallReturnType());
+ llvm::VectorType *VTy = llvm::VectorType::get(Ty, 1);
+ Tys.push_back(VTy);
+ Ty = CGF.ConvertType(Arg->getType());
+ VTy = llvm::VectorType::get(Ty, 1);
+ Tys.push_back(VTy);
+
+ F = CGF.CGM.getIntrinsic(Int, Tys);
} else
F = CGF.CGM.getIntrinsic(Int);
Added: cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c?rev=195789&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c (added)
+++ cfe/trunk/test/CodeGen/aarch64-neon-fcvt-intrinsics.c Tue Nov 26 16:17:51 2013
@@ -0,0 +1,133 @@
+// REQUIRES: aarch64-registered-target
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +neon \
+// RUN: -ffp-contract=fast -S -O3 -o - %s | FileCheck %s
+
+// Test new aarch64 intrinsics and types
+
+#include <arm_neon.h>
+
+float32_t test_vcvtxd_f32_f64(float64_t a) {
+// CHECK: test_vcvtxd_f32_f64
+// CHECK: fcvtxn {{s[0-9]+}}, {{d[0-9]+}}
+ return (float32_t)vcvtxd_f32_f64(a);
+}
+
+int32_t test_vcvtas_s32_f32(float32_t a) {
+// CHECK: test_vcvtas_s32_f32
+// CHECK: fcvtas {{s[0-9]+}}, {{s[0-9]+}}
+ return (int32_t)vcvtas_s32_f32(a);
+}
+
+int64_t test_test_vcvtad_s64_f64(float64_t a) {
+// CHECK: test_test_vcvtad_s64_f64
+// CHECK: fcvtas {{d[0-9]+}}, {{d[0-9]+}}
+ return (int64_t)vcvtad_s64_f64(a);
+}
+
+uint32_t test_vcvtas_u32_f32(float32_t a) {
+// CHECK: test_vcvtas_u32_f32
+// CHECK: fcvtau {{s[0-9]+}}, {{s[0-9]+}}
+ return (uint32_t)vcvtas_u32_f32(a);
+}
+
+uint64_t test_vcvtad_u64_f64(float64_t a) {
+// CHECK: test_vcvtad_u64_f64
+// CHECK: fcvtau {{d[0-9]+}}, {{d[0-9]+}}
+ return (uint64_t)vcvtad_u64_f64(a);
+}
+
+int32_t test_vcvtms_s32_f32(float32_t a) {
+// CHECK: test_vcvtms_s32_f32
+// CHECK: fcvtms {{s[0-9]+}}, {{s[0-9]+}}
+ return (int32_t)vcvtms_s32_f32(a);
+}
+
+int64_t test_vcvtmd_s64_f64(float64_t a) {
+// CHECK: test_vcvtmd_s64_f64
+// CHECK: fcvtms {{d[0-9]+}}, {{d[0-9]+}}
+ return (int64_t)vcvtmd_s64_f64(a);
+}
+
+uint32_t test_vcvtms_u32_f32(float32_t a) {
+// CHECK: test_vcvtms_u32_f32
+// CHECK: fcvtmu {{s[0-9]+}}, {{s[0-9]+}}
+ return (uint32_t)vcvtms_u32_f32(a);
+}
+
+uint64_t test_vcvtmd_u64_f64(float64_t a) {
+// CHECK: test_vcvtmd_u64_f64
+// CHECK: fcvtmu {{d[0-9]+}}, {{d[0-9]+}}
+ return (uint64_t)vcvtmd_u64_f64(a);
+}
+
+int32_t test_vcvtns_s32_f32(float32_t a) {
+// CHECK: test_vcvtns_s32_f32
+// CHECK: fcvtns {{s[0-9]+}}, {{s[0-9]+}}
+ return (int32_t)vcvtns_s32_f32(a);
+}
+
+int64_t test_vcvtnd_s64_f64(float64_t a) {
+// CHECK: test_vcvtnd_s64_f64
+// CHECK: fcvtns {{d[0-9]+}}, {{d[0-9]+}}
+ return (int64_t)vcvtnd_s64_f64(a);
+}
+
+uint32_t test_vcvtns_u32_f32(float32_t a) {
+// CHECK: test_vcvtns_u32_f32
+// CHECK: fcvtnu {{s[0-9]+}}, {{s[0-9]+}}
+ return (uint32_t)vcvtns_u32_f32(a);
+}
+
+uint64_t test_vcvtnd_u64_f64(float64_t a) {
+// CHECK: test_vcvtnd_u64_f64
+// CHECK: fcvtnu {{d[0-9]+}}, {{d[0-9]+}}
+ return (uint64_t)vcvtnd_u64_f64(a);
+}
+
+int32_t test_vcvtps_s32_f32(float32_t a) {
+// CHECK: test_vcvtps_s32_f32
+// CHECK: fcvtps {{s[0-9]+}}, {{s[0-9]+}}
+ return (int32_t)vcvtps_s32_f32(a);
+}
+
+int64_t test_vcvtpd_s64_f64(float64_t a) {
+// CHECK: test_vcvtpd_s64_f64
+// CHECK: fcvtps {{d[0-9]+}}, {{d[0-9]+}}
+ return (int64_t)vcvtpd_s64_f64(a);
+}
+
+uint32_t test_vcvtps_u32_f32(float32_t a) {
+// CHECK: test_vcvtps_u32_f32
+// CHECK: fcvtpu {{s[0-9]+}}, {{s[0-9]+}}
+ return (uint32_t)vcvtps_u32_f32(a);
+}
+
+uint64_t test_vcvtpd_u64_f64(float64_t a) {
+// CHECK: test_vcvtpd_u64_f64
+// CHECK: fcvtpu {{d[0-9]+}}, {{d[0-9]+}}
+ return (uint64_t)vcvtpd_u64_f64(a);
+}
+
+int32_t test_vcvts_s32_f32(float32_t a) {
+// CHECK: test_vcvts_s32_f32
+// CHECK: fcvtzs {{s[0-9]+}}, {{s[0-9]+}}
+ return (int32_t)vcvts_s32_f32(a);
+}
+
+int64_t test_vcvtd_s64_f64(float64_t a) {
+// CHECK: test_vcvtd_s64_f64
+// CHECK: fcvtzs {{d[0-9]+}}, {{d[0-9]+}}
+ return (int64_t)vcvtd_s64_f64(a);
+}
+
+uint32_t test_vcvts_u32_f32(float32_t a) {
+// CHECK: test_vcvts_u32_f32
+// CHECK: fcvtzu {{s[0-9]+}}, {{s[0-9]+}}
+ return (uint32_t)vcvts_u32_f32(a);
+}
+
+uint64_t test_vcvtd_u64_f64(float64_t a) {
+// CHECK: test_vcvtd_u64_f64
+// CHECK: fcvtzu {{d[0-9]+}}, {{d[0-9]+}}
+ return (uint64_t)vcvtd_u64_f64(a);
+}
More information about the cfe-commits
mailing list