Chromium Code Reviews| Index: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
| diff --git a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
| index 7332761b3e1c88b41f3355efea479d1e41ed2d25..f44b8d304b7f7c896e28ddf4383faec91f26427c 100644 |
| --- a/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
| +++ b/lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp |
| @@ -369,6 +369,15 @@ bool NaClBitcodeReader::ParseTypeTableBody() { |
| ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); |
| break; |
| } |
| + case naclbitc::TYPE_CODE_VECTOR: { // VECTOR: [numelts, eltty] |
| + if (Record.size() < 2) |
|
Karl
2014/04/02 15:56:22
Why not == instead of <?
JF
2014/04/02 18:37:12
Done, as discussed I'll also update the surroundin
|
| + return Error("Invalid VECTOR type record"); |
| + if ((ResultTy = getTypeByID(Record[1]))) |
| + ResultTy = VectorType::get(ResultTy, Record[0]); |
| + else |
| + return Error("invalid type in vector type"); |
| + break; |
| + } |
| } |
| if (NumRecords >= TypeList.size()) |
| @@ -1158,6 +1167,43 @@ bool NaClBitcodeReader::ParseFunctionBody(Function *F) { |
| break; |
| } |
| + case naclbitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opty, opval, opval] |
|
Karl
2014/04/02 15:56:22
Don't you need to record size test here to verify
JF
2014/04/02 18:37:12
Same as above, I'll send a CL to update the surrou
|
| + unsigned OpNum = 0; |
| + Value *Vec, *Idx; |
| + if (popValue(Record, &OpNum, NextValueNo, &Vec) || |
| + popValue(Record, &OpNum, NextValueNo, &Idx)) |
| + return Error("Invalid EXTRACTELEMENT record"); |
| + |
| + // expect i32 |
| + if (Idx->getType() != Type::getInt32Ty(Context)) |
| + return Error("Invalid EXTRACTELEMENT index type"); |
| + |
| + I = ExtractElementInst::Create(Vec, Idx); |
| + break; |
| + } |
| + |
| + case naclbitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [ty, opval,opval,opval] |
|
Karl
2014/04/02 15:56:22
Same here.
Also, why does the comment have 4 valu
JF
2014/04/02 18:37:12
Ditto.
|
| + unsigned OpNum = 0; |
| + Value *Vec, *Elt, *Idx; |
| + if (popValue(Record, &OpNum, NextValueNo, &Vec) || |
| + popValue(Record, &OpNum, NextValueNo, &Elt) || |
| + popValue(Record, &OpNum, NextValueNo, &Idx)) |
| + return Error("Invalid INSERTELEMENT record"); |
| + |
| + // expect vector type |
| + if (!isa<VectorType>(Vec->getType())) |
| + return Error("Invalid INSERTELEMENT vector type"); |
| + // match vector and element types |
| + if (cast<VectorType>(Vec->getType())->getElementType() != Elt->getType()) |
| + return Error("Mismatched INSERTELEMENT vector and element type"); |
| + // expect i32 |
| + if (Idx->getType() != Type::getInt32Ty(Context)) |
| + return Error("Invalid INSERTELEMENT index type"); |
| + |
| + I = InsertElementInst::Create(Vec, Elt, Idx); |
| + break; |
| + } |
| + |
| case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opval, opval, pred] |
| // FCmp/ICmp returning bool or vector of bool |