From 338cfc329f4c6b44f2c9bf0d193d10ec9e630c4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 23 Apr 2024 17:46:02 +0200 Subject: [PATCH 1/2] Replace `LLVM.version()` with `Base.libllvm_version` --- Project.toml | 2 -- src/IR/Attribute.jl | 4 ++-- src/IR/IR.jl | 3 +-- src/IR/Operation.jl | 2 +- src/IR/Pass.jl | 2 +- src/MLIR.jl | 5 +---- 6 files changed, 6 insertions(+), 12 deletions(-) diff --git a/Project.toml b/Project.toml index c24fc6c0..eae50c2c 100644 --- a/Project.toml +++ b/Project.toml @@ -4,12 +4,10 @@ version = "0.1.0" [deps] CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" -LLVM = "929cbde3-209d-540e-8aea-75f648917ca0" Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb" MLIR_jll = "a70bccb4-a5c0-5e2e-a329-e731972457e8" [compat] CEnum = "0.4" -LLVM = "5" MLIR_jll = "14,15,16" julia = "1.9" diff --git a/src/IR/Attribute.jl b/src/IR/Attribute.jl index 8d5b674c..c49f43ae 100644 --- a/src/IR/Attribute.jl +++ b/src/IR/Attribute.jl @@ -621,7 +621,7 @@ function Base.length(attr::Attribute) API.mlirDictionaryAttrGetNumElements(attr) elseif iselements(attr) API.mlirElementsAttrGetNumElements(attr) - elseif LLVM.version() >= v"16" + elseif Base.libllvm_version >= v"16" _isdensearray = any(T -> isdensearray(attr, T), [Bool, Int8, Int16, Int32, Int64, Float32, Float64]) if _isdensearray API.mlirDenseBoolArrayGetNumElements(attr) @@ -667,7 +667,7 @@ function Base.getindex(attr::Attribute, i) else throw("unsupported element type $(elem_type)") end - elseif LLVM.version() >= v"16" + elseif Base.libllvm_version >= v"16" if isdensearray(attr, Bool) API.mlirDenseBoolArrayGetElement(attr, i) elseif isdensearray(attr, Int8) diff --git a/src/IR/IR.jl b/src/IR/IR.jl index 5db0f4cc..91d765eb 100644 --- a/src/IR/IR.jl +++ b/src/IR/IR.jl @@ -1,7 +1,6 @@ module IR using ..API -using LLVM: LLVM # do not export `Type`, as it is already defined in Core # also, use `Core.Type` inside this module to avoid clash with MLIR `Type` @@ -31,7 +30,7 @@ macro llvmversioned(pred, expr) @assert Meta.isexpr(version, :macrocall) && version.args[1] == Symbol("@v_str") "Expected a VersionNumber" version = eval(version) - if predname == :min && LLVM.version() >= version || predname == :max && VersionNumber(LLVM.version().major) <= version + if predname == :min && Base.libllvm_version >= version || predname == :max && VersionNumber(Base.libllvm_version.major) <= version esc(expr) else esc(:(nothing)) diff --git a/src/IR/Operation.jl b/src/IR/Operation.jl index 0dd4c194..d7743977 100644 --- a/src/IR/Operation.jl +++ b/src/IR/Operation.jl @@ -220,7 +220,7 @@ function Base.show(io::IO, operation::Operation) flags = API.mlirOpPrintingFlagsCreate() - if LLVM.version() >= v"16" + if Base.libllvm_version >= v"16" API.mlirOpPrintingFlagsEnableDebugInfo(flags, get(io, :debug, false), true) else get(io, :debug, false) && API.mlirOpPrintingFlagsEnableDebugInfo(flags, true) diff --git a/src/IR/Pass.jl b/src/IR/Pass.jl index 8fe3dd20..84ba060a 100644 --- a/src/IR/Pass.jl +++ b/src/IR/Pass.jl @@ -145,7 +145,7 @@ end Parse a textual MLIR pass pipeline and add it to the provided `OpPassManager`. """ function Base.parse(opm::OpPassManager, pipeline::String) - result = if LLVM.version() >= v"16" + result = if Base.libllvm_version >= v"16" io = IOBuffer() c_print_callback = @cfunction(print_callback, Cvoid, (API.MlirStringRef, Any)) API.mlirParsePassPipeline(opm, pipeline, c_print_callback, Ref(io)) diff --git a/src/MLIR.jl b/src/MLIR.jl index 1a2b0517..5d28953f 100644 --- a/src/MLIR.jl +++ b/src/MLIR.jl @@ -1,15 +1,12 @@ module MLIR -import LLVM - module API using CEnum # MLIR C API -import ..LLVM using MLIR_jll let - ver = string(LLVM.version().major) + ver = string(Base.libllvm_version.major) dir = joinpath(@__DIR__, "API", ver) if !isdir(dir) error("""The MLIR API bindings for v$ver do not exist. From d592ebeb3eb046866cc390634ac536138e25a174 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20S=C3=A1nchez=20Ram=C3=ADrez?= Date: Tue, 23 Apr 2024 18:07:34 +0200 Subject: [PATCH 2/2] Fix forgotten LLVM import in Dialects --- src/Dialects.jl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Dialects.jl b/src/Dialects.jl index 591ac8c4..8bd9c513 100644 --- a/src/Dialects.jl +++ b/src/Dialects.jl @@ -1,6 +1,5 @@ module Dialects -import LLVM import ..IR: Attribute, NamedAttribute, context import ..API @@ -14,7 +13,7 @@ end operandsegmentsizes(segments) = namedattribute("operand_segment_sizes", Attribute(Int32.(segments))) let - ver = string(LLVM.version().major) + ver = string(Base.libllvm_version.major) dir = joinpath(@__DIR__, "Dialects", ver) if !isdir(dir) error("""The MLIR dialect bindings for v$ver do not exist.