1 /** 2 * Copyright (c) 2024 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef LIBABCKIT_SRC_IR_BUILDER_DYNAMIC_INST_BUILDER_INL_H 17 #define LIBABCKIT_SRC_IR_BUILDER_DYNAMIC_INST_BUILDER_INL_H 18 19 #include "libabckit/src/irbuilder_dynamic/inst_builder_dyn.h" 20 21 namespace libabckit { 22 23 template <compiler::Opcode OPCODE> BuildLoadFromPool(const BytecodeInst * bcInst)24void InstBuilder::BuildLoadFromPool(const BytecodeInst *bcInst) 25 { 26 static_assert(OPCODE == compiler::Opcode::LoadString); 27 BuildAbcKitLoadStringIntrinsic(bcInst); 28 } 29 BuildAbcKitLoadStringIntrinsic(const BytecodeInst * bcInst)30inline void InstBuilder::BuildAbcKitLoadStringIntrinsic(const BytecodeInst *bcInst) 31 { 32 ark::compiler::IntrinsicInst *inst = 33 GetGraph()->CreateInstIntrinsic(ark::compiler::DataType::ANY, GetPc(bcInst->GetAddress()), 34 ark::compiler::RuntimeInterface::IntrinsicId::INTRINSIC_ABCKIT_LOAD_STRING); 35 uint32_t stringId0 = bcInst->GetId(0).AsIndex(); 36 stringId0 = GetRuntime()->ResolveMethodIndex(GetGraph()->GetMethod(), stringId0); 37 inst->AddImm(GetGraph()->GetAllocator(), stringId0); 38 auto method = GetGraph()->GetMethod(); 39 inst->SetMethod(method); 40 AddInstruction(inst); 41 UpdateDefinitionAcc(inst); 42 } 43 44 } // namespace libabckit 45 46 #endif // LIBABCKIT_SRC_IR_BUILDER_DYNAMIC_INST_BUILDER_INL_H 47