1/** 2 * Copyright (c) 2021-2022 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// Autogenerated file -- DO NOT EDIT! 17 18// NOLINTNEXTLINE(readability-function-size) 19void panda::bytecodeopt::BytecodeGen::VisitEcma(panda::compiler::GraphVisitor *visitor, Inst *inst_base) 20{ 21 ASSERT(inst_base->IsIntrinsic()); 22 auto inst = inst_base->CastToIntrinsic(); 23 auto enc = static_cast<BytecodeGen *>(visitor); 24 25 switch (inst->GetIntrinsicId()) { 26% instructions = Panda::instructions.select{|b| b.namespace == "ecmascript"} 27% if instructions.first && instructions.first.intrinsic_name 28% instructions = instructions.group_by(&:intrinsic_name) 29% else 30% instructions = instructions.group_by(&:opcode) 31% end 32% instructions.each do |intrinsic_name, group| 33% inst = group.first 34% next if inst.properties.include?("jump") 35% opcode = inst.opcode.upcase 36% params_arr = inst.operands 37% group.each do |i| 38% intr_id = i.opcode.upcase 39 case compiler::RuntimeInterface::IntrinsicId::<%= intr_id %>: 40% end 41 { 42% if inst.acc.include?("in") 43 auto acc_src = inst->GetSrcReg(inst->GetInputsCount() - 2); 44 if (acc_src != compiler::ACC_REG_ID) { 45 DoLda(acc_src, enc->result_); 46 } 47% end 48% params_str = "" 49% vreg_index = 0 50% imm_index = 0 51% id_index = 0 52% input_index = 0 53% params_arr.each do |param| 54% if param.reg? 55 auto v<%= vreg_index %> = inst->GetSrcReg(<%= input_index %>); 56% params_str = params_str + "v#{vreg_index}, " 57% vreg_index = vreg_index + 1 58% input_index = input_index + 1 59% elsif param.id? 60% if param.method_id? 61 ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) 62 auto ir_id<%= id_index %> = static_cast<uint32_t>(inst->GetImms()[<%= imm_index %>]); 63 auto bc_id<%= id_index %> = enc->ir_interface_->GetMethodIdByOffset(ir_id<%= id_index %>); 64% params_str = params_str + "bc_id#{id_index}, " 65% elsif param.string_id? 66 ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) 67 auto ir_id<%= id_index %> = static_cast<uint32_t>(inst->GetImms()[<%= imm_index %>]); 68 auto bc_id<%= id_index %> = enc->ir_interface_->GetStringIdByOffset(ir_id<%= id_index %>); 69% params_str = params_str + "bc_id#{id_index}, " 70% elsif param.literalarray_id? 71 ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) 72 auto ir_id<%= id_index %> = static_cast<uint32_t>(inst->GetImms()[<%= imm_index %>]); 73 auto bc_id<%= id_index %> = enc->ir_interface_->GetLiteralArrayByOffset(ir_id<%= id_index %>); 74% params_str = params_str + "bc_id#{id_index}, " 75% end 76% id_index = id_index + 1 77% imm_index = imm_index + 1 78% elsif param.imm? 79 ASSERT(inst->HasImms() && inst->GetImms().size() > <%= imm_index %>); // NOLINTNEXTLINE(readability-container-size-empty) 80% if inst.properties.include?("jump") 81% params_str += "LabelName(inst->GetBasicBlock()->GetTrueSuccessor()->GetId()), " 82% else 83 auto imm<%= imm_index %> = static_cast<uint32_t>(inst->GetImms()[<%= imm_index %>]); 84% params_str = params_str + "imm#{imm_index}, " 85% imm_index = imm_index + 1 86% end 87% end 88% end 89% if params_arr.length > 0 90% params_str = params_str.chop 91% params_str = params_str.chop 92% end 93 enc->result_.emplace_back(pandasm::Create_<%= inst.asm_token %>(<%= params_str %>)); 94% if inst.acc.include?("out") 95 auto acc_dst = inst->GetDstReg(); 96 if (acc_dst != compiler::ACC_REG_ID) { 97 DoSta(inst->GetDstReg(), enc->result_); 98 } 99% end 100 break; 101 } 102% end 103 default: 104 enc->success_ = false; 105 LOG(ERROR,COMPILER) << "Unsupported ecma opcode"; 106 } 107} 108