From 995be7d07a0ed1f70a93b2a2e7f445461162e8a5 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sat, 31 May 2008 19:12:39 +0000 Subject: [PATCH] AsmWriter support for insertvalue/extractvalue. These instructions can now round-trip through assembly and bitcode. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@51823 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/VMCore/AsmWriter.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/lib/VMCore/AsmWriter.cpp b/lib/VMCore/AsmWriter.cpp index 3d39553e727..d8372ef0063 100644 --- a/lib/VMCore/AsmWriter.cpp +++ b/lib/VMCore/AsmWriter.cpp @@ -624,6 +624,12 @@ static void WriteConstantInt(std::ostream &Out, const Constant *CV, Out << ", "; } + if (CE->hasIndices()) { + const SmallVector &Indices = CE->getIndices(); + for (unsigned i = 0, e = Indices.size(); i != e; ++i) + Out << ", " << Indices[i]; + } + if (CE->isCast()) { Out << " to "; printTypeInt(Out, CE->getType(), TypeTable); @@ -1292,6 +1298,15 @@ void AssemblyWriter::printInstruction(const Instruction &I) { } else if (const GetResultInst *GRI = dyn_cast(&I)) { writeOperand(I.getOperand(0), true); Out << ", " << GRI->getIndex(); + } else if (const ExtractValueInst *EVI = dyn_cast(&I)) { + writeOperand(I.getOperand(0), true); + for (const unsigned *i = EVI->idx_begin(), *e = EVI->idx_end(); i != e; ++i) + Out << ", " << *i; + } else if (const InsertValueInst *IVI = dyn_cast(&I)) { + writeOperand(I.getOperand(0), true); Out << ','; + writeOperand(I.getOperand(1), true); + for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i) + Out << ", " << *i; } else if (isa(I) && !Operand) { Out << " void"; } else if (const CallInst *CI = dyn_cast(&I)) {