mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-09 12:02:21 +02:00
Fixing TryMemCpy
This commit is contained in:
parent
858cca5bec
commit
cdf5f3b03b
1 changed files with 8 additions and 7 deletions
|
@ -1051,8 +1051,6 @@ void BfIRCodeGen::AddNop()
|
||||||
|
|
||||||
bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
||||||
{
|
{
|
||||||
return false;
|
|
||||||
|
|
||||||
auto arrayType = llvm::dyn_cast<llvm::ArrayType>(val->getType());
|
auto arrayType = llvm::dyn_cast<llvm::ArrayType>(val->getType());
|
||||||
if (arrayType == NULL)
|
if (arrayType == NULL)
|
||||||
return false;
|
return false;
|
||||||
|
@ -1062,8 +1060,11 @@ bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto int8Ty = llvm::Type::getInt8Ty(*mLLVMContext);
|
auto int8Ty = llvm::Type::getInt8Ty(*mLLVMContext);
|
||||||
|
auto int32Ty = llvm::Type::getInt32Ty(*mLLVMContext);
|
||||||
auto int8PtrTy = int8Ty->getPointerTo();
|
auto int8PtrTy = int8Ty->getPointerTo();
|
||||||
int arrayBytes = arrayType->getScalarSizeInBits() / 8;
|
|
||||||
|
auto dataLayout = llvm::DataLayout(mLLVMModule);
|
||||||
|
int arrayBytes = (int)dataLayout.getTypeSizeInBits(arrayType) / 8;
|
||||||
|
|
||||||
if (auto loadInst = llvm::dyn_cast<llvm::LoadInst>(val))
|
if (auto loadInst = llvm::dyn_cast<llvm::LoadInst>(val))
|
||||||
{
|
{
|
||||||
|
@ -1072,7 +1073,7 @@ bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
||||||
1,
|
1,
|
||||||
mIRBuilder->CreateBitCast(loadInst->getPointerOperand(), int8PtrTy),
|
mIRBuilder->CreateBitCast(loadInst->getPointerOperand(), int8PtrTy),
|
||||||
1,
|
1,
|
||||||
llvm::ConstantInt::get(int8Ty, arrayBytes));
|
llvm::ConstantInt::get(int32Ty, arrayBytes));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1095,7 +1096,7 @@ bool BfIRCodeGen::TryMemCpy(llvm::Value* ptr, llvm::Value* val)
|
||||||
1,
|
1,
|
||||||
mIRBuilder->CreateBitCast(globalVariable, int8PtrTy),
|
mIRBuilder->CreateBitCast(globalVariable, int8PtrTy),
|
||||||
1,
|
1,
|
||||||
llvm::ConstantInt::get(int8Ty, arrayBytes));
|
llvm::ConstantInt::get(int32Ty, arrayBytes));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue