Skip to content

Commit

Permalink
Revert changes unrelated to llvm 17
Browse files Browse the repository at this point in the history
Signed-off-by: Alex Saveau <[email protected]>
  • Loading branch information
SUPERCILEX authored and TheDan64 committed Jan 13, 2024
1 parent 69290bf commit b545f7c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 43 deletions.
45 changes: 5 additions & 40 deletions src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@ use llvm_sys::core::{
LLVMCreateStringAttribute, LLVMDoubleTypeInContext, LLVMFP128TypeInContext, LLVMFloatTypeInContext,
LLVMGetGlobalContext, LLVMGetMDKindIDInContext, LLVMHalfTypeInContext, LLVMInsertBasicBlockInContext,
LLVMInt16TypeInContext, LLVMInt1TypeInContext, LLVMInt32TypeInContext, LLVMInt64TypeInContext,
LLVMInt8TypeInContext, LLVMIntTypeInContext, LLVMModuleCreateWithNameInContext, LLVMPPCFP128TypeInContext,
LLVMStructCreateNamed, LLVMStructTypeInContext, LLVMVoidTypeInContext, LLVMX86FP80TypeInContext,
LLVMInt8TypeInContext, LLVMIntTypeInContext, LLVMMDNodeInContext, LLVMMDStringInContext,
LLVMModuleCreateWithNameInContext, LLVMPPCFP128TypeInContext, LLVMStructCreateNamed, LLVMStructTypeInContext,
LLVMVoidTypeInContext, LLVMX86FP80TypeInContext,
};
#[llvm_versions(4.0..=16.0)]
use llvm_sys::core::{LLVMMDNodeInContext, LLVMMDStringInContext};
#[llvm_versions(16.0..=latest)]
use llvm_sys::core::{LLVMMDNodeInContext2, LLVMMDStringInContext2};
use llvm_sys::ir_reader::LLVMParseIRInContext;
use llvm_sys::prelude::{LLVMContextRef, LLVMDiagnosticInfoRef, LLVMTypeRef, LLVMValueRef};
use llvm_sys::target::{LLVMIntPtrTypeForASInContext, LLVMIntPtrTypeInContext};
Expand Down Expand Up @@ -324,7 +321,6 @@ impl ContextImpl {
}
}

#[llvm_versions(4.0..=16.0)]
fn metadata_node<'ctx>(&self, values: &[BasicMetadataValueEnum<'ctx>]) -> MetadataValue<'ctx> {
let mut tuple_values: Vec<LLVMValueRef> = values.iter().map(|val| val.as_value_ref()).collect();
unsafe {
Expand All @@ -336,43 +332,12 @@ impl ContextImpl {
}
}

#[llvm_versions(17.0..=latest)]
fn metadata_node<'ctx>(&self, values: &[BasicMetadataValueEnum<'ctx>]) -> MetadataValue<'ctx> {
use llvm_sys::{core::LLVMMetadataAsValue, prelude::LLVMMetadataRef};

let mut tuple_values: Vec<LLVMMetadataRef> = values
.iter()
.map(|val| val.into_metadata_value().as_metadata_ref())
.collect();
unsafe {
MetadataValue::new(LLVMMetadataAsValue(
self.0,
LLVMMDNodeInContext2(self.0, tuple_values.as_mut_ptr(), tuple_values.len()),
))
}
}

#[llvm_versions(4.0..=16.0)]
fn metadata_string<'ctx>(&self, string: &str) -> MetadataValue<'ctx> {
let c_string = to_c_str(string);

unsafe { MetadataValue::new(LLVMMDStringInContext(self.0, c_string.as_ptr(), string.len() as u32)) }
}

#[llvm_versions(17.0..=latest)]
fn metadata_string<'ctx>(&self, string: &str) -> MetadataValue<'ctx> {
use llvm_sys::core::LLVMMetadataAsValue;

let c_string = to_c_str(string);

unsafe {
MetadataValue::new(LLVMMetadataAsValue(
self.0,
LLVMMDStringInContext2(self.0, c_string.as_ptr(), string.len()),
))
}
}

fn get_kind_id(&self, key: &str) -> u32 {
unsafe { LLVMGetMDKindIDInContext(self.0, key.as_ptr() as *const ::libc::c_char, key.len() as u32) }
}
Expand Down Expand Up @@ -604,7 +569,7 @@ impl Context {
/// builder.build_call(callable_value, params, "exit").unwrap();
/// }
///
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// builder.build_indirect_call(asm_fn, asm, params, "exit").unwrap();
///
/// builder.build_return(None).unwrap();
Expand Down Expand Up @@ -1452,7 +1417,7 @@ impl<'ctx> ContextRef<'ctx> {
/// builder.build_call(callable_value, params, "exit").unwrap();
/// }
///
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// builder.build_indirect_call(asm_fn, asm, params, "exit").unwrap();
///
/// builder.build_return(None).unwrap();
Expand Down
3 changes: 0 additions & 3 deletions src/values/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ pub use crate::values::traits::AsValueRef;
pub use crate::values::traits::{AggregateValue, AnyValue, BasicValue, FloatMathValue, IntMathValue, PointerMathValue};
pub use crate::values::vec_value::VectorValue;

#[llvm_versions(12.0..=16.0)]
use llvm_sys::core::LLVMIsPoison;

use llvm_sys::core::{
LLVMDumpValue, LLVMGetFirstUse, LLVMGetSection, LLVMIsAInstruction, LLVMIsConstant, LLVMIsNull, LLVMIsUndef,
LLVMPrintTypeToString, LLVMPrintValueToString, LLVMReplaceAllUsesWith, LLVMSetSection, LLVMTypeOf,
Expand Down

0 comments on commit b545f7c

Please sign in to comment.