[PATCH] D18729: [llvm-c] Improve IR Introspection: Add enums
Nicole Mazzuca via llvm-commits
llvm-commits at lists.llvm.org
Sat Apr 2 14:47:10 PDT 2016
ubsan updated the summary for this revision.
ubsan updated this revision to Diff 52481.
http://reviews.llvm.org/D18729
Files:
include/llvm-c/Core.h
lib/IR/Core.cpp
Index: lib/IR/Core.cpp
===================================================================
--- lib/IR/Core.cpp
+++ lib/IR/Core.cpp
@@ -157,6 +157,15 @@
delete unwrap(M);
}
+char *LLVMGetModuleIdentifier(LLVMModuleRef M) {
+ return strdup(unwrap(M)->getModuleIdentifier().c_str());
+}
+
+void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *ID) {
+ unwrap(M)->setModuleIdentifier(ID);
+}
+
+
/*--.. Data layout .........................................................--*/
const char *LLVMGetDataLayoutStr(LLVMModuleRef M) {
return unwrap(M)->getDataLayoutStr().c_str();
@@ -539,6 +548,17 @@
return wrap(unwrap(Val)->getType());
}
+LLVMValueKind LLVMGetValueKind(LLVMValueRef Val) {
+ switch(unwrap(Val)->getValueID()) {
+#define HANDLE_VALUE(Name) \
+ case ValueTy::Name##Val: \
+ return LLVM##Name##ValueKind;
+#include "llvm/IR/Value.def"
+ default:
+ return LLVMInstructionValueKind;
+ }
+}
+
const char *LLVMGetValueName(LLVMValueRef Val) {
return unwrap(Val)->getName().data();
}
Index: include/llvm-c/Core.h
===================================================================
--- include/llvm-c/Core.h
+++ include/llvm-c/Core.h
@@ -248,6 +248,11 @@
} LLVMCallConv;
typedef enum {
+#define HANDLE_VALUE(Name) LLVM##Name##ValueKind,
+#include "llvm/IR/Value.def"
+} LLVMValueKind;
+
+typedef enum {
LLVMIntEQ = 32, /**< equal */
LLVMIntNE, /**< not equal */
LLVMIntUGT, /**< unsigned greater than */
@@ -481,6 +486,19 @@
void LLVMDisposeModule(LLVMModuleRef M);
/**
+ * Obtain the identifier of a module. The result must be discarded with
+ * LLVMDisposeMessage.
+ * @see Module::getModuleIdentifier()
+ */
+char *LLVMGetModuleIdentifier(LLVMModuleRef M);
+
+/**
+ * Set the identifier of a module.
+ * @see Module::setModuleIdentifier()
+ */
+void LLVMSetModuleIdentifier(LLVMModuleRef M, const char *ID);
+
+/**
* Obtain the data layout for a module.
*
* @see Module::getDataLayoutStr()
@@ -1171,6 +1189,13 @@
LLVMTypeRef LLVMTypeOf(LLVMValueRef Val);
/**
+ * Obtain the enumerated type of a Value instance.
+ *
+ * @see llvm::Value::getValueID()
+ */
+LLVMValueKind LLVMGetValueKind(LLVMValueRef Val);
+
+/**
* Obtain the string name of a value.
*
* @see llvm::Value::getName()
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18729.52481.patch
Type: text/x-patch
Size: 2268 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160402/0bdefd9e/attachment.bin>
More information about the llvm-commits
mailing list