From 7a012299ced5cff02cec47055a63d3b2a78bb36f Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Tue, 5 Aug 2003 15:34:45 +0000 Subject: [PATCH] Implement TODO: print out short form of Invoke if possible git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@7595 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 2ebce7243bc..e8feb725005 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -777,15 +777,15 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } else if (isa(I) && !Operand) { Out << " void"; } else if (isa(I)) { - const PointerType *PTy = dyn_cast(Operand->getType()); - const FunctionType*MTy = PTy ? dyn_cast(PTy->getElementType()):0; - const Type *RetTy = MTy ? MTy->getReturnType() : 0; + const PointerType *PTy = cast(Operand->getType()); + const FunctionType *FTy = cast(PTy->getElementType()); + const Type *RetTy = FTy->getReturnType(); - // If possible, print out the short form of the call instruction, but we can + // If possible, print out the short form of the call instruction. We can // only do this if the first argument is a pointer to a nonvararg function, - // and if the value returned is not a pointer to a function. + // and if the return type is not a pointer to a function. // - if (RetTy && MTy && !MTy->isVarArg() && + if (!FTy->isVarArg() && (!isa(RetTy) || !isa(cast(RetTy)->getElementType()))) { Out << " "; printType(RetTy); @@ -802,8 +802,23 @@ void AssemblyWriter::printInstruction(const Instruction &I) { Out << " )"; } else if (const InvokeInst *II = dyn_cast(&I)) { - // TODO: Should try to print out short form of the Invoke instruction - writeOperand(Operand, true); + const PointerType *PTy = cast(Operand->getType()); + const FunctionType *FTy = cast(PTy->getElementType()); + const Type *RetTy = FTy->getReturnType(); + + // If possible, print out the short form of the invoke instruction. We can + // only do this if the first argument is a pointer to a nonvararg function, + // and if the return type is not a pointer to a function. + // + if (!FTy->isVarArg() && + (!isa(RetTy) || + !isa(cast(RetTy)->getElementType()))) { + Out << " "; printType(RetTy); + writeOperand(Operand, false); + } else { + writeOperand(Operand, true); + } + Out << "("; if (I.getNumOperands() > 3) writeOperand(I.getOperand(3), true); for (unsigned op = 4, Eop = I.getNumOperands(); op < Eop; ++op) { -- 2.34.1