From 038d1189fc0fd79b4fa03d2b790d311966e9b0f8 Mon Sep 17 00:00:00 2001 From: Aaron Simkin Date: Thu, 29 Jun 2023 18:51:39 +0300 Subject: [PATCH] Add check for SSE4.4 support for rounding in ETS Since the rounding functions makes use of the `roundsd` instruction that is supported only from SSE4.2 we should check if the target system support this ISA. Signed-off-by: Aaron Simkin --- compiler/intrinsics_can_encode.inl | 22 +++++++++++++++++++ .../intrinsics/intrinsics_can_encode.inl.erb | 2 ++ plugins/ets/runtime/ets_libbase_runtime.yaml | 4 ++++ 3 files changed, 28 insertions(+) create mode 100644 compiler/intrinsics_can_encode.inl diff --git a/compiler/intrinsics_can_encode.inl b/compiler/intrinsics_can_encode.inl new file mode 100644 index 000000000..5f3ae61fb --- /dev/null +++ b/compiler/intrinsics_can_encode.inl @@ -0,0 +1,22 @@ +/** + * Copyright (c) 2023 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +inline bool CheckSSE42([[maybe_unused]] RuntimeInterface *runtime, Arch arch) +{ + if (arch == Arch::X86_64) { + return OPTIONS.IsCpuFeatureEnabled(SSE42); + } + return true; +} diff --git a/compiler/optimizer/templates/intrinsics/intrinsics_can_encode.inl.erb b/compiler/optimizer/templates/intrinsics/intrinsics_can_encode.inl.erb index 296b32b8f..937d58d7b 100644 --- a/compiler/optimizer/templates/intrinsics/intrinsics_can_encode.inl.erb +++ b/compiler/optimizer/templates/intrinsics/intrinsics_can_encode.inl.erb @@ -21,3 +21,5 @@ #include "<%= plugin_opts["Intrinsics"]["can_encode_inl"] %>" % end % end +% # the shared/core part of the encoder checkers +#include "compiler/intrinsics_can_encode.inl" diff --git a/plugins/ets/runtime/ets_libbase_runtime.yaml b/plugins/ets/runtime/ets_libbase_runtime.yaml index fb7a2b6ff..921f34877 100644 --- a/plugins/ets/runtime/ets_libbase_runtime.yaml +++ b/plugins/ets/runtime/ets_libbase_runtime.yaml @@ -290,6 +290,7 @@ intrinsics: args: [ f64 ] impl: panda::ets::intrinsics::StdMathFloor codegen_func: CreateMathFloor + can_encode_func: CheckSSE42 clear_flags: [ no_dce, no_hoist, no_cse, barrier, require_state, runtime_call ] - name: StdMathRound @@ -302,6 +303,7 @@ intrinsics: args: [ f64 ] impl: panda::ets::intrinsics::StdMathRound codegen_func: CreateMathRoundAway + can_encode_func: CheckSSE42 clear_flags: [ no_dce, no_hoist, no_cse, barrier, require_state, runtime_call ] - name: StdMathTrunc @@ -314,6 +316,7 @@ intrinsics: args: [ f64 ] impl: panda::ets::intrinsics::StdMathTrunc codegen_func: CreateMathTrunc + can_encode_func: CheckSSE42 clear_flags: [ no_dce, no_hoist, no_cse, barrier, require_state, runtime_call ] - name: StdMathCeil @@ -326,6 +329,7 @@ intrinsics: args: [ f64 ] impl: panda::ets::intrinsics::StdMathCeil codegen_func: CreateMathCeil + can_encode_func: CheckSSE42 clear_flags: [ no_dce, no_hoist, no_cse, barrier, require_state, runtime_call ] - name: StdMathLog -- Gitee