[PATCH] D18729: [llvm-c] Improve IR Introspection: Add enums

Nicole Mazzuca via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 2 14:53:22 PDT 2016


ubsan updated the summary for this revision.
ubsan updated this revision to Diff 52482.
ubsan added a comment.

listening to whitequark :P


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
@@ -539,6 +539,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 */
@@ -1171,6 +1176,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.52482.patch
Type: text/x-patch
Size: 1312 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160402/d5749fb7/attachment.bin>


More information about the llvm-commits mailing list