mirror of
https://gitee.com/openharmony/arkcompiler_runtime_core
synced 2024-12-04 04:52:54 +00:00
!1656 Fix stored value type in peephole for ets.stobj.name
Merge pull request !1656 from Efremov Andrey/fix-small-load-store
This commit is contained in:
commit
f412d951b1
@ -137,6 +137,8 @@ static void VisitEtsStObjByName(BytecodeGen *enc, compiler::IntrinsicInst *inst)
|
||||
auto bcId0 = enc->irInterface_->GetFieldIdByOffset(static_cast<uint32_t>(inst->GetImms()[0]));
|
||||
switch (inst->GetIntrinsicId()) {
|
||||
case compiler::RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32:
|
||||
case compiler::RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I16:
|
||||
case compiler::RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I8:
|
||||
case compiler::RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_F32:
|
||||
DoLda(inst->GetSrcReg(1U), enc->result_);
|
||||
enc->result_.emplace_back(pandasm::Create_ETS_STOBJ_NAME(v0, bcId0));
|
||||
|
@ -150,8 +150,14 @@ void InstBuilder::BuildStObjByName(const BytecodeInstruction *bcInst, DataType::
|
||||
break;
|
||||
case DataType::UINT8:
|
||||
case DataType::INT8:
|
||||
id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I8;
|
||||
type = DataType::INT8;
|
||||
break;
|
||||
case DataType::UINT16:
|
||||
case DataType::INT16:
|
||||
id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I16;
|
||||
type = DataType::INT16;
|
||||
break;
|
||||
case DataType::UINT32:
|
||||
case DataType::INT32:
|
||||
id = RuntimeInterface::IntrinsicId::INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32;
|
||||
|
@ -155,6 +155,8 @@ groups:
|
||||
prefix: ets
|
||||
intrinsic_name:
|
||||
- INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I32
|
||||
- INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I16
|
||||
- INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_I8
|
||||
- INTRINSIC_COMPILER_ETS_ST_OBJ_BY_NAME_F32
|
||||
- sig: ets.stobj.name.64 v:in:ref, field_id
|
||||
acc: in:b64
|
||||
|
@ -88,6 +88,28 @@ intrinsics:
|
||||
clear_flags: [ ]
|
||||
peephole_func: PeepholeStObjByName
|
||||
|
||||
- name: CompilerEtsStObjByNameI8
|
||||
space: ets
|
||||
compiler_only: true
|
||||
static: true
|
||||
signature:
|
||||
ret: void
|
||||
args: [ method, i32, u32, ref, i8 ]
|
||||
impl: ark::ets::intrinsics::CompilerEtsStObjByNameI8
|
||||
clear_flags: [ ]
|
||||
peephole_func: PeepholeStObjByName
|
||||
|
||||
- name: CompilerEtsStObjByNameI16
|
||||
space: ets
|
||||
compiler_only: true
|
||||
static: true
|
||||
signature:
|
||||
ret: void
|
||||
args: [ method, i32, u32, ref, i16 ]
|
||||
impl: ark::ets::intrinsics::CompilerEtsStObjByNameI16
|
||||
clear_flags: [ ]
|
||||
peephole_func: PeepholeStObjByName
|
||||
|
||||
- name: CompilerEtsStObjByNameI32
|
||||
space: ets
|
||||
compiler_only: true
|
||||
|
@ -329,6 +329,20 @@ extern "C" ark::ObjectHeader *CompilerEtsLdObjByNameObj(ark::Method *method, int
|
||||
return CompilerEtsLdObjByName<panda_file::Type::TypeId::REFERENCE, ark::ObjectHeader *>(method, id, pc, obj);
|
||||
}
|
||||
|
||||
extern "C" void CompilerEtsStObjByNameI8(ark::Method *method, int32_t id, uint32_t pc, ark::ObjectHeader *obj,
|
||||
int8_t storeValue)
|
||||
{
|
||||
CompilerEtsStObjByName<panda_file::Type::TypeId::I32, int32_t>(method, id, pc, obj,
|
||||
static_cast<int32_t>(storeValue));
|
||||
}
|
||||
|
||||
extern "C" void CompilerEtsStObjByNameI16(ark::Method *method, int32_t id, uint32_t pc, ark::ObjectHeader *obj,
|
||||
int16_t storeValue)
|
||||
{
|
||||
CompilerEtsStObjByName<panda_file::Type::TypeId::I32, int32_t>(method, id, pc, obj,
|
||||
static_cast<int32_t>(storeValue));
|
||||
}
|
||||
|
||||
extern "C" void CompilerEtsStObjByNameI32(ark::Method *method, int32_t id, uint32_t pc, ark::ObjectHeader *obj,
|
||||
int32_t storeValue)
|
||||
{
|
||||
|
@ -182,6 +182,8 @@ if (PANDA_TARGET_AMD64 OR NOT PANDA_ARM64_TESTS_WITH_SANITIZER)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_try_catch7.ets)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_try_catch8.ets)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_static_lookup.pa)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_static_lookup_8bit.pa)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_static_lookup_16bit.pa)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_nullish.ets)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_nested_loops.ets)
|
||||
panda_add_checked_test_ets(FILE ${CMAKE_CURRENT_SOURCE_DIR}/ets_stringbuilder.ets)
|
||||
|
148
static_core/plugins/ets/tests/checked/ets_static_lookup_16bit.pa
Normal file
148
static_core/plugins/ets/tests/checked/ets_static_lookup_16bit.pa
Normal file
@ -0,0 +1,148 @@
|
||||
# Copyright (c) 2024 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.
|
||||
|
||||
#! CHECKER Static lookup for 16-bit StObjByName JIT
|
||||
#! RUN force_jit: true, options: "--compiler-regex='.*test_store.*'", entry: "_GLOBAL::test_store"
|
||||
#! METHOD "_GLOBAL::test_store"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsStObjByNameI16/, 2
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsStObjByNameI16/
|
||||
#! INST_COUNT /i16 *StoreObject/, 2
|
||||
|
||||
#! CHECKER Static lookup for 16-bit StObjByName AOT
|
||||
#! SKIP_IF @architecture == "arm32"
|
||||
#! RUN_PAOC options: "--compiler-regex='.*test_store.*'"
|
||||
#! METHOD "_GLOBAL::test_store"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsStObjByNameI16/, 2
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsStObjByNameI16/
|
||||
#! INST_COUNT /i16 *StoreObject/, 2
|
||||
#! RUN entry: "_GLOBAL::test_store"
|
||||
|
||||
#! CHECKER Static lookup for 16-bit LdObjByName JIT
|
||||
#! RUN force_jit: true, options: "--compiler-regex='.*test_load.*'", entry: "_GLOBAL::test_load"
|
||||
#! METHOD "_GLOBAL::test_load"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsLdObjByNameI32/, 3
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsLdObjByNameI32/
|
||||
#! INST_COUNT /i16 *LoadObject/, 3
|
||||
|
||||
#! CHECKER Static lookup for 16-bit LdObjByName AOT
|
||||
#! SKIP_IF @architecture == "arm32"
|
||||
#! RUN_PAOC options: "--compiler-regex='.*test_load.*'"
|
||||
#! METHOD "_GLOBAL::test_load"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsLdObjByNameI32/, 3
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsLdObjByNameI32/
|
||||
#! INST_COUNT /i16 *LoadObject/, 3
|
||||
#! RUN entry: "_GLOBAL::test_load"
|
||||
|
||||
|
||||
.language eTS
|
||||
|
||||
.record std.core.Object
|
||||
.record A {
|
||||
i16 bar
|
||||
i16 baz
|
||||
i16 foo
|
||||
}
|
||||
|
||||
.union_field i16 bar
|
||||
.union_field i16 baz
|
||||
.union_field i16 foo
|
||||
|
||||
.function i32 load_bar__noinline__(A a0) {
|
||||
ets.ldobj.name a0, bar
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 load_baz__noinline__(A a0) {
|
||||
ets.ldobj.name a0, baz
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 load_foo__noinline__(A a0) {
|
||||
ets.ldobj.name a0, foo
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 test_store() {
|
||||
newobj v0, A
|
||||
ldai -1
|
||||
ets.stobj.name v0, bar
|
||||
ets.stobj.name v0, foo
|
||||
|
||||
call.short load_baz__noinline__, v0
|
||||
jnez error1
|
||||
|
||||
movi v1, -1
|
||||
call.short load_bar__noinline__, v0
|
||||
jne v1, error2
|
||||
|
||||
call.short load_foo__noinline__, v0
|
||||
jne v1, error3
|
||||
|
||||
ldai 0
|
||||
return
|
||||
error1:
|
||||
ldai 1
|
||||
return
|
||||
error2:
|
||||
ldai 2
|
||||
return
|
||||
error3:
|
||||
ldai 3
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 fill__noinline__(A a0) {
|
||||
ldai -1
|
||||
ets.stobj.name a0, bar
|
||||
ets.stobj.name a0, foo
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 test_load() {
|
||||
newobj v0, A
|
||||
call.short fill__noinline__, v0
|
||||
|
||||
ets.ldobj.name v0, baz
|
||||
jnez error1
|
||||
|
||||
movi v1, -1
|
||||
ets.ldobj.name v0, bar
|
||||
jne v1, error2
|
||||
|
||||
ets.ldobj.name v0, foo
|
||||
jne v1, error3
|
||||
|
||||
ldai 0
|
||||
return
|
||||
error1:
|
||||
ldai 1
|
||||
return
|
||||
error2:
|
||||
ldai 2
|
||||
return
|
||||
error3:
|
||||
ldai 3
|
||||
return
|
||||
}
|
148
static_core/plugins/ets/tests/checked/ets_static_lookup_8bit.pa
Normal file
148
static_core/plugins/ets/tests/checked/ets_static_lookup_8bit.pa
Normal file
@ -0,0 +1,148 @@
|
||||
# Copyright (c) 2024 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.
|
||||
|
||||
#! CHECKER Static lookup for 8-bit StObjByName JIT
|
||||
#! RUN force_jit: true, options: "--compiler-regex='.*test_store.*'", entry: "_GLOBAL::test_store"
|
||||
#! METHOD "_GLOBAL::test_store"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsStObjByNameI8/, 2
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsStObjByNameI8/
|
||||
#! INST_COUNT /i8 *StoreObject/, 2
|
||||
|
||||
#! CHECKER Static lookup for 8-bit StObjByName AOT
|
||||
#! SKIP_IF @architecture == "arm32"
|
||||
#! RUN_PAOC options: "--compiler-regex='.*test_store.*'"
|
||||
#! METHOD "_GLOBAL::test_store"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsStObjByNameI8/, 2
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsStObjByNameI8/
|
||||
#! INST_COUNT /i8 *StoreObject/, 2
|
||||
#! RUN entry: "_GLOBAL::test_store"
|
||||
|
||||
#! CHECKER Static lookup for 8-bit LdObjByName JIT
|
||||
#! RUN force_jit: true, options: "--compiler-regex='.*test_load.*'", entry: "_GLOBAL::test_load"
|
||||
#! METHOD "_GLOBAL::test_load"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsLdObjByNameI32/, 3
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsLdObjByNameI32/
|
||||
#! INST_COUNT /i8 *LoadObject/, 3
|
||||
|
||||
#! CHECKER Static lookup for 8-bit LdObjByName AOT
|
||||
#! SKIP_IF @architecture == "arm32"
|
||||
#! RUN_PAOC options: "--compiler-regex='.*test_load.*'"
|
||||
#! METHOD "_GLOBAL::test_load"
|
||||
#! PASS_AFTER "IrBuilder"
|
||||
#! INST_COUNT /Intrinsic.CompilerEtsLdObjByNameI32/, 3
|
||||
#! PASS_AFTER "Peepholes"
|
||||
#! PASS_AFTER_NEXT "Cleanup"
|
||||
#! INST_NOT /Intrinsic.CompilerEtsLdObjByNameI32/
|
||||
#! INST_COUNT /i8 *LoadObject/, 3
|
||||
#! RUN entry: "_GLOBAL::test_load"
|
||||
|
||||
|
||||
.language eTS
|
||||
|
||||
.record std.core.Object
|
||||
.record A {
|
||||
i8 bar
|
||||
i8 baz
|
||||
i8 foo
|
||||
}
|
||||
|
||||
.union_field i8 bar
|
||||
.union_field i8 baz
|
||||
.union_field i8 foo
|
||||
|
||||
.function i32 load_bar__noinline__(A a0) {
|
||||
ets.ldobj.name a0, bar
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 load_baz__noinline__(A a0) {
|
||||
ets.ldobj.name a0, baz
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 load_foo__noinline__(A a0) {
|
||||
ets.ldobj.name a0, foo
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 test_store() {
|
||||
newobj v0, A
|
||||
ldai -1
|
||||
ets.stobj.name v0, bar
|
||||
ets.stobj.name v0, foo
|
||||
|
||||
call.short load_baz__noinline__, v0
|
||||
jnez error1
|
||||
|
||||
movi v1, -1
|
||||
call.short load_bar__noinline__, v0
|
||||
jne v1, error2
|
||||
|
||||
call.short load_foo__noinline__, v0
|
||||
jne v1, error3
|
||||
|
||||
ldai 0
|
||||
return
|
||||
error1:
|
||||
ldai 1
|
||||
return
|
||||
error2:
|
||||
ldai 2
|
||||
return
|
||||
error3:
|
||||
ldai 3
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 fill__noinline__(A a0) {
|
||||
ldai -1
|
||||
ets.stobj.name a0, bar
|
||||
ets.stobj.name a0, foo
|
||||
return
|
||||
}
|
||||
|
||||
.function i32 test_load() {
|
||||
newobj v0, A
|
||||
call.short fill__noinline__, v0
|
||||
|
||||
ets.ldobj.name v0, baz
|
||||
jnez error1
|
||||
|
||||
movi v1, -1
|
||||
ets.ldobj.name v0, bar
|
||||
jne v1, error2
|
||||
|
||||
ets.ldobj.name v0, foo
|
||||
jne v1, error3
|
||||
|
||||
ldai 0
|
||||
return
|
||||
error1:
|
||||
ldai 1
|
||||
return
|
||||
error2:
|
||||
ldai 2
|
||||
return
|
||||
error3:
|
||||
ldai 3
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user