[llvm-commits] [PATCH] Extend named metadata support in the LLVM C API

Andrew Wilkins axwalk at gmail.com
Sat Dec 10 23:29:30 PST 2011


Hello,

I'm extending some Go bindings to the LLVM C API, and have found the LLVM C
API is lacking in support for named metadata. There are functions for
getting the number of and values of the operands of named metadata,
but there's no way to insert new named metadata into a module, nor to add
an operand to existing named metadata. I've attached a patch to make the
following modifications:

  * include/llvm-c/Core.h: Removed the existing
function LLVMGetNamedMetadataOperands and modified the signature
of LLVMGetNamedMetadataNumOperands.
  * include/llvm-c/Core.h: Added a new opaque type/typedef pair
LLVMOpaqueNamedMDNode/LLVMNamedMDNodeRef, and a corresponding
DEFINE_ISA_CONVERSION_FUNCTIONS conversion macro.
  * include/llvm-c/Core.h: Added new
functions LLVMGetNamedMetadata, LLVMGetOrInsertNamedMetadata,
LLVMGetNamedMetadataName, LLVMGetNamedMetadataOperand, and
LLVMAddNamedMetadataOperand. These functions operate on the
LLVMNamedMDNodeRef type.
  * lib/VMCore/Core.cpp: Functions added/removed according to changes
described above.
  * bindings/ocaml/llvm/llvm_ocaml.c: Modified llvm_get_namedmd to use the
new API calls.

The only reason I can see this change being contentious is due to the
removal of LLVMGetNamedMetadataOperands and the change in signature
of LLVMGetNamedMetadataNumOperands. I'm not too sure why there was no named
metadata type in the C API, and I don't know what the policy of API
backwards compatibility is. I hope someone will enlighten me.

This is my first patch to LLVM, please let me know if there's anything I've
missed or you'd like done differently.

Regards,
--
Andrew Wilkins
http://awilkins.id.au
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111211/e208fa5a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-capi-namedmd.diff
Type: application/octet-stream
Size: 5378 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20111211/e208fa5a/attachment.obj>


More information about the llvm-commits mailing list