Skip to content

Commit

Permalink
Add support for LLVM 18
Browse files Browse the repository at this point in the history
  • Loading branch information
Xavier Lambein committed Apr 11, 2024
1 parent a903e0a commit cb4cfd2
Show file tree
Hide file tree
Showing 21 changed files with 664 additions and 178 deletions.
4 changes: 2 additions & 2 deletions src/basic_block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -288,9 +288,9 @@ impl<'ctx> BasicBlock<'ctx> {
///
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
///
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
Expand Down
60 changes: 30 additions & 30 deletions src/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -456,9 +456,9 @@ impl<'ctx> Builder<'ctx> {
/// };
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i32_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -708,9 +708,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -740,9 +740,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -775,9 +775,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -813,9 +813,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -935,9 +935,9 @@ impl<'ctx> Builder<'ctx> {
/// };
///
/// // type of an exception in C++
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i8_ptr_type = context.i8_type().ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i8_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_type = context.i32_type();
/// let exception_type = context.struct_type(&[i8_ptr_type.into(), i32_type.into()], false);
Expand Down Expand Up @@ -1087,9 +1087,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("struct_gep");
/// let void_type = context.void_type();
/// let i32_ty = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let field_types = &[i32_ty.into(), i32_ty.into()];
/// let struct_ty = context.struct_type(field_types, false);
Expand Down Expand Up @@ -1153,9 +1153,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("struct_gep");
/// let void_type = context.void_type();
/// let i32_ty = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_ty = i32_ty.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_ty = context.ptr_type(AddressSpace::default());
/// let field_types = &[i32_ty.into(), i32_ty.into()];
/// let struct_ty = context.struct_type(field_types, false);
Expand Down Expand Up @@ -1227,9 +1227,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into(), i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1278,9 +1278,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into(), i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1347,9 +1347,9 @@ impl<'ctx> Builder<'ctx> {
/// let builder = context.create_builder();
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let i32_seven = i32_type.const_int(7, false);
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
Expand Down Expand Up @@ -1387,9 +1387,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("ret");
/// let builder = context.create_builder();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = i32_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -1427,9 +1427,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("ret");
/// let builder = context.create_builder();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = i32_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("ret", fn_type, None);
Expand Down Expand Up @@ -3265,9 +3265,9 @@ impl<'ctx> Builder<'ctx> {
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// let i32_seven = i32_type.const_int(7, false);
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("rmw", fn_type, None);
Expand Down Expand Up @@ -3344,9 +3344,9 @@ impl<'ctx> Builder<'ctx> {
/// let module = context.create_module("cmpxchg");
/// let void_type = context.void_type();
/// let i32_type = context.i32_type();
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0")))]
/// #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0")))]
/// let i32_ptr_type = i32_type.ptr_type(AddressSpace::default());
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0"))]
/// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-0"))]
/// let i32_ptr_type = context.ptr_type(AddressSpace::default());
/// let fn_type = void_type.fn_type(&[i32_ptr_type.into()], false);
/// let fn_value = module.add_function("", fn_type, None);
Expand Down
3 changes: 2 additions & 1 deletion src/targets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,8 @@ impl Target {
/// # Example
///
/// ```no_run
/// use inkwell::targets::{Target, TargetTriple, TargetMachineOptions};
/// use inkwell::targets::{InitializationConfig, Target, TargetTriple, TargetMachineOptions};
/// use inkwell::OptimizationLevel;
///
/// Target::initialize_x86(&InitializationConfig::default());
///
Expand Down
7 changes: 6 additions & 1 deletion src/types/array_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,12 @@ impl<'ctx> ArrayType<'ctx> {
/// assert_eq!(i8_array_ptr_type.get_element_type().into_array_type(), i8_array_type);
/// ```
#[cfg_attr(
any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0",),
any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
),
deprecated(
note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead."
)
Expand Down
7 changes: 6 additions & 1 deletion src/types/float_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,12 @@ impl<'ctx> FloatType<'ctx> {
/// assert_eq!(f32_ptr_type.get_element_type().into_float_type(), f32_type);
/// ```
#[cfg_attr(
any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0",),
any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
),
deprecated(
note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead."
)
Expand Down
7 changes: 6 additions & 1 deletion src/types/fn_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,12 @@ impl<'ctx> FunctionType<'ctx> {
/// assert_eq!(fn_ptr_type.get_element_type().into_function_type(), fn_type);
/// ```
#[cfg_attr(
any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0",),
any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
),
deprecated(
note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead."
)
Expand Down
7 changes: 6 additions & 1 deletion src/types/int_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,12 @@ impl<'ctx> IntType<'ctx> {
/// assert_eq!(i8_ptr_type.get_element_type().into_int_type(), i8_type);
/// ```
#[cfg_attr(
any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0",),
any(
feature = "llvm15-0",
feature = "llvm16-0",
feature = "llvm17-0",
feature = "llvm18-0"
),
deprecated(
note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead."
)
Expand Down
2 changes: 1 addition & 1 deletion src/types/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ pub use crate::types::fn_type::FunctionType;
pub use crate::types::int_type::{IntType, StringRadix};
pub use crate::types::metadata_type::MetadataType;
pub use crate::types::ptr_type::PointerType;
pub use crate::types::struct_type::StructType;
pub use crate::types::struct_type::FieldTypesIter;
pub use crate::types::struct_type::StructType;
pub use crate::types::traits::{AnyType, AsTypeRef, BasicType, FloatMathType, IntMathType, PointerMathType};
pub use crate::types::vec_type::VectorType;
pub use crate::types::void_type::VoidType;
Expand Down
Loading

0 comments on commit cb4cfd2

Please sign in to comment.