[llvm-branch-commits] [llvm-branch] r136020 - in /llvm/branches/exception-handling-rewrite: include/llvm/Bitcode/LLVMBitCodes.h lib/Bitcode/Reader/BitcodeReader.cpp lib/Bitcode/Writer/BitcodeWriter.cpp lib/VMCore/AsmWriter.cpp
Bill Wendling
isanbard at gmail.com
Mon Jul 25 16:59:03 PDT 2011
Author: void
Date: Mon Jul 25 18:59:03 2011
New Revision: 136020
URL: http://llvm.org/viewvc/llvm-project?rev=136020&view=rev
Log:
Support reading and writing to a bitcode file.
We can now read and emit the landingpad instruction to and from the bitcode
format.
Modified:
llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp
Modified: llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h?rev=136020&r1=136019&r2=136020&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h (original)
+++ llvm/branches/exception-handling-rewrite/include/llvm/Bitcode/LLVMBitCodes.h Mon Jul 25 18:59:03 2011
@@ -266,7 +266,9 @@
FUNC_CODE_INST_CALL = 34, // CALL: [attr, fnty, fnid, args...]
- FUNC_CODE_DEBUG_LOC = 35 // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
+ FUNC_CODE_INST_LANDINGPAD = 35, // LANDINGPAD: [ty, val, num, id0,val0 ...]
+
+ FUNC_CODE_DEBUG_LOC = 36 // DEBUG_LOC: [Line,Col,ScopeVal, IAVal]
};
} // End bitc namespace
} // End llvm namespace
Modified: llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp?rev=136020&r1=136019&r2=136020&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/Bitcode/Reader/BitcodeReader.cpp Mon Jul 25 18:59:03 2011
@@ -2497,6 +2497,36 @@
break;
}
+ case bitc::FUNC_CODE_INST_LANDINGPAD: {
+ // LANDINGPAD: [ty, val, num, id0,val0 ...]
+ unsigned Idx = 0;
+ if (Record.size() < 3) ////////////////
+ return Error("Invalid LANDINGPAD record");
+ Type *Ty = getTypeByID(Record[Idx++]);
+ if (!Ty) return Error("Invalid LANDINGPAD record");
+ Value *PersFn = 0;
+ if (getValueTypePair(Record, Idx, NextValueNo, PersFn))
+ return Error("Invalid LANDINGPAD record");
+
+ unsigned NumClauses = Record[Idx++];
+ LandingPadInst *LP = LandingPadInst::Create(Ty, PersFn, NumClauses);
+
+ for (unsigned J = 0; J != NumClauses; ++J) {
+ LandingPadInst::ClauseType CT =
+ LandingPadInst::ClauseType(Record[Idx++]);
+ Value *Val = 0;
+ if (getValueTypePair(Record, Idx, NextValueNo, Val)) {
+ delete LP;
+ return Error("Invalid LANDINGPAD record");
+ }
+
+ LP->addClause(CT, Val);
+ }
+
+ I = LP;
+ break;
+ }
+
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
if (Record.size() != 4)
return Error("Invalid ALLOCA record");
Modified: llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp?rev=136020&r1=136019&r2=136020&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/Bitcode/Writer/BitcodeWriter.cpp Mon Jul 25 18:59:03 2011
@@ -1124,6 +1124,19 @@
break;
}
+ case Instruction::LandingPad: {
+ const LandingPadInst &LP = cast<LandingPadInst>(I);
+ Code = bitc::FUNC_CODE_INST_LANDINGPAD;
+ Vals.push_back(VE.getTypeID(LP.getType()));
+ PushValueAndType(LP.getPersonalityFn(), InstID, Vals, VE);
+ Vals.push_back(LP.getNumClauses());
+ for (unsigned I = 0, E = LP.getNumClauses(); I != E; ++I) {
+ Vals.push_back(LP.getClauseType(I));
+ PushValueAndType(LP.getClauseValue(I), InstID, Vals, VE);
+ }
+ break;
+ }
+
case Instruction::Alloca:
Code = bitc::FUNC_CODE_INST_ALLOCA;
Vals.push_back(VE.getTypeID(I.getType()));
Modified: llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp?rev=136020&r1=136019&r2=136020&view=diff
==============================================================================
--- llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp (original)
+++ llvm/branches/exception-handling-rewrite/lib/VMCore/AsmWriter.cpp Mon Jul 25 18:59:03 2011
@@ -1709,6 +1709,28 @@
writeOperand(I.getOperand(1), true);
for (const unsigned *i = IVI->idx_begin(), *e = IVI->idx_end(); i != e; ++i)
Out << ", " << *i;
+ } else if (const LandingPadInst *LPI = dyn_cast<LandingPadInst>(&I)) {
+ Out << ' ';
+ TypePrinter.print(I.getType(), Out);
+ Out << " personality ";
+ writeOperand(LPI->getPersonalityFn(), true); Out << '\n';
+
+ for (unsigned i = 0, e = LPI->getNumClauses(); i != e; ) {
+ SmallVector<const Value*, 8> Vals;
+ LandingPadInst::ClauseType CT = LPI->getClauseType(i);
+ for (; i != e && LPI->getClauseType(i) == CT; ++i)
+ Vals.push_back(LPI->getClauseValue(i));
+
+ if (CT == LandingPadInst::Catch)
+ Out << " catch ";
+ else
+ Out << " filter ";
+
+ for (unsigned II = 0, IE = Vals.size(); II != IE; ++II) {
+ if (II != 0) Out << ", ";
+ writeOperand(Vals[II], true);
+ }
+ }
} else if (isa<ReturnInst>(I) && !Operand) {
Out << " void";
} else if (const CallInst *CI = dyn_cast<CallInst>(&I)) {
More information about the llvm-branch-commits
mailing list