[llvm-commits] [llvm] r146984 - in /llvm/trunk: include/llvm-c/Core.h lib/VMCore/Core.cpp

Devang Patel dpatel at apple.com
Tue Dec 20 11:29:36 PST 2011


Author: dpatel
Date: Tue Dec 20 13:29:36 2011
New Revision: 146984

URL: http://llvm.org/viewvc/llvm-project?rev=146984&view=rev
Log:
Add support to add named metadata operand.
Patch by Andrew Wilkins!

Modified:
    llvm/trunk/include/llvm-c/Core.h
    llvm/trunk/lib/VMCore/Core.cpp

Modified: llvm/trunk/include/llvm-c/Core.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm-c/Core.h?rev=146984&r1=146983&r2=146984&view=diff
==============================================================================
--- llvm/trunk/include/llvm-c/Core.h (original)
+++ llvm/trunk/include/llvm-c/Core.h Tue Dec 20 13:29:36 2011
@@ -567,6 +567,8 @@
 const char  *LLVMGetMDString(LLVMValueRef V, unsigned* Len);
 unsigned LLVMGetNamedMetadataNumOperands(LLVMModuleRef M, const char* name);
 void LLVMGetNamedMetadataOperands(LLVMModuleRef M, const char* name, LLVMValueRef *Dest);
+void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
+                                 LLVMValueRef Val);
 
 /* Operations on scalar constants */
 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,

Modified: llvm/trunk/lib/VMCore/Core.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Core.cpp?rev=146984&r1=146983&r2=146984&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Core.cpp (original)
+++ llvm/trunk/lib/VMCore/Core.cpp Tue Dec 20 13:29:36 2011
@@ -566,6 +566,17 @@
     Dest[i] = wrap(N->getOperand(i));
 }
 
+void LLVMAddNamedMetadataOperand(LLVMModuleRef M, const char* name,
+                                 LLVMValueRef Val)
+{
+  NamedMDNode *N = unwrap(M)->getOrInsertNamedMetadata(name);
+  if (!N)
+    return;
+  MDNode *Op = Val ? unwrap<MDNode>(Val) : NULL;
+  if (Op)
+    N->addOperand(Op);
+}
+
 /*--.. Operations on scalar constants ......................................--*/
 
 LLVMValueRef LLVMConstInt(LLVMTypeRef IntTy, unsigned long long N,





More information about the llvm-commits mailing list