diff options
author | whitequark <whitequark@whitequark.org> | 2017-06-05 11:49:52 +0000 |
---|---|---|
committer | whitequark <whitequark@whitequark.org> | 2017-06-05 11:49:52 +0000 |
commit | f6059fdc547f1f07ef1c22b48da6514a581c3665 (patch) | |
tree | b5754f0c702d23dd67eff0cc4e46695a46dac054 /llvm/lib | |
parent | b3398936ab26d7426bd5419da6c57334c3cfc043 (diff) | |
download | bcm5719-llvm-f6059fdc547f1f07ef1c22b48da6514a581c3665.tar.gz bcm5719-llvm-f6059fdc547f1f07ef1c22b48da6514a581c3665.zip |
[LLVM-C] [OCaml] Expose Type::subtypes.
The C functions added are LLVMGetNumContainedTypes and
LLVMGetSubtypes.
The OCaml function added is Llvm.subtypes.
Patch by Ekaterina Vaartis.
Differential Revision: https://reviews.llvm.org/D33677
llvm-svn: 304709
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/IR/Core.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp index 50292b6e20b..4ff0261a7f0 100644 --- a/llvm/lib/IR/Core.cpp +++ b/llvm/lib/IR/Core.cpp @@ -568,6 +568,14 @@ LLVMTypeRef LLVMGetTypeByName(LLVMModuleRef M, const char *Name) { /*--.. Operations on array, pointer, and vector types (sequence types) .....--*/ +void LLVMGetSubtypes(LLVMTypeRef Tp, LLVMTypeRef *Arr) { + int i = 0; + for (auto *T : unwrap(Tp)->subtypes()) { + Arr[i] = wrap(T); + i++; + } +} + LLVMTypeRef LLVMArrayType(LLVMTypeRef ElementType, unsigned ElementCount) { return wrap(ArrayType::get(unwrap(ElementType), ElementCount)); } @@ -587,6 +595,10 @@ LLVMTypeRef LLVMGetElementType(LLVMTypeRef WrappedTy) { return wrap(cast<SequentialType>(Ty)->getElementType()); } +unsigned LLVMGetNumContainedTypes(LLVMTypeRef Tp) { + return unwrap(Tp)->getNumContainedTypes(); +} + unsigned LLVMGetArrayLength(LLVMTypeRef ArrayTy) { return unwrap<ArrayType>(ArrayTy)->getNumElements(); } |