Skip to content

Commit

Permalink
Update versioned module generation
Browse files Browse the repository at this point in the history
  • Loading branch information
mofeing committed Oct 13, 2024
1 parent 5018ca0 commit 7b0e2b6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/API/API.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ end

# generate version-less API functions
begin
local ops = mapreduce(, [v14, v15, v16, v17, v18]) do mod
local ops = mapreduce(, [v14, v15, v16, v17, v18, v19]) do mod
filter(names(mod; all=true)) do name
name [nameof(mod), :eval, :include] && !startswith(string(name), '#')
end
end

for op in ops
container_mods = filter([v14, v15, v16, v17, v18]) do mod
container_mods = filter([v14, v15, v16, v17, v18, v19]) do mod
op in names(mod; all=true)
end
container_mods = map(container_mods) do mod
Expand All @@ -34,7 +34,7 @@ begin

@eval function $op(args...; kwargs...)
version = MLIR_VERSION[]
if v"14" > version <= v"17"
if !(MLIR_VERSION_MIN <= version <= MLIR_VERSION_MAX)
error("Unsupported MLIR version $version")
end

Expand Down
8 changes: 4 additions & 4 deletions src/Dialects/Dialects.jl
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ end

begin
# list dialect operations
local dialectops = mapreduce(mergewith!(), [v14, v15, v16, v17, v18]) do mod
local dialectops = mapreduce(mergewith!(), [v14, v15, v16, v17, v18, v19]) do mod
dialects = filter(names(mod; all=true)) do dialect
dialect [nameof(mod), :eval, :include] && !startswith(string(dialect), '#')
end
Expand All @@ -33,11 +33,11 @@ begin
for (dialect, ops) in dialectops
mod = @eval module $dialect
using ...MLIR: MLIR_VERSION, MLIRException
using ..Dialects: v14, v15, v16, v17, v18
using ..Dialects: v14, v15, v16, v17, v18, v19
end

for op in ops
container_mods = filter([v14, v15, v16, v17, v18]) do mod
container_mods = filter([v14, v15, v16, v17, v18, v19]) do mod
dialect in names(mod; all=true) &&
op in names(getproperty(mod, dialect); all=true)
end
Expand All @@ -47,7 +47,7 @@ begin

@eval mod function $op(args...; kwargs...)
version = MLIR_VERSION[]
if v"14" > version > v"18"
if !(MLIR_VERSION_MIN <= version <= MLIR_VERSION_MAX)
error("Unsupported MLIR version $version")
end

Expand Down
3 changes: 3 additions & 0 deletions src/MLIR.jl
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const MLIR_VERSION = ScopedValue(
)
const MLIR_C_PATH = ScopedValue(@load_preference("MLIR_C_PATH", MLIR_jll.mlir_c))

const MLIR_VERSION_MIN = v"15"
const MLIR_VERSION_MAX = v"19"

struct MLIRException <: Exception
msg::String
end
Expand Down

0 comments on commit 7b0e2b6

Please sign in to comment.