From: whitequark Date: Fri, 27 Oct 2017 11:51:40 +0000 (+0000) Subject: [LLVM-C] Publicly expose getters of MetadataType, TokenType X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a129dc8bcf535f2d5ba0f80a7280d16c88e69e95;p=llvm [LLVM-C] Publicly expose getters of MetadataType, TokenType Patch by Robert Widmann. Expose getters for MetadataType and TokenType publicly in the C API. Discovered a need for these while trying to wrap the intrinsics API. Differential Revision: https://reviews.llvm.org/D38809 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@316762 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/llvm-c/Core.h b/include/llvm-c/Core.h index 22cef23007c..8238c09f9dd 100644 --- a/include/llvm-c/Core.h +++ b/include/llvm-c/Core.h @@ -1136,6 +1136,16 @@ LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C); */ LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C); +/** + * Create a token type in a context. + */ +LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C); + +/** + * Create a metadata type in a context. + */ +LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C); + /** * These are similar to the above functions except they operate on the * global context. diff --git a/lib/IR/Core.cpp b/lib/IR/Core.cpp index 54c73b01acf..d3c33edec18 100644 --- a/lib/IR/Core.cpp +++ b/lib/IR/Core.cpp @@ -452,9 +452,6 @@ LLVMTypeRef LLVMPPCFP128TypeInContext(LLVMContextRef C) { LLVMTypeRef LLVMX86MMXTypeInContext(LLVMContextRef C) { return (LLVMTypeRef) Type::getX86_MMXTy(*unwrap(C)); } -LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C) { - return (LLVMTypeRef) Type::getTokenTy(*unwrap(C)); -} LLVMTypeRef LLVMHalfType(void) { return LLVMHalfTypeInContext(LLVMGetGlobalContext()); @@ -620,6 +617,12 @@ LLVMTypeRef LLVMVoidTypeInContext(LLVMContextRef C) { LLVMTypeRef LLVMLabelTypeInContext(LLVMContextRef C) { return wrap(Type::getLabelTy(*unwrap(C))); } +LLVMTypeRef LLVMTokenTypeInContext(LLVMContextRef C) { + return wrap(Type::getTokenTy(*unwrap(C))); +} +LLVMTypeRef LLVMMetadataTypeInContext(LLVMContextRef C) { + return wrap(Type::getMetadataTy(*unwrap(C))); +} LLVMTypeRef LLVMVoidType(void) { return LLVMVoidTypeInContext(LLVMGetGlobalContext()); diff --git a/tools/llvm-c-test/echo.cpp b/tools/llvm-c-test/echo.cpp index 966c0083bf8..885f9c0d899 100644 --- a/tools/llvm-c-test/echo.cpp +++ b/tools/llvm-c-test/echo.cpp @@ -142,7 +142,7 @@ struct TypeCloner { LLVMGetVectorSize(Src) ); case LLVMMetadataTypeKind: - break; + return LLVMMetadataTypeInContext(Ctx); case LLVMX86_MMXTypeKind: return LLVMX86MMXTypeInContext(Ctx); default: