summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2018-10-18 23:03:55 +0000
committerChandler Carruth <chandlerc@gmail.com>2018-10-18 23:03:55 +0000
commit7c80c3a8e49a19748636b7488860cbe2dd2c99d9 (patch)
tree78a1b115067ca6a5069c690d9eca228b37fc7ab5 /llvm/lib/IR
parent96079a368a3b4033c5ce8c23910eeefd15b2037a (diff)
downloadbcm5719-llvm-7c80c3a8e49a19748636b7488860cbe2dd2c99d9.tar.gz
bcm5719-llvm-7c80c3a8e49a19748636b7488860cbe2dd2c99d9.zip
[TI removal] Update the C API for the move away from `TerminatorInst`.
This updates the C API for the removal of `TerminatorInst`. It converts the type query to a predicate query and moves the generic methods to work on `Instruction` instances that satisfy this predicate rather than requiring a specific type. It also clarifies that the C API wrapping `BasicBlock::getTerminator` just returns an `Instruction`. Because this was always wrapped opaquely as a value and the functions consuming these values will work on `Instruction` objects, this shouldn't break any clients. This is a completely compatible change to the C API. Differential Revision: https://reviews.llvm.org/D52968 llvm-svn: 344764
Diffstat (limited to 'llvm/lib/IR')
-rw-r--r--llvm/lib/IR/Core.cpp11
1 files changed, 8 insertions, 3 deletions
diff --git a/llvm/lib/IR/Core.cpp b/llvm/lib/IR/Core.cpp
index 639b6b4489a..27906e68636 100644
--- a/llvm/lib/IR/Core.cpp
+++ b/llvm/lib/IR/Core.cpp
@@ -2595,6 +2595,11 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst) {
return nullptr;
}
+LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst) {
+ Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
+ return (I && I->isTerminator()) ? wrap(I) : nullptr;
+}
+
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
return FPI->getNumArgOperands();
@@ -2710,15 +2715,15 @@ void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B) {
/*--.. Operations on terminators ...........................................--*/
unsigned LLVMGetNumSuccessors(LLVMValueRef Term) {
- return unwrap<TerminatorInst>(Term)->getNumSuccessors();
+ return unwrap<Instruction>(Term)->getNumSuccessors();
}
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i) {
- return wrap(unwrap<TerminatorInst>(Term)->getSuccessor(i));
+ return wrap(unwrap<Instruction>(Term)->getSuccessor(i));
}
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block) {
- return unwrap<TerminatorInst>(Term)->setSuccessor(i,unwrap(block));
+ return unwrap<Instruction>(Term)->setSuccessor(i, unwrap(block));
}
/*--.. Operations on branch instructions (only) ............................--*/
OpenPOWER on IntegriCloud