Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions llvm/include/llvm/CodeGen/Analysis.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,13 @@ void ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL, Type *Ty,
/// with the in-memory offsets of each of the individual values.
///
void computeValueLLTs(const DataLayout &DL, Type &Ty,
SmallVectorImpl<LLT> &ValueTys,
SmallVectorImpl<uint64_t> *Offsets = nullptr,
uint64_t StartingOffset = 0);
SmallVectorImpl<LLT> &ValueLLTs,
SmallVectorImpl<TypeSize> *Offsets = nullptr,
TypeSize StartingOffset = TypeSize::getZero());
void computeValueLLTs(const DataLayout &DL, Type &Ty,
SmallVectorImpl<LLT> &ValueLLTs,
SmallVectorImpl<uint64_t> *FixedOffsets,
uint64_t FixedStartingOffset = 0);

/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
GlobalValue *ExtractTypeInfo(Value *V);
Expand Down
52 changes: 21 additions & 31 deletions llvm/lib/CodeGen/Analysis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,38 +147,28 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
}

void llvm::computeValueLLTs(const DataLayout &DL, Type &Ty,
SmallVectorImpl<LLT> &ValueTys,
SmallVectorImpl<uint64_t> *Offsets,
uint64_t StartingOffset) {
// Given a struct type, recursively traverse the elements.
if (StructType *STy = dyn_cast<StructType>(&Ty)) {
// If the Offsets aren't needed, don't query the struct layout. This allows
// us to support structs with scalable vectors for operations that don't
// need offsets.
const StructLayout *SL = Offsets ? DL.getStructLayout(STy) : nullptr;
for (unsigned I = 0, E = STy->getNumElements(); I != E; ++I) {
uint64_t EltOffset = SL ? SL->getElementOffset(I) : 0;
computeValueLLTs(DL, *STy->getElementType(I), ValueTys, Offsets,
StartingOffset + EltOffset);
}
return;
}
// Given an array type, recursively traverse the elements.
if (ArrayType *ATy = dyn_cast<ArrayType>(&Ty)) {
Type *EltTy = ATy->getElementType();
uint64_t EltSize = DL.getTypeAllocSize(EltTy).getFixedValue();
for (unsigned i = 0, e = ATy->getNumElements(); i != e; ++i)
computeValueLLTs(DL, *EltTy, ValueTys, Offsets,
StartingOffset + i * EltSize);
return;
SmallVectorImpl<LLT> &ValueLLTs,
SmallVectorImpl<TypeSize> *Offsets,
TypeSize StartingOffset) {
SmallVector<Type *> ValTys;
ComputeValueTypes(DL, &Ty, ValTys, Offsets, StartingOffset);
for (Type *ValTy : ValTys)
ValueLLTs.push_back(getLLTForType(*ValTy, DL));
}

void llvm::computeValueLLTs(const DataLayout &DL, Type &Ty,
SmallVectorImpl<LLT> &ValueLLTs,
SmallVectorImpl<uint64_t> *FixedOffsets,
uint64_t FixedStartingOffset) {
TypeSize StartingOffset = TypeSize::getFixed(FixedStartingOffset);
if (FixedOffsets) {
SmallVector<TypeSize, 4> Offsets;
computeValueLLTs(DL, Ty, ValueLLTs, &Offsets, StartingOffset);
for (TypeSize Offset : Offsets)
FixedOffsets->push_back(Offset.getFixedValue());
} else {
computeValueLLTs(DL, Ty, ValueLLTs, nullptr, StartingOffset);
}
// Interpret void as zero return values.
if (Ty.isVoidTy())
return;
// Base case: we can get an LLT for this LLVM IR type.
ValueTys.push_back(getLLTForType(Ty, DL));
if (Offsets)
Offsets->push_back(StartingOffset);
}

/// ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
Expand Down
Loading