mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 11:38:21 +02:00
Fixed some const vector and static vector issues
This commit is contained in:
parent
3b1a5fd4d6
commit
9d3b693cfa
4 changed files with 206 additions and 178 deletions
|
@ -816,6 +816,17 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
|||
values.push_back(lastValue);
|
||||
}
|
||||
}
|
||||
else if (type->IsVector())
|
||||
{
|
||||
auto vecType = (BeVectorType*)type;
|
||||
int fillCount = (int)(vecType->mLength - values.size());
|
||||
if (fillCount > 0)
|
||||
{
|
||||
auto lastValue = values.back();
|
||||
for (int i = 0; i < fillCount; i++)
|
||||
values.push_back(lastValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BF_ASSERT(type->IsStruct());
|
||||
|
@ -835,8 +846,15 @@ void BeIRCodeGen::Read(BeValue*& beValue)
|
|||
auto memberType = constant->GetType();
|
||||
BF_ASSERT(memberType == arrayType->mElementType);
|
||||
}
|
||||
else if (type->IsVector())
|
||||
{
|
||||
auto vecType = (BeVectorType*)type;
|
||||
auto memberType = constant->GetType();
|
||||
BF_ASSERT(memberType == vecType->mElementType);
|
||||
}
|
||||
else
|
||||
{
|
||||
BF_ASSERT(type->IsStruct());
|
||||
auto structType = (BeStructType*)type;
|
||||
auto memberType = constant->GetType();
|
||||
BF_ASSERT(memberType == structType->mMembers[i].mType);
|
||||
|
|
|
@ -3084,48 +3084,8 @@ bool BfIRBuilder::WantsDbgDefinition(BfType* type)
|
|||
return false;
|
||||
}
|
||||
|
||||
void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
|
||||
void BfIRBuilder::CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInstance* typeInstance, bool forceDbgDefine)
|
||||
{
|
||||
auto populateModule = mModule->mContext->mUnreifiedModule;
|
||||
auto typeInstance = type->ToTypeInstance();
|
||||
if (typeInstance != NULL)
|
||||
populateModule = typeInstance->mModule;
|
||||
|
||||
// This PopulateType is generally NOT needed, but here is a scenario in which it is:
|
||||
// ClassB derives from ClassA. ClassC uses ClassB. A method inside ClassA gets modified,
|
||||
// marking ClassA as incomplete, and then ClassC rebuilds and calls MapType on ClassB.
|
||||
// "ClassB" itself is still populated, but its base class (ClassA) is not -- until we call
|
||||
// this PopulateType below.
|
||||
if (type->IsDataIncomplete())
|
||||
populateModule->PopulateType(type, BfPopulateType_Data);
|
||||
|
||||
bool isDefiningModule = ((type->GetModule() == mModule) || (type->IsFunction()));
|
||||
if (mModule->mExtensionCount != 0)
|
||||
isDefiningModule = false;
|
||||
|
||||
// if (mModule->mModuleName == "vdata")
|
||||
// isDefiningModule = true;
|
||||
|
||||
if ((isDefiningModule) || (type->IsValueType()))
|
||||
populateModule->PopulateType(type, BfPopulateType_DataAndMethods);
|
||||
|
||||
if ((!isDefiningModule) && (!type->IsUnspecializedType()) && (type->IsValueType()) && (mHasDebugInfo))
|
||||
{
|
||||
DbgSetTypeSize(DbgGetType(type), BF_ALIGN(type->mSize, type->mAlign) * 8, type->mAlign * 8);
|
||||
}
|
||||
|
||||
bool isPrimEnum = (type->IsEnum()) && (type->IsTypedPrimitive());
|
||||
|
||||
if (typeInstance == NULL)
|
||||
return;
|
||||
|
||||
BfType* underlyingArrayType = NULL;
|
||||
int underlyingArraySize = -1;
|
||||
bool underlyingIsVector = false;
|
||||
typeInstance->GetUnderlyingArray(underlyingArrayType, underlyingArraySize, underlyingIsVector);
|
||||
if (underlyingArraySize > 0)
|
||||
return;
|
||||
|
||||
auto typeDef = typeInstance->mTypeDef;
|
||||
|
||||
#ifdef BFIR_RENTRY_CHECK
|
||||
|
@ -3302,6 +3262,55 @@ void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
|
|||
{
|
||||
BF_ASSERT(irFieldTypes.size() <= 3);
|
||||
}
|
||||
}
|
||||
|
||||
void BfIRBuilder::CreateTypeDefinition(BfType* type, bool forceDbgDefine)
|
||||
{
|
||||
auto populateModule = mModule->mContext->mUnreifiedModule;
|
||||
auto typeInstance = type->ToTypeInstance();
|
||||
if (typeInstance != NULL)
|
||||
populateModule = typeInstance->mModule;
|
||||
|
||||
// This PopulateType is generally NOT needed, but here is a scenario in which it is:
|
||||
// ClassB derives from ClassA. ClassC uses ClassB. A method inside ClassA gets modified,
|
||||
// marking ClassA as incomplete, and then ClassC rebuilds and calls MapType on ClassB.
|
||||
// "ClassB" itself is still populated, but its base class (ClassA) is not -- until we call
|
||||
// this PopulateType below.
|
||||
if (type->IsDataIncomplete())
|
||||
populateModule->PopulateType(type, BfPopulateType_Data);
|
||||
|
||||
bool isDefiningModule = ((type->GetModule() == mModule) || (type->IsFunction()));
|
||||
if (mModule->mExtensionCount != 0)
|
||||
isDefiningModule = false;
|
||||
|
||||
// if (mModule->mModuleName == "vdata")
|
||||
// isDefiningModule = true;
|
||||
|
||||
if ((isDefiningModule) || (type->IsValueType()))
|
||||
populateModule->PopulateType(type, BfPopulateType_DataAndMethods);
|
||||
|
||||
if ((!isDefiningModule) && (!type->IsUnspecializedType()) && (type->IsValueType()) && (mHasDebugInfo))
|
||||
{
|
||||
DbgSetTypeSize(DbgGetType(type), BF_ALIGN(type->mSize, type->mAlign) * 8, type->mAlign * 8);
|
||||
}
|
||||
|
||||
bool isPrimEnum = (type->IsEnum()) && (type->IsTypedPrimitive());
|
||||
|
||||
if (typeInstance == NULL)
|
||||
return;
|
||||
|
||||
BfType* underlyingArrayType = NULL;
|
||||
int underlyingArraySize = -1;
|
||||
bool underlyingIsVector = false;
|
||||
typeInstance->GetUnderlyingArray(underlyingArrayType, underlyingArraySize, underlyingIsVector);
|
||||
if (underlyingArraySize > 0)
|
||||
{
|
||||
// Don't populate data
|
||||
}
|
||||
else
|
||||
{
|
||||
CreateTypeDefinition_Data(populateModule, typeInstance, forceDbgDefine);
|
||||
}
|
||||
|
||||
for (auto& fieldInstanceRef : typeInstance->mFieldInstances)
|
||||
{
|
||||
|
@ -4682,11 +4691,6 @@ BfIRFunction BfIRBuilder::CreateFunction(BfIRFunctionType funcType, BfIRLinkageT
|
|||
NEW_CMD_INSERTED_IRVALUE;
|
||||
mFunctionMap[name] = retVal;
|
||||
|
||||
if ((mModule->mIsConstModule) && (name.Contains("Dbg_")))
|
||||
{
|
||||
NOP;
|
||||
}
|
||||
|
||||
//BfLogSys(mModule->mSystem, "BfIRBuilder::CreateFunction: %d %s Module:%p\n", retVal.mId, name.c_str(), mModule);
|
||||
|
||||
return retVal;
|
||||
|
|
|
@ -1025,6 +1025,7 @@ public:
|
|||
void CreateDbgTypeDefinition(BfType* type);
|
||||
bool WantsDbgDefinition(BfType * type);
|
||||
void CreateTypeDeclaration(BfType* type, bool forceDbgDefine);
|
||||
void CreateTypeDefinition_Data(BfModule* populateModule, BfTypeInstance* typeInstance, bool forceDbgDefine);
|
||||
void CreateTypeDefinition(BfType* type, bool forceDbgDefine);
|
||||
void ReplaceDITemporaryTypes();
|
||||
void PushDbgLoc(BfTypeInstance* typeInst);
|
||||
|
|
|
@ -923,8 +923,13 @@ void BfIRCodeGen::Read(llvm::Value*& llvmValue, BfIRCodeGenEntry** codeGenEntry)
|
|||
{
|
||||
llvmValue = llvm::ConstantStruct::get(structType, values);
|
||||
}
|
||||
else if (auto vecType = llvm::dyn_cast<llvm::VectorType>(type))
|
||||
{
|
||||
llvmValue = llvm::ConstantVector::get(values);
|
||||
}
|
||||
else
|
||||
{
|
||||
llvmValue = NULL;
|
||||
Fail("Bad type");
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue