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

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: Remove TODOs that were done. 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: [opty, opval, opv al]
Jim Stichnoth 2014/04/04 23:08:17 line longer than 80 chars...
jvoung (off chromium) 2014/04/04 23:20:21 no opty?
JF 2014/04/15 01:52:27 jvoung's comment made it go under 80, I nonetheles
JF 2014/04/15 01:52:27 Done.
1171 unsigned OpNum = 0;
1172 Value *Vec, *Idx;
1173 if (popValue(Record, &OpNum, NextValueNo, &Vec) ||
1174 popValue(Record, &OpNum, NextValueNo, &Idx) ||
1175 OpNum != Record.size())
1176 return Error("Invalid EXTRACTELEMENT record");
1177
1178 // expect i32
1179 if (Idx->getType() != Type::getInt32Ty(Context))
1180 return Error("Invalid EXTRACTELEMENT index type");
1181
1182 I = ExtractElementInst::Create(Vec, Idx);
1183 break;
1184 }
1185
1186 case naclbitc::FUNC_CODE_INST_INSERTELT: { // INSERTELT: [opval,opval,opval]
1187 unsigned OpNum = 0;
1188 Value *Vec, *Elt, *Idx;
1189 if (popValue(Record, &OpNum, NextValueNo, &Vec) ||
1190 popValue(Record, &OpNum, NextValueNo, &Elt) ||
1191 popValue(Record, &OpNum, NextValueNo, &Idx) ||
1192 OpNum != Record.size())
1193 return Error("Invalid INSERTELEMENT record");
1194
1195 // expect vector type
1196 if (!isa<VectorType>(Vec->getType()))
1197 return Error("Invalid INSERTELEMENT vector type");
1198 // match vector and element types
1199 if (cast<VectorType>(Vec->getType())->getElementType() != Elt->getType())
1200 return Error("Mismatched INSERTELEMENT vector and element type");
1201 // expect i32
1202 if (Idx->getType() != Type::getInt32Ty(Context))
1203 return Error("Invalid INSERTELEMENT index type");
1204
1205 I = InsertElementInst::Create(Vec, Elt, Idx);
1206 break;
1207 }
1208
1161 case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opval, opval, pred] 1209 case naclbitc::FUNC_CODE_INST_CMP2: { // CMP2: [opval, opval, pred]
1162 // FCmp/ICmp returning bool or vector of bool 1210 // FCmp/ICmp returning bool or vector of bool
1163 1211
1164 unsigned OpNum = 0; 1212 unsigned OpNum = 0;
1165 Value *LHS, *RHS; 1213 Value *LHS, *RHS;
1166 if (popValue(Record, &OpNum, NextValueNo, &LHS) || 1214 if (popValue(Record, &OpNum, NextValueNo, &LHS) ||
1167 popValue(Record, &OpNum, NextValueNo, &RHS) || 1215 popValue(Record, &OpNum, NextValueNo, &RHS) ||
1168 OpNum+1 != Record.size()) 1216 OpNum+1 != Record.size())
1169 return Error("Invalid CMP record"); 1217 return Error("Invalid CMP record");
1170 1218
(...skipping 525 matching lines...) Expand 10 before | Expand all | Expand 10 after
1696 if (M->MaterializeAllPermanently(ErrMsg)) { 1744 if (M->MaterializeAllPermanently(ErrMsg)) {
1697 delete M; 1745 delete M;
1698 return 0; 1746 return 0;
1699 } 1747 }
1700 1748
1701 // TODO: Restore the use-lists to the in-memory state when the bitcode was 1749 // 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. 1750 // written. We must defer until the Module has been fully materialized.
1703 1751
1704 return M; 1752 return M;
1705 } 1753 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698