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() 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(); }