- GenericValue Result;
-
- if (TD.isLittleEndian()) {
- switch (I.getType()->getPrimitiveID()) {
- case Type::BoolTyID:
- case Type::UByteTyID:
- case Type::SByteTyID: Result.UByteVal = Ptr->Untyped[0]; break;
- case Type::UShortTyID:
- case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[0] |
- ((unsigned)Ptr->Untyped[1] << 8);
- break;
- case Type::FloatTyID:
- case Type::UIntTyID:
- case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[0] |
- ((unsigned)Ptr->Untyped[1] << 8) |
- ((unsigned)Ptr->Untyped[2] << 16) |
- ((unsigned)Ptr->Untyped[3] << 24);
- break;
- case Type::DoubleTyID:
- case Type::ULongTyID:
- case Type::LongTyID:
- case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[0] |
- ((uint64_t)Ptr->Untyped[1] << 8) |
- ((uint64_t)Ptr->Untyped[2] << 16) |
- ((uint64_t)Ptr->Untyped[3] << 24) |
- ((uint64_t)Ptr->Untyped[4] << 32) |
- ((uint64_t)Ptr->Untyped[5] << 40) |
- ((uint64_t)Ptr->Untyped[6] << 48) |
- ((uint64_t)Ptr->Untyped[7] << 56);
- break;
- default:
- cout << "Cannot load value of type " << I.getType() << "!\n";
- }
- } else {
- switch (I.getType()->getPrimitiveID()) {
- case Type::BoolTyID:
- case Type::UByteTyID:
- case Type::SByteTyID: Result.UByteVal = Ptr->Untyped[0]; break;
- case Type::UShortTyID:
- case Type::ShortTyID: Result.UShortVal = (unsigned)Ptr->Untyped[1] |
- ((unsigned)Ptr->Untyped[0] << 8);
- break;
- case Type::FloatTyID:
- case Type::UIntTyID:
- case Type::IntTyID: Result.UIntVal = (unsigned)Ptr->Untyped[3] |
- ((unsigned)Ptr->Untyped[2] << 8) |
- ((unsigned)Ptr->Untyped[1] << 16) |
- ((unsigned)Ptr->Untyped[0] << 24);
- break;
- case Type::DoubleTyID:
- case Type::ULongTyID:
- case Type::LongTyID:
- case Type::PointerTyID: Result.ULongVal = (uint64_t)Ptr->Untyped[7] |
- ((uint64_t)Ptr->Untyped[6] << 8) |
- ((uint64_t)Ptr->Untyped[5] << 16) |
- ((uint64_t)Ptr->Untyped[4] << 24) |
- ((uint64_t)Ptr->Untyped[3] << 32) |
- ((uint64_t)Ptr->Untyped[2] << 40) |
- ((uint64_t)Ptr->Untyped[1] << 48) |
- ((uint64_t)Ptr->Untyped[0] << 56);
- break;
- default:
- cout << "Cannot load value of type " << I.getType() << "!\n";
- }
- }
-