OLD | NEW |
1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// | 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// |
2 // Internal NaClBitcodeReader implementation | 2 // Internal NaClBitcodeReader implementation |
3 // | 3 // |
4 // The LLVM Compiler Infrastructure | 4 // The LLVM Compiler Infrastructure |
5 // | 5 // |
6 // This file is distributed under the University of Illinois Open Source | 6 // This file is distributed under the University of Illinois Open Source |
7 // License. See LICENSE.TXT for details. | 7 // License. See LICENSE.TXT for details. |
8 // | 8 // |
9 //===----------------------------------------------------------------------===// | 9 //===----------------------------------------------------------------------===// |
10 | 10 |
(...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1165 Value *TrueVal, *FalseVal, *Cond; | 1165 Value *TrueVal, *FalseVal, *Cond; |
1166 if (popValue(Record, &OpNum, NextValueNo, &TrueVal) || | 1166 if (popValue(Record, &OpNum, NextValueNo, &TrueVal) || |
1167 popValue(Record, &OpNum, NextValueNo, &FalseVal) || | 1167 popValue(Record, &OpNum, NextValueNo, &FalseVal) || |
1168 popValue(Record, &OpNum, NextValueNo, &Cond) || | 1168 popValue(Record, &OpNum, NextValueNo, &Cond) || |
1169 OpNum != Record.size()) | 1169 OpNum != Record.size()) |
1170 return Error("Invalid SELECT record"); | 1170 return Error("Invalid SELECT record"); |
1171 | 1171 |
1172 TrueVal = ConvertOpToScalar(TrueVal, CurBBNo); | 1172 TrueVal = ConvertOpToScalar(TrueVal, CurBBNo); |
1173 FalseVal = ConvertOpToScalar(FalseVal, CurBBNo); | 1173 FalseVal = ConvertOpToScalar(FalseVal, CurBBNo); |
1174 | 1174 |
1175 // expect i1 | 1175 // select condition can be either i1 or [N x i1] |
1176 if (Cond->getType() != Type::getInt1Ty(Context)) | 1176 if (VectorType* vector_type = |
1177 return Error("Invalid SELECT condition type"); | 1177 dyn_cast<VectorType>(Cond->getType())) { |
| 1178 // expect <n x i1> |
| 1179 if (vector_type->getElementType() != Type::getInt1Ty(Context)) |
| 1180 return Error("Invalid SELECT vector condition type"); |
| 1181 } else { |
| 1182 // expect i1 |
| 1183 if (Cond->getType() != Type::getInt1Ty(Context)) |
| 1184 return Error("Invalid SELECT condition type"); |
| 1185 } |
1178 | 1186 |
1179 I = SelectInst::Create(Cond, TrueVal, FalseVal); | 1187 I = SelectInst::Create(Cond, TrueVal, FalseVal); |
1180 break; | 1188 break; |
1181 } | 1189 } |
1182 | 1190 |
1183 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opval, opval] | 1191 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opval, opval] |
1184 unsigned OpNum = 0; | 1192 unsigned OpNum = 0; |
1185 Value *Vec, *Idx; | 1193 Value *Vec, *Idx; |
1186 if (popValue(Record, &OpNum, NextValueNo, &Vec) || | 1194 if (popValue(Record, &OpNum, NextValueNo, &Vec) || |
1187 popValue(Record, &OpNum, NextValueNo, &Idx) || OpNum != Record.size()) | 1195 popValue(Record, &OpNum, NextValueNo, &Idx) || OpNum != Record.size()) |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1754 if (M->MaterializeAllPermanently(ErrMsg)) { | 1762 if (M->MaterializeAllPermanently(ErrMsg)) { |
1755 delete M; | 1763 delete M; |
1756 return 0; | 1764 return 0; |
1757 } | 1765 } |
1758 | 1766 |
1759 // TODO: Restore the use-lists to the in-memory state when the bitcode was | 1767 // TODO: Restore the use-lists to the in-memory state when the bitcode was |
1760 // written. We must defer until the Module has been fully materialized. | 1768 // written. We must defer until the Module has been fully materialized. |
1761 | 1769 |
1762 return M; | 1770 return M; |
1763 } | 1771 } |
OLD | NEW |