mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
More explicit alignments
This commit is contained in:
parent
fb8d528c6b
commit
229c7fbd12
4 changed files with 65 additions and 62 deletions
|
@ -7428,8 +7428,8 @@ BfTypedValue BfExprEvaluator::CreateCall(BfAstNode* targetSrc, const BfTypedValu
|
|||
|
||||
expandedParamsArray = BfTypedValue(mModule->CreateAlloca(wantType), wantType, true);
|
||||
expandedParamAlloca = mModule->CreateAlloca(genericTypeInst->mGenericTypeInfo->mTypeGenericArguments[0], true, NULL, mModule->GetConstValue(numElements));
|
||||
mModule->mBfIRBuilder->CreateStore(expandedParamAlloca, mModule->mBfIRBuilder->CreateInBoundsGEP(expandedParamsArray.mValue, 0, 1));
|
||||
mModule->mBfIRBuilder->CreateStore(mModule->GetConstValue(numElements), mModule->mBfIRBuilder->CreateInBoundsGEP(expandedParamsArray.mValue, 0, 2));
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(expandedParamAlloca, mModule->mBfIRBuilder->CreateInBoundsGEP(expandedParamsArray.mValue, 0, 1), mModule->mSystem->mPtrSize);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(mModule->GetConstValue(numElements), mModule->mBfIRBuilder->CreateInBoundsGEP(expandedParamsArray.mValue, 0, 2), mModule->mSystem->mPtrSize);
|
||||
|
||||
PushArg(expandedParamsArray, irArgs, !wantsSplat);
|
||||
continue;
|
||||
|
@ -11701,16 +11701,16 @@ void BfExprEvaluator::Visit(BfCheckTypeExpression* checkTypeExpr)
|
|||
auto endBB = mModule->mBfIRBuilder->CreateBlock("is.done");
|
||||
|
||||
BfIRValue boolResult = mModule->CreateAlloca(boolType);
|
||||
irb->CreateStore(irb->CreateConst(BfTypeCode_Boolean, 0), boolResult);
|
||||
irb->CreateAlignedStore(irb->CreateConst(BfTypeCode_Boolean, 0), boolResult, 1);
|
||||
|
||||
mModule->EmitDynamicCastCheck(targetValue, targetType, matchBB, endBB);
|
||||
|
||||
mModule->AddBasicBlock(matchBB);
|
||||
irb->CreateStore(irb->CreateConst(BfTypeCode_Boolean, 1), boolResult);
|
||||
irb->CreateAlignedStore(irb->CreateConst(BfTypeCode_Boolean, 1), boolResult, 1);
|
||||
irb->CreateBr(endBB);
|
||||
|
||||
mModule->AddBasicBlock(endBB);
|
||||
mResult = BfTypedValue(irb->CreateLoad(boolResult), boolType);
|
||||
mResult = BfTypedValue(irb->CreateAlignedLoad(boolResult, 1), boolType);
|
||||
}
|
||||
|
||||
void BfExprEvaluator::Visit(BfDynamicCastExpression* dynCastExpr)
|
||||
|
@ -11986,17 +11986,17 @@ void BfExprEvaluator::Visit(BfDynamicCastExpression* dynCastExpr)
|
|||
auto matchBlock = irb->CreateBlock("as.match");
|
||||
|
||||
BfIRValue targetVal = mModule->CreateAlloca(targetType);
|
||||
irb->CreateStore(irb->CreateConstNull(irb->MapType(targetType)), targetVal);
|
||||
irb->CreateAlignedStore(irb->CreateConstNull(irb->MapType(targetType)), targetVal, targetType->mAlign);
|
||||
|
||||
mModule->EmitDynamicCastCheck(targetValue, targetType, matchBlock, endBB);
|
||||
|
||||
mModule->AddBasicBlock(matchBlock);
|
||||
BfIRValue castedCallResult = mModule->mBfIRBuilder->CreateBitCast(targetValue.mValue, mModule->mBfIRBuilder->MapType(targetType));
|
||||
irb->CreateStore(castedCallResult, targetVal);
|
||||
irb->CreateAlignedStore(castedCallResult, targetVal, targetValue.mType->mAlign);
|
||||
irb->CreateBr(endBB);
|
||||
|
||||
mModule->AddBasicBlock(endBB);
|
||||
mResult = BfTypedValue(irb->CreateLoad(targetVal), targetType);
|
||||
mResult = BfTypedValue(irb->CreateAlignedLoad(targetVal, targetType->mAlign), targetType);
|
||||
_CheckResult();
|
||||
}
|
||||
|
||||
|
@ -12260,7 +12260,7 @@ BfTypedValue BfExprEvaluator::DoImplicitArgCapture(BfAstNode* refNode, BfIdentif
|
|||
{
|
||||
auto refType = (BfRefType*)field.mResolvedType;
|
||||
auto underlyingType = refType->GetUnderlyingType();
|
||||
result = BfTypedValue(mModule->mBfIRBuilder->CreateLoad(result.mValue), underlyingType, true);
|
||||
result = BfTypedValue(mModule->mBfIRBuilder->CreateAlignedLoad(result.mValue, underlyingType->mAlign), underlyingType, true);
|
||||
}
|
||||
else if (fieldDef->mIsReadOnly)
|
||||
result = mModule->LoadValue(result);
|
||||
|
@ -14275,7 +14275,7 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|||
else
|
||||
valPtr = mModule->GetDefaultValue(nullPtrType);
|
||||
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(baseDelegate, 0, targetField.mDataIdx);
|
||||
mModule->mBfIRBuilder->CreateStore(valPtr, fieldPtr);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(valPtr, fieldPtr, targetField.mResolvedType->mAlign);
|
||||
|
||||
// >> delegate.mFuncPtr = bindResult.mFunc
|
||||
if (lambdaInstance->mClosureFunc)
|
||||
|
@ -14283,7 +14283,7 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|||
auto nullPtrType = mModule->GetPrimitiveType(BfTypeCode_NullPtr);
|
||||
auto valPtr = mModule->mBfIRBuilder->CreateBitCast(lambdaInstance->mClosureFunc, mModule->mBfIRBuilder->MapType(nullPtrType));
|
||||
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(baseDelegate, 0, funcPtrField.mDataIdx);
|
||||
mModule->mBfIRBuilder->CreateStore(valPtr, fieldPtr);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(valPtr, fieldPtr, funcPtrField.mResolvedType->mAlign);
|
||||
}
|
||||
|
||||
mModule->AddDependency(useTypeInstance, mModule->mCurTypeInstance, BfDependencyMap::DependencyFlag_Calls);
|
||||
|
@ -14303,7 +14303,7 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|||
|
||||
auto localVar = mModule->mCurMethodState->mLocals[0];
|
||||
auto capturedValue = mModule->mBfIRBuilder->CreateInBoundsGEP(localVar->mValue, 0, fieldInstance.mDataIdx);
|
||||
capturedValue = mModule->mBfIRBuilder->CreateLoad(capturedValue);
|
||||
capturedValue = mModule->mBfIRBuilder->CreateAlignedLoad(capturedValue, fieldInstance.mResolvedType->mAlign);
|
||||
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, fieldInstance.mDataIdx);
|
||||
mModule->mBfIRBuilder->CreateStore(capturedValue, fieldPtr);
|
||||
|
||||
|
@ -14340,7 +14340,7 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|||
if (!IsVar(capturedTypedVal.mType))
|
||||
{
|
||||
auto fieldPtr = mModule->mBfIRBuilder->CreateInBoundsGEP(mResult.mValue, 0, fieldInstance->mDataIdx);
|
||||
mModule->mBfIRBuilder->CreateStore(capturedValue, fieldPtr);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(capturedValue, fieldPtr, fieldInstance->mResolvedType->mAlign);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -14359,7 +14359,7 @@ void BfExprEvaluator::Visit(BfLambdaBindExpression* lambdaBindExpr)
|
|||
auto voidPtrType = mModule->CreatePointerType(voidType);
|
||||
auto dtorThunk = mModule->mBfIRBuilder->CreateBitCast(lambdaInstance->mDtorFunc, mModule->mBfIRBuilder->MapType(voidPtrType));
|
||||
|
||||
mModule->mBfIRBuilder->CreateStore(dtorThunk, fieldPtr);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(dtorThunk, fieldPtr, mModule->mSystem->mPtrSize);
|
||||
fieldIdx++;
|
||||
}
|
||||
}
|
||||
|
@ -20360,7 +20360,7 @@ void BfExprEvaluator::Visit(BfTupleExpression* tupleExpr)
|
|||
else if (typedVal.IsSplat())
|
||||
mModule->AggregateSplatIntoAddr(typedVal, memberVal);
|
||||
else
|
||||
mModule->mBfIRBuilder->CreateStore(typedVal.mValue, memberVal);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(typedVal.mValue, memberVal, typedVal.mType->mAlign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20445,14 +20445,14 @@ BfTypedValue BfExprEvaluator::SetupNullConditional(BfTypedValue thisValue, BfTok
|
|||
{
|
||||
thisValue = mModule->MakeAddressable(thisValue);
|
||||
BfIRValue hasValuePtr = mModule->mBfIRBuilder->CreateInBoundsGEP(thisValue.mValue, 0, 1); // mHasValue
|
||||
isNotNull = mModule->mBfIRBuilder->CreateLoad(hasValuePtr);
|
||||
isNotNull = mModule->mBfIRBuilder->CreateAlignedLoad(hasValuePtr, 1);
|
||||
thisValue = BfTypedValue(mModule->mBfIRBuilder->GetFakeVal(), elementType, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
thisValue = mModule->MakeAddressable(thisValue);
|
||||
BfIRValue hasValuePtr = mModule->mBfIRBuilder->CreateInBoundsGEP(thisValue.mValue, 0, 2); // mHasValue
|
||||
isNotNull = mModule->mBfIRBuilder->CreateLoad(hasValuePtr);
|
||||
isNotNull = mModule->mBfIRBuilder->CreateAlignedLoad(hasValuePtr, 1);
|
||||
BfIRValue valuePtr = mModule->mBfIRBuilder->CreateInBoundsGEP(thisValue.mValue, 0, 1); // mValue
|
||||
thisValue = BfTypedValue(valuePtr, elementType, true);
|
||||
}
|
||||
|
@ -21650,7 +21650,7 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
if ((propDef != NULL) && (!ptr.IsAddr()))
|
||||
writeToProp = BfTypedValue(resultValue, ptr.mType);
|
||||
else
|
||||
mModule->mBfIRBuilder->CreateStore(resultValue, ptr.mValue, mIsVolatileReference);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(resultValue, ptr.mValue, ptr.mType->mAlign, mIsVolatileReference);
|
||||
if (unaryOp == BfUnaryOp_PostIncrement)
|
||||
mResult = BfTypedValue(origVal, ptr.mType, false);
|
||||
else
|
||||
|
@ -21707,7 +21707,7 @@ void BfExprEvaluator::PerformUnaryOperation_OnResult(BfExpression* unaryOpExpr,
|
|||
if ((propDef != NULL) && (!ptr.IsAddr()))
|
||||
writeToProp = BfTypedValue(resultValue, ptr.mType);
|
||||
else
|
||||
mModule->mBfIRBuilder->CreateStore(resultValue, ptr.mValue, mIsVolatileReference);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(resultValue, ptr.mValue, ptr.mType->mAlign, mIsVolatileReference);
|
||||
if (unaryOp == BfUnaryOp_PostDecrement)
|
||||
mResult = BfTypedValue(origVal, ptr.mType, false);
|
||||
else
|
||||
|
@ -22706,7 +22706,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
mModule->mBfIRBuilder->PopulateType(resultType);
|
||||
BfTypedValue nullableTypedVale = mModule->MakeAddressable(*resultTypedValue);
|
||||
BfIRValue hasValuePtr = mModule->mBfIRBuilder->CreateInBoundsGEP(nullableTypedVale.mValue, 0, 1);
|
||||
BfIRValue hasValueValue = mModule->mBfIRBuilder->CreateLoad(hasValuePtr);
|
||||
BfIRValue hasValueValue = mModule->mBfIRBuilder->CreateAlignedLoad(hasValuePtr, 1);
|
||||
if (isEquality)
|
||||
hasValueValue = mModule->mBfIRBuilder->CreateNot(hasValueValue);
|
||||
mResult = BfTypedValue(hasValueValue, boolType);
|
||||
|
@ -22716,7 +22716,7 @@ void BfExprEvaluator::PerformBinaryOperation(BfAstNode* leftExpression, BfAstNod
|
|||
mModule->mBfIRBuilder->PopulateType(resultType);
|
||||
BfTypedValue nullableTypedVale = mModule->MakeAddressable(*resultTypedValue);
|
||||
BfIRValue hasValuePtr = mModule->mBfIRBuilder->CreateInBoundsGEP(nullableTypedVale.mValue, 0, 2);
|
||||
BfIRValue hasValueValue = mModule->mBfIRBuilder->CreateLoad(hasValuePtr);
|
||||
BfIRValue hasValueValue = mModule->mBfIRBuilder->CreateAlignedLoad(hasValuePtr, 1);
|
||||
if (isEquality)
|
||||
hasValueValue = mModule->mBfIRBuilder->CreateNot(hasValueValue);
|
||||
mResult = BfTypedValue(hasValueValue, boolType);
|
||||
|
|
|
@ -762,9 +762,9 @@ public:
|
|||
}
|
||||
else
|
||||
{
|
||||
auto prevVal = mModule->mBfIRBuilder->CreateLoad(accumValuePtr);
|
||||
auto prevVal = mModule->mBfIRBuilder->CreateAlignedLoad(accumValuePtr, intPtrType->mAlign);
|
||||
auto addedVal = mModule->mBfIRBuilder->CreateAdd(sizeValue, prevVal);
|
||||
mModule->mBfIRBuilder->CreateStore(addedVal, accumValuePtr);
|
||||
mModule->mBfIRBuilder->CreateAlignedStore(addedVal, accumValuePtr, intPtrType->mAlign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2049,7 +2049,7 @@ BfDeferredCallEntry* BfModule::AddStackAlloc(BfTypedValue val, BfIRValue arraySi
|
|||
BF_ASSERT(!isDynAlloc);
|
||||
auto valPtr = CreateAlloca(checkBaseType);
|
||||
mBfIRBuilder->ClearDebugLocation_Last();
|
||||
mBfIRBuilder->CreateStore(useVal, valPtr);
|
||||
mBfIRBuilder->CreateAlignedStore(useVal, valPtr, checkBaseType->mAlign);
|
||||
mBfIRBuilder->ClearDebugLocation_Last();
|
||||
useVal = valPtr;
|
||||
}
|
||||
|
@ -4523,7 +4523,7 @@ BfTypedValue BfModule::GetFieldInitializerValue(BfFieldInstance* fieldInstance,
|
|||
{
|
||||
result = LoadValue(result);
|
||||
if (!result.mType->IsValuelessType())
|
||||
mBfIRBuilder->CreateStore(result.mValue, staticVarRef.mValue);
|
||||
mBfIRBuilder->CreateAlignedStore(result.mValue, staticVarRef.mValue, result.mType->mAlign);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -8613,9 +8613,9 @@ BfTypedValue BfModule::FlushNullConditional(BfTypedValue result, bool ignoreNull
|
|||
else
|
||||
{
|
||||
BfIRValue ptrValue = mBfIRBuilder->CreateInBoundsGEP(nullableTypedValue.mValue, 0, 1); // mValue
|
||||
mBfIRBuilder->CreateStore(result.mValue, ptrValue);
|
||||
mBfIRBuilder->CreateAlignedStore(result.mValue, ptrValue, result.mType->mAlign);
|
||||
ptrValue = mBfIRBuilder->CreateInBoundsGEP(nullableTypedValue.mValue, 0, 2); // mHasValue
|
||||
mBfIRBuilder->CreateStore(GetConstValue(1, GetPrimitiveType(BfTypeCode_Boolean)), ptrValue);
|
||||
mBfIRBuilder->CreateAlignedStore(GetConstValue(1, GetPrimitiveType(BfTypeCode_Boolean)), ptrValue, 1);
|
||||
}
|
||||
result = nullableTypedValue;
|
||||
}
|
||||
|
@ -10444,7 +10444,7 @@ BfTypedValue BfModule::BoxValue(BfAstNode* srcNode, BfTypedValue typedVal, BfTyp
|
|||
AggregateSplatIntoAddr(typedVal, valPtr);
|
||||
}
|
||||
else
|
||||
mBfIRBuilder->CreateStore(typedVal.mValue, valPtr);
|
||||
mBfIRBuilder->CreateStore(typedVal.mValue, valPtr, typedVal.mType->mAlign);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12446,7 +12446,7 @@ BfTypedValue BfModule::RemoveRef(BfTypedValue typedValue)
|
|||
typedValue = BfTypedValue(typedValue.mValue, elementType, true);
|
||||
}
|
||||
else
|
||||
typedValue = BfTypedValue(mBfIRBuilder->CreateLoad(typedValue.mValue), elementType, true);
|
||||
typedValue = BfTypedValue(mBfIRBuilder->CreateAlignedLoad(typedValue.mValue, elementType->mAlign), elementType, true);
|
||||
}
|
||||
else
|
||||
typedValue = BfTypedValue(typedValue.mValue, elementType, true);
|
||||
|
@ -12881,7 +12881,7 @@ BfIRValue BfModule::ExtractSplatValue(BfTypedValue typedValue, int componentIdx,
|
|||
}
|
||||
else
|
||||
{
|
||||
val = mBfIRBuilder->CreateLoad(val);
|
||||
val = mBfIRBuilder->CreateAlignedLoad(val, wantType->mAlign);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -13083,7 +13083,7 @@ BfIRValue BfModule::ExtractValue(BfTypedValue typedValue, int dataIdx)
|
|||
if (typedValue.IsAddr())
|
||||
{
|
||||
auto addrVal = mBfIRBuilder->CreateInBoundsGEP(typedValue.mValue, 0, dataIdx);
|
||||
return mBfIRBuilder->CreateLoad(addrVal);
|
||||
return mBfIRBuilder->CreateAlignedLoad(addrVal, typedValue.mType->mAlign);
|
||||
}
|
||||
return mBfIRBuilder->CreateExtractValue(typedValue.mValue, dataIdx);
|
||||
}
|
||||
|
@ -14509,7 +14509,7 @@ BfIRValue BfModule::GetInterfaceSlotNum(BfTypeInstance* ifaceType)
|
|||
mInterfaceSlotRefs[ifaceType] = globalValue;
|
||||
}
|
||||
|
||||
return mBfIRBuilder->CreateLoad(globalValue/*, "slotOfs"*/);
|
||||
return mBfIRBuilder->CreateAlignedLoad(globalValue/*, "slotOfs"*/, 4);
|
||||
}
|
||||
|
||||
void BfModule::HadSlotCountDependency()
|
||||
|
@ -14724,7 +14724,7 @@ BfTypedValue BfModule::ReferenceStaticField(BfFieldInstance* fieldInstance)
|
|||
return BfTypedValue(globalValue, type, !fieldDef->mIsConst);
|
||||
}
|
||||
|
||||
int BfModule::GetFieldDataIdx(BfTypeInstance* typeInst, int fieldIdx, const char* fieldName)
|
||||
BfFieldInstance* BfModule::GetFieldInstance(BfTypeInstance* typeInst, int fieldIdx, const char* fieldName)
|
||||
{
|
||||
if (typeInst->IsDataIncomplete())
|
||||
PopulateType(typeInst);
|
||||
|
@ -14733,8 +14733,7 @@ int BfModule::GetFieldDataIdx(BfTypeInstance* typeInst, int fieldIdx, const char
|
|||
Fail(StrFormat("Invalid field data in type '%s'", TypeToString(typeInst).c_str()));
|
||||
return 0;
|
||||
}
|
||||
auto& fieldInstance = typeInst->mFieldInstances[fieldIdx];
|
||||
return fieldInstance.mDataIdx;
|
||||
return &typeInst->mFieldInstances[fieldIdx];
|
||||
}
|
||||
|
||||
void BfModule::MarkUsingThis()
|
||||
|
@ -14866,7 +14865,7 @@ BfTypedValue BfModule::GetThis(bool markUsing)
|
|||
else if ((thisLocal->mIsSplat) || (thisLocal->mIsLowered))
|
||||
thisValue = thisLocal->mAddr;
|
||||
else
|
||||
thisValue = mBfIRBuilder->CreateLoad(thisLocal->mAddr);
|
||||
thisValue = mBfIRBuilder->CreateAlignedLoad(thisLocal->mAddr, thisLocal->mResolvedType->mAlign);
|
||||
if (markUsing)
|
||||
useMethodState->mLocals[0]->mReadFromId = useMethodState->GetRootMethodState()->mCurAccessId++;
|
||||
|
||||
|
@ -15935,9 +15934,9 @@ void BfModule::EmitReturn(const BfTypedValue& val)
|
|||
{
|
||||
BfIRValue retVal = mCurMethodState->mRetVal.mValue;
|
||||
if (!mCurMethodState->mRetVal)
|
||||
retVal = mBfIRBuilder->CreateLoad(mCurMethodState->mRetValAddr);
|
||||
retVal = mBfIRBuilder->CreateAlignedLoad(mCurMethodState->mRetValAddr, mCurMethodInstance->mReturnType->mAlign);
|
||||
|
||||
mBfIRBuilder->CreateStore(val.mValue, retVal);
|
||||
mBfIRBuilder->CreateAlignedStore(val.mValue, retVal, mCurMethodInstance->mReturnType->mAlign);
|
||||
}
|
||||
else if (mIsComptimeModule)
|
||||
{
|
||||
|
@ -16089,7 +16088,7 @@ void BfModule::CreateDelegateInvokeMethod()
|
|||
|
||||
auto multicastDelegate = mBfIRBuilder->CreateBitCast(mCurMethodState->mLocals[0]->mValue, mBfIRBuilder->MapType(multicastDelegateType));
|
||||
auto fieldPtr = mBfIRBuilder->CreateInBoundsGEP(multicastDelegate, 0, 2); // Load 'delegate.mTarget'
|
||||
auto fieldVal = mBfIRBuilder->CreateLoad(fieldPtr);
|
||||
auto fieldVal = mBfIRBuilder->CreateAlignedLoad(fieldPtr, mSystem->mPtrSize);
|
||||
|
||||
BfExprEvaluator exprEvaluator(this);
|
||||
|
||||
|
@ -16151,7 +16150,7 @@ void BfModule::CreateDelegateInvokeMethod()
|
|||
memberFuncArgs[thisIdx] = mBfIRBuilder->CreateBitCast(fieldVal, mBfIRBuilder->MapType(mCurTypeInstance));
|
||||
auto fieldPtr = mBfIRBuilder->CreateInBoundsGEP(multicastDelegate, 0, 1); // Load 'delegate.mFuncPtr'
|
||||
auto funcPtrPtr = mBfIRBuilder->CreateBitCast(fieldPtr, memberFuncPtrPtr);
|
||||
auto funcPtr = mBfIRBuilder->CreateLoad(funcPtrPtr);
|
||||
auto funcPtr = mBfIRBuilder->CreateAlignedLoad(funcPtrPtr, mSystem->mPtrSize);
|
||||
nonStaticResult = mBfIRBuilder->CreateCall(funcPtr, memberFuncArgs);
|
||||
if ((!mIsComptimeModule) && (mCurMethodInstance->GetStructRetIdx() != -1))
|
||||
mBfIRBuilder->Call_AddAttribute(nonStaticResult, mCurMethodInstance->GetStructRetIdx() + 1, BfIRAttribute_StructRet);
|
||||
|
@ -16169,7 +16168,7 @@ void BfModule::CreateDelegateInvokeMethod()
|
|||
mBfIRBuilder->SetInsertPoint(falseBB);
|
||||
auto fieldPtr = mBfIRBuilder->CreateInBoundsGEP(multicastDelegate, 0, 1); // Load 'delegate.mFuncPtr'
|
||||
auto funcPtrPtr = mBfIRBuilder->CreateBitCast(fieldPtr, staticFuncPtrPtr);
|
||||
auto funcPtr = mBfIRBuilder->CreateLoad(funcPtrPtr);
|
||||
auto funcPtr = mBfIRBuilder->CreateAlignedLoad(funcPtrPtr, mSystem->mPtrSize);
|
||||
staticResult = mBfIRBuilder->CreateCall(funcPtr, staticFuncArgs);
|
||||
if ((!mIsComptimeModule) && (mCurMethodInstance->GetStructRetIdx(true) != -1))
|
||||
{
|
||||
|
@ -17452,7 +17451,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
|||
if ((mCurTypeInstance->IsTypedPrimitive()) && (!mCurTypeInstance->IsValuelessType()))
|
||||
{
|
||||
// Zero out typed primitives in ctor
|
||||
mBfIRBuilder->CreateStore(GetDefaultValue(mCurTypeInstance->GetUnderlyingType()), mBfIRBuilder->GetArgument(0));
|
||||
mBfIRBuilder->CreateAlignedStore(GetDefaultValue(mCurTypeInstance->GetUnderlyingType()), mBfIRBuilder->GetArgument(0), mCurTypeInstance->mAlign);
|
||||
}
|
||||
|
||||
if ((!mCurTypeInstance->IsBoxed()) && (methodDef->mMethodType == BfMethodType_Ctor) && (!hadThisInitializer))
|
||||
|
@ -17636,7 +17635,7 @@ void BfModule::EmitCtorBody(bool& skipBody)
|
|||
}
|
||||
|
||||
if ((fieldAddr) && (assignValue))
|
||||
mBfIRBuilder->CreateStore(assignValue.mValue, fieldAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(assignValue.mValue, fieldAddr, fieldInst->mResolvedType->mAlign);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20300,7 +20299,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
auto primType = mBfIRBuilder->GetPrimitiveType(loweredTypeCode);
|
||||
auto primPtrType = mBfIRBuilder->GetPointerTo(primType);
|
||||
auto primPtrVal = mBfIRBuilder->CreateBitCast(paramVar->mAddr, primPtrType);
|
||||
mBfIRBuilder->CreateStore(paramVar->mValue, primPtrVal);
|
||||
mBfIRBuilder->CreateAlignedStore(paramVar->mValue, primPtrVal, mCurTypeInstance->mAlign);
|
||||
|
||||
if (loweredTypeCode2 != BfTypeCode_None)
|
||||
{
|
||||
|
@ -20474,7 +20473,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
// We don't allow actually assignment to "this", so we just do a single load
|
||||
// Keep in mind we don't use the ACTUAL mValue value because that's a register, but
|
||||
// we need to store it in the stack frame for debugging purposes
|
||||
auto loadedThis = mBfIRBuilder->CreateLoad(paramVar->mAddr/*, "this"*/);
|
||||
auto loadedThis = mBfIRBuilder->CreateAlignedLoad(paramVar->mAddr/*, "this"*/, paramVar->mResolvedType->mAlign);
|
||||
mBfIRBuilder->ClearDebugLocation(loadedThis);
|
||||
paramVar->mValue = loadedThis;
|
||||
}
|
||||
|
@ -20985,7 +20984,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
BfExprEvaluator exprEvaluator(this);
|
||||
auto localVal = exprEvaluator.LoadLocal(lastParam);
|
||||
localVal = LoadOrAggregateValue(localVal);
|
||||
mBfIRBuilder->CreateStore(localVal.mValue, lookupAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(localVal.mValue, lookupAddr, localVal.mType->mAlign);
|
||||
}
|
||||
else if (!fieldInstance->mResolvedType->IsValuelessType())
|
||||
{
|
||||
|
@ -21034,7 +21033,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
{
|
||||
auto ptrType = CreatePointerType(mCurMethodInstance->mReturnType);
|
||||
auto allocaInst = AllocLocalVariable(ptrType, "__return.addr", false);
|
||||
auto storeInst = mBfIRBuilder->CreateStore(mBfIRBuilder->GetArgument(mCurMethodInstance->GetStructRetIdx()), allocaInst);
|
||||
auto storeInst = mBfIRBuilder->CreateAlignedStore(mBfIRBuilder->GetArgument(mCurMethodInstance->GetStructRetIdx()), allocaInst, mCurMethodInstance->mReturnType->mAlign);
|
||||
mBfIRBuilder->ClearDebugLocation(storeInst);
|
||||
mCurMethodState->mRetValAddr = allocaInst;
|
||||
}
|
||||
|
@ -21047,7 +21046,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
|
||||
if (methodDef->mMethodType == BfMethodType_CtorCalcAppend)
|
||||
{
|
||||
mBfIRBuilder->CreateStore(GetConstValue(0), mCurMethodState->mRetVal.mValue);
|
||||
mBfIRBuilder->CreateAlignedStore(GetConstValue(0), mCurMethodState->mRetVal.mValue, mCurMethodState->mRetVal.mType->mAlign);
|
||||
BfGetSymbolReferenceKind prevSymbolKind;
|
||||
BfAutoComplete* prevAutoComplete;
|
||||
if (mCompiler->mResolvePassData != NULL)
|
||||
|
@ -21234,7 +21233,7 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
|||
if ((mCurMethodState->mRetVal) &&
|
||||
((mIsComptimeModule) || (mCurMethodInstance->GetStructRetIdx() == -1)))
|
||||
{
|
||||
auto loadedVal = mBfIRBuilder->CreateLoad(mCurMethodState->mRetVal.mValue);
|
||||
auto loadedVal = mBfIRBuilder->CreateAlignedLoad(mCurMethodState->mRetVal.mValue, mCurMethodState->mRetVal.mType->mAlign);
|
||||
|
||||
CreateReturn(loadedVal);
|
||||
|
||||
|
|
|
@ -1696,7 +1696,7 @@ public:
|
|||
BfTypedValue GetCompilerFieldValue(const StringImpl& str);
|
||||
BfTypedValue GetCompilerFieldValue(const BfTypedValue typedVal);
|
||||
BfTypedValue ReferenceStaticField(BfFieldInstance* fieldInstance);
|
||||
int GetFieldDataIdx(BfTypeInstance* typeInst, int fieldIdx, const char* fieldName = NULL);
|
||||
BfFieldInstance* GetFieldInstance(BfTypeInstance* typeInst, int fieldIdx, const char* fieldName = NULL);
|
||||
BfTypedValue GetThis(bool markUsing = true);
|
||||
void MarkUsingThis();
|
||||
BfLocalVariable* GetThisVariable();
|
||||
|
|
|
@ -1924,7 +1924,7 @@ BfLocalVariable* BfModule::HandleVariableDeclaration(BfVariableDeclaration* varD
|
|||
|
||||
BfLocalVariable* localVar = AddLocalVariableDef(localDef, true, false, BfIRValue(), initType);
|
||||
if (wantsStore)
|
||||
mBfIRBuilder->CreateStore(initValue.mValue, localVar->mAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(initValue.mValue, localVar->mAddr, localVar->mResolvedType->mAlign);
|
||||
return localVar;
|
||||
}
|
||||
|
||||
|
@ -5962,7 +5962,7 @@ void BfModule::DoForLess(BfForEachStatement* forEachStmt)
|
|||
|
||||
CheckVariableDef(localDef);
|
||||
|
||||
mBfIRBuilder->CreateStore(GetDefaultValue(varType), localDef->mAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(GetDefaultValue(varType), localDef->mAddr, varType->mAlign);
|
||||
|
||||
localDef->Init();
|
||||
UpdateExprSrcPos(forEachStmt->mVariableName);
|
||||
|
@ -5992,7 +5992,7 @@ void BfModule::DoForLess(BfForEachStatement* forEachStmt)
|
|||
|
||||
// Cond
|
||||
auto valueScopeStart = ValueScopeStart();
|
||||
auto localVal = mBfIRBuilder->CreateLoad(localDef->mAddr);
|
||||
auto localVal = mBfIRBuilder->CreateAlignedLoad(localDef->mAddr, localDef->mResolvedType->mAlign);
|
||||
if (!target)
|
||||
{
|
||||
// Soldier on
|
||||
|
@ -6029,9 +6029,9 @@ void BfModule::DoForLess(BfForEachStatement* forEachStmt)
|
|||
|
||||
auto one = GetConstValue(1, localDef->mResolvedType);
|
||||
// We have to reload localVal before the inc, user logic could have changed it
|
||||
localVal = mBfIRBuilder->CreateLoad(localDef->mAddr);
|
||||
localVal = mBfIRBuilder->CreateAlignedLoad(localDef->mAddr, localDef->mResolvedType->mAlign);
|
||||
auto result = mBfIRBuilder->CreateAdd(localVal, one);
|
||||
mBfIRBuilder->CreateStore(result, localDef->mAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(result, localDef->mAddr, localDef->mResolvedType->mAlign);
|
||||
ValueScopeEnd(valueScopeStart);
|
||||
|
||||
mBfIRBuilder->CreateBr(condBB);
|
||||
|
@ -6508,7 +6508,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
else
|
||||
tuplePtr = mBfIRBuilder->CreateBitCast(varInst, mBfIRBuilder->MapType(tuplePtrType));
|
||||
auto valAddr = mBfIRBuilder->CreateInBoundsGEP(tuplePtr, 0, fieldInstance->mDataIdx);
|
||||
mBfIRBuilder->CreateStore(valAddr, localDef->mAddr);
|
||||
mBfIRBuilder->CreateAlignedStore(valAddr, localDef->mAddr, localDef->mResolvedType->mAlign);
|
||||
}
|
||||
|
||||
UpdateSrcPos(forEachStmt);
|
||||
|
@ -6550,7 +6550,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
if (!needsValCopy)
|
||||
{
|
||||
auto valAddr = mBfIRBuilder->CreateBitCast(nextResult.mValue, mBfIRBuilder->MapType(varType));
|
||||
mBfIRBuilder->CreateStore(valAddr, varInst);
|
||||
mBfIRBuilder->CreateAlignedStore(valAddr, varInst, varType->mAlign);
|
||||
}
|
||||
|
||||
UpdateSrcPos(forEachStmt);
|
||||
|
@ -6605,7 +6605,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
autoComplete->CheckVarResolution(forEachStmt->mVariableTypeRef, varType);
|
||||
|
||||
if (isArray || isSizedArray)
|
||||
mBfIRBuilder->CreateStore(GetConstValue(0), itr.mValue);
|
||||
mBfIRBuilder->CreateAlignedStore(GetConstValue(0), itr.mValue, itr.mType->mAlign);
|
||||
|
||||
auto valueScopeStartInner = ValueScopeStart();
|
||||
|
||||
|
@ -6642,7 +6642,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
}
|
||||
else if (isArray) // if (i < array.mLength)
|
||||
{
|
||||
auto itrVal = mBfIRBuilder->CreateLoad(itr.mValue);
|
||||
auto itrVal = mBfIRBuilder->CreateAlignedLoad(itr.mValue, itr.mType->mAlign);
|
||||
auto arrayType = (BfArrayType*)target.mType;
|
||||
PopulateType(arrayType);
|
||||
auto arrayBaseValue = mBfIRBuilder->CreateBitCast(target.mValue, mBfIRBuilder->MapType(arrayType->mBaseType, BfIRPopulateType_Full));
|
||||
|
@ -6659,8 +6659,12 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
}
|
||||
else
|
||||
{
|
||||
auto lengthValAddr = mBfIRBuilder->CreateInBoundsGEP(arrayBaseValue, 0, GetFieldDataIdx(arrayType->mBaseType, 0, "mLength"));
|
||||
lengthVal = mBfIRBuilder->CreateLoad(lengthValAddr);
|
||||
auto fieldInst = GetFieldInstance(arrayType->mBaseType, 0, "mLength");
|
||||
if (fieldInst != NULL)
|
||||
{
|
||||
auto lengthValAddr = mBfIRBuilder->CreateInBoundsGEP(arrayBaseValue, 0, fieldInst->mDataIdx);
|
||||
lengthVal = mBfIRBuilder->CreateAlignedLoad(lengthValAddr, fieldInst->mResolvedType->mAlign);
|
||||
}
|
||||
}
|
||||
lengthVal = mBfIRBuilder->CreateNumericCast(lengthVal, true, BfTypeCode_IntPtr);
|
||||
conditionValue = mBfIRBuilder->CreateCmpLT(itrVal, lengthVal, true);
|
||||
|
@ -6808,7 +6812,7 @@ void BfModule::Visit(BfForEachStatement* forEachStmt)
|
|||
nextVal = Cast(forEachStmt->mCollectionExpression, nextVal, varType, BfCastFlags_Explicit);
|
||||
nextVal = LoadValue(nextVal);
|
||||
if ((nextVal) && (!nextVal.mType->IsValuelessType()))
|
||||
mBfIRBuilder->CreateStore(nextVal.mValue, varInst);
|
||||
mBfIRBuilder->CreateAlignedStore(nextVal.mValue, varInst, nextVal.mType->mAlign);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue