From 106f80da248ecd29e610a74455a1919ab413569c Mon Sep 17 00:00:00 2001 From: Vladimir Ivanov Date: Thu, 21 Nov 2019 10:24:35 +0300 Subject: [PATCH] =?UTF-8?q?Avoid=20bitcast=20from/to=20function=20types=20?= =?UTF-8?q?returning=20simd=20to=20respect=20the=20ca=E2=80=A6=20(#3581)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Avoid bitcast from/to function types returning simd to respect the calling conventions difference * minor: remove public declaration of KVector4i32 --- runtime/src/main/cpp/Types.cpp | 11 +++++++++-- runtime/src/main/cpp/Types.h | 1 - 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/runtime/src/main/cpp/Types.cpp b/runtime/src/main/cpp/Types.cpp index 34f3a7764b0..b7defd21d51 100644 --- a/runtime/src/main/cpp/Types.cpp +++ b/runtime/src/main/cpp/Types.cpp @@ -97,8 +97,15 @@ KVector4f Kotlin_Vector4f_of(KFloat f0, KFloat f1, KFloat f2, KFloat f3) { return {f0, f1, f2, f3}; } -KVector4i32 Kotlin_Vector4i32_of(KInt f0, KInt f1, KInt f2, KInt f3) { - return {f0, f1, f2, f3}; +/* + * In the current design all simd types are mapped internally to floating type, e.g. <4 x float>. + * However, some platforms (ex. arm32) have different calling convention for <4 x float> and <4 x i32>. + * To avoid illegal bitcast from/to function types the following function + * return type MUST be <4 x float> and explicit type cast is done on the variable type. + */ +KVector4f Kotlin_Vector4i32_of(KInt f0, KInt f1, KInt f2, KInt f3) { + KInt __attribute__ ((__vector_size__(16))) v4i = {f0, f1, f2, f3}; + return (KVector4f)v4i; } } // extern "C" diff --git a/runtime/src/main/cpp/Types.h b/runtime/src/main/cpp/Types.h index 473c38fd56b..b010cef5a6b 100644 --- a/runtime/src/main/cpp/Types.h +++ b/runtime/src/main/cpp/Types.h @@ -52,7 +52,6 @@ typedef float KFloat; typedef double KDouble; typedef void* KNativePtr; typedef KFloat __attribute__ ((__vector_size__ (16))) KVector4f; -typedef KInt __attribute__ ((__vector_size__ (16))) KVector4i32; typedef const void* KConstNativePtr;