Skip to content

Commit a01ca4f

Browse files
krystian-andrzejewskiigcbot
authored andcommitted
Get or create a resource dim type
This change introduces a way of getting a resource dim typ e in which the type is created if absent.
1 parent 1058244 commit a01ca4f

File tree

1 file changed

+16
-1
lines changed

1 file changed

+16
-1
lines changed

IGC/common/igc_resourceDimTypes.h

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,16 @@ namespace IGC
3535
"__2D_DIM_Resource", "__2D_ARRAY_DIM_Resource",
3636
"__3D_DIM_Resource", "__Cube_DIM_Resource", "__Cube_ARRAY_DIM_Resource" };
3737

38+
inline llvm::Type* CreateResourceDimensionType(llvm::LLVMContext& llvmCtx, RESOURCE_DIMENSION_TYPE resourceDimType)
39+
{
40+
return llvm::StructType::create(llvmCtx, ResourceDimensionTypeName[resourceDimType]);
41+
}
42+
3843
inline void CreateResourceDimensionTypes(llvm::LLVMContext& llvmCtx)
3944
{
4045
for (unsigned int resourceDimTypeId = 0; resourceDimTypeId < (unsigned int)RESOURCE_DIMENSION_TYPE::NUM_RESOURCE_DIMENSION_TYPES; resourceDimTypeId++)
4146
{
42-
llvm::StructType::create(llvmCtx, ResourceDimensionTypeName[(RESOURCE_DIMENSION_TYPE)resourceDimTypeId]);
47+
CreateResourceDimensionType(llvmCtx, static_cast<RESOURCE_DIMENSION_TYPE>(resourceDimTypeId));
4348
}
4449
}
4550

@@ -57,4 +62,14 @@ namespace IGC
5762
return module.getTypeByName(ResourceDimensionTypeName[resourceDimTypeId]);
5863
#endif
5964
}
65+
66+
inline llvm::Type* GetOrCreateResourceDimensionType(const llvm::Module& module, RESOURCE_DIMENSION_TYPE resourceDimTypeId)
67+
{
68+
llvm::Type* pRet = GetResourceDimensionType(module, resourceDimTypeId);
69+
if (pRet == nullptr)
70+
{
71+
pRet = CreateResourceDimensionType(module.getContext(), resourceDimTypeId);
72+
}
73+
return pRet;
74+
}
6075
}

0 commit comments

Comments
 (0)