11cb0ef41Sopenharmony_ci// Copyright 2018 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#ifndef V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_ 61cb0ef41Sopenharmony_ci#define V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_ 71cb0ef41Sopenharmony_ci 81cb0ef41Sopenharmony_ci#include "src/codegen/code-stub-assembler.h" 91cb0ef41Sopenharmony_ci#include "src/objects/bigint.h" 101cb0ef41Sopenharmony_ci#include "src/objects/elements-kind.h" 111cb0ef41Sopenharmony_ci 121cb0ef41Sopenharmony_cinamespace v8 { 131cb0ef41Sopenharmony_cinamespace internal { 141cb0ef41Sopenharmony_ci 151cb0ef41Sopenharmony_ciclass DataViewBuiltinsAssembler : public CodeStubAssembler { 161cb0ef41Sopenharmony_ci public: 171cb0ef41Sopenharmony_ci explicit DataViewBuiltinsAssembler(compiler::CodeAssemblerState* state) 181cb0ef41Sopenharmony_ci : CodeStubAssembler(state) {} 191cb0ef41Sopenharmony_ci 201cb0ef41Sopenharmony_ci TNode<Uint8T> LoadUint8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) { 211cb0ef41Sopenharmony_ci return UncheckedCast<Uint8T>( 221cb0ef41Sopenharmony_ci Load(MachineType::Uint8(), data_pointer, offset)); 231cb0ef41Sopenharmony_ci } 241cb0ef41Sopenharmony_ci 251cb0ef41Sopenharmony_ci TNode<Int8T> LoadInt8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset) { 261cb0ef41Sopenharmony_ci return UncheckedCast<Int8T>( 271cb0ef41Sopenharmony_ci Load(MachineType::Int8(), data_pointer, offset)); 281cb0ef41Sopenharmony_ci } 291cb0ef41Sopenharmony_ci 301cb0ef41Sopenharmony_ci void StoreWord8(TNode<RawPtrT> data_pointer, TNode<UintPtrT> offset, 311cb0ef41Sopenharmony_ci TNode<Word32T> value) { 321cb0ef41Sopenharmony_ci StoreNoWriteBarrier(MachineRepresentation::kWord8, data_pointer, offset, 331cb0ef41Sopenharmony_ci value); 341cb0ef41Sopenharmony_ci } 351cb0ef41Sopenharmony_ci 361cb0ef41Sopenharmony_ci int32_t DataViewElementSize(ElementsKind elements_kind) { 371cb0ef41Sopenharmony_ci return ElementsKindToByteSize(elements_kind); 381cb0ef41Sopenharmony_ci } 391cb0ef41Sopenharmony_ci 401cb0ef41Sopenharmony_ci TNode<Uint32T> DataViewEncodeBigIntBits(bool sign, int32_t digits) { 411cb0ef41Sopenharmony_ci return Unsigned(Int32Constant(BigInt::SignBits::encode(sign) | 421cb0ef41Sopenharmony_ci BigInt::LengthBits::encode(digits))); 431cb0ef41Sopenharmony_ci } 441cb0ef41Sopenharmony_ci 451cb0ef41Sopenharmony_ci TNode<Uint32T> DataViewDecodeBigIntLength(TNode<BigInt> value) { 461cb0ef41Sopenharmony_ci TNode<Word32T> bitfield = LoadBigIntBitfield(value); 471cb0ef41Sopenharmony_ci return DecodeWord32<BigIntBase::LengthBits>(bitfield); 481cb0ef41Sopenharmony_ci } 491cb0ef41Sopenharmony_ci 501cb0ef41Sopenharmony_ci TNode<Uint32T> DataViewDecodeBigIntSign(TNode<BigInt> value) { 511cb0ef41Sopenharmony_ci TNode<Word32T> bitfield = LoadBigIntBitfield(value); 521cb0ef41Sopenharmony_ci return DecodeWord32<BigIntBase::SignBits>(bitfield); 531cb0ef41Sopenharmony_ci } 541cb0ef41Sopenharmony_ci}; 551cb0ef41Sopenharmony_ci 561cb0ef41Sopenharmony_ci} // namespace internal 571cb0ef41Sopenharmony_ci} // namespace v8 581cb0ef41Sopenharmony_ci 591cb0ef41Sopenharmony_ci#endif // V8_BUILTINS_BUILTINS_DATA_VIEW_GEN_H_ 60