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

Check for LLVM.jl version #1498

Closed
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LLVM = "929cbde3-209d-540e-8aea-75f648917ca0"
Libdl = "8f399da3-3557-5675-b5ff-fb832c97cbdb"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
ObjectFile = "d8793406-e978-5875-9003-1fc021f44a92"
Pkg = "44cfe95a-1eb2-52ea-b672-e2afdf69b78f"
Preferences = "21216c6a-2e73-6563-6e65-726566657250"
Printf = "de0858da-6303-5e67-8744-51eddeeeb8d7"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
Expand Down
5 changes: 4 additions & 1 deletion src/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ using Enzyme_jll
using Libdl
using LLVM
using CEnum
using Pkg

const EnzymeLogicRef = Ptr{Cvoid}
const EnzymeTypeAnalysisRef = Ptr{Cvoid}
Expand All @@ -15,6 +16,7 @@ const EnzymeGradientUtilsRef = Ptr{Cvoid}
const UP = Cint(1)
const DOWN = Cint(2)
const BOTH = Cint(3)
const LLVM_JL_VERSION = Pkg.installed()["LLVM"]

struct IntList
data::Ptr{Int64}
Expand Down Expand Up @@ -103,7 +105,7 @@ struct CFnTypeInfo
known_values::Ptr{IntList}
end


@static if LLVM_JL_VERSION < v"7.2.0"
Base.haskey(md::LLVM.InstructionMetadataDict, kind::String) =
ccall((:EnzymeGetStringMD, libEnzyme), Cvoid, (LLVM.API.LLVMValueRef, Cstring), md.inst, kind) != C_NULL

Expand All @@ -115,6 +117,7 @@ function Base.getindex(md::LLVM.InstructionMetadataDict, kind::String)

Base.setindex!(md::LLVM.InstructionMetadataDict, node::LLVM.Metadata, kind::String) =
ccall((:EnzymeSetStringMD, libEnzyme), Cvoid, (LLVM.API.LLVMValueRef, Cstring, LLVM.API.LLVMValueRef), md.inst, kind, LLVM.Value(node))
end

@cenum(CDIFFE_TYPE,
DFT_OUT_DIFF = 0, # add differential to an output struct
Expand Down
Loading