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 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
318 } else { | 318 } else { |
319 std::string Buffer; | 319 std::string Buffer; |
320 raw_string_ostream StrBuf(Buffer); | 320 raw_string_ostream StrBuf(Buffer); |
321 StrBuf << "Reference to global not defined: " << ID; | 321 StrBuf << "Reference to global not defined: " << ID; |
322 Error(StrBuf.str()); | 322 Error(StrBuf.str()); |
323 // TODO(kschimpf) Remove error recovery once implementation complete. | 323 // TODO(kschimpf) Remove error recovery once implementation complete. |
324 Name = "??"; | 324 Name = "??"; |
325 SuppressMangling = false; | 325 SuppressMangling = false; |
326 } | 326 } |
327 const Ice::RelocOffsetT Offset = 0; | 327 const Ice::RelocOffsetT Offset = 0; |
328 C = getTranslator().getContext()->getConstantSym( | 328 C = getTranslator().getContext()->getConstantSym(Offset, Name, |
329 getIcePointerType(), Offset, Name, SuppressMangling); | 329 SuppressMangling); |
330 ValueIDConstants[ID] = C; | 330 ValueIDConstants[ID] = C; |
331 return C; | 331 return C; |
332 } | 332 } |
333 | 333 |
334 /// Returns the number of function declarations in the bitcode file. | 334 /// Returns the number of function declarations in the bitcode file. |
335 unsigned getNumFunctionIDs() const { return NumFunctionIds; } | 335 unsigned getNumFunctionIDs() const { return NumFunctionIds; } |
336 | 336 |
337 /// Returns the number of global declarations (i.e. IDs) defined in | 337 /// Returns the number of global declarations (i.e. IDs) defined in |
338 /// the bitcode file. | 338 /// the bitcode file. |
339 unsigned getNumGlobalIDs() const { | 339 unsigned getNumGlobalIDs() const { |
(...skipping 1093 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1433 // Returns whether the given vector index (for insertelement and | 1433 // Returns whether the given vector index (for insertelement and |
1434 // extractelement instructions) is valid. | 1434 // extractelement instructions) is valid. |
1435 VectorIndexCheckValue validateVectorIndex(const Ice::Operand *Vec, | 1435 VectorIndexCheckValue validateVectorIndex(const Ice::Operand *Vec, |
1436 const Ice::Operand *Index) const { | 1436 const Ice::Operand *Index) const { |
1437 Ice::Type VecType = Vec->getType(); | 1437 Ice::Type VecType = Vec->getType(); |
1438 if (!Ice::isVectorType(VecType)) | 1438 if (!Ice::isVectorType(VecType)) |
1439 return VectorIndexNotVector; | 1439 return VectorIndexNotVector; |
1440 const auto *C = dyn_cast<Ice::ConstantInteger32>(Index); | 1440 const auto *C = dyn_cast<Ice::ConstantInteger32>(Index); |
1441 if (C == nullptr) | 1441 if (C == nullptr) |
1442 return VectorIndexNotConstant; | 1442 return VectorIndexNotConstant; |
1443 if (C->getValue() >= typeNumElements(VecType)) | 1443 if (static_cast<size_t>(C->getValue()) >= typeNumElements(VecType)) |
1444 return VectorIndexNotInRange; | 1444 return VectorIndexNotInRange; |
1445 if (Index->getType() != Ice::IceType_i32) | 1445 if (Index->getType() != Ice::IceType_i32) |
1446 return VectorIndexNotI32; | 1446 return VectorIndexNotI32; |
1447 return VectorIndexValid; | 1447 return VectorIndexValid; |
1448 } | 1448 } |
1449 | 1449 |
1450 // Reports that the given binary Opcode, for the given type Ty, | 1450 // Reports that the given binary Opcode, for the given type Ty, |
1451 // is not understood. | 1451 // is not understood. |
1452 void ReportInvalidBinopOpcode(unsigned Opcode, Ice::Type Ty); | 1452 void ReportInvalidBinopOpcode(unsigned Opcode, Ice::Type Ty); |
1453 | 1453 |
(...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2492 return; | 2492 return; |
2493 if (!isValidNextConstantType()) | 2493 if (!isValidNextConstantType()) |
2494 return; | 2494 return; |
2495 if (isIRGenerationDisabled()) { | 2495 if (isIRGenerationDisabled()) { |
2496 FuncParser->setNextConstantID(nullptr); | 2496 FuncParser->setNextConstantID(nullptr); |
2497 return; | 2497 return; |
2498 } | 2498 } |
2499 if (IntegerType *IType = dyn_cast<IntegerType>( | 2499 if (IntegerType *IType = dyn_cast<IntegerType>( |
2500 Context->convertToLLVMType(NextConstantType))) { | 2500 Context->convertToLLVMType(NextConstantType))) { |
2501 APInt Value(IType->getBitWidth(), NaClDecodeSignRotatedValue(Values[0])); | 2501 APInt Value(IType->getBitWidth(), NaClDecodeSignRotatedValue(Values[0])); |
2502 Ice::Constant *C = (NextConstantType == Ice::IceType_i64) | 2502 Ice::Constant *C = nullptr; |
Karl
2014/11/20 17:43:39
Why not:
if (auto C = getContext->getConstantInt(
Jim Stichnoth
2014/11/20 19:04:58
Good point, done.
| |
2503 ? getContext()->getConstantInt64( | 2503 C = getContext()->getConstantInt(NextConstantType, Value.getSExtValue()); |
2504 NextConstantType, Value.getSExtValue()) | 2504 if (C) { |
2505 : getContext()->getConstantInt32( | 2505 FuncParser->setNextConstantID(C); |
2506 NextConstantType, Value.getSExtValue()); | 2506 return; |
2507 FuncParser->setNextConstantID(C); | 2507 } |
2508 return; | |
2509 } | 2508 } |
2510 std::string Buffer; | 2509 std::string Buffer; |
2511 raw_string_ostream StrBuf(Buffer); | 2510 raw_string_ostream StrBuf(Buffer); |
2512 StrBuf << "constant block integer record for non-integer type " | 2511 StrBuf << "constant block integer record for non-integer type " |
2513 << NextConstantType; | 2512 << NextConstantType; |
2514 Error(StrBuf.str()); | 2513 Error(StrBuf.str()); |
2515 return; | 2514 return; |
2516 } | 2515 } |
2517 case naclbitc::CST_CODE_FLOAT: { | 2516 case naclbitc::CST_CODE_FLOAT: { |
2518 // FLOAT: [fpval] | 2517 // FLOAT: [fpval] |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2872 | 2871 |
2873 if (TopLevelBlocks != 1) { | 2872 if (TopLevelBlocks != 1) { |
2874 errs() << IRFilename | 2873 errs() << IRFilename |
2875 << ": Contains more than one module. Found: " << TopLevelBlocks | 2874 << ": Contains more than one module. Found: " << TopLevelBlocks |
2876 << "\n"; | 2875 << "\n"; |
2877 ErrorStatus = true; | 2876 ErrorStatus = true; |
2878 } | 2877 } |
2879 } | 2878 } |
2880 | 2879 |
2881 } // end of namespace Ice | 2880 } // end of namespace Ice |
OLD | NEW |