mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-25 13:24:46 +00:00
Implement loading and storing of APInt values from memory.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34874 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -425,7 +425,7 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
|
|||||||
else if (BitWidth <= 64)
|
else if (BitWidth <= 64)
|
||||||
Result.Int64Val = (uint64_t )cast<ConstantInt>(C)->getZExtValue();
|
Result.Int64Val = (uint64_t )cast<ConstantInt>(C)->getZExtValue();
|
||||||
else
|
else
|
||||||
assert(0 && "Integers with > 64-bits not implemented");
|
Result.APIntVal = const_cast<APInt*>(&cast<ConstantInt>(C)->getValue());
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -481,8 +481,12 @@ void ExecutionEngine::StoreValueToMemory(GenericValue Val, GenericValue *Ptr,
|
|||||||
Ptr->Untyped[5] = (unsigned char)(TmpVal.Int64Val >> 40);
|
Ptr->Untyped[5] = (unsigned char)(TmpVal.Int64Val >> 40);
|
||||||
Ptr->Untyped[6] = (unsigned char)(TmpVal.Int64Val >> 48);
|
Ptr->Untyped[6] = (unsigned char)(TmpVal.Int64Val >> 48);
|
||||||
Ptr->Untyped[7] = (unsigned char)(TmpVal.Int64Val >> 56);
|
Ptr->Untyped[7] = (unsigned char)(TmpVal.Int64Val >> 56);
|
||||||
} else
|
} else {
|
||||||
assert(0 && "Integer types > 64 bits not supported");
|
uint64_t *Dest = (uint64_t*)Ptr;
|
||||||
|
const uint64_t *Src = Val.APIntVal->getRawData();
|
||||||
|
for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
|
||||||
|
Dest[i] = Src[i];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Store4BytesLittleEndian:
|
Store4BytesLittleEndian:
|
||||||
@@ -537,8 +541,12 @@ Store4BytesLittleEndian:
|
|||||||
Ptr->Untyped[2] = (unsigned char)(TmpVal.Int64Val >> 40);
|
Ptr->Untyped[2] = (unsigned char)(TmpVal.Int64Val >> 40);
|
||||||
Ptr->Untyped[1] = (unsigned char)(TmpVal.Int64Val >> 48);
|
Ptr->Untyped[1] = (unsigned char)(TmpVal.Int64Val >> 48);
|
||||||
Ptr->Untyped[0] = (unsigned char)(TmpVal.Int64Val >> 56);
|
Ptr->Untyped[0] = (unsigned char)(TmpVal.Int64Val >> 56);
|
||||||
} else
|
} else {
|
||||||
assert(0 && "Integer types > 64 bits not supported");
|
uint64_t *Dest = (uint64_t*)Ptr;
|
||||||
|
const uint64_t *Src = Val.APIntVal->getRawData();
|
||||||
|
for (uint32_t i = 0; i < Val.APIntVal->getNumWords(); ++i)
|
||||||
|
Dest[i] = Src[i];
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Store4BytesBigEndian:
|
Store4BytesBigEndian:
|
||||||
@@ -597,7 +605,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
|||||||
((uint64_t)Ptr->Untyped[6] << 48) |
|
((uint64_t)Ptr->Untyped[6] << 48) |
|
||||||
((uint64_t)Ptr->Untyped[7] << 56);
|
((uint64_t)Ptr->Untyped[7] << 56);
|
||||||
} else
|
} else
|
||||||
assert(0 && "Integer types > 64 bits not supported");
|
Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Load4BytesLittleEndian:
|
Load4BytesLittleEndian:
|
||||||
@@ -628,7 +636,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
|||||||
} else {
|
} else {
|
||||||
switch (Ty->getTypeID()) {
|
switch (Ty->getTypeID()) {
|
||||||
case Type::IntegerTyID: {
|
case Type::IntegerTyID: {
|
||||||
unsigned BitWidth = cast<IntegerType>(Ty)->getBitWidth();
|
uint32_t BitWidth = cast<IntegerType>(Ty)->getBitWidth();
|
||||||
if (BitWidth <= 8)
|
if (BitWidth <= 8)
|
||||||
Result.Int8Val = Ptr->Untyped[0];
|
Result.Int8Val = Ptr->Untyped[0];
|
||||||
else if (BitWidth <= 16) {
|
else if (BitWidth <= 16) {
|
||||||
@@ -649,7 +657,7 @@ GenericValue ExecutionEngine::LoadValueFromMemory(GenericValue *Ptr,
|
|||||||
((uint64_t)Ptr->Untyped[1] << 48) |
|
((uint64_t)Ptr->Untyped[1] << 48) |
|
||||||
((uint64_t)Ptr->Untyped[0] << 56);
|
((uint64_t)Ptr->Untyped[0] << 56);
|
||||||
} else
|
} else
|
||||||
assert(0 && "Integer types > 64 bits not supported");
|
Result.APIntVal = new APInt(BitWidth, BitWidth/64, (uint64_t*)Ptr);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Load4BytesBigEndian:
|
Load4BytesBigEndian:
|
||||||
|
Reference in New Issue
Block a user