[mlir][int-range] Limit xor int range inference to i1 (#116968)
[llvm-project.git] / lldb / source / Utility / AddressableBits.cpp
blob4c98addc1f073bf3d13d354c439a7468657b9a4b
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 //===----------------------------------------------------------------------===//
9 #include "lldb/Utility/AddressableBits.h"
10 #include "lldb/lldb-types.h"
12 #include <cassert>
14 using namespace lldb;
15 using namespace lldb_private;
17 void AddressableBits::SetAddressableBits(uint32_t addressing_bits) {
18 m_low_memory_addr_bits = m_high_memory_addr_bits = addressing_bits;
21 void 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;
27 void AddressableBits::SetLowmemAddressableBits(
28 uint32_t lowmem_addressing_bits) {
29 m_low_memory_addr_bits = lowmem_addressing_bits;
32 uint32_t AddressableBits::GetLowmemAddressableBits() const {
33 return m_low_memory_addr_bits;
36 void AddressableBits::SetHighmemAddressableBits(
37 uint32_t highmem_addressing_bits) {
38 m_high_memory_addr_bits = highmem_addressing_bits;
41 uint32_t AddressableBits::GetHighmemAddressableBits() const {
42 return m_high_memory_addr_bits;
45 addr_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);