Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replace Base.libllvm_version with libmlir_version preference #70

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ version = "0.1.0"
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
MLIR_jll = "a70bccb4-a5c0-5e2e-a329-e731972457e8"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"

[compat]
CEnum = "0.4"
MLIR_jll = "14,15,16"
Preferences = "1"
julia = "1.9"
2 changes: 1 addition & 1 deletion src/Dialects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ end
operandsegmentsizes(segments) = namedattribute("operand_segment_sizes", Attribute(Int32.(segments)))

let
ver = string(Base.libllvm_version.major)
ver = string(libmlir_version.major)
dir = joinpath(@__DIR__, "Dialects", ver)
if !isdir(dir)
error("""The MLIR dialect bindings for v$ver do not exist.
Expand Down
4 changes: 2 additions & 2 deletions src/IR/Attribute.jl
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ function Base.length(attr::Attribute)
API.mlirDictionaryAttrGetNumElements(attr)
elseif iselements(attr)
API.mlirElementsAttrGetNumElements(attr)
elseif Base.libllvm_version >= v"16"
elseif libmlir_version >= v"16"
_isdensearray = any(T -> isdensearray(attr, T), [Bool, Int8, Int16, Int32, Int64, Float32, Float64])
if _isdensearray
API.mlirDenseBoolArrayGetNumElements(attr)
Expand Down Expand Up @@ -667,7 +667,7 @@ function Base.getindex(attr::Attribute, i)
else
throw("unsupported element type $(elem_type)")
end
elseif Base.libllvm_version >= v"16"
elseif libmlir_version >= v"16"
if isdensearray(attr, Bool)
API.mlirDenseBoolArrayGetElement(attr, i)
elseif isdensearray(attr, Int8)
Expand Down
2 changes: 1 addition & 1 deletion src/IR/IR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,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 && Base.libllvm_version >= version || predname == :max && VersionNumber(Base.libllvm_version.major) <= version
if predname == :min && libmlir_version >= version || predname == :max && VersionNumber(libmlir_version.major) <= version
esc(expr)
else
esc(:(nothing))
Expand Down
2 changes: 1 addition & 1 deletion src/IR/Operation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ function Base.show(io::IO, operation::Operation)

flags = API.mlirOpPrintingFlagsCreate()

if Base.libllvm_version >= v"16"
if libmlir_version >= v"16"
API.mlirOpPrintingFlagsEnableDebugInfo(flags, get(io, :debug, false), true)
else
get(io, :debug, false) && API.mlirOpPrintingFlagsEnableDebugInfo(flags, true)
Expand Down
2 changes: 1 addition & 1 deletion src/IR/Pass.jl
Original file line number Diff line number Diff line change
Expand Up @@ -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 Base.libllvm_version >= v"16"
result = if libmlir_version >= v"16"
io = IOBuffer()
c_print_callback = @cfunction(print_callback, Cvoid, (API.MlirStringRef, Any))
API.mlirParsePassPipeline(opm, pipeline, c_print_callback, Ref(io))
Expand Down
6 changes: 5 additions & 1 deletion src/MLIR.jl
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
module MLIR

using Preferences

libmlir_version = VersionNumber(@load_preference("libmlir_version", Base.libllvm_version_string))

module API
using CEnum

# MLIR C API
using MLIR_jll
let
ver = string(Base.libllvm_version.major)
ver = string(libmlir_version.major)
dir = joinpath(@__DIR__, "API", ver)
if !isdir(dir)
error("""The MLIR API bindings for v$ver do not exist.
Expand Down
Loading