Chromium Code Reviews| 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; |
| 2503 ? getContext()->getConstantInt64( | 2503 switch (NextConstantType) { |
|
Karl
2014/11/19 18:45:28
Why not provide a helper function (in IceGlobalCon
Jim Stichnoth
2014/11/20 00:08:57
Done.
| |
| 2504 NextConstantType, Value.getSExtValue()) | 2504 default: |
| 2505 : getContext()->getConstantInt32( | 2505 assert(0); |
| 2506 NextConstantType, Value.getSExtValue()); | 2506 break; |
| 2507 FuncParser->setNextConstantID(C); | 2507 case Ice::IceType_i1: |
| 2508 return; | 2508 C = getContext()->getConstantInt1(Value.getSExtValue()); |
| 2509 break; | |
| 2510 case Ice::IceType_i8: | |
| 2511 C = getContext()->getConstantInt8(Value.getSExtValue()); | |
| 2512 break; | |
| 2513 case Ice::IceType_i16: | |
| 2514 C = getContext()->getConstantInt16(Value.getSExtValue()); | |
| 2515 break; | |
| 2516 case Ice::IceType_i32: | |
| 2517 C = getContext()->getConstantInt32(Value.getSExtValue()); | |
| 2518 break; | |
| 2519 case Ice::IceType_i64: | |
| 2520 C = getContext()->getConstantInt64(Value.getSExtValue()); | |
| 2521 break; | |
| 2522 } | |
| 2523 if (C) { | |
| 2524 FuncParser->setNextConstantID(C); | |
| 2525 return; | |
| 2526 } | |
| 2509 } | 2527 } |
| 2510 std::string Buffer; | 2528 std::string Buffer; |
| 2511 raw_string_ostream StrBuf(Buffer); | 2529 raw_string_ostream StrBuf(Buffer); |
| 2512 StrBuf << "constant block integer record for non-integer type " | 2530 StrBuf << "constant block integer record for non-integer type " |
| 2513 << NextConstantType; | 2531 << NextConstantType; |
| 2514 Error(StrBuf.str()); | 2532 Error(StrBuf.str()); |
| 2515 return; | 2533 return; |
| 2516 } | 2534 } |
| 2517 case naclbitc::CST_CODE_FLOAT: { | 2535 case naclbitc::CST_CODE_FLOAT: { |
| 2518 // FLOAT: [fpval] | 2536 // FLOAT: [fpval] |
| (...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2872 | 2890 |
| 2873 if (TopLevelBlocks != 1) { | 2891 if (TopLevelBlocks != 1) { |
| 2874 errs() << IRFilename | 2892 errs() << IRFilename |
| 2875 << ": Contains more than one module. Found: " << TopLevelBlocks | 2893 << ": Contains more than one module. Found: " << TopLevelBlocks |
| 2876 << "\n"; | 2894 << "\n"; |
| 2877 ErrorStatus = true; | 2895 ErrorStatus = true; |
| 2878 } | 2896 } |
| 2879 } | 2897 } |
| 2880 | 2898 |
| 2881 } // end of namespace Ice | 2899 } // end of namespace Ice |
| OLD | NEW |