Path: blob/main/contrib/llvm-project/lldb/source/Utility/AddressableBits.cpp
39587 views
//===-- AddressableBits.cpp -----------------------------------------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//78#include "lldb/Utility/AddressableBits.h"9#include "lldb/lldb-types.h"1011#include <cassert>1213using namespace lldb;14using namespace lldb_private;1516void AddressableBits::SetAddressableBits(uint32_t addressing_bits) {17m_low_memory_addr_bits = m_high_memory_addr_bits = addressing_bits;18}1920void AddressableBits::SetAddressableBits(uint32_t lowmem_addressing_bits,21uint32_t highmem_addressing_bits) {22m_low_memory_addr_bits = lowmem_addressing_bits;23m_high_memory_addr_bits = highmem_addressing_bits;24}2526void AddressableBits::SetLowmemAddressableBits(27uint32_t lowmem_addressing_bits) {28m_low_memory_addr_bits = lowmem_addressing_bits;29}3031uint32_t AddressableBits::GetLowmemAddressableBits() const {32return m_low_memory_addr_bits;33}3435void AddressableBits::SetHighmemAddressableBits(36uint32_t highmem_addressing_bits) {37m_high_memory_addr_bits = highmem_addressing_bits;38}3940uint32_t AddressableBits::GetHighmemAddressableBits() const {41return m_high_memory_addr_bits;42}4344addr_t AddressableBits::AddressableBitToMask(uint32_t addressable_bits) {45assert(addressable_bits <= sizeof(addr_t) * 8);46if (addressable_bits == 64)47return 0; // all bits used for addressing48else49return ~((1ULL << addressable_bits) - 1);50}515253