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 1174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Ice::Type CondType = CondVal->getType(); |
| 1211 if (isVectorType(CondType)) { |
| 1212 if (!isVectorType(ThenType) || |
| 1213 typeElementType(CondType) != Ice::IceType_i1 || |
| 1214 typeNumElements(ThenType) != typeNumElements(CondType)) { |
| 1215 std::string Buffer; |
| 1216 raw_string_ostream StrBuf(Buffer); |
| 1217 StrBuf << "Select condition " << CondType |
| 1218 << " not allowed for values of type " << ThenType; |
| 1219 Error(StrBuf.str()); |
| 1220 return; |
| 1221 } |
| 1222 } else if (CondVal->getType() != Ice::IceType_i1) { |
| 1223 std::string Buffer; |
| 1224 raw_string_ostream StrBuf(Buffer); |
| 1225 StrBuf << "Select condition not type i1. Found: " << CondVal->getType(); |
| 1226 Error(StrBuf.str()); |
| 1227 return; |
| 1228 } |
| 1229 Ice::Variable *DestVal = NextInstVar(ThenType); |
| 1230 Inst = Ice::InstSelect::create(Func, DestVal, CondVal, ThenVal, ElseVal); |
| 1231 break; |
| 1232 } |
1195 case naclbitc::FUNC_CODE_INST_RET: { | 1233 case naclbitc::FUNC_CODE_INST_RET: { |
1196 // RET: [opval?] | 1234 // RET: [opval?] |
1197 InstIsTerminating = true; | 1235 InstIsTerminating = true; |
1198 if (!isValidRecordSizeInRange(0, 1, "function block ret")) | 1236 if (!isValidRecordSizeInRange(0, 1, "function block ret")) |
1199 return; | 1237 return; |
1200 if (Values.size() == 0) { | 1238 if (Values.size() == 0) { |
1201 Inst = Ice::InstRet::create(Func); | 1239 Inst = Ice::InstRet::create(Func); |
1202 } else { | 1240 } else { |
1203 Inst = Ice::InstRet::create( | 1241 Inst = Ice::InstRet::create( |
1204 Func, getOperand(convertRelativeToAbsIndex(Values[0]))); | 1242 Func, getOperand(convertRelativeToAbsIndex(Values[0]))); |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1372 if (TopLevelBlocks != 1) { | 1410 if (TopLevelBlocks != 1) { |
1373 errs() << IRFilename | 1411 errs() << IRFilename |
1374 << ": Contains more than one module. Found: " << TopLevelBlocks | 1412 << ": Contains more than one module. Found: " << TopLevelBlocks |
1375 << "\n"; | 1413 << "\n"; |
1376 ErrorStatus = true; | 1414 ErrorStatus = true; |
1377 } | 1415 } |
1378 return; | 1416 return; |
1379 } | 1417 } |
1380 | 1418 |
1381 } // end of namespace Ice | 1419 } // end of namespace Ice |
OLD | NEW |