/** * Copyright (c) 2021-2022 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. */ // NOLINTNEXTLINE(misc-definitions-in-headers,readability-function-size) inline void AdjustFlags([[maybe_unused]] RuntimeInterface::IntrinsicId intrinsic, [[maybe_unused]] Inst *inst) { // Note: code relies on current intrinsic instruction default flags % if Compiler::intrinsics.any? {|intrinsic| !intrinsic.clear_flags.empty? or !intrinsic.set_flags.empty?} switch (intrinsic) { % Compiler::intrinsics.select {|intrinsic| !intrinsic.clear_flags.empty? or !intrinsic.set_flags.empty?}.each do |intrinsic| case RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>: { constexpr auto clear_flags = <%= intrinsic.clear_flags.empty? ? "0U" : intrinsic.clear_flags.collect { |f| "compiler::inst_flags::" + f.upcase }.join("|") %>; constexpr auto set_flags = <%= intrinsic.set_flags.empty? ? "0U" : intrinsic.set_flags.collect { |f| "compiler::inst_flags::" + f.upcase }.join("|") %>; static_assert((set_flags & clear_flags) == 0, "<%= intrinsic.enum_name %> clear_flags cannot intersect set_flags"); % if !intrinsic.static static_assert((clear_flags & compiler::inst_flags::REQUIRE_STATE) == 0, "<%= intrinsic.enum_name %> requires save_state because virtual call might cause NPE"); % end % if !intrinsic.clear_flags.empty? inst->ClearFlag(static_cast(clear_flags)); % end % if !intrinsic.set_flags.empty? static_assert((set_flags & compiler::inst_flags::CAN_THROW) == 0 || (clear_flags & (compiler::inst_flags::REQUIRE_STATE | compiler::inst_flags::RUNTIME_CALL)) == 0, "<%= intrinsic.enum_name %> cannot set can_throw flag"); inst->SetFlag(static_cast(set_flags)); % end break; } % end default: return; } % end } inline bool IsIrtocIntrinsic(RuntimeInterface::IntrinsicId intrinsic) { switch (intrinsic) { % Compiler::intrinsics.select(&:is_irtoc?).each do |intrinsic| case RuntimeInterface::IntrinsicId::<%= intrinsic.entrypoint_name %>: % end return true; default: return false; } }