mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Explicit 64-bit indexer truncation on 32-bit builds
This commit is contained in:
parent
390f27c072
commit
7d0121ea27
2 changed files with 10 additions and 1 deletions
|
@ -486,6 +486,12 @@ void BfIRCodeGen::FixValues(llvm::StructType* structType, llvm::SmallVector<llvm
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void BfIRCodeGen::FixIndexer(llvm::Value*& val)
|
||||||
|
{
|
||||||
|
if ((int)val->getType()->getScalarSizeInBits() > mPtrSize * 8)
|
||||||
|
val = mIRBuilder->CreateIntCast(val, llvm::Type::getInt32Ty(*mLLVMContext), false);
|
||||||
|
}
|
||||||
|
|
||||||
BfTypeCode BfIRCodeGen::GetTypeCode(llvm::Type* type, bool isSigned)
|
BfTypeCode BfIRCodeGen::GetTypeCode(llvm::Type* type, bool isSigned)
|
||||||
{
|
{
|
||||||
if (type->isIntegerTy())
|
if (type->isIntegerTy())
|
||||||
|
@ -2340,7 +2346,7 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
SetResult(curId, mIRBuilder->CreateBitCast(gepResult, val->getType()));
|
SetResult(curId, mIRBuilder->CreateBitCast(gepResult, val->getType()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
FixIndexer(idx0);
|
||||||
SetResult(curId, mIRBuilder->CreateInBoundsGEP(val, idx0));
|
SetResult(curId, mIRBuilder->CreateInBoundsGEP(val, idx0));
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -2349,6 +2355,8 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(llvm::Value*, val);
|
CMD_PARAM(llvm::Value*, val);
|
||||||
CMD_PARAM(llvm::Value*, idx0);
|
CMD_PARAM(llvm::Value*, idx0);
|
||||||
CMD_PARAM(llvm::Value*, idx1);
|
CMD_PARAM(llvm::Value*, idx1);
|
||||||
|
FixIndexer(idx0);
|
||||||
|
FixIndexer(idx1);
|
||||||
llvm::Value* indices[2] = { idx0, idx1 };
|
llvm::Value* indices[2] = { idx0, idx1 };
|
||||||
SetResult(curId, FixGEP(val, mIRBuilder->CreateInBoundsGEP(val, llvm::makeArrayRef(indices))));
|
SetResult(curId, FixGEP(val, mIRBuilder->CreateInBoundsGEP(val, llvm::makeArrayRef(indices))));
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,6 +125,7 @@ public:
|
||||||
public:
|
public:
|
||||||
void InitTarget();
|
void InitTarget();
|
||||||
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
void FixValues(llvm::StructType* structType, llvm::SmallVector<llvm::Value*, 8>& values);
|
||||||
|
void FixIndexer(llvm::Value*& val);
|
||||||
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
BfTypeCode GetTypeCode(llvm::Type* type, bool isSigned);
|
||||||
llvm::Type* GetLLVMType(BfTypeCode typeCode, bool& isSigned);
|
llvm::Type* GetLLVMType(BfTypeCode typeCode, bool& isSigned);
|
||||||
BfIRTypeEntry& GetTypeEntry(int typeId);
|
BfIRTypeEntry& GetTypeEntry(int typeId);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue