1//===-- AddressableBits.cpp -----------------------------------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "lldb/Utility/AddressableBits.h"
10#include "lldb/lldb-types.h"
11
12#include <cassert>
13
14using namespace lldb;
15using namespace lldb_private;
16
17void AddressableBits::SetAddressableBits(uint32_t addressing_bits) {
18 m_low_memory_addr_bits = m_high_memory_addr_bits = addressing_bits;
19}
20
21void AddressableBits::SetAddressableBits(uint32_t lowmem_addressing_bits,
22 uint32_t highmem_addressing_bits) {
23 m_low_memory_addr_bits = lowmem_addressing_bits;
24 m_high_memory_addr_bits = highmem_addressing_bits;
25}
26
27void AddressableBits::SetLowmemAddressableBits(
28 uint32_t lowmem_addressing_bits) {
29 m_low_memory_addr_bits = lowmem_addressing_bits;
30}
31
32uint32_t AddressableBits::GetLowmemAddressableBits() const {
33 return m_low_memory_addr_bits;
34}
35
36void AddressableBits::SetHighmemAddressableBits(
37 uint32_t highmem_addressing_bits) {
38 m_high_memory_addr_bits = highmem_addressing_bits;
39}
40
41uint32_t AddressableBits::GetHighmemAddressableBits() const {
42 return m_high_memory_addr_bits;
43}
44
45addr_t AddressableBits::AddressableBitToMask(uint32_t addressable_bits) {
46 assert(addressable_bits <= sizeof(addr_t) * 8);
47 if (addressable_bits == 64)
48 return 0; // all bits used for addressing
49 else
50 return ~((1ULL << addressable_bits) - 1);
51}
52

source code of lldb/source/Utility/AddressableBits.cpp