1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
/* SPDX-FileCopyrightText: © 2024-2025 Decompollaborate */
/* SPDX-License-Identifier: MIT */
pub use crate::generated::AccessType;
use crate::{access_type_descriptor::AccessTypeDescriptor, generated::ACCESS_TYPES};
pub const ACCESS_TYPE_COUNT: usize = {
let mut count = 7;
if cfg!(feature = "MIPS_II") {
count += 3;
}
if cfg!(feature = "MIPS_III") {
count += 4;
}
if cfg!(feature = "MIPS_IV") {
count += 0;
}
if cfg!(feature = "RSP") {
count += 0;
}
if cfg!(feature = "R3000GTE") {
count += 0;
}
if cfg!(feature = "R4000ALLEGREX") {
count += 0;
}
if cfg!(feature = "R5900EE") {
count += 1;
}
if cfg!(feature = "RspViceMsp") {
count += 0;
}
count
};
impl AccessType {
#[must_use]
pub fn get_descriptor(&self) -> &'static AccessTypeDescriptor {
&ACCESS_TYPES[*self as usize]
}
}
impl AccessType {
/// The name of this access type.
#[must_use]
pub fn name(&self) -> &'static str {
self.get_descriptor().name()
}
/// The minimal size a symbol should have for this access type.
///
/// For example, a single precision float access type does reference a symbol that is at least
/// 0x4 bytes big.
/// The actual symbol may be larger since it could be an struct or an array too.
#[must_use]
pub fn min_size(&self) -> Option<u8> {
self.get_descriptor().min_size()
}
/// The minimal alignment a symbol should have for this access type.
///
/// For example, a single precision float access does reference a symbol that is aligned at
/// least the 0x4 byte boundary.
/// The actual symbol may be have an stricter alignment since it could be part of an struct.
#[must_use]
pub fn min_alignment(&self) -> Option<u8> {
self.get_descriptor().min_alignment()
}
/// Unaligned access type.
///
/// This is usually paired with the corresponding left/right variant.
#[must_use]
pub fn is_unaligned(&self) -> bool {
self.get_descriptor().is_unaligned()
}
}