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
use llvm_sys::comdat::{LLVMComdatSelectionKind, LLVMGetComdatSelectionKind, LLVMSetComdatSelectionKind};
use llvm_sys::prelude::LLVMComdatRef;
#[cfg(feature = "internal-getters")]
use crate::LLVMReference;
#[llvm_enum(LLVMComdatSelectionKind)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
pub enum ComdatSelectionKind {
#[llvm_variant(LLVMAnyComdatSelectionKind)]
Any,
#[llvm_variant(LLVMExactMatchComdatSelectionKind)]
ExactMatch,
#[llvm_variant(LLVMLargestComdatSelectionKind)]
Largest,
#[llvm_variant(LLVMNoDuplicatesComdatSelectionKind)]
NoDuplicates,
#[llvm_variant(LLVMSameSizeComdatSelectionKind)]
SameSize,
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub struct Comdat(pub(crate) LLVMComdatRef);
impl Comdat {
pub(crate) fn new(comdat: LLVMComdatRef) -> Self {
debug_assert!(!comdat.is_null());
Comdat(comdat)
}
pub fn get_selection_kind(self) -> ComdatSelectionKind {
let kind_ptr = unsafe { LLVMGetComdatSelectionKind(self.0) };
ComdatSelectionKind::new(kind_ptr)
}
pub fn set_selection_kind(self, kind: ComdatSelectionKind) {
unsafe { LLVMSetComdatSelectionKind(self.0, kind.into()) }
}
}
#[cfg(feature = "internal-getters")]
impl LLVMReference<LLVMComdatRef> for Comdat {
unsafe fn get_ref(&self) -> LLVMComdatRef {
self.0
}
}