Skip to content

Commit

Permalink
Add serde derives for some config datastructures
Browse files Browse the repository at this point in the history
Signed-off-by: xermicus <[email protected]>
  • Loading branch information
xermicus committed Mar 11, 2024
1 parent e0aa2e5 commit ef0c647
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ llvm-sys-170 = { package = "llvm-sys", version = "170.0.1", optional = true }
once_cell = "1.16"
static-alloc = { version = "0.2", optional = true }
thiserror = "1.0.48"
serde = { version = "1.0", default-features = false, optional = true }

[dev-dependencies]
regex = "1"
Expand Down
7 changes: 7 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,8 @@ use llvm_sys::{
#[llvm_versions(7.0..=latest)]
use llvm_sys::LLVMInlineAsmDialect;

#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use std::convert::TryFrom;

// Thanks to kennytm for coming up with assert_unique_features!
Expand Down Expand Up @@ -383,6 +385,7 @@ pub enum AtomicRMWBinOp {
/// See also: https://llvm.org/doxygen/CodeGen_8h_source.html
#[repr(u32)]
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum OptimizationLevel {
None = 0,
Less = 1,
Expand All @@ -399,6 +402,7 @@ impl Default for OptimizationLevel {

#[llvm_enum(LLVMVisibility)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum GlobalVisibility {
#[llvm_variant(LLVMDefaultVisibility)]
Default,
Expand All @@ -416,6 +420,7 @@ impl Default for GlobalVisibility {
}

#[derive(Clone, Copy, Debug, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum ThreadLocalMode {
GeneralDynamicTLSModel,
LocalDynamicTLSModel,
Expand Down Expand Up @@ -447,6 +452,7 @@ impl ThreadLocalMode {

#[llvm_enum(LLVMDLLStorageClass)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum DLLStorageClass {
#[llvm_variant(LLVMDefaultStorageClass)]
Default,
Expand All @@ -466,6 +472,7 @@ impl Default for DLLStorageClass {
#[llvm_versions(7.0..=latest)]
#[llvm_enum(LLVMInlineAsmDialect)]
#[derive(Clone, Copy, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)]
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
pub enum InlineAsmDialect {
#[llvm_variant(LLVMInlineAsmDialectATT)]
ATT,
Expand Down

0 comments on commit ef0c647

Please sign in to comment.