11cb0ef41Sopenharmony_ci// Copyright 2014 the V8 project authors. All rights reserved. 21cb0ef41Sopenharmony_ci// Use of this source code is governed by a BSD-style license that can be 31cb0ef41Sopenharmony_ci// found in the LICENSE file. 41cb0ef41Sopenharmony_ci 51cb0ef41Sopenharmony_ci#include <assert.h> // For assert 61cb0ef41Sopenharmony_ci#include <limits.h> // For LONG_MIN, LONG_MAX. 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390 91cb0ef41Sopenharmony_ci 101cb0ef41Sopenharmony_ci#include "src/base/bits.h" 111cb0ef41Sopenharmony_ci#include "src/base/division-by-constant.h" 121cb0ef41Sopenharmony_ci#include "src/codegen/callable.h" 131cb0ef41Sopenharmony_ci#include "src/codegen/code-factory.h" 141cb0ef41Sopenharmony_ci#include "src/codegen/external-reference-table.h" 151cb0ef41Sopenharmony_ci#include "src/codegen/interface-descriptors-inl.h" 161cb0ef41Sopenharmony_ci#include "src/codegen/macro-assembler.h" 171cb0ef41Sopenharmony_ci#include "src/codegen/register-configuration.h" 181cb0ef41Sopenharmony_ci#include "src/debug/debug.h" 191cb0ef41Sopenharmony_ci#include "src/deoptimizer/deoptimizer.h" 201cb0ef41Sopenharmony_ci#include "src/execution/frames-inl.h" 211cb0ef41Sopenharmony_ci#include "src/heap/memory-chunk.h" 221cb0ef41Sopenharmony_ci#include "src/init/bootstrapper.h" 231cb0ef41Sopenharmony_ci#include "src/logging/counters.h" 241cb0ef41Sopenharmony_ci#include "src/objects/smi.h" 251cb0ef41Sopenharmony_ci#include "src/runtime/runtime.h" 261cb0ef41Sopenharmony_ci#include "src/snapshot/snapshot.h" 271cb0ef41Sopenharmony_ci 281cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 291cb0ef41Sopenharmony_ci#include "src/wasm/wasm-code-manager.h" 301cb0ef41Sopenharmony_ci#endif // V8_ENABLE_WEBASSEMBLY 311cb0ef41Sopenharmony_ci 321cb0ef41Sopenharmony_ci// Satisfy cpplint check, but don't include platform-specific header. It is 331cb0ef41Sopenharmony_ci// included recursively via macro-assembler.h. 341cb0ef41Sopenharmony_ci#if 0 351cb0ef41Sopenharmony_ci#include "src/codegen/s390/macro-assembler-s390.h" 361cb0ef41Sopenharmony_ci#endif 371cb0ef41Sopenharmony_ci 381cb0ef41Sopenharmony_cinamespace v8 { 391cb0ef41Sopenharmony_cinamespace internal { 401cb0ef41Sopenharmony_ci 411cb0ef41Sopenharmony_cinamespace { 421cb0ef41Sopenharmony_ci 431cb0ef41Sopenharmony_ci// For WebAssembly we care about the full floating point (Simd) registers. If we 441cb0ef41Sopenharmony_ci// are not running Wasm, we can get away with saving half of those (F64) 451cb0ef41Sopenharmony_ci// registers. 461cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 471cb0ef41Sopenharmony_ciconstexpr int kStackSavedSavedFPSizeInBytes = 481cb0ef41Sopenharmony_ci kNumCallerSavedDoubles * kSimd128Size; 491cb0ef41Sopenharmony_ci#else 501cb0ef41Sopenharmony_ciconstexpr int kStackSavedSavedFPSizeInBytes = 511cb0ef41Sopenharmony_ci kNumCallerSavedDoubles * kDoubleSize; 521cb0ef41Sopenharmony_ci#endif // V8_ENABLE_WEBASSEMBLY 531cb0ef41Sopenharmony_ci 541cb0ef41Sopenharmony_ci} // namespace 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_civoid TurboAssembler::DoubleMax(DoubleRegister result_reg, 571cb0ef41Sopenharmony_ci DoubleRegister left_reg, 581cb0ef41Sopenharmony_ci DoubleRegister right_reg) { 591cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_1)) { 601cb0ef41Sopenharmony_ci vfmax(result_reg, left_reg, right_reg, Condition(1), Condition(8), 611cb0ef41Sopenharmony_ci Condition(3)); 621cb0ef41Sopenharmony_ci return; 631cb0ef41Sopenharmony_ci } 641cb0ef41Sopenharmony_ci 651cb0ef41Sopenharmony_ci Label check_zero, return_left, return_right, return_nan, done; 661cb0ef41Sopenharmony_ci cdbr(left_reg, right_reg); 671cb0ef41Sopenharmony_ci bunordered(&return_nan, Label::kNear); 681cb0ef41Sopenharmony_ci beq(&check_zero); 691cb0ef41Sopenharmony_ci bge(&return_left, Label::kNear); 701cb0ef41Sopenharmony_ci b(&return_right, Label::kNear); 711cb0ef41Sopenharmony_ci 721cb0ef41Sopenharmony_ci bind(&check_zero); 731cb0ef41Sopenharmony_ci lzdr(kDoubleRegZero); 741cb0ef41Sopenharmony_ci cdbr(left_reg, kDoubleRegZero); 751cb0ef41Sopenharmony_ci /* left == right != 0. */ 761cb0ef41Sopenharmony_ci bne(&return_left, Label::kNear); 771cb0ef41Sopenharmony_ci /* At this point, both left and right are either 0 or -0. */ 781cb0ef41Sopenharmony_ci /* N.B. The following works because +0 + -0 == +0 */ 791cb0ef41Sopenharmony_ci /* For max we want logical-and of sign bit: (L + R) */ 801cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 811cb0ef41Sopenharmony_ci adbr(result_reg, right_reg); 821cb0ef41Sopenharmony_ci b(&done, Label::kNear); 831cb0ef41Sopenharmony_ci 841cb0ef41Sopenharmony_ci bind(&return_nan); 851cb0ef41Sopenharmony_ci /* If left or right are NaN, adbr propagates the appropriate one.*/ 861cb0ef41Sopenharmony_ci adbr(left_reg, right_reg); 871cb0ef41Sopenharmony_ci b(&return_left, Label::kNear); 881cb0ef41Sopenharmony_ci 891cb0ef41Sopenharmony_ci bind(&return_right); 901cb0ef41Sopenharmony_ci if (right_reg != result_reg) { 911cb0ef41Sopenharmony_ci ldr(result_reg, right_reg); 921cb0ef41Sopenharmony_ci } 931cb0ef41Sopenharmony_ci b(&done, Label::kNear); 941cb0ef41Sopenharmony_ci 951cb0ef41Sopenharmony_ci bind(&return_left); 961cb0ef41Sopenharmony_ci if (left_reg != result_reg) { 971cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 981cb0ef41Sopenharmony_ci } 991cb0ef41Sopenharmony_ci bind(&done); 1001cb0ef41Sopenharmony_ci} 1011cb0ef41Sopenharmony_ci 1021cb0ef41Sopenharmony_civoid TurboAssembler::DoubleMin(DoubleRegister result_reg, 1031cb0ef41Sopenharmony_ci DoubleRegister left_reg, 1041cb0ef41Sopenharmony_ci DoubleRegister right_reg) { 1051cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_1)) { 1061cb0ef41Sopenharmony_ci vfmin(result_reg, left_reg, right_reg, Condition(1), Condition(8), 1071cb0ef41Sopenharmony_ci Condition(3)); 1081cb0ef41Sopenharmony_ci return; 1091cb0ef41Sopenharmony_ci } 1101cb0ef41Sopenharmony_ci Label check_zero, return_left, return_right, return_nan, done; 1111cb0ef41Sopenharmony_ci cdbr(left_reg, right_reg); 1121cb0ef41Sopenharmony_ci bunordered(&return_nan, Label::kNear); 1131cb0ef41Sopenharmony_ci beq(&check_zero); 1141cb0ef41Sopenharmony_ci ble(&return_left, Label::kNear); 1151cb0ef41Sopenharmony_ci b(&return_right, Label::kNear); 1161cb0ef41Sopenharmony_ci 1171cb0ef41Sopenharmony_ci bind(&check_zero); 1181cb0ef41Sopenharmony_ci lzdr(kDoubleRegZero); 1191cb0ef41Sopenharmony_ci cdbr(left_reg, kDoubleRegZero); 1201cb0ef41Sopenharmony_ci /* left == right != 0. */ 1211cb0ef41Sopenharmony_ci bne(&return_left, Label::kNear); 1221cb0ef41Sopenharmony_ci /* At this point, both left and right are either 0 or -0. */ 1231cb0ef41Sopenharmony_ci /* N.B. The following works because +0 + -0 == +0 */ 1241cb0ef41Sopenharmony_ci /* For min we want logical-or of sign bit: -(-L + -R) */ 1251cb0ef41Sopenharmony_ci lcdbr(left_reg, left_reg); 1261cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 1271cb0ef41Sopenharmony_ci if (left_reg == right_reg) { 1281cb0ef41Sopenharmony_ci adbr(result_reg, right_reg); 1291cb0ef41Sopenharmony_ci } else { 1301cb0ef41Sopenharmony_ci sdbr(result_reg, right_reg); 1311cb0ef41Sopenharmony_ci } 1321cb0ef41Sopenharmony_ci lcdbr(result_reg, result_reg); 1331cb0ef41Sopenharmony_ci b(&done, Label::kNear); 1341cb0ef41Sopenharmony_ci 1351cb0ef41Sopenharmony_ci bind(&return_nan); 1361cb0ef41Sopenharmony_ci /* If left or right are NaN, adbr propagates the appropriate one.*/ 1371cb0ef41Sopenharmony_ci adbr(left_reg, right_reg); 1381cb0ef41Sopenharmony_ci b(&return_left, Label::kNear); 1391cb0ef41Sopenharmony_ci 1401cb0ef41Sopenharmony_ci bind(&return_right); 1411cb0ef41Sopenharmony_ci if (right_reg != result_reg) { 1421cb0ef41Sopenharmony_ci ldr(result_reg, right_reg); 1431cb0ef41Sopenharmony_ci } 1441cb0ef41Sopenharmony_ci b(&done, Label::kNear); 1451cb0ef41Sopenharmony_ci 1461cb0ef41Sopenharmony_ci bind(&return_left); 1471cb0ef41Sopenharmony_ci if (left_reg != result_reg) { 1481cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 1491cb0ef41Sopenharmony_ci } 1501cb0ef41Sopenharmony_ci bind(&done); 1511cb0ef41Sopenharmony_ci} 1521cb0ef41Sopenharmony_ci 1531cb0ef41Sopenharmony_civoid TurboAssembler::FloatMax(DoubleRegister result_reg, 1541cb0ef41Sopenharmony_ci DoubleRegister left_reg, 1551cb0ef41Sopenharmony_ci DoubleRegister right_reg) { 1561cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_1)) { 1571cb0ef41Sopenharmony_ci vfmax(result_reg, left_reg, right_reg, Condition(1), Condition(8), 1581cb0ef41Sopenharmony_ci Condition(2)); 1591cb0ef41Sopenharmony_ci return; 1601cb0ef41Sopenharmony_ci } 1611cb0ef41Sopenharmony_ci Label check_zero, return_left, return_right, return_nan, done; 1621cb0ef41Sopenharmony_ci cebr(left_reg, right_reg); 1631cb0ef41Sopenharmony_ci bunordered(&return_nan, Label::kNear); 1641cb0ef41Sopenharmony_ci beq(&check_zero); 1651cb0ef41Sopenharmony_ci bge(&return_left, Label::kNear); 1661cb0ef41Sopenharmony_ci b(&return_right, Label::kNear); 1671cb0ef41Sopenharmony_ci 1681cb0ef41Sopenharmony_ci bind(&check_zero); 1691cb0ef41Sopenharmony_ci lzdr(kDoubleRegZero); 1701cb0ef41Sopenharmony_ci cebr(left_reg, kDoubleRegZero); 1711cb0ef41Sopenharmony_ci /* left == right != 0. */ 1721cb0ef41Sopenharmony_ci bne(&return_left, Label::kNear); 1731cb0ef41Sopenharmony_ci /* At this point, both left and right are either 0 or -0. */ 1741cb0ef41Sopenharmony_ci /* N.B. The following works because +0 + -0 == +0 */ 1751cb0ef41Sopenharmony_ci /* For max we want logical-and of sign bit: (L + R) */ 1761cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 1771cb0ef41Sopenharmony_ci aebr(result_reg, right_reg); 1781cb0ef41Sopenharmony_ci b(&done, Label::kNear); 1791cb0ef41Sopenharmony_ci 1801cb0ef41Sopenharmony_ci bind(&return_nan); 1811cb0ef41Sopenharmony_ci /* If left or right are NaN, aebr propagates the appropriate one.*/ 1821cb0ef41Sopenharmony_ci aebr(left_reg, right_reg); 1831cb0ef41Sopenharmony_ci b(&return_left, Label::kNear); 1841cb0ef41Sopenharmony_ci 1851cb0ef41Sopenharmony_ci bind(&return_right); 1861cb0ef41Sopenharmony_ci if (right_reg != result_reg) { 1871cb0ef41Sopenharmony_ci ldr(result_reg, right_reg); 1881cb0ef41Sopenharmony_ci } 1891cb0ef41Sopenharmony_ci b(&done, Label::kNear); 1901cb0ef41Sopenharmony_ci 1911cb0ef41Sopenharmony_ci bind(&return_left); 1921cb0ef41Sopenharmony_ci if (left_reg != result_reg) { 1931cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 1941cb0ef41Sopenharmony_ci } 1951cb0ef41Sopenharmony_ci bind(&done); 1961cb0ef41Sopenharmony_ci} 1971cb0ef41Sopenharmony_ci 1981cb0ef41Sopenharmony_civoid TurboAssembler::FloatMin(DoubleRegister result_reg, 1991cb0ef41Sopenharmony_ci DoubleRegister left_reg, 2001cb0ef41Sopenharmony_ci DoubleRegister right_reg) { 2011cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_1)) { 2021cb0ef41Sopenharmony_ci vfmin(result_reg, left_reg, right_reg, Condition(1), Condition(8), 2031cb0ef41Sopenharmony_ci Condition(2)); 2041cb0ef41Sopenharmony_ci return; 2051cb0ef41Sopenharmony_ci } 2061cb0ef41Sopenharmony_ci 2071cb0ef41Sopenharmony_ci Label check_zero, return_left, return_right, return_nan, done; 2081cb0ef41Sopenharmony_ci cebr(left_reg, right_reg); 2091cb0ef41Sopenharmony_ci bunordered(&return_nan, Label::kNear); 2101cb0ef41Sopenharmony_ci beq(&check_zero); 2111cb0ef41Sopenharmony_ci ble(&return_left, Label::kNear); 2121cb0ef41Sopenharmony_ci b(&return_right, Label::kNear); 2131cb0ef41Sopenharmony_ci 2141cb0ef41Sopenharmony_ci bind(&check_zero); 2151cb0ef41Sopenharmony_ci lzdr(kDoubleRegZero); 2161cb0ef41Sopenharmony_ci cebr(left_reg, kDoubleRegZero); 2171cb0ef41Sopenharmony_ci /* left == right != 0. */ 2181cb0ef41Sopenharmony_ci bne(&return_left, Label::kNear); 2191cb0ef41Sopenharmony_ci /* At this point, both left and right are either 0 or -0. */ 2201cb0ef41Sopenharmony_ci /* N.B. The following works because +0 + -0 == +0 */ 2211cb0ef41Sopenharmony_ci /* For min we want logical-or of sign bit: -(-L + -R) */ 2221cb0ef41Sopenharmony_ci lcebr(left_reg, left_reg); 2231cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 2241cb0ef41Sopenharmony_ci if (left_reg == right_reg) { 2251cb0ef41Sopenharmony_ci aebr(result_reg, right_reg); 2261cb0ef41Sopenharmony_ci } else { 2271cb0ef41Sopenharmony_ci sebr(result_reg, right_reg); 2281cb0ef41Sopenharmony_ci } 2291cb0ef41Sopenharmony_ci lcebr(result_reg, result_reg); 2301cb0ef41Sopenharmony_ci b(&done, Label::kNear); 2311cb0ef41Sopenharmony_ci 2321cb0ef41Sopenharmony_ci bind(&return_nan); 2331cb0ef41Sopenharmony_ci /* If left or right are NaN, aebr propagates the appropriate one.*/ 2341cb0ef41Sopenharmony_ci aebr(left_reg, right_reg); 2351cb0ef41Sopenharmony_ci b(&return_left, Label::kNear); 2361cb0ef41Sopenharmony_ci 2371cb0ef41Sopenharmony_ci bind(&return_right); 2381cb0ef41Sopenharmony_ci if (right_reg != result_reg) { 2391cb0ef41Sopenharmony_ci ldr(result_reg, right_reg); 2401cb0ef41Sopenharmony_ci } 2411cb0ef41Sopenharmony_ci b(&done, Label::kNear); 2421cb0ef41Sopenharmony_ci 2431cb0ef41Sopenharmony_ci bind(&return_left); 2441cb0ef41Sopenharmony_ci if (left_reg != result_reg) { 2451cb0ef41Sopenharmony_ci ldr(result_reg, left_reg); 2461cb0ef41Sopenharmony_ci } 2471cb0ef41Sopenharmony_ci bind(&done); 2481cb0ef41Sopenharmony_ci} 2491cb0ef41Sopenharmony_ci 2501cb0ef41Sopenharmony_civoid TurboAssembler::CeilF32(DoubleRegister dst, DoubleRegister src) { 2511cb0ef41Sopenharmony_ci fiebra(ROUND_TOWARD_POS_INF, dst, src); 2521cb0ef41Sopenharmony_ci} 2531cb0ef41Sopenharmony_ci 2541cb0ef41Sopenharmony_civoid TurboAssembler::CeilF64(DoubleRegister dst, DoubleRegister src) { 2551cb0ef41Sopenharmony_ci fidbra(ROUND_TOWARD_POS_INF, dst, src); 2561cb0ef41Sopenharmony_ci} 2571cb0ef41Sopenharmony_ci 2581cb0ef41Sopenharmony_civoid TurboAssembler::FloorF32(DoubleRegister dst, DoubleRegister src) { 2591cb0ef41Sopenharmony_ci fiebra(ROUND_TOWARD_NEG_INF, dst, src); 2601cb0ef41Sopenharmony_ci} 2611cb0ef41Sopenharmony_ci 2621cb0ef41Sopenharmony_civoid TurboAssembler::FloorF64(DoubleRegister dst, DoubleRegister src) { 2631cb0ef41Sopenharmony_ci fidbra(ROUND_TOWARD_NEG_INF, dst, src); 2641cb0ef41Sopenharmony_ci} 2651cb0ef41Sopenharmony_ci 2661cb0ef41Sopenharmony_civoid TurboAssembler::TruncF32(DoubleRegister dst, DoubleRegister src) { 2671cb0ef41Sopenharmony_ci fiebra(ROUND_TOWARD_0, dst, src); 2681cb0ef41Sopenharmony_ci} 2691cb0ef41Sopenharmony_ci 2701cb0ef41Sopenharmony_civoid TurboAssembler::TruncF64(DoubleRegister dst, DoubleRegister src) { 2711cb0ef41Sopenharmony_ci fidbra(ROUND_TOWARD_0, dst, src); 2721cb0ef41Sopenharmony_ci} 2731cb0ef41Sopenharmony_ci 2741cb0ef41Sopenharmony_civoid TurboAssembler::NearestIntF32(DoubleRegister dst, DoubleRegister src) { 2751cb0ef41Sopenharmony_ci fiebra(ROUND_TO_NEAREST_TO_EVEN, dst, src); 2761cb0ef41Sopenharmony_ci} 2771cb0ef41Sopenharmony_ci 2781cb0ef41Sopenharmony_civoid TurboAssembler::NearestIntF64(DoubleRegister dst, DoubleRegister src) { 2791cb0ef41Sopenharmony_ci fidbra(ROUND_TO_NEAREST_TO_EVEN, dst, src); 2801cb0ef41Sopenharmony_ci} 2811cb0ef41Sopenharmony_ci 2821cb0ef41Sopenharmony_ciint TurboAssembler::RequiredStackSizeForCallerSaved(SaveFPRegsMode fp_mode, 2831cb0ef41Sopenharmony_ci Register exclusion1, 2841cb0ef41Sopenharmony_ci Register exclusion2, 2851cb0ef41Sopenharmony_ci Register exclusion3) const { 2861cb0ef41Sopenharmony_ci int bytes = 0; 2871cb0ef41Sopenharmony_ci 2881cb0ef41Sopenharmony_ci RegList exclusions = {exclusion1, exclusion2, exclusion3}; 2891cb0ef41Sopenharmony_ci RegList list = kJSCallerSaved - exclusions; 2901cb0ef41Sopenharmony_ci bytes += list.Count() * kSystemPointerSize; 2911cb0ef41Sopenharmony_ci 2921cb0ef41Sopenharmony_ci if (fp_mode == SaveFPRegsMode::kSave) { 2931cb0ef41Sopenharmony_ci bytes += kStackSavedSavedFPSizeInBytes; 2941cb0ef41Sopenharmony_ci } 2951cb0ef41Sopenharmony_ci 2961cb0ef41Sopenharmony_ci return bytes; 2971cb0ef41Sopenharmony_ci} 2981cb0ef41Sopenharmony_ci 2991cb0ef41Sopenharmony_ciint TurboAssembler::PushCallerSaved(SaveFPRegsMode fp_mode, Register scratch, 3001cb0ef41Sopenharmony_ci Register exclusion1, Register exclusion2, 3011cb0ef41Sopenharmony_ci Register exclusion3) { 3021cb0ef41Sopenharmony_ci int bytes = 0; 3031cb0ef41Sopenharmony_ci 3041cb0ef41Sopenharmony_ci RegList exclusions = {exclusion1, exclusion2, exclusion3}; 3051cb0ef41Sopenharmony_ci RegList list = kJSCallerSaved - exclusions; 3061cb0ef41Sopenharmony_ci MultiPush(list); 3071cb0ef41Sopenharmony_ci bytes += list.Count() * kSystemPointerSize; 3081cb0ef41Sopenharmony_ci 3091cb0ef41Sopenharmony_ci if (fp_mode == SaveFPRegsMode::kSave) { 3101cb0ef41Sopenharmony_ci MultiPushF64OrV128(kCallerSavedDoubles, scratch); 3111cb0ef41Sopenharmony_ci bytes += kStackSavedSavedFPSizeInBytes; 3121cb0ef41Sopenharmony_ci } 3131cb0ef41Sopenharmony_ci 3141cb0ef41Sopenharmony_ci return bytes; 3151cb0ef41Sopenharmony_ci} 3161cb0ef41Sopenharmony_ci 3171cb0ef41Sopenharmony_ciint TurboAssembler::PopCallerSaved(SaveFPRegsMode fp_mode, Register scratch, 3181cb0ef41Sopenharmony_ci Register exclusion1, Register exclusion2, 3191cb0ef41Sopenharmony_ci Register exclusion3) { 3201cb0ef41Sopenharmony_ci int bytes = 0; 3211cb0ef41Sopenharmony_ci if (fp_mode == SaveFPRegsMode::kSave) { 3221cb0ef41Sopenharmony_ci MultiPopF64OrV128(kCallerSavedDoubles, scratch); 3231cb0ef41Sopenharmony_ci bytes += kStackSavedSavedFPSizeInBytes; 3241cb0ef41Sopenharmony_ci } 3251cb0ef41Sopenharmony_ci 3261cb0ef41Sopenharmony_ci RegList exclusions = {exclusion1, exclusion2, exclusion3}; 3271cb0ef41Sopenharmony_ci RegList list = kJSCallerSaved - exclusions; 3281cb0ef41Sopenharmony_ci MultiPop(list); 3291cb0ef41Sopenharmony_ci bytes += list.Count() * kSystemPointerSize; 3301cb0ef41Sopenharmony_ci 3311cb0ef41Sopenharmony_ci return bytes; 3321cb0ef41Sopenharmony_ci} 3331cb0ef41Sopenharmony_ci 3341cb0ef41Sopenharmony_civoid TurboAssembler::LoadFromConstantsTable(Register destination, 3351cb0ef41Sopenharmony_ci int constant_index) { 3361cb0ef41Sopenharmony_ci DCHECK(RootsTable::IsImmortalImmovable(RootIndex::kBuiltinsConstantsTable)); 3371cb0ef41Sopenharmony_ci 3381cb0ef41Sopenharmony_ci const uint32_t offset = FixedArray::kHeaderSize + 3391cb0ef41Sopenharmony_ci constant_index * kSystemPointerSize - kHeapObjectTag; 3401cb0ef41Sopenharmony_ci 3411cb0ef41Sopenharmony_ci CHECK(is_uint19(offset)); 3421cb0ef41Sopenharmony_ci DCHECK_NE(destination, r0); 3431cb0ef41Sopenharmony_ci LoadRoot(destination, RootIndex::kBuiltinsConstantsTable); 3441cb0ef41Sopenharmony_ci LoadTaggedPointerField( 3451cb0ef41Sopenharmony_ci destination, 3461cb0ef41Sopenharmony_ci FieldMemOperand(destination, 3471cb0ef41Sopenharmony_ci FixedArray::OffsetOfElementAt(constant_index)), 3481cb0ef41Sopenharmony_ci r1); 3491cb0ef41Sopenharmony_ci} 3501cb0ef41Sopenharmony_ci 3511cb0ef41Sopenharmony_civoid TurboAssembler::LoadRootRelative(Register destination, int32_t offset) { 3521cb0ef41Sopenharmony_ci LoadU64(destination, MemOperand(kRootRegister, offset)); 3531cb0ef41Sopenharmony_ci} 3541cb0ef41Sopenharmony_ci 3551cb0ef41Sopenharmony_civoid TurboAssembler::LoadRootRegisterOffset(Register destination, 3561cb0ef41Sopenharmony_ci intptr_t offset) { 3571cb0ef41Sopenharmony_ci if (offset == 0) { 3581cb0ef41Sopenharmony_ci mov(destination, kRootRegister); 3591cb0ef41Sopenharmony_ci } else if (is_uint12(offset)) { 3601cb0ef41Sopenharmony_ci la(destination, MemOperand(kRootRegister, offset)); 3611cb0ef41Sopenharmony_ci } else { 3621cb0ef41Sopenharmony_ci DCHECK(is_int20(offset)); 3631cb0ef41Sopenharmony_ci lay(destination, MemOperand(kRootRegister, offset)); 3641cb0ef41Sopenharmony_ci } 3651cb0ef41Sopenharmony_ci} 3661cb0ef41Sopenharmony_ci 3671cb0ef41Sopenharmony_civoid TurboAssembler::Jump(Register target, Condition cond) { b(cond, target); } 3681cb0ef41Sopenharmony_ci 3691cb0ef41Sopenharmony_civoid TurboAssembler::Jump(intptr_t target, RelocInfo::Mode rmode, 3701cb0ef41Sopenharmony_ci Condition cond) { 3711cb0ef41Sopenharmony_ci Label skip; 3721cb0ef41Sopenharmony_ci 3731cb0ef41Sopenharmony_ci if (cond != al) b(NegateCondition(cond), &skip); 3741cb0ef41Sopenharmony_ci 3751cb0ef41Sopenharmony_ci mov(ip, Operand(target, rmode)); 3761cb0ef41Sopenharmony_ci b(ip); 3771cb0ef41Sopenharmony_ci 3781cb0ef41Sopenharmony_ci bind(&skip); 3791cb0ef41Sopenharmony_ci} 3801cb0ef41Sopenharmony_ci 3811cb0ef41Sopenharmony_civoid TurboAssembler::Jump(Address target, RelocInfo::Mode rmode, 3821cb0ef41Sopenharmony_ci Condition cond) { 3831cb0ef41Sopenharmony_ci DCHECK(!RelocInfo::IsCodeTarget(rmode)); 3841cb0ef41Sopenharmony_ci Jump(static_cast<intptr_t>(target), rmode, cond); 3851cb0ef41Sopenharmony_ci} 3861cb0ef41Sopenharmony_ci 3871cb0ef41Sopenharmony_civoid TurboAssembler::Jump(Handle<Code> code, RelocInfo::Mode rmode, 3881cb0ef41Sopenharmony_ci Condition cond) { 3891cb0ef41Sopenharmony_ci DCHECK(RelocInfo::IsCodeTarget(rmode)); 3901cb0ef41Sopenharmony_ci DCHECK_IMPLIES(options().isolate_independent_code, 3911cb0ef41Sopenharmony_ci Builtins::IsIsolateIndependentBuiltin(*code)); 3921cb0ef41Sopenharmony_ci 3931cb0ef41Sopenharmony_ci Builtin builtin = Builtin::kNoBuiltinId; 3941cb0ef41Sopenharmony_ci bool target_is_builtin = 3951cb0ef41Sopenharmony_ci isolate()->builtins()->IsBuiltinHandle(code, &builtin); 3961cb0ef41Sopenharmony_ci 3971cb0ef41Sopenharmony_ci if (options().inline_offheap_trampolines && target_is_builtin) { 3981cb0ef41Sopenharmony_ci // Inline the trampoline. 3991cb0ef41Sopenharmony_ci RecordCommentForOffHeapTrampoline(builtin); 4001cb0ef41Sopenharmony_ci mov(ip, Operand(BuiltinEntry(builtin), RelocInfo::OFF_HEAP_TARGET)); 4011cb0ef41Sopenharmony_ci b(cond, ip); 4021cb0ef41Sopenharmony_ci return; 4031cb0ef41Sopenharmony_ci } 4041cb0ef41Sopenharmony_ci jump(code, RelocInfo::RELATIVE_CODE_TARGET, cond); 4051cb0ef41Sopenharmony_ci} 4061cb0ef41Sopenharmony_ci 4071cb0ef41Sopenharmony_civoid TurboAssembler::Jump(const ExternalReference& reference) { 4081cb0ef41Sopenharmony_ci UseScratchRegisterScope temps(this); 4091cb0ef41Sopenharmony_ci Register scratch = temps.Acquire(); 4101cb0ef41Sopenharmony_ci Move(scratch, reference); 4111cb0ef41Sopenharmony_ci Jump(scratch); 4121cb0ef41Sopenharmony_ci} 4131cb0ef41Sopenharmony_ci 4141cb0ef41Sopenharmony_civoid TurboAssembler::Call(Register target) { 4151cb0ef41Sopenharmony_ci // Branch to target via indirect branch 4161cb0ef41Sopenharmony_ci basr(r14, target); 4171cb0ef41Sopenharmony_ci} 4181cb0ef41Sopenharmony_ci 4191cb0ef41Sopenharmony_civoid MacroAssembler::CallJSEntry(Register target) { 4201cb0ef41Sopenharmony_ci DCHECK(target == r4); 4211cb0ef41Sopenharmony_ci Call(target); 4221cb0ef41Sopenharmony_ci} 4231cb0ef41Sopenharmony_ci 4241cb0ef41Sopenharmony_ciint MacroAssembler::CallSizeNotPredictableCodeSize(Address target, 4251cb0ef41Sopenharmony_ci RelocInfo::Mode rmode, 4261cb0ef41Sopenharmony_ci Condition cond) { 4271cb0ef41Sopenharmony_ci // S390 Assembler::move sequence is IILF / IIHF 4281cb0ef41Sopenharmony_ci int size; 4291cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 4301cb0ef41Sopenharmony_ci size = 14; // IILF + IIHF + BASR 4311cb0ef41Sopenharmony_ci#else 4321cb0ef41Sopenharmony_ci size = 8; // IILF + BASR 4331cb0ef41Sopenharmony_ci#endif 4341cb0ef41Sopenharmony_ci return size; 4351cb0ef41Sopenharmony_ci} 4361cb0ef41Sopenharmony_ci 4371cb0ef41Sopenharmony_civoid TurboAssembler::Call(Address target, RelocInfo::Mode rmode, 4381cb0ef41Sopenharmony_ci Condition cond) { 4391cb0ef41Sopenharmony_ci DCHECK(cond == al); 4401cb0ef41Sopenharmony_ci 4411cb0ef41Sopenharmony_ci mov(ip, Operand(target, rmode)); 4421cb0ef41Sopenharmony_ci basr(r14, ip); 4431cb0ef41Sopenharmony_ci} 4441cb0ef41Sopenharmony_ci 4451cb0ef41Sopenharmony_civoid TurboAssembler::Call(Handle<Code> code, RelocInfo::Mode rmode, 4461cb0ef41Sopenharmony_ci Condition cond) { 4471cb0ef41Sopenharmony_ci DCHECK(RelocInfo::IsCodeTarget(rmode) && cond == al); 4481cb0ef41Sopenharmony_ci 4491cb0ef41Sopenharmony_ci DCHECK_IMPLIES(options().isolate_independent_code, 4501cb0ef41Sopenharmony_ci Builtins::IsIsolateIndependentBuiltin(*code)); 4511cb0ef41Sopenharmony_ci Builtin builtin = Builtin::kNoBuiltinId; 4521cb0ef41Sopenharmony_ci bool target_is_builtin = 4531cb0ef41Sopenharmony_ci isolate()->builtins()->IsBuiltinHandle(code, &builtin); 4541cb0ef41Sopenharmony_ci 4551cb0ef41Sopenharmony_ci if (target_is_builtin && options().inline_offheap_trampolines) { 4561cb0ef41Sopenharmony_ci // Inline the trampoline. 4571cb0ef41Sopenharmony_ci CallBuiltin(builtin); 4581cb0ef41Sopenharmony_ci return; 4591cb0ef41Sopenharmony_ci } 4601cb0ef41Sopenharmony_ci DCHECK(code->IsExecutable()); 4611cb0ef41Sopenharmony_ci call(code, rmode); 4621cb0ef41Sopenharmony_ci} 4631cb0ef41Sopenharmony_ci 4641cb0ef41Sopenharmony_civoid TurboAssembler::CallBuiltin(Builtin builtin) { 4651cb0ef41Sopenharmony_ci ASM_CODE_COMMENT_STRING(this, CommentForOffHeapTrampoline("call", builtin)); 4661cb0ef41Sopenharmony_ci DCHECK(Builtins::IsBuiltinId(builtin)); 4671cb0ef41Sopenharmony_ci // Use ip directly instead of using UseScratchRegisterScope, as we do not 4681cb0ef41Sopenharmony_ci // preserve scratch registers across calls. 4691cb0ef41Sopenharmony_ci mov(ip, Operand(BuiltinEntry(builtin), RelocInfo::OFF_HEAP_TARGET)); 4701cb0ef41Sopenharmony_ci Call(ip); 4711cb0ef41Sopenharmony_ci} 4721cb0ef41Sopenharmony_ci 4731cb0ef41Sopenharmony_civoid TurboAssembler::TailCallBuiltin(Builtin builtin) { 4741cb0ef41Sopenharmony_ci ASM_CODE_COMMENT_STRING(this, 4751cb0ef41Sopenharmony_ci CommentForOffHeapTrampoline("tail call", builtin)); 4761cb0ef41Sopenharmony_ci mov(ip, Operand(BuiltinEntry(builtin), RelocInfo::OFF_HEAP_TARGET)); 4771cb0ef41Sopenharmony_ci b(ip); 4781cb0ef41Sopenharmony_ci} 4791cb0ef41Sopenharmony_ci 4801cb0ef41Sopenharmony_civoid TurboAssembler::Drop(int count) { 4811cb0ef41Sopenharmony_ci if (count > 0) { 4821cb0ef41Sopenharmony_ci int total = count * kSystemPointerSize; 4831cb0ef41Sopenharmony_ci if (is_uint12(total)) { 4841cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, total)); 4851cb0ef41Sopenharmony_ci } else if (is_int20(total)) { 4861cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, total)); 4871cb0ef41Sopenharmony_ci } else { 4881cb0ef41Sopenharmony_ci AddS64(sp, Operand(total)); 4891cb0ef41Sopenharmony_ci } 4901cb0ef41Sopenharmony_ci } 4911cb0ef41Sopenharmony_ci} 4921cb0ef41Sopenharmony_ci 4931cb0ef41Sopenharmony_civoid TurboAssembler::Drop(Register count, Register scratch) { 4941cb0ef41Sopenharmony_ci ShiftLeftU64(scratch, count, Operand(kSystemPointerSizeLog2)); 4951cb0ef41Sopenharmony_ci AddS64(sp, sp, scratch); 4961cb0ef41Sopenharmony_ci} 4971cb0ef41Sopenharmony_ci 4981cb0ef41Sopenharmony_civoid TurboAssembler::Call(Label* target) { b(r14, target); } 4991cb0ef41Sopenharmony_ci 5001cb0ef41Sopenharmony_civoid TurboAssembler::Push(Handle<HeapObject> handle) { 5011cb0ef41Sopenharmony_ci mov(r0, Operand(handle)); 5021cb0ef41Sopenharmony_ci push(r0); 5031cb0ef41Sopenharmony_ci} 5041cb0ef41Sopenharmony_ci 5051cb0ef41Sopenharmony_civoid TurboAssembler::Push(Smi smi) { 5061cb0ef41Sopenharmony_ci mov(r0, Operand(smi)); 5071cb0ef41Sopenharmony_ci push(r0); 5081cb0ef41Sopenharmony_ci} 5091cb0ef41Sopenharmony_ci 5101cb0ef41Sopenharmony_civoid TurboAssembler::Move(Register dst, Handle<HeapObject> value, 5111cb0ef41Sopenharmony_ci RelocInfo::Mode rmode) { 5121cb0ef41Sopenharmony_ci // TODO(jgruber,v8:8887): Also consider a root-relative load when generating 5131cb0ef41Sopenharmony_ci // non-isolate-independent code. In many cases it might be cheaper than 5141cb0ef41Sopenharmony_ci // embedding the relocatable value. 5151cb0ef41Sopenharmony_ci if (root_array_available_ && options().isolate_independent_code) { 5161cb0ef41Sopenharmony_ci IndirectLoadConstant(dst, value); 5171cb0ef41Sopenharmony_ci return; 5181cb0ef41Sopenharmony_ci } else if (RelocInfo::IsCompressedEmbeddedObject(rmode)) { 5191cb0ef41Sopenharmony_ci EmbeddedObjectIndex index = AddEmbeddedObject(value); 5201cb0ef41Sopenharmony_ci DCHECK(is_uint32(index)); 5211cb0ef41Sopenharmony_ci mov(dst, Operand(static_cast<int>(index), rmode)); 5221cb0ef41Sopenharmony_ci } else { 5231cb0ef41Sopenharmony_ci DCHECK(RelocInfo::IsFullEmbeddedObject(rmode)); 5241cb0ef41Sopenharmony_ci mov(dst, Operand(value.address(), rmode)); 5251cb0ef41Sopenharmony_ci } 5261cb0ef41Sopenharmony_ci} 5271cb0ef41Sopenharmony_ci 5281cb0ef41Sopenharmony_civoid TurboAssembler::Move(Register dst, ExternalReference reference) { 5291cb0ef41Sopenharmony_ci // TODO(jgruber,v8:8887): Also consider a root-relative load when generating 5301cb0ef41Sopenharmony_ci // non-isolate-independent code. In many cases it might be cheaper than 5311cb0ef41Sopenharmony_ci // embedding the relocatable value. 5321cb0ef41Sopenharmony_ci if (root_array_available_ && options().isolate_independent_code) { 5331cb0ef41Sopenharmony_ci IndirectLoadExternalReference(dst, reference); 5341cb0ef41Sopenharmony_ci return; 5351cb0ef41Sopenharmony_ci } 5361cb0ef41Sopenharmony_ci mov(dst, Operand(reference)); 5371cb0ef41Sopenharmony_ci} 5381cb0ef41Sopenharmony_ci 5391cb0ef41Sopenharmony_civoid TurboAssembler::Move(Register dst, Register src, Condition cond) { 5401cb0ef41Sopenharmony_ci if (dst != src) { 5411cb0ef41Sopenharmony_ci if (cond == al) { 5421cb0ef41Sopenharmony_ci mov(dst, src); 5431cb0ef41Sopenharmony_ci } else { 5441cb0ef41Sopenharmony_ci LoadOnConditionP(cond, dst, src); 5451cb0ef41Sopenharmony_ci } 5461cb0ef41Sopenharmony_ci } 5471cb0ef41Sopenharmony_ci} 5481cb0ef41Sopenharmony_ci 5491cb0ef41Sopenharmony_civoid TurboAssembler::Move(DoubleRegister dst, DoubleRegister src) { 5501cb0ef41Sopenharmony_ci if (dst != src) { 5511cb0ef41Sopenharmony_ci ldr(dst, src); 5521cb0ef41Sopenharmony_ci } 5531cb0ef41Sopenharmony_ci} 5541cb0ef41Sopenharmony_ci 5551cb0ef41Sopenharmony_civoid TurboAssembler::Move(Register dst, const MemOperand& src) { 5561cb0ef41Sopenharmony_ci LoadU64(dst, src); 5571cb0ef41Sopenharmony_ci} 5581cb0ef41Sopenharmony_ci 5591cb0ef41Sopenharmony_ci// Wrapper around Assembler::mvc (SS-a format) 5601cb0ef41Sopenharmony_civoid TurboAssembler::MoveChar(const MemOperand& opnd1, const MemOperand& opnd2, 5611cb0ef41Sopenharmony_ci const Operand& length) { 5621cb0ef41Sopenharmony_ci mvc(opnd1, opnd2, Operand(static_cast<intptr_t>(length.immediate() - 1))); 5631cb0ef41Sopenharmony_ci} 5641cb0ef41Sopenharmony_ci 5651cb0ef41Sopenharmony_ci// Wrapper around Assembler::clc (SS-a format) 5661cb0ef41Sopenharmony_civoid TurboAssembler::CompareLogicalChar(const MemOperand& opnd1, 5671cb0ef41Sopenharmony_ci const MemOperand& opnd2, 5681cb0ef41Sopenharmony_ci const Operand& length) { 5691cb0ef41Sopenharmony_ci clc(opnd1, opnd2, Operand(static_cast<intptr_t>(length.immediate() - 1))); 5701cb0ef41Sopenharmony_ci} 5711cb0ef41Sopenharmony_ci 5721cb0ef41Sopenharmony_ci// Wrapper around Assembler::xc (SS-a format) 5731cb0ef41Sopenharmony_civoid TurboAssembler::ExclusiveOrChar(const MemOperand& opnd1, 5741cb0ef41Sopenharmony_ci const MemOperand& opnd2, 5751cb0ef41Sopenharmony_ci const Operand& length) { 5761cb0ef41Sopenharmony_ci xc(opnd1, opnd2, Operand(static_cast<intptr_t>(length.immediate() - 1))); 5771cb0ef41Sopenharmony_ci} 5781cb0ef41Sopenharmony_ci 5791cb0ef41Sopenharmony_ci// Wrapper around Assembler::risbg(n) (RIE-f) 5801cb0ef41Sopenharmony_civoid TurboAssembler::RotateInsertSelectBits(Register dst, Register src, 5811cb0ef41Sopenharmony_ci const Operand& startBit, 5821cb0ef41Sopenharmony_ci const Operand& endBit, 5831cb0ef41Sopenharmony_ci const Operand& shiftAmt, 5841cb0ef41Sopenharmony_ci bool zeroBits) { 5851cb0ef41Sopenharmony_ci if (zeroBits) 5861cb0ef41Sopenharmony_ci // High tag the top bit of I4/EndBit to zero out any unselected bits 5871cb0ef41Sopenharmony_ci risbg(dst, src, startBit, 5881cb0ef41Sopenharmony_ci Operand(static_cast<intptr_t>(endBit.immediate() | 0x80)), shiftAmt); 5891cb0ef41Sopenharmony_ci else 5901cb0ef41Sopenharmony_ci risbg(dst, src, startBit, endBit, shiftAmt); 5911cb0ef41Sopenharmony_ci} 5921cb0ef41Sopenharmony_ci 5931cb0ef41Sopenharmony_civoid TurboAssembler::BranchRelativeOnIdxHighP(Register dst, Register inc, 5941cb0ef41Sopenharmony_ci Label* L) { 5951cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 5961cb0ef41Sopenharmony_ci brxhg(dst, inc, L); 5971cb0ef41Sopenharmony_ci#else 5981cb0ef41Sopenharmony_ci brxh(dst, inc, L); 5991cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_S390X 6001cb0ef41Sopenharmony_ci} 6011cb0ef41Sopenharmony_ci 6021cb0ef41Sopenharmony_civoid TurboAssembler::PushArray(Register array, Register size, Register scratch, 6031cb0ef41Sopenharmony_ci Register scratch2, PushArrayOrder order) { 6041cb0ef41Sopenharmony_ci Label loop, done; 6051cb0ef41Sopenharmony_ci 6061cb0ef41Sopenharmony_ci if (order == kNormal) { 6071cb0ef41Sopenharmony_ci ShiftLeftU64(scratch, size, Operand(kSystemPointerSizeLog2)); 6081cb0ef41Sopenharmony_ci lay(scratch, MemOperand(array, scratch)); 6091cb0ef41Sopenharmony_ci bind(&loop); 6101cb0ef41Sopenharmony_ci CmpS64(array, scratch); 6111cb0ef41Sopenharmony_ci bge(&done); 6121cb0ef41Sopenharmony_ci lay(scratch, MemOperand(scratch, -kSystemPointerSize)); 6131cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kSystemPointerSize)); 6141cb0ef41Sopenharmony_ci MoveChar(MemOperand(sp), MemOperand(scratch), Operand(kSystemPointerSize)); 6151cb0ef41Sopenharmony_ci b(&loop); 6161cb0ef41Sopenharmony_ci bind(&done); 6171cb0ef41Sopenharmony_ci } else { 6181cb0ef41Sopenharmony_ci DCHECK_NE(scratch2, r0); 6191cb0ef41Sopenharmony_ci ShiftLeftU64(scratch, size, Operand(kSystemPointerSizeLog2)); 6201cb0ef41Sopenharmony_ci lay(scratch, MemOperand(array, scratch)); 6211cb0ef41Sopenharmony_ci mov(scratch2, array); 6221cb0ef41Sopenharmony_ci bind(&loop); 6231cb0ef41Sopenharmony_ci CmpS64(scratch2, scratch); 6241cb0ef41Sopenharmony_ci bge(&done); 6251cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kSystemPointerSize)); 6261cb0ef41Sopenharmony_ci MoveChar(MemOperand(sp), MemOperand(scratch2), Operand(kSystemPointerSize)); 6271cb0ef41Sopenharmony_ci lay(scratch2, MemOperand(scratch2, kSystemPointerSize)); 6281cb0ef41Sopenharmony_ci b(&loop); 6291cb0ef41Sopenharmony_ci bind(&done); 6301cb0ef41Sopenharmony_ci } 6311cb0ef41Sopenharmony_ci} 6321cb0ef41Sopenharmony_ci 6331cb0ef41Sopenharmony_civoid TurboAssembler::MultiPush(RegList regs, Register location) { 6341cb0ef41Sopenharmony_ci int16_t num_to_push = regs.Count(); 6351cb0ef41Sopenharmony_ci int16_t stack_offset = num_to_push * kSystemPointerSize; 6361cb0ef41Sopenharmony_ci 6371cb0ef41Sopenharmony_ci SubS64(location, location, Operand(stack_offset)); 6381cb0ef41Sopenharmony_ci for (int16_t i = Register::kNumRegisters - 1; i >= 0; i--) { 6391cb0ef41Sopenharmony_ci if ((regs.bits() & (1 << i)) != 0) { 6401cb0ef41Sopenharmony_ci stack_offset -= kSystemPointerSize; 6411cb0ef41Sopenharmony_ci StoreU64(ToRegister(i), MemOperand(location, stack_offset)); 6421cb0ef41Sopenharmony_ci } 6431cb0ef41Sopenharmony_ci } 6441cb0ef41Sopenharmony_ci} 6451cb0ef41Sopenharmony_ci 6461cb0ef41Sopenharmony_civoid TurboAssembler::MultiPop(RegList regs, Register location) { 6471cb0ef41Sopenharmony_ci int16_t stack_offset = 0; 6481cb0ef41Sopenharmony_ci 6491cb0ef41Sopenharmony_ci for (int16_t i = 0; i < Register::kNumRegisters; i++) { 6501cb0ef41Sopenharmony_ci if ((regs.bits() & (1 << i)) != 0) { 6511cb0ef41Sopenharmony_ci LoadU64(ToRegister(i), MemOperand(location, stack_offset)); 6521cb0ef41Sopenharmony_ci stack_offset += kSystemPointerSize; 6531cb0ef41Sopenharmony_ci } 6541cb0ef41Sopenharmony_ci } 6551cb0ef41Sopenharmony_ci AddS64(location, location, Operand(stack_offset)); 6561cb0ef41Sopenharmony_ci} 6571cb0ef41Sopenharmony_ci 6581cb0ef41Sopenharmony_civoid TurboAssembler::MultiPushDoubles(DoubleRegList dregs, Register location) { 6591cb0ef41Sopenharmony_ci int16_t num_to_push = dregs.Count(); 6601cb0ef41Sopenharmony_ci int16_t stack_offset = num_to_push * kDoubleSize; 6611cb0ef41Sopenharmony_ci 6621cb0ef41Sopenharmony_ci SubS64(location, location, Operand(stack_offset)); 6631cb0ef41Sopenharmony_ci for (int16_t i = DoubleRegister::kNumRegisters - 1; i >= 0; i--) { 6641cb0ef41Sopenharmony_ci if ((dregs.bits() & (1 << i)) != 0) { 6651cb0ef41Sopenharmony_ci DoubleRegister dreg = DoubleRegister::from_code(i); 6661cb0ef41Sopenharmony_ci stack_offset -= kDoubleSize; 6671cb0ef41Sopenharmony_ci StoreF64(dreg, MemOperand(location, stack_offset)); 6681cb0ef41Sopenharmony_ci } 6691cb0ef41Sopenharmony_ci } 6701cb0ef41Sopenharmony_ci} 6711cb0ef41Sopenharmony_ci 6721cb0ef41Sopenharmony_civoid TurboAssembler::MultiPushV128(DoubleRegList dregs, Register scratch, 6731cb0ef41Sopenharmony_ci Register location) { 6741cb0ef41Sopenharmony_ci int16_t num_to_push = dregs.Count(); 6751cb0ef41Sopenharmony_ci int16_t stack_offset = num_to_push * kSimd128Size; 6761cb0ef41Sopenharmony_ci 6771cb0ef41Sopenharmony_ci SubS64(location, location, Operand(stack_offset)); 6781cb0ef41Sopenharmony_ci for (int16_t i = Simd128Register::kNumRegisters - 1; i >= 0; i--) { 6791cb0ef41Sopenharmony_ci if ((dregs.bits() & (1 << i)) != 0) { 6801cb0ef41Sopenharmony_ci Simd128Register dreg = Simd128Register::from_code(i); 6811cb0ef41Sopenharmony_ci stack_offset -= kSimd128Size; 6821cb0ef41Sopenharmony_ci StoreV128(dreg, MemOperand(location, stack_offset), scratch); 6831cb0ef41Sopenharmony_ci } 6841cb0ef41Sopenharmony_ci } 6851cb0ef41Sopenharmony_ci} 6861cb0ef41Sopenharmony_ci 6871cb0ef41Sopenharmony_civoid TurboAssembler::MultiPopDoubles(DoubleRegList dregs, Register location) { 6881cb0ef41Sopenharmony_ci int16_t stack_offset = 0; 6891cb0ef41Sopenharmony_ci 6901cb0ef41Sopenharmony_ci for (int16_t i = 0; i < DoubleRegister::kNumRegisters; i++) { 6911cb0ef41Sopenharmony_ci if ((dregs.bits() & (1 << i)) != 0) { 6921cb0ef41Sopenharmony_ci DoubleRegister dreg = DoubleRegister::from_code(i); 6931cb0ef41Sopenharmony_ci LoadF64(dreg, MemOperand(location, stack_offset)); 6941cb0ef41Sopenharmony_ci stack_offset += kDoubleSize; 6951cb0ef41Sopenharmony_ci } 6961cb0ef41Sopenharmony_ci } 6971cb0ef41Sopenharmony_ci AddS64(location, location, Operand(stack_offset)); 6981cb0ef41Sopenharmony_ci} 6991cb0ef41Sopenharmony_ci 7001cb0ef41Sopenharmony_civoid TurboAssembler::MultiPopV128(DoubleRegList dregs, Register scratch, 7011cb0ef41Sopenharmony_ci Register location) { 7021cb0ef41Sopenharmony_ci int16_t stack_offset = 0; 7031cb0ef41Sopenharmony_ci 7041cb0ef41Sopenharmony_ci for (int16_t i = 0; i < Simd128Register::kNumRegisters; i++) { 7051cb0ef41Sopenharmony_ci if ((dregs.bits() & (1 << i)) != 0) { 7061cb0ef41Sopenharmony_ci Simd128Register dreg = Simd128Register::from_code(i); 7071cb0ef41Sopenharmony_ci LoadV128(dreg, MemOperand(location, stack_offset), scratch); 7081cb0ef41Sopenharmony_ci stack_offset += kSimd128Size; 7091cb0ef41Sopenharmony_ci } 7101cb0ef41Sopenharmony_ci } 7111cb0ef41Sopenharmony_ci AddS64(location, location, Operand(stack_offset)); 7121cb0ef41Sopenharmony_ci} 7131cb0ef41Sopenharmony_ci 7141cb0ef41Sopenharmony_civoid TurboAssembler::MultiPushF64OrV128(DoubleRegList dregs, Register scratch, 7151cb0ef41Sopenharmony_ci Register location) { 7161cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 7171cb0ef41Sopenharmony_ci bool generating_bultins = 7181cb0ef41Sopenharmony_ci isolate() && isolate()->IsGeneratingEmbeddedBuiltins(); 7191cb0ef41Sopenharmony_ci if (generating_bultins) { 7201cb0ef41Sopenharmony_ci Label push_doubles, simd_pushed; 7211cb0ef41Sopenharmony_ci Move(r1, ExternalReference::supports_wasm_simd_128_address()); 7221cb0ef41Sopenharmony_ci LoadU8(r1, MemOperand(r1)); 7231cb0ef41Sopenharmony_ci LoadAndTestP(r1, r1); // If > 0 then simd is available. 7241cb0ef41Sopenharmony_ci ble(&push_doubles, Label::kNear); 7251cb0ef41Sopenharmony_ci // Save vector registers, don't save double registers anymore. 7261cb0ef41Sopenharmony_ci MultiPushV128(dregs, scratch); 7271cb0ef41Sopenharmony_ci b(&simd_pushed); 7281cb0ef41Sopenharmony_ci bind(&push_doubles); 7291cb0ef41Sopenharmony_ci // Simd not supported, only save double registers. 7301cb0ef41Sopenharmony_ci MultiPushDoubles(dregs); 7311cb0ef41Sopenharmony_ci // We still need to allocate empty space on the stack as if 7321cb0ef41Sopenharmony_ci // Simd rgeisters were saved (see kFixedFrameSizeFromFp). 7331cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -(dregs.Count() * kDoubleSize))); 7341cb0ef41Sopenharmony_ci bind(&simd_pushed); 7351cb0ef41Sopenharmony_ci } else { 7361cb0ef41Sopenharmony_ci if (CpuFeatures::SupportsWasmSimd128()) { 7371cb0ef41Sopenharmony_ci MultiPushV128(dregs, scratch); 7381cb0ef41Sopenharmony_ci } else { 7391cb0ef41Sopenharmony_ci MultiPushDoubles(dregs); 7401cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -(dregs.Count() * kDoubleSize))); 7411cb0ef41Sopenharmony_ci } 7421cb0ef41Sopenharmony_ci } 7431cb0ef41Sopenharmony_ci#else 7441cb0ef41Sopenharmony_ci MultiPushDoubles(dregs); 7451cb0ef41Sopenharmony_ci#endif 7461cb0ef41Sopenharmony_ci} 7471cb0ef41Sopenharmony_ci 7481cb0ef41Sopenharmony_civoid TurboAssembler::MultiPopF64OrV128(DoubleRegList dregs, Register scratch, 7491cb0ef41Sopenharmony_ci Register location) { 7501cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 7511cb0ef41Sopenharmony_ci bool generating_bultins = 7521cb0ef41Sopenharmony_ci isolate() && isolate()->IsGeneratingEmbeddedBuiltins(); 7531cb0ef41Sopenharmony_ci if (generating_bultins) { 7541cb0ef41Sopenharmony_ci Label pop_doubles, simd_popped; 7551cb0ef41Sopenharmony_ci Move(r1, ExternalReference::supports_wasm_simd_128_address()); 7561cb0ef41Sopenharmony_ci LoadU8(r1, MemOperand(r1)); 7571cb0ef41Sopenharmony_ci LoadAndTestP(r1, r1); // If > 0 then simd is available. 7581cb0ef41Sopenharmony_ci ble(&pop_doubles, Label::kNear); 7591cb0ef41Sopenharmony_ci // Pop vector registers, don't pop double registers anymore. 7601cb0ef41Sopenharmony_ci MultiPopV128(dregs, scratch); 7611cb0ef41Sopenharmony_ci b(&simd_popped); 7621cb0ef41Sopenharmony_ci bind(&pop_doubles); 7631cb0ef41Sopenharmony_ci // Simd not supported, only pop double registers. 7641cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, dregs.Count() * kDoubleSize)); 7651cb0ef41Sopenharmony_ci MultiPopDoubles(dregs); 7661cb0ef41Sopenharmony_ci bind(&simd_popped); 7671cb0ef41Sopenharmony_ci } else { 7681cb0ef41Sopenharmony_ci if (CpuFeatures::SupportsWasmSimd128()) { 7691cb0ef41Sopenharmony_ci MultiPopV128(dregs, scratch); 7701cb0ef41Sopenharmony_ci } else { 7711cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, dregs.Count() * kDoubleSize)); 7721cb0ef41Sopenharmony_ci MultiPopDoubles(dregs); 7731cb0ef41Sopenharmony_ci } 7741cb0ef41Sopenharmony_ci } 7751cb0ef41Sopenharmony_ci#else 7761cb0ef41Sopenharmony_ci MultiPopDoubles(dregs); 7771cb0ef41Sopenharmony_ci#endif 7781cb0ef41Sopenharmony_ci} 7791cb0ef41Sopenharmony_ci 7801cb0ef41Sopenharmony_civoid TurboAssembler::LoadRoot(Register destination, RootIndex index, 7811cb0ef41Sopenharmony_ci Condition) { 7821cb0ef41Sopenharmony_ci LoadU64(destination, 7831cb0ef41Sopenharmony_ci MemOperand(kRootRegister, RootRegisterOffsetForRootIndex(index)), r0); 7841cb0ef41Sopenharmony_ci} 7851cb0ef41Sopenharmony_ci 7861cb0ef41Sopenharmony_civoid TurboAssembler::LoadTaggedPointerField(const Register& destination, 7871cb0ef41Sopenharmony_ci const MemOperand& field_operand, 7881cb0ef41Sopenharmony_ci const Register& scratch) { 7891cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 7901cb0ef41Sopenharmony_ci DecompressTaggedPointer(destination, field_operand); 7911cb0ef41Sopenharmony_ci } else { 7921cb0ef41Sopenharmony_ci LoadU64(destination, field_operand, scratch); 7931cb0ef41Sopenharmony_ci } 7941cb0ef41Sopenharmony_ci} 7951cb0ef41Sopenharmony_ci 7961cb0ef41Sopenharmony_civoid TurboAssembler::LoadAnyTaggedField(const Register& destination, 7971cb0ef41Sopenharmony_ci const MemOperand& field_operand, 7981cb0ef41Sopenharmony_ci const Register& scratch) { 7991cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 8001cb0ef41Sopenharmony_ci DecompressAnyTagged(destination, field_operand); 8011cb0ef41Sopenharmony_ci } else { 8021cb0ef41Sopenharmony_ci LoadU64(destination, field_operand, scratch); 8031cb0ef41Sopenharmony_ci } 8041cb0ef41Sopenharmony_ci} 8051cb0ef41Sopenharmony_ci 8061cb0ef41Sopenharmony_civoid TurboAssembler::SmiUntag(Register dst, const MemOperand& src) { 8071cb0ef41Sopenharmony_ci if (SmiValuesAre31Bits()) { 8081cb0ef41Sopenharmony_ci LoadS32(dst, src); 8091cb0ef41Sopenharmony_ci } else { 8101cb0ef41Sopenharmony_ci LoadU64(dst, src); 8111cb0ef41Sopenharmony_ci } 8121cb0ef41Sopenharmony_ci SmiUntag(dst); 8131cb0ef41Sopenharmony_ci} 8141cb0ef41Sopenharmony_ci 8151cb0ef41Sopenharmony_civoid TurboAssembler::SmiUntagField(Register dst, const MemOperand& src) { 8161cb0ef41Sopenharmony_ci SmiUntag(dst, src); 8171cb0ef41Sopenharmony_ci} 8181cb0ef41Sopenharmony_ci 8191cb0ef41Sopenharmony_civoid TurboAssembler::StoreTaggedField(const Register& value, 8201cb0ef41Sopenharmony_ci const MemOperand& dst_field_operand, 8211cb0ef41Sopenharmony_ci const Register& scratch) { 8221cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 8231cb0ef41Sopenharmony_ci RecordComment("[ StoreTagged"); 8241cb0ef41Sopenharmony_ci StoreU32(value, dst_field_operand); 8251cb0ef41Sopenharmony_ci RecordComment("]"); 8261cb0ef41Sopenharmony_ci } else { 8271cb0ef41Sopenharmony_ci StoreU64(value, dst_field_operand, scratch); 8281cb0ef41Sopenharmony_ci } 8291cb0ef41Sopenharmony_ci} 8301cb0ef41Sopenharmony_ci 8311cb0ef41Sopenharmony_civoid TurboAssembler::DecompressTaggedSigned(Register destination, 8321cb0ef41Sopenharmony_ci Register src) { 8331cb0ef41Sopenharmony_ci RecordComment("[ DecompressTaggedSigned"); 8341cb0ef41Sopenharmony_ci llgfr(destination, src); 8351cb0ef41Sopenharmony_ci RecordComment("]"); 8361cb0ef41Sopenharmony_ci} 8371cb0ef41Sopenharmony_ci 8381cb0ef41Sopenharmony_civoid TurboAssembler::DecompressTaggedSigned(Register destination, 8391cb0ef41Sopenharmony_ci MemOperand field_operand) { 8401cb0ef41Sopenharmony_ci RecordComment("[ DecompressTaggedSigned"); 8411cb0ef41Sopenharmony_ci llgf(destination, field_operand); 8421cb0ef41Sopenharmony_ci RecordComment("]"); 8431cb0ef41Sopenharmony_ci} 8441cb0ef41Sopenharmony_ci 8451cb0ef41Sopenharmony_civoid TurboAssembler::DecompressTaggedPointer(Register destination, 8461cb0ef41Sopenharmony_ci Register source) { 8471cb0ef41Sopenharmony_ci RecordComment("[ DecompressTaggedPointer"); 8481cb0ef41Sopenharmony_ci llgfr(destination, source); 8491cb0ef41Sopenharmony_ci agr(destination, kRootRegister); 8501cb0ef41Sopenharmony_ci RecordComment("]"); 8511cb0ef41Sopenharmony_ci} 8521cb0ef41Sopenharmony_ci 8531cb0ef41Sopenharmony_civoid TurboAssembler::DecompressTaggedPointer(Register destination, 8541cb0ef41Sopenharmony_ci MemOperand field_operand) { 8551cb0ef41Sopenharmony_ci RecordComment("[ DecompressTaggedPointer"); 8561cb0ef41Sopenharmony_ci llgf(destination, field_operand); 8571cb0ef41Sopenharmony_ci agr(destination, kRootRegister); 8581cb0ef41Sopenharmony_ci RecordComment("]"); 8591cb0ef41Sopenharmony_ci} 8601cb0ef41Sopenharmony_ci 8611cb0ef41Sopenharmony_civoid TurboAssembler::DecompressAnyTagged(Register destination, 8621cb0ef41Sopenharmony_ci MemOperand field_operand) { 8631cb0ef41Sopenharmony_ci RecordComment("[ DecompressAnyTagged"); 8641cb0ef41Sopenharmony_ci llgf(destination, field_operand); 8651cb0ef41Sopenharmony_ci agr(destination, kRootRegister); 8661cb0ef41Sopenharmony_ci RecordComment("]"); 8671cb0ef41Sopenharmony_ci} 8681cb0ef41Sopenharmony_ci 8691cb0ef41Sopenharmony_civoid TurboAssembler::DecompressAnyTagged(Register destination, 8701cb0ef41Sopenharmony_ci Register source) { 8711cb0ef41Sopenharmony_ci RecordComment("[ DecompressAnyTagged"); 8721cb0ef41Sopenharmony_ci llgfr(destination, source); 8731cb0ef41Sopenharmony_ci agr(destination, kRootRegister); 8741cb0ef41Sopenharmony_ci RecordComment("]"); 8751cb0ef41Sopenharmony_ci} 8761cb0ef41Sopenharmony_ci 8771cb0ef41Sopenharmony_civoid TurboAssembler::LoadTaggedSignedField(Register destination, 8781cb0ef41Sopenharmony_ci MemOperand field_operand) { 8791cb0ef41Sopenharmony_ci if (COMPRESS_POINTERS_BOOL) { 8801cb0ef41Sopenharmony_ci DecompressTaggedSigned(destination, field_operand); 8811cb0ef41Sopenharmony_ci } else { 8821cb0ef41Sopenharmony_ci LoadU64(destination, field_operand); 8831cb0ef41Sopenharmony_ci } 8841cb0ef41Sopenharmony_ci} 8851cb0ef41Sopenharmony_ci 8861cb0ef41Sopenharmony_civoid MacroAssembler::RecordWriteField(Register object, int offset, 8871cb0ef41Sopenharmony_ci Register value, Register slot_address, 8881cb0ef41Sopenharmony_ci LinkRegisterStatus lr_status, 8891cb0ef41Sopenharmony_ci SaveFPRegsMode save_fp, 8901cb0ef41Sopenharmony_ci RememberedSetAction remembered_set_action, 8911cb0ef41Sopenharmony_ci SmiCheck smi_check) { 8921cb0ef41Sopenharmony_ci // First, check if a write barrier is even needed. The tests below 8931cb0ef41Sopenharmony_ci // catch stores of Smis. 8941cb0ef41Sopenharmony_ci Label done; 8951cb0ef41Sopenharmony_ci 8961cb0ef41Sopenharmony_ci // Skip barrier if writing a smi. 8971cb0ef41Sopenharmony_ci if (smi_check == SmiCheck::kInline) { 8981cb0ef41Sopenharmony_ci JumpIfSmi(value, &done); 8991cb0ef41Sopenharmony_ci } 9001cb0ef41Sopenharmony_ci 9011cb0ef41Sopenharmony_ci // Although the object register is tagged, the offset is relative to the start 9021cb0ef41Sopenharmony_ci // of the object, so so offset must be a multiple of kSystemPointerSize. 9031cb0ef41Sopenharmony_ci DCHECK(IsAligned(offset, kTaggedSize)); 9041cb0ef41Sopenharmony_ci 9051cb0ef41Sopenharmony_ci lay(slot_address, MemOperand(object, offset - kHeapObjectTag)); 9061cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 9071cb0ef41Sopenharmony_ci Label ok; 9081cb0ef41Sopenharmony_ci AndP(r0, slot_address, Operand(kTaggedSize - 1)); 9091cb0ef41Sopenharmony_ci beq(&ok, Label::kNear); 9101cb0ef41Sopenharmony_ci stop(); 9111cb0ef41Sopenharmony_ci bind(&ok); 9121cb0ef41Sopenharmony_ci } 9131cb0ef41Sopenharmony_ci 9141cb0ef41Sopenharmony_ci RecordWrite(object, slot_address, value, lr_status, save_fp, 9151cb0ef41Sopenharmony_ci remembered_set_action, SmiCheck::kOmit); 9161cb0ef41Sopenharmony_ci 9171cb0ef41Sopenharmony_ci bind(&done); 9181cb0ef41Sopenharmony_ci 9191cb0ef41Sopenharmony_ci // Clobber clobbered input registers when running with the debug-code flag 9201cb0ef41Sopenharmony_ci // turned on to provoke errors. 9211cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 9221cb0ef41Sopenharmony_ci mov(value, Operand(bit_cast<intptr_t>(kZapValue + 4))); 9231cb0ef41Sopenharmony_ci mov(slot_address, Operand(bit_cast<intptr_t>(kZapValue + 8))); 9241cb0ef41Sopenharmony_ci } 9251cb0ef41Sopenharmony_ci} 9261cb0ef41Sopenharmony_ci 9271cb0ef41Sopenharmony_civoid TurboAssembler::MaybeSaveRegisters(RegList registers) { 9281cb0ef41Sopenharmony_ci if (registers.is_empty()) return; 9291cb0ef41Sopenharmony_ci MultiPush(registers); 9301cb0ef41Sopenharmony_ci} 9311cb0ef41Sopenharmony_ci 9321cb0ef41Sopenharmony_civoid TurboAssembler::MaybeRestoreRegisters(RegList registers) { 9331cb0ef41Sopenharmony_ci if (registers.is_empty()) return; 9341cb0ef41Sopenharmony_ci MultiPop(registers); 9351cb0ef41Sopenharmony_ci} 9361cb0ef41Sopenharmony_ci 9371cb0ef41Sopenharmony_civoid TurboAssembler::CallEphemeronKeyBarrier(Register object, 9381cb0ef41Sopenharmony_ci Register slot_address, 9391cb0ef41Sopenharmony_ci SaveFPRegsMode fp_mode) { 9401cb0ef41Sopenharmony_ci DCHECK(!AreAliased(object, slot_address)); 9411cb0ef41Sopenharmony_ci RegList registers = 9421cb0ef41Sopenharmony_ci WriteBarrierDescriptor::ComputeSavedRegisters(object, slot_address); 9431cb0ef41Sopenharmony_ci MaybeSaveRegisters(registers); 9441cb0ef41Sopenharmony_ci 9451cb0ef41Sopenharmony_ci Register object_parameter = WriteBarrierDescriptor::ObjectRegister(); 9461cb0ef41Sopenharmony_ci Register slot_address_parameter = 9471cb0ef41Sopenharmony_ci WriteBarrierDescriptor::SlotAddressRegister(); 9481cb0ef41Sopenharmony_ci 9491cb0ef41Sopenharmony_ci Push(object); 9501cb0ef41Sopenharmony_ci Push(slot_address); 9511cb0ef41Sopenharmony_ci Pop(slot_address_parameter); 9521cb0ef41Sopenharmony_ci Pop(object_parameter); 9531cb0ef41Sopenharmony_ci 9541cb0ef41Sopenharmony_ci Call(isolate()->builtins()->code_handle( 9551cb0ef41Sopenharmony_ci Builtins::GetEphemeronKeyBarrierStub(fp_mode)), 9561cb0ef41Sopenharmony_ci RelocInfo::CODE_TARGET); 9571cb0ef41Sopenharmony_ci MaybeRestoreRegisters(registers); 9581cb0ef41Sopenharmony_ci} 9591cb0ef41Sopenharmony_ci 9601cb0ef41Sopenharmony_civoid TurboAssembler::CallRecordWriteStubSaveRegisters( 9611cb0ef41Sopenharmony_ci Register object, Register slot_address, 9621cb0ef41Sopenharmony_ci RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, 9631cb0ef41Sopenharmony_ci StubCallMode mode) { 9641cb0ef41Sopenharmony_ci DCHECK(!AreAliased(object, slot_address)); 9651cb0ef41Sopenharmony_ci RegList registers = 9661cb0ef41Sopenharmony_ci WriteBarrierDescriptor::ComputeSavedRegisters(object, slot_address); 9671cb0ef41Sopenharmony_ci MaybeSaveRegisters(registers); 9681cb0ef41Sopenharmony_ci 9691cb0ef41Sopenharmony_ci Register object_parameter = WriteBarrierDescriptor::ObjectRegister(); 9701cb0ef41Sopenharmony_ci Register slot_address_parameter = 9711cb0ef41Sopenharmony_ci WriteBarrierDescriptor::SlotAddressRegister(); 9721cb0ef41Sopenharmony_ci 9731cb0ef41Sopenharmony_ci Push(object); 9741cb0ef41Sopenharmony_ci Push(slot_address); 9751cb0ef41Sopenharmony_ci Pop(slot_address_parameter); 9761cb0ef41Sopenharmony_ci Pop(object_parameter); 9771cb0ef41Sopenharmony_ci 9781cb0ef41Sopenharmony_ci CallRecordWriteStub(object_parameter, slot_address_parameter, 9791cb0ef41Sopenharmony_ci remembered_set_action, fp_mode, mode); 9801cb0ef41Sopenharmony_ci 9811cb0ef41Sopenharmony_ci MaybeRestoreRegisters(registers); 9821cb0ef41Sopenharmony_ci} 9831cb0ef41Sopenharmony_ci 9841cb0ef41Sopenharmony_civoid TurboAssembler::CallRecordWriteStub( 9851cb0ef41Sopenharmony_ci Register object, Register slot_address, 9861cb0ef41Sopenharmony_ci RememberedSetAction remembered_set_action, SaveFPRegsMode fp_mode, 9871cb0ef41Sopenharmony_ci StubCallMode mode) { 9881cb0ef41Sopenharmony_ci // Use CallRecordWriteStubSaveRegisters if the object and slot registers 9891cb0ef41Sopenharmony_ci // need to be caller saved. 9901cb0ef41Sopenharmony_ci DCHECK_EQ(WriteBarrierDescriptor::ObjectRegister(), object); 9911cb0ef41Sopenharmony_ci DCHECK_EQ(WriteBarrierDescriptor::SlotAddressRegister(), slot_address); 9921cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 9931cb0ef41Sopenharmony_ci if (mode == StubCallMode::kCallWasmRuntimeStub) { 9941cb0ef41Sopenharmony_ci auto wasm_target = 9951cb0ef41Sopenharmony_ci wasm::WasmCode::GetRecordWriteStub(remembered_set_action, fp_mode); 9961cb0ef41Sopenharmony_ci Call(wasm_target, RelocInfo::WASM_STUB_CALL); 9971cb0ef41Sopenharmony_ci#else 9981cb0ef41Sopenharmony_ci if (false) { 9991cb0ef41Sopenharmony_ci#endif 10001cb0ef41Sopenharmony_ci } else { 10011cb0ef41Sopenharmony_ci auto builtin_index = 10021cb0ef41Sopenharmony_ci Builtins::GetRecordWriteStub(remembered_set_action, fp_mode); 10031cb0ef41Sopenharmony_ci if (options().inline_offheap_trampolines) { 10041cb0ef41Sopenharmony_ci RecordCommentForOffHeapTrampoline(builtin_index); 10051cb0ef41Sopenharmony_ci mov(ip, Operand(BuiltinEntry(builtin_index), RelocInfo::OFF_HEAP_TARGET)); 10061cb0ef41Sopenharmony_ci Call(ip); 10071cb0ef41Sopenharmony_ci } else { 10081cb0ef41Sopenharmony_ci Handle<Code> code_target = 10091cb0ef41Sopenharmony_ci isolate()->builtins()->code_handle(builtin_index); 10101cb0ef41Sopenharmony_ci Call(code_target, RelocInfo::CODE_TARGET); 10111cb0ef41Sopenharmony_ci } 10121cb0ef41Sopenharmony_ci } 10131cb0ef41Sopenharmony_ci} 10141cb0ef41Sopenharmony_ci 10151cb0ef41Sopenharmony_ci// Will clobber 4 registers: object, address, scratch, ip. The 10161cb0ef41Sopenharmony_ci// register 'object' contains a heap object pointer. The heap object 10171cb0ef41Sopenharmony_ci// tag is shifted away. 10181cb0ef41Sopenharmony_civoid MacroAssembler::RecordWrite(Register object, Register slot_address, 10191cb0ef41Sopenharmony_ci Register value, LinkRegisterStatus lr_status, 10201cb0ef41Sopenharmony_ci SaveFPRegsMode fp_mode, 10211cb0ef41Sopenharmony_ci RememberedSetAction remembered_set_action, 10221cb0ef41Sopenharmony_ci SmiCheck smi_check) { 10231cb0ef41Sopenharmony_ci DCHECK(!AreAliased(object, slot_address, value)); 10241cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 10251cb0ef41Sopenharmony_ci LoadTaggedPointerField(r0, MemOperand(slot_address)); 10261cb0ef41Sopenharmony_ci CmpS64(value, r0); 10271cb0ef41Sopenharmony_ci Check(eq, AbortReason::kWrongAddressOrValuePassedToRecordWrite); 10281cb0ef41Sopenharmony_ci } 10291cb0ef41Sopenharmony_ci 10301cb0ef41Sopenharmony_ci if ((remembered_set_action == RememberedSetAction::kOmit && 10311cb0ef41Sopenharmony_ci !FLAG_incremental_marking) || 10321cb0ef41Sopenharmony_ci FLAG_disable_write_barriers) { 10331cb0ef41Sopenharmony_ci return; 10341cb0ef41Sopenharmony_ci } 10351cb0ef41Sopenharmony_ci // First, check if a write barrier is even needed. The tests below 10361cb0ef41Sopenharmony_ci // catch stores of smis and stores into the young generation. 10371cb0ef41Sopenharmony_ci Label done; 10381cb0ef41Sopenharmony_ci 10391cb0ef41Sopenharmony_ci if (smi_check == SmiCheck::kInline) { 10401cb0ef41Sopenharmony_ci JumpIfSmi(value, &done); 10411cb0ef41Sopenharmony_ci } 10421cb0ef41Sopenharmony_ci 10431cb0ef41Sopenharmony_ci CheckPageFlag(value, 10441cb0ef41Sopenharmony_ci value, // Used as scratch. 10451cb0ef41Sopenharmony_ci MemoryChunk::kPointersToHereAreInterestingMask, eq, &done); 10461cb0ef41Sopenharmony_ci CheckPageFlag(object, 10471cb0ef41Sopenharmony_ci value, // Used as scratch. 10481cb0ef41Sopenharmony_ci MemoryChunk::kPointersFromHereAreInterestingMask, eq, &done); 10491cb0ef41Sopenharmony_ci 10501cb0ef41Sopenharmony_ci // Record the actual write. 10511cb0ef41Sopenharmony_ci if (lr_status == kLRHasNotBeenSaved) { 10521cb0ef41Sopenharmony_ci push(r14); 10531cb0ef41Sopenharmony_ci } 10541cb0ef41Sopenharmony_ci CallRecordWriteStubSaveRegisters(object, slot_address, remembered_set_action, 10551cb0ef41Sopenharmony_ci fp_mode); 10561cb0ef41Sopenharmony_ci if (lr_status == kLRHasNotBeenSaved) { 10571cb0ef41Sopenharmony_ci pop(r14); 10581cb0ef41Sopenharmony_ci } 10591cb0ef41Sopenharmony_ci 10601cb0ef41Sopenharmony_ci if (FLAG_debug_code) mov(slot_address, Operand(kZapValue)); 10611cb0ef41Sopenharmony_ci 10621cb0ef41Sopenharmony_ci bind(&done); 10631cb0ef41Sopenharmony_ci 10641cb0ef41Sopenharmony_ci // Clobber clobbered registers when running with the debug-code flag 10651cb0ef41Sopenharmony_ci // turned on to provoke errors. 10661cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 10671cb0ef41Sopenharmony_ci mov(slot_address, Operand(bit_cast<intptr_t>(kZapValue + 12))); 10681cb0ef41Sopenharmony_ci mov(value, Operand(bit_cast<intptr_t>(kZapValue + 16))); 10691cb0ef41Sopenharmony_ci } 10701cb0ef41Sopenharmony_ci} 10711cb0ef41Sopenharmony_ci 10721cb0ef41Sopenharmony_civoid TurboAssembler::PushCommonFrame(Register marker_reg) { 10731cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 10741cb0ef41Sopenharmony_ci int fp_delta = 0; 10751cb0ef41Sopenharmony_ci CleanseP(r14); 10761cb0ef41Sopenharmony_ci if (marker_reg.is_valid()) { 10771cb0ef41Sopenharmony_ci Push(r14, fp, marker_reg); 10781cb0ef41Sopenharmony_ci fp_delta = 1; 10791cb0ef41Sopenharmony_ci } else { 10801cb0ef41Sopenharmony_ci Push(r14, fp); 10811cb0ef41Sopenharmony_ci fp_delta = 0; 10821cb0ef41Sopenharmony_ci } 10831cb0ef41Sopenharmony_ci la(fp, MemOperand(sp, fp_delta * kSystemPointerSize)); 10841cb0ef41Sopenharmony_ci} 10851cb0ef41Sopenharmony_ci 10861cb0ef41Sopenharmony_civoid TurboAssembler::PopCommonFrame(Register marker_reg) { 10871cb0ef41Sopenharmony_ci if (marker_reg.is_valid()) { 10881cb0ef41Sopenharmony_ci Pop(r14, fp, marker_reg); 10891cb0ef41Sopenharmony_ci } else { 10901cb0ef41Sopenharmony_ci Pop(r14, fp); 10911cb0ef41Sopenharmony_ci } 10921cb0ef41Sopenharmony_ci} 10931cb0ef41Sopenharmony_ci 10941cb0ef41Sopenharmony_civoid TurboAssembler::PushStandardFrame(Register function_reg) { 10951cb0ef41Sopenharmony_ci int fp_delta = 0; 10961cb0ef41Sopenharmony_ci CleanseP(r14); 10971cb0ef41Sopenharmony_ci if (function_reg.is_valid()) { 10981cb0ef41Sopenharmony_ci Push(r14, fp, cp, function_reg); 10991cb0ef41Sopenharmony_ci fp_delta = 2; 11001cb0ef41Sopenharmony_ci } else { 11011cb0ef41Sopenharmony_ci Push(r14, fp, cp); 11021cb0ef41Sopenharmony_ci fp_delta = 1; 11031cb0ef41Sopenharmony_ci } 11041cb0ef41Sopenharmony_ci la(fp, MemOperand(sp, fp_delta * kSystemPointerSize)); 11051cb0ef41Sopenharmony_ci Push(kJavaScriptCallArgCountRegister); 11061cb0ef41Sopenharmony_ci} 11071cb0ef41Sopenharmony_ci 11081cb0ef41Sopenharmony_civoid TurboAssembler::RestoreFrameStateForTailCall() { 11091cb0ef41Sopenharmony_ci // if (FLAG_enable_embedded_constant_pool) { 11101cb0ef41Sopenharmony_ci // LoadU64(kConstantPoolRegister, 11111cb0ef41Sopenharmony_ci // MemOperand(fp, StandardFrameConstants::kConstantPoolOffset)); 11121cb0ef41Sopenharmony_ci // set_constant_pool_available(false); 11131cb0ef41Sopenharmony_ci // } 11141cb0ef41Sopenharmony_ci DCHECK(!FLAG_enable_embedded_constant_pool); 11151cb0ef41Sopenharmony_ci LoadU64(r14, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); 11161cb0ef41Sopenharmony_ci LoadU64(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 11171cb0ef41Sopenharmony_ci} 11181cb0ef41Sopenharmony_ci 11191cb0ef41Sopenharmony_civoid TurboAssembler::CanonicalizeNaN(const DoubleRegister dst, 11201cb0ef41Sopenharmony_ci const DoubleRegister src) { 11211cb0ef41Sopenharmony_ci // Turn potential sNaN into qNaN 11221cb0ef41Sopenharmony_ci if (dst != src) ldr(dst, src); 11231cb0ef41Sopenharmony_ci lzdr(kDoubleRegZero); 11241cb0ef41Sopenharmony_ci sdbr(dst, kDoubleRegZero); 11251cb0ef41Sopenharmony_ci} 11261cb0ef41Sopenharmony_ci 11271cb0ef41Sopenharmony_civoid TurboAssembler::ConvertIntToDouble(DoubleRegister dst, Register src) { 11281cb0ef41Sopenharmony_ci cdfbr(dst, src); 11291cb0ef41Sopenharmony_ci} 11301cb0ef41Sopenharmony_ci 11311cb0ef41Sopenharmony_civoid TurboAssembler::ConvertUnsignedIntToDouble(DoubleRegister dst, 11321cb0ef41Sopenharmony_ci Register src) { 11331cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(FLOATING_POINT_EXT)) { 11341cb0ef41Sopenharmony_ci cdlfbr(Condition(5), Condition(0), dst, src); 11351cb0ef41Sopenharmony_ci } else { 11361cb0ef41Sopenharmony_ci // zero-extend src 11371cb0ef41Sopenharmony_ci llgfr(src, src); 11381cb0ef41Sopenharmony_ci // convert to double 11391cb0ef41Sopenharmony_ci cdgbr(dst, src); 11401cb0ef41Sopenharmony_ci } 11411cb0ef41Sopenharmony_ci} 11421cb0ef41Sopenharmony_ci 11431cb0ef41Sopenharmony_civoid TurboAssembler::ConvertIntToFloat(DoubleRegister dst, Register src) { 11441cb0ef41Sopenharmony_ci cefbra(Condition(4), dst, src); 11451cb0ef41Sopenharmony_ci} 11461cb0ef41Sopenharmony_ci 11471cb0ef41Sopenharmony_civoid TurboAssembler::ConvertUnsignedIntToFloat(DoubleRegister dst, 11481cb0ef41Sopenharmony_ci Register src) { 11491cb0ef41Sopenharmony_ci celfbr(Condition(4), Condition(0), dst, src); 11501cb0ef41Sopenharmony_ci} 11511cb0ef41Sopenharmony_ci 11521cb0ef41Sopenharmony_civoid TurboAssembler::ConvertInt64ToFloat(DoubleRegister double_dst, 11531cb0ef41Sopenharmony_ci Register src) { 11541cb0ef41Sopenharmony_ci cegbr(double_dst, src); 11551cb0ef41Sopenharmony_ci} 11561cb0ef41Sopenharmony_ci 11571cb0ef41Sopenharmony_civoid TurboAssembler::ConvertInt64ToDouble(DoubleRegister double_dst, 11581cb0ef41Sopenharmony_ci Register src) { 11591cb0ef41Sopenharmony_ci cdgbr(double_dst, src); 11601cb0ef41Sopenharmony_ci} 11611cb0ef41Sopenharmony_ci 11621cb0ef41Sopenharmony_civoid TurboAssembler::ConvertUnsignedInt64ToFloat(DoubleRegister double_dst, 11631cb0ef41Sopenharmony_ci Register src) { 11641cb0ef41Sopenharmony_ci celgbr(Condition(0), Condition(0), double_dst, src); 11651cb0ef41Sopenharmony_ci} 11661cb0ef41Sopenharmony_ci 11671cb0ef41Sopenharmony_civoid TurboAssembler::ConvertUnsignedInt64ToDouble(DoubleRegister double_dst, 11681cb0ef41Sopenharmony_ci Register src) { 11691cb0ef41Sopenharmony_ci cdlgbr(Condition(0), Condition(0), double_dst, src); 11701cb0ef41Sopenharmony_ci} 11711cb0ef41Sopenharmony_ci 11721cb0ef41Sopenharmony_civoid TurboAssembler::ConvertFloat32ToInt64(const Register dst, 11731cb0ef41Sopenharmony_ci const DoubleRegister double_input, 11741cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 11751cb0ef41Sopenharmony_ci Condition m = Condition(0); 11761cb0ef41Sopenharmony_ci switch (rounding_mode) { 11771cb0ef41Sopenharmony_ci case kRoundToZero: 11781cb0ef41Sopenharmony_ci m = Condition(5); 11791cb0ef41Sopenharmony_ci break; 11801cb0ef41Sopenharmony_ci case kRoundToNearest: 11811cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 11821cb0ef41Sopenharmony_ci case kRoundToPlusInf: 11831cb0ef41Sopenharmony_ci m = Condition(6); 11841cb0ef41Sopenharmony_ci break; 11851cb0ef41Sopenharmony_ci case kRoundToMinusInf: 11861cb0ef41Sopenharmony_ci m = Condition(7); 11871cb0ef41Sopenharmony_ci break; 11881cb0ef41Sopenharmony_ci default: 11891cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 11901cb0ef41Sopenharmony_ci } 11911cb0ef41Sopenharmony_ci cgebr(m, dst, double_input); 11921cb0ef41Sopenharmony_ci} 11931cb0ef41Sopenharmony_ci 11941cb0ef41Sopenharmony_civoid TurboAssembler::ConvertDoubleToInt64(const Register dst, 11951cb0ef41Sopenharmony_ci const DoubleRegister double_input, 11961cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 11971cb0ef41Sopenharmony_ci Condition m = Condition(0); 11981cb0ef41Sopenharmony_ci switch (rounding_mode) { 11991cb0ef41Sopenharmony_ci case kRoundToZero: 12001cb0ef41Sopenharmony_ci m = Condition(5); 12011cb0ef41Sopenharmony_ci break; 12021cb0ef41Sopenharmony_ci case kRoundToNearest: 12031cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12041cb0ef41Sopenharmony_ci case kRoundToPlusInf: 12051cb0ef41Sopenharmony_ci m = Condition(6); 12061cb0ef41Sopenharmony_ci break; 12071cb0ef41Sopenharmony_ci case kRoundToMinusInf: 12081cb0ef41Sopenharmony_ci m = Condition(7); 12091cb0ef41Sopenharmony_ci break; 12101cb0ef41Sopenharmony_ci default: 12111cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12121cb0ef41Sopenharmony_ci } 12131cb0ef41Sopenharmony_ci cgdbr(m, dst, double_input); 12141cb0ef41Sopenharmony_ci} 12151cb0ef41Sopenharmony_ci 12161cb0ef41Sopenharmony_civoid TurboAssembler::ConvertDoubleToInt32(const Register dst, 12171cb0ef41Sopenharmony_ci const DoubleRegister double_input, 12181cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 12191cb0ef41Sopenharmony_ci Condition m = Condition(0); 12201cb0ef41Sopenharmony_ci switch (rounding_mode) { 12211cb0ef41Sopenharmony_ci case kRoundToZero: 12221cb0ef41Sopenharmony_ci m = Condition(5); 12231cb0ef41Sopenharmony_ci break; 12241cb0ef41Sopenharmony_ci case kRoundToNearest: 12251cb0ef41Sopenharmony_ci m = Condition(4); 12261cb0ef41Sopenharmony_ci break; 12271cb0ef41Sopenharmony_ci case kRoundToPlusInf: 12281cb0ef41Sopenharmony_ci m = Condition(6); 12291cb0ef41Sopenharmony_ci break; 12301cb0ef41Sopenharmony_ci case kRoundToMinusInf: 12311cb0ef41Sopenharmony_ci m = Condition(7); 12321cb0ef41Sopenharmony_ci break; 12331cb0ef41Sopenharmony_ci default: 12341cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12351cb0ef41Sopenharmony_ci } 12361cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 12371cb0ef41Sopenharmony_ci lghi(dst, Operand::Zero()); 12381cb0ef41Sopenharmony_ci#endif 12391cb0ef41Sopenharmony_ci cfdbr(m, dst, double_input); 12401cb0ef41Sopenharmony_ci} 12411cb0ef41Sopenharmony_ci 12421cb0ef41Sopenharmony_civoid TurboAssembler::ConvertFloat32ToInt32(const Register result, 12431cb0ef41Sopenharmony_ci const DoubleRegister double_input, 12441cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 12451cb0ef41Sopenharmony_ci Condition m = Condition(0); 12461cb0ef41Sopenharmony_ci switch (rounding_mode) { 12471cb0ef41Sopenharmony_ci case kRoundToZero: 12481cb0ef41Sopenharmony_ci m = Condition(5); 12491cb0ef41Sopenharmony_ci break; 12501cb0ef41Sopenharmony_ci case kRoundToNearest: 12511cb0ef41Sopenharmony_ci m = Condition(4); 12521cb0ef41Sopenharmony_ci break; 12531cb0ef41Sopenharmony_ci case kRoundToPlusInf: 12541cb0ef41Sopenharmony_ci m = Condition(6); 12551cb0ef41Sopenharmony_ci break; 12561cb0ef41Sopenharmony_ci case kRoundToMinusInf: 12571cb0ef41Sopenharmony_ci m = Condition(7); 12581cb0ef41Sopenharmony_ci break; 12591cb0ef41Sopenharmony_ci default: 12601cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12611cb0ef41Sopenharmony_ci } 12621cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 12631cb0ef41Sopenharmony_ci lghi(result, Operand::Zero()); 12641cb0ef41Sopenharmony_ci#endif 12651cb0ef41Sopenharmony_ci cfebr(m, result, double_input); 12661cb0ef41Sopenharmony_ci} 12671cb0ef41Sopenharmony_ci 12681cb0ef41Sopenharmony_civoid TurboAssembler::ConvertFloat32ToUnsignedInt32( 12691cb0ef41Sopenharmony_ci const Register result, const DoubleRegister double_input, 12701cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 12711cb0ef41Sopenharmony_ci Condition m = Condition(0); 12721cb0ef41Sopenharmony_ci switch (rounding_mode) { 12731cb0ef41Sopenharmony_ci case kRoundToZero: 12741cb0ef41Sopenharmony_ci m = Condition(5); 12751cb0ef41Sopenharmony_ci break; 12761cb0ef41Sopenharmony_ci case kRoundToNearest: 12771cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12781cb0ef41Sopenharmony_ci case kRoundToPlusInf: 12791cb0ef41Sopenharmony_ci m = Condition(6); 12801cb0ef41Sopenharmony_ci break; 12811cb0ef41Sopenharmony_ci case kRoundToMinusInf: 12821cb0ef41Sopenharmony_ci m = Condition(7); 12831cb0ef41Sopenharmony_ci break; 12841cb0ef41Sopenharmony_ci default: 12851cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 12861cb0ef41Sopenharmony_ci } 12871cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 12881cb0ef41Sopenharmony_ci lghi(result, Operand::Zero()); 12891cb0ef41Sopenharmony_ci#endif 12901cb0ef41Sopenharmony_ci clfebr(m, Condition(0), result, double_input); 12911cb0ef41Sopenharmony_ci} 12921cb0ef41Sopenharmony_ci 12931cb0ef41Sopenharmony_civoid TurboAssembler::ConvertFloat32ToUnsignedInt64( 12941cb0ef41Sopenharmony_ci const Register result, const DoubleRegister double_input, 12951cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 12961cb0ef41Sopenharmony_ci Condition m = Condition(0); 12971cb0ef41Sopenharmony_ci switch (rounding_mode) { 12981cb0ef41Sopenharmony_ci case kRoundToZero: 12991cb0ef41Sopenharmony_ci m = Condition(5); 13001cb0ef41Sopenharmony_ci break; 13011cb0ef41Sopenharmony_ci case kRoundToNearest: 13021cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13031cb0ef41Sopenharmony_ci case kRoundToPlusInf: 13041cb0ef41Sopenharmony_ci m = Condition(6); 13051cb0ef41Sopenharmony_ci break; 13061cb0ef41Sopenharmony_ci case kRoundToMinusInf: 13071cb0ef41Sopenharmony_ci m = Condition(7); 13081cb0ef41Sopenharmony_ci break; 13091cb0ef41Sopenharmony_ci default: 13101cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13111cb0ef41Sopenharmony_ci } 13121cb0ef41Sopenharmony_ci clgebr(m, Condition(0), result, double_input); 13131cb0ef41Sopenharmony_ci} 13141cb0ef41Sopenharmony_ci 13151cb0ef41Sopenharmony_civoid TurboAssembler::ConvertDoubleToUnsignedInt64( 13161cb0ef41Sopenharmony_ci const Register dst, const DoubleRegister double_input, 13171cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 13181cb0ef41Sopenharmony_ci Condition m = Condition(0); 13191cb0ef41Sopenharmony_ci switch (rounding_mode) { 13201cb0ef41Sopenharmony_ci case kRoundToZero: 13211cb0ef41Sopenharmony_ci m = Condition(5); 13221cb0ef41Sopenharmony_ci break; 13231cb0ef41Sopenharmony_ci case kRoundToNearest: 13241cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13251cb0ef41Sopenharmony_ci case kRoundToPlusInf: 13261cb0ef41Sopenharmony_ci m = Condition(6); 13271cb0ef41Sopenharmony_ci break; 13281cb0ef41Sopenharmony_ci case kRoundToMinusInf: 13291cb0ef41Sopenharmony_ci m = Condition(7); 13301cb0ef41Sopenharmony_ci break; 13311cb0ef41Sopenharmony_ci default: 13321cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13331cb0ef41Sopenharmony_ci } 13341cb0ef41Sopenharmony_ci clgdbr(m, Condition(0), dst, double_input); 13351cb0ef41Sopenharmony_ci} 13361cb0ef41Sopenharmony_ci 13371cb0ef41Sopenharmony_civoid TurboAssembler::ConvertDoubleToUnsignedInt32( 13381cb0ef41Sopenharmony_ci const Register dst, const DoubleRegister double_input, 13391cb0ef41Sopenharmony_ci FPRoundingMode rounding_mode) { 13401cb0ef41Sopenharmony_ci Condition m = Condition(0); 13411cb0ef41Sopenharmony_ci switch (rounding_mode) { 13421cb0ef41Sopenharmony_ci case kRoundToZero: 13431cb0ef41Sopenharmony_ci m = Condition(5); 13441cb0ef41Sopenharmony_ci break; 13451cb0ef41Sopenharmony_ci case kRoundToNearest: 13461cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13471cb0ef41Sopenharmony_ci case kRoundToPlusInf: 13481cb0ef41Sopenharmony_ci m = Condition(6); 13491cb0ef41Sopenharmony_ci break; 13501cb0ef41Sopenharmony_ci case kRoundToMinusInf: 13511cb0ef41Sopenharmony_ci m = Condition(7); 13521cb0ef41Sopenharmony_ci break; 13531cb0ef41Sopenharmony_ci default: 13541cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 13551cb0ef41Sopenharmony_ci } 13561cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 13571cb0ef41Sopenharmony_ci lghi(dst, Operand::Zero()); 13581cb0ef41Sopenharmony_ci#endif 13591cb0ef41Sopenharmony_ci clfdbr(m, Condition(0), dst, double_input); 13601cb0ef41Sopenharmony_ci} 13611cb0ef41Sopenharmony_ci 13621cb0ef41Sopenharmony_civoid TurboAssembler::MovDoubleToInt64(Register dst, DoubleRegister src) { 13631cb0ef41Sopenharmony_ci lgdr(dst, src); 13641cb0ef41Sopenharmony_ci} 13651cb0ef41Sopenharmony_ci 13661cb0ef41Sopenharmony_civoid TurboAssembler::MovInt64ToDouble(DoubleRegister dst, Register src) { 13671cb0ef41Sopenharmony_ci ldgr(dst, src); 13681cb0ef41Sopenharmony_ci} 13691cb0ef41Sopenharmony_ci 13701cb0ef41Sopenharmony_civoid TurboAssembler::StubPrologue(StackFrame::Type type, Register base, 13711cb0ef41Sopenharmony_ci int prologue_offset) { 13721cb0ef41Sopenharmony_ci { 13731cb0ef41Sopenharmony_ci ConstantPoolUnavailableScope constant_pool_unavailable(this); 13741cb0ef41Sopenharmony_ci mov(r1, Operand(StackFrame::TypeToMarker(type))); 13751cb0ef41Sopenharmony_ci PushCommonFrame(r1); 13761cb0ef41Sopenharmony_ci } 13771cb0ef41Sopenharmony_ci} 13781cb0ef41Sopenharmony_ci 13791cb0ef41Sopenharmony_civoid TurboAssembler::Prologue(Register base, int prologue_offset) { 13801cb0ef41Sopenharmony_ci DCHECK(base != no_reg); 13811cb0ef41Sopenharmony_ci PushStandardFrame(r3); 13821cb0ef41Sopenharmony_ci} 13831cb0ef41Sopenharmony_ci 13841cb0ef41Sopenharmony_civoid TurboAssembler::DropArguments(Register count, ArgumentsCountType type, 13851cb0ef41Sopenharmony_ci ArgumentsCountMode mode) { 13861cb0ef41Sopenharmony_ci int receiver_bytes = 13871cb0ef41Sopenharmony_ci (mode == kCountExcludesReceiver) ? kSystemPointerSize : 0; 13881cb0ef41Sopenharmony_ci switch (type) { 13891cb0ef41Sopenharmony_ci case kCountIsInteger: { 13901cb0ef41Sopenharmony_ci ShiftLeftU64(ip, count, Operand(kSystemPointerSizeLog2)); 13911cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, ip)); 13921cb0ef41Sopenharmony_ci break; 13931cb0ef41Sopenharmony_ci } 13941cb0ef41Sopenharmony_ci case kCountIsSmi: { 13951cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTagSize == 1 && kSmiTag == 0); 13961cb0ef41Sopenharmony_ci SmiToPtrArrayOffset(count, count); 13971cb0ef41Sopenharmony_ci AddS64(sp, sp, count); 13981cb0ef41Sopenharmony_ci break; 13991cb0ef41Sopenharmony_ci } 14001cb0ef41Sopenharmony_ci case kCountIsBytes: { 14011cb0ef41Sopenharmony_ci AddS64(sp, sp, count); 14021cb0ef41Sopenharmony_ci break; 14031cb0ef41Sopenharmony_ci } 14041cb0ef41Sopenharmony_ci } 14051cb0ef41Sopenharmony_ci if (receiver_bytes != 0) { 14061cb0ef41Sopenharmony_ci AddS64(sp, sp, Operand(receiver_bytes)); 14071cb0ef41Sopenharmony_ci } 14081cb0ef41Sopenharmony_ci} 14091cb0ef41Sopenharmony_ci 14101cb0ef41Sopenharmony_civoid TurboAssembler::DropArgumentsAndPushNewReceiver(Register argc, 14111cb0ef41Sopenharmony_ci Register receiver, 14121cb0ef41Sopenharmony_ci ArgumentsCountType type, 14131cb0ef41Sopenharmony_ci ArgumentsCountMode mode) { 14141cb0ef41Sopenharmony_ci DCHECK(!AreAliased(argc, receiver)); 14151cb0ef41Sopenharmony_ci if (mode == kCountExcludesReceiver) { 14161cb0ef41Sopenharmony_ci // Drop arguments without receiver and override old receiver. 14171cb0ef41Sopenharmony_ci DropArguments(argc, type, kCountIncludesReceiver); 14181cb0ef41Sopenharmony_ci StoreU64(receiver, MemOperand(sp)); 14191cb0ef41Sopenharmony_ci } else { 14201cb0ef41Sopenharmony_ci DropArguments(argc, type, mode); 14211cb0ef41Sopenharmony_ci push(receiver); 14221cb0ef41Sopenharmony_ci } 14231cb0ef41Sopenharmony_ci} 14241cb0ef41Sopenharmony_ci 14251cb0ef41Sopenharmony_civoid TurboAssembler::EnterFrame(StackFrame::Type type, 14261cb0ef41Sopenharmony_ci bool load_constant_pool_pointer_reg) { 14271cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 14281cb0ef41Sopenharmony_ci // We create a stack frame with: 14291cb0ef41Sopenharmony_ci // Return Addr <-- old sp 14301cb0ef41Sopenharmony_ci // Old FP <-- new fp 14311cb0ef41Sopenharmony_ci // CP 14321cb0ef41Sopenharmony_ci // type 14331cb0ef41Sopenharmony_ci // CodeObject <-- new sp 14341cb0ef41Sopenharmony_ci 14351cb0ef41Sopenharmony_ci Register scratch = no_reg; 14361cb0ef41Sopenharmony_ci if (!StackFrame::IsJavaScript(type)) { 14371cb0ef41Sopenharmony_ci scratch = ip; 14381cb0ef41Sopenharmony_ci mov(scratch, Operand(StackFrame::TypeToMarker(type))); 14391cb0ef41Sopenharmony_ci } 14401cb0ef41Sopenharmony_ci PushCommonFrame(scratch); 14411cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 14421cb0ef41Sopenharmony_ci if (type == StackFrame::WASM) Push(kWasmInstanceRegister); 14431cb0ef41Sopenharmony_ci#endif // V8_ENABLE_WEBASSEMBLY 14441cb0ef41Sopenharmony_ci} 14451cb0ef41Sopenharmony_ci 14461cb0ef41Sopenharmony_ciint TurboAssembler::LeaveFrame(StackFrame::Type type, int stack_adjustment) { 14471cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 14481cb0ef41Sopenharmony_ci // Drop the execution stack down to the frame pointer and restore 14491cb0ef41Sopenharmony_ci // the caller frame pointer, return address and constant pool pointer. 14501cb0ef41Sopenharmony_ci LoadU64(r14, MemOperand(fp, StandardFrameConstants::kCallerPCOffset)); 14511cb0ef41Sopenharmony_ci if (is_int20(StandardFrameConstants::kCallerSPOffset + stack_adjustment)) { 14521cb0ef41Sopenharmony_ci lay(r1, MemOperand(fp, StandardFrameConstants::kCallerSPOffset + 14531cb0ef41Sopenharmony_ci stack_adjustment)); 14541cb0ef41Sopenharmony_ci } else { 14551cb0ef41Sopenharmony_ci AddS64(r1, fp, 14561cb0ef41Sopenharmony_ci Operand(StandardFrameConstants::kCallerSPOffset + stack_adjustment)); 14571cb0ef41Sopenharmony_ci } 14581cb0ef41Sopenharmony_ci LoadU64(fp, MemOperand(fp, StandardFrameConstants::kCallerFPOffset)); 14591cb0ef41Sopenharmony_ci mov(sp, r1); 14601cb0ef41Sopenharmony_ci int frame_ends = pc_offset(); 14611cb0ef41Sopenharmony_ci return frame_ends; 14621cb0ef41Sopenharmony_ci} 14631cb0ef41Sopenharmony_ci 14641cb0ef41Sopenharmony_ci// ExitFrame layout (probably wrongish.. needs updating) 14651cb0ef41Sopenharmony_ci// 14661cb0ef41Sopenharmony_ci// SP -> previousSP 14671cb0ef41Sopenharmony_ci// LK reserved 14681cb0ef41Sopenharmony_ci// sp_on_exit (for debug?) 14691cb0ef41Sopenharmony_ci// oldSP->prev SP 14701cb0ef41Sopenharmony_ci// LK 14711cb0ef41Sopenharmony_ci// <parameters on stack> 14721cb0ef41Sopenharmony_ci 14731cb0ef41Sopenharmony_ci// Prior to calling EnterExitFrame, we've got a bunch of parameters 14741cb0ef41Sopenharmony_ci// on the stack that we need to wrap a real frame around.. so first 14751cb0ef41Sopenharmony_ci// we reserve a slot for LK and push the previous SP which is captured 14761cb0ef41Sopenharmony_ci// in the fp register (r11) 14771cb0ef41Sopenharmony_ci// Then - we buy a new frame 14781cb0ef41Sopenharmony_ci 14791cb0ef41Sopenharmony_ci// r14 14801cb0ef41Sopenharmony_ci// oldFP <- newFP 14811cb0ef41Sopenharmony_ci// SP 14821cb0ef41Sopenharmony_ci// Floats 14831cb0ef41Sopenharmony_ci// gaps 14841cb0ef41Sopenharmony_ci// Args 14851cb0ef41Sopenharmony_ci// ABIRes <- newSP 14861cb0ef41Sopenharmony_civoid MacroAssembler::EnterExitFrame(bool save_doubles, int stack_space, 14871cb0ef41Sopenharmony_ci StackFrame::Type frame_type) { 14881cb0ef41Sopenharmony_ci DCHECK(frame_type == StackFrame::EXIT || 14891cb0ef41Sopenharmony_ci frame_type == StackFrame::BUILTIN_EXIT); 14901cb0ef41Sopenharmony_ci // Set up the frame structure on the stack. 14911cb0ef41Sopenharmony_ci DCHECK_EQ(2 * kSystemPointerSize, ExitFrameConstants::kCallerSPDisplacement); 14921cb0ef41Sopenharmony_ci DCHECK_EQ(1 * kSystemPointerSize, ExitFrameConstants::kCallerPCOffset); 14931cb0ef41Sopenharmony_ci DCHECK_EQ(0 * kSystemPointerSize, ExitFrameConstants::kCallerFPOffset); 14941cb0ef41Sopenharmony_ci DCHECK_GT(stack_space, 0); 14951cb0ef41Sopenharmony_ci 14961cb0ef41Sopenharmony_ci // This is an opportunity to build a frame to wrap 14971cb0ef41Sopenharmony_ci // all of the pushes that have happened inside of V8 14981cb0ef41Sopenharmony_ci // since we were called from C code 14991cb0ef41Sopenharmony_ci CleanseP(r14); 15001cb0ef41Sopenharmony_ci mov(r1, Operand(StackFrame::TypeToMarker(frame_type))); 15011cb0ef41Sopenharmony_ci PushCommonFrame(r1); 15021cb0ef41Sopenharmony_ci // Reserve room for saved entry sp. 15031cb0ef41Sopenharmony_ci lay(sp, MemOperand(fp, -ExitFrameConstants::kFixedFrameSizeFromFp)); 15041cb0ef41Sopenharmony_ci 15051cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 15061cb0ef41Sopenharmony_ci StoreU64(MemOperand(fp, ExitFrameConstants::kSPOffset), Operand::Zero(), 15071cb0ef41Sopenharmony_ci r1); 15081cb0ef41Sopenharmony_ci } 15091cb0ef41Sopenharmony_ci 15101cb0ef41Sopenharmony_ci // Save the frame pointer and the context in top. 15111cb0ef41Sopenharmony_ci Move(r1, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, 15121cb0ef41Sopenharmony_ci isolate())); 15131cb0ef41Sopenharmony_ci StoreU64(fp, MemOperand(r1)); 15141cb0ef41Sopenharmony_ci Move(r1, 15151cb0ef41Sopenharmony_ci ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); 15161cb0ef41Sopenharmony_ci StoreU64(cp, MemOperand(r1)); 15171cb0ef41Sopenharmony_ci 15181cb0ef41Sopenharmony_ci // Optionally save all volatile double registers. 15191cb0ef41Sopenharmony_ci if (save_doubles) { 15201cb0ef41Sopenharmony_ci MultiPushDoubles(kCallerSavedDoubles); 15211cb0ef41Sopenharmony_ci // Note that d0 will be accessible at 15221cb0ef41Sopenharmony_ci // fp - ExitFrameConstants::kFrameSize - 15231cb0ef41Sopenharmony_ci // kNumCallerSavedDoubles * kDoubleSize, 15241cb0ef41Sopenharmony_ci // since the sp slot and code slot were pushed after the fp. 15251cb0ef41Sopenharmony_ci } 15261cb0ef41Sopenharmony_ci 15271cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -stack_space * kSystemPointerSize)); 15281cb0ef41Sopenharmony_ci 15291cb0ef41Sopenharmony_ci // Allocate and align the frame preparing for calling the runtime 15301cb0ef41Sopenharmony_ci // function. 15311cb0ef41Sopenharmony_ci const int frame_alignment = TurboAssembler::ActivationFrameAlignment(); 15321cb0ef41Sopenharmony_ci if (frame_alignment > 0) { 15331cb0ef41Sopenharmony_ci DCHECK_EQ(frame_alignment, 8); 15341cb0ef41Sopenharmony_ci ClearRightImm(sp, sp, Operand(3)); // equivalent to &= -8 15351cb0ef41Sopenharmony_ci } 15361cb0ef41Sopenharmony_ci 15371cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kNumRequiredStackFrameSlots * kSystemPointerSize)); 15381cb0ef41Sopenharmony_ci StoreU64(MemOperand(sp), Operand::Zero(), r0); 15391cb0ef41Sopenharmony_ci // Set the exit frame sp value to point just before the return address 15401cb0ef41Sopenharmony_ci // location. 15411cb0ef41Sopenharmony_ci lay(r1, MemOperand(sp, kStackFrameSPSlot * kSystemPointerSize)); 15421cb0ef41Sopenharmony_ci StoreU64(r1, MemOperand(fp, ExitFrameConstants::kSPOffset)); 15431cb0ef41Sopenharmony_ci} 15441cb0ef41Sopenharmony_ci 15451cb0ef41Sopenharmony_ciint TurboAssembler::ActivationFrameAlignment() { 15461cb0ef41Sopenharmony_ci#if !defined(USE_SIMULATOR) 15471cb0ef41Sopenharmony_ci // Running on the real platform. Use the alignment as mandated by the local 15481cb0ef41Sopenharmony_ci // environment. 15491cb0ef41Sopenharmony_ci // Note: This will break if we ever start generating snapshots on one S390 15501cb0ef41Sopenharmony_ci // platform for another S390 platform with a different alignment. 15511cb0ef41Sopenharmony_ci return base::OS::ActivationFrameAlignment(); 15521cb0ef41Sopenharmony_ci#else // Simulated 15531cb0ef41Sopenharmony_ci // If we are using the simulator then we should always align to the expected 15541cb0ef41Sopenharmony_ci // alignment. As the simulator is used to generate snapshots we do not know 15551cb0ef41Sopenharmony_ci // if the target platform will need alignment, so this is controlled from a 15561cb0ef41Sopenharmony_ci // flag. 15571cb0ef41Sopenharmony_ci return FLAG_sim_stack_alignment; 15581cb0ef41Sopenharmony_ci#endif 15591cb0ef41Sopenharmony_ci} 15601cb0ef41Sopenharmony_ci 15611cb0ef41Sopenharmony_civoid MacroAssembler::LeaveExitFrame(bool save_doubles, Register argument_count, 15621cb0ef41Sopenharmony_ci bool argument_count_is_length) { 15631cb0ef41Sopenharmony_ci // Optionally restore all double registers. 15641cb0ef41Sopenharmony_ci if (save_doubles) { 15651cb0ef41Sopenharmony_ci // Calculate the stack location of the saved doubles and restore them. 15661cb0ef41Sopenharmony_ci const int kNumRegs = kNumCallerSavedDoubles; 15671cb0ef41Sopenharmony_ci lay(r5, MemOperand(fp, -(ExitFrameConstants::kFixedFrameSizeFromFp + 15681cb0ef41Sopenharmony_ci kNumRegs * kDoubleSize))); 15691cb0ef41Sopenharmony_ci MultiPopDoubles(kCallerSavedDoubles, r5); 15701cb0ef41Sopenharmony_ci } 15711cb0ef41Sopenharmony_ci 15721cb0ef41Sopenharmony_ci // Clear top frame. 15731cb0ef41Sopenharmony_ci Move(ip, ExternalReference::Create(IsolateAddressId::kCEntryFPAddress, 15741cb0ef41Sopenharmony_ci isolate())); 15751cb0ef41Sopenharmony_ci StoreU64(MemOperand(ip), Operand(0, RelocInfo::NO_INFO), r0); 15761cb0ef41Sopenharmony_ci 15771cb0ef41Sopenharmony_ci // Restore current context from top and clear it in debug mode. 15781cb0ef41Sopenharmony_ci Move(ip, 15791cb0ef41Sopenharmony_ci ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); 15801cb0ef41Sopenharmony_ci LoadU64(cp, MemOperand(ip)); 15811cb0ef41Sopenharmony_ci 15821cb0ef41Sopenharmony_ci#ifdef DEBUG 15831cb0ef41Sopenharmony_ci mov(r1, Operand(Context::kInvalidContext)); 15841cb0ef41Sopenharmony_ci Move(ip, 15851cb0ef41Sopenharmony_ci ExternalReference::Create(IsolateAddressId::kContextAddress, isolate())); 15861cb0ef41Sopenharmony_ci StoreU64(r1, MemOperand(ip)); 15871cb0ef41Sopenharmony_ci#endif 15881cb0ef41Sopenharmony_ci 15891cb0ef41Sopenharmony_ci // Tear down the exit frame, pop the arguments, and return. 15901cb0ef41Sopenharmony_ci LeaveFrame(StackFrame::EXIT); 15911cb0ef41Sopenharmony_ci 15921cb0ef41Sopenharmony_ci if (argument_count.is_valid()) { 15931cb0ef41Sopenharmony_ci if (!argument_count_is_length) { 15941cb0ef41Sopenharmony_ci ShiftLeftU64(argument_count, argument_count, 15951cb0ef41Sopenharmony_ci Operand(kSystemPointerSizeLog2)); 15961cb0ef41Sopenharmony_ci } 15971cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, argument_count)); 15981cb0ef41Sopenharmony_ci } 15991cb0ef41Sopenharmony_ci} 16001cb0ef41Sopenharmony_ci 16011cb0ef41Sopenharmony_civoid TurboAssembler::MovFromFloatResult(const DoubleRegister dst) { 16021cb0ef41Sopenharmony_ci Move(dst, d0); 16031cb0ef41Sopenharmony_ci} 16041cb0ef41Sopenharmony_ci 16051cb0ef41Sopenharmony_civoid TurboAssembler::MovFromFloatParameter(const DoubleRegister dst) { 16061cb0ef41Sopenharmony_ci Move(dst, d0); 16071cb0ef41Sopenharmony_ci} 16081cb0ef41Sopenharmony_ci 16091cb0ef41Sopenharmony_ciMemOperand MacroAssembler::StackLimitAsMemOperand(StackLimitKind kind) { 16101cb0ef41Sopenharmony_ci DCHECK(root_array_available()); 16111cb0ef41Sopenharmony_ci Isolate* isolate = this->isolate(); 16121cb0ef41Sopenharmony_ci ExternalReference limit = 16131cb0ef41Sopenharmony_ci kind == StackLimitKind::kRealStackLimit 16141cb0ef41Sopenharmony_ci ? ExternalReference::address_of_real_jslimit(isolate) 16151cb0ef41Sopenharmony_ci : ExternalReference::address_of_jslimit(isolate); 16161cb0ef41Sopenharmony_ci DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); 16171cb0ef41Sopenharmony_ci 16181cb0ef41Sopenharmony_ci intptr_t offset = 16191cb0ef41Sopenharmony_ci TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); 16201cb0ef41Sopenharmony_ci CHECK(is_int32(offset)); 16211cb0ef41Sopenharmony_ci return MemOperand(kRootRegister, offset); 16221cb0ef41Sopenharmony_ci} 16231cb0ef41Sopenharmony_ci 16241cb0ef41Sopenharmony_civoid MacroAssembler::StackOverflowCheck(Register num_args, Register scratch, 16251cb0ef41Sopenharmony_ci Label* stack_overflow) { 16261cb0ef41Sopenharmony_ci // Check the stack for overflow. We are not trying to catch 16271cb0ef41Sopenharmony_ci // interruptions (e.g. debug break and preemption) here, so the "real stack 16281cb0ef41Sopenharmony_ci // limit" is checked. 16291cb0ef41Sopenharmony_ci LoadU64(scratch, StackLimitAsMemOperand(StackLimitKind::kRealStackLimit)); 16301cb0ef41Sopenharmony_ci // Make scratch the space we have left. The stack might already be overflowed 16311cb0ef41Sopenharmony_ci // here which will cause scratch to become negative. 16321cb0ef41Sopenharmony_ci SubS64(scratch, sp, scratch); 16331cb0ef41Sopenharmony_ci // Check if the arguments will overflow the stack. 16341cb0ef41Sopenharmony_ci ShiftLeftU64(r0, num_args, Operand(kSystemPointerSizeLog2)); 16351cb0ef41Sopenharmony_ci CmpS64(scratch, r0); 16361cb0ef41Sopenharmony_ci ble(stack_overflow); // Signed comparison. 16371cb0ef41Sopenharmony_ci} 16381cb0ef41Sopenharmony_ci 16391cb0ef41Sopenharmony_civoid MacroAssembler::InvokePrologue(Register expected_parameter_count, 16401cb0ef41Sopenharmony_ci Register actual_parameter_count, 16411cb0ef41Sopenharmony_ci Label* done, InvokeType type) { 16421cb0ef41Sopenharmony_ci Label regular_invoke; 16431cb0ef41Sopenharmony_ci 16441cb0ef41Sopenharmony_ci // r2: actual arguments count 16451cb0ef41Sopenharmony_ci // r3: function (passed through to callee) 16461cb0ef41Sopenharmony_ci // r4: expected arguments count 16471cb0ef41Sopenharmony_ci 16481cb0ef41Sopenharmony_ci DCHECK_EQ(actual_parameter_count, r2); 16491cb0ef41Sopenharmony_ci DCHECK_EQ(expected_parameter_count, r4); 16501cb0ef41Sopenharmony_ci 16511cb0ef41Sopenharmony_ci // If the expected parameter count is equal to the adaptor sentinel, no need 16521cb0ef41Sopenharmony_ci // to push undefined value as arguments. 16531cb0ef41Sopenharmony_ci if (kDontAdaptArgumentsSentinel != 0) { 16541cb0ef41Sopenharmony_ci CmpS64(expected_parameter_count, Operand(kDontAdaptArgumentsSentinel)); 16551cb0ef41Sopenharmony_ci beq(®ular_invoke); 16561cb0ef41Sopenharmony_ci } 16571cb0ef41Sopenharmony_ci 16581cb0ef41Sopenharmony_ci // If overapplication or if the actual argument count is equal to the 16591cb0ef41Sopenharmony_ci // formal parameter count, no need to push extra undefined values. 16601cb0ef41Sopenharmony_ci SubS64(expected_parameter_count, expected_parameter_count, 16611cb0ef41Sopenharmony_ci actual_parameter_count); 16621cb0ef41Sopenharmony_ci ble(®ular_invoke); 16631cb0ef41Sopenharmony_ci 16641cb0ef41Sopenharmony_ci Label stack_overflow; 16651cb0ef41Sopenharmony_ci Register scratch = r6; 16661cb0ef41Sopenharmony_ci StackOverflowCheck(expected_parameter_count, scratch, &stack_overflow); 16671cb0ef41Sopenharmony_ci 16681cb0ef41Sopenharmony_ci // Underapplication. Move the arguments already in the stack, including the 16691cb0ef41Sopenharmony_ci // receiver and the return address. 16701cb0ef41Sopenharmony_ci { 16711cb0ef41Sopenharmony_ci Label copy, check; 16721cb0ef41Sopenharmony_ci Register num = r7, src = r8, dest = ip; // r7 and r8 are context and root. 16731cb0ef41Sopenharmony_ci mov(src, sp); 16741cb0ef41Sopenharmony_ci // Update stack pointer. 16751cb0ef41Sopenharmony_ci ShiftLeftU64(scratch, expected_parameter_count, 16761cb0ef41Sopenharmony_ci Operand(kSystemPointerSizeLog2)); 16771cb0ef41Sopenharmony_ci SubS64(sp, sp, scratch); 16781cb0ef41Sopenharmony_ci mov(dest, sp); 16791cb0ef41Sopenharmony_ci ltgr(num, actual_parameter_count); 16801cb0ef41Sopenharmony_ci b(&check); 16811cb0ef41Sopenharmony_ci bind(©); 16821cb0ef41Sopenharmony_ci LoadU64(r0, MemOperand(src)); 16831cb0ef41Sopenharmony_ci lay(src, MemOperand(src, kSystemPointerSize)); 16841cb0ef41Sopenharmony_ci StoreU64(r0, MemOperand(dest)); 16851cb0ef41Sopenharmony_ci lay(dest, MemOperand(dest, kSystemPointerSize)); 16861cb0ef41Sopenharmony_ci SubS64(num, num, Operand(1)); 16871cb0ef41Sopenharmony_ci bind(&check); 16881cb0ef41Sopenharmony_ci b(gt, ©); 16891cb0ef41Sopenharmony_ci } 16901cb0ef41Sopenharmony_ci 16911cb0ef41Sopenharmony_ci // Fill remaining expected arguments with undefined values. 16921cb0ef41Sopenharmony_ci LoadRoot(scratch, RootIndex::kUndefinedValue); 16931cb0ef41Sopenharmony_ci { 16941cb0ef41Sopenharmony_ci Label loop; 16951cb0ef41Sopenharmony_ci bind(&loop); 16961cb0ef41Sopenharmony_ci StoreU64(scratch, MemOperand(ip)); 16971cb0ef41Sopenharmony_ci lay(ip, MemOperand(ip, kSystemPointerSize)); 16981cb0ef41Sopenharmony_ci SubS64(expected_parameter_count, expected_parameter_count, Operand(1)); 16991cb0ef41Sopenharmony_ci bgt(&loop); 17001cb0ef41Sopenharmony_ci } 17011cb0ef41Sopenharmony_ci b(®ular_invoke); 17021cb0ef41Sopenharmony_ci 17031cb0ef41Sopenharmony_ci bind(&stack_overflow); 17041cb0ef41Sopenharmony_ci { 17051cb0ef41Sopenharmony_ci FrameScope frame( 17061cb0ef41Sopenharmony_ci this, has_frame() ? StackFrame::NO_FRAME_TYPE : StackFrame::INTERNAL); 17071cb0ef41Sopenharmony_ci CallRuntime(Runtime::kThrowStackOverflow); 17081cb0ef41Sopenharmony_ci bkpt(0); 17091cb0ef41Sopenharmony_ci } 17101cb0ef41Sopenharmony_ci 17111cb0ef41Sopenharmony_ci bind(®ular_invoke); 17121cb0ef41Sopenharmony_ci} 17131cb0ef41Sopenharmony_ci 17141cb0ef41Sopenharmony_civoid MacroAssembler::CheckDebugHook(Register fun, Register new_target, 17151cb0ef41Sopenharmony_ci Register expected_parameter_count, 17161cb0ef41Sopenharmony_ci Register actual_parameter_count) { 17171cb0ef41Sopenharmony_ci Label skip_hook; 17181cb0ef41Sopenharmony_ci 17191cb0ef41Sopenharmony_ci ExternalReference debug_hook_active = 17201cb0ef41Sopenharmony_ci ExternalReference::debug_hook_on_function_call_address(isolate()); 17211cb0ef41Sopenharmony_ci Move(r6, debug_hook_active); 17221cb0ef41Sopenharmony_ci tm(MemOperand(r6), Operand(0xFF)); 17231cb0ef41Sopenharmony_ci beq(&skip_hook); 17241cb0ef41Sopenharmony_ci 17251cb0ef41Sopenharmony_ci { 17261cb0ef41Sopenharmony_ci // Load receiver to pass it later to DebugOnFunctionCall hook. 17271cb0ef41Sopenharmony_ci LoadReceiver(r6, actual_parameter_count); 17281cb0ef41Sopenharmony_ci FrameScope frame( 17291cb0ef41Sopenharmony_ci this, has_frame() ? StackFrame::NO_FRAME_TYPE : StackFrame::INTERNAL); 17301cb0ef41Sopenharmony_ci 17311cb0ef41Sopenharmony_ci SmiTag(expected_parameter_count); 17321cb0ef41Sopenharmony_ci Push(expected_parameter_count); 17331cb0ef41Sopenharmony_ci 17341cb0ef41Sopenharmony_ci SmiTag(actual_parameter_count); 17351cb0ef41Sopenharmony_ci Push(actual_parameter_count); 17361cb0ef41Sopenharmony_ci 17371cb0ef41Sopenharmony_ci if (new_target.is_valid()) { 17381cb0ef41Sopenharmony_ci Push(new_target); 17391cb0ef41Sopenharmony_ci } 17401cb0ef41Sopenharmony_ci Push(fun, fun, r6); 17411cb0ef41Sopenharmony_ci CallRuntime(Runtime::kDebugOnFunctionCall); 17421cb0ef41Sopenharmony_ci Pop(fun); 17431cb0ef41Sopenharmony_ci if (new_target.is_valid()) { 17441cb0ef41Sopenharmony_ci Pop(new_target); 17451cb0ef41Sopenharmony_ci } 17461cb0ef41Sopenharmony_ci 17471cb0ef41Sopenharmony_ci Pop(actual_parameter_count); 17481cb0ef41Sopenharmony_ci SmiUntag(actual_parameter_count); 17491cb0ef41Sopenharmony_ci 17501cb0ef41Sopenharmony_ci Pop(expected_parameter_count); 17511cb0ef41Sopenharmony_ci SmiUntag(expected_parameter_count); 17521cb0ef41Sopenharmony_ci } 17531cb0ef41Sopenharmony_ci bind(&skip_hook); 17541cb0ef41Sopenharmony_ci} 17551cb0ef41Sopenharmony_ci 17561cb0ef41Sopenharmony_civoid MacroAssembler::InvokeFunctionCode(Register function, Register new_target, 17571cb0ef41Sopenharmony_ci Register expected_parameter_count, 17581cb0ef41Sopenharmony_ci Register actual_parameter_count, 17591cb0ef41Sopenharmony_ci InvokeType type) { 17601cb0ef41Sopenharmony_ci // You can't call a function without a valid frame. 17611cb0ef41Sopenharmony_ci DCHECK_IMPLIES(type == InvokeType::kCall, has_frame()); 17621cb0ef41Sopenharmony_ci DCHECK_EQ(function, r3); 17631cb0ef41Sopenharmony_ci DCHECK_IMPLIES(new_target.is_valid(), new_target == r5); 17641cb0ef41Sopenharmony_ci 17651cb0ef41Sopenharmony_ci // On function call, call into the debugger if necessary. 17661cb0ef41Sopenharmony_ci CheckDebugHook(function, new_target, expected_parameter_count, 17671cb0ef41Sopenharmony_ci actual_parameter_count); 17681cb0ef41Sopenharmony_ci 17691cb0ef41Sopenharmony_ci // Clear the new.target register if not given. 17701cb0ef41Sopenharmony_ci if (!new_target.is_valid()) { 17711cb0ef41Sopenharmony_ci LoadRoot(r5, RootIndex::kUndefinedValue); 17721cb0ef41Sopenharmony_ci } 17731cb0ef41Sopenharmony_ci 17741cb0ef41Sopenharmony_ci Label done; 17751cb0ef41Sopenharmony_ci InvokePrologue(expected_parameter_count, actual_parameter_count, &done, type); 17761cb0ef41Sopenharmony_ci // We call indirectly through the code field in the function to 17771cb0ef41Sopenharmony_ci // allow recompilation to take effect without changing any of the 17781cb0ef41Sopenharmony_ci // call sites. 17791cb0ef41Sopenharmony_ci Register code = kJavaScriptCallCodeStartRegister; 17801cb0ef41Sopenharmony_ci LoadTaggedPointerField(code, 17811cb0ef41Sopenharmony_ci FieldMemOperand(function, JSFunction::kCodeOffset)); 17821cb0ef41Sopenharmony_ci switch (type) { 17831cb0ef41Sopenharmony_ci case InvokeType::kCall: 17841cb0ef41Sopenharmony_ci CallCodeObject(code); 17851cb0ef41Sopenharmony_ci break; 17861cb0ef41Sopenharmony_ci case InvokeType::kJump: 17871cb0ef41Sopenharmony_ci JumpCodeObject(code); 17881cb0ef41Sopenharmony_ci break; 17891cb0ef41Sopenharmony_ci } 17901cb0ef41Sopenharmony_ci // Continue here if InvokePrologue does handle the invocation due to 17911cb0ef41Sopenharmony_ci // mismatched parameter counts. 17921cb0ef41Sopenharmony_ci bind(&done); 17931cb0ef41Sopenharmony_ci} 17941cb0ef41Sopenharmony_ci 17951cb0ef41Sopenharmony_civoid MacroAssembler::InvokeFunctionWithNewTarget( 17961cb0ef41Sopenharmony_ci Register fun, Register new_target, Register actual_parameter_count, 17971cb0ef41Sopenharmony_ci InvokeType type) { 17981cb0ef41Sopenharmony_ci // You can't call a function without a valid frame. 17991cb0ef41Sopenharmony_ci DCHECK_IMPLIES(type == InvokeType::kCall, has_frame()); 18001cb0ef41Sopenharmony_ci 18011cb0ef41Sopenharmony_ci // Contract with called JS functions requires that function is passed in r3. 18021cb0ef41Sopenharmony_ci DCHECK_EQ(fun, r3); 18031cb0ef41Sopenharmony_ci 18041cb0ef41Sopenharmony_ci Register expected_reg = r4; 18051cb0ef41Sopenharmony_ci Register temp_reg = r6; 18061cb0ef41Sopenharmony_ci LoadTaggedPointerField(cp, FieldMemOperand(fun, JSFunction::kContextOffset)); 18071cb0ef41Sopenharmony_ci LoadTaggedPointerField( 18081cb0ef41Sopenharmony_ci temp_reg, FieldMemOperand(fun, JSFunction::kSharedFunctionInfoOffset)); 18091cb0ef41Sopenharmony_ci LoadU16( 18101cb0ef41Sopenharmony_ci expected_reg, 18111cb0ef41Sopenharmony_ci FieldMemOperand(temp_reg, 18121cb0ef41Sopenharmony_ci SharedFunctionInfo::kFormalParameterCountOffset)); 18131cb0ef41Sopenharmony_ci 18141cb0ef41Sopenharmony_ci InvokeFunctionCode(fun, new_target, expected_reg, actual_parameter_count, 18151cb0ef41Sopenharmony_ci type); 18161cb0ef41Sopenharmony_ci} 18171cb0ef41Sopenharmony_ci 18181cb0ef41Sopenharmony_civoid MacroAssembler::InvokeFunction(Register function, 18191cb0ef41Sopenharmony_ci Register expected_parameter_count, 18201cb0ef41Sopenharmony_ci Register actual_parameter_count, 18211cb0ef41Sopenharmony_ci InvokeType type) { 18221cb0ef41Sopenharmony_ci // You can't call a function without a valid frame. 18231cb0ef41Sopenharmony_ci DCHECK_IMPLIES(type == InvokeType::kCall, has_frame()); 18241cb0ef41Sopenharmony_ci 18251cb0ef41Sopenharmony_ci // Contract with called JS functions requires that function is passed in r3. 18261cb0ef41Sopenharmony_ci DCHECK_EQ(function, r3); 18271cb0ef41Sopenharmony_ci 18281cb0ef41Sopenharmony_ci // Get the function and setup the context. 18291cb0ef41Sopenharmony_ci LoadTaggedPointerField(cp, 18301cb0ef41Sopenharmony_ci FieldMemOperand(function, JSFunction::kContextOffset)); 18311cb0ef41Sopenharmony_ci 18321cb0ef41Sopenharmony_ci InvokeFunctionCode(r3, no_reg, expected_parameter_count, 18331cb0ef41Sopenharmony_ci actual_parameter_count, type); 18341cb0ef41Sopenharmony_ci} 18351cb0ef41Sopenharmony_ci 18361cb0ef41Sopenharmony_civoid MacroAssembler::PushStackHandler() { 18371cb0ef41Sopenharmony_ci // Adjust this code if not the case. 18381cb0ef41Sopenharmony_ci STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kSystemPointerSize); 18391cb0ef41Sopenharmony_ci STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0 * kSystemPointerSize); 18401cb0ef41Sopenharmony_ci 18411cb0ef41Sopenharmony_ci // Link the current handler as the next handler. 18421cb0ef41Sopenharmony_ci Move(r7, 18431cb0ef41Sopenharmony_ci ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); 18441cb0ef41Sopenharmony_ci 18451cb0ef41Sopenharmony_ci // Buy the full stack frame for 5 slots. 18461cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -StackHandlerConstants::kSize)); 18471cb0ef41Sopenharmony_ci 18481cb0ef41Sopenharmony_ci // Store padding. 18491cb0ef41Sopenharmony_ci lghi(r0, Operand::Zero()); 18501cb0ef41Sopenharmony_ci StoreU64(r0, MemOperand(sp)); // Padding. 18511cb0ef41Sopenharmony_ci 18521cb0ef41Sopenharmony_ci // Copy the old handler into the next handler slot. 18531cb0ef41Sopenharmony_ci MoveChar(MemOperand(sp, StackHandlerConstants::kNextOffset), MemOperand(r7), 18541cb0ef41Sopenharmony_ci Operand(kSystemPointerSize)); 18551cb0ef41Sopenharmony_ci // Set this new handler as the current one. 18561cb0ef41Sopenharmony_ci StoreU64(sp, MemOperand(r7)); 18571cb0ef41Sopenharmony_ci} 18581cb0ef41Sopenharmony_ci 18591cb0ef41Sopenharmony_civoid MacroAssembler::PopStackHandler() { 18601cb0ef41Sopenharmony_ci STATIC_ASSERT(StackHandlerConstants::kSize == 2 * kSystemPointerSize); 18611cb0ef41Sopenharmony_ci STATIC_ASSERT(StackHandlerConstants::kNextOffset == 0); 18621cb0ef41Sopenharmony_ci 18631cb0ef41Sopenharmony_ci // Pop the Next Handler into r3 and store it into Handler Address reference. 18641cb0ef41Sopenharmony_ci Pop(r3); 18651cb0ef41Sopenharmony_ci Move(ip, 18661cb0ef41Sopenharmony_ci ExternalReference::Create(IsolateAddressId::kHandlerAddress, isolate())); 18671cb0ef41Sopenharmony_ci StoreU64(r3, MemOperand(ip)); 18681cb0ef41Sopenharmony_ci 18691cb0ef41Sopenharmony_ci Drop(1); // Drop padding. 18701cb0ef41Sopenharmony_ci} 18711cb0ef41Sopenharmony_ci 18721cb0ef41Sopenharmony_civoid MacroAssembler::CompareObjectType(Register object, Register map, 18731cb0ef41Sopenharmony_ci Register type_reg, InstanceType type) { 18741cb0ef41Sopenharmony_ci const Register temp = type_reg == no_reg ? r0 : type_reg; 18751cb0ef41Sopenharmony_ci 18761cb0ef41Sopenharmony_ci LoadMap(map, object); 18771cb0ef41Sopenharmony_ci CompareInstanceType(map, temp, type); 18781cb0ef41Sopenharmony_ci} 18791cb0ef41Sopenharmony_ci 18801cb0ef41Sopenharmony_civoid MacroAssembler::CompareInstanceType(Register map, Register type_reg, 18811cb0ef41Sopenharmony_ci InstanceType type) { 18821cb0ef41Sopenharmony_ci STATIC_ASSERT(Map::kInstanceTypeOffset < 4096); 18831cb0ef41Sopenharmony_ci STATIC_ASSERT(LAST_TYPE <= 0xFFFF); 18841cb0ef41Sopenharmony_ci LoadS16(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); 18851cb0ef41Sopenharmony_ci CmpS64(type_reg, Operand(type)); 18861cb0ef41Sopenharmony_ci} 18871cb0ef41Sopenharmony_ci 18881cb0ef41Sopenharmony_civoid MacroAssembler::CompareRange(Register value, unsigned lower_limit, 18891cb0ef41Sopenharmony_ci unsigned higher_limit) { 18901cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 18911cb0ef41Sopenharmony_ci DCHECK_LT(lower_limit, higher_limit); 18921cb0ef41Sopenharmony_ci if (lower_limit != 0) { 18931cb0ef41Sopenharmony_ci UseScratchRegisterScope temps(this); 18941cb0ef41Sopenharmony_ci Register scratch = temps.Acquire(); 18951cb0ef41Sopenharmony_ci mov(scratch, value); 18961cb0ef41Sopenharmony_ci slgfi(scratch, Operand(lower_limit)); 18971cb0ef41Sopenharmony_ci CmpU64(scratch, Operand(higher_limit - lower_limit)); 18981cb0ef41Sopenharmony_ci } else { 18991cb0ef41Sopenharmony_ci CmpU64(value, Operand(higher_limit)); 19001cb0ef41Sopenharmony_ci } 19011cb0ef41Sopenharmony_ci} 19021cb0ef41Sopenharmony_ci 19031cb0ef41Sopenharmony_civoid MacroAssembler::CompareInstanceTypeRange(Register map, Register type_reg, 19041cb0ef41Sopenharmony_ci InstanceType lower_limit, 19051cb0ef41Sopenharmony_ci InstanceType higher_limit) { 19061cb0ef41Sopenharmony_ci DCHECK_LT(lower_limit, higher_limit); 19071cb0ef41Sopenharmony_ci LoadU16(type_reg, FieldMemOperand(map, Map::kInstanceTypeOffset)); 19081cb0ef41Sopenharmony_ci CompareRange(type_reg, lower_limit, higher_limit); 19091cb0ef41Sopenharmony_ci} 19101cb0ef41Sopenharmony_ci 19111cb0ef41Sopenharmony_civoid MacroAssembler::CompareRoot(Register obj, RootIndex index) { 19121cb0ef41Sopenharmony_ci int32_t offset = RootRegisterOffsetForRootIndex(index); 19131cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 19141cb0ef41Sopenharmony_ci offset += (COMPRESS_POINTERS_BOOL ? kTaggedSize : 0); 19151cb0ef41Sopenharmony_ci#endif 19161cb0ef41Sopenharmony_ci CompareTagged(obj, MemOperand(kRootRegister, offset)); 19171cb0ef41Sopenharmony_ci} 19181cb0ef41Sopenharmony_ci 19191cb0ef41Sopenharmony_civoid MacroAssembler::JumpIfIsInRange(Register value, unsigned lower_limit, 19201cb0ef41Sopenharmony_ci unsigned higher_limit, 19211cb0ef41Sopenharmony_ci Label* on_in_range) { 19221cb0ef41Sopenharmony_ci CompareRange(value, lower_limit, higher_limit); 19231cb0ef41Sopenharmony_ci ble(on_in_range); 19241cb0ef41Sopenharmony_ci} 19251cb0ef41Sopenharmony_ci 19261cb0ef41Sopenharmony_civoid TurboAssembler::TruncateDoubleToI(Isolate* isolate, Zone* zone, 19271cb0ef41Sopenharmony_ci Register result, 19281cb0ef41Sopenharmony_ci DoubleRegister double_input, 19291cb0ef41Sopenharmony_ci StubCallMode stub_mode) { 19301cb0ef41Sopenharmony_ci Label done; 19311cb0ef41Sopenharmony_ci 19321cb0ef41Sopenharmony_ci TryInlineTruncateDoubleToI(result, double_input, &done); 19331cb0ef41Sopenharmony_ci 19341cb0ef41Sopenharmony_ci // If we fell through then inline version didn't succeed - call stub instead. 19351cb0ef41Sopenharmony_ci push(r14); 19361cb0ef41Sopenharmony_ci // Put input on stack. 19371cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kDoubleSize)); 19381cb0ef41Sopenharmony_ci StoreF64(double_input, MemOperand(sp)); 19391cb0ef41Sopenharmony_ci 19401cb0ef41Sopenharmony_ci#if V8_ENABLE_WEBASSEMBLY 19411cb0ef41Sopenharmony_ci if (stub_mode == StubCallMode::kCallWasmRuntimeStub) { 19421cb0ef41Sopenharmony_ci Call(wasm::WasmCode::kDoubleToI, RelocInfo::WASM_STUB_CALL); 19431cb0ef41Sopenharmony_ci#else 19441cb0ef41Sopenharmony_ci // For balance. 19451cb0ef41Sopenharmony_ci if (false) { 19461cb0ef41Sopenharmony_ci#endif // V8_ENABLE_WEBASSEMBLY 19471cb0ef41Sopenharmony_ci } else { 19481cb0ef41Sopenharmony_ci Call(BUILTIN_CODE(isolate, DoubleToI), RelocInfo::CODE_TARGET); 19491cb0ef41Sopenharmony_ci } 19501cb0ef41Sopenharmony_ci 19511cb0ef41Sopenharmony_ci LoadU64(result, MemOperand(sp, 0)); 19521cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, kDoubleSize)); 19531cb0ef41Sopenharmony_ci pop(r14); 19541cb0ef41Sopenharmony_ci 19551cb0ef41Sopenharmony_ci bind(&done); 19561cb0ef41Sopenharmony_ci} 19571cb0ef41Sopenharmony_ci 19581cb0ef41Sopenharmony_civoid TurboAssembler::TryInlineTruncateDoubleToI(Register result, 19591cb0ef41Sopenharmony_ci DoubleRegister double_input, 19601cb0ef41Sopenharmony_ci Label* done) { 19611cb0ef41Sopenharmony_ci ConvertDoubleToInt64(result, double_input); 19621cb0ef41Sopenharmony_ci 19631cb0ef41Sopenharmony_ci // Test for overflow 19641cb0ef41Sopenharmony_ci TestIfInt32(result); 19651cb0ef41Sopenharmony_ci beq(done); 19661cb0ef41Sopenharmony_ci} 19671cb0ef41Sopenharmony_ci 19681cb0ef41Sopenharmony_civoid MacroAssembler::CallRuntime(const Runtime::Function* f, int num_arguments, 19691cb0ef41Sopenharmony_ci SaveFPRegsMode save_doubles) { 19701cb0ef41Sopenharmony_ci // All parameters are on the stack. r2 has the return value after call. 19711cb0ef41Sopenharmony_ci 19721cb0ef41Sopenharmony_ci // If the expected number of arguments of the runtime function is 19731cb0ef41Sopenharmony_ci // constant, we check that the actual number of arguments match the 19741cb0ef41Sopenharmony_ci // expectation. 19751cb0ef41Sopenharmony_ci CHECK(f->nargs < 0 || f->nargs == num_arguments); 19761cb0ef41Sopenharmony_ci 19771cb0ef41Sopenharmony_ci // TODO(1236192): Most runtime routines don't need the number of 19781cb0ef41Sopenharmony_ci // arguments passed in because it is constant. At some point we 19791cb0ef41Sopenharmony_ci // should remove this need and make the runtime routine entry code 19801cb0ef41Sopenharmony_ci // smarter. 19811cb0ef41Sopenharmony_ci mov(r2, Operand(num_arguments)); 19821cb0ef41Sopenharmony_ci Move(r3, ExternalReference::Create(f)); 19831cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 19841cb0ef41Sopenharmony_ci Handle<Code> code = 19851cb0ef41Sopenharmony_ci CodeFactory::CEntry(isolate(), f->result_size, save_doubles); 19861cb0ef41Sopenharmony_ci#else 19871cb0ef41Sopenharmony_ci Handle<Code> code = CodeFactory::CEntry(isolate(), 1, save_doubles); 19881cb0ef41Sopenharmony_ci#endif 19891cb0ef41Sopenharmony_ci 19901cb0ef41Sopenharmony_ci Call(code, RelocInfo::CODE_TARGET); 19911cb0ef41Sopenharmony_ci} 19921cb0ef41Sopenharmony_ci 19931cb0ef41Sopenharmony_civoid MacroAssembler::TailCallRuntime(Runtime::FunctionId fid) { 19941cb0ef41Sopenharmony_ci const Runtime::Function* function = Runtime::FunctionForId(fid); 19951cb0ef41Sopenharmony_ci DCHECK_EQ(1, function->result_size); 19961cb0ef41Sopenharmony_ci if (function->nargs >= 0) { 19971cb0ef41Sopenharmony_ci mov(r2, Operand(function->nargs)); 19981cb0ef41Sopenharmony_ci } 19991cb0ef41Sopenharmony_ci JumpToExternalReference(ExternalReference::Create(fid)); 20001cb0ef41Sopenharmony_ci} 20011cb0ef41Sopenharmony_ci 20021cb0ef41Sopenharmony_civoid MacroAssembler::JumpToExternalReference(const ExternalReference& builtin, 20031cb0ef41Sopenharmony_ci bool builtin_exit_frame) { 20041cb0ef41Sopenharmony_ci Move(r3, builtin); 20051cb0ef41Sopenharmony_ci Handle<Code> code = CodeFactory::CEntry(isolate(), 1, SaveFPRegsMode::kIgnore, 20061cb0ef41Sopenharmony_ci ArgvMode::kStack, builtin_exit_frame); 20071cb0ef41Sopenharmony_ci Jump(code, RelocInfo::CODE_TARGET); 20081cb0ef41Sopenharmony_ci} 20091cb0ef41Sopenharmony_ci 20101cb0ef41Sopenharmony_civoid MacroAssembler::JumpToOffHeapInstructionStream(Address entry) { 20111cb0ef41Sopenharmony_ci mov(kOffHeapTrampolineRegister, Operand(entry, RelocInfo::OFF_HEAP_TARGET)); 20121cb0ef41Sopenharmony_ci Jump(kOffHeapTrampolineRegister); 20131cb0ef41Sopenharmony_ci} 20141cb0ef41Sopenharmony_ci 20151cb0ef41Sopenharmony_civoid MacroAssembler::LoadWeakValue(Register out, Register in, 20161cb0ef41Sopenharmony_ci Label* target_if_cleared) { 20171cb0ef41Sopenharmony_ci CmpS32(in, Operand(kClearedWeakHeapObjectLower32)); 20181cb0ef41Sopenharmony_ci beq(target_if_cleared); 20191cb0ef41Sopenharmony_ci 20201cb0ef41Sopenharmony_ci AndP(out, in, Operand(~kWeakHeapObjectMask)); 20211cb0ef41Sopenharmony_ci} 20221cb0ef41Sopenharmony_ci 20231cb0ef41Sopenharmony_civoid MacroAssembler::EmitIncrementCounter(StatsCounter* counter, int value, 20241cb0ef41Sopenharmony_ci Register scratch1, 20251cb0ef41Sopenharmony_ci Register scratch2) { 20261cb0ef41Sopenharmony_ci DCHECK(value > 0 && is_int8(value)); 20271cb0ef41Sopenharmony_ci if (FLAG_native_code_counters && counter->Enabled()) { 20281cb0ef41Sopenharmony_ci Move(scratch2, ExternalReference::Create(counter)); 20291cb0ef41Sopenharmony_ci // @TODO(john.yan): can be optimized by asi() 20301cb0ef41Sopenharmony_ci LoadS32(scratch1, MemOperand(scratch2)); 20311cb0ef41Sopenharmony_ci AddS64(scratch1, Operand(value)); 20321cb0ef41Sopenharmony_ci StoreU32(scratch1, MemOperand(scratch2)); 20331cb0ef41Sopenharmony_ci } 20341cb0ef41Sopenharmony_ci} 20351cb0ef41Sopenharmony_ci 20361cb0ef41Sopenharmony_civoid MacroAssembler::EmitDecrementCounter(StatsCounter* counter, int value, 20371cb0ef41Sopenharmony_ci Register scratch1, 20381cb0ef41Sopenharmony_ci Register scratch2) { 20391cb0ef41Sopenharmony_ci DCHECK(value > 0 && is_int8(value)); 20401cb0ef41Sopenharmony_ci if (FLAG_native_code_counters && counter->Enabled()) { 20411cb0ef41Sopenharmony_ci Move(scratch2, ExternalReference::Create(counter)); 20421cb0ef41Sopenharmony_ci // @TODO(john.yan): can be optimized by asi() 20431cb0ef41Sopenharmony_ci LoadS32(scratch1, MemOperand(scratch2)); 20441cb0ef41Sopenharmony_ci AddS64(scratch1, Operand(-value)); 20451cb0ef41Sopenharmony_ci StoreU32(scratch1, MemOperand(scratch2)); 20461cb0ef41Sopenharmony_ci } 20471cb0ef41Sopenharmony_ci} 20481cb0ef41Sopenharmony_ci 20491cb0ef41Sopenharmony_civoid TurboAssembler::Assert(Condition cond, AbortReason reason, CRegister cr) { 20501cb0ef41Sopenharmony_ci if (FLAG_debug_code) Check(cond, reason, cr); 20511cb0ef41Sopenharmony_ci} 20521cb0ef41Sopenharmony_ci 20531cb0ef41Sopenharmony_civoid TurboAssembler::AssertUnreachable(AbortReason reason) { 20541cb0ef41Sopenharmony_ci if (FLAG_debug_code) Abort(reason); 20551cb0ef41Sopenharmony_ci} 20561cb0ef41Sopenharmony_ci 20571cb0ef41Sopenharmony_civoid TurboAssembler::Check(Condition cond, AbortReason reason, CRegister cr) { 20581cb0ef41Sopenharmony_ci Label L; 20591cb0ef41Sopenharmony_ci b(cond, &L); 20601cb0ef41Sopenharmony_ci Abort(reason); 20611cb0ef41Sopenharmony_ci // will not return here 20621cb0ef41Sopenharmony_ci bind(&L); 20631cb0ef41Sopenharmony_ci} 20641cb0ef41Sopenharmony_ci 20651cb0ef41Sopenharmony_civoid TurboAssembler::Abort(AbortReason reason) { 20661cb0ef41Sopenharmony_ci Label abort_start; 20671cb0ef41Sopenharmony_ci bind(&abort_start); 20681cb0ef41Sopenharmony_ci if (FLAG_code_comments) { 20691cb0ef41Sopenharmony_ci const char* msg = GetAbortReason(reason); 20701cb0ef41Sopenharmony_ci RecordComment("Abort message: "); 20711cb0ef41Sopenharmony_ci RecordComment(msg); 20721cb0ef41Sopenharmony_ci } 20731cb0ef41Sopenharmony_ci 20741cb0ef41Sopenharmony_ci // Avoid emitting call to builtin if requested. 20751cb0ef41Sopenharmony_ci if (trap_on_abort()) { 20761cb0ef41Sopenharmony_ci stop(); 20771cb0ef41Sopenharmony_ci return; 20781cb0ef41Sopenharmony_ci } 20791cb0ef41Sopenharmony_ci 20801cb0ef41Sopenharmony_ci if (should_abort_hard()) { 20811cb0ef41Sopenharmony_ci // We don't care if we constructed a frame. Just pretend we did. 20821cb0ef41Sopenharmony_ci FrameScope assume_frame(this, StackFrame::NO_FRAME_TYPE); 20831cb0ef41Sopenharmony_ci lgfi(r2, Operand(static_cast<int>(reason))); 20841cb0ef41Sopenharmony_ci PrepareCallCFunction(1, 0, r3); 20851cb0ef41Sopenharmony_ci Move(r3, ExternalReference::abort_with_reason()); 20861cb0ef41Sopenharmony_ci // Use Call directly to avoid any unneeded overhead. The function won't 20871cb0ef41Sopenharmony_ci // return anyway. 20881cb0ef41Sopenharmony_ci Call(r3); 20891cb0ef41Sopenharmony_ci return; 20901cb0ef41Sopenharmony_ci } 20911cb0ef41Sopenharmony_ci 20921cb0ef41Sopenharmony_ci LoadSmiLiteral(r3, Smi::FromInt(static_cast<int>(reason))); 20931cb0ef41Sopenharmony_ci 20941cb0ef41Sopenharmony_ci // Disable stub call restrictions to always allow calls to abort. 20951cb0ef41Sopenharmony_ci if (!has_frame_) { 20961cb0ef41Sopenharmony_ci // We don't actually want to generate a pile of code for this, so just 20971cb0ef41Sopenharmony_ci // claim there is a stack frame, without generating one. 20981cb0ef41Sopenharmony_ci FrameScope scope(this, StackFrame::NO_FRAME_TYPE); 20991cb0ef41Sopenharmony_ci Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); 21001cb0ef41Sopenharmony_ci } else { 21011cb0ef41Sopenharmony_ci Call(BUILTIN_CODE(isolate(), Abort), RelocInfo::CODE_TARGET); 21021cb0ef41Sopenharmony_ci } 21031cb0ef41Sopenharmony_ci // will not return here 21041cb0ef41Sopenharmony_ci} 21051cb0ef41Sopenharmony_ci 21061cb0ef41Sopenharmony_civoid TurboAssembler::LoadMap(Register destination, Register object) { 21071cb0ef41Sopenharmony_ci LoadTaggedPointerField(destination, 21081cb0ef41Sopenharmony_ci FieldMemOperand(object, HeapObject::kMapOffset)); 21091cb0ef41Sopenharmony_ci} 21101cb0ef41Sopenharmony_ci 21111cb0ef41Sopenharmony_civoid MacroAssembler::LoadNativeContextSlot(Register dst, int index) { 21121cb0ef41Sopenharmony_ci LoadMap(dst, cp); 21131cb0ef41Sopenharmony_ci LoadTaggedPointerField( 21141cb0ef41Sopenharmony_ci dst, FieldMemOperand( 21151cb0ef41Sopenharmony_ci dst, Map::kConstructorOrBackPointerOrNativeContextOffset)); 21161cb0ef41Sopenharmony_ci LoadTaggedPointerField(dst, MemOperand(dst, Context::SlotOffset(index))); 21171cb0ef41Sopenharmony_ci} 21181cb0ef41Sopenharmony_ci 21191cb0ef41Sopenharmony_civoid TurboAssembler::AssertNotSmi(Register object) { 21201cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 21211cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21221cb0ef41Sopenharmony_ci TestIfSmi(object); 21231cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmi, cr0); 21241cb0ef41Sopenharmony_ci } 21251cb0ef41Sopenharmony_ci} 21261cb0ef41Sopenharmony_ci 21271cb0ef41Sopenharmony_civoid TurboAssembler::AssertSmi(Register object) { 21281cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 21291cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21301cb0ef41Sopenharmony_ci TestIfSmi(object); 21311cb0ef41Sopenharmony_ci Check(eq, AbortReason::kOperandIsNotASmi, cr0); 21321cb0ef41Sopenharmony_ci } 21331cb0ef41Sopenharmony_ci} 21341cb0ef41Sopenharmony_ci 21351cb0ef41Sopenharmony_civoid MacroAssembler::AssertConstructor(Register object, Register scratch) { 21361cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 21371cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21381cb0ef41Sopenharmony_ci TestIfSmi(object); 21391cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmiAndNotAConstructor); 21401cb0ef41Sopenharmony_ci LoadMap(scratch, object); 21411cb0ef41Sopenharmony_ci tm(FieldMemOperand(scratch, Map::kBitFieldOffset), 21421cb0ef41Sopenharmony_ci Operand(Map::Bits1::IsConstructorBit::kMask)); 21431cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsNotAConstructor); 21441cb0ef41Sopenharmony_ci } 21451cb0ef41Sopenharmony_ci} 21461cb0ef41Sopenharmony_ci 21471cb0ef41Sopenharmony_civoid MacroAssembler::AssertFunction(Register object) { 21481cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 21491cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21501cb0ef41Sopenharmony_ci TestIfSmi(object); 21511cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmiAndNotAFunction, cr0); 21521cb0ef41Sopenharmony_ci push(object); 21531cb0ef41Sopenharmony_ci LoadMap(object, object); 21541cb0ef41Sopenharmony_ci CompareInstanceTypeRange(object, object, FIRST_JS_FUNCTION_TYPE, 21551cb0ef41Sopenharmony_ci LAST_JS_FUNCTION_TYPE); 21561cb0ef41Sopenharmony_ci pop(object); 21571cb0ef41Sopenharmony_ci Check(le, AbortReason::kOperandIsNotAFunction); 21581cb0ef41Sopenharmony_ci } 21591cb0ef41Sopenharmony_ci} 21601cb0ef41Sopenharmony_ci 21611cb0ef41Sopenharmony_civoid MacroAssembler::AssertCallableFunction(Register object) { 21621cb0ef41Sopenharmony_ci if (!FLAG_debug_code) return; 21631cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 21641cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21651cb0ef41Sopenharmony_ci TestIfSmi(object); 21661cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmiAndNotAFunction); 21671cb0ef41Sopenharmony_ci push(object); 21681cb0ef41Sopenharmony_ci LoadMap(object, object); 21691cb0ef41Sopenharmony_ci CompareInstanceTypeRange(object, object, FIRST_CALLABLE_JS_FUNCTION_TYPE, 21701cb0ef41Sopenharmony_ci LAST_CALLABLE_JS_FUNCTION_TYPE); 21711cb0ef41Sopenharmony_ci pop(object); 21721cb0ef41Sopenharmony_ci Check(le, AbortReason::kOperandIsNotACallableFunction); 21731cb0ef41Sopenharmony_ci} 21741cb0ef41Sopenharmony_ci 21751cb0ef41Sopenharmony_civoid MacroAssembler::AssertBoundFunction(Register object) { 21761cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 21771cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 21781cb0ef41Sopenharmony_ci TestIfSmi(object); 21791cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmiAndNotABoundFunction, cr0); 21801cb0ef41Sopenharmony_ci push(object); 21811cb0ef41Sopenharmony_ci CompareObjectType(object, object, object, JS_BOUND_FUNCTION_TYPE); 21821cb0ef41Sopenharmony_ci pop(object); 21831cb0ef41Sopenharmony_ci Check(eq, AbortReason::kOperandIsNotABoundFunction); 21841cb0ef41Sopenharmony_ci } 21851cb0ef41Sopenharmony_ci} 21861cb0ef41Sopenharmony_ci 21871cb0ef41Sopenharmony_civoid MacroAssembler::AssertGeneratorObject(Register object) { 21881cb0ef41Sopenharmony_ci if (!FLAG_debug_code) return; 21891cb0ef41Sopenharmony_ci TestIfSmi(object); 21901cb0ef41Sopenharmony_ci Check(ne, AbortReason::kOperandIsASmiAndNotAGeneratorObject, cr0); 21911cb0ef41Sopenharmony_ci 21921cb0ef41Sopenharmony_ci // Load map 21931cb0ef41Sopenharmony_ci Register map = object; 21941cb0ef41Sopenharmony_ci push(object); 21951cb0ef41Sopenharmony_ci LoadMap(map, object); 21961cb0ef41Sopenharmony_ci 21971cb0ef41Sopenharmony_ci // Check if JSGeneratorObject 21981cb0ef41Sopenharmony_ci Label do_check; 21991cb0ef41Sopenharmony_ci Register instance_type = object; 22001cb0ef41Sopenharmony_ci CompareInstanceType(map, instance_type, JS_GENERATOR_OBJECT_TYPE); 22011cb0ef41Sopenharmony_ci beq(&do_check); 22021cb0ef41Sopenharmony_ci 22031cb0ef41Sopenharmony_ci // Check if JSAsyncFunctionObject (See MacroAssembler::CompareInstanceType) 22041cb0ef41Sopenharmony_ci CmpS64(instance_type, Operand(JS_ASYNC_FUNCTION_OBJECT_TYPE)); 22051cb0ef41Sopenharmony_ci beq(&do_check); 22061cb0ef41Sopenharmony_ci 22071cb0ef41Sopenharmony_ci // Check if JSAsyncGeneratorObject (See MacroAssembler::CompareInstanceType) 22081cb0ef41Sopenharmony_ci CmpS64(instance_type, Operand(JS_ASYNC_GENERATOR_OBJECT_TYPE)); 22091cb0ef41Sopenharmony_ci 22101cb0ef41Sopenharmony_ci bind(&do_check); 22111cb0ef41Sopenharmony_ci // Restore generator object to register and perform assertion 22121cb0ef41Sopenharmony_ci pop(object); 22131cb0ef41Sopenharmony_ci Check(eq, AbortReason::kOperandIsNotAGeneratorObject); 22141cb0ef41Sopenharmony_ci} 22151cb0ef41Sopenharmony_ci 22161cb0ef41Sopenharmony_civoid MacroAssembler::AssertUndefinedOrAllocationSite(Register object, 22171cb0ef41Sopenharmony_ci Register scratch) { 22181cb0ef41Sopenharmony_ci if (FLAG_debug_code) { 22191cb0ef41Sopenharmony_ci Label done_checking; 22201cb0ef41Sopenharmony_ci AssertNotSmi(object); 22211cb0ef41Sopenharmony_ci CompareRoot(object, RootIndex::kUndefinedValue); 22221cb0ef41Sopenharmony_ci beq(&done_checking, Label::kNear); 22231cb0ef41Sopenharmony_ci LoadMap(scratch, object); 22241cb0ef41Sopenharmony_ci CompareInstanceType(scratch, scratch, ALLOCATION_SITE_TYPE); 22251cb0ef41Sopenharmony_ci Assert(eq, AbortReason::kExpectedUndefinedOrCell); 22261cb0ef41Sopenharmony_ci bind(&done_checking); 22271cb0ef41Sopenharmony_ci } 22281cb0ef41Sopenharmony_ci} 22291cb0ef41Sopenharmony_ci 22301cb0ef41Sopenharmony_cistatic const int kRegisterPassedArguments = 5; 22311cb0ef41Sopenharmony_ci 22321cb0ef41Sopenharmony_ciint TurboAssembler::CalculateStackPassedWords(int num_reg_arguments, 22331cb0ef41Sopenharmony_ci int num_double_arguments) { 22341cb0ef41Sopenharmony_ci int stack_passed_words = 0; 22351cb0ef41Sopenharmony_ci if (num_double_arguments > DoubleRegister::kNumRegisters) { 22361cb0ef41Sopenharmony_ci stack_passed_words += 22371cb0ef41Sopenharmony_ci 2 * (num_double_arguments - DoubleRegister::kNumRegisters); 22381cb0ef41Sopenharmony_ci } 22391cb0ef41Sopenharmony_ci // Up to five simple arguments are passed in registers r2..r6 22401cb0ef41Sopenharmony_ci if (num_reg_arguments > kRegisterPassedArguments) { 22411cb0ef41Sopenharmony_ci stack_passed_words += num_reg_arguments - kRegisterPassedArguments; 22421cb0ef41Sopenharmony_ci } 22431cb0ef41Sopenharmony_ci return stack_passed_words; 22441cb0ef41Sopenharmony_ci} 22451cb0ef41Sopenharmony_ci 22461cb0ef41Sopenharmony_civoid TurboAssembler::PrepareCallCFunction(int num_reg_arguments, 22471cb0ef41Sopenharmony_ci int num_double_arguments, 22481cb0ef41Sopenharmony_ci Register scratch) { 22491cb0ef41Sopenharmony_ci int frame_alignment = ActivationFrameAlignment(); 22501cb0ef41Sopenharmony_ci int stack_passed_arguments = 22511cb0ef41Sopenharmony_ci CalculateStackPassedWords(num_reg_arguments, num_double_arguments); 22521cb0ef41Sopenharmony_ci int stack_space = kNumRequiredStackFrameSlots; 22531cb0ef41Sopenharmony_ci if (frame_alignment > kSystemPointerSize) { 22541cb0ef41Sopenharmony_ci // Make stack end at alignment and make room for stack arguments 22551cb0ef41Sopenharmony_ci // -- preserving original value of sp. 22561cb0ef41Sopenharmony_ci mov(scratch, sp); 22571cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -(stack_passed_arguments + 1) * kSystemPointerSize)); 22581cb0ef41Sopenharmony_ci DCHECK(base::bits::IsPowerOfTwo(frame_alignment)); 22591cb0ef41Sopenharmony_ci ClearRightImm(sp, sp, 22601cb0ef41Sopenharmony_ci Operand(base::bits::WhichPowerOfTwo(frame_alignment))); 22611cb0ef41Sopenharmony_ci StoreU64(scratch, 22621cb0ef41Sopenharmony_ci MemOperand(sp, (stack_passed_arguments)*kSystemPointerSize)); 22631cb0ef41Sopenharmony_ci } else { 22641cb0ef41Sopenharmony_ci stack_space += stack_passed_arguments; 22651cb0ef41Sopenharmony_ci } 22661cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, (-stack_space) * kSystemPointerSize)); 22671cb0ef41Sopenharmony_ci} 22681cb0ef41Sopenharmony_ci 22691cb0ef41Sopenharmony_civoid TurboAssembler::PrepareCallCFunction(int num_reg_arguments, 22701cb0ef41Sopenharmony_ci Register scratch) { 22711cb0ef41Sopenharmony_ci PrepareCallCFunction(num_reg_arguments, 0, scratch); 22721cb0ef41Sopenharmony_ci} 22731cb0ef41Sopenharmony_ci 22741cb0ef41Sopenharmony_civoid TurboAssembler::MovToFloatParameter(DoubleRegister src) { Move(d0, src); } 22751cb0ef41Sopenharmony_ci 22761cb0ef41Sopenharmony_civoid TurboAssembler::MovToFloatResult(DoubleRegister src) { Move(d0, src); } 22771cb0ef41Sopenharmony_ci 22781cb0ef41Sopenharmony_civoid TurboAssembler::MovToFloatParameters(DoubleRegister src1, 22791cb0ef41Sopenharmony_ci DoubleRegister src2) { 22801cb0ef41Sopenharmony_ci if (src2 == d0) { 22811cb0ef41Sopenharmony_ci DCHECK(src1 != d2); 22821cb0ef41Sopenharmony_ci Move(d2, src2); 22831cb0ef41Sopenharmony_ci Move(d0, src1); 22841cb0ef41Sopenharmony_ci } else { 22851cb0ef41Sopenharmony_ci Move(d0, src1); 22861cb0ef41Sopenharmony_ci Move(d2, src2); 22871cb0ef41Sopenharmony_ci } 22881cb0ef41Sopenharmony_ci} 22891cb0ef41Sopenharmony_ci 22901cb0ef41Sopenharmony_civoid TurboAssembler::CallCFunction(ExternalReference function, 22911cb0ef41Sopenharmony_ci int num_reg_arguments, 22921cb0ef41Sopenharmony_ci int num_double_arguments) { 22931cb0ef41Sopenharmony_ci Move(ip, function); 22941cb0ef41Sopenharmony_ci CallCFunctionHelper(ip, num_reg_arguments, num_double_arguments); 22951cb0ef41Sopenharmony_ci} 22961cb0ef41Sopenharmony_ci 22971cb0ef41Sopenharmony_civoid TurboAssembler::CallCFunction(Register function, int num_reg_arguments, 22981cb0ef41Sopenharmony_ci int num_double_arguments) { 22991cb0ef41Sopenharmony_ci CallCFunctionHelper(function, num_reg_arguments, num_double_arguments); 23001cb0ef41Sopenharmony_ci} 23011cb0ef41Sopenharmony_ci 23021cb0ef41Sopenharmony_civoid TurboAssembler::CallCFunction(ExternalReference function, 23031cb0ef41Sopenharmony_ci int num_arguments) { 23041cb0ef41Sopenharmony_ci CallCFunction(function, num_arguments, 0); 23051cb0ef41Sopenharmony_ci} 23061cb0ef41Sopenharmony_ci 23071cb0ef41Sopenharmony_civoid TurboAssembler::CallCFunction(Register function, int num_arguments) { 23081cb0ef41Sopenharmony_ci CallCFunction(function, num_arguments, 0); 23091cb0ef41Sopenharmony_ci} 23101cb0ef41Sopenharmony_ci 23111cb0ef41Sopenharmony_civoid TurboAssembler::CallCFunctionHelper(Register function, 23121cb0ef41Sopenharmony_ci int num_reg_arguments, 23131cb0ef41Sopenharmony_ci int num_double_arguments) { 23141cb0ef41Sopenharmony_ci DCHECK_LE(num_reg_arguments + num_double_arguments, kMaxCParameters); 23151cb0ef41Sopenharmony_ci DCHECK(has_frame()); 23161cb0ef41Sopenharmony_ci 23171cb0ef41Sopenharmony_ci // Save the frame pointer and PC so that the stack layout remains iterable, 23181cb0ef41Sopenharmony_ci // even without an ExitFrame which normally exists between JS and C frames. 23191cb0ef41Sopenharmony_ci Register addr_scratch = r1; 23201cb0ef41Sopenharmony_ci // See x64 code for reasoning about how to address the isolate data fields. 23211cb0ef41Sopenharmony_ci if (root_array_available()) { 23221cb0ef41Sopenharmony_ci LoadPC(r0); 23231cb0ef41Sopenharmony_ci StoreU64(r0, MemOperand(kRootRegister, 23241cb0ef41Sopenharmony_ci IsolateData::fast_c_call_caller_pc_offset())); 23251cb0ef41Sopenharmony_ci StoreU64(fp, MemOperand(kRootRegister, 23261cb0ef41Sopenharmony_ci IsolateData::fast_c_call_caller_fp_offset())); 23271cb0ef41Sopenharmony_ci } else { 23281cb0ef41Sopenharmony_ci DCHECK_NOT_NULL(isolate()); 23291cb0ef41Sopenharmony_ci 23301cb0ef41Sopenharmony_ci Move(addr_scratch, 23311cb0ef41Sopenharmony_ci ExternalReference::fast_c_call_caller_pc_address(isolate())); 23321cb0ef41Sopenharmony_ci LoadPC(r0); 23331cb0ef41Sopenharmony_ci StoreU64(r0, MemOperand(addr_scratch)); 23341cb0ef41Sopenharmony_ci Move(addr_scratch, 23351cb0ef41Sopenharmony_ci ExternalReference::fast_c_call_caller_fp_address(isolate())); 23361cb0ef41Sopenharmony_ci StoreU64(fp, MemOperand(addr_scratch)); 23371cb0ef41Sopenharmony_ci } 23381cb0ef41Sopenharmony_ci 23391cb0ef41Sopenharmony_ci // Just call directly. The function called cannot cause a GC, or 23401cb0ef41Sopenharmony_ci // allow preemption, so the return address in the link register 23411cb0ef41Sopenharmony_ci // stays correct. 23421cb0ef41Sopenharmony_ci Register dest = function; 23431cb0ef41Sopenharmony_ci if (ABI_CALL_VIA_IP) { 23441cb0ef41Sopenharmony_ci Move(ip, function); 23451cb0ef41Sopenharmony_ci dest = ip; 23461cb0ef41Sopenharmony_ci } 23471cb0ef41Sopenharmony_ci 23481cb0ef41Sopenharmony_ci Call(dest); 23491cb0ef41Sopenharmony_ci 23501cb0ef41Sopenharmony_ci // We don't unset the PC; the FP is the source of truth. 23511cb0ef41Sopenharmony_ci Register zero_scratch = r0; 23521cb0ef41Sopenharmony_ci lghi(zero_scratch, Operand::Zero()); 23531cb0ef41Sopenharmony_ci 23541cb0ef41Sopenharmony_ci if (root_array_available()) { 23551cb0ef41Sopenharmony_ci StoreU64( 23561cb0ef41Sopenharmony_ci zero_scratch, 23571cb0ef41Sopenharmony_ci MemOperand(kRootRegister, IsolateData::fast_c_call_caller_fp_offset())); 23581cb0ef41Sopenharmony_ci } else { 23591cb0ef41Sopenharmony_ci DCHECK_NOT_NULL(isolate()); 23601cb0ef41Sopenharmony_ci Move(addr_scratch, 23611cb0ef41Sopenharmony_ci ExternalReference::fast_c_call_caller_fp_address(isolate())); 23621cb0ef41Sopenharmony_ci StoreU64(zero_scratch, MemOperand(addr_scratch)); 23631cb0ef41Sopenharmony_ci } 23641cb0ef41Sopenharmony_ci 23651cb0ef41Sopenharmony_ci int stack_passed_arguments = 23661cb0ef41Sopenharmony_ci CalculateStackPassedWords(num_reg_arguments, num_double_arguments); 23671cb0ef41Sopenharmony_ci int stack_space = kNumRequiredStackFrameSlots + stack_passed_arguments; 23681cb0ef41Sopenharmony_ci if (ActivationFrameAlignment() > kSystemPointerSize) { 23691cb0ef41Sopenharmony_ci // Load the original stack pointer (pre-alignment) from the stack 23701cb0ef41Sopenharmony_ci LoadU64(sp, MemOperand(sp, stack_space * kSystemPointerSize)); 23711cb0ef41Sopenharmony_ci } else { 23721cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, stack_space * kSystemPointerSize)); 23731cb0ef41Sopenharmony_ci } 23741cb0ef41Sopenharmony_ci} 23751cb0ef41Sopenharmony_ci 23761cb0ef41Sopenharmony_civoid TurboAssembler::CheckPageFlag( 23771cb0ef41Sopenharmony_ci Register object, 23781cb0ef41Sopenharmony_ci Register scratch, // scratch may be same register as object 23791cb0ef41Sopenharmony_ci int mask, Condition cc, Label* condition_met) { 23801cb0ef41Sopenharmony_ci DCHECK(cc == ne || cc == eq); 23811cb0ef41Sopenharmony_ci ClearRightImm(scratch, object, Operand(kPageSizeBits)); 23821cb0ef41Sopenharmony_ci 23831cb0ef41Sopenharmony_ci if (base::bits::IsPowerOfTwo(mask)) { 23841cb0ef41Sopenharmony_ci // If it's a power of two, we can use Test-Under-Mask Memory-Imm form 23851cb0ef41Sopenharmony_ci // which allows testing of a single byte in memory. 23861cb0ef41Sopenharmony_ci int32_t byte_offset = 4; 23871cb0ef41Sopenharmony_ci uint32_t shifted_mask = mask; 23881cb0ef41Sopenharmony_ci // Determine the byte offset to be tested 23891cb0ef41Sopenharmony_ci if (mask <= 0x80) { 23901cb0ef41Sopenharmony_ci byte_offset = kSystemPointerSize - 1; 23911cb0ef41Sopenharmony_ci } else if (mask < 0x8000) { 23921cb0ef41Sopenharmony_ci byte_offset = kSystemPointerSize - 2; 23931cb0ef41Sopenharmony_ci shifted_mask = mask >> 8; 23941cb0ef41Sopenharmony_ci } else if (mask < 0x800000) { 23951cb0ef41Sopenharmony_ci byte_offset = kSystemPointerSize - 3; 23961cb0ef41Sopenharmony_ci shifted_mask = mask >> 16; 23971cb0ef41Sopenharmony_ci } else { 23981cb0ef41Sopenharmony_ci byte_offset = kSystemPointerSize - 4; 23991cb0ef41Sopenharmony_ci shifted_mask = mask >> 24; 24001cb0ef41Sopenharmony_ci } 24011cb0ef41Sopenharmony_ci#if V8_TARGET_LITTLE_ENDIAN 24021cb0ef41Sopenharmony_ci // Reverse the byte_offset if emulating on little endian platform 24031cb0ef41Sopenharmony_ci byte_offset = kSystemPointerSize - byte_offset - 1; 24041cb0ef41Sopenharmony_ci#endif 24051cb0ef41Sopenharmony_ci tm(MemOperand(scratch, BasicMemoryChunk::kFlagsOffset + byte_offset), 24061cb0ef41Sopenharmony_ci Operand(shifted_mask)); 24071cb0ef41Sopenharmony_ci } else { 24081cb0ef41Sopenharmony_ci LoadU64(scratch, MemOperand(scratch, BasicMemoryChunk::kFlagsOffset)); 24091cb0ef41Sopenharmony_ci AndP(r0, scratch, Operand(mask)); 24101cb0ef41Sopenharmony_ci } 24111cb0ef41Sopenharmony_ci // Should be okay to remove rc 24121cb0ef41Sopenharmony_ci 24131cb0ef41Sopenharmony_ci if (cc == ne) { 24141cb0ef41Sopenharmony_ci bne(condition_met); 24151cb0ef41Sopenharmony_ci } 24161cb0ef41Sopenharmony_ci if (cc == eq) { 24171cb0ef41Sopenharmony_ci beq(condition_met); 24181cb0ef41Sopenharmony_ci } 24191cb0ef41Sopenharmony_ci} 24201cb0ef41Sopenharmony_ci 24211cb0ef41Sopenharmony_ciRegister GetRegisterThatIsNotOneOf(Register reg1, Register reg2, Register reg3, 24221cb0ef41Sopenharmony_ci Register reg4, Register reg5, 24231cb0ef41Sopenharmony_ci Register reg6) { 24241cb0ef41Sopenharmony_ci RegList regs = {reg1, reg2, reg3, reg4, reg5, reg6}; 24251cb0ef41Sopenharmony_ci 24261cb0ef41Sopenharmony_ci const RegisterConfiguration* config = RegisterConfiguration::Default(); 24271cb0ef41Sopenharmony_ci for (int i = 0; i < config->num_allocatable_general_registers(); ++i) { 24281cb0ef41Sopenharmony_ci int code = config->GetAllocatableGeneralCode(i); 24291cb0ef41Sopenharmony_ci Register candidate = Register::from_code(code); 24301cb0ef41Sopenharmony_ci if (regs.has(candidate)) continue; 24311cb0ef41Sopenharmony_ci return candidate; 24321cb0ef41Sopenharmony_ci } 24331cb0ef41Sopenharmony_ci UNREACHABLE(); 24341cb0ef41Sopenharmony_ci} 24351cb0ef41Sopenharmony_ci 24361cb0ef41Sopenharmony_civoid TurboAssembler::mov(Register dst, Register src) { lgr(dst, src); } 24371cb0ef41Sopenharmony_ci 24381cb0ef41Sopenharmony_civoid TurboAssembler::mov(Register dst, const Operand& src) { 24391cb0ef41Sopenharmony_ci int64_t value = 0; 24401cb0ef41Sopenharmony_ci 24411cb0ef41Sopenharmony_ci if (src.is_heap_object_request()) { 24421cb0ef41Sopenharmony_ci RequestHeapObject(src.heap_object_request()); 24431cb0ef41Sopenharmony_ci } else { 24441cb0ef41Sopenharmony_ci value = src.immediate(); 24451cb0ef41Sopenharmony_ci } 24461cb0ef41Sopenharmony_ci 24471cb0ef41Sopenharmony_ci if (src.rmode() != RelocInfo::NO_INFO) { 24481cb0ef41Sopenharmony_ci // some form of relocation needed 24491cb0ef41Sopenharmony_ci RecordRelocInfo(src.rmode(), value); 24501cb0ef41Sopenharmony_ci } 24511cb0ef41Sopenharmony_ci 24521cb0ef41Sopenharmony_ci int32_t hi_32 = static_cast<int32_t>(value >> 32); 24531cb0ef41Sopenharmony_ci int32_t lo_32 = static_cast<int32_t>(value); 24541cb0ef41Sopenharmony_ci 24551cb0ef41Sopenharmony_ci if (src.rmode() == RelocInfo::NO_INFO) { 24561cb0ef41Sopenharmony_ci if (hi_32 == 0) { 24571cb0ef41Sopenharmony_ci if (is_uint16(lo_32)) { 24581cb0ef41Sopenharmony_ci llill(dst, Operand(lo_32)); 24591cb0ef41Sopenharmony_ci return; 24601cb0ef41Sopenharmony_ci } 24611cb0ef41Sopenharmony_ci llilf(dst, Operand(lo_32)); 24621cb0ef41Sopenharmony_ci return; 24631cb0ef41Sopenharmony_ci } else if (lo_32 == 0) { 24641cb0ef41Sopenharmony_ci if (is_uint16(hi_32)) { 24651cb0ef41Sopenharmony_ci llihl(dst, Operand(hi_32)); 24661cb0ef41Sopenharmony_ci return; 24671cb0ef41Sopenharmony_ci } 24681cb0ef41Sopenharmony_ci llihf(dst, Operand(hi_32)); 24691cb0ef41Sopenharmony_ci return; 24701cb0ef41Sopenharmony_ci } else if (is_int16(value)) { 24711cb0ef41Sopenharmony_ci lghi(dst, Operand(value)); 24721cb0ef41Sopenharmony_ci return; 24731cb0ef41Sopenharmony_ci } else if (is_int32(value)) { 24741cb0ef41Sopenharmony_ci lgfi(dst, Operand(value)); 24751cb0ef41Sopenharmony_ci return; 24761cb0ef41Sopenharmony_ci } 24771cb0ef41Sopenharmony_ci } 24781cb0ef41Sopenharmony_ci 24791cb0ef41Sopenharmony_ci iihf(dst, Operand(hi_32)); 24801cb0ef41Sopenharmony_ci iilf(dst, Operand(lo_32)); 24811cb0ef41Sopenharmony_ci} 24821cb0ef41Sopenharmony_ci 24831cb0ef41Sopenharmony_civoid TurboAssembler::MulS32(Register dst, const MemOperand& src1) { 24841cb0ef41Sopenharmony_ci if (is_uint12(src1.offset())) { 24851cb0ef41Sopenharmony_ci ms(dst, src1); 24861cb0ef41Sopenharmony_ci } else if (is_int20(src1.offset())) { 24871cb0ef41Sopenharmony_ci msy(dst, src1); 24881cb0ef41Sopenharmony_ci } else { 24891cb0ef41Sopenharmony_ci UNIMPLEMENTED(); 24901cb0ef41Sopenharmony_ci } 24911cb0ef41Sopenharmony_ci} 24921cb0ef41Sopenharmony_ci 24931cb0ef41Sopenharmony_civoid TurboAssembler::MulS32(Register dst, Register src1) { msr(dst, src1); } 24941cb0ef41Sopenharmony_ci 24951cb0ef41Sopenharmony_civoid TurboAssembler::MulS32(Register dst, const Operand& src1) { 24961cb0ef41Sopenharmony_ci msfi(dst, src1); 24971cb0ef41Sopenharmony_ci} 24981cb0ef41Sopenharmony_ci 24991cb0ef41Sopenharmony_ci#define Generate_MulHigh32(instr) \ 25001cb0ef41Sopenharmony_ci { \ 25011cb0ef41Sopenharmony_ci lgfr(dst, src1); \ 25021cb0ef41Sopenharmony_ci instr(dst, src2); \ 25031cb0ef41Sopenharmony_ci srlg(dst, dst, Operand(32)); \ 25041cb0ef41Sopenharmony_ci } 25051cb0ef41Sopenharmony_ci 25061cb0ef41Sopenharmony_civoid TurboAssembler::MulHighS32(Register dst, Register src1, 25071cb0ef41Sopenharmony_ci const MemOperand& src2) { 25081cb0ef41Sopenharmony_ci Generate_MulHigh32(msgf); 25091cb0ef41Sopenharmony_ci} 25101cb0ef41Sopenharmony_ci 25111cb0ef41Sopenharmony_civoid TurboAssembler::MulHighS32(Register dst, Register src1, Register src2) { 25121cb0ef41Sopenharmony_ci if (dst == src2) { 25131cb0ef41Sopenharmony_ci std::swap(src1, src2); 25141cb0ef41Sopenharmony_ci } 25151cb0ef41Sopenharmony_ci Generate_MulHigh32(msgfr); 25161cb0ef41Sopenharmony_ci} 25171cb0ef41Sopenharmony_ci 25181cb0ef41Sopenharmony_civoid TurboAssembler::MulHighS32(Register dst, Register src1, 25191cb0ef41Sopenharmony_ci const Operand& src2) { 25201cb0ef41Sopenharmony_ci Generate_MulHigh32(msgfi); 25211cb0ef41Sopenharmony_ci} 25221cb0ef41Sopenharmony_ci 25231cb0ef41Sopenharmony_ci#undef Generate_MulHigh32 25241cb0ef41Sopenharmony_ci 25251cb0ef41Sopenharmony_ci#define Generate_MulHighU32(instr) \ 25261cb0ef41Sopenharmony_ci { \ 25271cb0ef41Sopenharmony_ci lr(r1, src1); \ 25281cb0ef41Sopenharmony_ci instr(r0, src2); \ 25291cb0ef41Sopenharmony_ci LoadU32(dst, r0); \ 25301cb0ef41Sopenharmony_ci } 25311cb0ef41Sopenharmony_ci 25321cb0ef41Sopenharmony_civoid TurboAssembler::MulHighU32(Register dst, Register src1, 25331cb0ef41Sopenharmony_ci const MemOperand& src2) { 25341cb0ef41Sopenharmony_ci Generate_MulHighU32(ml); 25351cb0ef41Sopenharmony_ci} 25361cb0ef41Sopenharmony_ci 25371cb0ef41Sopenharmony_civoid TurboAssembler::MulHighU32(Register dst, Register src1, Register src2) { 25381cb0ef41Sopenharmony_ci Generate_MulHighU32(mlr); 25391cb0ef41Sopenharmony_ci} 25401cb0ef41Sopenharmony_ci 25411cb0ef41Sopenharmony_civoid TurboAssembler::MulHighU32(Register dst, Register src1, 25421cb0ef41Sopenharmony_ci const Operand& src2) { 25431cb0ef41Sopenharmony_ci USE(dst); 25441cb0ef41Sopenharmony_ci USE(src1); 25451cb0ef41Sopenharmony_ci USE(src2); 25461cb0ef41Sopenharmony_ci UNREACHABLE(); 25471cb0ef41Sopenharmony_ci} 25481cb0ef41Sopenharmony_ci 25491cb0ef41Sopenharmony_ci#undef Generate_MulHighU32 25501cb0ef41Sopenharmony_ci 25511cb0ef41Sopenharmony_ci#define Generate_Mul32WithOverflowIfCCUnequal(instr) \ 25521cb0ef41Sopenharmony_ci { \ 25531cb0ef41Sopenharmony_ci lgfr(dst, src1); \ 25541cb0ef41Sopenharmony_ci instr(dst, src2); \ 25551cb0ef41Sopenharmony_ci cgfr(dst, dst); \ 25561cb0ef41Sopenharmony_ci } 25571cb0ef41Sopenharmony_ci 25581cb0ef41Sopenharmony_civoid TurboAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1, 25591cb0ef41Sopenharmony_ci const MemOperand& src2) { 25601cb0ef41Sopenharmony_ci Register result = dst; 25611cb0ef41Sopenharmony_ci if (src2.rx() == dst || src2.rb() == dst) dst = r0; 25621cb0ef41Sopenharmony_ci Generate_Mul32WithOverflowIfCCUnequal(msgf); 25631cb0ef41Sopenharmony_ci if (result != dst) llgfr(result, dst); 25641cb0ef41Sopenharmony_ci} 25651cb0ef41Sopenharmony_ci 25661cb0ef41Sopenharmony_civoid TurboAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1, 25671cb0ef41Sopenharmony_ci Register src2) { 25681cb0ef41Sopenharmony_ci if (dst == src2) { 25691cb0ef41Sopenharmony_ci std::swap(src1, src2); 25701cb0ef41Sopenharmony_ci } 25711cb0ef41Sopenharmony_ci Generate_Mul32WithOverflowIfCCUnequal(msgfr); 25721cb0ef41Sopenharmony_ci} 25731cb0ef41Sopenharmony_ci 25741cb0ef41Sopenharmony_civoid TurboAssembler::Mul32WithOverflowIfCCUnequal(Register dst, Register src1, 25751cb0ef41Sopenharmony_ci const Operand& src2) { 25761cb0ef41Sopenharmony_ci Generate_Mul32WithOverflowIfCCUnequal(msgfi); 25771cb0ef41Sopenharmony_ci} 25781cb0ef41Sopenharmony_ci 25791cb0ef41Sopenharmony_ci#undef Generate_Mul32WithOverflowIfCCUnequal 25801cb0ef41Sopenharmony_ci 25811cb0ef41Sopenharmony_ci#define Generate_Div32(instr) \ 25821cb0ef41Sopenharmony_ci { \ 25831cb0ef41Sopenharmony_ci lgfr(r1, src1); \ 25841cb0ef41Sopenharmony_ci instr(r0, src2); \ 25851cb0ef41Sopenharmony_ci LoadU32(dst, r1); \ 25861cb0ef41Sopenharmony_ci } 25871cb0ef41Sopenharmony_ci 25881cb0ef41Sopenharmony_civoid TurboAssembler::DivS32(Register dst, Register src1, 25891cb0ef41Sopenharmony_ci const MemOperand& src2) { 25901cb0ef41Sopenharmony_ci Generate_Div32(dsgf); 25911cb0ef41Sopenharmony_ci} 25921cb0ef41Sopenharmony_ci 25931cb0ef41Sopenharmony_civoid TurboAssembler::DivS32(Register dst, Register src1, Register src2) { 25941cb0ef41Sopenharmony_ci Generate_Div32(dsgfr); 25951cb0ef41Sopenharmony_ci} 25961cb0ef41Sopenharmony_ci 25971cb0ef41Sopenharmony_ci#undef Generate_Div32 25981cb0ef41Sopenharmony_ci 25991cb0ef41Sopenharmony_ci#define Generate_DivU32(instr) \ 26001cb0ef41Sopenharmony_ci { \ 26011cb0ef41Sopenharmony_ci lr(r0, src1); \ 26021cb0ef41Sopenharmony_ci srdl(r0, Operand(32)); \ 26031cb0ef41Sopenharmony_ci instr(r0, src2); \ 26041cb0ef41Sopenharmony_ci LoadU32(dst, r1); \ 26051cb0ef41Sopenharmony_ci } 26061cb0ef41Sopenharmony_ci 26071cb0ef41Sopenharmony_civoid TurboAssembler::DivU32(Register dst, Register src1, 26081cb0ef41Sopenharmony_ci const MemOperand& src2) { 26091cb0ef41Sopenharmony_ci Generate_DivU32(dl); 26101cb0ef41Sopenharmony_ci} 26111cb0ef41Sopenharmony_ci 26121cb0ef41Sopenharmony_civoid TurboAssembler::DivU32(Register dst, Register src1, Register src2) { 26131cb0ef41Sopenharmony_ci Generate_DivU32(dlr); 26141cb0ef41Sopenharmony_ci} 26151cb0ef41Sopenharmony_ci 26161cb0ef41Sopenharmony_ci#undef Generate_DivU32 26171cb0ef41Sopenharmony_ci 26181cb0ef41Sopenharmony_ci#define Generate_Div64(instr) \ 26191cb0ef41Sopenharmony_ci { \ 26201cb0ef41Sopenharmony_ci lgr(r1, src1); \ 26211cb0ef41Sopenharmony_ci instr(r0, src2); \ 26221cb0ef41Sopenharmony_ci lgr(dst, r1); \ 26231cb0ef41Sopenharmony_ci } 26241cb0ef41Sopenharmony_ci 26251cb0ef41Sopenharmony_civoid TurboAssembler::DivS64(Register dst, Register src1, 26261cb0ef41Sopenharmony_ci const MemOperand& src2) { 26271cb0ef41Sopenharmony_ci Generate_Div64(dsg); 26281cb0ef41Sopenharmony_ci} 26291cb0ef41Sopenharmony_ci 26301cb0ef41Sopenharmony_civoid TurboAssembler::DivS64(Register dst, Register src1, Register src2) { 26311cb0ef41Sopenharmony_ci Generate_Div64(dsgr); 26321cb0ef41Sopenharmony_ci} 26331cb0ef41Sopenharmony_ci 26341cb0ef41Sopenharmony_ci#undef Generate_Div64 26351cb0ef41Sopenharmony_ci 26361cb0ef41Sopenharmony_ci#define Generate_DivU64(instr) \ 26371cb0ef41Sopenharmony_ci { \ 26381cb0ef41Sopenharmony_ci lgr(r1, src1); \ 26391cb0ef41Sopenharmony_ci lghi(r0, Operand::Zero()); \ 26401cb0ef41Sopenharmony_ci instr(r0, src2); \ 26411cb0ef41Sopenharmony_ci lgr(dst, r1); \ 26421cb0ef41Sopenharmony_ci } 26431cb0ef41Sopenharmony_ci 26441cb0ef41Sopenharmony_civoid TurboAssembler::DivU64(Register dst, Register src1, 26451cb0ef41Sopenharmony_ci const MemOperand& src2) { 26461cb0ef41Sopenharmony_ci Generate_DivU64(dlg); 26471cb0ef41Sopenharmony_ci} 26481cb0ef41Sopenharmony_ci 26491cb0ef41Sopenharmony_civoid TurboAssembler::DivU64(Register dst, Register src1, Register src2) { 26501cb0ef41Sopenharmony_ci Generate_DivU64(dlgr); 26511cb0ef41Sopenharmony_ci} 26521cb0ef41Sopenharmony_ci 26531cb0ef41Sopenharmony_ci#undef Generate_DivU64 26541cb0ef41Sopenharmony_ci 26551cb0ef41Sopenharmony_ci#define Generate_Mod32(instr) \ 26561cb0ef41Sopenharmony_ci { \ 26571cb0ef41Sopenharmony_ci lgfr(r1, src1); \ 26581cb0ef41Sopenharmony_ci instr(r0, src2); \ 26591cb0ef41Sopenharmony_ci LoadU32(dst, r0); \ 26601cb0ef41Sopenharmony_ci } 26611cb0ef41Sopenharmony_ci 26621cb0ef41Sopenharmony_civoid TurboAssembler::ModS32(Register dst, Register src1, 26631cb0ef41Sopenharmony_ci const MemOperand& src2) { 26641cb0ef41Sopenharmony_ci Generate_Mod32(dsgf); 26651cb0ef41Sopenharmony_ci} 26661cb0ef41Sopenharmony_ci 26671cb0ef41Sopenharmony_civoid TurboAssembler::ModS32(Register dst, Register src1, Register src2) { 26681cb0ef41Sopenharmony_ci Generate_Mod32(dsgfr); 26691cb0ef41Sopenharmony_ci} 26701cb0ef41Sopenharmony_ci 26711cb0ef41Sopenharmony_ci#undef Generate_Mod32 26721cb0ef41Sopenharmony_ci 26731cb0ef41Sopenharmony_ci#define Generate_ModU32(instr) \ 26741cb0ef41Sopenharmony_ci { \ 26751cb0ef41Sopenharmony_ci lr(r0, src1); \ 26761cb0ef41Sopenharmony_ci srdl(r0, Operand(32)); \ 26771cb0ef41Sopenharmony_ci instr(r0, src2); \ 26781cb0ef41Sopenharmony_ci LoadU32(dst, r0); \ 26791cb0ef41Sopenharmony_ci } 26801cb0ef41Sopenharmony_ci 26811cb0ef41Sopenharmony_civoid TurboAssembler::ModU32(Register dst, Register src1, 26821cb0ef41Sopenharmony_ci const MemOperand& src2) { 26831cb0ef41Sopenharmony_ci Generate_ModU32(dl); 26841cb0ef41Sopenharmony_ci} 26851cb0ef41Sopenharmony_ci 26861cb0ef41Sopenharmony_civoid TurboAssembler::ModU32(Register dst, Register src1, Register src2) { 26871cb0ef41Sopenharmony_ci Generate_ModU32(dlr); 26881cb0ef41Sopenharmony_ci} 26891cb0ef41Sopenharmony_ci 26901cb0ef41Sopenharmony_ci#undef Generate_ModU32 26911cb0ef41Sopenharmony_ci 26921cb0ef41Sopenharmony_ci#define Generate_Mod64(instr) \ 26931cb0ef41Sopenharmony_ci { \ 26941cb0ef41Sopenharmony_ci lgr(r1, src1); \ 26951cb0ef41Sopenharmony_ci instr(r0, src2); \ 26961cb0ef41Sopenharmony_ci lgr(dst, r0); \ 26971cb0ef41Sopenharmony_ci } 26981cb0ef41Sopenharmony_ci 26991cb0ef41Sopenharmony_civoid TurboAssembler::ModS64(Register dst, Register src1, 27001cb0ef41Sopenharmony_ci const MemOperand& src2) { 27011cb0ef41Sopenharmony_ci Generate_Mod64(dsg); 27021cb0ef41Sopenharmony_ci} 27031cb0ef41Sopenharmony_ci 27041cb0ef41Sopenharmony_civoid TurboAssembler::ModS64(Register dst, Register src1, Register src2) { 27051cb0ef41Sopenharmony_ci Generate_Mod64(dsgr); 27061cb0ef41Sopenharmony_ci} 27071cb0ef41Sopenharmony_ci 27081cb0ef41Sopenharmony_ci#undef Generate_Mod64 27091cb0ef41Sopenharmony_ci 27101cb0ef41Sopenharmony_ci#define Generate_ModU64(instr) \ 27111cb0ef41Sopenharmony_ci { \ 27121cb0ef41Sopenharmony_ci lgr(r1, src1); \ 27131cb0ef41Sopenharmony_ci lghi(r0, Operand::Zero()); \ 27141cb0ef41Sopenharmony_ci instr(r0, src2); \ 27151cb0ef41Sopenharmony_ci lgr(dst, r0); \ 27161cb0ef41Sopenharmony_ci } 27171cb0ef41Sopenharmony_ci 27181cb0ef41Sopenharmony_civoid TurboAssembler::ModU64(Register dst, Register src1, 27191cb0ef41Sopenharmony_ci const MemOperand& src2) { 27201cb0ef41Sopenharmony_ci Generate_ModU64(dlg); 27211cb0ef41Sopenharmony_ci} 27221cb0ef41Sopenharmony_ci 27231cb0ef41Sopenharmony_civoid TurboAssembler::ModU64(Register dst, Register src1, Register src2) { 27241cb0ef41Sopenharmony_ci Generate_ModU64(dlgr); 27251cb0ef41Sopenharmony_ci} 27261cb0ef41Sopenharmony_ci 27271cb0ef41Sopenharmony_ci#undef Generate_ModU64 27281cb0ef41Sopenharmony_ci 27291cb0ef41Sopenharmony_civoid TurboAssembler::MulS64(Register dst, const Operand& opnd) { 27301cb0ef41Sopenharmony_ci msgfi(dst, opnd); 27311cb0ef41Sopenharmony_ci} 27321cb0ef41Sopenharmony_ci 27331cb0ef41Sopenharmony_civoid TurboAssembler::MulS64(Register dst, Register src) { msgr(dst, src); } 27341cb0ef41Sopenharmony_ci 27351cb0ef41Sopenharmony_civoid TurboAssembler::MulS64(Register dst, const MemOperand& opnd) { 27361cb0ef41Sopenharmony_ci msg(dst, opnd); 27371cb0ef41Sopenharmony_ci} 27381cb0ef41Sopenharmony_ci 27391cb0ef41Sopenharmony_civoid TurboAssembler::Sqrt(DoubleRegister result, DoubleRegister input) { 27401cb0ef41Sopenharmony_ci sqdbr(result, input); 27411cb0ef41Sopenharmony_ci} 27421cb0ef41Sopenharmony_civoid TurboAssembler::Sqrt(DoubleRegister result, const MemOperand& input) { 27431cb0ef41Sopenharmony_ci if (is_uint12(input.offset())) { 27441cb0ef41Sopenharmony_ci sqdb(result, input); 27451cb0ef41Sopenharmony_ci } else { 27461cb0ef41Sopenharmony_ci ldy(result, input); 27471cb0ef41Sopenharmony_ci sqdbr(result, result); 27481cb0ef41Sopenharmony_ci } 27491cb0ef41Sopenharmony_ci} 27501cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 27511cb0ef41Sopenharmony_ci// Add Instructions 27521cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 27531cb0ef41Sopenharmony_ci 27541cb0ef41Sopenharmony_ci// Add 32-bit (Register dst = Register dst + Immediate opnd) 27551cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, const Operand& opnd) { 27561cb0ef41Sopenharmony_ci if (is_int16(opnd.immediate())) 27571cb0ef41Sopenharmony_ci ahi(dst, opnd); 27581cb0ef41Sopenharmony_ci else 27591cb0ef41Sopenharmony_ci afi(dst, opnd); 27601cb0ef41Sopenharmony_ci} 27611cb0ef41Sopenharmony_ci 27621cb0ef41Sopenharmony_ci// Add Pointer Size (Register dst = Register dst + Immediate opnd) 27631cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, const Operand& opnd) { 27641cb0ef41Sopenharmony_ci if (is_int16(opnd.immediate())) 27651cb0ef41Sopenharmony_ci aghi(dst, opnd); 27661cb0ef41Sopenharmony_ci else 27671cb0ef41Sopenharmony_ci agfi(dst, opnd); 27681cb0ef41Sopenharmony_ci} 27691cb0ef41Sopenharmony_ci 27701cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, Register src, int32_t opnd) { 27711cb0ef41Sopenharmony_ci AddS32(dst, src, Operand(opnd)); 27721cb0ef41Sopenharmony_ci} 27731cb0ef41Sopenharmony_ci 27741cb0ef41Sopenharmony_ci// Add 32-bit (Register dst = Register src + Immediate opnd) 27751cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, Register src, const Operand& opnd) { 27761cb0ef41Sopenharmony_ci if (dst != src) { 27771cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS) && is_int16(opnd.immediate())) { 27781cb0ef41Sopenharmony_ci ahik(dst, src, opnd); 27791cb0ef41Sopenharmony_ci return; 27801cb0ef41Sopenharmony_ci } 27811cb0ef41Sopenharmony_ci lr(dst, src); 27821cb0ef41Sopenharmony_ci } 27831cb0ef41Sopenharmony_ci AddS32(dst, opnd); 27841cb0ef41Sopenharmony_ci} 27851cb0ef41Sopenharmony_ci 27861cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, Register src, int32_t opnd) { 27871cb0ef41Sopenharmony_ci AddS64(dst, src, Operand(opnd)); 27881cb0ef41Sopenharmony_ci} 27891cb0ef41Sopenharmony_ci 27901cb0ef41Sopenharmony_ci// Add Pointer Size (Register dst = Register src + Immediate opnd) 27911cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, Register src, const Operand& opnd) { 27921cb0ef41Sopenharmony_ci if (dst != src) { 27931cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS) && is_int16(opnd.immediate())) { 27941cb0ef41Sopenharmony_ci aghik(dst, src, opnd); 27951cb0ef41Sopenharmony_ci return; 27961cb0ef41Sopenharmony_ci } 27971cb0ef41Sopenharmony_ci mov(dst, src); 27981cb0ef41Sopenharmony_ci } 27991cb0ef41Sopenharmony_ci AddS64(dst, opnd); 28001cb0ef41Sopenharmony_ci} 28011cb0ef41Sopenharmony_ci 28021cb0ef41Sopenharmony_ci// Add 32-bit (Register dst = Register dst + Register src) 28031cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, Register src) { ar(dst, src); } 28041cb0ef41Sopenharmony_ci 28051cb0ef41Sopenharmony_ci// Add Pointer Size (Register dst = Register dst + Register src) 28061cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, Register src) { agr(dst, src); } 28071cb0ef41Sopenharmony_ci 28081cb0ef41Sopenharmony_ci// Add 32-bit (Register dst = Register src1 + Register src2) 28091cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, Register src1, Register src2) { 28101cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 28111cb0ef41Sopenharmony_ci // We prefer to generate AR/AGR, over the non clobbering ARK/AGRK 28121cb0ef41Sopenharmony_ci // as AR is a smaller instruction 28131cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 28141cb0ef41Sopenharmony_ci ark(dst, src1, src2); 28151cb0ef41Sopenharmony_ci return; 28161cb0ef41Sopenharmony_ci } else { 28171cb0ef41Sopenharmony_ci lr(dst, src1); 28181cb0ef41Sopenharmony_ci } 28191cb0ef41Sopenharmony_ci } else if (dst == src2) { 28201cb0ef41Sopenharmony_ci src2 = src1; 28211cb0ef41Sopenharmony_ci } 28221cb0ef41Sopenharmony_ci ar(dst, src2); 28231cb0ef41Sopenharmony_ci} 28241cb0ef41Sopenharmony_ci 28251cb0ef41Sopenharmony_ci// Add Pointer Size (Register dst = Register src1 + Register src2) 28261cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, Register src1, Register src2) { 28271cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 28281cb0ef41Sopenharmony_ci // We prefer to generate AR/AGR, over the non clobbering ARK/AGRK 28291cb0ef41Sopenharmony_ci // as AR is a smaller instruction 28301cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 28311cb0ef41Sopenharmony_ci agrk(dst, src1, src2); 28321cb0ef41Sopenharmony_ci return; 28331cb0ef41Sopenharmony_ci } else { 28341cb0ef41Sopenharmony_ci mov(dst, src1); 28351cb0ef41Sopenharmony_ci } 28361cb0ef41Sopenharmony_ci } else if (dst == src2) { 28371cb0ef41Sopenharmony_ci src2 = src1; 28381cb0ef41Sopenharmony_ci } 28391cb0ef41Sopenharmony_ci agr(dst, src2); 28401cb0ef41Sopenharmony_ci} 28411cb0ef41Sopenharmony_ci 28421cb0ef41Sopenharmony_ci// Add 32-bit (Register-Memory) 28431cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(Register dst, const MemOperand& opnd) { 28441cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 28451cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 28461cb0ef41Sopenharmony_ci a(dst, opnd); 28471cb0ef41Sopenharmony_ci else 28481cb0ef41Sopenharmony_ci ay(dst, opnd); 28491cb0ef41Sopenharmony_ci} 28501cb0ef41Sopenharmony_ci 28511cb0ef41Sopenharmony_ci// Add Pointer Size (Register-Memory) 28521cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(Register dst, const MemOperand& opnd) { 28531cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 28541cb0ef41Sopenharmony_ci ag(dst, opnd); 28551cb0ef41Sopenharmony_ci} 28561cb0ef41Sopenharmony_ci 28571cb0ef41Sopenharmony_ci// Add 32-bit (Memory - Immediate) 28581cb0ef41Sopenharmony_civoid TurboAssembler::AddS32(const MemOperand& opnd, const Operand& imm) { 28591cb0ef41Sopenharmony_ci DCHECK(is_int8(imm.immediate())); 28601cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 28611cb0ef41Sopenharmony_ci DCHECK(CpuFeatures::IsSupported(GENERAL_INSTR_EXT)); 28621cb0ef41Sopenharmony_ci asi(opnd, imm); 28631cb0ef41Sopenharmony_ci} 28641cb0ef41Sopenharmony_ci 28651cb0ef41Sopenharmony_ci// Add Pointer-sized (Memory - Immediate) 28661cb0ef41Sopenharmony_civoid TurboAssembler::AddS64(const MemOperand& opnd, const Operand& imm) { 28671cb0ef41Sopenharmony_ci DCHECK(is_int8(imm.immediate())); 28681cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 28691cb0ef41Sopenharmony_ci DCHECK(CpuFeatures::IsSupported(GENERAL_INSTR_EXT)); 28701cb0ef41Sopenharmony_ci agsi(opnd, imm); 28711cb0ef41Sopenharmony_ci} 28721cb0ef41Sopenharmony_ci 28731cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 28741cb0ef41Sopenharmony_ci// Add Logical Instructions 28751cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 28761cb0ef41Sopenharmony_ci 28771cb0ef41Sopenharmony_ci// Add Logical 32-bit (Register dst = Register src1 + Register src2) 28781cb0ef41Sopenharmony_civoid TurboAssembler::AddU32(Register dst, Register src1, Register src2) { 28791cb0ef41Sopenharmony_ci if (dst != src2 && dst != src1) { 28801cb0ef41Sopenharmony_ci lr(dst, src1); 28811cb0ef41Sopenharmony_ci alr(dst, src2); 28821cb0ef41Sopenharmony_ci } else if (dst != src2) { 28831cb0ef41Sopenharmony_ci // dst == src1 28841cb0ef41Sopenharmony_ci DCHECK(dst == src1); 28851cb0ef41Sopenharmony_ci alr(dst, src2); 28861cb0ef41Sopenharmony_ci } else { 28871cb0ef41Sopenharmony_ci // dst == src2 28881cb0ef41Sopenharmony_ci DCHECK(dst == src2); 28891cb0ef41Sopenharmony_ci alr(dst, src1); 28901cb0ef41Sopenharmony_ci } 28911cb0ef41Sopenharmony_ci} 28921cb0ef41Sopenharmony_ci 28931cb0ef41Sopenharmony_ci// Add Logical 32-bit (Register dst = Register dst + Immediate opnd) 28941cb0ef41Sopenharmony_civoid TurboAssembler::AddU32(Register dst, const Operand& imm) { 28951cb0ef41Sopenharmony_ci alfi(dst, imm); 28961cb0ef41Sopenharmony_ci} 28971cb0ef41Sopenharmony_ci 28981cb0ef41Sopenharmony_ci// Add Logical Pointer Size (Register dst = Register dst + Immediate opnd) 28991cb0ef41Sopenharmony_civoid TurboAssembler::AddU64(Register dst, const Operand& imm) { 29001cb0ef41Sopenharmony_ci algfi(dst, imm); 29011cb0ef41Sopenharmony_ci} 29021cb0ef41Sopenharmony_ci 29031cb0ef41Sopenharmony_civoid TurboAssembler::AddU64(Register dst, Register src1, Register src2) { 29041cb0ef41Sopenharmony_ci if (dst != src2 && dst != src1) { 29051cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 29061cb0ef41Sopenharmony_ci algrk(dst, src1, src2); 29071cb0ef41Sopenharmony_ci } else { 29081cb0ef41Sopenharmony_ci lgr(dst, src1); 29091cb0ef41Sopenharmony_ci algr(dst, src2); 29101cb0ef41Sopenharmony_ci } 29111cb0ef41Sopenharmony_ci } else if (dst != src2) { 29121cb0ef41Sopenharmony_ci // dst == src1 29131cb0ef41Sopenharmony_ci DCHECK(dst == src1); 29141cb0ef41Sopenharmony_ci algr(dst, src2); 29151cb0ef41Sopenharmony_ci } else { 29161cb0ef41Sopenharmony_ci // dst == src2 29171cb0ef41Sopenharmony_ci DCHECK(dst == src2); 29181cb0ef41Sopenharmony_ci algr(dst, src1); 29191cb0ef41Sopenharmony_ci } 29201cb0ef41Sopenharmony_ci} 29211cb0ef41Sopenharmony_ci 29221cb0ef41Sopenharmony_ci// Add Logical 32-bit (Register-Memory) 29231cb0ef41Sopenharmony_civoid TurboAssembler::AddU32(Register dst, const MemOperand& opnd) { 29241cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 29251cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 29261cb0ef41Sopenharmony_ci al_z(dst, opnd); 29271cb0ef41Sopenharmony_ci else 29281cb0ef41Sopenharmony_ci aly(dst, opnd); 29291cb0ef41Sopenharmony_ci} 29301cb0ef41Sopenharmony_ci 29311cb0ef41Sopenharmony_ci// Add Logical Pointer Size (Register-Memory) 29321cb0ef41Sopenharmony_civoid TurboAssembler::AddU64(Register dst, const MemOperand& opnd) { 29331cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 29341cb0ef41Sopenharmony_ci alg(dst, opnd); 29351cb0ef41Sopenharmony_ci} 29361cb0ef41Sopenharmony_ci 29371cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 29381cb0ef41Sopenharmony_ci// Subtract Instructions 29391cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 29401cb0ef41Sopenharmony_ci 29411cb0ef41Sopenharmony_ci// Subtract Logical 32-bit (Register dst = Register src1 - Register src2) 29421cb0ef41Sopenharmony_civoid TurboAssembler::SubU32(Register dst, Register src1, Register src2) { 29431cb0ef41Sopenharmony_ci if (dst != src2 && dst != src1) { 29441cb0ef41Sopenharmony_ci lr(dst, src1); 29451cb0ef41Sopenharmony_ci slr(dst, src2); 29461cb0ef41Sopenharmony_ci } else if (dst != src2) { 29471cb0ef41Sopenharmony_ci // dst == src1 29481cb0ef41Sopenharmony_ci DCHECK(dst == src1); 29491cb0ef41Sopenharmony_ci slr(dst, src2); 29501cb0ef41Sopenharmony_ci } else { 29511cb0ef41Sopenharmony_ci // dst == src2 29521cb0ef41Sopenharmony_ci DCHECK(dst == src2); 29531cb0ef41Sopenharmony_ci lr(r0, dst); 29541cb0ef41Sopenharmony_ci SubU32(dst, src1, r0); 29551cb0ef41Sopenharmony_ci } 29561cb0ef41Sopenharmony_ci} 29571cb0ef41Sopenharmony_ci 29581cb0ef41Sopenharmony_ci// Subtract 32-bit (Register dst = Register dst - Immediate opnd) 29591cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, const Operand& imm) { 29601cb0ef41Sopenharmony_ci AddS32(dst, Operand(-(imm.immediate()))); 29611cb0ef41Sopenharmony_ci} 29621cb0ef41Sopenharmony_ci 29631cb0ef41Sopenharmony_ci// Subtract Pointer Size (Register dst = Register dst - Immediate opnd) 29641cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, const Operand& imm) { 29651cb0ef41Sopenharmony_ci AddS64(dst, Operand(-(imm.immediate()))); 29661cb0ef41Sopenharmony_ci} 29671cb0ef41Sopenharmony_ci 29681cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, Register src, int32_t imm) { 29691cb0ef41Sopenharmony_ci SubS32(dst, src, Operand(imm)); 29701cb0ef41Sopenharmony_ci} 29711cb0ef41Sopenharmony_ci 29721cb0ef41Sopenharmony_ci// Subtract 32-bit (Register dst = Register src - Immediate opnd) 29731cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, Register src, const Operand& imm) { 29741cb0ef41Sopenharmony_ci AddS32(dst, src, Operand(-(imm.immediate()))); 29751cb0ef41Sopenharmony_ci} 29761cb0ef41Sopenharmony_ci 29771cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, Register src, int32_t imm) { 29781cb0ef41Sopenharmony_ci SubS64(dst, src, Operand(imm)); 29791cb0ef41Sopenharmony_ci} 29801cb0ef41Sopenharmony_ci 29811cb0ef41Sopenharmony_ci// Subtract Pointer Sized (Register dst = Register src - Immediate opnd) 29821cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, Register src, const Operand& imm) { 29831cb0ef41Sopenharmony_ci AddS64(dst, src, Operand(-(imm.immediate()))); 29841cb0ef41Sopenharmony_ci} 29851cb0ef41Sopenharmony_ci 29861cb0ef41Sopenharmony_ci// Subtract 32-bit (Register dst = Register dst - Register src) 29871cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, Register src) { sr(dst, src); } 29881cb0ef41Sopenharmony_ci 29891cb0ef41Sopenharmony_ci// Subtract Pointer Size (Register dst = Register dst - Register src) 29901cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, Register src) { sgr(dst, src); } 29911cb0ef41Sopenharmony_ci 29921cb0ef41Sopenharmony_ci// Subtract 32-bit (Register = Register - Register) 29931cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, Register src1, Register src2) { 29941cb0ef41Sopenharmony_ci // Use non-clobbering version if possible 29951cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 29961cb0ef41Sopenharmony_ci srk(dst, src1, src2); 29971cb0ef41Sopenharmony_ci return; 29981cb0ef41Sopenharmony_ci } 29991cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) lr(dst, src1); 30001cb0ef41Sopenharmony_ci // In scenario where we have dst = src - dst, we need to swap and negate 30011cb0ef41Sopenharmony_ci if (dst != src1 && dst == src2) { 30021cb0ef41Sopenharmony_ci Label done; 30031cb0ef41Sopenharmony_ci lcr(dst, dst); // dst = -dst 30041cb0ef41Sopenharmony_ci b(overflow, &done); 30051cb0ef41Sopenharmony_ci ar(dst, src1); // dst = dst + src 30061cb0ef41Sopenharmony_ci bind(&done); 30071cb0ef41Sopenharmony_ci } else { 30081cb0ef41Sopenharmony_ci sr(dst, src2); 30091cb0ef41Sopenharmony_ci } 30101cb0ef41Sopenharmony_ci} 30111cb0ef41Sopenharmony_ci 30121cb0ef41Sopenharmony_ci// Subtract Pointer Sized (Register = Register - Register) 30131cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, Register src1, Register src2) { 30141cb0ef41Sopenharmony_ci // Use non-clobbering version if possible 30151cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 30161cb0ef41Sopenharmony_ci sgrk(dst, src1, src2); 30171cb0ef41Sopenharmony_ci return; 30181cb0ef41Sopenharmony_ci } 30191cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) mov(dst, src1); 30201cb0ef41Sopenharmony_ci // In scenario where we have dst = src - dst, we need to swap and negate 30211cb0ef41Sopenharmony_ci if (dst != src1 && dst == src2) { 30221cb0ef41Sopenharmony_ci Label done; 30231cb0ef41Sopenharmony_ci lcgr(dst, dst); // dst = -dst 30241cb0ef41Sopenharmony_ci b(overflow, &done); 30251cb0ef41Sopenharmony_ci AddS64(dst, src1); // dst = dst + src 30261cb0ef41Sopenharmony_ci bind(&done); 30271cb0ef41Sopenharmony_ci } else { 30281cb0ef41Sopenharmony_ci SubS64(dst, src2); 30291cb0ef41Sopenharmony_ci } 30301cb0ef41Sopenharmony_ci} 30311cb0ef41Sopenharmony_ci 30321cb0ef41Sopenharmony_ci// Subtract 32-bit (Register-Memory) 30331cb0ef41Sopenharmony_civoid TurboAssembler::SubS32(Register dst, const MemOperand& opnd) { 30341cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 30351cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 30361cb0ef41Sopenharmony_ci s(dst, opnd); 30371cb0ef41Sopenharmony_ci else 30381cb0ef41Sopenharmony_ci sy(dst, opnd); 30391cb0ef41Sopenharmony_ci} 30401cb0ef41Sopenharmony_ci 30411cb0ef41Sopenharmony_ci// Subtract Pointer Sized (Register - Memory) 30421cb0ef41Sopenharmony_civoid TurboAssembler::SubS64(Register dst, const MemOperand& opnd) { 30431cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 30441cb0ef41Sopenharmony_ci sg(dst, opnd); 30451cb0ef41Sopenharmony_ci#else 30461cb0ef41Sopenharmony_ci SubS32(dst, opnd); 30471cb0ef41Sopenharmony_ci#endif 30481cb0ef41Sopenharmony_ci} 30491cb0ef41Sopenharmony_ci 30501cb0ef41Sopenharmony_civoid TurboAssembler::MovIntToFloat(DoubleRegister dst, Register src) { 30511cb0ef41Sopenharmony_ci sllg(r0, src, Operand(32)); 30521cb0ef41Sopenharmony_ci ldgr(dst, r0); 30531cb0ef41Sopenharmony_ci} 30541cb0ef41Sopenharmony_ci 30551cb0ef41Sopenharmony_civoid TurboAssembler::MovFloatToInt(Register dst, DoubleRegister src) { 30561cb0ef41Sopenharmony_ci lgdr(dst, src); 30571cb0ef41Sopenharmony_ci srlg(dst, dst, Operand(32)); 30581cb0ef41Sopenharmony_ci} 30591cb0ef41Sopenharmony_ci 30601cb0ef41Sopenharmony_ci// Load And Subtract 32-bit (similar to laa/lan/lao/lax) 30611cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndSub32(Register dst, Register src, 30621cb0ef41Sopenharmony_ci const MemOperand& opnd) { 30631cb0ef41Sopenharmony_ci lcr(dst, src); 30641cb0ef41Sopenharmony_ci laa(dst, dst, opnd); 30651cb0ef41Sopenharmony_ci} 30661cb0ef41Sopenharmony_ci 30671cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndSub64(Register dst, Register src, 30681cb0ef41Sopenharmony_ci const MemOperand& opnd) { 30691cb0ef41Sopenharmony_ci lcgr(dst, src); 30701cb0ef41Sopenharmony_ci laag(dst, dst, opnd); 30711cb0ef41Sopenharmony_ci} 30721cb0ef41Sopenharmony_ci 30731cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 30741cb0ef41Sopenharmony_ci// Subtract Logical Instructions 30751cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 30761cb0ef41Sopenharmony_ci 30771cb0ef41Sopenharmony_ci// Subtract Logical 32-bit (Register - Memory) 30781cb0ef41Sopenharmony_civoid TurboAssembler::SubU32(Register dst, const MemOperand& opnd) { 30791cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 30801cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 30811cb0ef41Sopenharmony_ci sl(dst, opnd); 30821cb0ef41Sopenharmony_ci else 30831cb0ef41Sopenharmony_ci sly(dst, opnd); 30841cb0ef41Sopenharmony_ci} 30851cb0ef41Sopenharmony_ci 30861cb0ef41Sopenharmony_ci// Subtract Logical Pointer Sized (Register - Memory) 30871cb0ef41Sopenharmony_civoid TurboAssembler::SubU64(Register dst, const MemOperand& opnd) { 30881cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 30891cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 30901cb0ef41Sopenharmony_ci slgf(dst, opnd); 30911cb0ef41Sopenharmony_ci#else 30921cb0ef41Sopenharmony_ci SubU32(dst, opnd); 30931cb0ef41Sopenharmony_ci#endif 30941cb0ef41Sopenharmony_ci} 30951cb0ef41Sopenharmony_ci 30961cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 30971cb0ef41Sopenharmony_ci// Bitwise Operations 30981cb0ef41Sopenharmony_ci//---------------------------------------------------------------------------- 30991cb0ef41Sopenharmony_ci 31001cb0ef41Sopenharmony_ci// AND 32-bit - dst = dst & src 31011cb0ef41Sopenharmony_civoid TurboAssembler::And(Register dst, Register src) { nr(dst, src); } 31021cb0ef41Sopenharmony_ci 31031cb0ef41Sopenharmony_ci// AND Pointer Size - dst = dst & src 31041cb0ef41Sopenharmony_civoid TurboAssembler::AndP(Register dst, Register src) { ngr(dst, src); } 31051cb0ef41Sopenharmony_ci 31061cb0ef41Sopenharmony_ci// Non-clobbering AND 32-bit - dst = src1 & src1 31071cb0ef41Sopenharmony_civoid TurboAssembler::And(Register dst, Register src1, Register src2) { 31081cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 31091cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 31101cb0ef41Sopenharmony_ci // as XR is a smaller instruction 31111cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 31121cb0ef41Sopenharmony_ci nrk(dst, src1, src2); 31131cb0ef41Sopenharmony_ci return; 31141cb0ef41Sopenharmony_ci } else { 31151cb0ef41Sopenharmony_ci lr(dst, src1); 31161cb0ef41Sopenharmony_ci } 31171cb0ef41Sopenharmony_ci } else if (dst == src2) { 31181cb0ef41Sopenharmony_ci src2 = src1; 31191cb0ef41Sopenharmony_ci } 31201cb0ef41Sopenharmony_ci And(dst, src2); 31211cb0ef41Sopenharmony_ci} 31221cb0ef41Sopenharmony_ci 31231cb0ef41Sopenharmony_ci// Non-clobbering AND pointer size - dst = src1 & src1 31241cb0ef41Sopenharmony_civoid TurboAssembler::AndP(Register dst, Register src1, Register src2) { 31251cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 31261cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 31271cb0ef41Sopenharmony_ci // as XR is a smaller instruction 31281cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 31291cb0ef41Sopenharmony_ci ngrk(dst, src1, src2); 31301cb0ef41Sopenharmony_ci return; 31311cb0ef41Sopenharmony_ci } else { 31321cb0ef41Sopenharmony_ci mov(dst, src1); 31331cb0ef41Sopenharmony_ci } 31341cb0ef41Sopenharmony_ci } else if (dst == src2) { 31351cb0ef41Sopenharmony_ci src2 = src1; 31361cb0ef41Sopenharmony_ci } 31371cb0ef41Sopenharmony_ci AndP(dst, src2); 31381cb0ef41Sopenharmony_ci} 31391cb0ef41Sopenharmony_ci 31401cb0ef41Sopenharmony_ci// AND 32-bit (Reg - Mem) 31411cb0ef41Sopenharmony_civoid TurboAssembler::And(Register dst, const MemOperand& opnd) { 31421cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 31431cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 31441cb0ef41Sopenharmony_ci n(dst, opnd); 31451cb0ef41Sopenharmony_ci else 31461cb0ef41Sopenharmony_ci ny(dst, opnd); 31471cb0ef41Sopenharmony_ci} 31481cb0ef41Sopenharmony_ci 31491cb0ef41Sopenharmony_ci// AND Pointer Size (Reg - Mem) 31501cb0ef41Sopenharmony_civoid TurboAssembler::AndP(Register dst, const MemOperand& opnd) { 31511cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 31521cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 31531cb0ef41Sopenharmony_ci ng(dst, opnd); 31541cb0ef41Sopenharmony_ci#else 31551cb0ef41Sopenharmony_ci And(dst, opnd); 31561cb0ef41Sopenharmony_ci#endif 31571cb0ef41Sopenharmony_ci} 31581cb0ef41Sopenharmony_ci 31591cb0ef41Sopenharmony_ci// AND 32-bit - dst = dst & imm 31601cb0ef41Sopenharmony_civoid TurboAssembler::And(Register dst, const Operand& opnd) { nilf(dst, opnd); } 31611cb0ef41Sopenharmony_ci 31621cb0ef41Sopenharmony_ci// AND Pointer Size - dst = dst & imm 31631cb0ef41Sopenharmony_civoid TurboAssembler::AndP(Register dst, const Operand& opnd) { 31641cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 31651cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 31661cb0ef41Sopenharmony_ci if (value >> 32 != -1) { 31671cb0ef41Sopenharmony_ci // this may not work b/c condition code won't be set correctly 31681cb0ef41Sopenharmony_ci nihf(dst, Operand(value >> 32)); 31691cb0ef41Sopenharmony_ci } 31701cb0ef41Sopenharmony_ci nilf(dst, Operand(value & 0xFFFFFFFF)); 31711cb0ef41Sopenharmony_ci#else 31721cb0ef41Sopenharmony_ci And(dst, opnd); 31731cb0ef41Sopenharmony_ci#endif 31741cb0ef41Sopenharmony_ci} 31751cb0ef41Sopenharmony_ci 31761cb0ef41Sopenharmony_ci// AND 32-bit - dst = src & imm 31771cb0ef41Sopenharmony_civoid TurboAssembler::And(Register dst, Register src, const Operand& opnd) { 31781cb0ef41Sopenharmony_ci if (dst != src) lr(dst, src); 31791cb0ef41Sopenharmony_ci nilf(dst, opnd); 31801cb0ef41Sopenharmony_ci} 31811cb0ef41Sopenharmony_ci 31821cb0ef41Sopenharmony_ci// AND Pointer Size - dst = src & imm 31831cb0ef41Sopenharmony_civoid TurboAssembler::AndP(Register dst, Register src, const Operand& opnd) { 31841cb0ef41Sopenharmony_ci // Try to exploit RISBG first 31851cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 31861cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT)) { 31871cb0ef41Sopenharmony_ci intptr_t shifted_value = value; 31881cb0ef41Sopenharmony_ci int trailing_zeros = 0; 31891cb0ef41Sopenharmony_ci 31901cb0ef41Sopenharmony_ci // We start checking how many trailing zeros are left at the end. 31911cb0ef41Sopenharmony_ci while ((0 != shifted_value) && (0 == (shifted_value & 1))) { 31921cb0ef41Sopenharmony_ci trailing_zeros++; 31931cb0ef41Sopenharmony_ci shifted_value >>= 1; 31941cb0ef41Sopenharmony_ci } 31951cb0ef41Sopenharmony_ci 31961cb0ef41Sopenharmony_ci // If temp (value with right-most set of zeros shifted out) is 1 less 31971cb0ef41Sopenharmony_ci // than power of 2, we have consecutive bits of 1. 31981cb0ef41Sopenharmony_ci // Special case: If shift_value is zero, we cannot use RISBG, as it requires 31991cb0ef41Sopenharmony_ci // selection of at least 1 bit. 32001cb0ef41Sopenharmony_ci if ((0 != shifted_value) && base::bits::IsPowerOfTwo(shifted_value + 1)) { 32011cb0ef41Sopenharmony_ci int startBit = 32021cb0ef41Sopenharmony_ci base::bits::CountLeadingZeros64(shifted_value) - trailing_zeros; 32031cb0ef41Sopenharmony_ci int endBit = 63 - trailing_zeros; 32041cb0ef41Sopenharmony_ci // Start: startBit, End: endBit, Shift = 0, true = zero unselected bits. 32051cb0ef41Sopenharmony_ci RotateInsertSelectBits(dst, src, Operand(startBit), Operand(endBit), 32061cb0ef41Sopenharmony_ci Operand::Zero(), true); 32071cb0ef41Sopenharmony_ci return; 32081cb0ef41Sopenharmony_ci } else if (-1 == shifted_value) { 32091cb0ef41Sopenharmony_ci // A Special case in which all top bits up to MSB are 1's. In this case, 32101cb0ef41Sopenharmony_ci // we can set startBit to be 0. 32111cb0ef41Sopenharmony_ci int endBit = 63 - trailing_zeros; 32121cb0ef41Sopenharmony_ci RotateInsertSelectBits(dst, src, Operand::Zero(), Operand(endBit), 32131cb0ef41Sopenharmony_ci Operand::Zero(), true); 32141cb0ef41Sopenharmony_ci return; 32151cb0ef41Sopenharmony_ci } 32161cb0ef41Sopenharmony_ci } 32171cb0ef41Sopenharmony_ci 32181cb0ef41Sopenharmony_ci // If we are &'ing zero, we can just whack the dst register and skip copy 32191cb0ef41Sopenharmony_ci if (dst != src && (0 != value)) mov(dst, src); 32201cb0ef41Sopenharmony_ci AndP(dst, opnd); 32211cb0ef41Sopenharmony_ci} 32221cb0ef41Sopenharmony_ci 32231cb0ef41Sopenharmony_ci// OR 32-bit - dst = dst & src 32241cb0ef41Sopenharmony_civoid TurboAssembler::Or(Register dst, Register src) { or_z(dst, src); } 32251cb0ef41Sopenharmony_ci 32261cb0ef41Sopenharmony_ci// OR Pointer Size - dst = dst & src 32271cb0ef41Sopenharmony_civoid TurboAssembler::OrP(Register dst, Register src) { ogr(dst, src); } 32281cb0ef41Sopenharmony_ci 32291cb0ef41Sopenharmony_ci// Non-clobbering OR 32-bit - dst = src1 & src1 32301cb0ef41Sopenharmony_civoid TurboAssembler::Or(Register dst, Register src1, Register src2) { 32311cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 32321cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 32331cb0ef41Sopenharmony_ci // as XR is a smaller instruction 32341cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 32351cb0ef41Sopenharmony_ci ork(dst, src1, src2); 32361cb0ef41Sopenharmony_ci return; 32371cb0ef41Sopenharmony_ci } else { 32381cb0ef41Sopenharmony_ci lr(dst, src1); 32391cb0ef41Sopenharmony_ci } 32401cb0ef41Sopenharmony_ci } else if (dst == src2) { 32411cb0ef41Sopenharmony_ci src2 = src1; 32421cb0ef41Sopenharmony_ci } 32431cb0ef41Sopenharmony_ci Or(dst, src2); 32441cb0ef41Sopenharmony_ci} 32451cb0ef41Sopenharmony_ci 32461cb0ef41Sopenharmony_ci// Non-clobbering OR pointer size - dst = src1 & src1 32471cb0ef41Sopenharmony_civoid TurboAssembler::OrP(Register dst, Register src1, Register src2) { 32481cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 32491cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 32501cb0ef41Sopenharmony_ci // as XR is a smaller instruction 32511cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 32521cb0ef41Sopenharmony_ci ogrk(dst, src1, src2); 32531cb0ef41Sopenharmony_ci return; 32541cb0ef41Sopenharmony_ci } else { 32551cb0ef41Sopenharmony_ci mov(dst, src1); 32561cb0ef41Sopenharmony_ci } 32571cb0ef41Sopenharmony_ci } else if (dst == src2) { 32581cb0ef41Sopenharmony_ci src2 = src1; 32591cb0ef41Sopenharmony_ci } 32601cb0ef41Sopenharmony_ci OrP(dst, src2); 32611cb0ef41Sopenharmony_ci} 32621cb0ef41Sopenharmony_ci 32631cb0ef41Sopenharmony_ci// OR 32-bit (Reg - Mem) 32641cb0ef41Sopenharmony_civoid TurboAssembler::Or(Register dst, const MemOperand& opnd) { 32651cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 32661cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 32671cb0ef41Sopenharmony_ci o(dst, opnd); 32681cb0ef41Sopenharmony_ci else 32691cb0ef41Sopenharmony_ci oy(dst, opnd); 32701cb0ef41Sopenharmony_ci} 32711cb0ef41Sopenharmony_ci 32721cb0ef41Sopenharmony_ci// OR Pointer Size (Reg - Mem) 32731cb0ef41Sopenharmony_civoid TurboAssembler::OrP(Register dst, const MemOperand& opnd) { 32741cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 32751cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 32761cb0ef41Sopenharmony_ci og(dst, opnd); 32771cb0ef41Sopenharmony_ci#else 32781cb0ef41Sopenharmony_ci Or(dst, opnd); 32791cb0ef41Sopenharmony_ci#endif 32801cb0ef41Sopenharmony_ci} 32811cb0ef41Sopenharmony_ci 32821cb0ef41Sopenharmony_ci// OR 32-bit - dst = dst & imm 32831cb0ef41Sopenharmony_civoid TurboAssembler::Or(Register dst, const Operand& opnd) { oilf(dst, opnd); } 32841cb0ef41Sopenharmony_ci 32851cb0ef41Sopenharmony_ci// OR Pointer Size - dst = dst & imm 32861cb0ef41Sopenharmony_civoid TurboAssembler::OrP(Register dst, const Operand& opnd) { 32871cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 32881cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 32891cb0ef41Sopenharmony_ci if (value >> 32 != 0) { 32901cb0ef41Sopenharmony_ci // this may not work b/c condition code won't be set correctly 32911cb0ef41Sopenharmony_ci oihf(dst, Operand(value >> 32)); 32921cb0ef41Sopenharmony_ci } 32931cb0ef41Sopenharmony_ci oilf(dst, Operand(value & 0xFFFFFFFF)); 32941cb0ef41Sopenharmony_ci#else 32951cb0ef41Sopenharmony_ci Or(dst, opnd); 32961cb0ef41Sopenharmony_ci#endif 32971cb0ef41Sopenharmony_ci} 32981cb0ef41Sopenharmony_ci 32991cb0ef41Sopenharmony_ci// OR 32-bit - dst = src & imm 33001cb0ef41Sopenharmony_civoid TurboAssembler::Or(Register dst, Register src, const Operand& opnd) { 33011cb0ef41Sopenharmony_ci if (dst != src) lr(dst, src); 33021cb0ef41Sopenharmony_ci oilf(dst, opnd); 33031cb0ef41Sopenharmony_ci} 33041cb0ef41Sopenharmony_ci 33051cb0ef41Sopenharmony_ci// OR Pointer Size - dst = src & imm 33061cb0ef41Sopenharmony_civoid TurboAssembler::OrP(Register dst, Register src, const Operand& opnd) { 33071cb0ef41Sopenharmony_ci if (dst != src) mov(dst, src); 33081cb0ef41Sopenharmony_ci OrP(dst, opnd); 33091cb0ef41Sopenharmony_ci} 33101cb0ef41Sopenharmony_ci 33111cb0ef41Sopenharmony_ci// XOR 32-bit - dst = dst & src 33121cb0ef41Sopenharmony_civoid TurboAssembler::Xor(Register dst, Register src) { xr(dst, src); } 33131cb0ef41Sopenharmony_ci 33141cb0ef41Sopenharmony_ci// XOR Pointer Size - dst = dst & src 33151cb0ef41Sopenharmony_civoid TurboAssembler::XorP(Register dst, Register src) { xgr(dst, src); } 33161cb0ef41Sopenharmony_ci 33171cb0ef41Sopenharmony_ci// Non-clobbering XOR 32-bit - dst = src1 & src1 33181cb0ef41Sopenharmony_civoid TurboAssembler::Xor(Register dst, Register src1, Register src2) { 33191cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 33201cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 33211cb0ef41Sopenharmony_ci // as XR is a smaller instruction 33221cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 33231cb0ef41Sopenharmony_ci xrk(dst, src1, src2); 33241cb0ef41Sopenharmony_ci return; 33251cb0ef41Sopenharmony_ci } else { 33261cb0ef41Sopenharmony_ci lr(dst, src1); 33271cb0ef41Sopenharmony_ci } 33281cb0ef41Sopenharmony_ci } else if (dst == src2) { 33291cb0ef41Sopenharmony_ci src2 = src1; 33301cb0ef41Sopenharmony_ci } 33311cb0ef41Sopenharmony_ci Xor(dst, src2); 33321cb0ef41Sopenharmony_ci} 33331cb0ef41Sopenharmony_ci 33341cb0ef41Sopenharmony_ci// Non-clobbering XOR pointer size - dst = src1 & src1 33351cb0ef41Sopenharmony_civoid TurboAssembler::XorP(Register dst, Register src1, Register src2) { 33361cb0ef41Sopenharmony_ci if (dst != src1 && dst != src2) { 33371cb0ef41Sopenharmony_ci // We prefer to generate XR/XGR, over the non clobbering XRK/XRK 33381cb0ef41Sopenharmony_ci // as XR is a smaller instruction 33391cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 33401cb0ef41Sopenharmony_ci xgrk(dst, src1, src2); 33411cb0ef41Sopenharmony_ci return; 33421cb0ef41Sopenharmony_ci } else { 33431cb0ef41Sopenharmony_ci mov(dst, src1); 33441cb0ef41Sopenharmony_ci } 33451cb0ef41Sopenharmony_ci } else if (dst == src2) { 33461cb0ef41Sopenharmony_ci src2 = src1; 33471cb0ef41Sopenharmony_ci } 33481cb0ef41Sopenharmony_ci XorP(dst, src2); 33491cb0ef41Sopenharmony_ci} 33501cb0ef41Sopenharmony_ci 33511cb0ef41Sopenharmony_ci// XOR 32-bit (Reg - Mem) 33521cb0ef41Sopenharmony_civoid TurboAssembler::Xor(Register dst, const MemOperand& opnd) { 33531cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 33541cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 33551cb0ef41Sopenharmony_ci x(dst, opnd); 33561cb0ef41Sopenharmony_ci else 33571cb0ef41Sopenharmony_ci xy(dst, opnd); 33581cb0ef41Sopenharmony_ci} 33591cb0ef41Sopenharmony_ci 33601cb0ef41Sopenharmony_ci// XOR Pointer Size (Reg - Mem) 33611cb0ef41Sopenharmony_civoid TurboAssembler::XorP(Register dst, const MemOperand& opnd) { 33621cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 33631cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 33641cb0ef41Sopenharmony_ci xg(dst, opnd); 33651cb0ef41Sopenharmony_ci#else 33661cb0ef41Sopenharmony_ci Xor(dst, opnd); 33671cb0ef41Sopenharmony_ci#endif 33681cb0ef41Sopenharmony_ci} 33691cb0ef41Sopenharmony_ci 33701cb0ef41Sopenharmony_ci// XOR 32-bit - dst = dst & imm 33711cb0ef41Sopenharmony_civoid TurboAssembler::Xor(Register dst, const Operand& opnd) { xilf(dst, opnd); } 33721cb0ef41Sopenharmony_ci 33731cb0ef41Sopenharmony_ci// XOR Pointer Size - dst = dst & imm 33741cb0ef41Sopenharmony_civoid TurboAssembler::XorP(Register dst, const Operand& opnd) { 33751cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 33761cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 33771cb0ef41Sopenharmony_ci xihf(dst, Operand(value >> 32)); 33781cb0ef41Sopenharmony_ci xilf(dst, Operand(value & 0xFFFFFFFF)); 33791cb0ef41Sopenharmony_ci#else 33801cb0ef41Sopenharmony_ci Xor(dst, opnd); 33811cb0ef41Sopenharmony_ci#endif 33821cb0ef41Sopenharmony_ci} 33831cb0ef41Sopenharmony_ci 33841cb0ef41Sopenharmony_ci// XOR 32-bit - dst = src & imm 33851cb0ef41Sopenharmony_civoid TurboAssembler::Xor(Register dst, Register src, const Operand& opnd) { 33861cb0ef41Sopenharmony_ci if (dst != src) lr(dst, src); 33871cb0ef41Sopenharmony_ci xilf(dst, opnd); 33881cb0ef41Sopenharmony_ci} 33891cb0ef41Sopenharmony_ci 33901cb0ef41Sopenharmony_ci// XOR Pointer Size - dst = src & imm 33911cb0ef41Sopenharmony_civoid TurboAssembler::XorP(Register dst, Register src, const Operand& opnd) { 33921cb0ef41Sopenharmony_ci if (dst != src) mov(dst, src); 33931cb0ef41Sopenharmony_ci XorP(dst, opnd); 33941cb0ef41Sopenharmony_ci} 33951cb0ef41Sopenharmony_ci 33961cb0ef41Sopenharmony_civoid TurboAssembler::Not32(Register dst, Register src) { 33971cb0ef41Sopenharmony_ci if (src != no_reg && src != dst) lr(dst, src); 33981cb0ef41Sopenharmony_ci xilf(dst, Operand(0xFFFFFFFF)); 33991cb0ef41Sopenharmony_ci} 34001cb0ef41Sopenharmony_ci 34011cb0ef41Sopenharmony_civoid TurboAssembler::Not64(Register dst, Register src) { 34021cb0ef41Sopenharmony_ci if (src != no_reg && src != dst) lgr(dst, src); 34031cb0ef41Sopenharmony_ci xihf(dst, Operand(0xFFFFFFFF)); 34041cb0ef41Sopenharmony_ci xilf(dst, Operand(0xFFFFFFFF)); 34051cb0ef41Sopenharmony_ci} 34061cb0ef41Sopenharmony_ci 34071cb0ef41Sopenharmony_civoid TurboAssembler::NotP(Register dst, Register src) { 34081cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 34091cb0ef41Sopenharmony_ci Not64(dst, src); 34101cb0ef41Sopenharmony_ci#else 34111cb0ef41Sopenharmony_ci Not32(dst, src); 34121cb0ef41Sopenharmony_ci#endif 34131cb0ef41Sopenharmony_ci} 34141cb0ef41Sopenharmony_ci 34151cb0ef41Sopenharmony_civoid TurboAssembler::LoadPositiveP(Register result, Register input) { 34161cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 34171cb0ef41Sopenharmony_ci lpgr(result, input); 34181cb0ef41Sopenharmony_ci#else 34191cb0ef41Sopenharmony_ci lpr(result, input); 34201cb0ef41Sopenharmony_ci#endif 34211cb0ef41Sopenharmony_ci} 34221cb0ef41Sopenharmony_ci 34231cb0ef41Sopenharmony_civoid TurboAssembler::LoadPositive32(Register result, Register input) { 34241cb0ef41Sopenharmony_ci lpr(result, input); 34251cb0ef41Sopenharmony_ci lgfr(result, result); 34261cb0ef41Sopenharmony_ci} 34271cb0ef41Sopenharmony_ci 34281cb0ef41Sopenharmony_ci//----------------------------------------------------------------------------- 34291cb0ef41Sopenharmony_ci// Compare Helpers 34301cb0ef41Sopenharmony_ci//----------------------------------------------------------------------------- 34311cb0ef41Sopenharmony_ci 34321cb0ef41Sopenharmony_ci// Compare 32-bit Register vs Register 34331cb0ef41Sopenharmony_civoid TurboAssembler::CmpS32(Register src1, Register src2) { cr_z(src1, src2); } 34341cb0ef41Sopenharmony_ci 34351cb0ef41Sopenharmony_ci// Compare Pointer Sized Register vs Register 34361cb0ef41Sopenharmony_civoid TurboAssembler::CmpS64(Register src1, Register src2) { cgr(src1, src2); } 34371cb0ef41Sopenharmony_ci 34381cb0ef41Sopenharmony_ci// Compare 32-bit Register vs Immediate 34391cb0ef41Sopenharmony_ci// This helper will set up proper relocation entries if required. 34401cb0ef41Sopenharmony_civoid TurboAssembler::CmpS32(Register dst, const Operand& opnd) { 34411cb0ef41Sopenharmony_ci if (opnd.rmode() == RelocInfo::NO_INFO) { 34421cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 34431cb0ef41Sopenharmony_ci if (is_int16(value)) 34441cb0ef41Sopenharmony_ci chi(dst, opnd); 34451cb0ef41Sopenharmony_ci else 34461cb0ef41Sopenharmony_ci cfi(dst, opnd); 34471cb0ef41Sopenharmony_ci } else { 34481cb0ef41Sopenharmony_ci // Need to generate relocation record here 34491cb0ef41Sopenharmony_ci RecordRelocInfo(opnd.rmode(), opnd.immediate()); 34501cb0ef41Sopenharmony_ci cfi(dst, opnd); 34511cb0ef41Sopenharmony_ci } 34521cb0ef41Sopenharmony_ci} 34531cb0ef41Sopenharmony_ci 34541cb0ef41Sopenharmony_ci// Compare Pointer Sized Register vs Immediate 34551cb0ef41Sopenharmony_ci// This helper will set up proper relocation entries if required. 34561cb0ef41Sopenharmony_civoid TurboAssembler::CmpS64(Register dst, const Operand& opnd) { 34571cb0ef41Sopenharmony_ci if (opnd.rmode() == RelocInfo::NO_INFO) { 34581cb0ef41Sopenharmony_ci cgfi(dst, opnd); 34591cb0ef41Sopenharmony_ci } else { 34601cb0ef41Sopenharmony_ci mov(r0, opnd); // Need to generate 64-bit relocation 34611cb0ef41Sopenharmony_ci cgr(dst, r0); 34621cb0ef41Sopenharmony_ci } 34631cb0ef41Sopenharmony_ci} 34641cb0ef41Sopenharmony_ci 34651cb0ef41Sopenharmony_ci// Compare 32-bit Register vs Memory 34661cb0ef41Sopenharmony_civoid TurboAssembler::CmpS32(Register dst, const MemOperand& opnd) { 34671cb0ef41Sopenharmony_ci // make sure offset is within 20 bit range 34681cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 34691cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 34701cb0ef41Sopenharmony_ci c(dst, opnd); 34711cb0ef41Sopenharmony_ci else 34721cb0ef41Sopenharmony_ci cy(dst, opnd); 34731cb0ef41Sopenharmony_ci} 34741cb0ef41Sopenharmony_ci 34751cb0ef41Sopenharmony_ci// Compare Pointer Size Register vs Memory 34761cb0ef41Sopenharmony_civoid TurboAssembler::CmpS64(Register dst, const MemOperand& opnd) { 34771cb0ef41Sopenharmony_ci // make sure offset is within 20 bit range 34781cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 34791cb0ef41Sopenharmony_ci cg(dst, opnd); 34801cb0ef41Sopenharmony_ci} 34811cb0ef41Sopenharmony_ci 34821cb0ef41Sopenharmony_ci// Using cs or scy based on the offset 34831cb0ef41Sopenharmony_civoid TurboAssembler::CmpAndSwap(Register old_val, Register new_val, 34841cb0ef41Sopenharmony_ci const MemOperand& opnd) { 34851cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 34861cb0ef41Sopenharmony_ci cs(old_val, new_val, opnd); 34871cb0ef41Sopenharmony_ci } else { 34881cb0ef41Sopenharmony_ci csy(old_val, new_val, opnd); 34891cb0ef41Sopenharmony_ci } 34901cb0ef41Sopenharmony_ci} 34911cb0ef41Sopenharmony_ci 34921cb0ef41Sopenharmony_civoid TurboAssembler::CmpAndSwap64(Register old_val, Register new_val, 34931cb0ef41Sopenharmony_ci const MemOperand& opnd) { 34941cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 34951cb0ef41Sopenharmony_ci csg(old_val, new_val, opnd); 34961cb0ef41Sopenharmony_ci} 34971cb0ef41Sopenharmony_ci 34981cb0ef41Sopenharmony_ci//----------------------------------------------------------------------------- 34991cb0ef41Sopenharmony_ci// Compare Logical Helpers 35001cb0ef41Sopenharmony_ci//----------------------------------------------------------------------------- 35011cb0ef41Sopenharmony_ci 35021cb0ef41Sopenharmony_ci// Compare Logical 32-bit Register vs Register 35031cb0ef41Sopenharmony_civoid TurboAssembler::CmpU32(Register dst, Register src) { clr(dst, src); } 35041cb0ef41Sopenharmony_ci 35051cb0ef41Sopenharmony_ci// Compare Logical Pointer Sized Register vs Register 35061cb0ef41Sopenharmony_civoid TurboAssembler::CmpU64(Register dst, Register src) { 35071cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 35081cb0ef41Sopenharmony_ci clgr(dst, src); 35091cb0ef41Sopenharmony_ci#else 35101cb0ef41Sopenharmony_ci CmpU32(dst, src); 35111cb0ef41Sopenharmony_ci#endif 35121cb0ef41Sopenharmony_ci} 35131cb0ef41Sopenharmony_ci 35141cb0ef41Sopenharmony_ci// Compare Logical 32-bit Register vs Immediate 35151cb0ef41Sopenharmony_civoid TurboAssembler::CmpU32(Register dst, const Operand& opnd) { 35161cb0ef41Sopenharmony_ci clfi(dst, opnd); 35171cb0ef41Sopenharmony_ci} 35181cb0ef41Sopenharmony_ci 35191cb0ef41Sopenharmony_ci// Compare Logical Pointer Sized Register vs Immediate 35201cb0ef41Sopenharmony_civoid TurboAssembler::CmpU64(Register dst, const Operand& opnd) { 35211cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 35221cb0ef41Sopenharmony_ci DCHECK_EQ(static_cast<uint32_t>(opnd.immediate() >> 32), 0); 35231cb0ef41Sopenharmony_ci clgfi(dst, opnd); 35241cb0ef41Sopenharmony_ci#else 35251cb0ef41Sopenharmony_ci CmpU32(dst, opnd); 35261cb0ef41Sopenharmony_ci#endif 35271cb0ef41Sopenharmony_ci} 35281cb0ef41Sopenharmony_ci 35291cb0ef41Sopenharmony_ci// Compare Logical 32-bit Register vs Memory 35301cb0ef41Sopenharmony_civoid TurboAssembler::CmpU32(Register dst, const MemOperand& opnd) { 35311cb0ef41Sopenharmony_ci // make sure offset is within 20 bit range 35321cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 35331cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) 35341cb0ef41Sopenharmony_ci cl(dst, opnd); 35351cb0ef41Sopenharmony_ci else 35361cb0ef41Sopenharmony_ci cly(dst, opnd); 35371cb0ef41Sopenharmony_ci} 35381cb0ef41Sopenharmony_ci 35391cb0ef41Sopenharmony_ci// Compare Logical Pointer Sized Register vs Memory 35401cb0ef41Sopenharmony_civoid TurboAssembler::CmpU64(Register dst, const MemOperand& opnd) { 35411cb0ef41Sopenharmony_ci // make sure offset is within 20 bit range 35421cb0ef41Sopenharmony_ci DCHECK(is_int20(opnd.offset())); 35431cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 35441cb0ef41Sopenharmony_ci clg(dst, opnd); 35451cb0ef41Sopenharmony_ci#else 35461cb0ef41Sopenharmony_ci CmpU32(dst, opnd); 35471cb0ef41Sopenharmony_ci#endif 35481cb0ef41Sopenharmony_ci} 35491cb0ef41Sopenharmony_ci 35501cb0ef41Sopenharmony_civoid TurboAssembler::Branch(Condition c, const Operand& opnd) { 35511cb0ef41Sopenharmony_ci intptr_t value = opnd.immediate(); 35521cb0ef41Sopenharmony_ci if (is_int16(value)) 35531cb0ef41Sopenharmony_ci brc(c, opnd); 35541cb0ef41Sopenharmony_ci else 35551cb0ef41Sopenharmony_ci brcl(c, opnd); 35561cb0ef41Sopenharmony_ci} 35571cb0ef41Sopenharmony_ci 35581cb0ef41Sopenharmony_ci// Branch On Count. Decrement R1, and branch if R1 != 0. 35591cb0ef41Sopenharmony_civoid TurboAssembler::BranchOnCount(Register r1, Label* l) { 35601cb0ef41Sopenharmony_ci int32_t offset = branch_offset(l); 35611cb0ef41Sopenharmony_ci if (is_int16(offset)) { 35621cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 35631cb0ef41Sopenharmony_ci brctg(r1, Operand(offset)); 35641cb0ef41Sopenharmony_ci#else 35651cb0ef41Sopenharmony_ci brct(r1, Operand(offset)); 35661cb0ef41Sopenharmony_ci#endif 35671cb0ef41Sopenharmony_ci } else { 35681cb0ef41Sopenharmony_ci AddS64(r1, Operand(-1)); 35691cb0ef41Sopenharmony_ci Branch(ne, Operand(offset)); 35701cb0ef41Sopenharmony_ci } 35711cb0ef41Sopenharmony_ci} 35721cb0ef41Sopenharmony_ci 35731cb0ef41Sopenharmony_civoid TurboAssembler::LoadSmiLiteral(Register dst, Smi smi) { 35741cb0ef41Sopenharmony_ci intptr_t value = static_cast<intptr_t>(smi.ptr()); 35751cb0ef41Sopenharmony_ci#if defined(V8_COMPRESS_POINTERS) || defined(V8_31BIT_SMIS_ON_64BIT_ARCH) 35761cb0ef41Sopenharmony_ci llilf(dst, Operand(value)); 35771cb0ef41Sopenharmony_ci#else 35781cb0ef41Sopenharmony_ci DCHECK_EQ(value & 0xFFFFFFFF, 0); 35791cb0ef41Sopenharmony_ci // The smi value is loaded in upper 32-bits. Lower 32-bit are zeros. 35801cb0ef41Sopenharmony_ci llihf(dst, Operand(value >> 32)); 35811cb0ef41Sopenharmony_ci#endif 35821cb0ef41Sopenharmony_ci} 35831cb0ef41Sopenharmony_ci 35841cb0ef41Sopenharmony_civoid TurboAssembler::CmpSmiLiteral(Register src1, Smi smi, Register scratch) { 35851cb0ef41Sopenharmony_ci#if defined(V8_COMPRESS_POINTERS) || defined(V8_31BIT_SMIS_ON_64BIT_ARCH) 35861cb0ef41Sopenharmony_ci // CFI takes 32-bit immediate. 35871cb0ef41Sopenharmony_ci cfi(src1, Operand(smi)); 35881cb0ef41Sopenharmony_ci#else 35891cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 35901cb0ef41Sopenharmony_ci cih(src1, Operand(static_cast<intptr_t>(smi.ptr()) >> 32)); 35911cb0ef41Sopenharmony_ci } else { 35921cb0ef41Sopenharmony_ci LoadSmiLiteral(scratch, smi); 35931cb0ef41Sopenharmony_ci cgr(src1, scratch); 35941cb0ef41Sopenharmony_ci } 35951cb0ef41Sopenharmony_ci#endif 35961cb0ef41Sopenharmony_ci} 35971cb0ef41Sopenharmony_ci 35981cb0ef41Sopenharmony_civoid TurboAssembler::LoadU64(Register dst, const MemOperand& mem, 35991cb0ef41Sopenharmony_ci Register scratch) { 36001cb0ef41Sopenharmony_ci int offset = mem.offset(); 36011cb0ef41Sopenharmony_ci 36021cb0ef41Sopenharmony_ci MemOperand src = mem; 36031cb0ef41Sopenharmony_ci if (!is_int20(offset)) { 36041cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg && scratch != r0 && mem.rx() == r0); 36051cb0ef41Sopenharmony_ci DCHECK(scratch != mem.rb()); 36061cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 36071cb0ef41Sopenharmony_ci src = MemOperand(mem.rb(), scratch); 36081cb0ef41Sopenharmony_ci } 36091cb0ef41Sopenharmony_ci lg(dst, src); 36101cb0ef41Sopenharmony_ci} 36111cb0ef41Sopenharmony_ci 36121cb0ef41Sopenharmony_ci// Store a "pointer" sized value to the memory location 36131cb0ef41Sopenharmony_civoid TurboAssembler::StoreU64(Register src, const MemOperand& mem, 36141cb0ef41Sopenharmony_ci Register scratch) { 36151cb0ef41Sopenharmony_ci if (!is_int20(mem.offset())) { 36161cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 36171cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 36181cb0ef41Sopenharmony_ci mov(scratch, Operand(mem.offset())); 36191cb0ef41Sopenharmony_ci stg(src, MemOperand(mem.rb(), scratch)); 36201cb0ef41Sopenharmony_ci } else { 36211cb0ef41Sopenharmony_ci stg(src, mem); 36221cb0ef41Sopenharmony_ci } 36231cb0ef41Sopenharmony_ci} 36241cb0ef41Sopenharmony_ci 36251cb0ef41Sopenharmony_ci// Store a "pointer" sized constant to the memory location 36261cb0ef41Sopenharmony_civoid TurboAssembler::StoreU64(const MemOperand& mem, const Operand& opnd, 36271cb0ef41Sopenharmony_ci Register scratch) { 36281cb0ef41Sopenharmony_ci // Relocations not supported 36291cb0ef41Sopenharmony_ci DCHECK_EQ(opnd.rmode(), RelocInfo::NO_INFO); 36301cb0ef41Sopenharmony_ci 36311cb0ef41Sopenharmony_ci // Try to use MVGHI/MVHI 36321cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT) && is_uint12(mem.offset()) && 36331cb0ef41Sopenharmony_ci mem.getIndexRegister() == r0 && is_int16(opnd.immediate())) { 36341cb0ef41Sopenharmony_ci mvghi(mem, opnd); 36351cb0ef41Sopenharmony_ci } else { 36361cb0ef41Sopenharmony_ci mov(scratch, opnd); 36371cb0ef41Sopenharmony_ci StoreU64(scratch, mem); 36381cb0ef41Sopenharmony_ci } 36391cb0ef41Sopenharmony_ci} 36401cb0ef41Sopenharmony_ci 36411cb0ef41Sopenharmony_civoid TurboAssembler::LoadMultipleP(Register dst1, Register dst2, 36421cb0ef41Sopenharmony_ci const MemOperand& mem) { 36431cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 36441cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36451cb0ef41Sopenharmony_ci lmg(dst1, dst2, mem); 36461cb0ef41Sopenharmony_ci#else 36471cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 36481cb0ef41Sopenharmony_ci lm(dst1, dst2, mem); 36491cb0ef41Sopenharmony_ci } else { 36501cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36511cb0ef41Sopenharmony_ci lmy(dst1, dst2, mem); 36521cb0ef41Sopenharmony_ci } 36531cb0ef41Sopenharmony_ci#endif 36541cb0ef41Sopenharmony_ci} 36551cb0ef41Sopenharmony_ci 36561cb0ef41Sopenharmony_civoid TurboAssembler::StoreMultipleP(Register src1, Register src2, 36571cb0ef41Sopenharmony_ci const MemOperand& mem) { 36581cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 36591cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36601cb0ef41Sopenharmony_ci stmg(src1, src2, mem); 36611cb0ef41Sopenharmony_ci#else 36621cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 36631cb0ef41Sopenharmony_ci stm(src1, src2, mem); 36641cb0ef41Sopenharmony_ci } else { 36651cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36661cb0ef41Sopenharmony_ci stmy(src1, src2, mem); 36671cb0ef41Sopenharmony_ci } 36681cb0ef41Sopenharmony_ci#endif 36691cb0ef41Sopenharmony_ci} 36701cb0ef41Sopenharmony_ci 36711cb0ef41Sopenharmony_civoid TurboAssembler::LoadMultipleW(Register dst1, Register dst2, 36721cb0ef41Sopenharmony_ci const MemOperand& mem) { 36731cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 36741cb0ef41Sopenharmony_ci lm(dst1, dst2, mem); 36751cb0ef41Sopenharmony_ci } else { 36761cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36771cb0ef41Sopenharmony_ci lmy(dst1, dst2, mem); 36781cb0ef41Sopenharmony_ci } 36791cb0ef41Sopenharmony_ci} 36801cb0ef41Sopenharmony_ci 36811cb0ef41Sopenharmony_civoid TurboAssembler::StoreMultipleW(Register src1, Register src2, 36821cb0ef41Sopenharmony_ci const MemOperand& mem) { 36831cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 36841cb0ef41Sopenharmony_ci stm(src1, src2, mem); 36851cb0ef41Sopenharmony_ci } else { 36861cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 36871cb0ef41Sopenharmony_ci stmy(src1, src2, mem); 36881cb0ef41Sopenharmony_ci } 36891cb0ef41Sopenharmony_ci} 36901cb0ef41Sopenharmony_ci 36911cb0ef41Sopenharmony_ci// Load 32-bits and sign extend if necessary. 36921cb0ef41Sopenharmony_civoid TurboAssembler::LoadS32(Register dst, Register src) { 36931cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 36941cb0ef41Sopenharmony_ci lgfr(dst, src); 36951cb0ef41Sopenharmony_ci#else 36961cb0ef41Sopenharmony_ci if (dst != src) lr(dst, src); 36971cb0ef41Sopenharmony_ci#endif 36981cb0ef41Sopenharmony_ci} 36991cb0ef41Sopenharmony_ci 37001cb0ef41Sopenharmony_ci// Load 32-bits and sign extend if necessary. 37011cb0ef41Sopenharmony_civoid TurboAssembler::LoadS32(Register dst, const MemOperand& mem, 37021cb0ef41Sopenharmony_ci Register scratch) { 37031cb0ef41Sopenharmony_ci int offset = mem.offset(); 37041cb0ef41Sopenharmony_ci 37051cb0ef41Sopenharmony_ci if (!is_int20(offset)) { 37061cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 37071cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 37081cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37091cb0ef41Sopenharmony_ci lgf(dst, MemOperand(mem.rb(), scratch)); 37101cb0ef41Sopenharmony_ci#else 37111cb0ef41Sopenharmony_ci l(dst, MemOperand(mem.rb(), scratch)); 37121cb0ef41Sopenharmony_ci#endif 37131cb0ef41Sopenharmony_ci } else { 37141cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37151cb0ef41Sopenharmony_ci lgf(dst, mem); 37161cb0ef41Sopenharmony_ci#else 37171cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 37181cb0ef41Sopenharmony_ci l(dst, mem); 37191cb0ef41Sopenharmony_ci } else { 37201cb0ef41Sopenharmony_ci ly(dst, mem); 37211cb0ef41Sopenharmony_ci } 37221cb0ef41Sopenharmony_ci#endif 37231cb0ef41Sopenharmony_ci } 37241cb0ef41Sopenharmony_ci} 37251cb0ef41Sopenharmony_ci 37261cb0ef41Sopenharmony_ci// Load 32-bits and zero extend if necessary. 37271cb0ef41Sopenharmony_civoid TurboAssembler::LoadU32(Register dst, Register src) { 37281cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37291cb0ef41Sopenharmony_ci llgfr(dst, src); 37301cb0ef41Sopenharmony_ci#else 37311cb0ef41Sopenharmony_ci if (dst != src) lr(dst, src); 37321cb0ef41Sopenharmony_ci#endif 37331cb0ef41Sopenharmony_ci} 37341cb0ef41Sopenharmony_ci 37351cb0ef41Sopenharmony_ci// Variable length depending on whether offset fits into immediate field 37361cb0ef41Sopenharmony_ci// MemOperand of RX or RXY format 37371cb0ef41Sopenharmony_civoid TurboAssembler::LoadU32(Register dst, const MemOperand& mem, 37381cb0ef41Sopenharmony_ci Register scratch) { 37391cb0ef41Sopenharmony_ci Register base = mem.rb(); 37401cb0ef41Sopenharmony_ci int offset = mem.offset(); 37411cb0ef41Sopenharmony_ci 37421cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37431cb0ef41Sopenharmony_ci if (is_int20(offset)) { 37441cb0ef41Sopenharmony_ci llgf(dst, mem); 37451cb0ef41Sopenharmony_ci } else if (scratch != no_reg) { 37461cb0ef41Sopenharmony_ci // Materialize offset into scratch register. 37471cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 37481cb0ef41Sopenharmony_ci llgf(dst, MemOperand(base, scratch)); 37491cb0ef41Sopenharmony_ci } else { 37501cb0ef41Sopenharmony_ci DCHECK(false); 37511cb0ef41Sopenharmony_ci } 37521cb0ef41Sopenharmony_ci#else 37531cb0ef41Sopenharmony_ci bool use_RXform = false; 37541cb0ef41Sopenharmony_ci bool use_RXYform = false; 37551cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 37561cb0ef41Sopenharmony_ci // RX-format supports unsigned 12-bits offset. 37571cb0ef41Sopenharmony_ci use_RXform = true; 37581cb0ef41Sopenharmony_ci } else if (is_int20(offset)) { 37591cb0ef41Sopenharmony_ci // RXY-format supports signed 20-bits offset. 37601cb0ef41Sopenharmony_ci use_RXYform = true; 37611cb0ef41Sopenharmony_ci } else if (scratch != no_reg) { 37621cb0ef41Sopenharmony_ci // Materialize offset into scratch register. 37631cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 37641cb0ef41Sopenharmony_ci } else { 37651cb0ef41Sopenharmony_ci DCHECK(false); 37661cb0ef41Sopenharmony_ci } 37671cb0ef41Sopenharmony_ci 37681cb0ef41Sopenharmony_ci if (use_RXform) { 37691cb0ef41Sopenharmony_ci l(dst, mem); 37701cb0ef41Sopenharmony_ci } else if (use_RXYform) { 37711cb0ef41Sopenharmony_ci ly(dst, mem); 37721cb0ef41Sopenharmony_ci } else { 37731cb0ef41Sopenharmony_ci ly(dst, MemOperand(base, scratch)); 37741cb0ef41Sopenharmony_ci } 37751cb0ef41Sopenharmony_ci#endif 37761cb0ef41Sopenharmony_ci} 37771cb0ef41Sopenharmony_ci 37781cb0ef41Sopenharmony_civoid TurboAssembler::LoadU16(Register dst, const MemOperand& mem) { 37791cb0ef41Sopenharmony_ci // TODO(s390x): Add scratch reg 37801cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37811cb0ef41Sopenharmony_ci llgh(dst, mem); 37821cb0ef41Sopenharmony_ci#else 37831cb0ef41Sopenharmony_ci llh(dst, mem); 37841cb0ef41Sopenharmony_ci#endif 37851cb0ef41Sopenharmony_ci} 37861cb0ef41Sopenharmony_ci 37871cb0ef41Sopenharmony_civoid TurboAssembler::LoadU16(Register dst, Register src) { 37881cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37891cb0ef41Sopenharmony_ci llghr(dst, src); 37901cb0ef41Sopenharmony_ci#else 37911cb0ef41Sopenharmony_ci llhr(dst, src); 37921cb0ef41Sopenharmony_ci#endif 37931cb0ef41Sopenharmony_ci} 37941cb0ef41Sopenharmony_ci 37951cb0ef41Sopenharmony_civoid TurboAssembler::LoadS8(Register dst, const MemOperand& mem) { 37961cb0ef41Sopenharmony_ci // TODO(s390x): Add scratch reg 37971cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 37981cb0ef41Sopenharmony_ci lgb(dst, mem); 37991cb0ef41Sopenharmony_ci#else 38001cb0ef41Sopenharmony_ci lb(dst, mem); 38011cb0ef41Sopenharmony_ci#endif 38021cb0ef41Sopenharmony_ci} 38031cb0ef41Sopenharmony_ci 38041cb0ef41Sopenharmony_civoid TurboAssembler::LoadS8(Register dst, Register src) { 38051cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 38061cb0ef41Sopenharmony_ci lgbr(dst, src); 38071cb0ef41Sopenharmony_ci#else 38081cb0ef41Sopenharmony_ci lbr(dst, src); 38091cb0ef41Sopenharmony_ci#endif 38101cb0ef41Sopenharmony_ci} 38111cb0ef41Sopenharmony_ci 38121cb0ef41Sopenharmony_civoid TurboAssembler::LoadU8(Register dst, const MemOperand& mem) { 38131cb0ef41Sopenharmony_ci // TODO(s390x): Add scratch reg 38141cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 38151cb0ef41Sopenharmony_ci llgc(dst, mem); 38161cb0ef41Sopenharmony_ci#else 38171cb0ef41Sopenharmony_ci llc(dst, mem); 38181cb0ef41Sopenharmony_ci#endif 38191cb0ef41Sopenharmony_ci} 38201cb0ef41Sopenharmony_ci 38211cb0ef41Sopenharmony_civoid TurboAssembler::LoadU8(Register dst, Register src) { 38221cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 38231cb0ef41Sopenharmony_ci llgcr(dst, src); 38241cb0ef41Sopenharmony_ci#else 38251cb0ef41Sopenharmony_ci llcr(dst, src); 38261cb0ef41Sopenharmony_ci#endif 38271cb0ef41Sopenharmony_ci} 38281cb0ef41Sopenharmony_ci 38291cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 38301cb0ef41Sopenharmony_civoid TurboAssembler::LoadU64LE(Register dst, const MemOperand& mem, 38311cb0ef41Sopenharmony_ci Register scratch) { 38321cb0ef41Sopenharmony_ci lrvg(dst, mem); 38331cb0ef41Sopenharmony_ci} 38341cb0ef41Sopenharmony_ci 38351cb0ef41Sopenharmony_civoid TurboAssembler::LoadS32LE(Register dst, const MemOperand& opnd, 38361cb0ef41Sopenharmony_ci Register scratch) { 38371cb0ef41Sopenharmony_ci lrv(dst, opnd); 38381cb0ef41Sopenharmony_ci LoadS32(dst, dst); 38391cb0ef41Sopenharmony_ci} 38401cb0ef41Sopenharmony_ci 38411cb0ef41Sopenharmony_civoid TurboAssembler::LoadU32LE(Register dst, const MemOperand& opnd, 38421cb0ef41Sopenharmony_ci Register scratch) { 38431cb0ef41Sopenharmony_ci lrv(dst, opnd); 38441cb0ef41Sopenharmony_ci LoadU32(dst, dst); 38451cb0ef41Sopenharmony_ci} 38461cb0ef41Sopenharmony_ci 38471cb0ef41Sopenharmony_civoid TurboAssembler::LoadU16LE(Register dst, const MemOperand& opnd) { 38481cb0ef41Sopenharmony_ci lrvh(dst, opnd); 38491cb0ef41Sopenharmony_ci LoadU16(dst, dst); 38501cb0ef41Sopenharmony_ci} 38511cb0ef41Sopenharmony_ci 38521cb0ef41Sopenharmony_civoid TurboAssembler::LoadS16LE(Register dst, const MemOperand& opnd) { 38531cb0ef41Sopenharmony_ci lrvh(dst, opnd); 38541cb0ef41Sopenharmony_ci LoadS16(dst, dst); 38551cb0ef41Sopenharmony_ci} 38561cb0ef41Sopenharmony_ci 38571cb0ef41Sopenharmony_civoid TurboAssembler::LoadV128LE(DoubleRegister dst, const MemOperand& opnd, 38581cb0ef41Sopenharmony_ci Register scratch0, Register scratch1) { 38591cb0ef41Sopenharmony_ci bool use_vlbr = CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2) && 38601cb0ef41Sopenharmony_ci is_uint12(opnd.offset()); 38611cb0ef41Sopenharmony_ci if (use_vlbr) { 38621cb0ef41Sopenharmony_ci vlbr(dst, opnd, Condition(4)); 38631cb0ef41Sopenharmony_ci } else { 38641cb0ef41Sopenharmony_ci lrvg(scratch0, opnd); 38651cb0ef41Sopenharmony_ci lrvg(scratch1, 38661cb0ef41Sopenharmony_ci MemOperand(opnd.rx(), opnd.rb(), opnd.offset() + kSystemPointerSize)); 38671cb0ef41Sopenharmony_ci vlvgp(dst, scratch1, scratch0); 38681cb0ef41Sopenharmony_ci } 38691cb0ef41Sopenharmony_ci} 38701cb0ef41Sopenharmony_ci 38711cb0ef41Sopenharmony_civoid TurboAssembler::LoadF64LE(DoubleRegister dst, const MemOperand& opnd, 38721cb0ef41Sopenharmony_ci Register scratch) { 38731cb0ef41Sopenharmony_ci lrvg(scratch, opnd); 38741cb0ef41Sopenharmony_ci ldgr(dst, scratch); 38751cb0ef41Sopenharmony_ci} 38761cb0ef41Sopenharmony_ci 38771cb0ef41Sopenharmony_civoid TurboAssembler::LoadF32LE(DoubleRegister dst, const MemOperand& opnd, 38781cb0ef41Sopenharmony_ci Register scratch) { 38791cb0ef41Sopenharmony_ci lrv(scratch, opnd); 38801cb0ef41Sopenharmony_ci ShiftLeftU64(scratch, scratch, Operand(32)); 38811cb0ef41Sopenharmony_ci ldgr(dst, scratch); 38821cb0ef41Sopenharmony_ci} 38831cb0ef41Sopenharmony_ci 38841cb0ef41Sopenharmony_civoid TurboAssembler::StoreU64LE(Register src, const MemOperand& mem, 38851cb0ef41Sopenharmony_ci Register scratch) { 38861cb0ef41Sopenharmony_ci if (!is_int20(mem.offset())) { 38871cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 38881cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 38891cb0ef41Sopenharmony_ci mov(scratch, Operand(mem.offset())); 38901cb0ef41Sopenharmony_ci strvg(src, MemOperand(mem.rb(), scratch)); 38911cb0ef41Sopenharmony_ci } else { 38921cb0ef41Sopenharmony_ci strvg(src, mem); 38931cb0ef41Sopenharmony_ci } 38941cb0ef41Sopenharmony_ci} 38951cb0ef41Sopenharmony_ci 38961cb0ef41Sopenharmony_civoid TurboAssembler::StoreU32LE(Register src, const MemOperand& mem, 38971cb0ef41Sopenharmony_ci Register scratch) { 38981cb0ef41Sopenharmony_ci if (!is_int20(mem.offset())) { 38991cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 39001cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 39011cb0ef41Sopenharmony_ci mov(scratch, Operand(mem.offset())); 39021cb0ef41Sopenharmony_ci strv(src, MemOperand(mem.rb(), scratch)); 39031cb0ef41Sopenharmony_ci } else { 39041cb0ef41Sopenharmony_ci strv(src, mem); 39051cb0ef41Sopenharmony_ci } 39061cb0ef41Sopenharmony_ci} 39071cb0ef41Sopenharmony_ci 39081cb0ef41Sopenharmony_civoid TurboAssembler::StoreU16LE(Register src, const MemOperand& mem, 39091cb0ef41Sopenharmony_ci Register scratch) { 39101cb0ef41Sopenharmony_ci if (!is_int20(mem.offset())) { 39111cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 39121cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 39131cb0ef41Sopenharmony_ci mov(scratch, Operand(mem.offset())); 39141cb0ef41Sopenharmony_ci strvh(src, MemOperand(mem.rb(), scratch)); 39151cb0ef41Sopenharmony_ci } else { 39161cb0ef41Sopenharmony_ci strvh(src, mem); 39171cb0ef41Sopenharmony_ci } 39181cb0ef41Sopenharmony_ci} 39191cb0ef41Sopenharmony_ci 39201cb0ef41Sopenharmony_civoid TurboAssembler::StoreF64LE(DoubleRegister src, const MemOperand& opnd, 39211cb0ef41Sopenharmony_ci Register scratch) { 39221cb0ef41Sopenharmony_ci DCHECK(is_uint12(opnd.offset())); 39231cb0ef41Sopenharmony_ci lgdr(scratch, src); 39241cb0ef41Sopenharmony_ci strvg(scratch, opnd); 39251cb0ef41Sopenharmony_ci} 39261cb0ef41Sopenharmony_ci 39271cb0ef41Sopenharmony_civoid TurboAssembler::StoreF32LE(DoubleRegister src, const MemOperand& opnd, 39281cb0ef41Sopenharmony_ci Register scratch) { 39291cb0ef41Sopenharmony_ci DCHECK(is_uint12(opnd.offset())); 39301cb0ef41Sopenharmony_ci lgdr(scratch, src); 39311cb0ef41Sopenharmony_ci ShiftRightU64(scratch, scratch, Operand(32)); 39321cb0ef41Sopenharmony_ci strv(scratch, opnd); 39331cb0ef41Sopenharmony_ci} 39341cb0ef41Sopenharmony_ci 39351cb0ef41Sopenharmony_civoid TurboAssembler::StoreV128LE(Simd128Register src, const MemOperand& mem, 39361cb0ef41Sopenharmony_ci Register scratch1, Register scratch2) { 39371cb0ef41Sopenharmony_ci bool use_vstbr = CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2) && 39381cb0ef41Sopenharmony_ci is_uint12(mem.offset()); 39391cb0ef41Sopenharmony_ci if (use_vstbr) { 39401cb0ef41Sopenharmony_ci vstbr(src, mem, Condition(4)); 39411cb0ef41Sopenharmony_ci } else { 39421cb0ef41Sopenharmony_ci vlgv(scratch1, src, MemOperand(r0, 1), Condition(3)); 39431cb0ef41Sopenharmony_ci vlgv(scratch2, src, MemOperand(r0, 0), Condition(3)); 39441cb0ef41Sopenharmony_ci strvg(scratch1, mem); 39451cb0ef41Sopenharmony_ci strvg(scratch2, 39461cb0ef41Sopenharmony_ci MemOperand(mem.rx(), mem.rb(), mem.offset() + kSystemPointerSize)); 39471cb0ef41Sopenharmony_ci } 39481cb0ef41Sopenharmony_ci} 39491cb0ef41Sopenharmony_ci 39501cb0ef41Sopenharmony_ci#else 39511cb0ef41Sopenharmony_civoid TurboAssembler::LoadU64LE(Register dst, const MemOperand& mem, 39521cb0ef41Sopenharmony_ci Register scratch) { 39531cb0ef41Sopenharmony_ci LoadU64(dst, mem, scratch); 39541cb0ef41Sopenharmony_ci} 39551cb0ef41Sopenharmony_ci 39561cb0ef41Sopenharmony_civoid TurboAssembler::LoadS32LE(Register dst, const MemOperand& opnd, 39571cb0ef41Sopenharmony_ci Register scratch) { 39581cb0ef41Sopenharmony_ci LoadS32(dst, opnd, scratch); 39591cb0ef41Sopenharmony_ci} 39601cb0ef41Sopenharmony_ci 39611cb0ef41Sopenharmony_civoid TurboAssembler::LoadU32LE(Register dst, const MemOperand& opnd, 39621cb0ef41Sopenharmony_ci Register scratch) { 39631cb0ef41Sopenharmony_ci LoadU32(dst, opnd, scratch); 39641cb0ef41Sopenharmony_ci} 39651cb0ef41Sopenharmony_ci 39661cb0ef41Sopenharmony_civoid TurboAssembler::LoadU16LE(Register dst, const MemOperand& opnd) { 39671cb0ef41Sopenharmony_ci LoadU16(dst, opnd); 39681cb0ef41Sopenharmony_ci} 39691cb0ef41Sopenharmony_ci 39701cb0ef41Sopenharmony_civoid TurboAssembler::LoadS16LE(Register dst, const MemOperand& opnd) { 39711cb0ef41Sopenharmony_ci LoadS16(dst, opnd); 39721cb0ef41Sopenharmony_ci} 39731cb0ef41Sopenharmony_ci 39741cb0ef41Sopenharmony_civoid TurboAssembler::LoadV128LE(DoubleRegister dst, const MemOperand& opnd, 39751cb0ef41Sopenharmony_ci Register scratch0, Register scratch1) { 39761cb0ef41Sopenharmony_ci USE(scratch1); 39771cb0ef41Sopenharmony_ci LoadV128(dst, opnd, scratch0); 39781cb0ef41Sopenharmony_ci} 39791cb0ef41Sopenharmony_ci 39801cb0ef41Sopenharmony_civoid TurboAssembler::LoadF64LE(DoubleRegister dst, const MemOperand& opnd, 39811cb0ef41Sopenharmony_ci Register scratch) { 39821cb0ef41Sopenharmony_ci USE(scratch); 39831cb0ef41Sopenharmony_ci LoadF64(dst, opnd); 39841cb0ef41Sopenharmony_ci} 39851cb0ef41Sopenharmony_ci 39861cb0ef41Sopenharmony_civoid TurboAssembler::LoadF32LE(DoubleRegister dst, const MemOperand& opnd, 39871cb0ef41Sopenharmony_ci Register scratch) { 39881cb0ef41Sopenharmony_ci USE(scratch); 39891cb0ef41Sopenharmony_ci LoadF32(dst, opnd); 39901cb0ef41Sopenharmony_ci} 39911cb0ef41Sopenharmony_ci 39921cb0ef41Sopenharmony_civoid TurboAssembler::StoreU64LE(Register src, const MemOperand& mem, 39931cb0ef41Sopenharmony_ci Register scratch) { 39941cb0ef41Sopenharmony_ci StoreU64(src, mem, scratch); 39951cb0ef41Sopenharmony_ci} 39961cb0ef41Sopenharmony_ci 39971cb0ef41Sopenharmony_civoid TurboAssembler::StoreU32LE(Register src, const MemOperand& mem, 39981cb0ef41Sopenharmony_ci Register scratch) { 39991cb0ef41Sopenharmony_ci StoreU32(src, mem, scratch); 40001cb0ef41Sopenharmony_ci} 40011cb0ef41Sopenharmony_ci 40021cb0ef41Sopenharmony_civoid TurboAssembler::StoreU16LE(Register src, const MemOperand& mem, 40031cb0ef41Sopenharmony_ci Register scratch) { 40041cb0ef41Sopenharmony_ci StoreU16(src, mem, scratch); 40051cb0ef41Sopenharmony_ci} 40061cb0ef41Sopenharmony_ci 40071cb0ef41Sopenharmony_civoid TurboAssembler::StoreF64LE(DoubleRegister src, const MemOperand& opnd, 40081cb0ef41Sopenharmony_ci Register scratch) { 40091cb0ef41Sopenharmony_ci StoreF64(src, opnd); 40101cb0ef41Sopenharmony_ci} 40111cb0ef41Sopenharmony_ci 40121cb0ef41Sopenharmony_civoid TurboAssembler::StoreF32LE(DoubleRegister src, const MemOperand& opnd, 40131cb0ef41Sopenharmony_ci Register scratch) { 40141cb0ef41Sopenharmony_ci StoreF32(src, opnd); 40151cb0ef41Sopenharmony_ci} 40161cb0ef41Sopenharmony_ci 40171cb0ef41Sopenharmony_civoid TurboAssembler::StoreV128LE(Simd128Register src, const MemOperand& mem, 40181cb0ef41Sopenharmony_ci Register scratch1, Register scratch2) { 40191cb0ef41Sopenharmony_ci StoreV128(src, mem, scratch1); 40201cb0ef41Sopenharmony_ci} 40211cb0ef41Sopenharmony_ci 40221cb0ef41Sopenharmony_ci#endif 40231cb0ef41Sopenharmony_ci 40241cb0ef41Sopenharmony_ci// Load And Test (Reg <- Reg) 40251cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndTest32(Register dst, Register src) { 40261cb0ef41Sopenharmony_ci ltr(dst, src); 40271cb0ef41Sopenharmony_ci} 40281cb0ef41Sopenharmony_ci 40291cb0ef41Sopenharmony_ci// Load And Test Pointer Sized (Reg <- Reg) 40301cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndTestP(Register dst, Register src) { 40311cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 40321cb0ef41Sopenharmony_ci ltgr(dst, src); 40331cb0ef41Sopenharmony_ci#else 40341cb0ef41Sopenharmony_ci ltr(dst, src); 40351cb0ef41Sopenharmony_ci#endif 40361cb0ef41Sopenharmony_ci} 40371cb0ef41Sopenharmony_ci 40381cb0ef41Sopenharmony_ci// Load And Test 32-bit (Reg <- Mem) 40391cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndTest32(Register dst, const MemOperand& mem) { 40401cb0ef41Sopenharmony_ci lt_z(dst, mem); 40411cb0ef41Sopenharmony_ci} 40421cb0ef41Sopenharmony_ci 40431cb0ef41Sopenharmony_ci// Load And Test Pointer Sized (Reg <- Mem) 40441cb0ef41Sopenharmony_civoid TurboAssembler::LoadAndTestP(Register dst, const MemOperand& mem) { 40451cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 40461cb0ef41Sopenharmony_ci ltg(dst, mem); 40471cb0ef41Sopenharmony_ci#else 40481cb0ef41Sopenharmony_ci lt_z(dst, mem); 40491cb0ef41Sopenharmony_ci#endif 40501cb0ef41Sopenharmony_ci} 40511cb0ef41Sopenharmony_ci 40521cb0ef41Sopenharmony_ci// Load On Condition Pointer Sized (Reg <- Reg) 40531cb0ef41Sopenharmony_civoid TurboAssembler::LoadOnConditionP(Condition cond, Register dst, 40541cb0ef41Sopenharmony_ci Register src) { 40551cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 40561cb0ef41Sopenharmony_ci locgr(cond, dst, src); 40571cb0ef41Sopenharmony_ci#else 40581cb0ef41Sopenharmony_ci locr(cond, dst, src); 40591cb0ef41Sopenharmony_ci#endif 40601cb0ef41Sopenharmony_ci} 40611cb0ef41Sopenharmony_ci 40621cb0ef41Sopenharmony_ci// Load Double Precision (64-bit) Floating Point number from memory 40631cb0ef41Sopenharmony_civoid TurboAssembler::LoadF64(DoubleRegister dst, const MemOperand& mem) { 40641cb0ef41Sopenharmony_ci // for 32bit and 64bit we all use 64bit floating point regs 40651cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 40661cb0ef41Sopenharmony_ci ld(dst, mem); 40671cb0ef41Sopenharmony_ci } else { 40681cb0ef41Sopenharmony_ci ldy(dst, mem); 40691cb0ef41Sopenharmony_ci } 40701cb0ef41Sopenharmony_ci} 40711cb0ef41Sopenharmony_ci 40721cb0ef41Sopenharmony_ci// Load Single Precision (32-bit) Floating Point number from memory 40731cb0ef41Sopenharmony_civoid TurboAssembler::LoadF32(DoubleRegister dst, const MemOperand& mem) { 40741cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 40751cb0ef41Sopenharmony_ci le_z(dst, mem); 40761cb0ef41Sopenharmony_ci } else { 40771cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 40781cb0ef41Sopenharmony_ci ley(dst, mem); 40791cb0ef41Sopenharmony_ci } 40801cb0ef41Sopenharmony_ci} 40811cb0ef41Sopenharmony_ci 40821cb0ef41Sopenharmony_civoid TurboAssembler::LoadV128(Simd128Register dst, const MemOperand& mem, 40831cb0ef41Sopenharmony_ci Register scratch) { 40841cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 40851cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 40861cb0ef41Sopenharmony_ci vl(dst, mem, Condition(0)); 40871cb0ef41Sopenharmony_ci } else { 40881cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 40891cb0ef41Sopenharmony_ci lay(scratch, mem); 40901cb0ef41Sopenharmony_ci vl(dst, MemOperand(scratch), Condition(0)); 40911cb0ef41Sopenharmony_ci } 40921cb0ef41Sopenharmony_ci} 40931cb0ef41Sopenharmony_ci 40941cb0ef41Sopenharmony_ci// Store Double Precision (64-bit) Floating Point number to memory 40951cb0ef41Sopenharmony_civoid TurboAssembler::StoreF64(DoubleRegister dst, const MemOperand& mem) { 40961cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 40971cb0ef41Sopenharmony_ci std(dst, mem); 40981cb0ef41Sopenharmony_ci } else { 40991cb0ef41Sopenharmony_ci stdy(dst, mem); 41001cb0ef41Sopenharmony_ci } 41011cb0ef41Sopenharmony_ci} 41021cb0ef41Sopenharmony_ci 41031cb0ef41Sopenharmony_ci// Store Single Precision (32-bit) Floating Point number to memory 41041cb0ef41Sopenharmony_civoid TurboAssembler::StoreF32(DoubleRegister src, const MemOperand& mem) { 41051cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 41061cb0ef41Sopenharmony_ci ste(src, mem); 41071cb0ef41Sopenharmony_ci } else { 41081cb0ef41Sopenharmony_ci stey(src, mem); 41091cb0ef41Sopenharmony_ci } 41101cb0ef41Sopenharmony_ci} 41111cb0ef41Sopenharmony_ci 41121cb0ef41Sopenharmony_civoid TurboAssembler::StoreV128(Simd128Register src, const MemOperand& mem, 41131cb0ef41Sopenharmony_ci Register scratch) { 41141cb0ef41Sopenharmony_ci DCHECK(scratch != r0); 41151cb0ef41Sopenharmony_ci if (is_uint12(mem.offset())) { 41161cb0ef41Sopenharmony_ci vst(src, mem, Condition(0)); 41171cb0ef41Sopenharmony_ci } else { 41181cb0ef41Sopenharmony_ci DCHECK(is_int20(mem.offset())); 41191cb0ef41Sopenharmony_ci lay(scratch, mem); 41201cb0ef41Sopenharmony_ci vst(src, MemOperand(scratch), Condition(0)); 41211cb0ef41Sopenharmony_ci } 41221cb0ef41Sopenharmony_ci} 41231cb0ef41Sopenharmony_ci 41241cb0ef41Sopenharmony_civoid TurboAssembler::AddF32(DoubleRegister dst, DoubleRegister lhs, 41251cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41261cb0ef41Sopenharmony_ci if (dst == lhs) { 41271cb0ef41Sopenharmony_ci aebr(dst, rhs); 41281cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41291cb0ef41Sopenharmony_ci aebr(dst, lhs); 41301cb0ef41Sopenharmony_ci } else { 41311cb0ef41Sopenharmony_ci ler(dst, lhs); 41321cb0ef41Sopenharmony_ci aebr(dst, rhs); 41331cb0ef41Sopenharmony_ci } 41341cb0ef41Sopenharmony_ci} 41351cb0ef41Sopenharmony_ci 41361cb0ef41Sopenharmony_civoid TurboAssembler::SubF32(DoubleRegister dst, DoubleRegister lhs, 41371cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41381cb0ef41Sopenharmony_ci if (dst == lhs) { 41391cb0ef41Sopenharmony_ci sebr(dst, rhs); 41401cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41411cb0ef41Sopenharmony_ci sebr(dst, lhs); 41421cb0ef41Sopenharmony_ci lcebr(dst, dst); 41431cb0ef41Sopenharmony_ci } else { 41441cb0ef41Sopenharmony_ci ler(dst, lhs); 41451cb0ef41Sopenharmony_ci sebr(dst, rhs); 41461cb0ef41Sopenharmony_ci } 41471cb0ef41Sopenharmony_ci} 41481cb0ef41Sopenharmony_ci 41491cb0ef41Sopenharmony_civoid TurboAssembler::MulF32(DoubleRegister dst, DoubleRegister lhs, 41501cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41511cb0ef41Sopenharmony_ci if (dst == lhs) { 41521cb0ef41Sopenharmony_ci meebr(dst, rhs); 41531cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41541cb0ef41Sopenharmony_ci meebr(dst, lhs); 41551cb0ef41Sopenharmony_ci } else { 41561cb0ef41Sopenharmony_ci ler(dst, lhs); 41571cb0ef41Sopenharmony_ci meebr(dst, rhs); 41581cb0ef41Sopenharmony_ci } 41591cb0ef41Sopenharmony_ci} 41601cb0ef41Sopenharmony_ci 41611cb0ef41Sopenharmony_civoid TurboAssembler::DivF32(DoubleRegister dst, DoubleRegister lhs, 41621cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41631cb0ef41Sopenharmony_ci if (dst == lhs) { 41641cb0ef41Sopenharmony_ci debr(dst, rhs); 41651cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41661cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kSystemPointerSize)); 41671cb0ef41Sopenharmony_ci StoreF32(dst, MemOperand(sp)); 41681cb0ef41Sopenharmony_ci ler(dst, lhs); 41691cb0ef41Sopenharmony_ci deb(dst, MemOperand(sp)); 41701cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, kSystemPointerSize)); 41711cb0ef41Sopenharmony_ci } else { 41721cb0ef41Sopenharmony_ci ler(dst, lhs); 41731cb0ef41Sopenharmony_ci debr(dst, rhs); 41741cb0ef41Sopenharmony_ci } 41751cb0ef41Sopenharmony_ci} 41761cb0ef41Sopenharmony_ci 41771cb0ef41Sopenharmony_civoid TurboAssembler::AddF64(DoubleRegister dst, DoubleRegister lhs, 41781cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41791cb0ef41Sopenharmony_ci if (dst == lhs) { 41801cb0ef41Sopenharmony_ci adbr(dst, rhs); 41811cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41821cb0ef41Sopenharmony_ci adbr(dst, lhs); 41831cb0ef41Sopenharmony_ci } else { 41841cb0ef41Sopenharmony_ci ldr(dst, lhs); 41851cb0ef41Sopenharmony_ci adbr(dst, rhs); 41861cb0ef41Sopenharmony_ci } 41871cb0ef41Sopenharmony_ci} 41881cb0ef41Sopenharmony_ci 41891cb0ef41Sopenharmony_civoid TurboAssembler::SubF64(DoubleRegister dst, DoubleRegister lhs, 41901cb0ef41Sopenharmony_ci DoubleRegister rhs) { 41911cb0ef41Sopenharmony_ci if (dst == lhs) { 41921cb0ef41Sopenharmony_ci sdbr(dst, rhs); 41931cb0ef41Sopenharmony_ci } else if (dst == rhs) { 41941cb0ef41Sopenharmony_ci sdbr(dst, lhs); 41951cb0ef41Sopenharmony_ci lcdbr(dst, dst); 41961cb0ef41Sopenharmony_ci } else { 41971cb0ef41Sopenharmony_ci ldr(dst, lhs); 41981cb0ef41Sopenharmony_ci sdbr(dst, rhs); 41991cb0ef41Sopenharmony_ci } 42001cb0ef41Sopenharmony_ci} 42011cb0ef41Sopenharmony_ci 42021cb0ef41Sopenharmony_civoid TurboAssembler::MulF64(DoubleRegister dst, DoubleRegister lhs, 42031cb0ef41Sopenharmony_ci DoubleRegister rhs) { 42041cb0ef41Sopenharmony_ci if (dst == lhs) { 42051cb0ef41Sopenharmony_ci mdbr(dst, rhs); 42061cb0ef41Sopenharmony_ci } else if (dst == rhs) { 42071cb0ef41Sopenharmony_ci mdbr(dst, lhs); 42081cb0ef41Sopenharmony_ci } else { 42091cb0ef41Sopenharmony_ci ldr(dst, lhs); 42101cb0ef41Sopenharmony_ci mdbr(dst, rhs); 42111cb0ef41Sopenharmony_ci } 42121cb0ef41Sopenharmony_ci} 42131cb0ef41Sopenharmony_ci 42141cb0ef41Sopenharmony_civoid TurboAssembler::DivF64(DoubleRegister dst, DoubleRegister lhs, 42151cb0ef41Sopenharmony_ci DoubleRegister rhs) { 42161cb0ef41Sopenharmony_ci if (dst == lhs) { 42171cb0ef41Sopenharmony_ci ddbr(dst, rhs); 42181cb0ef41Sopenharmony_ci } else if (dst == rhs) { 42191cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kSystemPointerSize)); 42201cb0ef41Sopenharmony_ci StoreF64(dst, MemOperand(sp)); 42211cb0ef41Sopenharmony_ci ldr(dst, lhs); 42221cb0ef41Sopenharmony_ci ddb(dst, MemOperand(sp)); 42231cb0ef41Sopenharmony_ci la(sp, MemOperand(sp, kSystemPointerSize)); 42241cb0ef41Sopenharmony_ci } else { 42251cb0ef41Sopenharmony_ci ldr(dst, lhs); 42261cb0ef41Sopenharmony_ci ddbr(dst, rhs); 42271cb0ef41Sopenharmony_ci } 42281cb0ef41Sopenharmony_ci} 42291cb0ef41Sopenharmony_ci 42301cb0ef41Sopenharmony_civoid TurboAssembler::AddFloat32(DoubleRegister dst, const MemOperand& opnd, 42311cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42321cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42331cb0ef41Sopenharmony_ci aeb(dst, opnd); 42341cb0ef41Sopenharmony_ci } else { 42351cb0ef41Sopenharmony_ci ley(scratch, opnd); 42361cb0ef41Sopenharmony_ci aebr(dst, scratch); 42371cb0ef41Sopenharmony_ci } 42381cb0ef41Sopenharmony_ci} 42391cb0ef41Sopenharmony_ci 42401cb0ef41Sopenharmony_civoid TurboAssembler::AddFloat64(DoubleRegister dst, const MemOperand& opnd, 42411cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42421cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42431cb0ef41Sopenharmony_ci adb(dst, opnd); 42441cb0ef41Sopenharmony_ci } else { 42451cb0ef41Sopenharmony_ci ldy(scratch, opnd); 42461cb0ef41Sopenharmony_ci adbr(dst, scratch); 42471cb0ef41Sopenharmony_ci } 42481cb0ef41Sopenharmony_ci} 42491cb0ef41Sopenharmony_ci 42501cb0ef41Sopenharmony_civoid TurboAssembler::SubFloat32(DoubleRegister dst, const MemOperand& opnd, 42511cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42521cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42531cb0ef41Sopenharmony_ci seb(dst, opnd); 42541cb0ef41Sopenharmony_ci } else { 42551cb0ef41Sopenharmony_ci ley(scratch, opnd); 42561cb0ef41Sopenharmony_ci sebr(dst, scratch); 42571cb0ef41Sopenharmony_ci } 42581cb0ef41Sopenharmony_ci} 42591cb0ef41Sopenharmony_ci 42601cb0ef41Sopenharmony_civoid TurboAssembler::SubFloat64(DoubleRegister dst, const MemOperand& opnd, 42611cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42621cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42631cb0ef41Sopenharmony_ci sdb(dst, opnd); 42641cb0ef41Sopenharmony_ci } else { 42651cb0ef41Sopenharmony_ci ldy(scratch, opnd); 42661cb0ef41Sopenharmony_ci sdbr(dst, scratch); 42671cb0ef41Sopenharmony_ci } 42681cb0ef41Sopenharmony_ci} 42691cb0ef41Sopenharmony_ci 42701cb0ef41Sopenharmony_civoid TurboAssembler::MulFloat32(DoubleRegister dst, const MemOperand& opnd, 42711cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42721cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42731cb0ef41Sopenharmony_ci meeb(dst, opnd); 42741cb0ef41Sopenharmony_ci } else { 42751cb0ef41Sopenharmony_ci ley(scratch, opnd); 42761cb0ef41Sopenharmony_ci meebr(dst, scratch); 42771cb0ef41Sopenharmony_ci } 42781cb0ef41Sopenharmony_ci} 42791cb0ef41Sopenharmony_ci 42801cb0ef41Sopenharmony_civoid TurboAssembler::MulFloat64(DoubleRegister dst, const MemOperand& opnd, 42811cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42821cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42831cb0ef41Sopenharmony_ci mdb(dst, opnd); 42841cb0ef41Sopenharmony_ci } else { 42851cb0ef41Sopenharmony_ci ldy(scratch, opnd); 42861cb0ef41Sopenharmony_ci mdbr(dst, scratch); 42871cb0ef41Sopenharmony_ci } 42881cb0ef41Sopenharmony_ci} 42891cb0ef41Sopenharmony_ci 42901cb0ef41Sopenharmony_civoid TurboAssembler::DivFloat32(DoubleRegister dst, const MemOperand& opnd, 42911cb0ef41Sopenharmony_ci DoubleRegister scratch) { 42921cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 42931cb0ef41Sopenharmony_ci deb(dst, opnd); 42941cb0ef41Sopenharmony_ci } else { 42951cb0ef41Sopenharmony_ci ley(scratch, opnd); 42961cb0ef41Sopenharmony_ci debr(dst, scratch); 42971cb0ef41Sopenharmony_ci } 42981cb0ef41Sopenharmony_ci} 42991cb0ef41Sopenharmony_ci 43001cb0ef41Sopenharmony_civoid TurboAssembler::DivFloat64(DoubleRegister dst, const MemOperand& opnd, 43011cb0ef41Sopenharmony_ci DoubleRegister scratch) { 43021cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 43031cb0ef41Sopenharmony_ci ddb(dst, opnd); 43041cb0ef41Sopenharmony_ci } else { 43051cb0ef41Sopenharmony_ci ldy(scratch, opnd); 43061cb0ef41Sopenharmony_ci ddbr(dst, scratch); 43071cb0ef41Sopenharmony_ci } 43081cb0ef41Sopenharmony_ci} 43091cb0ef41Sopenharmony_ci 43101cb0ef41Sopenharmony_civoid TurboAssembler::LoadF32AsF64(DoubleRegister dst, const MemOperand& opnd, 43111cb0ef41Sopenharmony_ci DoubleRegister scratch) { 43121cb0ef41Sopenharmony_ci if (is_uint12(opnd.offset())) { 43131cb0ef41Sopenharmony_ci ldeb(dst, opnd); 43141cb0ef41Sopenharmony_ci } else { 43151cb0ef41Sopenharmony_ci ley(scratch, opnd); 43161cb0ef41Sopenharmony_ci ldebr(dst, scratch); 43171cb0ef41Sopenharmony_ci } 43181cb0ef41Sopenharmony_ci} 43191cb0ef41Sopenharmony_ci 43201cb0ef41Sopenharmony_ci// Variable length depending on whether offset fits into immediate field 43211cb0ef41Sopenharmony_ci// MemOperand of RX or RXY format 43221cb0ef41Sopenharmony_civoid TurboAssembler::StoreU32(Register src, const MemOperand& mem, 43231cb0ef41Sopenharmony_ci Register scratch) { 43241cb0ef41Sopenharmony_ci Register base = mem.rb(); 43251cb0ef41Sopenharmony_ci int offset = mem.offset(); 43261cb0ef41Sopenharmony_ci 43271cb0ef41Sopenharmony_ci bool use_RXform = false; 43281cb0ef41Sopenharmony_ci bool use_RXYform = false; 43291cb0ef41Sopenharmony_ci 43301cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 43311cb0ef41Sopenharmony_ci // RX-format supports unsigned 12-bits offset. 43321cb0ef41Sopenharmony_ci use_RXform = true; 43331cb0ef41Sopenharmony_ci } else if (is_int20(offset)) { 43341cb0ef41Sopenharmony_ci // RXY-format supports signed 20-bits offset. 43351cb0ef41Sopenharmony_ci use_RXYform = true; 43361cb0ef41Sopenharmony_ci } else if (scratch != no_reg) { 43371cb0ef41Sopenharmony_ci // Materialize offset into scratch register. 43381cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 43391cb0ef41Sopenharmony_ci } else { 43401cb0ef41Sopenharmony_ci // scratch is no_reg 43411cb0ef41Sopenharmony_ci DCHECK(false); 43421cb0ef41Sopenharmony_ci } 43431cb0ef41Sopenharmony_ci 43441cb0ef41Sopenharmony_ci if (use_RXform) { 43451cb0ef41Sopenharmony_ci st(src, mem); 43461cb0ef41Sopenharmony_ci } else if (use_RXYform) { 43471cb0ef41Sopenharmony_ci sty(src, mem); 43481cb0ef41Sopenharmony_ci } else { 43491cb0ef41Sopenharmony_ci StoreU32(src, MemOperand(base, scratch)); 43501cb0ef41Sopenharmony_ci } 43511cb0ef41Sopenharmony_ci} 43521cb0ef41Sopenharmony_ci 43531cb0ef41Sopenharmony_civoid TurboAssembler::LoadS16(Register dst, Register src) { 43541cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 43551cb0ef41Sopenharmony_ci lghr(dst, src); 43561cb0ef41Sopenharmony_ci#else 43571cb0ef41Sopenharmony_ci lhr(dst, src); 43581cb0ef41Sopenharmony_ci#endif 43591cb0ef41Sopenharmony_ci} 43601cb0ef41Sopenharmony_ci 43611cb0ef41Sopenharmony_ci// Loads 16-bits half-word value from memory and sign extends to pointer 43621cb0ef41Sopenharmony_ci// sized register 43631cb0ef41Sopenharmony_civoid TurboAssembler::LoadS16(Register dst, const MemOperand& mem, 43641cb0ef41Sopenharmony_ci Register scratch) { 43651cb0ef41Sopenharmony_ci Register base = mem.rb(); 43661cb0ef41Sopenharmony_ci int offset = mem.offset(); 43671cb0ef41Sopenharmony_ci 43681cb0ef41Sopenharmony_ci if (!is_int20(offset)) { 43691cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 43701cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 43711cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 43721cb0ef41Sopenharmony_ci lgh(dst, MemOperand(base, scratch)); 43731cb0ef41Sopenharmony_ci#else 43741cb0ef41Sopenharmony_ci lh(dst, MemOperand(base, scratch)); 43751cb0ef41Sopenharmony_ci#endif 43761cb0ef41Sopenharmony_ci } else { 43771cb0ef41Sopenharmony_ci#if V8_TARGET_ARCH_S390X 43781cb0ef41Sopenharmony_ci lgh(dst, mem); 43791cb0ef41Sopenharmony_ci#else 43801cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 43811cb0ef41Sopenharmony_ci lh(dst, mem); 43821cb0ef41Sopenharmony_ci } else { 43831cb0ef41Sopenharmony_ci lhy(dst, mem); 43841cb0ef41Sopenharmony_ci } 43851cb0ef41Sopenharmony_ci#endif 43861cb0ef41Sopenharmony_ci } 43871cb0ef41Sopenharmony_ci} 43881cb0ef41Sopenharmony_ci 43891cb0ef41Sopenharmony_ci// Variable length depending on whether offset fits into immediate field 43901cb0ef41Sopenharmony_ci// MemOperand current only supports d-form 43911cb0ef41Sopenharmony_civoid TurboAssembler::StoreU16(Register src, const MemOperand& mem, 43921cb0ef41Sopenharmony_ci Register scratch) { 43931cb0ef41Sopenharmony_ci Register base = mem.rb(); 43941cb0ef41Sopenharmony_ci int offset = mem.offset(); 43951cb0ef41Sopenharmony_ci 43961cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 43971cb0ef41Sopenharmony_ci sth(src, mem); 43981cb0ef41Sopenharmony_ci } else if (is_int20(offset)) { 43991cb0ef41Sopenharmony_ci sthy(src, mem); 44001cb0ef41Sopenharmony_ci } else { 44011cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 44021cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 44031cb0ef41Sopenharmony_ci sth(src, MemOperand(base, scratch)); 44041cb0ef41Sopenharmony_ci } 44051cb0ef41Sopenharmony_ci} 44061cb0ef41Sopenharmony_ci 44071cb0ef41Sopenharmony_ci// Variable length depending on whether offset fits into immediate field 44081cb0ef41Sopenharmony_ci// MemOperand current only supports d-form 44091cb0ef41Sopenharmony_civoid TurboAssembler::StoreU8(Register src, const MemOperand& mem, 44101cb0ef41Sopenharmony_ci Register scratch) { 44111cb0ef41Sopenharmony_ci Register base = mem.rb(); 44121cb0ef41Sopenharmony_ci int offset = mem.offset(); 44131cb0ef41Sopenharmony_ci 44141cb0ef41Sopenharmony_ci if (is_uint12(offset)) { 44151cb0ef41Sopenharmony_ci stc(src, mem); 44161cb0ef41Sopenharmony_ci } else if (is_int20(offset)) { 44171cb0ef41Sopenharmony_ci stcy(src, mem); 44181cb0ef41Sopenharmony_ci } else { 44191cb0ef41Sopenharmony_ci DCHECK(scratch != no_reg); 44201cb0ef41Sopenharmony_ci mov(scratch, Operand(offset)); 44211cb0ef41Sopenharmony_ci stc(src, MemOperand(base, scratch)); 44221cb0ef41Sopenharmony_ci } 44231cb0ef41Sopenharmony_ci} 44241cb0ef41Sopenharmony_ci 44251cb0ef41Sopenharmony_ci// Shift left logical for 32-bit integer types. 44261cb0ef41Sopenharmony_civoid TurboAssembler::ShiftLeftU32(Register dst, Register src, 44271cb0ef41Sopenharmony_ci const Operand& val) { 44281cb0ef41Sopenharmony_ci ShiftLeftU32(dst, src, r0, val); 44291cb0ef41Sopenharmony_ci} 44301cb0ef41Sopenharmony_ci 44311cb0ef41Sopenharmony_ci// Shift left logical for 32-bit integer types. 44321cb0ef41Sopenharmony_civoid TurboAssembler::ShiftLeftU32(Register dst, Register src, Register val, 44331cb0ef41Sopenharmony_ci const Operand& val2) { 44341cb0ef41Sopenharmony_ci if (dst == src) { 44351cb0ef41Sopenharmony_ci sll(dst, val, val2); 44361cb0ef41Sopenharmony_ci } else if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 44371cb0ef41Sopenharmony_ci sllk(dst, src, val, val2); 44381cb0ef41Sopenharmony_ci } else { 44391cb0ef41Sopenharmony_ci DCHECK(dst != val || val == r0); // The lr/sll path clobbers val. 44401cb0ef41Sopenharmony_ci lr(dst, src); 44411cb0ef41Sopenharmony_ci sll(dst, val, val2); 44421cb0ef41Sopenharmony_ci } 44431cb0ef41Sopenharmony_ci} 44441cb0ef41Sopenharmony_ci 44451cb0ef41Sopenharmony_ci// Shift left logical for 32-bit integer types. 44461cb0ef41Sopenharmony_civoid TurboAssembler::ShiftLeftU64(Register dst, Register src, 44471cb0ef41Sopenharmony_ci const Operand& val) { 44481cb0ef41Sopenharmony_ci ShiftLeftU64(dst, src, r0, val); 44491cb0ef41Sopenharmony_ci} 44501cb0ef41Sopenharmony_ci 44511cb0ef41Sopenharmony_ci// Shift left logical for 32-bit integer types. 44521cb0ef41Sopenharmony_civoid TurboAssembler::ShiftLeftU64(Register dst, Register src, Register val, 44531cb0ef41Sopenharmony_ci const Operand& val2) { 44541cb0ef41Sopenharmony_ci sllg(dst, src, val, val2); 44551cb0ef41Sopenharmony_ci} 44561cb0ef41Sopenharmony_ci 44571cb0ef41Sopenharmony_ci// Shift right logical for 32-bit integer types. 44581cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightU32(Register dst, Register src, 44591cb0ef41Sopenharmony_ci const Operand& val) { 44601cb0ef41Sopenharmony_ci ShiftRightU32(dst, src, r0, val); 44611cb0ef41Sopenharmony_ci} 44621cb0ef41Sopenharmony_ci 44631cb0ef41Sopenharmony_ci// Shift right logical for 32-bit integer types. 44641cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightU32(Register dst, Register src, Register val, 44651cb0ef41Sopenharmony_ci const Operand& val2) { 44661cb0ef41Sopenharmony_ci if (dst == src) { 44671cb0ef41Sopenharmony_ci srl(dst, val, val2); 44681cb0ef41Sopenharmony_ci } else if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 44691cb0ef41Sopenharmony_ci srlk(dst, src, val, val2); 44701cb0ef41Sopenharmony_ci } else { 44711cb0ef41Sopenharmony_ci DCHECK(dst != val || val == r0); // The lr/srl path clobbers val. 44721cb0ef41Sopenharmony_ci lr(dst, src); 44731cb0ef41Sopenharmony_ci srl(dst, val, val2); 44741cb0ef41Sopenharmony_ci } 44751cb0ef41Sopenharmony_ci} 44761cb0ef41Sopenharmony_ci 44771cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightU64(Register dst, Register src, Register val, 44781cb0ef41Sopenharmony_ci const Operand& val2) { 44791cb0ef41Sopenharmony_ci srlg(dst, src, val, val2); 44801cb0ef41Sopenharmony_ci} 44811cb0ef41Sopenharmony_ci 44821cb0ef41Sopenharmony_ci// Shift right logical for 64-bit integer types. 44831cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightU64(Register dst, Register src, 44841cb0ef41Sopenharmony_ci const Operand& val) { 44851cb0ef41Sopenharmony_ci ShiftRightU64(dst, src, r0, val); 44861cb0ef41Sopenharmony_ci} 44871cb0ef41Sopenharmony_ci 44881cb0ef41Sopenharmony_ci// Shift right arithmetic for 32-bit integer types. 44891cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightS32(Register dst, Register src, 44901cb0ef41Sopenharmony_ci const Operand& val) { 44911cb0ef41Sopenharmony_ci ShiftRightS32(dst, src, r0, val); 44921cb0ef41Sopenharmony_ci} 44931cb0ef41Sopenharmony_ci 44941cb0ef41Sopenharmony_ci// Shift right arithmetic for 32-bit integer types. 44951cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightS32(Register dst, Register src, Register val, 44961cb0ef41Sopenharmony_ci const Operand& val2) { 44971cb0ef41Sopenharmony_ci if (dst == src) { 44981cb0ef41Sopenharmony_ci sra(dst, val, val2); 44991cb0ef41Sopenharmony_ci } else if (CpuFeatures::IsSupported(DISTINCT_OPS)) { 45001cb0ef41Sopenharmony_ci srak(dst, src, val, val2); 45011cb0ef41Sopenharmony_ci } else { 45021cb0ef41Sopenharmony_ci DCHECK(dst != val || val == r0); // The lr/sra path clobbers val. 45031cb0ef41Sopenharmony_ci lr(dst, src); 45041cb0ef41Sopenharmony_ci sra(dst, val, val2); 45051cb0ef41Sopenharmony_ci } 45061cb0ef41Sopenharmony_ci} 45071cb0ef41Sopenharmony_ci 45081cb0ef41Sopenharmony_ci// Shift right arithmetic for 64-bit integer types. 45091cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightS64(Register dst, Register src, 45101cb0ef41Sopenharmony_ci const Operand& val) { 45111cb0ef41Sopenharmony_ci ShiftRightS64(dst, src, r0, val); 45121cb0ef41Sopenharmony_ci} 45131cb0ef41Sopenharmony_ci 45141cb0ef41Sopenharmony_ci// Shift right arithmetic for 64-bit integer types. 45151cb0ef41Sopenharmony_civoid TurboAssembler::ShiftRightS64(Register dst, Register src, Register val, 45161cb0ef41Sopenharmony_ci const Operand& val2) { 45171cb0ef41Sopenharmony_ci srag(dst, src, val, val2); 45181cb0ef41Sopenharmony_ci} 45191cb0ef41Sopenharmony_ci 45201cb0ef41Sopenharmony_ci// Clear right most # of bits 45211cb0ef41Sopenharmony_civoid TurboAssembler::ClearRightImm(Register dst, Register src, 45221cb0ef41Sopenharmony_ci const Operand& val) { 45231cb0ef41Sopenharmony_ci int numBitsToClear = val.immediate() % (kSystemPointerSize * 8); 45241cb0ef41Sopenharmony_ci 45251cb0ef41Sopenharmony_ci // Try to use RISBG if possible 45261cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(GENERAL_INSTR_EXT)) { 45271cb0ef41Sopenharmony_ci int endBit = 63 - numBitsToClear; 45281cb0ef41Sopenharmony_ci RotateInsertSelectBits(dst, src, Operand::Zero(), Operand(endBit), 45291cb0ef41Sopenharmony_ci Operand::Zero(), true); 45301cb0ef41Sopenharmony_ci return; 45311cb0ef41Sopenharmony_ci } 45321cb0ef41Sopenharmony_ci 45331cb0ef41Sopenharmony_ci uint64_t hexMask = ~((1L << numBitsToClear) - 1); 45341cb0ef41Sopenharmony_ci 45351cb0ef41Sopenharmony_ci // S390 AND instr clobbers source. Make a copy if necessary 45361cb0ef41Sopenharmony_ci if (dst != src) mov(dst, src); 45371cb0ef41Sopenharmony_ci 45381cb0ef41Sopenharmony_ci if (numBitsToClear <= 16) { 45391cb0ef41Sopenharmony_ci nill(dst, Operand(static_cast<uint16_t>(hexMask))); 45401cb0ef41Sopenharmony_ci } else if (numBitsToClear <= 32) { 45411cb0ef41Sopenharmony_ci nilf(dst, Operand(static_cast<uint32_t>(hexMask))); 45421cb0ef41Sopenharmony_ci } else if (numBitsToClear <= 64) { 45431cb0ef41Sopenharmony_ci nilf(dst, Operand(static_cast<intptr_t>(0))); 45441cb0ef41Sopenharmony_ci nihf(dst, Operand(hexMask >> 32)); 45451cb0ef41Sopenharmony_ci } 45461cb0ef41Sopenharmony_ci} 45471cb0ef41Sopenharmony_ci 45481cb0ef41Sopenharmony_civoid TurboAssembler::Popcnt32(Register dst, Register src) { 45491cb0ef41Sopenharmony_ci DCHECK(src != r0); 45501cb0ef41Sopenharmony_ci DCHECK(dst != r0); 45511cb0ef41Sopenharmony_ci 45521cb0ef41Sopenharmony_ci popcnt(dst, src); 45531cb0ef41Sopenharmony_ci ShiftRightU32(r0, dst, Operand(16)); 45541cb0ef41Sopenharmony_ci ar(dst, r0); 45551cb0ef41Sopenharmony_ci ShiftRightU32(r0, dst, Operand(8)); 45561cb0ef41Sopenharmony_ci ar(dst, r0); 45571cb0ef41Sopenharmony_ci llgcr(dst, dst); 45581cb0ef41Sopenharmony_ci} 45591cb0ef41Sopenharmony_ci 45601cb0ef41Sopenharmony_ci#ifdef V8_TARGET_ARCH_S390X 45611cb0ef41Sopenharmony_civoid TurboAssembler::Popcnt64(Register dst, Register src) { 45621cb0ef41Sopenharmony_ci DCHECK(src != r0); 45631cb0ef41Sopenharmony_ci DCHECK(dst != r0); 45641cb0ef41Sopenharmony_ci 45651cb0ef41Sopenharmony_ci popcnt(dst, src); 45661cb0ef41Sopenharmony_ci ShiftRightU64(r0, dst, Operand(32)); 45671cb0ef41Sopenharmony_ci AddS64(dst, r0); 45681cb0ef41Sopenharmony_ci ShiftRightU64(r0, dst, Operand(16)); 45691cb0ef41Sopenharmony_ci AddS64(dst, r0); 45701cb0ef41Sopenharmony_ci ShiftRightU64(r0, dst, Operand(8)); 45711cb0ef41Sopenharmony_ci AddS64(dst, r0); 45721cb0ef41Sopenharmony_ci LoadU8(dst, dst); 45731cb0ef41Sopenharmony_ci} 45741cb0ef41Sopenharmony_ci#endif 45751cb0ef41Sopenharmony_ci 45761cb0ef41Sopenharmony_civoid TurboAssembler::SwapP(Register src, Register dst, Register scratch) { 45771cb0ef41Sopenharmony_ci if (src == dst) return; 45781cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, dst, scratch)); 45791cb0ef41Sopenharmony_ci mov(scratch, src); 45801cb0ef41Sopenharmony_ci mov(src, dst); 45811cb0ef41Sopenharmony_ci mov(dst, scratch); 45821cb0ef41Sopenharmony_ci} 45831cb0ef41Sopenharmony_ci 45841cb0ef41Sopenharmony_civoid TurboAssembler::SwapP(Register src, MemOperand dst, Register scratch) { 45851cb0ef41Sopenharmony_ci if (dst.rx() != r0) DCHECK(!AreAliased(src, dst.rx(), scratch)); 45861cb0ef41Sopenharmony_ci if (dst.rb() != r0) DCHECK(!AreAliased(src, dst.rb(), scratch)); 45871cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch)); 45881cb0ef41Sopenharmony_ci mov(scratch, src); 45891cb0ef41Sopenharmony_ci LoadU64(src, dst); 45901cb0ef41Sopenharmony_ci StoreU64(scratch, dst); 45911cb0ef41Sopenharmony_ci} 45921cb0ef41Sopenharmony_ci 45931cb0ef41Sopenharmony_civoid TurboAssembler::SwapP(MemOperand src, MemOperand dst, Register scratch_0, 45941cb0ef41Sopenharmony_ci Register scratch_1) { 45951cb0ef41Sopenharmony_ci if (src.rx() != r0) DCHECK(!AreAliased(src.rx(), scratch_0, scratch_1)); 45961cb0ef41Sopenharmony_ci if (src.rb() != r0) DCHECK(!AreAliased(src.rb(), scratch_0, scratch_1)); 45971cb0ef41Sopenharmony_ci if (dst.rx() != r0) DCHECK(!AreAliased(dst.rx(), scratch_0, scratch_1)); 45981cb0ef41Sopenharmony_ci if (dst.rb() != r0) DCHECK(!AreAliased(dst.rb(), scratch_0, scratch_1)); 45991cb0ef41Sopenharmony_ci DCHECK(!AreAliased(scratch_0, scratch_1)); 46001cb0ef41Sopenharmony_ci LoadU64(scratch_0, src); 46011cb0ef41Sopenharmony_ci LoadU64(scratch_1, dst); 46021cb0ef41Sopenharmony_ci StoreU64(scratch_0, dst); 46031cb0ef41Sopenharmony_ci StoreU64(scratch_1, src); 46041cb0ef41Sopenharmony_ci} 46051cb0ef41Sopenharmony_ci 46061cb0ef41Sopenharmony_civoid TurboAssembler::SwapFloat32(DoubleRegister src, DoubleRegister dst, 46071cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46081cb0ef41Sopenharmony_ci if (src == dst) return; 46091cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, dst, scratch)); 46101cb0ef41Sopenharmony_ci ldr(scratch, src); 46111cb0ef41Sopenharmony_ci ldr(src, dst); 46121cb0ef41Sopenharmony_ci ldr(dst, scratch); 46131cb0ef41Sopenharmony_ci} 46141cb0ef41Sopenharmony_ci 46151cb0ef41Sopenharmony_civoid TurboAssembler::SwapFloat32(DoubleRegister src, MemOperand dst, 46161cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46171cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch)); 46181cb0ef41Sopenharmony_ci ldr(scratch, src); 46191cb0ef41Sopenharmony_ci LoadF32(src, dst); 46201cb0ef41Sopenharmony_ci StoreF32(scratch, dst); 46211cb0ef41Sopenharmony_ci} 46221cb0ef41Sopenharmony_ci 46231cb0ef41Sopenharmony_civoid TurboAssembler::SwapFloat32(MemOperand src, MemOperand dst, 46241cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46251cb0ef41Sopenharmony_ci // push d0, to be used as scratch 46261cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kDoubleSize)); 46271cb0ef41Sopenharmony_ci StoreF64(d0, MemOperand(sp)); 46281cb0ef41Sopenharmony_ci LoadF32(scratch, src); 46291cb0ef41Sopenharmony_ci LoadF32(d0, dst); 46301cb0ef41Sopenharmony_ci StoreF32(scratch, dst); 46311cb0ef41Sopenharmony_ci StoreF32(d0, src); 46321cb0ef41Sopenharmony_ci // restore d0 46331cb0ef41Sopenharmony_ci LoadF64(d0, MemOperand(sp)); 46341cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, kDoubleSize)); 46351cb0ef41Sopenharmony_ci} 46361cb0ef41Sopenharmony_ci 46371cb0ef41Sopenharmony_civoid TurboAssembler::SwapDouble(DoubleRegister src, DoubleRegister dst, 46381cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46391cb0ef41Sopenharmony_ci if (src == dst) return; 46401cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, dst, scratch)); 46411cb0ef41Sopenharmony_ci ldr(scratch, src); 46421cb0ef41Sopenharmony_ci ldr(src, dst); 46431cb0ef41Sopenharmony_ci ldr(dst, scratch); 46441cb0ef41Sopenharmony_ci} 46451cb0ef41Sopenharmony_ci 46461cb0ef41Sopenharmony_civoid TurboAssembler::SwapDouble(DoubleRegister src, MemOperand dst, 46471cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46481cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch)); 46491cb0ef41Sopenharmony_ci ldr(scratch, src); 46501cb0ef41Sopenharmony_ci LoadF64(src, dst); 46511cb0ef41Sopenharmony_ci StoreF64(scratch, dst); 46521cb0ef41Sopenharmony_ci} 46531cb0ef41Sopenharmony_ci 46541cb0ef41Sopenharmony_civoid TurboAssembler::SwapDouble(MemOperand src, MemOperand dst, 46551cb0ef41Sopenharmony_ci DoubleRegister scratch) { 46561cb0ef41Sopenharmony_ci // push d0, to be used as scratch 46571cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kDoubleSize)); 46581cb0ef41Sopenharmony_ci StoreF64(d0, MemOperand(sp)); 46591cb0ef41Sopenharmony_ci LoadF64(scratch, src); 46601cb0ef41Sopenharmony_ci LoadF64(d0, dst); 46611cb0ef41Sopenharmony_ci StoreF64(scratch, dst); 46621cb0ef41Sopenharmony_ci StoreF64(d0, src); 46631cb0ef41Sopenharmony_ci // restore d0 46641cb0ef41Sopenharmony_ci LoadF64(d0, MemOperand(sp)); 46651cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, kDoubleSize)); 46661cb0ef41Sopenharmony_ci} 46671cb0ef41Sopenharmony_ci 46681cb0ef41Sopenharmony_civoid TurboAssembler::SwapSimd128(Simd128Register src, Simd128Register dst, 46691cb0ef41Sopenharmony_ci Simd128Register scratch) { 46701cb0ef41Sopenharmony_ci if (src == dst) return; 46711cb0ef41Sopenharmony_ci vlr(scratch, src, Condition(0), Condition(0), Condition(0)); 46721cb0ef41Sopenharmony_ci vlr(src, dst, Condition(0), Condition(0), Condition(0)); 46731cb0ef41Sopenharmony_ci vlr(dst, scratch, Condition(0), Condition(0), Condition(0)); 46741cb0ef41Sopenharmony_ci} 46751cb0ef41Sopenharmony_ci 46761cb0ef41Sopenharmony_civoid TurboAssembler::SwapSimd128(Simd128Register src, MemOperand dst, 46771cb0ef41Sopenharmony_ci Simd128Register scratch) { 46781cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch)); 46791cb0ef41Sopenharmony_ci vlr(scratch, src, Condition(0), Condition(0), Condition(0)); 46801cb0ef41Sopenharmony_ci LoadV128(src, dst, ip); 46811cb0ef41Sopenharmony_ci StoreV128(scratch, dst, ip); 46821cb0ef41Sopenharmony_ci} 46831cb0ef41Sopenharmony_ci 46841cb0ef41Sopenharmony_civoid TurboAssembler::SwapSimd128(MemOperand src, MemOperand dst, 46851cb0ef41Sopenharmony_ci Simd128Register scratch) { 46861cb0ef41Sopenharmony_ci // push d0, to be used as scratch 46871cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, -kSimd128Size)); 46881cb0ef41Sopenharmony_ci StoreV128(d0, MemOperand(sp), ip); 46891cb0ef41Sopenharmony_ci LoadV128(scratch, src, ip); 46901cb0ef41Sopenharmony_ci LoadV128(d0, dst, ip); 46911cb0ef41Sopenharmony_ci StoreV128(scratch, dst, ip); 46921cb0ef41Sopenharmony_ci StoreV128(d0, src, ip); 46931cb0ef41Sopenharmony_ci // restore d0 46941cb0ef41Sopenharmony_ci LoadV128(d0, MemOperand(sp), ip); 46951cb0ef41Sopenharmony_ci lay(sp, MemOperand(sp, kSimd128Size)); 46961cb0ef41Sopenharmony_ci} 46971cb0ef41Sopenharmony_ci 46981cb0ef41Sopenharmony_civoid TurboAssembler::ComputeCodeStartAddress(Register dst) { 46991cb0ef41Sopenharmony_ci larl(dst, Operand(-pc_offset() / 2)); 47001cb0ef41Sopenharmony_ci} 47011cb0ef41Sopenharmony_ci 47021cb0ef41Sopenharmony_civoid TurboAssembler::LoadPC(Register dst) { 47031cb0ef41Sopenharmony_ci Label current_pc; 47041cb0ef41Sopenharmony_ci larl(dst, ¤t_pc); 47051cb0ef41Sopenharmony_ci bind(¤t_pc); 47061cb0ef41Sopenharmony_ci} 47071cb0ef41Sopenharmony_ci 47081cb0ef41Sopenharmony_civoid TurboAssembler::JumpIfEqual(Register x, int32_t y, Label* dest) { 47091cb0ef41Sopenharmony_ci CmpS32(x, Operand(y)); 47101cb0ef41Sopenharmony_ci beq(dest); 47111cb0ef41Sopenharmony_ci} 47121cb0ef41Sopenharmony_ci 47131cb0ef41Sopenharmony_civoid TurboAssembler::JumpIfLessThan(Register x, int32_t y, Label* dest) { 47141cb0ef41Sopenharmony_ci CmpS32(x, Operand(y)); 47151cb0ef41Sopenharmony_ci blt(dest); 47161cb0ef41Sopenharmony_ci} 47171cb0ef41Sopenharmony_ci 47181cb0ef41Sopenharmony_civoid TurboAssembler::LoadEntryFromBuiltinIndex(Register builtin_index) { 47191cb0ef41Sopenharmony_ci STATIC_ASSERT(kSystemPointerSize == 8); 47201cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTagSize == 1); 47211cb0ef41Sopenharmony_ci STATIC_ASSERT(kSmiTag == 0); 47221cb0ef41Sopenharmony_ci // The builtin_index register contains the builtin index as a Smi. 47231cb0ef41Sopenharmony_ci if (SmiValuesAre32Bits()) { 47241cb0ef41Sopenharmony_ci ShiftRightS64(builtin_index, builtin_index, 47251cb0ef41Sopenharmony_ci Operand(kSmiShift - kSystemPointerSizeLog2)); 47261cb0ef41Sopenharmony_ci } else { 47271cb0ef41Sopenharmony_ci DCHECK(SmiValuesAre31Bits()); 47281cb0ef41Sopenharmony_ci ShiftLeftU64(builtin_index, builtin_index, 47291cb0ef41Sopenharmony_ci Operand(kSystemPointerSizeLog2 - kSmiShift)); 47301cb0ef41Sopenharmony_ci } 47311cb0ef41Sopenharmony_ci LoadU64(builtin_index, MemOperand(kRootRegister, builtin_index, 47321cb0ef41Sopenharmony_ci IsolateData::builtin_entry_table_offset())); 47331cb0ef41Sopenharmony_ci} 47341cb0ef41Sopenharmony_ci 47351cb0ef41Sopenharmony_civoid TurboAssembler::CallBuiltinByIndex(Register builtin_index) { 47361cb0ef41Sopenharmony_ci LoadEntryFromBuiltinIndex(builtin_index); 47371cb0ef41Sopenharmony_ci Call(builtin_index); 47381cb0ef41Sopenharmony_ci} 47391cb0ef41Sopenharmony_ci 47401cb0ef41Sopenharmony_civoid TurboAssembler::LoadEntryFromBuiltin(Builtin builtin, 47411cb0ef41Sopenharmony_ci Register destination) { 47421cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 47431cb0ef41Sopenharmony_ci LoadU64(destination, EntryFromBuiltinAsOperand(builtin)); 47441cb0ef41Sopenharmony_ci} 47451cb0ef41Sopenharmony_ci 47461cb0ef41Sopenharmony_ciMemOperand TurboAssembler::EntryFromBuiltinAsOperand(Builtin builtin) { 47471cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 47481cb0ef41Sopenharmony_ci DCHECK(root_array_available()); 47491cb0ef41Sopenharmony_ci return MemOperand(kRootRegister, 47501cb0ef41Sopenharmony_ci IsolateData::BuiltinEntrySlotOffset(builtin)); 47511cb0ef41Sopenharmony_ci} 47521cb0ef41Sopenharmony_ci 47531cb0ef41Sopenharmony_civoid TurboAssembler::LoadCodeObjectEntry(Register destination, 47541cb0ef41Sopenharmony_ci Register code_object) { 47551cb0ef41Sopenharmony_ci // Code objects are called differently depending on whether we are generating 47561cb0ef41Sopenharmony_ci // builtin code (which will later be embedded into the binary) or compiling 47571cb0ef41Sopenharmony_ci // user JS code at runtime. 47581cb0ef41Sopenharmony_ci // * Builtin code runs in --jitless mode and thus must not call into on-heap 47591cb0ef41Sopenharmony_ci // Code targets. Instead, we dispatch through the builtins entry table. 47601cb0ef41Sopenharmony_ci // * Codegen at runtime does not have this restriction and we can use the 47611cb0ef41Sopenharmony_ci // shorter, branchless instruction sequence. The assumption here is that 47621cb0ef41Sopenharmony_ci // targets are usually generated code and not builtin Code objects. 47631cb0ef41Sopenharmony_ci 47641cb0ef41Sopenharmony_ci if (options().isolate_independent_code) { 47651cb0ef41Sopenharmony_ci DCHECK(root_array_available()); 47661cb0ef41Sopenharmony_ci Label if_code_is_off_heap, out; 47671cb0ef41Sopenharmony_ci 47681cb0ef41Sopenharmony_ci Register scratch = r1; 47691cb0ef41Sopenharmony_ci 47701cb0ef41Sopenharmony_ci DCHECK(!AreAliased(destination, scratch)); 47711cb0ef41Sopenharmony_ci DCHECK(!AreAliased(code_object, scratch)); 47721cb0ef41Sopenharmony_ci 47731cb0ef41Sopenharmony_ci // Check whether the Code object is an off-heap trampoline. If so, call its 47741cb0ef41Sopenharmony_ci // (off-heap) entry point directly without going through the (on-heap) 47751cb0ef41Sopenharmony_ci // trampoline. Otherwise, just call the Code object as always. 47761cb0ef41Sopenharmony_ci LoadS32(scratch, FieldMemOperand(code_object, Code::kFlagsOffset)); 47771cb0ef41Sopenharmony_ci tmlh(scratch, Operand(Code::IsOffHeapTrampoline::kMask >> 16)); 47781cb0ef41Sopenharmony_ci bne(&if_code_is_off_heap); 47791cb0ef41Sopenharmony_ci 47801cb0ef41Sopenharmony_ci // Not an off-heap trampoline, the entry point is at 47811cb0ef41Sopenharmony_ci // Code::raw_instruction_start(). 47821cb0ef41Sopenharmony_ci AddS64(destination, code_object, 47831cb0ef41Sopenharmony_ci Operand(Code::kHeaderSize - kHeapObjectTag)); 47841cb0ef41Sopenharmony_ci b(&out); 47851cb0ef41Sopenharmony_ci 47861cb0ef41Sopenharmony_ci // An off-heap trampoline, the entry point is loaded from the builtin entry 47871cb0ef41Sopenharmony_ci // table. 47881cb0ef41Sopenharmony_ci bind(&if_code_is_off_heap); 47891cb0ef41Sopenharmony_ci LoadS32(scratch, FieldMemOperand(code_object, Code::kBuiltinIndexOffset)); 47901cb0ef41Sopenharmony_ci ShiftLeftU64(destination, scratch, Operand(kSystemPointerSizeLog2)); 47911cb0ef41Sopenharmony_ci AddS64(destination, destination, kRootRegister); 47921cb0ef41Sopenharmony_ci LoadU64(destination, 47931cb0ef41Sopenharmony_ci MemOperand(destination, IsolateData::builtin_entry_table_offset())); 47941cb0ef41Sopenharmony_ci 47951cb0ef41Sopenharmony_ci bind(&out); 47961cb0ef41Sopenharmony_ci } else { 47971cb0ef41Sopenharmony_ci AddS64(destination, code_object, 47981cb0ef41Sopenharmony_ci Operand(Code::kHeaderSize - kHeapObjectTag)); 47991cb0ef41Sopenharmony_ci } 48001cb0ef41Sopenharmony_ci} 48011cb0ef41Sopenharmony_ci 48021cb0ef41Sopenharmony_civoid TurboAssembler::CallCodeObject(Register code_object) { 48031cb0ef41Sopenharmony_ci LoadCodeObjectEntry(code_object, code_object); 48041cb0ef41Sopenharmony_ci Call(code_object); 48051cb0ef41Sopenharmony_ci} 48061cb0ef41Sopenharmony_ci 48071cb0ef41Sopenharmony_civoid TurboAssembler::JumpCodeObject(Register code_object, JumpMode jump_mode) { 48081cb0ef41Sopenharmony_ci DCHECK_EQ(JumpMode::kJump, jump_mode); 48091cb0ef41Sopenharmony_ci LoadCodeObjectEntry(code_object, code_object); 48101cb0ef41Sopenharmony_ci Jump(code_object); 48111cb0ef41Sopenharmony_ci} 48121cb0ef41Sopenharmony_ci 48131cb0ef41Sopenharmony_civoid TurboAssembler::StoreReturnAddressAndCall(Register target) { 48141cb0ef41Sopenharmony_ci // This generates the final instruction sequence for calls to C functions 48151cb0ef41Sopenharmony_ci // once an exit frame has been constructed. 48161cb0ef41Sopenharmony_ci // 48171cb0ef41Sopenharmony_ci // Note that this assumes the caller code (i.e. the Code object currently 48181cb0ef41Sopenharmony_ci // being generated) is immovable or that the callee function cannot trigger 48191cb0ef41Sopenharmony_ci // GC, since the callee function will return to it. 48201cb0ef41Sopenharmony_ci 48211cb0ef41Sopenharmony_ci Label return_label; 48221cb0ef41Sopenharmony_ci larl(r14, &return_label); // Generate the return addr of call later. 48231cb0ef41Sopenharmony_ci StoreU64(r14, MemOperand(sp, kStackFrameRASlot * kSystemPointerSize)); 48241cb0ef41Sopenharmony_ci 48251cb0ef41Sopenharmony_ci // zLinux ABI requires caller's frame to have sufficient space for callee 48261cb0ef41Sopenharmony_ci // preserved regsiter save area. 48271cb0ef41Sopenharmony_ci b(target); 48281cb0ef41Sopenharmony_ci bind(&return_label); 48291cb0ef41Sopenharmony_ci} 48301cb0ef41Sopenharmony_ci 48311cb0ef41Sopenharmony_civoid TurboAssembler::CallForDeoptimization(Builtin target, int, Label* exit, 48321cb0ef41Sopenharmony_ci DeoptimizeKind kind, Label* ret, 48331cb0ef41Sopenharmony_ci Label*) { 48341cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 48351cb0ef41Sopenharmony_ci LoadU64(ip, MemOperand(kRootRegister, 48361cb0ef41Sopenharmony_ci IsolateData::BuiltinEntrySlotOffset(target))); 48371cb0ef41Sopenharmony_ci Call(ip); 48381cb0ef41Sopenharmony_ci DCHECK_EQ(SizeOfCodeGeneratedSince(exit), 48391cb0ef41Sopenharmony_ci (kind == DeoptimizeKind::kLazy) ? Deoptimizer::kLazyDeoptExitSize 48401cb0ef41Sopenharmony_ci : Deoptimizer::kEagerDeoptExitSize); 48411cb0ef41Sopenharmony_ci} 48421cb0ef41Sopenharmony_ci 48431cb0ef41Sopenharmony_civoid TurboAssembler::Trap() { stop(); } 48441cb0ef41Sopenharmony_civoid TurboAssembler::DebugBreak() { stop(); } 48451cb0ef41Sopenharmony_ci 48461cb0ef41Sopenharmony_civoid TurboAssembler::CountLeadingZerosU32(Register dst, Register src, 48471cb0ef41Sopenharmony_ci Register scratch_pair) { 48481cb0ef41Sopenharmony_ci llgfr(dst, src); 48491cb0ef41Sopenharmony_ci flogr(scratch_pair, 48501cb0ef41Sopenharmony_ci dst); // will modify a register pair scratch and scratch + 1 48511cb0ef41Sopenharmony_ci AddS32(dst, scratch_pair, Operand(-32)); 48521cb0ef41Sopenharmony_ci} 48531cb0ef41Sopenharmony_ci 48541cb0ef41Sopenharmony_civoid TurboAssembler::CountLeadingZerosU64(Register dst, Register src, 48551cb0ef41Sopenharmony_ci Register scratch_pair) { 48561cb0ef41Sopenharmony_ci flogr(scratch_pair, 48571cb0ef41Sopenharmony_ci src); // will modify a register pair scratch and scratch + 1 48581cb0ef41Sopenharmony_ci mov(dst, scratch_pair); 48591cb0ef41Sopenharmony_ci} 48601cb0ef41Sopenharmony_ci 48611cb0ef41Sopenharmony_civoid TurboAssembler::CountTrailingZerosU32(Register dst, Register src, 48621cb0ef41Sopenharmony_ci Register scratch_pair) { 48631cb0ef41Sopenharmony_ci Register scratch0 = scratch_pair; 48641cb0ef41Sopenharmony_ci Register scratch1 = Register::from_code(scratch_pair.code() + 1); 48651cb0ef41Sopenharmony_ci DCHECK(!AreAliased(dst, scratch0, scratch1)); 48661cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch0, scratch1)); 48671cb0ef41Sopenharmony_ci 48681cb0ef41Sopenharmony_ci Label done; 48691cb0ef41Sopenharmony_ci // Check if src is all zeros. 48701cb0ef41Sopenharmony_ci ltr(scratch1, src); 48711cb0ef41Sopenharmony_ci mov(dst, Operand(32)); 48721cb0ef41Sopenharmony_ci beq(&done); 48731cb0ef41Sopenharmony_ci llgfr(scratch1, scratch1); 48741cb0ef41Sopenharmony_ci lcgr(scratch0, scratch1); 48751cb0ef41Sopenharmony_ci ngr(scratch1, scratch0); 48761cb0ef41Sopenharmony_ci flogr(scratch0, scratch1); 48771cb0ef41Sopenharmony_ci mov(dst, Operand(63)); 48781cb0ef41Sopenharmony_ci SubS64(dst, scratch0); 48791cb0ef41Sopenharmony_ci bind(&done); 48801cb0ef41Sopenharmony_ci} 48811cb0ef41Sopenharmony_ci 48821cb0ef41Sopenharmony_civoid TurboAssembler::CountTrailingZerosU64(Register dst, Register src, 48831cb0ef41Sopenharmony_ci Register scratch_pair) { 48841cb0ef41Sopenharmony_ci Register scratch0 = scratch_pair; 48851cb0ef41Sopenharmony_ci Register scratch1 = Register::from_code(scratch_pair.code() + 1); 48861cb0ef41Sopenharmony_ci DCHECK(!AreAliased(dst, scratch0, scratch1)); 48871cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src, scratch0, scratch1)); 48881cb0ef41Sopenharmony_ci 48891cb0ef41Sopenharmony_ci Label done; 48901cb0ef41Sopenharmony_ci // Check if src is all zeros. 48911cb0ef41Sopenharmony_ci ltgr(scratch1, src); 48921cb0ef41Sopenharmony_ci mov(dst, Operand(64)); 48931cb0ef41Sopenharmony_ci beq(&done); 48941cb0ef41Sopenharmony_ci lcgr(scratch0, scratch1); 48951cb0ef41Sopenharmony_ci ngr(scratch0, scratch1); 48961cb0ef41Sopenharmony_ci flogr(scratch0, scratch0); 48971cb0ef41Sopenharmony_ci mov(dst, Operand(63)); 48981cb0ef41Sopenharmony_ci SubS64(dst, scratch0); 48991cb0ef41Sopenharmony_ci bind(&done); 49001cb0ef41Sopenharmony_ci} 49011cb0ef41Sopenharmony_ci 49021cb0ef41Sopenharmony_civoid TurboAssembler::AtomicCmpExchangeHelper(Register addr, Register output, 49031cb0ef41Sopenharmony_ci Register old_value, 49041cb0ef41Sopenharmony_ci Register new_value, int start, 49051cb0ef41Sopenharmony_ci int end, int shift_amount, 49061cb0ef41Sopenharmony_ci int offset, Register temp0, 49071cb0ef41Sopenharmony_ci Register temp1) { 49081cb0ef41Sopenharmony_ci LoadU32(temp0, MemOperand(addr, offset)); 49091cb0ef41Sopenharmony_ci llgfr(temp1, temp0); 49101cb0ef41Sopenharmony_ci RotateInsertSelectBits(temp0, old_value, Operand(start), Operand(end), 49111cb0ef41Sopenharmony_ci Operand(shift_amount), false); 49121cb0ef41Sopenharmony_ci RotateInsertSelectBits(temp1, new_value, Operand(start), Operand(end), 49131cb0ef41Sopenharmony_ci Operand(shift_amount), false); 49141cb0ef41Sopenharmony_ci CmpAndSwap(temp0, temp1, MemOperand(addr, offset)); 49151cb0ef41Sopenharmony_ci RotateInsertSelectBits(output, temp0, Operand(start + shift_amount), 49161cb0ef41Sopenharmony_ci Operand(end + shift_amount), 49171cb0ef41Sopenharmony_ci Operand(64 - shift_amount), true); 49181cb0ef41Sopenharmony_ci} 49191cb0ef41Sopenharmony_ci 49201cb0ef41Sopenharmony_civoid TurboAssembler::AtomicCmpExchangeU8(Register addr, Register output, 49211cb0ef41Sopenharmony_ci Register old_value, Register new_value, 49221cb0ef41Sopenharmony_ci Register temp0, Register temp1) { 49231cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 49241cb0ef41Sopenharmony_ci#define ATOMIC_COMP_EXCHANGE_BYTE(i) \ 49251cb0ef41Sopenharmony_ci { \ 49261cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 49271cb0ef41Sopenharmony_ci static_assert(idx <= 3 && idx >= 0, "idx is out of range!"); \ 49281cb0ef41Sopenharmony_ci constexpr int start = 32 + 8 * idx; \ 49291cb0ef41Sopenharmony_ci constexpr int end = start + 7; \ 49301cb0ef41Sopenharmony_ci constexpr int shift_amount = (3 - idx) * 8; \ 49311cb0ef41Sopenharmony_ci AtomicCmpExchangeHelper(addr, output, old_value, new_value, start, end, \ 49321cb0ef41Sopenharmony_ci shift_amount, -idx, temp0, temp1); \ 49331cb0ef41Sopenharmony_ci } 49341cb0ef41Sopenharmony_ci#else 49351cb0ef41Sopenharmony_ci#define ATOMIC_COMP_EXCHANGE_BYTE(i) \ 49361cb0ef41Sopenharmony_ci { \ 49371cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 49381cb0ef41Sopenharmony_ci static_assert(idx <= 3 && idx >= 0, "idx is out of range!"); \ 49391cb0ef41Sopenharmony_ci constexpr int start = 32 + 8 * (3 - idx); \ 49401cb0ef41Sopenharmony_ci constexpr int end = start + 7; \ 49411cb0ef41Sopenharmony_ci constexpr int shift_amount = idx * 8; \ 49421cb0ef41Sopenharmony_ci AtomicCmpExchangeHelper(addr, output, old_value, new_value, start, end, \ 49431cb0ef41Sopenharmony_ci shift_amount, -idx, temp0, temp1); \ 49441cb0ef41Sopenharmony_ci } 49451cb0ef41Sopenharmony_ci#endif 49461cb0ef41Sopenharmony_ci 49471cb0ef41Sopenharmony_ci Label one, two, three, done; 49481cb0ef41Sopenharmony_ci tmll(addr, Operand(3)); 49491cb0ef41Sopenharmony_ci b(Condition(1), &three); 49501cb0ef41Sopenharmony_ci b(Condition(2), &two); 49511cb0ef41Sopenharmony_ci b(Condition(4), &one); 49521cb0ef41Sopenharmony_ci /* ending with 0b00 */ 49531cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_BYTE(0); 49541cb0ef41Sopenharmony_ci b(&done); 49551cb0ef41Sopenharmony_ci /* ending with 0b01 */ 49561cb0ef41Sopenharmony_ci bind(&one); 49571cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_BYTE(1); 49581cb0ef41Sopenharmony_ci b(&done); 49591cb0ef41Sopenharmony_ci /* ending with 0b10 */ 49601cb0ef41Sopenharmony_ci bind(&two); 49611cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_BYTE(2); 49621cb0ef41Sopenharmony_ci b(&done); 49631cb0ef41Sopenharmony_ci /* ending with 0b11 */ 49641cb0ef41Sopenharmony_ci bind(&three); 49651cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_BYTE(3); 49661cb0ef41Sopenharmony_ci bind(&done); 49671cb0ef41Sopenharmony_ci} 49681cb0ef41Sopenharmony_ci 49691cb0ef41Sopenharmony_civoid TurboAssembler::AtomicCmpExchangeU16(Register addr, Register output, 49701cb0ef41Sopenharmony_ci Register old_value, 49711cb0ef41Sopenharmony_ci Register new_value, Register temp0, 49721cb0ef41Sopenharmony_ci Register temp1) { 49731cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 49741cb0ef41Sopenharmony_ci#define ATOMIC_COMP_EXCHANGE_HALFWORD(i) \ 49751cb0ef41Sopenharmony_ci { \ 49761cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 49771cb0ef41Sopenharmony_ci static_assert(idx <= 1 && idx >= 0, "idx is out of range!"); \ 49781cb0ef41Sopenharmony_ci constexpr int start = 32 + 16 * idx; \ 49791cb0ef41Sopenharmony_ci constexpr int end = start + 15; \ 49801cb0ef41Sopenharmony_ci constexpr int shift_amount = (1 - idx) * 16; \ 49811cb0ef41Sopenharmony_ci AtomicCmpExchangeHelper(addr, output, old_value, new_value, start, end, \ 49821cb0ef41Sopenharmony_ci shift_amount, -idx * 2, temp0, temp1); \ 49831cb0ef41Sopenharmony_ci } 49841cb0ef41Sopenharmony_ci#else 49851cb0ef41Sopenharmony_ci#define ATOMIC_COMP_EXCHANGE_HALFWORD(i) \ 49861cb0ef41Sopenharmony_ci { \ 49871cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 49881cb0ef41Sopenharmony_ci static_assert(idx <= 1 && idx >= 0, "idx is out of range!"); \ 49891cb0ef41Sopenharmony_ci constexpr int start = 32 + 16 * (1 - idx); \ 49901cb0ef41Sopenharmony_ci constexpr int end = start + 15; \ 49911cb0ef41Sopenharmony_ci constexpr int shift_amount = idx * 16; \ 49921cb0ef41Sopenharmony_ci AtomicCmpExchangeHelper(addr, output, old_value, new_value, start, end, \ 49931cb0ef41Sopenharmony_ci shift_amount, -idx * 2, temp0, temp1); \ 49941cb0ef41Sopenharmony_ci } 49951cb0ef41Sopenharmony_ci#endif 49961cb0ef41Sopenharmony_ci 49971cb0ef41Sopenharmony_ci Label two, done; 49981cb0ef41Sopenharmony_ci tmll(addr, Operand(3)); 49991cb0ef41Sopenharmony_ci b(Condition(2), &two); 50001cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_HALFWORD(0); 50011cb0ef41Sopenharmony_ci b(&done); 50021cb0ef41Sopenharmony_ci bind(&two); 50031cb0ef41Sopenharmony_ci ATOMIC_COMP_EXCHANGE_HALFWORD(1); 50041cb0ef41Sopenharmony_ci bind(&done); 50051cb0ef41Sopenharmony_ci} 50061cb0ef41Sopenharmony_ci 50071cb0ef41Sopenharmony_civoid TurboAssembler::AtomicExchangeHelper(Register addr, Register value, 50081cb0ef41Sopenharmony_ci Register output, int start, int end, 50091cb0ef41Sopenharmony_ci int shift_amount, int offset, 50101cb0ef41Sopenharmony_ci Register scratch) { 50111cb0ef41Sopenharmony_ci Label do_cs; 50121cb0ef41Sopenharmony_ci LoadU32(output, MemOperand(addr, offset)); 50131cb0ef41Sopenharmony_ci bind(&do_cs); 50141cb0ef41Sopenharmony_ci llgfr(scratch, output); 50151cb0ef41Sopenharmony_ci RotateInsertSelectBits(scratch, value, Operand(start), Operand(end), 50161cb0ef41Sopenharmony_ci Operand(shift_amount), false); 50171cb0ef41Sopenharmony_ci csy(output, scratch, MemOperand(addr, offset)); 50181cb0ef41Sopenharmony_ci bne(&do_cs, Label::kNear); 50191cb0ef41Sopenharmony_ci srl(output, Operand(shift_amount)); 50201cb0ef41Sopenharmony_ci} 50211cb0ef41Sopenharmony_ci 50221cb0ef41Sopenharmony_civoid TurboAssembler::AtomicExchangeU8(Register addr, Register value, 50231cb0ef41Sopenharmony_ci Register output, Register scratch) { 50241cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 50251cb0ef41Sopenharmony_ci#define ATOMIC_EXCHANGE_BYTE(i) \ 50261cb0ef41Sopenharmony_ci { \ 50271cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 50281cb0ef41Sopenharmony_ci static_assert(idx <= 3 && idx >= 0, "idx is out of range!"); \ 50291cb0ef41Sopenharmony_ci constexpr int start = 32 + 8 * idx; \ 50301cb0ef41Sopenharmony_ci constexpr int end = start + 7; \ 50311cb0ef41Sopenharmony_ci constexpr int shift_amount = (3 - idx) * 8; \ 50321cb0ef41Sopenharmony_ci AtomicExchangeHelper(addr, value, output, start, end, shift_amount, -idx, \ 50331cb0ef41Sopenharmony_ci scratch); \ 50341cb0ef41Sopenharmony_ci } 50351cb0ef41Sopenharmony_ci#else 50361cb0ef41Sopenharmony_ci#define ATOMIC_EXCHANGE_BYTE(i) \ 50371cb0ef41Sopenharmony_ci { \ 50381cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 50391cb0ef41Sopenharmony_ci static_assert(idx <= 3 && idx >= 0, "idx is out of range!"); \ 50401cb0ef41Sopenharmony_ci constexpr int start = 32 + 8 * (3 - idx); \ 50411cb0ef41Sopenharmony_ci constexpr int end = start + 7; \ 50421cb0ef41Sopenharmony_ci constexpr int shift_amount = idx * 8; \ 50431cb0ef41Sopenharmony_ci AtomicExchangeHelper(addr, value, output, start, end, shift_amount, -idx, \ 50441cb0ef41Sopenharmony_ci scratch); \ 50451cb0ef41Sopenharmony_ci } 50461cb0ef41Sopenharmony_ci#endif 50471cb0ef41Sopenharmony_ci Label three, two, one, done; 50481cb0ef41Sopenharmony_ci tmll(addr, Operand(3)); 50491cb0ef41Sopenharmony_ci b(Condition(1), &three); 50501cb0ef41Sopenharmony_ci b(Condition(2), &two); 50511cb0ef41Sopenharmony_ci b(Condition(4), &one); 50521cb0ef41Sopenharmony_ci 50531cb0ef41Sopenharmony_ci // end with 0b00 50541cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_BYTE(0); 50551cb0ef41Sopenharmony_ci b(&done); 50561cb0ef41Sopenharmony_ci 50571cb0ef41Sopenharmony_ci // ending with 0b01 50581cb0ef41Sopenharmony_ci bind(&one); 50591cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_BYTE(1); 50601cb0ef41Sopenharmony_ci b(&done); 50611cb0ef41Sopenharmony_ci 50621cb0ef41Sopenharmony_ci // ending with 0b10 50631cb0ef41Sopenharmony_ci bind(&two); 50641cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_BYTE(2); 50651cb0ef41Sopenharmony_ci b(&done); 50661cb0ef41Sopenharmony_ci 50671cb0ef41Sopenharmony_ci // ending with 0b11 50681cb0ef41Sopenharmony_ci bind(&three); 50691cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_BYTE(3); 50701cb0ef41Sopenharmony_ci 50711cb0ef41Sopenharmony_ci bind(&done); 50721cb0ef41Sopenharmony_ci} 50731cb0ef41Sopenharmony_ci 50741cb0ef41Sopenharmony_civoid TurboAssembler::AtomicExchangeU16(Register addr, Register value, 50751cb0ef41Sopenharmony_ci Register output, Register scratch) { 50761cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 50771cb0ef41Sopenharmony_ci#define ATOMIC_EXCHANGE_HALFWORD(i) \ 50781cb0ef41Sopenharmony_ci { \ 50791cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 50801cb0ef41Sopenharmony_ci static_assert(idx <= 1 && idx >= 0, "idx is out of range!"); \ 50811cb0ef41Sopenharmony_ci constexpr int start = 32 + 16 * idx; \ 50821cb0ef41Sopenharmony_ci constexpr int end = start + 15; \ 50831cb0ef41Sopenharmony_ci constexpr int shift_amount = (1 - idx) * 16; \ 50841cb0ef41Sopenharmony_ci AtomicExchangeHelper(addr, value, output, start, end, shift_amount, \ 50851cb0ef41Sopenharmony_ci -idx * 2, scratch); \ 50861cb0ef41Sopenharmony_ci } 50871cb0ef41Sopenharmony_ci#else 50881cb0ef41Sopenharmony_ci#define ATOMIC_EXCHANGE_HALFWORD(i) \ 50891cb0ef41Sopenharmony_ci { \ 50901cb0ef41Sopenharmony_ci constexpr int idx = (i); \ 50911cb0ef41Sopenharmony_ci static_assert(idx <= 1 && idx >= 0, "idx is out of range!"); \ 50921cb0ef41Sopenharmony_ci constexpr int start = 32 + 16 * (1 - idx); \ 50931cb0ef41Sopenharmony_ci constexpr int end = start + 15; \ 50941cb0ef41Sopenharmony_ci constexpr int shift_amount = idx * 16; \ 50951cb0ef41Sopenharmony_ci AtomicExchangeHelper(addr, value, output, start, end, shift_amount, \ 50961cb0ef41Sopenharmony_ci -idx * 2, scratch); \ 50971cb0ef41Sopenharmony_ci } 50981cb0ef41Sopenharmony_ci#endif 50991cb0ef41Sopenharmony_ci Label two, done; 51001cb0ef41Sopenharmony_ci tmll(addr, Operand(3)); 51011cb0ef41Sopenharmony_ci b(Condition(2), &two); 51021cb0ef41Sopenharmony_ci 51031cb0ef41Sopenharmony_ci // end with 0b00 51041cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_HALFWORD(0); 51051cb0ef41Sopenharmony_ci b(&done); 51061cb0ef41Sopenharmony_ci 51071cb0ef41Sopenharmony_ci // ending with 0b10 51081cb0ef41Sopenharmony_ci bind(&two); 51091cb0ef41Sopenharmony_ci ATOMIC_EXCHANGE_HALFWORD(1); 51101cb0ef41Sopenharmony_ci 51111cb0ef41Sopenharmony_ci bind(&done); 51121cb0ef41Sopenharmony_ci} 51131cb0ef41Sopenharmony_ci 51141cb0ef41Sopenharmony_ci// Simd Support. 51151cb0ef41Sopenharmony_civoid TurboAssembler::F64x2Splat(Simd128Register dst, Simd128Register src) { 51161cb0ef41Sopenharmony_ci vrep(dst, src, Operand(0), Condition(3)); 51171cb0ef41Sopenharmony_ci} 51181cb0ef41Sopenharmony_ci 51191cb0ef41Sopenharmony_civoid TurboAssembler::F32x4Splat(Simd128Register dst, Simd128Register src) { 51201cb0ef41Sopenharmony_ci vrep(dst, src, Operand(0), Condition(2)); 51211cb0ef41Sopenharmony_ci} 51221cb0ef41Sopenharmony_ci 51231cb0ef41Sopenharmony_civoid TurboAssembler::I64x2Splat(Simd128Register dst, Register src) { 51241cb0ef41Sopenharmony_ci vlvg(dst, src, MemOperand(r0, 0), Condition(3)); 51251cb0ef41Sopenharmony_ci vrep(dst, dst, Operand(0), Condition(3)); 51261cb0ef41Sopenharmony_ci} 51271cb0ef41Sopenharmony_ci 51281cb0ef41Sopenharmony_civoid TurboAssembler::I32x4Splat(Simd128Register dst, Register src) { 51291cb0ef41Sopenharmony_ci vlvg(dst, src, MemOperand(r0, 0), Condition(2)); 51301cb0ef41Sopenharmony_ci vrep(dst, dst, Operand(0), Condition(2)); 51311cb0ef41Sopenharmony_ci} 51321cb0ef41Sopenharmony_ci 51331cb0ef41Sopenharmony_civoid TurboAssembler::I16x8Splat(Simd128Register dst, Register src) { 51341cb0ef41Sopenharmony_ci vlvg(dst, src, MemOperand(r0, 0), Condition(1)); 51351cb0ef41Sopenharmony_ci vrep(dst, dst, Operand(0), Condition(1)); 51361cb0ef41Sopenharmony_ci} 51371cb0ef41Sopenharmony_ci 51381cb0ef41Sopenharmony_civoid TurboAssembler::I8x16Splat(Simd128Register dst, Register src) { 51391cb0ef41Sopenharmony_ci vlvg(dst, src, MemOperand(r0, 0), Condition(0)); 51401cb0ef41Sopenharmony_ci vrep(dst, dst, Operand(0), Condition(0)); 51411cb0ef41Sopenharmony_ci} 51421cb0ef41Sopenharmony_ci 51431cb0ef41Sopenharmony_civoid TurboAssembler::F64x2ExtractLane(DoubleRegister dst, Simd128Register src, 51441cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51451cb0ef41Sopenharmony_ci vrep(dst, src, Operand(1 - imm_lane_idx), Condition(3)); 51461cb0ef41Sopenharmony_ci} 51471cb0ef41Sopenharmony_ci 51481cb0ef41Sopenharmony_civoid TurboAssembler::F32x4ExtractLane(DoubleRegister dst, Simd128Register src, 51491cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51501cb0ef41Sopenharmony_ci vrep(dst, src, Operand(3 - imm_lane_idx), Condition(2)); 51511cb0ef41Sopenharmony_ci} 51521cb0ef41Sopenharmony_ci 51531cb0ef41Sopenharmony_civoid TurboAssembler::I64x2ExtractLane(Register dst, Simd128Register src, 51541cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51551cb0ef41Sopenharmony_ci vlgv(dst, src, MemOperand(r0, 1 - imm_lane_idx), Condition(3)); 51561cb0ef41Sopenharmony_ci} 51571cb0ef41Sopenharmony_ci 51581cb0ef41Sopenharmony_civoid TurboAssembler::I32x4ExtractLane(Register dst, Simd128Register src, 51591cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51601cb0ef41Sopenharmony_ci vlgv(dst, src, MemOperand(r0, 3 - imm_lane_idx), Condition(2)); 51611cb0ef41Sopenharmony_ci} 51621cb0ef41Sopenharmony_ci 51631cb0ef41Sopenharmony_civoid TurboAssembler::I16x8ExtractLaneU(Register dst, Simd128Register src, 51641cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51651cb0ef41Sopenharmony_ci vlgv(dst, src, MemOperand(r0, 7 - imm_lane_idx), Condition(1)); 51661cb0ef41Sopenharmony_ci} 51671cb0ef41Sopenharmony_ci 51681cb0ef41Sopenharmony_civoid TurboAssembler::I16x8ExtractLaneS(Register dst, Simd128Register src, 51691cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register scratch) { 51701cb0ef41Sopenharmony_ci vlgv(scratch, src, MemOperand(r0, 7 - imm_lane_idx), Condition(1)); 51711cb0ef41Sopenharmony_ci lghr(dst, scratch); 51721cb0ef41Sopenharmony_ci} 51731cb0ef41Sopenharmony_ci 51741cb0ef41Sopenharmony_civoid TurboAssembler::I8x16ExtractLaneU(Register dst, Simd128Register src, 51751cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register) { 51761cb0ef41Sopenharmony_ci vlgv(dst, src, MemOperand(r0, 15 - imm_lane_idx), Condition(0)); 51771cb0ef41Sopenharmony_ci} 51781cb0ef41Sopenharmony_ci 51791cb0ef41Sopenharmony_civoid TurboAssembler::I8x16ExtractLaneS(Register dst, Simd128Register src, 51801cb0ef41Sopenharmony_ci uint8_t imm_lane_idx, Register scratch) { 51811cb0ef41Sopenharmony_ci vlgv(scratch, src, MemOperand(r0, 15 - imm_lane_idx), Condition(0)); 51821cb0ef41Sopenharmony_ci lgbr(dst, scratch); 51831cb0ef41Sopenharmony_ci} 51841cb0ef41Sopenharmony_ci 51851cb0ef41Sopenharmony_civoid TurboAssembler::F64x2ReplaceLane(Simd128Register dst, Simd128Register src1, 51861cb0ef41Sopenharmony_ci DoubleRegister src2, uint8_t imm_lane_idx, 51871cb0ef41Sopenharmony_ci Register scratch) { 51881cb0ef41Sopenharmony_ci vlgv(scratch, src2, MemOperand(r0, 0), Condition(3)); 51891cb0ef41Sopenharmony_ci if (src1 != dst) { 51901cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 51911cb0ef41Sopenharmony_ci } 51921cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 1 - imm_lane_idx), Condition(3)); 51931cb0ef41Sopenharmony_ci} 51941cb0ef41Sopenharmony_ci 51951cb0ef41Sopenharmony_civoid TurboAssembler::F32x4ReplaceLane(Simd128Register dst, Simd128Register src1, 51961cb0ef41Sopenharmony_ci DoubleRegister src2, uint8_t imm_lane_idx, 51971cb0ef41Sopenharmony_ci Register scratch) { 51981cb0ef41Sopenharmony_ci vlgv(scratch, src2, MemOperand(r0, 0), Condition(2)); 51991cb0ef41Sopenharmony_ci if (src1 != dst) { 52001cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 52011cb0ef41Sopenharmony_ci } 52021cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 3 - imm_lane_idx), Condition(2)); 52031cb0ef41Sopenharmony_ci} 52041cb0ef41Sopenharmony_ci 52051cb0ef41Sopenharmony_civoid TurboAssembler::I64x2ReplaceLane(Simd128Register dst, Simd128Register src1, 52061cb0ef41Sopenharmony_ci Register src2, uint8_t imm_lane_idx, 52071cb0ef41Sopenharmony_ci Register) { 52081cb0ef41Sopenharmony_ci if (src1 != dst) { 52091cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 52101cb0ef41Sopenharmony_ci } 52111cb0ef41Sopenharmony_ci vlvg(dst, src2, MemOperand(r0, 1 - imm_lane_idx), Condition(3)); 52121cb0ef41Sopenharmony_ci} 52131cb0ef41Sopenharmony_ci 52141cb0ef41Sopenharmony_civoid TurboAssembler::I32x4ReplaceLane(Simd128Register dst, Simd128Register src1, 52151cb0ef41Sopenharmony_ci Register src2, uint8_t imm_lane_idx, 52161cb0ef41Sopenharmony_ci Register) { 52171cb0ef41Sopenharmony_ci if (src1 != dst) { 52181cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 52191cb0ef41Sopenharmony_ci } 52201cb0ef41Sopenharmony_ci vlvg(dst, src2, MemOperand(r0, 3 - imm_lane_idx), Condition(2)); 52211cb0ef41Sopenharmony_ci} 52221cb0ef41Sopenharmony_ci 52231cb0ef41Sopenharmony_civoid TurboAssembler::I16x8ReplaceLane(Simd128Register dst, Simd128Register src1, 52241cb0ef41Sopenharmony_ci Register src2, uint8_t imm_lane_idx, 52251cb0ef41Sopenharmony_ci Register) { 52261cb0ef41Sopenharmony_ci if (src1 != dst) { 52271cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 52281cb0ef41Sopenharmony_ci } 52291cb0ef41Sopenharmony_ci vlvg(dst, src2, MemOperand(r0, 7 - imm_lane_idx), Condition(1)); 52301cb0ef41Sopenharmony_ci} 52311cb0ef41Sopenharmony_ci 52321cb0ef41Sopenharmony_civoid TurboAssembler::I8x16ReplaceLane(Simd128Register dst, Simd128Register src1, 52331cb0ef41Sopenharmony_ci Register src2, uint8_t imm_lane_idx, 52341cb0ef41Sopenharmony_ci Register) { 52351cb0ef41Sopenharmony_ci if (src1 != dst) { 52361cb0ef41Sopenharmony_ci vlr(dst, src1, Condition(0), Condition(0), Condition(0)); 52371cb0ef41Sopenharmony_ci } 52381cb0ef41Sopenharmony_ci vlvg(dst, src2, MemOperand(r0, 15 - imm_lane_idx), Condition(0)); 52391cb0ef41Sopenharmony_ci} 52401cb0ef41Sopenharmony_ci 52411cb0ef41Sopenharmony_civoid TurboAssembler::S128Not(Simd128Register dst, Simd128Register src) { 52421cb0ef41Sopenharmony_ci vno(dst, src, src, Condition(0), Condition(0), Condition(0)); 52431cb0ef41Sopenharmony_ci} 52441cb0ef41Sopenharmony_ci 52451cb0ef41Sopenharmony_civoid TurboAssembler::S128Zero(Simd128Register dst, Simd128Register src) { 52461cb0ef41Sopenharmony_ci vx(dst, src, src, Condition(0), Condition(0), Condition(0)); 52471cb0ef41Sopenharmony_ci} 52481cb0ef41Sopenharmony_ci 52491cb0ef41Sopenharmony_civoid TurboAssembler::S128AllOnes(Simd128Register dst, Simd128Register src) { 52501cb0ef41Sopenharmony_ci vceq(dst, src, src, Condition(0), Condition(3)); 52511cb0ef41Sopenharmony_ci} 52521cb0ef41Sopenharmony_ci 52531cb0ef41Sopenharmony_civoid TurboAssembler::S128Select(Simd128Register dst, Simd128Register src1, 52541cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register mask) { 52551cb0ef41Sopenharmony_ci vsel(dst, src1, src2, mask, Condition(0), Condition(0)); 52561cb0ef41Sopenharmony_ci} 52571cb0ef41Sopenharmony_ci 52581cb0ef41Sopenharmony_ci#define SIMD_UNOP_LIST_VRR_A(V) \ 52591cb0ef41Sopenharmony_ci V(F64x2Abs, vfpso, 2, 0, 3) \ 52601cb0ef41Sopenharmony_ci V(F64x2Neg, vfpso, 0, 0, 3) \ 52611cb0ef41Sopenharmony_ci V(F64x2Sqrt, vfsq, 0, 0, 3) \ 52621cb0ef41Sopenharmony_ci V(F64x2Ceil, vfi, 6, 0, 3) \ 52631cb0ef41Sopenharmony_ci V(F64x2Floor, vfi, 7, 0, 3) \ 52641cb0ef41Sopenharmony_ci V(F64x2Trunc, vfi, 5, 0, 3) \ 52651cb0ef41Sopenharmony_ci V(F64x2NearestInt, vfi, 4, 0, 3) \ 52661cb0ef41Sopenharmony_ci V(F32x4Abs, vfpso, 2, 0, 2) \ 52671cb0ef41Sopenharmony_ci V(F32x4Neg, vfpso, 0, 0, 2) \ 52681cb0ef41Sopenharmony_ci V(F32x4Sqrt, vfsq, 0, 0, 2) \ 52691cb0ef41Sopenharmony_ci V(F32x4Ceil, vfi, 6, 0, 2) \ 52701cb0ef41Sopenharmony_ci V(F32x4Floor, vfi, 7, 0, 2) \ 52711cb0ef41Sopenharmony_ci V(F32x4Trunc, vfi, 5, 0, 2) \ 52721cb0ef41Sopenharmony_ci V(F32x4NearestInt, vfi, 4, 0, 2) \ 52731cb0ef41Sopenharmony_ci V(I64x2Abs, vlp, 0, 0, 3) \ 52741cb0ef41Sopenharmony_ci V(I64x2Neg, vlc, 0, 0, 3) \ 52751cb0ef41Sopenharmony_ci V(I64x2SConvertI32x4Low, vupl, 0, 0, 2) \ 52761cb0ef41Sopenharmony_ci V(I64x2SConvertI32x4High, vuph, 0, 0, 2) \ 52771cb0ef41Sopenharmony_ci V(I64x2UConvertI32x4Low, vupll, 0, 0, 2) \ 52781cb0ef41Sopenharmony_ci V(I64x2UConvertI32x4High, vuplh, 0, 0, 2) \ 52791cb0ef41Sopenharmony_ci V(I32x4Abs, vlp, 0, 0, 2) \ 52801cb0ef41Sopenharmony_ci V(I32x4Neg, vlc, 0, 0, 2) \ 52811cb0ef41Sopenharmony_ci V(I32x4SConvertI16x8Low, vupl, 0, 0, 1) \ 52821cb0ef41Sopenharmony_ci V(I32x4SConvertI16x8High, vuph, 0, 0, 1) \ 52831cb0ef41Sopenharmony_ci V(I32x4UConvertI16x8Low, vupll, 0, 0, 1) \ 52841cb0ef41Sopenharmony_ci V(I32x4UConvertI16x8High, vuplh, 0, 0, 1) \ 52851cb0ef41Sopenharmony_ci V(I16x8Abs, vlp, 0, 0, 1) \ 52861cb0ef41Sopenharmony_ci V(I16x8Neg, vlc, 0, 0, 1) \ 52871cb0ef41Sopenharmony_ci V(I16x8SConvertI8x16Low, vupl, 0, 0, 0) \ 52881cb0ef41Sopenharmony_ci V(I16x8SConvertI8x16High, vuph, 0, 0, 0) \ 52891cb0ef41Sopenharmony_ci V(I16x8UConvertI8x16Low, vupll, 0, 0, 0) \ 52901cb0ef41Sopenharmony_ci V(I16x8UConvertI8x16High, vuplh, 0, 0, 0) \ 52911cb0ef41Sopenharmony_ci V(I8x16Abs, vlp, 0, 0, 0) \ 52921cb0ef41Sopenharmony_ci V(I8x16Neg, vlc, 0, 0, 0) \ 52931cb0ef41Sopenharmony_ci V(I8x16Popcnt, vpopct, 0, 0, 0) 52941cb0ef41Sopenharmony_ci 52951cb0ef41Sopenharmony_ci#define EMIT_SIMD_UNOP_VRR_A(name, op, c1, c2, c3) \ 52961cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src) { \ 52971cb0ef41Sopenharmony_ci op(dst, src, Condition(c1), Condition(c2), Condition(c3)); \ 52981cb0ef41Sopenharmony_ci } 52991cb0ef41Sopenharmony_ciSIMD_UNOP_LIST_VRR_A(EMIT_SIMD_UNOP_VRR_A) 53001cb0ef41Sopenharmony_ci#undef EMIT_SIMD_UNOP_VRR_A 53011cb0ef41Sopenharmony_ci#undef SIMD_UNOP_LIST_VRR_A 53021cb0ef41Sopenharmony_ci 53031cb0ef41Sopenharmony_ci#define SIMD_BINOP_LIST_VRR_B(V) \ 53041cb0ef41Sopenharmony_ci V(I64x2Eq, vceq, 0, 3) \ 53051cb0ef41Sopenharmony_ci V(I64x2GtS, vch, 0, 3) \ 53061cb0ef41Sopenharmony_ci V(I32x4Eq, vceq, 0, 2) \ 53071cb0ef41Sopenharmony_ci V(I32x4GtS, vch, 0, 2) \ 53081cb0ef41Sopenharmony_ci V(I32x4GtU, vchl, 0, 2) \ 53091cb0ef41Sopenharmony_ci V(I16x8Eq, vceq, 0, 1) \ 53101cb0ef41Sopenharmony_ci V(I16x8GtS, vch, 0, 1) \ 53111cb0ef41Sopenharmony_ci V(I16x8GtU, vchl, 0, 1) \ 53121cb0ef41Sopenharmony_ci V(I8x16Eq, vceq, 0, 0) \ 53131cb0ef41Sopenharmony_ci V(I8x16GtS, vch, 0, 0) \ 53141cb0ef41Sopenharmony_ci V(I8x16GtU, vchl, 0, 0) 53151cb0ef41Sopenharmony_ci 53161cb0ef41Sopenharmony_ci#define EMIT_SIMD_BINOP_VRR_B(name, op, c1, c2) \ 53171cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 53181cb0ef41Sopenharmony_ci Simd128Register src2) { \ 53191cb0ef41Sopenharmony_ci op(dst, src1, src2, Condition(c1), Condition(c2)); \ 53201cb0ef41Sopenharmony_ci } 53211cb0ef41Sopenharmony_ciSIMD_BINOP_LIST_VRR_B(EMIT_SIMD_BINOP_VRR_B) 53221cb0ef41Sopenharmony_ci#undef EMIT_SIMD_BINOP_VRR_B 53231cb0ef41Sopenharmony_ci#undef SIMD_BINOP_LIST_VRR_B 53241cb0ef41Sopenharmony_ci 53251cb0ef41Sopenharmony_ci#define SIMD_BINOP_LIST_VRR_C(V) \ 53261cb0ef41Sopenharmony_ci V(F64x2Add, vfa, 0, 0, 3) \ 53271cb0ef41Sopenharmony_ci V(F64x2Sub, vfs, 0, 0, 3) \ 53281cb0ef41Sopenharmony_ci V(F64x2Mul, vfm, 0, 0, 3) \ 53291cb0ef41Sopenharmony_ci V(F64x2Div, vfd, 0, 0, 3) \ 53301cb0ef41Sopenharmony_ci V(F64x2Min, vfmin, 1, 0, 3) \ 53311cb0ef41Sopenharmony_ci V(F64x2Max, vfmax, 1, 0, 3) \ 53321cb0ef41Sopenharmony_ci V(F64x2Eq, vfce, 0, 0, 3) \ 53331cb0ef41Sopenharmony_ci V(F64x2Pmin, vfmin, 3, 0, 3) \ 53341cb0ef41Sopenharmony_ci V(F64x2Pmax, vfmax, 3, 0, 3) \ 53351cb0ef41Sopenharmony_ci V(F32x4Add, vfa, 0, 0, 2) \ 53361cb0ef41Sopenharmony_ci V(F32x4Sub, vfs, 0, 0, 2) \ 53371cb0ef41Sopenharmony_ci V(F32x4Mul, vfm, 0, 0, 2) \ 53381cb0ef41Sopenharmony_ci V(F32x4Div, vfd, 0, 0, 2) \ 53391cb0ef41Sopenharmony_ci V(F32x4Min, vfmin, 1, 0, 2) \ 53401cb0ef41Sopenharmony_ci V(F32x4Max, vfmax, 1, 0, 2) \ 53411cb0ef41Sopenharmony_ci V(F32x4Eq, vfce, 0, 0, 2) \ 53421cb0ef41Sopenharmony_ci V(F32x4Pmin, vfmin, 3, 0, 2) \ 53431cb0ef41Sopenharmony_ci V(F32x4Pmax, vfmax, 3, 0, 2) \ 53441cb0ef41Sopenharmony_ci V(I64x2Add, va, 0, 0, 3) \ 53451cb0ef41Sopenharmony_ci V(I64x2Sub, vs, 0, 0, 3) \ 53461cb0ef41Sopenharmony_ci V(I32x4Add, va, 0, 0, 2) \ 53471cb0ef41Sopenharmony_ci V(I32x4Sub, vs, 0, 0, 2) \ 53481cb0ef41Sopenharmony_ci V(I32x4Mul, vml, 0, 0, 2) \ 53491cb0ef41Sopenharmony_ci V(I32x4MinS, vmn, 0, 0, 2) \ 53501cb0ef41Sopenharmony_ci V(I32x4MinU, vmnl, 0, 0, 2) \ 53511cb0ef41Sopenharmony_ci V(I32x4MaxS, vmx, 0, 0, 2) \ 53521cb0ef41Sopenharmony_ci V(I32x4MaxU, vmxl, 0, 0, 2) \ 53531cb0ef41Sopenharmony_ci V(I16x8Add, va, 0, 0, 1) \ 53541cb0ef41Sopenharmony_ci V(I16x8Sub, vs, 0, 0, 1) \ 53551cb0ef41Sopenharmony_ci V(I16x8Mul, vml, 0, 0, 1) \ 53561cb0ef41Sopenharmony_ci V(I16x8MinS, vmn, 0, 0, 1) \ 53571cb0ef41Sopenharmony_ci V(I16x8MinU, vmnl, 0, 0, 1) \ 53581cb0ef41Sopenharmony_ci V(I16x8MaxS, vmx, 0, 0, 1) \ 53591cb0ef41Sopenharmony_ci V(I16x8MaxU, vmxl, 0, 0, 1) \ 53601cb0ef41Sopenharmony_ci V(I16x8RoundingAverageU, vavgl, 0, 0, 1) \ 53611cb0ef41Sopenharmony_ci V(I8x16Add, va, 0, 0, 0) \ 53621cb0ef41Sopenharmony_ci V(I8x16Sub, vs, 0, 0, 0) \ 53631cb0ef41Sopenharmony_ci V(I8x16MinS, vmn, 0, 0, 0) \ 53641cb0ef41Sopenharmony_ci V(I8x16MinU, vmnl, 0, 0, 0) \ 53651cb0ef41Sopenharmony_ci V(I8x16MaxS, vmx, 0, 0, 0) \ 53661cb0ef41Sopenharmony_ci V(I8x16MaxU, vmxl, 0, 0, 0) \ 53671cb0ef41Sopenharmony_ci V(I8x16RoundingAverageU, vavgl, 0, 0, 0) \ 53681cb0ef41Sopenharmony_ci V(S128And, vn, 0, 0, 0) \ 53691cb0ef41Sopenharmony_ci V(S128Or, vo, 0, 0, 0) \ 53701cb0ef41Sopenharmony_ci V(S128Xor, vx, 0, 0, 0) \ 53711cb0ef41Sopenharmony_ci V(S128AndNot, vnc, 0, 0, 0) 53721cb0ef41Sopenharmony_ci 53731cb0ef41Sopenharmony_ci#define EMIT_SIMD_BINOP_VRR_C(name, op, c1, c2, c3) \ 53741cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 53751cb0ef41Sopenharmony_ci Simd128Register src2) { \ 53761cb0ef41Sopenharmony_ci op(dst, src1, src2, Condition(c1), Condition(c2), Condition(c3)); \ 53771cb0ef41Sopenharmony_ci } 53781cb0ef41Sopenharmony_ciSIMD_BINOP_LIST_VRR_C(EMIT_SIMD_BINOP_VRR_C) 53791cb0ef41Sopenharmony_ci#undef EMIT_SIMD_BINOP_VRR_C 53801cb0ef41Sopenharmony_ci#undef SIMD_BINOP_LIST_VRR_C 53811cb0ef41Sopenharmony_ci 53821cb0ef41Sopenharmony_ci#define SIMD_SHIFT_LIST(V) \ 53831cb0ef41Sopenharmony_ci V(I64x2Shl, veslv, 3) \ 53841cb0ef41Sopenharmony_ci V(I64x2ShrS, vesrav, 3) \ 53851cb0ef41Sopenharmony_ci V(I64x2ShrU, vesrlv, 3) \ 53861cb0ef41Sopenharmony_ci V(I32x4Shl, veslv, 2) \ 53871cb0ef41Sopenharmony_ci V(I32x4ShrS, vesrav, 2) \ 53881cb0ef41Sopenharmony_ci V(I32x4ShrU, vesrlv, 2) \ 53891cb0ef41Sopenharmony_ci V(I16x8Shl, veslv, 1) \ 53901cb0ef41Sopenharmony_ci V(I16x8ShrS, vesrav, 1) \ 53911cb0ef41Sopenharmony_ci V(I16x8ShrU, vesrlv, 1) \ 53921cb0ef41Sopenharmony_ci V(I8x16Shl, veslv, 0) \ 53931cb0ef41Sopenharmony_ci V(I8x16ShrS, vesrav, 0) \ 53941cb0ef41Sopenharmony_ci V(I8x16ShrU, vesrlv, 0) 53951cb0ef41Sopenharmony_ci 53961cb0ef41Sopenharmony_ci#define EMIT_SIMD_SHIFT(name, op, c1) \ 53971cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 53981cb0ef41Sopenharmony_ci Register src2, Simd128Register scratch) { \ 53991cb0ef41Sopenharmony_ci vlvg(scratch, src2, MemOperand(r0, 0), Condition(c1)); \ 54001cb0ef41Sopenharmony_ci vrep(scratch, scratch, Operand(0), Condition(c1)); \ 54011cb0ef41Sopenharmony_ci op(dst, src1, scratch, Condition(0), Condition(0), Condition(c1)); \ 54021cb0ef41Sopenharmony_ci } \ 54031cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 54041cb0ef41Sopenharmony_ci const Operand& src2, Register scratch1, \ 54051cb0ef41Sopenharmony_ci Simd128Register scratch2) { \ 54061cb0ef41Sopenharmony_ci mov(scratch1, src2); \ 54071cb0ef41Sopenharmony_ci name(dst, src1, scratch1, scratch2); \ 54081cb0ef41Sopenharmony_ci } 54091cb0ef41Sopenharmony_ciSIMD_SHIFT_LIST(EMIT_SIMD_SHIFT) 54101cb0ef41Sopenharmony_ci#undef EMIT_SIMD_SHIFT 54111cb0ef41Sopenharmony_ci#undef SIMD_SHIFT_LIST 54121cb0ef41Sopenharmony_ci 54131cb0ef41Sopenharmony_ci#define SIMD_EXT_MUL_LIST(V) \ 54141cb0ef41Sopenharmony_ci V(I64x2ExtMulLowI32x4S, vme, vmo, vmrl, 2) \ 54151cb0ef41Sopenharmony_ci V(I64x2ExtMulHighI32x4S, vme, vmo, vmrh, 2) \ 54161cb0ef41Sopenharmony_ci V(I64x2ExtMulLowI32x4U, vmle, vmlo, vmrl, 2) \ 54171cb0ef41Sopenharmony_ci V(I64x2ExtMulHighI32x4U, vmle, vmlo, vmrh, 2) \ 54181cb0ef41Sopenharmony_ci V(I32x4ExtMulLowI16x8S, vme, vmo, vmrl, 1) \ 54191cb0ef41Sopenharmony_ci V(I32x4ExtMulHighI16x8S, vme, vmo, vmrh, 1) \ 54201cb0ef41Sopenharmony_ci V(I32x4ExtMulLowI16x8U, vmle, vmlo, vmrl, 1) \ 54211cb0ef41Sopenharmony_ci V(I32x4ExtMulHighI16x8U, vmle, vmlo, vmrh, 1) \ 54221cb0ef41Sopenharmony_ci V(I16x8ExtMulLowI8x16S, vme, vmo, vmrl, 0) \ 54231cb0ef41Sopenharmony_ci V(I16x8ExtMulHighI8x16S, vme, vmo, vmrh, 0) \ 54241cb0ef41Sopenharmony_ci V(I16x8ExtMulLowI8x16U, vmle, vmlo, vmrl, 0) \ 54251cb0ef41Sopenharmony_ci V(I16x8ExtMulHighI8x16U, vmle, vmlo, vmrh, 0) 54261cb0ef41Sopenharmony_ci 54271cb0ef41Sopenharmony_ci#define EMIT_SIMD_EXT_MUL(name, mul_even, mul_odd, merge, mode) \ 54281cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 54291cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register scratch) { \ 54301cb0ef41Sopenharmony_ci mul_even(scratch, src1, src2, Condition(0), Condition(0), \ 54311cb0ef41Sopenharmony_ci Condition(mode)); \ 54321cb0ef41Sopenharmony_ci mul_odd(dst, src1, src2, Condition(0), Condition(0), Condition(mode)); \ 54331cb0ef41Sopenharmony_ci merge(dst, scratch, dst, Condition(0), Condition(0), Condition(mode + 1)); \ 54341cb0ef41Sopenharmony_ci } 54351cb0ef41Sopenharmony_ciSIMD_EXT_MUL_LIST(EMIT_SIMD_EXT_MUL) 54361cb0ef41Sopenharmony_ci#undef EMIT_SIMD_EXT_MUL 54371cb0ef41Sopenharmony_ci#undef SIMD_EXT_MUL_LIST 54381cb0ef41Sopenharmony_ci 54391cb0ef41Sopenharmony_ci#define SIMD_ALL_TRUE_LIST(V) \ 54401cb0ef41Sopenharmony_ci V(I64x2AllTrue, 3) \ 54411cb0ef41Sopenharmony_ci V(I32x4AllTrue, 2) \ 54421cb0ef41Sopenharmony_ci V(I16x8AllTrue, 1) \ 54431cb0ef41Sopenharmony_ci V(I8x16AllTrue, 0) 54441cb0ef41Sopenharmony_ci 54451cb0ef41Sopenharmony_ci#define EMIT_SIMD_ALL_TRUE(name, mode) \ 54461cb0ef41Sopenharmony_ci void TurboAssembler::name(Register dst, Simd128Register src, \ 54471cb0ef41Sopenharmony_ci Register scratch1, Simd128Register scratch2) { \ 54481cb0ef41Sopenharmony_ci mov(scratch1, Operand(1)); \ 54491cb0ef41Sopenharmony_ci xgr(dst, dst); \ 54501cb0ef41Sopenharmony_ci vx(scratch2, scratch2, scratch2, Condition(0), Condition(0), \ 54511cb0ef41Sopenharmony_ci Condition(2)); \ 54521cb0ef41Sopenharmony_ci vceq(scratch2, src, scratch2, Condition(0), Condition(mode)); \ 54531cb0ef41Sopenharmony_ci vtm(scratch2, scratch2, Condition(0), Condition(0), Condition(0)); \ 54541cb0ef41Sopenharmony_ci locgr(Condition(8), dst, scratch1); \ 54551cb0ef41Sopenharmony_ci } 54561cb0ef41Sopenharmony_ciSIMD_ALL_TRUE_LIST(EMIT_SIMD_ALL_TRUE) 54571cb0ef41Sopenharmony_ci#undef EMIT_SIMD_ALL_TRUE 54581cb0ef41Sopenharmony_ci#undef SIMD_ALL_TRUE_LIST 54591cb0ef41Sopenharmony_ci 54601cb0ef41Sopenharmony_ci#define SIMD_QFM_LIST(V) \ 54611cb0ef41Sopenharmony_ci V(F64x2Qfma, vfma, 3) \ 54621cb0ef41Sopenharmony_ci V(F64x2Qfms, vfnms, 3) \ 54631cb0ef41Sopenharmony_ci V(F32x4Qfma, vfma, 2) \ 54641cb0ef41Sopenharmony_ci V(F32x4Qfms, vfnms, 2) 54651cb0ef41Sopenharmony_ci 54661cb0ef41Sopenharmony_ci#define EMIT_SIMD_QFM(name, op, c1) \ 54671cb0ef41Sopenharmony_ci void TurboAssembler::name(Simd128Register dst, Simd128Register src1, \ 54681cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register src3) { \ 54691cb0ef41Sopenharmony_ci op(dst, src2, src3, src1, Condition(c1), Condition(0)); \ 54701cb0ef41Sopenharmony_ci } 54711cb0ef41Sopenharmony_ciSIMD_QFM_LIST(EMIT_SIMD_QFM) 54721cb0ef41Sopenharmony_ci#undef EMIT_SIMD_QFM 54731cb0ef41Sopenharmony_ci#undef SIMD_QFM_LIST 54741cb0ef41Sopenharmony_ci 54751cb0ef41Sopenharmony_civoid TurboAssembler::I64x2Mul(Simd128Register dst, Simd128Register src1, 54761cb0ef41Sopenharmony_ci Simd128Register src2, Register scratch1, 54771cb0ef41Sopenharmony_ci Register scratch2, Register scratch3) { 54781cb0ef41Sopenharmony_ci Register scratch_1 = scratch1; 54791cb0ef41Sopenharmony_ci Register scratch_2 = scratch2; 54801cb0ef41Sopenharmony_ci for (int i = 0; i < 2; i++) { 54811cb0ef41Sopenharmony_ci vlgv(scratch_1, src1, MemOperand(r0, i), Condition(3)); 54821cb0ef41Sopenharmony_ci vlgv(scratch_2, src2, MemOperand(r0, i), Condition(3)); 54831cb0ef41Sopenharmony_ci MulS64(scratch_1, scratch_2); 54841cb0ef41Sopenharmony_ci scratch_1 = scratch2; 54851cb0ef41Sopenharmony_ci scratch_2 = scratch3; 54861cb0ef41Sopenharmony_ci } 54871cb0ef41Sopenharmony_ci vlvgp(dst, scratch1, scratch2); 54881cb0ef41Sopenharmony_ci} 54891cb0ef41Sopenharmony_ci 54901cb0ef41Sopenharmony_civoid TurboAssembler::F64x2Ne(Simd128Register dst, Simd128Register src1, 54911cb0ef41Sopenharmony_ci Simd128Register src2) { 54921cb0ef41Sopenharmony_ci vfce(dst, src1, src2, Condition(0), Condition(0), Condition(3)); 54931cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(3)); 54941cb0ef41Sopenharmony_ci} 54951cb0ef41Sopenharmony_ci 54961cb0ef41Sopenharmony_civoid TurboAssembler::F64x2Lt(Simd128Register dst, Simd128Register src1, 54971cb0ef41Sopenharmony_ci Simd128Register src2) { 54981cb0ef41Sopenharmony_ci vfch(dst, src2, src1, Condition(0), Condition(0), Condition(3)); 54991cb0ef41Sopenharmony_ci} 55001cb0ef41Sopenharmony_ci 55011cb0ef41Sopenharmony_civoid TurboAssembler::F64x2Le(Simd128Register dst, Simd128Register src1, 55021cb0ef41Sopenharmony_ci Simd128Register src2) { 55031cb0ef41Sopenharmony_ci vfche(dst, src2, src1, Condition(0), Condition(0), Condition(3)); 55041cb0ef41Sopenharmony_ci} 55051cb0ef41Sopenharmony_ci 55061cb0ef41Sopenharmony_civoid TurboAssembler::F32x4Ne(Simd128Register dst, Simd128Register src1, 55071cb0ef41Sopenharmony_ci Simd128Register src2) { 55081cb0ef41Sopenharmony_ci vfce(dst, src1, src2, Condition(0), Condition(0), Condition(2)); 55091cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 55101cb0ef41Sopenharmony_ci} 55111cb0ef41Sopenharmony_ci 55121cb0ef41Sopenharmony_civoid TurboAssembler::F32x4Lt(Simd128Register dst, Simd128Register src1, 55131cb0ef41Sopenharmony_ci Simd128Register src2) { 55141cb0ef41Sopenharmony_ci vfch(dst, src2, src1, Condition(0), Condition(0), Condition(2)); 55151cb0ef41Sopenharmony_ci} 55161cb0ef41Sopenharmony_ci 55171cb0ef41Sopenharmony_civoid TurboAssembler::F32x4Le(Simd128Register dst, Simd128Register src1, 55181cb0ef41Sopenharmony_ci Simd128Register src2) { 55191cb0ef41Sopenharmony_ci vfche(dst, src2, src1, Condition(0), Condition(0), Condition(2)); 55201cb0ef41Sopenharmony_ci} 55211cb0ef41Sopenharmony_ci 55221cb0ef41Sopenharmony_civoid TurboAssembler::I64x2Ne(Simd128Register dst, Simd128Register src1, 55231cb0ef41Sopenharmony_ci Simd128Register src2) { 55241cb0ef41Sopenharmony_ci vceq(dst, src1, src2, Condition(0), Condition(3)); 55251cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(3)); 55261cb0ef41Sopenharmony_ci} 55271cb0ef41Sopenharmony_ci 55281cb0ef41Sopenharmony_civoid TurboAssembler::I64x2GeS(Simd128Register dst, Simd128Register src1, 55291cb0ef41Sopenharmony_ci Simd128Register src2) { 55301cb0ef41Sopenharmony_ci // Compute !(B > A) which is equal to A >= B. 55311cb0ef41Sopenharmony_ci vch(dst, src2, src1, Condition(0), Condition(3)); 55321cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(3)); 55331cb0ef41Sopenharmony_ci} 55341cb0ef41Sopenharmony_ci 55351cb0ef41Sopenharmony_civoid TurboAssembler::I32x4Ne(Simd128Register dst, Simd128Register src1, 55361cb0ef41Sopenharmony_ci Simd128Register src2) { 55371cb0ef41Sopenharmony_ci vceq(dst, src1, src2, Condition(0), Condition(2)); 55381cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 55391cb0ef41Sopenharmony_ci} 55401cb0ef41Sopenharmony_ci 55411cb0ef41Sopenharmony_civoid TurboAssembler::I32x4GeS(Simd128Register dst, Simd128Register src1, 55421cb0ef41Sopenharmony_ci Simd128Register src2) { 55431cb0ef41Sopenharmony_ci // Compute !(B > A) which is equal to A >= B. 55441cb0ef41Sopenharmony_ci vch(dst, src2, src1, Condition(0), Condition(2)); 55451cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 55461cb0ef41Sopenharmony_ci} 55471cb0ef41Sopenharmony_ci 55481cb0ef41Sopenharmony_civoid TurboAssembler::I32x4GeU(Simd128Register dst, Simd128Register src1, 55491cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register scratch) { 55501cb0ef41Sopenharmony_ci vceq(scratch, src1, src2, Condition(0), Condition(2)); 55511cb0ef41Sopenharmony_ci vchl(dst, src1, src2, Condition(0), Condition(2)); 55521cb0ef41Sopenharmony_ci vo(dst, dst, scratch, Condition(0), Condition(0), Condition(2)); 55531cb0ef41Sopenharmony_ci} 55541cb0ef41Sopenharmony_ci 55551cb0ef41Sopenharmony_civoid TurboAssembler::I16x8Ne(Simd128Register dst, Simd128Register src1, 55561cb0ef41Sopenharmony_ci Simd128Register src2) { 55571cb0ef41Sopenharmony_ci vceq(dst, src1, src2, Condition(0), Condition(1)); 55581cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(1)); 55591cb0ef41Sopenharmony_ci} 55601cb0ef41Sopenharmony_ci 55611cb0ef41Sopenharmony_civoid TurboAssembler::I16x8GeS(Simd128Register dst, Simd128Register src1, 55621cb0ef41Sopenharmony_ci Simd128Register src2) { 55631cb0ef41Sopenharmony_ci // Compute !(B > A) which is equal to A >= B. 55641cb0ef41Sopenharmony_ci vch(dst, src2, src1, Condition(0), Condition(1)); 55651cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(1)); 55661cb0ef41Sopenharmony_ci} 55671cb0ef41Sopenharmony_ci 55681cb0ef41Sopenharmony_civoid TurboAssembler::I16x8GeU(Simd128Register dst, Simd128Register src1, 55691cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register scratch) { 55701cb0ef41Sopenharmony_ci vceq(scratch, src1, src2, Condition(0), Condition(1)); 55711cb0ef41Sopenharmony_ci vchl(dst, src1, src2, Condition(0), Condition(1)); 55721cb0ef41Sopenharmony_ci vo(dst, dst, scratch, Condition(0), Condition(0), Condition(1)); 55731cb0ef41Sopenharmony_ci} 55741cb0ef41Sopenharmony_ci 55751cb0ef41Sopenharmony_civoid TurboAssembler::I8x16Ne(Simd128Register dst, Simd128Register src1, 55761cb0ef41Sopenharmony_ci Simd128Register src2) { 55771cb0ef41Sopenharmony_ci vceq(dst, src1, src2, Condition(0), Condition(0)); 55781cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(0)); 55791cb0ef41Sopenharmony_ci} 55801cb0ef41Sopenharmony_ci 55811cb0ef41Sopenharmony_civoid TurboAssembler::I8x16GeS(Simd128Register dst, Simd128Register src1, 55821cb0ef41Sopenharmony_ci Simd128Register src2) { 55831cb0ef41Sopenharmony_ci // Compute !(B > A) which is equal to A >= B. 55841cb0ef41Sopenharmony_ci vch(dst, src2, src1, Condition(0), Condition(0)); 55851cb0ef41Sopenharmony_ci vno(dst, dst, dst, Condition(0), Condition(0), Condition(0)); 55861cb0ef41Sopenharmony_ci} 55871cb0ef41Sopenharmony_ci 55881cb0ef41Sopenharmony_civoid TurboAssembler::I8x16GeU(Simd128Register dst, Simd128Register src1, 55891cb0ef41Sopenharmony_ci Simd128Register src2, Simd128Register scratch) { 55901cb0ef41Sopenharmony_ci vceq(scratch, src1, src2, Condition(0), Condition(0)); 55911cb0ef41Sopenharmony_ci vchl(dst, src1, src2, Condition(0), Condition(0)); 55921cb0ef41Sopenharmony_ci vo(dst, dst, scratch, Condition(0), Condition(0), Condition(0)); 55931cb0ef41Sopenharmony_ci} 55941cb0ef41Sopenharmony_ci 55951cb0ef41Sopenharmony_civoid TurboAssembler::I64x2BitMask(Register dst, Simd128Register src, 55961cb0ef41Sopenharmony_ci Register scratch1, Simd128Register scratch2) { 55971cb0ef41Sopenharmony_ci mov(scratch1, Operand(0x8080808080800040)); 55981cb0ef41Sopenharmony_ci vlvg(scratch2, scratch1, MemOperand(r0, 1), Condition(3)); 55991cb0ef41Sopenharmony_ci vbperm(scratch2, src, scratch2, Condition(0), Condition(0), Condition(0)); 56001cb0ef41Sopenharmony_ci vlgv(dst, scratch2, MemOperand(r0, 7), Condition(0)); 56011cb0ef41Sopenharmony_ci} 56021cb0ef41Sopenharmony_ci 56031cb0ef41Sopenharmony_civoid TurboAssembler::I32x4BitMask(Register dst, Simd128Register src, 56041cb0ef41Sopenharmony_ci Register scratch1, Simd128Register scratch2) { 56051cb0ef41Sopenharmony_ci mov(scratch1, Operand(0x8080808000204060)); 56061cb0ef41Sopenharmony_ci vlvg(scratch2, scratch1, MemOperand(r0, 1), Condition(3)); 56071cb0ef41Sopenharmony_ci vbperm(scratch2, src, scratch2, Condition(0), Condition(0), Condition(0)); 56081cb0ef41Sopenharmony_ci vlgv(dst, scratch2, MemOperand(r0, 7), Condition(0)); 56091cb0ef41Sopenharmony_ci} 56101cb0ef41Sopenharmony_ci 56111cb0ef41Sopenharmony_civoid TurboAssembler::I16x8BitMask(Register dst, Simd128Register src, 56121cb0ef41Sopenharmony_ci Register scratch1, Simd128Register scratch2) { 56131cb0ef41Sopenharmony_ci mov(scratch1, Operand(0x10203040506070)); 56141cb0ef41Sopenharmony_ci vlvg(scratch2, scratch1, MemOperand(r0, 1), Condition(3)); 56151cb0ef41Sopenharmony_ci vbperm(scratch2, src, scratch2, Condition(0), Condition(0), Condition(0)); 56161cb0ef41Sopenharmony_ci vlgv(dst, scratch2, MemOperand(r0, 7), Condition(0)); 56171cb0ef41Sopenharmony_ci} 56181cb0ef41Sopenharmony_ci 56191cb0ef41Sopenharmony_civoid TurboAssembler::F64x2ConvertLowI32x4S(Simd128Register dst, 56201cb0ef41Sopenharmony_ci Simd128Register src) { 56211cb0ef41Sopenharmony_ci vupl(dst, src, Condition(0), Condition(0), Condition(2)); 56221cb0ef41Sopenharmony_ci vcdg(dst, dst, Condition(4), Condition(0), Condition(3)); 56231cb0ef41Sopenharmony_ci} 56241cb0ef41Sopenharmony_ci 56251cb0ef41Sopenharmony_civoid TurboAssembler::F64x2ConvertLowI32x4U(Simd128Register dst, 56261cb0ef41Sopenharmony_ci Simd128Register src) { 56271cb0ef41Sopenharmony_ci vupll(dst, src, Condition(0), Condition(0), Condition(2)); 56281cb0ef41Sopenharmony_ci vcdlg(dst, dst, Condition(4), Condition(0), Condition(3)); 56291cb0ef41Sopenharmony_ci} 56301cb0ef41Sopenharmony_ci 56311cb0ef41Sopenharmony_civoid TurboAssembler::I8x16BitMask(Register dst, Simd128Register src, 56321cb0ef41Sopenharmony_ci Register scratch1, Register scratch2, 56331cb0ef41Sopenharmony_ci Simd128Register scratch3) { 56341cb0ef41Sopenharmony_ci mov(scratch1, Operand(0x4048505860687078)); 56351cb0ef41Sopenharmony_ci mov(scratch2, Operand(0x8101820283038)); 56361cb0ef41Sopenharmony_ci vlvgp(scratch3, scratch2, scratch1); 56371cb0ef41Sopenharmony_ci vbperm(scratch3, src, scratch3, Condition(0), Condition(0), Condition(0)); 56381cb0ef41Sopenharmony_ci vlgv(dst, scratch3, MemOperand(r0, 3), Condition(1)); 56391cb0ef41Sopenharmony_ci} 56401cb0ef41Sopenharmony_ci 56411cb0ef41Sopenharmony_civoid TurboAssembler::V128AnyTrue(Register dst, Simd128Register src, 56421cb0ef41Sopenharmony_ci Register scratch) { 56431cb0ef41Sopenharmony_ci mov(dst, Operand(1)); 56441cb0ef41Sopenharmony_ci xgr(scratch, scratch); 56451cb0ef41Sopenharmony_ci vtm(src, src, Condition(0), Condition(0), Condition(0)); 56461cb0ef41Sopenharmony_ci locgr(Condition(8), dst, scratch); 56471cb0ef41Sopenharmony_ci} 56481cb0ef41Sopenharmony_ci 56491cb0ef41Sopenharmony_ci#define CONVERT_FLOAT_TO_INT32(convert, dst, src, scratch1, scratch2) \ 56501cb0ef41Sopenharmony_ci for (int index = 0; index < 4; index++) { \ 56511cb0ef41Sopenharmony_ci vlgv(scratch2, src, MemOperand(r0, index), Condition(2)); \ 56521cb0ef41Sopenharmony_ci MovIntToFloat(scratch1, scratch2); \ 56531cb0ef41Sopenharmony_ci convert(scratch2, scratch1, kRoundToZero); \ 56541cb0ef41Sopenharmony_ci vlvg(dst, scratch2, MemOperand(r0, index), Condition(2)); \ 56551cb0ef41Sopenharmony_ci } 56561cb0ef41Sopenharmony_civoid TurboAssembler::I32x4SConvertF32x4(Simd128Register dst, 56571cb0ef41Sopenharmony_ci Simd128Register src, 56581cb0ef41Sopenharmony_ci Simd128Register scratch1, 56591cb0ef41Sopenharmony_ci Register scratch2) { 56601cb0ef41Sopenharmony_ci // NaN to 0. 56611cb0ef41Sopenharmony_ci vfce(scratch1, src, src, Condition(0), Condition(0), Condition(2)); 56621cb0ef41Sopenharmony_ci vn(dst, src, scratch1, Condition(0), Condition(0), Condition(0)); 56631cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2)) { 56641cb0ef41Sopenharmony_ci vcgd(dst, dst, Condition(5), Condition(0), Condition(2)); 56651cb0ef41Sopenharmony_ci } else { 56661cb0ef41Sopenharmony_ci CONVERT_FLOAT_TO_INT32(ConvertFloat32ToInt32, dst, dst, scratch1, scratch2) 56671cb0ef41Sopenharmony_ci } 56681cb0ef41Sopenharmony_ci} 56691cb0ef41Sopenharmony_ci 56701cb0ef41Sopenharmony_civoid TurboAssembler::I32x4UConvertF32x4(Simd128Register dst, 56711cb0ef41Sopenharmony_ci Simd128Register src, 56721cb0ef41Sopenharmony_ci Simd128Register scratch1, 56731cb0ef41Sopenharmony_ci Register scratch2) { 56741cb0ef41Sopenharmony_ci // vclgd or ConvertFloat32ToUnsignedInt32 will convert NaN to 0, negative to 0 56751cb0ef41Sopenharmony_ci // automatically. 56761cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2)) { 56771cb0ef41Sopenharmony_ci vclgd(dst, src, Condition(5), Condition(0), Condition(2)); 56781cb0ef41Sopenharmony_ci } else { 56791cb0ef41Sopenharmony_ci CONVERT_FLOAT_TO_INT32(ConvertFloat32ToUnsignedInt32, dst, src, scratch1, 56801cb0ef41Sopenharmony_ci scratch2) 56811cb0ef41Sopenharmony_ci } 56821cb0ef41Sopenharmony_ci} 56831cb0ef41Sopenharmony_ci#undef CONVERT_FLOAT_TO_INT32 56841cb0ef41Sopenharmony_ci 56851cb0ef41Sopenharmony_ci#define CONVERT_INT32_TO_FLOAT(convert, dst, src, scratch1, scratch2) \ 56861cb0ef41Sopenharmony_ci for (int index = 0; index < 4; index++) { \ 56871cb0ef41Sopenharmony_ci vlgv(scratch2, src, MemOperand(r0, index), Condition(2)); \ 56881cb0ef41Sopenharmony_ci convert(scratch1, scratch2); \ 56891cb0ef41Sopenharmony_ci MovFloatToInt(scratch2, scratch1); \ 56901cb0ef41Sopenharmony_ci vlvg(dst, scratch2, MemOperand(r0, index), Condition(2)); \ 56911cb0ef41Sopenharmony_ci } 56921cb0ef41Sopenharmony_civoid TurboAssembler::F32x4SConvertI32x4(Simd128Register dst, 56931cb0ef41Sopenharmony_ci Simd128Register src, 56941cb0ef41Sopenharmony_ci Simd128Register scratch1, 56951cb0ef41Sopenharmony_ci Register scratch2) { 56961cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2)) { 56971cb0ef41Sopenharmony_ci vcdg(dst, src, Condition(4), Condition(0), Condition(2)); 56981cb0ef41Sopenharmony_ci } else { 56991cb0ef41Sopenharmony_ci CONVERT_INT32_TO_FLOAT(ConvertIntToFloat, dst, src, scratch1, scratch2) 57001cb0ef41Sopenharmony_ci } 57011cb0ef41Sopenharmony_ci} 57021cb0ef41Sopenharmony_civoid TurboAssembler::F32x4UConvertI32x4(Simd128Register dst, 57031cb0ef41Sopenharmony_ci Simd128Register src, 57041cb0ef41Sopenharmony_ci Simd128Register scratch1, 57051cb0ef41Sopenharmony_ci Register scratch2) { 57061cb0ef41Sopenharmony_ci if (CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2)) { 57071cb0ef41Sopenharmony_ci vcdlg(dst, src, Condition(4), Condition(0), Condition(2)); 57081cb0ef41Sopenharmony_ci } else { 57091cb0ef41Sopenharmony_ci CONVERT_INT32_TO_FLOAT(ConvertUnsignedIntToFloat, dst, src, scratch1, 57101cb0ef41Sopenharmony_ci scratch2) 57111cb0ef41Sopenharmony_ci } 57121cb0ef41Sopenharmony_ci} 57131cb0ef41Sopenharmony_ci#undef CONVERT_INT32_TO_FLOAT 57141cb0ef41Sopenharmony_ci 57151cb0ef41Sopenharmony_civoid TurboAssembler::I16x8SConvertI32x4(Simd128Register dst, 57161cb0ef41Sopenharmony_ci Simd128Register src1, 57171cb0ef41Sopenharmony_ci Simd128Register src2) { 57181cb0ef41Sopenharmony_ci vpks(dst, src2, src1, Condition(0), Condition(2)); 57191cb0ef41Sopenharmony_ci} 57201cb0ef41Sopenharmony_ci 57211cb0ef41Sopenharmony_civoid TurboAssembler::I8x16SConvertI16x8(Simd128Register dst, 57221cb0ef41Sopenharmony_ci Simd128Register src1, 57231cb0ef41Sopenharmony_ci Simd128Register src2) { 57241cb0ef41Sopenharmony_ci vpks(dst, src2, src1, Condition(0), Condition(1)); 57251cb0ef41Sopenharmony_ci} 57261cb0ef41Sopenharmony_ci 57271cb0ef41Sopenharmony_ci#define VECTOR_PACK_UNSIGNED(dst, src1, src2, scratch, mode) \ 57281cb0ef41Sopenharmony_ci vx(kDoubleRegZero, kDoubleRegZero, kDoubleRegZero, Condition(0), \ 57291cb0ef41Sopenharmony_ci Condition(0), Condition(mode)); \ 57301cb0ef41Sopenharmony_ci vmx(scratch, src1, kDoubleRegZero, Condition(0), Condition(0), \ 57311cb0ef41Sopenharmony_ci Condition(mode)); \ 57321cb0ef41Sopenharmony_ci vmx(dst, src2, kDoubleRegZero, Condition(0), Condition(0), Condition(mode)); 57331cb0ef41Sopenharmony_civoid TurboAssembler::I16x8UConvertI32x4(Simd128Register dst, 57341cb0ef41Sopenharmony_ci Simd128Register src1, 57351cb0ef41Sopenharmony_ci Simd128Register src2, 57361cb0ef41Sopenharmony_ci Simd128Register scratch) { 57371cb0ef41Sopenharmony_ci // treat inputs as signed, and saturate to unsigned (negative to 0). 57381cb0ef41Sopenharmony_ci VECTOR_PACK_UNSIGNED(dst, src1, src2, scratch, 2) 57391cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch, Condition(0), Condition(2)); 57401cb0ef41Sopenharmony_ci} 57411cb0ef41Sopenharmony_ci 57421cb0ef41Sopenharmony_civoid TurboAssembler::I8x16UConvertI16x8(Simd128Register dst, 57431cb0ef41Sopenharmony_ci Simd128Register src1, 57441cb0ef41Sopenharmony_ci Simd128Register src2, 57451cb0ef41Sopenharmony_ci Simd128Register scratch) { 57461cb0ef41Sopenharmony_ci // treat inputs as signed, and saturate to unsigned (negative to 0). 57471cb0ef41Sopenharmony_ci VECTOR_PACK_UNSIGNED(dst, src1, src2, scratch, 1) 57481cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch, Condition(0), Condition(1)); 57491cb0ef41Sopenharmony_ci} 57501cb0ef41Sopenharmony_ci#undef VECTOR_PACK_UNSIGNED 57511cb0ef41Sopenharmony_ci 57521cb0ef41Sopenharmony_ci#define BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, op, extract_high, \ 57531cb0ef41Sopenharmony_ci extract_low, mode) \ 57541cb0ef41Sopenharmony_ci DCHECK(dst != scratch1 && dst != scratch2); \ 57551cb0ef41Sopenharmony_ci DCHECK(dst != src1 && dst != src2); \ 57561cb0ef41Sopenharmony_ci extract_high(scratch1, src1, Condition(0), Condition(0), Condition(mode)); \ 57571cb0ef41Sopenharmony_ci extract_high(scratch2, src2, Condition(0), Condition(0), Condition(mode)); \ 57581cb0ef41Sopenharmony_ci op(dst, scratch1, scratch2, Condition(0), Condition(0), \ 57591cb0ef41Sopenharmony_ci Condition(mode + 1)); \ 57601cb0ef41Sopenharmony_ci extract_low(scratch1, src1, Condition(0), Condition(0), Condition(mode)); \ 57611cb0ef41Sopenharmony_ci extract_low(scratch2, src2, Condition(0), Condition(0), Condition(mode)); \ 57621cb0ef41Sopenharmony_ci op(scratch1, scratch1, scratch2, Condition(0), Condition(0), \ 57631cb0ef41Sopenharmony_ci Condition(mode + 1)); 57641cb0ef41Sopenharmony_civoid TurboAssembler::I16x8AddSatS(Simd128Register dst, Simd128Register src1, 57651cb0ef41Sopenharmony_ci Simd128Register src2, 57661cb0ef41Sopenharmony_ci Simd128Register scratch1, 57671cb0ef41Sopenharmony_ci Simd128Register scratch2) { 57681cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, va, vuph, vupl, 1) 57691cb0ef41Sopenharmony_ci vpks(dst, dst, scratch1, Condition(0), Condition(2)); 57701cb0ef41Sopenharmony_ci} 57711cb0ef41Sopenharmony_ci 57721cb0ef41Sopenharmony_civoid TurboAssembler::I16x8SubSatS(Simd128Register dst, Simd128Register src1, 57731cb0ef41Sopenharmony_ci Simd128Register src2, 57741cb0ef41Sopenharmony_ci Simd128Register scratch1, 57751cb0ef41Sopenharmony_ci Simd128Register scratch2) { 57761cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, vs, vuph, vupl, 1) 57771cb0ef41Sopenharmony_ci vpks(dst, dst, scratch1, Condition(0), Condition(2)); 57781cb0ef41Sopenharmony_ci} 57791cb0ef41Sopenharmony_ci 57801cb0ef41Sopenharmony_civoid TurboAssembler::I16x8AddSatU(Simd128Register dst, Simd128Register src1, 57811cb0ef41Sopenharmony_ci Simd128Register src2, 57821cb0ef41Sopenharmony_ci Simd128Register scratch1, 57831cb0ef41Sopenharmony_ci Simd128Register scratch2) { 57841cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, va, vuplh, vupll, 1) 57851cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch1, Condition(0), Condition(2)); 57861cb0ef41Sopenharmony_ci} 57871cb0ef41Sopenharmony_ci 57881cb0ef41Sopenharmony_civoid TurboAssembler::I16x8SubSatU(Simd128Register dst, Simd128Register src1, 57891cb0ef41Sopenharmony_ci Simd128Register src2, 57901cb0ef41Sopenharmony_ci Simd128Register scratch1, 57911cb0ef41Sopenharmony_ci Simd128Register scratch2) { 57921cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, vs, vuplh, vupll, 1) 57931cb0ef41Sopenharmony_ci // negative intermediate values to 0. 57941cb0ef41Sopenharmony_ci vx(kDoubleRegZero, kDoubleRegZero, kDoubleRegZero, Condition(0), Condition(0), 57951cb0ef41Sopenharmony_ci Condition(0)); 57961cb0ef41Sopenharmony_ci vmx(dst, kDoubleRegZero, dst, Condition(0), Condition(0), Condition(2)); 57971cb0ef41Sopenharmony_ci vmx(scratch1, kDoubleRegZero, scratch1, Condition(0), Condition(0), 57981cb0ef41Sopenharmony_ci Condition(2)); 57991cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch1, Condition(0), Condition(2)); 58001cb0ef41Sopenharmony_ci} 58011cb0ef41Sopenharmony_ci 58021cb0ef41Sopenharmony_civoid TurboAssembler::I8x16AddSatS(Simd128Register dst, Simd128Register src1, 58031cb0ef41Sopenharmony_ci Simd128Register src2, 58041cb0ef41Sopenharmony_ci Simd128Register scratch1, 58051cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58061cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, va, vuph, vupl, 0) 58071cb0ef41Sopenharmony_ci vpks(dst, dst, scratch1, Condition(0), Condition(1)); 58081cb0ef41Sopenharmony_ci} 58091cb0ef41Sopenharmony_ci 58101cb0ef41Sopenharmony_civoid TurboAssembler::I8x16SubSatS(Simd128Register dst, Simd128Register src1, 58111cb0ef41Sopenharmony_ci Simd128Register src2, 58121cb0ef41Sopenharmony_ci Simd128Register scratch1, 58131cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58141cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, vs, vuph, vupl, 0) 58151cb0ef41Sopenharmony_ci vpks(dst, dst, scratch1, Condition(0), Condition(1)); 58161cb0ef41Sopenharmony_ci} 58171cb0ef41Sopenharmony_ci 58181cb0ef41Sopenharmony_civoid TurboAssembler::I8x16AddSatU(Simd128Register dst, Simd128Register src1, 58191cb0ef41Sopenharmony_ci Simd128Register src2, 58201cb0ef41Sopenharmony_ci Simd128Register scratch1, 58211cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58221cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, va, vuplh, vupll, 0) 58231cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch1, Condition(0), Condition(1)); 58241cb0ef41Sopenharmony_ci} 58251cb0ef41Sopenharmony_ci 58261cb0ef41Sopenharmony_civoid TurboAssembler::I8x16SubSatU(Simd128Register dst, Simd128Register src1, 58271cb0ef41Sopenharmony_ci Simd128Register src2, 58281cb0ef41Sopenharmony_ci Simd128Register scratch1, 58291cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58301cb0ef41Sopenharmony_ci BINOP_EXTRACT(dst, src1, src2, scratch1, scratch2, vs, vuplh, vupll, 0) 58311cb0ef41Sopenharmony_ci // negative intermediate values to 0. 58321cb0ef41Sopenharmony_ci vx(kDoubleRegZero, kDoubleRegZero, kDoubleRegZero, Condition(0), Condition(0), 58331cb0ef41Sopenharmony_ci Condition(0)); 58341cb0ef41Sopenharmony_ci vmx(dst, kDoubleRegZero, dst, Condition(0), Condition(0), Condition(1)); 58351cb0ef41Sopenharmony_ci vmx(scratch1, kDoubleRegZero, scratch1, Condition(0), Condition(0), 58361cb0ef41Sopenharmony_ci Condition(1)); 58371cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch1, Condition(0), Condition(1)); 58381cb0ef41Sopenharmony_ci} 58391cb0ef41Sopenharmony_ci#undef BINOP_EXTRACT 58401cb0ef41Sopenharmony_ci 58411cb0ef41Sopenharmony_civoid TurboAssembler::F64x2PromoteLowF32x4(Simd128Register dst, 58421cb0ef41Sopenharmony_ci Simd128Register src, 58431cb0ef41Sopenharmony_ci Simd128Register scratch1, 58441cb0ef41Sopenharmony_ci Register scratch2, Register scratch3, 58451cb0ef41Sopenharmony_ci Register scratch4) { 58461cb0ef41Sopenharmony_ci Register holder = scratch3; 58471cb0ef41Sopenharmony_ci for (int index = 0; index < 2; ++index) { 58481cb0ef41Sopenharmony_ci vlgv(scratch2, src, MemOperand(scratch2, index + 2), Condition(2)); 58491cb0ef41Sopenharmony_ci MovIntToFloat(scratch1, scratch2); 58501cb0ef41Sopenharmony_ci ldebr(scratch1, scratch1); 58511cb0ef41Sopenharmony_ci MovDoubleToInt64(holder, scratch1); 58521cb0ef41Sopenharmony_ci holder = scratch4; 58531cb0ef41Sopenharmony_ci } 58541cb0ef41Sopenharmony_ci vlvgp(dst, scratch3, scratch4); 58551cb0ef41Sopenharmony_ci} 58561cb0ef41Sopenharmony_ci 58571cb0ef41Sopenharmony_civoid TurboAssembler::F32x4DemoteF64x2Zero(Simd128Register dst, 58581cb0ef41Sopenharmony_ci Simd128Register src, 58591cb0ef41Sopenharmony_ci Simd128Register scratch1, 58601cb0ef41Sopenharmony_ci Register scratch2, Register scratch3, 58611cb0ef41Sopenharmony_ci Register scratch4) { 58621cb0ef41Sopenharmony_ci Register holder = scratch3; 58631cb0ef41Sopenharmony_ci for (int index = 0; index < 2; ++index) { 58641cb0ef41Sopenharmony_ci vlgv(scratch2, src, MemOperand(r0, index), Condition(3)); 58651cb0ef41Sopenharmony_ci MovInt64ToDouble(scratch1, scratch2); 58661cb0ef41Sopenharmony_ci ledbr(scratch1, scratch1); 58671cb0ef41Sopenharmony_ci MovFloatToInt(holder, scratch1); 58681cb0ef41Sopenharmony_ci holder = scratch4; 58691cb0ef41Sopenharmony_ci } 58701cb0ef41Sopenharmony_ci vx(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 58711cb0ef41Sopenharmony_ci vlvg(dst, scratch3, MemOperand(r0, 2), Condition(2)); 58721cb0ef41Sopenharmony_ci vlvg(dst, scratch4, MemOperand(r0, 3), Condition(2)); 58731cb0ef41Sopenharmony_ci} 58741cb0ef41Sopenharmony_ci 58751cb0ef41Sopenharmony_ci#define EXT_ADD_PAIRWISE(dst, src, scratch1, scratch2, lane_size, mul_even, \ 58761cb0ef41Sopenharmony_ci mul_odd) \ 58771cb0ef41Sopenharmony_ci CHECK_NE(src, scratch2); \ 58781cb0ef41Sopenharmony_ci vrepi(scratch2, Operand(1), Condition(lane_size)); \ 58791cb0ef41Sopenharmony_ci mul_even(scratch1, src, scratch2, Condition(0), Condition(0), \ 58801cb0ef41Sopenharmony_ci Condition(lane_size)); \ 58811cb0ef41Sopenharmony_ci mul_odd(scratch2, src, scratch2, Condition(0), Condition(0), \ 58821cb0ef41Sopenharmony_ci Condition(lane_size)); \ 58831cb0ef41Sopenharmony_ci va(dst, scratch1, scratch2, Condition(0), Condition(0), \ 58841cb0ef41Sopenharmony_ci Condition(lane_size + 1)); 58851cb0ef41Sopenharmony_civoid TurboAssembler::I32x4ExtAddPairwiseI16x8S(Simd128Register dst, 58861cb0ef41Sopenharmony_ci Simd128Register src, 58871cb0ef41Sopenharmony_ci Simd128Register scratch1, 58881cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58891cb0ef41Sopenharmony_ci EXT_ADD_PAIRWISE(dst, src, scratch1, scratch2, 1, vme, vmo) 58901cb0ef41Sopenharmony_ci} 58911cb0ef41Sopenharmony_ci 58921cb0ef41Sopenharmony_civoid TurboAssembler::I32x4ExtAddPairwiseI16x8U(Simd128Register dst, 58931cb0ef41Sopenharmony_ci Simd128Register src, 58941cb0ef41Sopenharmony_ci Simd128Register scratch, 58951cb0ef41Sopenharmony_ci Simd128Register scratch2) { 58961cb0ef41Sopenharmony_ci vx(scratch, scratch, scratch, Condition(0), Condition(0), Condition(3)); 58971cb0ef41Sopenharmony_ci vsum(dst, src, scratch, Condition(0), Condition(0), Condition(1)); 58981cb0ef41Sopenharmony_ci} 58991cb0ef41Sopenharmony_ci 59001cb0ef41Sopenharmony_civoid TurboAssembler::I16x8ExtAddPairwiseI8x16S(Simd128Register dst, 59011cb0ef41Sopenharmony_ci Simd128Register src, 59021cb0ef41Sopenharmony_ci Simd128Register scratch1, 59031cb0ef41Sopenharmony_ci Simd128Register scratch2) { 59041cb0ef41Sopenharmony_ci EXT_ADD_PAIRWISE(dst, src, scratch1, scratch2, 0, vme, vmo) 59051cb0ef41Sopenharmony_ci} 59061cb0ef41Sopenharmony_ci 59071cb0ef41Sopenharmony_civoid TurboAssembler::I16x8ExtAddPairwiseI8x16U(Simd128Register dst, 59081cb0ef41Sopenharmony_ci Simd128Register src, 59091cb0ef41Sopenharmony_ci Simd128Register scratch1, 59101cb0ef41Sopenharmony_ci Simd128Register scratch2) { 59111cb0ef41Sopenharmony_ci EXT_ADD_PAIRWISE(dst, src, scratch1, scratch2, 0, vmle, vmlo) 59121cb0ef41Sopenharmony_ci} 59131cb0ef41Sopenharmony_ci#undef EXT_ADD_PAIRWISE 59141cb0ef41Sopenharmony_ci 59151cb0ef41Sopenharmony_civoid TurboAssembler::I32x4TruncSatF64x2SZero(Simd128Register dst, 59161cb0ef41Sopenharmony_ci Simd128Register src, 59171cb0ef41Sopenharmony_ci Simd128Register scratch) { 59181cb0ef41Sopenharmony_ci // NaN to 0. 59191cb0ef41Sopenharmony_ci vlr(scratch, src, Condition(0), Condition(0), Condition(0)); 59201cb0ef41Sopenharmony_ci vfce(scratch, scratch, scratch, Condition(0), Condition(0), Condition(3)); 59211cb0ef41Sopenharmony_ci vn(scratch, src, scratch, Condition(0), Condition(0), Condition(0)); 59221cb0ef41Sopenharmony_ci vcgd(scratch, scratch, Condition(5), Condition(0), Condition(3)); 59231cb0ef41Sopenharmony_ci vx(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 59241cb0ef41Sopenharmony_ci vpks(dst, dst, scratch, Condition(0), Condition(3)); 59251cb0ef41Sopenharmony_ci} 59261cb0ef41Sopenharmony_ci 59271cb0ef41Sopenharmony_civoid TurboAssembler::I32x4TruncSatF64x2UZero(Simd128Register dst, 59281cb0ef41Sopenharmony_ci Simd128Register src, 59291cb0ef41Sopenharmony_ci Simd128Register scratch) { 59301cb0ef41Sopenharmony_ci vclgd(scratch, src, Condition(5), Condition(0), Condition(3)); 59311cb0ef41Sopenharmony_ci vx(dst, dst, dst, Condition(0), Condition(0), Condition(2)); 59321cb0ef41Sopenharmony_ci vpkls(dst, dst, scratch, Condition(0), Condition(3)); 59331cb0ef41Sopenharmony_ci} 59341cb0ef41Sopenharmony_ci 59351cb0ef41Sopenharmony_civoid TurboAssembler::S128Const(Simd128Register dst, uint64_t high, uint64_t low, 59361cb0ef41Sopenharmony_ci Register scratch1, Register scratch2) { 59371cb0ef41Sopenharmony_ci mov(scratch1, Operand(low)); 59381cb0ef41Sopenharmony_ci mov(scratch2, Operand(high)); 59391cb0ef41Sopenharmony_ci vlvgp(dst, scratch2, scratch1); 59401cb0ef41Sopenharmony_ci} 59411cb0ef41Sopenharmony_ci 59421cb0ef41Sopenharmony_civoid TurboAssembler::I8x16Swizzle(Simd128Register dst, Simd128Register src1, 59431cb0ef41Sopenharmony_ci Simd128Register src2, Register scratch1, 59441cb0ef41Sopenharmony_ci Register scratch2, Simd128Register scratch3, 59451cb0ef41Sopenharmony_ci Simd128Register scratch4) { 59461cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src1, src2, scratch3, scratch4)); 59471cb0ef41Sopenharmony_ci // Saturate the indices to 5 bits. Input indices more than 31 should 59481cb0ef41Sopenharmony_ci // return 0. 59491cb0ef41Sopenharmony_ci vrepi(scratch3, Operand(31), Condition(0)); 59501cb0ef41Sopenharmony_ci vmnl(scratch4, src2, scratch3, Condition(0), Condition(0), Condition(0)); 59511cb0ef41Sopenharmony_ci // Input needs to be reversed. 59521cb0ef41Sopenharmony_ci vlgv(scratch1, src1, MemOperand(r0, 0), Condition(3)); 59531cb0ef41Sopenharmony_ci vlgv(scratch2, src1, MemOperand(r0, 1), Condition(3)); 59541cb0ef41Sopenharmony_ci lrvgr(scratch1, scratch1); 59551cb0ef41Sopenharmony_ci lrvgr(scratch2, scratch2); 59561cb0ef41Sopenharmony_ci vlvgp(dst, scratch2, scratch1); 59571cb0ef41Sopenharmony_ci // Clear scratch. 59581cb0ef41Sopenharmony_ci vx(scratch3, scratch3, scratch3, Condition(0), Condition(0), Condition(0)); 59591cb0ef41Sopenharmony_ci vperm(dst, dst, scratch3, scratch4, Condition(0), Condition(0)); 59601cb0ef41Sopenharmony_ci} 59611cb0ef41Sopenharmony_ci 59621cb0ef41Sopenharmony_civoid TurboAssembler::I8x16Shuffle(Simd128Register dst, Simd128Register src1, 59631cb0ef41Sopenharmony_ci Simd128Register src2, uint64_t high, 59641cb0ef41Sopenharmony_ci uint64_t low, Register scratch1, 59651cb0ef41Sopenharmony_ci Register scratch2, Simd128Register scratch3) { 59661cb0ef41Sopenharmony_ci mov(scratch1, Operand(low)); 59671cb0ef41Sopenharmony_ci mov(scratch2, Operand(high)); 59681cb0ef41Sopenharmony_ci vlvgp(scratch3, scratch2, scratch1); 59691cb0ef41Sopenharmony_ci vperm(dst, src1, src2, scratch3, Condition(0), Condition(0)); 59701cb0ef41Sopenharmony_ci} 59711cb0ef41Sopenharmony_ci 59721cb0ef41Sopenharmony_civoid TurboAssembler::I32x4DotI16x8S(Simd128Register dst, Simd128Register src1, 59731cb0ef41Sopenharmony_ci Simd128Register src2, 59741cb0ef41Sopenharmony_ci Simd128Register scratch) { 59751cb0ef41Sopenharmony_ci vme(scratch, src1, src2, Condition(0), Condition(0), Condition(1)); 59761cb0ef41Sopenharmony_ci vmo(dst, src1, src2, Condition(0), Condition(0), Condition(1)); 59771cb0ef41Sopenharmony_ci va(dst, scratch, dst, Condition(0), Condition(0), Condition(2)); 59781cb0ef41Sopenharmony_ci} 59791cb0ef41Sopenharmony_ci 59801cb0ef41Sopenharmony_ci#define Q15_MUL_ROAUND(accumulator, src1, src2, const_val, scratch, unpack) \ 59811cb0ef41Sopenharmony_ci unpack(scratch, src1, Condition(0), Condition(0), Condition(1)); \ 59821cb0ef41Sopenharmony_ci unpack(accumulator, src2, Condition(0), Condition(0), Condition(1)); \ 59831cb0ef41Sopenharmony_ci vml(accumulator, scratch, accumulator, Condition(0), Condition(0), \ 59841cb0ef41Sopenharmony_ci Condition(2)); \ 59851cb0ef41Sopenharmony_ci va(accumulator, accumulator, const_val, Condition(0), Condition(0), \ 59861cb0ef41Sopenharmony_ci Condition(2)); \ 59871cb0ef41Sopenharmony_ci vrepi(scratch, Operand(15), Condition(2)); \ 59881cb0ef41Sopenharmony_ci vesrav(accumulator, accumulator, scratch, Condition(0), Condition(0), \ 59891cb0ef41Sopenharmony_ci Condition(2)); 59901cb0ef41Sopenharmony_civoid TurboAssembler::I16x8Q15MulRSatS(Simd128Register dst, Simd128Register src1, 59911cb0ef41Sopenharmony_ci Simd128Register src2, 59921cb0ef41Sopenharmony_ci Simd128Register scratch1, 59931cb0ef41Sopenharmony_ci Simd128Register scratch2, 59941cb0ef41Sopenharmony_ci Simd128Register scratch3) { 59951cb0ef41Sopenharmony_ci DCHECK(!AreAliased(src1, src2, scratch1, scratch2, scratch3)); 59961cb0ef41Sopenharmony_ci vrepi(scratch1, Operand(0x4000), Condition(2)); 59971cb0ef41Sopenharmony_ci Q15_MUL_ROAUND(scratch2, src1, src2, scratch1, scratch3, vupl) 59981cb0ef41Sopenharmony_ci Q15_MUL_ROAUND(dst, src1, src2, scratch1, scratch3, vuph) 59991cb0ef41Sopenharmony_ci vpks(dst, dst, scratch2, Condition(0), Condition(2)); 60001cb0ef41Sopenharmony_ci} 60011cb0ef41Sopenharmony_ci#undef Q15_MUL_ROAUND 60021cb0ef41Sopenharmony_ci 60031cb0ef41Sopenharmony_ci// Vector LE Load and Transform instructions. 60041cb0ef41Sopenharmony_ci#ifdef V8_TARGET_BIG_ENDIAN 60051cb0ef41Sopenharmony_ci#define IS_BIG_ENDIAN true 60061cb0ef41Sopenharmony_ci#else 60071cb0ef41Sopenharmony_ci#define IS_BIG_ENDIAN false 60081cb0ef41Sopenharmony_ci#endif 60091cb0ef41Sopenharmony_ci 60101cb0ef41Sopenharmony_ci#define CAN_LOAD_STORE_REVERSE \ 60111cb0ef41Sopenharmony_ci IS_BIG_ENDIAN&& CpuFeatures::IsSupported(VECTOR_ENHANCE_FACILITY_2) 60121cb0ef41Sopenharmony_ci 60131cb0ef41Sopenharmony_ci#define LOAD_SPLAT_LIST(V) \ 60141cb0ef41Sopenharmony_ci V(64x2, vlbrrep, LoadU64LE, 3) \ 60151cb0ef41Sopenharmony_ci V(32x4, vlbrrep, LoadU32LE, 2) \ 60161cb0ef41Sopenharmony_ci V(16x8, vlbrrep, LoadU16LE, 1) \ 60171cb0ef41Sopenharmony_ci V(8x16, vlrep, LoadU8, 0) 60181cb0ef41Sopenharmony_ci 60191cb0ef41Sopenharmony_ci#define LOAD_SPLAT(name, vector_instr, scalar_instr, condition) \ 60201cb0ef41Sopenharmony_ci void TurboAssembler::LoadAndSplat##name##LE( \ 60211cb0ef41Sopenharmony_ci Simd128Register dst, const MemOperand& mem, Register scratch) { \ 60221cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { \ 60231cb0ef41Sopenharmony_ci vector_instr(dst, mem, Condition(condition)); \ 60241cb0ef41Sopenharmony_ci return; \ 60251cb0ef41Sopenharmony_ci } \ 60261cb0ef41Sopenharmony_ci scalar_instr(scratch, mem); \ 60271cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 0), Condition(condition)); \ 60281cb0ef41Sopenharmony_ci vrep(dst, dst, Operand(0), Condition(condition)); \ 60291cb0ef41Sopenharmony_ci } 60301cb0ef41Sopenharmony_ciLOAD_SPLAT_LIST(LOAD_SPLAT) 60311cb0ef41Sopenharmony_ci#undef LOAD_SPLAT 60321cb0ef41Sopenharmony_ci#undef LOAD_SPLAT_LIST 60331cb0ef41Sopenharmony_ci 60341cb0ef41Sopenharmony_ci#define LOAD_EXTEND_LIST(V) \ 60351cb0ef41Sopenharmony_ci V(32x2U, vuplh, 2) \ 60361cb0ef41Sopenharmony_ci V(32x2S, vuph, 2) \ 60371cb0ef41Sopenharmony_ci V(16x4U, vuplh, 1) \ 60381cb0ef41Sopenharmony_ci V(16x4S, vuph, 1) \ 60391cb0ef41Sopenharmony_ci V(8x8U, vuplh, 0) \ 60401cb0ef41Sopenharmony_ci V(8x8S, vuph, 0) 60411cb0ef41Sopenharmony_ci 60421cb0ef41Sopenharmony_ci#define LOAD_EXTEND(name, unpack_instr, condition) \ 60431cb0ef41Sopenharmony_ci void TurboAssembler::LoadAndExtend##name##LE( \ 60441cb0ef41Sopenharmony_ci Simd128Register dst, const MemOperand& mem, Register scratch) { \ 60451cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { \ 60461cb0ef41Sopenharmony_ci vlebrg(dst, mem, Condition(0)); \ 60471cb0ef41Sopenharmony_ci } else { \ 60481cb0ef41Sopenharmony_ci LoadU64LE(scratch, mem); \ 60491cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 0), Condition(3)); \ 60501cb0ef41Sopenharmony_ci } \ 60511cb0ef41Sopenharmony_ci unpack_instr(dst, dst, Condition(0), Condition(0), Condition(condition)); \ 60521cb0ef41Sopenharmony_ci } 60531cb0ef41Sopenharmony_ciLOAD_EXTEND_LIST(LOAD_EXTEND) 60541cb0ef41Sopenharmony_ci#undef LOAD_EXTEND 60551cb0ef41Sopenharmony_ci#undef LOAD_EXTEND 60561cb0ef41Sopenharmony_ci 60571cb0ef41Sopenharmony_civoid TurboAssembler::LoadV32ZeroLE(Simd128Register dst, const MemOperand& mem, 60581cb0ef41Sopenharmony_ci Register scratch) { 60591cb0ef41Sopenharmony_ci vx(dst, dst, dst, Condition(0), Condition(0), Condition(0)); 60601cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { 60611cb0ef41Sopenharmony_ci vlebrf(dst, mem, Condition(3)); 60621cb0ef41Sopenharmony_ci return; 60631cb0ef41Sopenharmony_ci } 60641cb0ef41Sopenharmony_ci LoadU32LE(scratch, mem); 60651cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 3), Condition(2)); 60661cb0ef41Sopenharmony_ci} 60671cb0ef41Sopenharmony_ci 60681cb0ef41Sopenharmony_civoid TurboAssembler::LoadV64ZeroLE(Simd128Register dst, const MemOperand& mem, 60691cb0ef41Sopenharmony_ci Register scratch) { 60701cb0ef41Sopenharmony_ci vx(dst, dst, dst, Condition(0), Condition(0), Condition(0)); 60711cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { 60721cb0ef41Sopenharmony_ci vlebrg(dst, mem, Condition(1)); 60731cb0ef41Sopenharmony_ci return; 60741cb0ef41Sopenharmony_ci } 60751cb0ef41Sopenharmony_ci LoadU64LE(scratch, mem); 60761cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, 1), Condition(3)); 60771cb0ef41Sopenharmony_ci} 60781cb0ef41Sopenharmony_ci 60791cb0ef41Sopenharmony_ci#define LOAD_LANE_LIST(V) \ 60801cb0ef41Sopenharmony_ci V(64, vlebrg, LoadU64LE, 3) \ 60811cb0ef41Sopenharmony_ci V(32, vlebrf, LoadU32LE, 2) \ 60821cb0ef41Sopenharmony_ci V(16, vlebrh, LoadU16LE, 1) \ 60831cb0ef41Sopenharmony_ci V(8, vleb, LoadU8, 0) 60841cb0ef41Sopenharmony_ci 60851cb0ef41Sopenharmony_ci#define LOAD_LANE(name, vector_instr, scalar_instr, condition) \ 60861cb0ef41Sopenharmony_ci void TurboAssembler::LoadLane##name##LE(Simd128Register dst, \ 60871cb0ef41Sopenharmony_ci const MemOperand& mem, int lane, \ 60881cb0ef41Sopenharmony_ci Register scratch) { \ 60891cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { \ 60901cb0ef41Sopenharmony_ci vector_instr(dst, mem, Condition(lane)); \ 60911cb0ef41Sopenharmony_ci return; \ 60921cb0ef41Sopenharmony_ci } \ 60931cb0ef41Sopenharmony_ci scalar_instr(scratch, mem); \ 60941cb0ef41Sopenharmony_ci vlvg(dst, scratch, MemOperand(r0, lane), Condition(condition)); \ 60951cb0ef41Sopenharmony_ci } 60961cb0ef41Sopenharmony_ciLOAD_LANE_LIST(LOAD_LANE) 60971cb0ef41Sopenharmony_ci#undef LOAD_LANE 60981cb0ef41Sopenharmony_ci#undef LOAD_LANE_LIST 60991cb0ef41Sopenharmony_ci 61001cb0ef41Sopenharmony_ci#define STORE_LANE_LIST(V) \ 61011cb0ef41Sopenharmony_ci V(64, vstebrg, StoreU64LE, 3) \ 61021cb0ef41Sopenharmony_ci V(32, vstebrf, StoreU32LE, 2) \ 61031cb0ef41Sopenharmony_ci V(16, vstebrh, StoreU16LE, 1) \ 61041cb0ef41Sopenharmony_ci V(8, vsteb, StoreU8, 0) 61051cb0ef41Sopenharmony_ci 61061cb0ef41Sopenharmony_ci#define STORE_LANE(name, vector_instr, scalar_instr, condition) \ 61071cb0ef41Sopenharmony_ci void TurboAssembler::StoreLane##name##LE(Simd128Register src, \ 61081cb0ef41Sopenharmony_ci const MemOperand& mem, int lane, \ 61091cb0ef41Sopenharmony_ci Register scratch) { \ 61101cb0ef41Sopenharmony_ci if (CAN_LOAD_STORE_REVERSE && is_uint12(mem.offset())) { \ 61111cb0ef41Sopenharmony_ci vector_instr(src, mem, Condition(lane)); \ 61121cb0ef41Sopenharmony_ci return; \ 61131cb0ef41Sopenharmony_ci } \ 61141cb0ef41Sopenharmony_ci vlgv(scratch, src, MemOperand(r0, lane), Condition(condition)); \ 61151cb0ef41Sopenharmony_ci scalar_instr(scratch, mem); \ 61161cb0ef41Sopenharmony_ci } 61171cb0ef41Sopenharmony_ciSTORE_LANE_LIST(STORE_LANE) 61181cb0ef41Sopenharmony_ci#undef STORE_LANE 61191cb0ef41Sopenharmony_ci#undef STORE_LANE_LIST 61201cb0ef41Sopenharmony_ci#undef CAN_LOAD_STORE_REVERSE 61211cb0ef41Sopenharmony_ci#undef IS_BIG_ENDIAN 61221cb0ef41Sopenharmony_ci 61231cb0ef41Sopenharmony_civoid MacroAssembler::LoadStackLimit(Register destination, StackLimitKind kind) { 61241cb0ef41Sopenharmony_ci ASM_CODE_COMMENT(this); 61251cb0ef41Sopenharmony_ci DCHECK(root_array_available()); 61261cb0ef41Sopenharmony_ci Isolate* isolate = this->isolate(); 61271cb0ef41Sopenharmony_ci ExternalReference limit = 61281cb0ef41Sopenharmony_ci kind == StackLimitKind::kRealStackLimit 61291cb0ef41Sopenharmony_ci ? ExternalReference::address_of_real_jslimit(isolate) 61301cb0ef41Sopenharmony_ci : ExternalReference::address_of_jslimit(isolate); 61311cb0ef41Sopenharmony_ci DCHECK(TurboAssembler::IsAddressableThroughRootRegister(isolate, limit)); 61321cb0ef41Sopenharmony_ci 61331cb0ef41Sopenharmony_ci intptr_t offset = 61341cb0ef41Sopenharmony_ci TurboAssembler::RootRegisterOffsetForExternalReference(isolate, limit); 61351cb0ef41Sopenharmony_ci CHECK(is_int32(offset)); 61361cb0ef41Sopenharmony_ci LoadU64(destination, MemOperand(kRootRegister, offset)); 61371cb0ef41Sopenharmony_ci} 61381cb0ef41Sopenharmony_ci 61391cb0ef41Sopenharmony_ci} // namespace internal 61401cb0ef41Sopenharmony_ci} // namespace v8 61411cb0ef41Sopenharmony_ci 61421cb0ef41Sopenharmony_ci#endif // V8_TARGET_ARCH_S390 6143