remove support for a bunch of obsolete instruction encodings

and other backward compatibility hacks.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@133273 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner
2011-06-17 18:09:11 +00:00
parent 738f05aa90
commit 96a74c57d9
21 changed files with 18 additions and 347 deletions

View File

@ -2087,18 +2087,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
break;
}
case bitc::FUNC_CODE_INST_GETRESULT: { // GETRESULT: [ty, val, n]
if (Record.size() != 2)
return Error("Invalid GETRESULT record");
unsigned OpNum = 0;
Value *Op;
getValueTypePair(Record, OpNum, NextValueNo, Op);
unsigned Index = Record[1];
I = ExtractValueInst::Create(Op, Index);
InstructionList.push_back(I);
break;
}
case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
{
unsigned Size = Record.size();
@ -2109,33 +2097,13 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
}
unsigned OpNum = 0;
SmallVector<Value *,4> Vs;
do {
Value *Op = NULL;
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
return Error("Invalid RET record");
Vs.push_back(Op);
} while(OpNum != Record.size());
Value *Op = NULL;
if (getValueTypePair(Record, OpNum, NextValueNo, Op))
return Error("Invalid RET record");
if (OpNum != Record.size())
return Error("Invalid RET record");
const Type *ReturnType = F->getReturnType();
// Handle multiple return values. FIXME: Remove in LLVM 3.0.
if (Vs.size() > 1 ||
(ReturnType->isStructTy() &&
(Vs.empty() || Vs[0]->getType() != ReturnType))) {
Value *RV = UndefValue::get(ReturnType);
for (unsigned i = 0, e = Vs.size(); i != e; ++i) {
I = InsertValueInst::Create(RV, Vs[i], i, "mrv");
InstructionList.push_back(I);
CurBB->getInstList().push_back(I);
ValueList.AssignValue(I, NextValueNo++);
RV = I;
}
I = ReturnInst::Create(Context, RV);
InstructionList.push_back(I);
break;
}
I = ReturnInst::Create(Context, Vs[0]);
I = ReturnInst::Create(Context, Op);
InstructionList.push_back(I);
break;
}
@ -2282,47 +2250,14 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
break;
}
case bitc::FUNC_CODE_INST_MALLOC: { // MALLOC: [instty, op, align]
// Autoupgrade malloc instruction to malloc call.
// FIXME: Remove in LLVM 3.0.
if (Record.size() < 3)
return Error("Invalid MALLOC record");
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
if (Record.size() != 4)
return Error("Invalid ALLOCA record");
const PointerType *Ty =
dyn_cast_or_null<PointerType>(getTypeByID(Record[0]));
Value *Size = getFnValueByID(Record[1], Type::getInt32Ty(Context));
if (!Ty || !Size) return Error("Invalid MALLOC record");
if (!CurBB) return Error("Invalid malloc instruction with no BB");
const Type *Int32Ty = IntegerType::getInt32Ty(CurBB->getContext());
Constant *AllocSize = ConstantExpr::getSizeOf(Ty->getElementType());
AllocSize = ConstantExpr::getTruncOrBitCast(AllocSize, Int32Ty);
I = CallInst::CreateMalloc(CurBB, Int32Ty, Ty->getElementType(),
AllocSize, Size, NULL);
InstructionList.push_back(I);
break;
}
case bitc::FUNC_CODE_INST_FREE: { // FREE: [op, opty]
unsigned OpNum = 0;
Value *Op;
if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
OpNum != Record.size())
return Error("Invalid FREE record");
if (!CurBB) return Error("Invalid free instruction with no BB");
I = CallInst::CreateFree(Op, CurBB);
InstructionList.push_back(I);
break;
}
case bitc::FUNC_CODE_INST_ALLOCA: { // ALLOCA: [instty, opty, op, align]
// For backward compatibility, tolerate a lack of an opty, and use i32.
// Remove this in LLVM 3.0.
if (Record.size() < 3 || Record.size() > 4)
return Error("Invalid ALLOCA record");
unsigned OpNum = 0;
const PointerType *Ty =
dyn_cast_or_null<PointerType>(getTypeByID(Record[OpNum++]));
const Type *OpTy = Record.size() == 4 ? getTypeByID(Record[OpNum++]) :
Type::getInt32Ty(Context);
Value *Size = getFnValueByID(Record[OpNum++], OpTy);
unsigned Align = Record[OpNum++];
const Type *OpTy = getTypeByID(Record[1]);
Value *Size = getFnValueByID(Record[2], OpTy);
unsigned Align = Record[3];
if (!Ty || !Size) return Error("Invalid ALLOCA record");
I = new AllocaInst(Ty->getElementType(), Size, (1 << Align) >> 1);
InstructionList.push_back(I);
@ -2352,22 +2287,6 @@ bool BitcodeReader::ParseFunctionBody(Function *F) {
InstructionList.push_back(I);
break;
}
case bitc::FUNC_CODE_INST_STORE: { // STORE:[val, valty, ptr, align, vol]
// FIXME: Legacy form of store instruction. Should be removed in LLVM 3.0.
unsigned OpNum = 0;
Value *Val, *Ptr;
if (getValueTypePair(Record, OpNum, NextValueNo, Val) ||
getValue(Record, OpNum,
PointerType::getUnqual(Val->getType()), Ptr)||
OpNum+2 != Record.size())
return Error("Invalid STORE record");
I = new StoreInst(Val, Ptr, Record[OpNum+1], (1 << Record[OpNum]) >> 1);
InstructionList.push_back(I);
break;
}
// FIXME: Remove this in LLVM 3.0.
case bitc::FUNC_CODE_INST_CALL:
case bitc::FUNC_CODE_INST_CALL2: {
// CALL: [paramattrs, cc, fnty, fnid, arg0, arg1...]
if (Record.size() < 3)