Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(218)

Side by Side Diff: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp

Issue 221693002: PNaCl: Add support for GCC/LLVM vector extensions (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Address dschuff's comments. Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 break; 362 break;
363 } 363 }
364 364
365 ResultTy = getTypeByID(Record[1]); 365 ResultTy = getTypeByID(Record[1]);
366 if (ResultTy == 0 || ArgTys.size() < Record.size()-2) 366 if (ResultTy == 0 || ArgTys.size() < Record.size()-2)
367 return Error("invalid type in function type"); 367 return Error("invalid type in function type");
368 368
369 ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]); 369 ResultTy = FunctionType::get(ResultTy, ArgTys, Record[0]);
370 break; 370 break;
371 } 371 }
372 case naclbitc::TYPE_CODE_VECTOR: { // VECTOR: [numelts, eltty]
373 if (Record.size() != 2)
374 return Error("Invalid VECTOR type record");
375 if ((ResultTy = getTypeByID(Record[1])))
376 ResultTy = VectorType::get(ResultTy, Record[0]);
377 else
378 return Error("invalid type in vector type");
379 break;
380 }
372 } 381 }
373 382
374 if (NumRecords >= TypeList.size()) 383 if (NumRecords >= TypeList.size())
375 return Error("invalid TYPE table"); 384 return Error("invalid TYPE table");
376 assert(ResultTy && "Didn't read a type?"); 385 assert(ResultTy && "Didn't read a type?");
377 assert(TypeList[NumRecords] == 0 && "Already read type?"); 386 assert(TypeList[NumRecords] == 0 && "Already read type?");
378 TypeList[NumRecords++] = ResultTy; 387 TypeList[NumRecords++] = ResultTy;
379 } 388 }
380 } 389 }
381 390
(...skipping 769 matching lines...) Expand 10 before | Expand all | Expand 10 after
1151 FalseVal = ConvertOpToScalar(FalseVal, CurBBNo); 1160 FalseVal = ConvertOpToScalar(FalseVal, CurBBNo);
1152 1161
1153 // expect i1 1162 // expect i1
1154 if (Cond->getType() != Type::getInt1Ty(Context)) 1163 if (Cond->getType() != Type::getInt1Ty(Context))
1155 return Error("Invalid SELECT condition type"); 1164 return Error("Invalid SELECT condition type");
1156 1165
1157 I = SelectInst::Create(Cond, TrueVal, FalseVal); 1166 I = SelectInst::Create(Cond, TrueVal, FalseVal);
1158 break; 1167 break;
1159 } 1168 }
1160 1169
1170 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { // EXTRACTELT: [opval, opval]
1171 unsigned OpNum = 0;
1172 Value *Vec, *Idx;
1173 if (popValue(Record, &OpNum, NextValueNo, &Vec) ||
1174 popValue(Record, &OpNum, NextValueNo, &Idx) || OpNum != Record.size())
1175 return Error("Invalid EXTRACTELEMENT record");
1176
1177 // expect i32
1178 if (Idx->getType() != Type::getInt32Ty(Context))
1179 return Error("Invalid EXTRACTELEMENT index type");
1180
1181 I = ExtractElementInst::Create(Vec, Idx);
1182 break;
1183 }
1184
1185 case naclbitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [opval,opval,opval]
1186 unsigned OpNum = 0;
1187 Value *Vec, *Elt, *Idx;
1188 if (popValue(Record, &OpNum, NextValueNo, &Vec) ||
1189 popValue(Record, &OpNum, NextValueNo, &Elt) ||
1190 popValue(Record, &OpNum, NextValueNo, &Idx) || OpNum != Record.size())
1191 return Error("Invalid INSERTELEMENT record");
1192
1193 // expect vector type
1194 if (!isa<VectorType>(Vec->getType()))
1195 return Error("Invalid INSERTELEMENT vector type");
1196 // match vector and element types
1197 if (cast<VectorType>(Vec->getType())->getElementType() != Elt->getType())
1198 return Error("Mismatched INSERTELEMENT vector and element type");
1199 // expect i32
1200 if (Idx->getType() != Type::getInt32Ty(Context))
1201 return Error("Invalid INSERTELEMENT index type");
1202
1203 I = InsertElementInst::Create(Vec, Elt, Idx);
1204 break;
1205 }
1206
1161 case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opval, opval, pred] 1207 case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opval, opval, pred]
1162 // FCmp/ICmp returning bool or vector of bool 1208 // FCmp/ICmp returning bool or vector of bool
1163 1209
1164 unsigned OpNum = 0; 1210 unsigned OpNum = 0;
1165 Value *LHS, *RHS; 1211 Value *LHS, *RHS;
1166 if (popValue(Record, &OpNum, NextValueNo, &LHS) || 1212 if (popValue(Record, &OpNum, NextValueNo, &LHS) ||
1167 popValue(Record, &OpNum, NextValueNo, &RHS) || 1213 popValue(Record, &OpNum, NextValueNo, &RHS) ||
1168 OpNum+1 != Record.size()) 1214 OpNum+1 != Record.size())
1169 return Error("Invalid CMP record"); 1215 return Error("Invalid CMP record");
1170 1216
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 if (M->MaterializeAllPermanently(ErrMsg)) { 1742 if (M->MaterializeAllPermanently(ErrMsg)) {
1697 delete M; 1743 delete M;
1698 return 0; 1744 return 0;
1699 } 1745 }
1700 1746
1701 // TODO: Restore the use-lists to the in-memory state when the bitcode was 1747 // TODO: Restore the use-lists to the in-memory state when the bitcode was
1702 // written. We must defer until the Module has been fully materialized. 1748 // written. We must defer until the Module has been fully materialized.
1703 1749
1704 return M; 1750 return M;
1705 } 1751 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698