forked from OSchip/llvm-project
[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
This commit is contained in:
parent
96079a368a
commit
7c80c3a8e4
|
@ -1539,7 +1539,6 @@ LLVMTypeRef LLVMX86MMXType(void);
|
||||||
macro(SelectInst) \
|
macro(SelectInst) \
|
||||||
macro(ShuffleVectorInst) \
|
macro(ShuffleVectorInst) \
|
||||||
macro(StoreInst) \
|
macro(StoreInst) \
|
||||||
macro(TerminatorInst) \
|
|
||||||
macro(BranchInst) \
|
macro(BranchInst) \
|
||||||
macro(IndirectBrInst) \
|
macro(IndirectBrInst) \
|
||||||
macro(InvokeInst) \
|
macro(InvokeInst) \
|
||||||
|
@ -2679,7 +2678,7 @@ LLVMValueRef LLVMGetBasicBlockParent(LLVMBasicBlockRef BB);
|
||||||
* If the basic block does not have a terminator (it is not well-formed
|
* If the basic block does not have a terminator (it is not well-formed
|
||||||
* if it doesn't), then NULL is returned.
|
* if it doesn't), then NULL is returned.
|
||||||
*
|
*
|
||||||
* The returned LLVMValueRef corresponds to a llvm::TerminatorInst.
|
* The returned LLVMValueRef corresponds to an llvm::Instruction.
|
||||||
*
|
*
|
||||||
* @see llvm::BasicBlock::getTerminator()
|
* @see llvm::BasicBlock::getTerminator()
|
||||||
*/
|
*/
|
||||||
|
@ -2951,6 +2950,15 @@ LLVMRealPredicate LLVMGetFCmpPredicate(LLVMValueRef Inst);
|
||||||
*/
|
*/
|
||||||
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
|
LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine whether an instruction is a terminator. This routine is named to
|
||||||
|
* be compatible with historical functions that did this by querying the
|
||||||
|
* underlying C++ type.
|
||||||
|
*
|
||||||
|
* @see llvm::Instruction::isTerminator()
|
||||||
|
*/
|
||||||
|
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
|
* @defgroup LLVMCCoreValueInstructionCall Call Sites and Invocations
|
||||||
*
|
*
|
||||||
|
@ -3091,8 +3099,8 @@ void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
|
||||||
/**
|
/**
|
||||||
* @defgroup LLVMCCoreValueInstructionTerminator Terminators
|
* @defgroup LLVMCCoreValueInstructionTerminator Terminators
|
||||||
*
|
*
|
||||||
* Functions in this group only apply to instructions that map to
|
* Functions in this group only apply to instructions for which
|
||||||
* llvm::TerminatorInst instances.
|
* LLVMIsATerminatorInst returns true.
|
||||||
*
|
*
|
||||||
* @{
|
* @{
|
||||||
*/
|
*/
|
||||||
|
@ -3100,21 +3108,21 @@ void LLVMSetUnwindDest(LLVMValueRef InvokeInst, LLVMBasicBlockRef B);
|
||||||
/**
|
/**
|
||||||
* Return the number of successors that this terminator has.
|
* Return the number of successors that this terminator has.
|
||||||
*
|
*
|
||||||
* @see llvm::TerminatorInst::getNumSuccessors
|
* @see llvm::Instruction::getNumSuccessors
|
||||||
*/
|
*/
|
||||||
unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
|
unsigned LLVMGetNumSuccessors(LLVMValueRef Term);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the specified successor.
|
* Return the specified successor.
|
||||||
*
|
*
|
||||||
* @see llvm::TerminatorInst::getSuccessor
|
* @see llvm::Instruction::getSuccessor
|
||||||
*/
|
*/
|
||||||
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
|
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Update the specified successor to point at the provided block.
|
* Update the specified successor to point at the provided block.
|
||||||
*
|
*
|
||||||
* @see llvm::TerminatorInst::setSuccessor
|
* @see llvm::Instruction::setSuccessor
|
||||||
*/
|
*/
|
||||||
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
|
void LLVMSetSuccessor(LLVMValueRef Term, unsigned i, LLVMBasicBlockRef block);
|
||||||
|
|
||||||
|
|
|
@ -2595,6 +2595,11 @@ LLVMValueRef LLVMInstructionClone(LLVMValueRef Inst) {
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
LLVMValueRef LLVMIsATerminatorInst(LLVMValueRef Inst) {
|
||||||
|
Instruction *I = dyn_cast<Instruction>(unwrap(Inst));
|
||||||
|
return (I && I->isTerminator()) ? wrap(I) : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
|
unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
|
||||||
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
|
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
|
||||||
return FPI->getNumArgOperands();
|
return FPI->getNumArgOperands();
|
||||||
|
@ -2710,15 +2715,15 @@ void LLVMSetUnwindDest(LLVMValueRef Invoke, LLVMBasicBlockRef B) {
|
||||||
/*--.. Operations on terminators ...........................................--*/
|
/*--.. Operations on terminators ...........................................--*/
|
||||||
|
|
||||||
unsigned LLVMGetNumSuccessors(LLVMValueRef Term) {
|
unsigned LLVMGetNumSuccessors(LLVMValueRef Term) {
|
||||||
return unwrap<TerminatorInst>(Term)->getNumSuccessors();
|
return unwrap<Instruction>(Term)->getNumSuccessors();
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMBasicBlockRef LLVMGetSuccessor(LLVMValueRef Term, unsigned i) {
|
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) {
|
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) ............................--*/
|
/*--.. Operations on branch instructions (only) ............................--*/
|
||||||
|
|
Loading…
Reference in New Issue