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

Side by Side Diff: src/PNaClTranslator.cpp

Issue 531123002: Add select instruction to Subzero bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « no previous file | tests_lit/reader_tests/select.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===// 1 //===- subzero/src/PNaClTranslator.cpp - ICE from bitcode -----------------===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file implements the PNaCl bitcode file to Ice, to machine code 10 // This file implements the PNaCl bitcode file to Ice, to machine code
(...skipping 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after
1185 raw_string_ostream StrBuf(Buffer); 1185 raw_string_ostream StrBuf(Buffer);
1186 StrBuf << "Illegal cast: " << Instruction::getOpcodeName(LLVMCastOp) 1186 StrBuf << "Illegal cast: " << Instruction::getOpcodeName(LLVMCastOp)
1187 << " " << *SrcType << " to " << *CastType; 1187 << " " << *SrcType << " to " << *CastType;
1188 Error(StrBuf.str()); 1188 Error(StrBuf.str());
1189 return; 1189 return;
1190 } 1190 }
1191 Ice::Variable *Dest = NextInstVar(Context->convertToIceType(CastType)); 1191 Ice::Variable *Dest = NextInstVar(Context->convertToIceType(CastType));
1192 Inst = Ice::InstCast::create(Func, CastKind, Dest, Src); 1192 Inst = Ice::InstCast::create(Func, CastKind, Dest, Src);
1193 break; 1193 break;
1194 } 1194 }
1195 case naclbitc::FUNC_CODE_INST_VSELECT: {
1196 // VSELECT: [opval, opval, pred]
1197 Ice::Operand *ThenVal = getOperand(convertRelativeToAbsIndex(Values[0]));
1198 Ice::Type ThenType = ThenVal->getType();
1199 Ice::Operand *ElseVal = getOperand(convertRelativeToAbsIndex(Values[1]));
1200 Ice::Type ElseType = ElseVal->getType();
1201 if (ThenType != ElseType) {
1202 std::string Buffer;
1203 raw_string_ostream StrBuf(Buffer);
1204 StrBuf << "Select operands not same type. Found " << ThenType << " and "
1205 << ElseType;
1206 Error(StrBuf.str());
1207 return;
1208 }
1209 Ice::Operand *CondVal = getOperand(convertRelativeToAbsIndex(Values[2]));
1210 if (CondVal->getType() != Ice::IceType_i1) {
Jim Stichnoth 2014/09/02 19:38:49 The predicate can also be a vector of i1 (and the
Karl 2014/09/02 22:20:25 Done.
1211 std::string Buffer;
1212 raw_string_ostream StrBuf(Buffer);
1213 StrBuf << "Select condition not type i1. Found: " << CondVal->getType();
1214 Error(StrBuf.str());
1215 return;
1216 }
1217 Ice::Variable *DestVal = NextInstVar(ThenType);
1218 Inst = Ice::InstSelect::create(Func, DestVal, CondVal, ThenVal, ElseVal);
1219 break;
1220 }
1195 case naclbitc::FUNC_CODE_INST_RET: { 1221 case naclbitc::FUNC_CODE_INST_RET: {
1196 // RET: [opval?] 1222 // RET: [opval?]
1197 InstIsTerminating = true; 1223 InstIsTerminating = true;
1198 if (!isValidRecordSizeInRange(0, 1, "function block ret")) 1224 if (!isValidRecordSizeInRange(0, 1, "function block ret"))
1199 return; 1225 return;
1200 if (Values.size() == 0) { 1226 if (Values.size() == 0) {
1201 Inst = Ice::InstRet::create(Func); 1227 Inst = Ice::InstRet::create(Func);
1202 } else { 1228 } else {
1203 Inst = Ice::InstRet::create( 1229 Inst = Ice::InstRet::create(
1204 Func, getOperand(convertRelativeToAbsIndex(Values[0]))); 1230 Func, getOperand(convertRelativeToAbsIndex(Values[0])));
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
1372 if (TopLevelBlocks != 1) { 1398 if (TopLevelBlocks != 1) {
1373 errs() << IRFilename 1399 errs() << IRFilename
1374 << ": Contains more than one module. Found: " << TopLevelBlocks 1400 << ": Contains more than one module. Found: " << TopLevelBlocks
1375 << "\n"; 1401 << "\n";
1376 ErrorStatus = true; 1402 ErrorStatus = true;
1377 } 1403 }
1378 return; 1404 return;
1379 } 1405 }
1380 1406
1381 } // end of namespace Ice 1407 } // end of namespace Ice
OLDNEW
« no previous file with comments | « no previous file | tests_lit/reader_tests/select.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698