1# Copyright (c) 2021-2025 Huawei Device Co., Ltd. 2# Licensed under the Apache License, Version 2.0 (the "License"); 3# you may not use this file except in compliance with the License. 4# You may obtain a copy of the License at 5# 6# http://www.apache.org/licenses/LICENSE-2.0 7# 8# Unless required by applicable law or agreed to in writing, software 9# distributed under the License is distributed on an "AS IS" BASIS, 10# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 11# See the License for the specific language governing permissions and 12# limitations under the License. 13 14module EtsConstants 15 CORO_NULL_VALUE_OFFSET = "cross_values::GetEtsCoroutineNullValueOffset(graph->GetArch())" 16 ESCOMPAT_ARRAY_DATA_OFFSET = "cross_values::GetEscompatArrayBufferOffset(graph->GetArch())" 17 BOX_PRIMITIVE_VALUE_OFFSET = "cross_values::GetEtsBoxPrimitiveValueOffset(graph->GetArch())" 18end 19 20macro(:ets_nullvalue) do 21 LoadI(%tr).Imm(EtsConstants::CORO_NULL_VALUE_OFFSET).ref 22end 23 24### 25# Resolves a value of type 'ref_uint' stored in the memory by address 'base + offset', where 'offset` is an immediate 26# value, and returns it as a pointer. See also the 'ark::ObjectPointerType' alias and the 'ark::ObjectPointer' class. 27# 28macro(:get_object_pointer_imm) do |base, offset| 29 # Cast makes no problem when panda's codegen is in use but leads to an ill-formed 'addrspacecast i32 to ptr' 30 # instruction when the LLVM codegen is used. 'Bitcast' is lowered to the expected instruction 'inttoptr i32 to ptr'. 31 Bitcast(Cast(LoadI(base).Imm(offset).ref_uint).word).ptr 32end 33 34### 35# Resolves a value of type 'ref_uint' stored in the memory by address 'base + offset', and returns it as a pointer. 36# See also the 'ark::ObjectPointerType' alias and the 'ark::ObjectPointer' class. 37# 38macro(:get_object_pointer) do |base, offset| 39 Bitcast(Cast(Load(Cast(base).ptr, Cast(offset).word).ref_uint).word).ptr 40end 41