39 Size structMemberOffset = 0;
40 Size maxMemberAlignment = 1;
42 for (uint32_t i = 0, e = structType.
getNumElements(); i < e; ++i) {
44 Size memberAlignment = 1;
48 structMemberOffset = llvm::alignTo(structMemberOffset, memberAlignment);
49 memberTypes.push_back(memberType);
51 static_cast<spirv::StructType::OffsetInfo>(structMemberOffset));
54 assert(memberSize != std::numeric_limits<Size>().
max() ||
60 structMemberOffset += memberSize;
61 maxMemberAlignment =
std::max(maxMemberAlignment, memberAlignment);
68 size = llvm::alignTo(structMemberOffset, maxMemberAlignment);
69 alignment = maxMemberAlignment;
83 alignment = getScalarTypeAlignment(type);
95 size = std::numeric_limits<Size>().
max();
98 llvm_unreachable(
"unhandled SPIR-V type");
104 const auto numElements =
vectorType.getNumElements();
105 auto elementType =
vectorType.getElementType();
106 Size elementSize = 0;
107 Size elementAlignment = 1;
109 auto memberType =
decorateType(elementType, elementSize, elementAlignment);
115 size = elementSize * numElements;
116 alignment = numElements == 2 ? elementAlignment * 2 : elementAlignment * 4;
117 return VectorType::get(numElements, memberType);
125 Size elementSize = 0;
126 Size elementAlignment = 1;
128 auto memberType =
decorateType(elementType, elementSize, elementAlignment);
132 size = elementSize * numElements;
133 alignment = elementAlignment;
140 Size elementSize = 0;
142 auto memberType =
decorateType(elementType, elementSize, alignment);
147 VulkanLayoutUtils::getScalarTypeAlignment(
Type scalarType) {
171 switch (storageClass) {
172 case spirv::StorageClass::Uniform:
173 case spirv::StorageClass::StorageBuffer:
174 case spirv::StorageClass::PushConstant:
175 case spirv::StorageClass::PhysicalStorageBuffer:
TODO: Remove this file when SCCP and integer range analysis have been ported to the new framework...
unsigned getNumElements() const
bool isIdentified() const
Returns true if the StructType is identified.
static RuntimeArrayType get(Type elementType)
Type getElementType() const
static StructType get(ArrayRef< Type > memberTypes, ArrayRef< OffsetInfo > offsetInfo={}, ArrayRef< MemberDecorationInfo > memberDecorations={})
Construct a literal StructType with at least one member.
static ArrayType get(Type elementType, unsigned elementCount)
Type getElementType() const
Instances of the Type class are uniqued, have an immutable identifier and an optional mutable compone...
static bool isLegalType(Type type)
Checks whether a type is legal in terms of Vulkan layout info decoration.
unsigned getNumElements() const
Type getElementType(unsigned) const
static VectorType vectorType(CodeGen &codegen, Type etp)
Constructs vector type.
unsigned getIntOrFloatBitWidth() const
Return the bit width of an integer or a float type, assert failure on other types.
StorageClass getStorageClass() const
void getMemberDecorations(SmallVectorImpl< StructType::MemberDecorationInfo > &memberDecorations) const
static spirv::StructType decorateType(spirv::StructType structType)
Returns a new StructType with layout decoration.
static Value max(ImplicitLocOpBuilder &builder, Value value, Value bound)