diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index afbf2438b61..89d930170a6 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,8 +4,8 @@ on: [ push, pull_request ] env: CARGO_TERM_COLOR: always - DOC_LLVM_FEATURE: llvm21-1 - DOC_LLVM_VERSION: "21.1" + DOC_LLVM_FEATURE: llvm23-1 + DOC_LLVM_VERSION: "23.1" DOC_PATH: target/doc jobs: @@ -28,25 +28,37 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - llvm-version: - - [ "12.0", "12-0" ] - - [ "13.0", "13-0" ] - - [ "14.0", "14-0" ] - - [ "15.0", "15-0" ] - - [ "16.0", "16-0" ] - - [ "17.0", "17-0" ] - - [ "18.1", "18-1" ] - - [ "19.1", "19-1", "19" ] - - [ "20.1", "20-1", "20" ] - - [ "21.1", "21-1", "21" ] - - [ "22.1", "22-1", "22" ] include: - - os: ubuntu-22.04 + - llvm-version: [ "12.0", "12-0" ] + os: ubuntu-22.04 + - llvm-version: [ "13.0", "13-0" ] + os: ubuntu-22.04 + - llvm-version: [ "14.0", "14-0" ] + os: ubuntu-22.04 + - llvm-version: [ "15.0", "15-0" ] + os: ubuntu-22.04 + - llvm-version: [ "16.0", "16-0" ] + os: ubuntu-22.04 + - llvm-version: [ "17.0", "17-0" ] + os: ubuntu-22.04 + - llvm-version: [ "18.1", "18-1" ] + os: ubuntu-22.04 + - llvm-version: [ "19.1", "19-1", "19" ] + os: ubuntu-latest + - llvm-version: [ "20.1", "20-1", "20" ] + os: ubuntu-latest + - llvm-version: [ "21.1", "21-1", "21" ] + os: ubuntu-latest + - llvm-version: [ "22.1", "22-1", "22" ] + os: ubuntu-latest + - llvm-version: [ "23.1", "23-1", "23" ] + os: ubuntu-latest steps: - name: Checkout Repo uses: actions/checkout@v4 - - name: Install libtinfo5 - run: sudo apt update && sudo apt install -y libtinfo5 + - name: Install libtinfo5 (LLVM < 19) + if: ${{ matrix.llvm-version[0] < 19 }} + run: sudo apt-get update && sudo apt-get install -y libtinfo5 - name: Install LLVM and Clang (LLVM >= 19.1) if: ${{ matrix.llvm-version[0] >= 19 }} run: | @@ -61,9 +73,9 @@ jobs: llvm-${{ matrix.llvm-version[2] }}-runtime \ libpolly-${{ matrix.llvm-version[2] }}-dev sudo update-alternatives --install /usr/bin/llvm-config llvm-config /usr/bin/llvm-config-${{ matrix.llvm-version[2] }} 10 - - name: Install LLVM and Clang (12 <= LLVM <= 19) + - name: Install LLVM and Clang (12 <= LLVM < 19) uses: KyleMayes/install-llvm-action@v2 - if: ${{ matrix.llvm-version[0] >= 12 && matrix.llvm-version[0] <= 19 }} + if: ${{ matrix.llvm-version[0] >= 12 && matrix.llvm-version[0] < 19 }} with: version: ${{ matrix.llvm-version[0] }} - name: llvm-config @@ -89,7 +101,7 @@ jobs: name: Documentation runs-on: ubuntu-latest env: - LLVM_SYS_211_PREFIX: ${{ github.workspace }}/llvm + LLVM_SYS_231_PREFIX: ${{ github.workspace }}/llvm needs: [ lint, tests ] if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: diff --git a/Cargo.toml b/Cargo.toml index 0eab1c12c4a..a3fa41e3b45 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,6 +27,7 @@ llvm19-1 = ["llvm-sys-191"] llvm20-1 = ["llvm-sys-201"] llvm21-1 = ["llvm-sys-211"] llvm22-1 = ["llvm-sys-221"] +llvm23-1 = ["llvm-sys-231"] # Don't link against LLVM libraries. This is useful if another dependency is # installing LLVM. See llvm-sys for more details. We can't enable a single @@ -44,6 +45,7 @@ llvm19-1-no-llvm-linking = ["llvm19-1", "llvm-sys-191/no-llvm-linking"] llvm20-1-no-llvm-linking = ["llvm20-1", "llvm-sys-201/no-llvm-linking"] llvm21-1-no-llvm-linking = ["llvm21-1", "llvm-sys-211/no-llvm-linking"] llvm22-1-no-llvm-linking = ["llvm22-1", "llvm-sys-221/no-llvm-linking"] +llvm23-1-no-llvm-linking = ["llvm23-1", "llvm-sys-231/no-llvm-linking"] # Linking preference. # If none of these are enabled, it defaults to force static linking. @@ -60,6 +62,7 @@ llvm19-1-force-dynamic = ["llvm19-1", "llvm-sys-191/force-dynamic"] llvm20-1-force-dynamic = ["llvm20-1", "llvm-sys-201/force-dynamic"] llvm21-1-force-dynamic = ["llvm21-1", "llvm-sys-211/force-dynamic"] llvm22-1-force-dynamic = ["llvm22-1", "llvm-sys-221/force-dynamic"] +llvm23-1-force-dynamic = ["llvm23-1", "llvm-sys-231/force-dynamic"] # Prefer dynamic linking against LLVM libraries. See llvm-sys for more details llvm12-0-prefer-dynamic = ["llvm12-0", "llvm-sys-120/prefer-dynamic"] @@ -73,6 +76,7 @@ llvm19-1-prefer-dynamic = ["llvm19-1", "llvm-sys-191/prefer-dynamic"] llvm20-1-prefer-dynamic = ["llvm20-1", "llvm-sys-201/prefer-dynamic"] llvm21-1-prefer-dynamic = ["llvm21-1", "llvm-sys-211/prefer-dynamic"] llvm22-1-prefer-dynamic = ["llvm22-1", "llvm-sys-221/prefer-dynamic"] +llvm23-1-prefer-dynamic = ["llvm23-1", "llvm-sys-231/prefer-dynamic"] # Force static linking against LLVM libraries. See llvm-sys for more details llvm12-0-force-static = ["llvm12-0", "llvm-sys-120/force-static"] @@ -86,6 +90,7 @@ llvm19-1-force-static = ["llvm19-1", "llvm-sys-191/force-static"] llvm20-1-force-static = ["llvm20-1", "llvm-sys-201/force-static"] llvm21-1-force-static = ["llvm21-1", "llvm-sys-211/force-static"] llvm22-1-force-static = ["llvm22-1", "llvm-sys-221/force-static"] +llvm23-1-force-static = ["llvm23-1", "llvm-sys-231/force-static"] # Prefer static linking against LLVM libraries. See llvm-sys for more details llvm12-0-prefer-static = ["llvm12-0", "llvm-sys-120/prefer-static"] @@ -99,6 +104,7 @@ llvm19-1-prefer-static = ["llvm19-1", "llvm-sys-191/prefer-static"] llvm20-1-prefer-static = ["llvm20-1", "llvm-sys-201/prefer-static"] llvm21-1-prefer-static = ["llvm21-1", "llvm-sys-211/prefer-static"] llvm22-1-prefer-static = ["llvm22-1", "llvm-sys-221/prefer-static"] +llvm23-1-prefer-static = ["llvm23-1", "llvm-sys-231/prefer-static"] # Don't force linking to libffi on non-windows platforms. Without this feature # inkwell always links to libffi on non-windows platforms. @@ -157,6 +163,7 @@ llvm-sys-191 = { package = "llvm-sys", version = "191.0.0", optional = true } llvm-sys-201 = { package = "llvm-sys", version = "201.0.0", optional = true } llvm-sys-211 = { package = "llvm-sys", version = "211.0.0", optional = true } llvm-sys-221 = { package = "llvm-sys", version = "221.0.0", optional = true } +llvm-sys-231 = { package = "llvm-sys", version = "231.0.0-rc2", optional = true } libc = "0.2" thiserror = "2.0.11" @@ -176,7 +183,7 @@ version = "0.62.2" features = ["Win32_System_SystemInformation", "Win32_System_Memory"] [package.metadata.docs.rs] -features = ["llvm22-1-no-llvm-linking"] +features = ["llvm23-1-no-llvm-linking"] [badges] codecov = { repository = "TheDan64/inkwell" } diff --git a/README.md b/README.md index d063c315790..200d3d777bf 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ Inkwell aims to help you pen your own programming languages by safely wrapping l ## Requirements * Rust 1.85+ -* One of LLVM 12-22 +* One of LLVM 12-23 ## Usage @@ -22,11 +22,11 @@ You'll need to point your Cargo.toml to use a single LLVM version feature flag c ```toml [dependencies] -inkwell = { version = "0.10.0", features = ["llvm22-1"] } +inkwell = { version = "0.10.0", features = ["llvm23-1"] } ``` Supported versions: -LLVM 12-22 mapping to a cargo feature flag `llvmM-N` where `M` and `N` correspond to the LLVM major and minor version, e.g. `llvm18-1` for LLVM 18.1.x. +LLVM 12-23 mapping to a cargo feature flag `llvmM-N` where `M` and `N` correspond to the LLVM major and minor version, e.g. `llvm18-1` for LLVM 18.1.x. Please be aware that we may make breaking changes on master from time to time since we are pre-v1.0.0, in compliance with semver. Please prefer a crates.io release whenever possible! diff --git a/internal_macros/src/cfg.rs b/internal_macros/src/cfg.rs index 36fdaf42362..9c94cef56c3 100644 --- a/internal_macros/src/cfg.rs +++ b/internal_macros/src/cfg.rs @@ -9,8 +9,8 @@ use syn::{Lit, RangeLimits}; // This array should match the LLVM features in the top level Cargo manifest const FEATURE_VERSIONS: &[&str] = &[ - "llvm12-0", "llvm13-0", "llvm14-0", "llvm15-0", "llvm16-0", "llvm17-0", "llvm18-1", "llvm19-1", - "llvm20-1", "llvm21-1", "llvm22-1", + "llvm12-0", "llvm13-0", "llvm14-0", "llvm15-0", "llvm16-0", "llvm17-0", "llvm18-1", "llvm19-1", "llvm20-1", + "llvm21-1", "llvm22-1", "llvm23-1", ]; pub struct VersionRange { diff --git a/src/builder.rs b/src/builder.rs index 2cfeb1a63b5..971b7fb60fb 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -3730,9 +3730,9 @@ impl<'ctx> Builder<'ctx> { /// let i32_ptr_param = fn_value.get_first_param().unwrap().into_pointer_value(); /// let builder = context.create_builder(); /// builder.position_at_end(entry); - /// #[cfg(any(feature = "llvm21-1", feature = "llvm22-1"))] + /// #[cfg(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] /// builder.build_atomicrmw(AtomicRMWBinOp::Add, i32_ptr_param, i32_seven, AtomicOrdering::Monotonic).unwrap(); - /// #[cfg(not(any(feature = "llvm21-1", feature = "llvm22-1")))] + /// #[cfg(not(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1")))] /// builder.build_atomicrmw(AtomicRMWBinOp::Add, i32_ptr_param, i32_seven, AtomicOrdering::AcquireRelease).unwrap(); /// builder.build_return(None).unwrap(); /// ``` diff --git a/src/context.rs b/src/context.rs index 1e808413229..2a95c5d44a3 100644 --- a/src/context.rs +++ b/src/context.rs @@ -124,10 +124,10 @@ impl ContextImpl { let mut module = ptr::null_mut(); let mut err_str = ptr::null_mut(); - #[cfg(not(feature = "llvm22-1"))] + #[cfg(not(any(feature = "llvm22-1", feature = "llvm23-1")))] let code = unsafe { LLVMParseIRInContext(self.as_mut_ptr(), memory_buffer.as_mut_ptr(), &mut module, &mut err_str) }; - #[cfg(feature = "llvm22-1")] + #[cfg(any(feature = "llvm22-1", feature = "llvm23-1"))] let code = unsafe { LLVMParseIRInContext2(self.as_mut_ptr(), memory_buffer.as_mut_ptr(), &mut module, &mut err_str) }; @@ -618,7 +618,7 @@ impl Context { /// builder.build_call(callable_value, params, "exit").unwrap(); /// } /// - /// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + /// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] /// builder.build_indirect_call(asm_fn, asm, params, "exit").unwrap(); /// /// builder.build_return(None).unwrap(); @@ -1480,7 +1480,7 @@ impl<'ctx> ContextRef<'ctx> { /// builder.build_call(callable_value, params, "exit").unwrap(); /// } /// - /// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + /// #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] /// builder.build_indirect_call(asm_fn, asm, params, "exit").unwrap(); /// /// builder.build_return(None).unwrap(); diff --git a/src/debug_info.rs b/src/debug_info.rs index 6097f1d0dae..84d34392b25 100644 --- a/src/debug_info.rs +++ b/src/debug_info.rs @@ -928,7 +928,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] { // In LLVM 19+, the insert... functions return a DbgRecord, not a Value. @@ -941,7 +942,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { unsafe { InstructionValue::new(value_ref) } @@ -972,7 +974,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] { // In LLVM 19+, the insert... functions return a DbgRecord, not a Value. @@ -985,7 +988,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { unsafe { InstructionValue::new(value_ref) } @@ -1032,7 +1036,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] { // In LLVM 19+, the insert... functions return a DbgRecord, not a Value. @@ -1045,7 +1050,8 @@ impl<'ctx> DebugInfoBuilder<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { unsafe { InstructionValue::new(value_ref) } diff --git a/src/lib.rs b/src/lib.rs index 1f356ab0a03..7eaa237385c 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -64,6 +64,8 @@ pub extern crate llvm_sys_201 as llvm_sys; pub extern crate llvm_sys_211 as llvm_sys; #[cfg(feature = "llvm22-1")] pub extern crate llvm_sys_221 as llvm_sys; +#[cfg(feature = "llvm23-1")] +pub extern crate llvm_sys_231 as llvm_sys; use llvm_sys::target_machine::LLVMCodeGenOptLevel; use llvm_sys::{ @@ -118,7 +120,8 @@ assert_unique_used_features! { "llvm19-1", "llvm20-1", "llvm21-1", - "llvm22-1" + "llvm22-1", + "llvm23-1" } #[cfg(all( @@ -387,6 +390,14 @@ pub enum AtomicRMWBinOp { #[llvm_versions(21..)] #[llvm_variant(LLVMAtomicRMWBinOpFMinimum)] FMinimum, + + #[llvm_versions(23..)] + #[llvm_variant(LLVMAtomicRMWBinOpFMaximumNum)] + FMaximumNum, + + #[llvm_versions(23..)] + #[llvm_variant(LLVMAtomicRMWBinOpFMinimumNum)] + FMinimumNum, } /// Defines the optimization level used to compile a [`Module`](crate::module::Module). diff --git a/src/types/array_type.rs b/src/types/array_type.rs index 1653078a9ad..e24a8f2cee2 100644 --- a/src/types/array_type.rs +++ b/src/types/array_type.rs @@ -78,6 +78,7 @@ impl<'ctx> ArrayType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/enums.rs b/src/types/enums.rs index 57f7a340ba5..c5205a82025 100644 --- a/src/types/enums.rs +++ b/src/types/enums.rs @@ -266,9 +266,16 @@ impl<'ctx> AnyTypeEnum<'ctx> { // FIXME: should inkwell support metadata as AnyType? LLVMTypeKind::LLVMMetadataTypeKind => panic!("Metadata type is not supported as AnyType."), - #[cfg(not(any(feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1")))] + #[cfg(not(any( + feature = "llvm20-1", + feature = "llvm21-1", + feature = "llvm22-1", + feature = "llvm23-1" + )))] LLVMTypeKind::LLVMX86_MMXTypeKind => panic!("FIXME: Unsupported type: MMX"), LLVMTypeKind::LLVMX86_AMXTypeKind => panic!("FIXME: Unsupported type: AMX"), + #[cfg(feature = "llvm23-1")] + LLVMTypeKind::LLVMByteTypeKind => panic!("FIXME: Unsupported type: Byte"), LLVMTypeKind::LLVMTokenTypeKind => panic!("FIXME: Unsupported type: Token"), #[cfg(any( feature = "llvm16-0", @@ -278,6 +285,7 @@ impl<'ctx> AnyTypeEnum<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ))] LLVMTypeKind::LLVMTargetExtTypeKind => panic!("FIXME: Unsupported type: TargetExt"), } @@ -448,10 +456,17 @@ impl<'ctx> BasicTypeEnum<'ctx> { }, LLVMTypeKind::LLVMMetadataTypeKind => panic!("Unsupported basic type: Metadata"), // see https://llvm.org/docs/LangRef.html#x86-mmx-type - #[cfg(not(any(feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1")))] + #[cfg(not(any( + feature = "llvm20-1", + feature = "llvm21-1", + feature = "llvm22-1", + feature = "llvm23-1" + )))] LLVMTypeKind::LLVMX86_MMXTypeKind => panic!("Unsupported basic type: MMX"), // see https://llvm.org/docs/LangRef.html#x86-amx-type LLVMTypeKind::LLVMX86_AMXTypeKind => unreachable!("Unsupported basic type: AMX"), + #[cfg(feature = "llvm23-1")] + LLVMTypeKind::LLVMByteTypeKind => unreachable!("Unsupported basic type: Byte"), LLVMTypeKind::LLVMLabelTypeKind => unreachable!("Unsupported basic type: Label"), LLVMTypeKind::LLVMVoidTypeKind => unreachable!("Unsupported basic type: VoidType"), LLVMTypeKind::LLVMFunctionTypeKind => unreachable!("Unsupported basic type: FunctionType"), @@ -464,6 +479,7 @@ impl<'ctx> BasicTypeEnum<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ))] LLVMTypeKind::LLVMTargetExtTypeKind => unreachable!("Unsupported basic type: TargetExt"), } diff --git a/src/types/float_type.rs b/src/types/float_type.rs index eba8a872716..1a7b023cfed 100644 --- a/src/types/float_type.rs +++ b/src/types/float_type.rs @@ -236,6 +236,7 @@ impl<'ctx> FloatType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/fn_type.rs b/src/types/fn_type.rs index 025f5cb40f0..12a3108c32b 100644 --- a/src/types/fn_type.rs +++ b/src/types/fn_type.rs @@ -62,6 +62,7 @@ impl<'ctx> FunctionType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/int_type.rs b/src/types/int_type.rs index 614ff959e54..ae9428b5fec 100644 --- a/src/types/int_type.rs +++ b/src/types/int_type.rs @@ -331,6 +331,7 @@ impl<'ctx> IntType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/ptr_type.rs b/src/types/ptr_type.rs index 49156b7dae4..01f02cae6ce 100644 --- a/src/types/ptr_type.rs +++ b/src/types/ptr_type.rs @@ -87,6 +87,7 @@ impl<'ctx> PointerType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/scalable_vec_type.rs b/src/types/scalable_vec_type.rs index 1ffac1a681a..e7f0f8719c7 100644 --- a/src/types/scalable_vec_type.rs +++ b/src/types/scalable_vec_type.rs @@ -172,6 +172,7 @@ impl<'ctx> ScalableVectorType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/struct_type.rs b/src/types/struct_type.rs index 479ba365cce..f573bf85aab 100644 --- a/src/types/struct_type.rs +++ b/src/types/struct_type.rs @@ -202,6 +202,7 @@ impl<'ctx> StructType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/traits.rs b/src/types/traits.rs index 7ae703023e4..b4899497143 100644 --- a/src/types/traits.rs +++ b/src/types/traits.rs @@ -160,6 +160,7 @@ pub unsafe trait BasicType<'ctx>: AnyType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/types/vec_type.rs b/src/types/vec_type.rs index 9f95b8a83e6..2982b81cdd6 100644 --- a/src/types/vec_type.rs +++ b/src/types/vec_type.rs @@ -200,6 +200,7 @@ impl<'ctx> VectorType<'ctx> { feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", ), deprecated( note = "Starting from version 15.0, LLVM doesn't differentiate between pointer types. Use Context::ptr_type instead." diff --git a/src/values/instruction_value.rs b/src/values/instruction_value.rs index 1bcb29c403d..e8f8c44e594 100644 --- a/src/values/instruction_value.rs +++ b/src/values/instruction_value.rs @@ -1,13 +1,15 @@ use llvm_sys::LLVMOpcode; #[llvm_versions(14..)] use llvm_sys::core::LLVMGetGEPSourceElementType; +#[cfg(not(feature = "llvm23-1"))] +use llvm_sys::core::LLVMIsConditional; use llvm_sys::core::{ LLVMGetAlignment, LLVMGetAllocatedType, LLVMGetAtomicRMWBinOp, LLVMGetFCmpPredicate, LLVMGetICmpPredicate, LLVMGetIndices, LLVMGetInstructionOpcode, LLVMGetInstructionParent, LLVMGetMetadata, LLVMGetNextInstruction, LLVMGetNumIndices, LLVMGetNumOperands, LLVMGetOperand, LLVMGetOperandUse, LLVMGetOrdering, LLVMGetPreviousInstruction, LLVMGetVolatile, LLVMHasMetadata, LLVMInstructionClone, LLVMInstructionEraseFromParent, - LLVMInstructionRemoveFromParent, LLVMIsATerminatorInst, LLVMIsConditional, LLVMIsTailCall, LLVMSetAlignment, - LLVMSetMetadata, LLVMSetOperand, LLVMSetOrdering, LLVMSetVolatile, LLVMValueAsBasicBlock, LLVMValueIsBasicBlock, + LLVMInstructionRemoveFromParent, LLVMIsATerminatorInst, LLVMIsTailCall, LLVMSetAlignment, LLVMSetMetadata, + LLVMSetOperand, LLVMSetOrdering, LLVMSetVolatile, LLVMValueAsBasicBlock, LLVMValueIsBasicBlock, }; use llvm_sys::prelude::LLVMValueRef; @@ -92,7 +94,12 @@ pub enum InstructionOpcode { AtomicCmpXchg, AtomicRMW, BitCast, + #[llvm_versions(..23)] Br, + #[llvm_versions(23..)] + UncondBr, + #[llvm_versions(23..)] + CondBr, Call, CallBr, CatchPad, @@ -129,7 +136,7 @@ pub enum InstructionOpcode { Or, #[llvm_variant(LLVMPHI)] Phi, - #[cfg(feature = "llvm22-1")] + #[llvm_versions(22..)] PtrToAddr, PtrToInt, Resume, @@ -278,10 +285,21 @@ impl<'ctx> InstructionValue<'ctx> { // SubTypes: Only apply to branch instructions /// Returns whether the branch instruction is conditional pub fn is_conditional(self) -> Result { - if self.get_opcode() == InstructionOpcode::Br { - Ok(unsafe { LLVMIsConditional(self.as_value_ref()) == 1 }) - } else { - Err(InstructionValueError::NotBrInst) + #[cfg(not(feature = "llvm23-1"))] + { + if self.get_opcode() == InstructionOpcode::Br { + Ok(unsafe { LLVMIsConditional(self.as_value_ref()) == 1 }) + } else { + Err(InstructionValueError::NotBrInst) + } + } + #[cfg(feature = "llvm23-1")] + { + match self.get_opcode() { + InstructionOpcode::CondBr => Ok(true), + InstructionOpcode::UncondBr => Ok(false), + _ => Err(InstructionValueError::NotBrInst), + } } } @@ -627,7 +645,8 @@ impl<'ctx> InstructionValue<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] InstructionOpcode::Fence => Ok(unsafe { LLVMGetOrdering(self.as_value_ref()) }.into()), _ => Err(InstructionValueError::NotAtomicOrderingInst), @@ -659,7 +678,8 @@ impl<'ctx> InstructionValue<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] ( InstructionOpcode::Fence, @@ -676,7 +696,8 @@ impl<'ctx> InstructionValue<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] (InstructionOpcode::Fence, _) => { Err(InstructionValueError::AtomicError(AtomicError::InvalidOrderingOnFence)) @@ -686,7 +707,8 @@ impl<'ctx> InstructionValue<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] (InstructionOpcode::AtomicRMW, AtomicOrdering::NotAtomic | AtomicOrdering::Unordered) => Err( InstructionValueError::AtomicError(AtomicError::InvalidOrderingOnAtomicRMW), @@ -696,7 +718,8 @@ impl<'ctx> InstructionValue<'ctx> { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] (InstructionOpcode::AtomicRMW, _) => { unsafe { LLVMSetOrdering(self.as_value_ref(), ordering.into()) }; diff --git a/src/values/metadata_value.rs b/src/values/metadata_value.rs index 0003100a252..3f2e04757ae 100644 --- a/src/values/metadata_value.rs +++ b/src/values/metadata_value.rs @@ -34,6 +34,8 @@ pub const FIRST_CUSTOM_METADATA_KIND_ID: u32 = 42 } else if cfg!(feature = "llvm22-1") { 47 + } else if cfg!(feature = "llvm23-1") { + 55 } else { panic!("Unhandled LLVM version") }; diff --git a/src/values/mod.rs b/src/values/mod.rs index 8bb09ca5140..5e15abb22cb 100644 --- a/src/values/mod.rs +++ b/src/values/mod.rs @@ -26,7 +26,8 @@ mod vec_value; feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] pub(crate) mod operand_bundle; @@ -39,6 +40,7 @@ pub(crate) mod operand_bundle; feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", )))] mod callable_value; @@ -51,6 +53,7 @@ mod callable_value; feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", + feature = "llvm23-1", )))] pub use crate::values::callable_value::CallableValue; diff --git a/tests/all/main.rs b/tests/all/main.rs index 5b556eea7eb..c24da00ad25 100644 --- a/tests/all/main.rs +++ b/tests/all/main.rs @@ -21,7 +21,8 @@ mod test_object_file; feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] mod test_passes; mod test_passes_on_function; diff --git a/tests/all/test_builder.rs b/tests/all/test_builder.rs index 48f65d30fcf..7c39b66c4a5 100644 --- a/tests/all/test_builder.rs +++ b/tests/all/test_builder.rs @@ -81,7 +81,8 @@ fn test_build_call() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] builder.build_indirect_call(fn_type2, load, &[], "call").unwrap(); builder.build_return(None).unwrap(); diff --git a/tests/all/test_instruction_values.rs b/tests/all/test_instruction_values.rs index e773630f865..ba7463ee1bf 100644 --- a/tests/all/test_instruction_values.rs +++ b/tests/all/test_instruction_values.rs @@ -223,17 +223,17 @@ fn test_get_next_use() { let arg1 = function.get_first_param().unwrap().into_float_value(); - #[cfg(any(feature = "llvm21-1", feature = "llvm22-1"))] + #[cfg(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] let f32_ptr = builder.build_alloca(f32_type, "f32_ptr").unwrap(); - #[cfg(any(feature = "llvm21-1", feature = "llvm22-1"))] + #[cfg(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] let _ = builder.build_store(f32_ptr, f32_type.const_float(std::f64::consts::PI)); - #[cfg(any(feature = "llvm21-1", feature = "llvm22-1"))] + #[cfg(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] let f32_val = builder .build_load(f32_type, f32_ptr, "f32_val") .unwrap() .into_float_value(); - #[cfg(not(any(feature = "llvm21-1", feature = "llvm22-1")))] + #[cfg(not(any(feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1")))] let f32_val = f32_type.const_float(std::f64::consts::PI); let add_pi0 = builder.build_float_add(arg1, f32_val, "add_pi").unwrap(); @@ -544,7 +544,8 @@ fn test_atomic_ordering_mem_instructions() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] let fence_instruction = builder .build_fence(AtomicOrdering::AcquireRelease, true, "fence") @@ -574,7 +575,8 @@ fn test_atomic_ordering_mem_instructions() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] assert_eq!( fence_instruction.get_atomic_ordering().unwrap(), @@ -613,7 +615,8 @@ fn test_atomic_ordering_mem_instructions() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] { assert!( diff --git a/tests/all/test_intrinsics.rs b/tests/all/test_intrinsics.rs index 4dc8667265b..497dab4c6a6 100644 --- a/tests/all/test_intrinsics.rs +++ b/tests/all/test_intrinsics.rs @@ -38,7 +38,8 @@ fn test_get_decl_va_copy() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { assert!(!va_copy.is_overloaded()); diff --git a/tests/all/test_targets.rs b/tests/all/test_targets.rs index d09d8cd9144..23267259d92 100644 --- a/tests/all/test_targets.rs +++ b/tests/all/test_targets.rs @@ -28,7 +28,12 @@ fn write_target_machine_to_memory_buffer(target_machine: TargetMachine) { let string = from_utf8(buffer.as_slice()).unwrap(); // Not sure why starting since LLVM 20, text section was removed... - #[cfg(not(any(feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1")))] + #[cfg(not(any( + feature = "llvm20-1", + feature = "llvm21-1", + feature = "llvm22-1", + feature = "llvm23-1" + )))] { assert!(string.contains(".text")); } @@ -402,7 +407,12 @@ fn test_write_target_machine_to_file() { let string = from_utf8(&contents).unwrap(); // Not sure why starting since LLVM 20, text section was removed... - #[cfg(not(any(feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1")))] + #[cfg(not(any( + feature = "llvm20-1", + feature = "llvm21-1", + feature = "llvm22-1", + feature = "llvm23-1" + )))] { assert!(string.contains(".text")); } diff --git a/tests/all/test_types.rs b/tests/all/test_types.rs index 0867b05d337..10d7d569a32 100644 --- a/tests/all/test_types.rs +++ b/tests/all/test_types.rs @@ -394,22 +394,28 @@ fn test_const_zero() { assert_eq!(i32_zero.print_to_string().to_str(), Ok("i32 0")); assert_eq!(i64_zero.print_to_string().to_str(), Ok("i64 0")); assert_eq!(i128_zero.print_to_string().to_str(), Ok("i128 0")); - assert_eq!(f16_zero.print_to_string().to_str(), Ok("half 0xH0000")); - assert_eq!(bf16_zero.print_to_string().to_str(), Ok("bfloat 0xR0000")); + assert!(matches!( + f16_zero.print_to_string().to_str(), + Ok("half 0xH0000" | "half 0.000000e+00") + )); + assert!(matches!( + bf16_zero.print_to_string().to_str(), + Ok("bfloat 0xR0000" | "bfloat 0.000000e+00") + )); assert_eq!(f32_zero.print_to_string().to_str(), Ok("float 0.000000e+00")); assert_eq!(f64_zero.print_to_string().to_str(), Ok("double 0.000000e+00")); - assert_eq!( + assert!(matches!( f80_zero.print_to_string().to_str(), - Ok("x86_fp80 0xK00000000000000000000") - ); - assert_eq!( + Ok("x86_fp80 0xK00000000000000000000" | "x86_fp80 0.000000e+00") + )); + assert!(matches!( f128_zero.print_to_string().to_str(), - Ok("fp128 0xL00000000000000000000000000000000") - ); - assert_eq!( + Ok("fp128 0xL00000000000000000000000000000000" | "fp128 0.000000e+00") + )); + assert!(matches!( ppc_f128_zero.print_to_string().to_str(), - Ok("ppc_fp128 0xM00000000000000000000000000000000") - ); + Ok("ppc_fp128 0xM00000000000000000000000000000000" | "ppc_fp128 0.000000e+00") + )); assert_eq!( struct_zero.print_to_string().to_str(), Ok("{ i8, fp128 } zeroinitializer") diff --git a/tests/all/test_values.rs b/tests/all/test_values.rs index 1e2c73b4d4e..e2dbaf7bfb1 100644 --- a/tests/all/test_values.rs +++ b/tests/all/test_values.rs @@ -79,7 +79,8 @@ fn test_call_site() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] fn test_call_site_tail_call_attributes() { let context = Context::create(); @@ -669,12 +670,12 @@ fn test_metadata() { // let i64_type = context.i64_type(); // let i128_type = context.i128_type(); // let f16_type = context.f16_type(); - // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] // let bf16_type = context.bf16_type(); let f32_type = context.f32_type(); // let f64_type = context.f64_type(); // let f128_type = context.f128_type(); - // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] // let ptr_type = context.ptr_type(AddressSpace::default()); // let array_type = f64_type.array_type(42); // let ppc_f128_type = context.ppc_f128_type(); @@ -687,15 +688,15 @@ fn test_metadata() { // let i64_val = i64_type.const_int(0, false); // let i128_val = i128_type.const_int(0, false); // let f16_val = f16_type.const_float(0.0); - // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] // let bf16_val = bf16_type.const_float(0.0); let f32_val = f32_type.const_float(0.0); // let f64_val = f64_type.const_float(0.0); // let f128_val = f128_type.const_float(0.0); // let ppc_f128_val = ppc_f128_type.const_float(0.0); - // #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1")))] + // #[cfg(not(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1")))] // let ptr_val = bool_type.ptr_type(AddressSpace::default()).const_null(); - // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + // #[cfg(any(feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] // let ptr_val = ptr_type.const_null(); // let array_val = f64_type.const_array(&[f64_val]); // let struct_val = context.const_struct(&[i8_val.into(), f128_val.into()], false); @@ -752,7 +753,7 @@ fn test_metadata() { // assert!(i64_val.has_metadata()); // assert!(!i128_val.has_metadata()); // assert!(!f16_val.has_metadata()); - // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1"))] + // #[cfg(any(feature = "llvm13-0", feature = "llvm14-0", feature = "llvm15-0", feature = "llvm16-0", feature = "llvm17-0", feature = "llvm18-1", feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", feature = "llvm22-1", feature = "llvm23-1"))] // assert!(!bf16_val.has_metadata()); // assert!(!f32_val.has_metadata()); // assert!(!f64_val.has_metadata()); @@ -806,7 +807,8 @@ fn test_floats() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { use inkwell::FloatPredicate; @@ -849,7 +851,8 @@ fn test_floats() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" )))] { let neg_two = f64_two.const_neg(); @@ -1521,7 +1524,8 @@ fn test_non_fn_ptr_called() { feature = "llvm19-1", feature = "llvm20-1", feature = "llvm21-1", - feature = "llvm22-1" + feature = "llvm22-1", + feature = "llvm23-1" ))] builder .build_indirect_call(i8_ptr_type.fn_type(&[], false), i8_ptr_param, &[], "call")