Skip to content

Commit

Permalink
fix executionengine tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Jan 16, 2024
1 parent d20023a commit 1d95e41
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion examples/brutus.jl
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ fptr = IR.context!(IR.Context()) do

IR.run!(pm, mod)

jit = if LLVM.version().major <= 15
jit = if LLVM.version() <= v"15"
MLIR.API.mlirExecutionEngineCreate(mod, 0, 0, C_NULL)
else
MLIR.API.mlirExecutionEngineCreate(mod, 0, 0, C_NULL, false)
Expand Down
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",
LLVM.version().major <= 15 ?
LLVM.version() <= v"15" ?
Attribute(Int32.(segments)) :
DenseArrayAttribute(Int32.(segments))
)
Expand Down
25 changes: 18 additions & 7 deletions test/executionengine.jl
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ function registerAllUpstreamDialects!(ctx)
return nothing
end

# TODO: Fix for LLVM 15
function lowerModuleToLLVM(ctx, mod)
pm = MLIR.API.mlirPassManagerCreate(ctx)
if LLVM.version() >= v"15"
Expand All @@ -26,17 +25,24 @@ function lowerModuleToLLVM(ctx, mod)
end
opm = MLIR.API.mlirPassManagerGetNestedUnder(pm, op)
if LLVM.version() >= v"15"
MLIR.API.mlirPassManagerAddOwnedPass(pm,
MLIR.API.mlirPassManagerAddOwnedPass(pm,
MLIR.API.mlirCreateConversionConvertFuncToLLVM()
)
else
MLIR.API.mlirPassManagerAddOwnedPass(pm,
MLIR.API.mlirCreateConversionConvertStandardToLLVM()
)
end
MLIR.API.mlirOpPassManagerAddOwnedPass(opm,
MLIR.API.mlirCreateConversionConvertArithmeticToLLVM()
)

if LLVM.version() >= v"16"
MLIR.API.mlirOpPassManagerAddOwnedPass(opm,
MLIR.API.mlirCreateConversionArithToLLVMConversionPass()
)
else
MLIR.API.mlirOpPassManagerAddOwnedPass(opm,
MLIR.API.mlirCreateConversionConvertArithmeticToLLVM()
)
end
status = MLIR.API.mlirPassManagerRun(pm, mod)
# undefined symbol: mlirLogicalResultIsFailure
if status.value == 0
Expand Down Expand Up @@ -74,8 +80,13 @@ MLIR.API.mlirRegisterAllLLVMTranslations(ctx)

# TODO add C-API for translateModuleToLLVMIR

jit = MLIR.API.mlirExecutionEngineCreate(
mod, #=optLevel=# 2, #=numPaths=# 0, #=sharedLibPaths=# C_NULL)
jit = if LLVM.version() <= v"15"
MLIR.API.mlirExecutionEngineCreate(
mod, #=optLevel=# 2, #=numPaths=# 0, #=sharedLibPaths=# C_NULL)
else
MLIR.API.mlirExecutionEngineCreate(
mod, #=optLevel=# 2, #=numPaths=# 0, #=sharedLibPaths=# C_NULL, #= enableObjectDump =# false)
end

if jit == C_NULL
error("Execution engine creation failed")
Expand Down

0 comments on commit 1d95e41

Please sign in to comment.