OLD | NEW |
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 1180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1191 raw_string_ostream StrBuf(Buffer); | 1191 raw_string_ostream StrBuf(Buffer); |
1192 StrBuf << "Illegal cast: " << Instruction::getOpcodeName(LLVMCastOp) | 1192 StrBuf << "Illegal cast: " << Instruction::getOpcodeName(LLVMCastOp) |
1193 << " " << *SrcType << " to " << *CastType; | 1193 << " " << *SrcType << " to " << *CastType; |
1194 Error(StrBuf.str()); | 1194 Error(StrBuf.str()); |
1195 return; | 1195 return; |
1196 } | 1196 } |
1197 Ice::Variable *Dest = NextInstVar(Context->convertToIceType(CastType)); | 1197 Ice::Variable *Dest = NextInstVar(Context->convertToIceType(CastType)); |
1198 Inst = Ice::InstCast::create(Func, CastKind, Dest, Src); | 1198 Inst = Ice::InstCast::create(Func, CastKind, Dest, Src); |
1199 break; | 1199 break; |
1200 } | 1200 } |
| 1201 case naclbitc::FUNC_CODE_INST_VSELECT: { |
| 1202 // VSELECT: [opval, opval, pred] |
| 1203 Ice::Operand *ThenVal = getOperand(convertRelativeToAbsIndex(Values[0])); |
| 1204 Ice::Type ThenType = ThenVal->getType(); |
| 1205 Ice::Operand *ElseVal = getOperand(convertRelativeToAbsIndex(Values[1])); |
| 1206 Ice::Type ElseType = ElseVal->getType(); |
| 1207 if (ThenType != ElseType) { |
| 1208 std::string Buffer; |
| 1209 raw_string_ostream StrBuf(Buffer); |
| 1210 StrBuf << "Select operands not same type. Found " << ThenType << " and " |
| 1211 << ElseType; |
| 1212 Error(StrBuf.str()); |
| 1213 return; |
| 1214 } |
| 1215 Ice::Operand *CondVal = getOperand(convertRelativeToAbsIndex(Values[2])); |
| 1216 Ice::Type CondType = CondVal->getType(); |
| 1217 if (isVectorType(CondType)) { |
| 1218 if (!isVectorType(ThenType) || |
| 1219 typeElementType(CondType) != Ice::IceType_i1 || |
| 1220 typeNumElements(ThenType) != typeNumElements(CondType)) { |
| 1221 std::string Buffer; |
| 1222 raw_string_ostream StrBuf(Buffer); |
| 1223 StrBuf << "Select condition " << CondType |
| 1224 << " not allowed for values of type " << ThenType; |
| 1225 Error(StrBuf.str()); |
| 1226 return; |
| 1227 } |
| 1228 } else if (CondVal->getType() != Ice::IceType_i1) { |
| 1229 std::string Buffer; |
| 1230 raw_string_ostream StrBuf(Buffer); |
| 1231 StrBuf << "Select condition not type i1. Found: " << CondVal->getType(); |
| 1232 Error(StrBuf.str()); |
| 1233 return; |
| 1234 } |
| 1235 Ice::Variable *DestVal = NextInstVar(ThenType); |
| 1236 Inst = Ice::InstSelect::create(Func, DestVal, CondVal, ThenVal, ElseVal); |
| 1237 break; |
| 1238 } |
1201 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { | 1239 case naclbitc::FUNC_CODE_INST_EXTRACTELT: { |
1202 // EXTRACTELT: [opval, opval] | 1240 // EXTRACTELT: [opval, opval] |
1203 Ice::Operand *Vec = getRelativeOperand(Values[0]); | 1241 Ice::Operand *Vec = getRelativeOperand(Values[0]); |
1204 Ice::Type VecType = Vec->getType(); | 1242 Ice::Type VecType = Vec->getType(); |
1205 if (!Ice::isVectorType(VecType)) { | 1243 if (!Ice::isVectorType(VecType)) { |
1206 std::string Buffer; | 1244 std::string Buffer; |
1207 raw_string_ostream StrBuf(Buffer); | 1245 raw_string_ostream StrBuf(Buffer); |
1208 StrBuf << "Extractelement not on vector. Found: " << Vec; | 1246 StrBuf << "Extractelement not on vector. Found: " << Vec; |
1209 Error(StrBuf.str()); | 1247 Error(StrBuf.str()); |
1210 } | 1248 } |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1432 if (TopLevelBlocks != 1) { | 1470 if (TopLevelBlocks != 1) { |
1433 errs() << IRFilename | 1471 errs() << IRFilename |
1434 << ": Contains more than one module. Found: " << TopLevelBlocks | 1472 << ": Contains more than one module. Found: " << TopLevelBlocks |
1435 << "\n"; | 1473 << "\n"; |
1436 ErrorStatus = true; | 1474 ErrorStatus = true; |
1437 } | 1475 } |
1438 return; | 1476 return; |
1439 } | 1477 } |
1440 | 1478 |
1441 } // end of namespace Ice | 1479 } // end of namespace Ice |
OLD | NEW |