Skip to content

Commit 87f2b0d

Browse files
vchuravymaleadt
authored andcommitted
add Metadata type
1 parent 267774d commit 87f2b0d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/core/metadata.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,15 @@ function operands(md::MDNode)
3838
API.LLVMGetMDNodeOperands(ref(md), ops)
3939
return Value[Value(op) for op in ops]
4040
end
41+
42+
@checked struct Metadata
43+
ref::API.LLVMMetadataRef
44+
end
45+
reftype(::Type{Metadata}) = API.LLVMMetdataRef
46+
function Value(md::Metadata, ctx::Context)
47+
return MetadataAsValue(API.LLVMMetadataAsValue(ref(ctx), md))
48+
end
49+
50+
function Metadata(val::Value)
51+
return Metadata(LLVM.API.LLVMValueAsMetadata(ref(val)))
52+
end

0 commit comments

Comments
 (0)