From 6d048e1a9768b594513e2ec7a6d3579787eb2505 Mon Sep 17 00:00:00 2001 From: Chad Rosier Date: Tue, 8 Oct 2013 20:43:46 +0000 Subject: [PATCH] [AArch64] Add support for NEON scalar signed/unsigned integer to floating-point convert instructions. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@192232 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/clang/Basic/arm_neon.td | 12 ++++++++++++ lib/CodeGen/CGBuiltin.cpp | 14 ++++++++++++++ test/CodeGen/aarch64-neon-intrinsics.c | 24 ++++++++++++++++++++++++ utils/TableGen/NeonEmitter.cpp | 7 +++++++ 4 files changed, 57 insertions(+) diff --git a/include/clang/Basic/arm_neon.td b/include/clang/Basic/arm_neon.td index 3482b8f77f..6228bdc043 100644 --- a/include/clang/Basic/arm_neon.td +++ b/include/clang/Basic/arm_neon.td @@ -167,6 +167,8 @@ class NoTestOpInst : Inst {} // s: scalar of element type // r: scalar of double width element type // a: scalar of element type (splat to vector type) +// y: scalar of float +// o: scalar of double // k: default elt width, double num elts // #: array of default vectors // p: pointer type @@ -765,4 +767,14 @@ def SCALAR_FRECPS : IInst<"vrecps", "sss", "SfSd">; // Scalar Floating-point Reciprocal Square Root Step def SCALAR_FRSQRTS : IInst<"vrsqrts", "sss", "SfSd">; +//////////////////////////////////////////////////////////////////////////////// +// Scalar Signed Integer Convert To Floating-point +def SCALAR_SCVTFS : SInst<"vcvt_f32", "ys", "Si">; +def SCALAR_SCVTFD : SInst<"vcvt_f64", "os", "Sl">; + +//////////////////////////////////////////////////////////////////////////////// +// Scalar Unsigned Integer Convert To Floating-point +def SCALAR_UCVTFS : SInst<"vcvt_f32", "ys", "SUi">; +def SCALAR_UCVTFD : SInst<"vcvt_f64", "os", "SUl">; + } diff --git a/lib/CodeGen/CGBuiltin.cpp b/lib/CodeGen/CGBuiltin.cpp index 093ab9b11d..a2b0bbc282 100644 --- a/lib/CodeGen/CGBuiltin.cpp +++ b/lib/CodeGen/CGBuiltin.cpp @@ -1971,6 +1971,20 @@ static Value *EmitAArch64ScalarBuiltinExpr(CodeGenFunction &CGF, case AArch64::BI__builtin_neon_vrsqrtsd_f64: Int = Intrinsic::arm_neon_vrsqrts; s = "vrsqrts"; OverloadInt = true; break; + // Scalar Signed Integer Convert To Floating-point + case AArch64::BI__builtin_neon_vcvts_f32_s32: + Int = Intrinsic::aarch64_neon_vcvtf32_s32, + s = "vcvtf"; OverloadInt = false; break; + case AArch64::BI__builtin_neon_vcvtd_f64_s64: + Int = Intrinsic::aarch64_neon_vcvtf64_s64, + s = "vcvtf"; OverloadInt = false; break; + // Scalar Unsigned Integer Convert To Floating-point + case AArch64::BI__builtin_neon_vcvts_f32_u32: + Int = Intrinsic::aarch64_neon_vcvtf32_u32, + s = "vcvtf"; OverloadInt = false; break; + case AArch64::BI__builtin_neon_vcvtd_f64_u64: + Int = Intrinsic::aarch64_neon_vcvtf64_u64, + s = "vcvtf"; OverloadInt = false; break; } if (!Int) diff --git a/test/CodeGen/aarch64-neon-intrinsics.c b/test/CodeGen/aarch64-neon-intrinsics.c index 07b15b55f6..d672f09600 100644 --- a/test/CodeGen/aarch64-neon-intrinsics.c +++ b/test/CodeGen/aarch64-neon-intrinsics.c @@ -5597,3 +5597,27 @@ float64_t test_vrsqrtsd_f64(float64_t a, float64_t b) { return vrsqrtsd_f64(a, b); // CHECK: frsqrts {{d[0-9]+}}, {{d[0-9]+}}, {{d[0-9]+}} } + +float32_t test_vcvts_f32_s32(int32_t a) { +// CHECK: test_vcvts_f32_s32 +// CHECK: scvtf {{s[0-9]+}}, {{s[0-9]+}} + return (float32_t)vcvts_f32_s32(a); +} + +float64_t test_vcvtd_f64_s64(int64_t a) { +// CHECK: test_vcvtd_f64_s64 +// CHECK: scvtf {{d[0-9]+}}, {{d[0-9]+}} + return (float64_t)vcvtd_f64_s64(a); +} + +float32_t test_vcvts_f32_u32(uint32_t a) { +// CHECK: test_vcvts_f32_u32 +// CHECK: ucvtf {{s[0-9]+}}, {{s[0-9]+}} + return (float32_t)vcvts_f32_u32(a); +} + +float64_t test_vcvtd_f64_u64(uint64_t a) { +// CHECK: test_vcvtd_f64_u64 +// CHECK: ucvtf {{d[0-9]+}}, {{d[0-9]+}} + return (float64_t)vcvtd_f64_u64(a); +} diff --git a/utils/TableGen/NeonEmitter.cpp b/utils/TableGen/NeonEmitter.cpp index 78075ba8a0..21827da2a3 100644 --- a/utils/TableGen/NeonEmitter.cpp +++ b/utils/TableGen/NeonEmitter.cpp @@ -456,6 +456,13 @@ static char ModType(const char mod, char type, bool &quad, bool &poly, if (type == 'd') type = 'l'; break; + case 'o': + scal = true; + type = 'd'; + usgn = false; + break; + case 'y': + scal = true; case 'f': if (type == 'h') quad = true; -- 2.40.0