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
use crate::{ir::Attribute, Context};

#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Linkage {
    Private,
    Internal,
    AvailableExternally,
    LinkOnce,
    Weak,
    Common,
    Appending,
    External,
}

/// Creates an LLVM linkage attribute.
pub fn linkage(context: &Context, linkage: Linkage) -> Attribute {
    let linkage = match linkage {
        Linkage::Private => "private",
        Linkage::Internal => "internal",
        Linkage::AvailableExternally => "available_externally",
        Linkage::LinkOnce => "link_once",
        Linkage::Weak => "weak",
        Linkage::Common => "common",
        Linkage::Appending => "appending",
        Linkage::External => "external",
    };
    Attribute::parse(context, &format!("#llvm.linkage<{linkage}>")).unwrap()
}