@@ -147,38 +147,28 @@ void llvm::ComputeValueVTs(const TargetLowering &TLI, const DataLayout &DL,
147147}
148148
149149void llvm::computeValueLLTs (const DataLayout &DL, Type &Ty,
150- SmallVectorImpl<LLT> &ValueTys,
151- SmallVectorImpl<uint64_t > *Offsets,
152- uint64_t StartingOffset) {
153- // Given a struct type, recursively traverse the elements.
154- if (StructType *STy = dyn_cast<StructType>(&Ty)) {
155- // If the Offsets aren't needed, don't query the struct layout. This allows
156- // us to support structs with scalable vectors for operations that don't
157- // need offsets.
158- const StructLayout *SL = Offsets ? DL.getStructLayout (STy) : nullptr ;
159- for (unsigned I = 0 , E = STy->getNumElements (); I != E; ++I) {
160- uint64_t EltOffset = SL ? SL->getElementOffset (I) : 0 ;
161- computeValueLLTs (DL, *STy->getElementType (I), ValueTys, Offsets,
162- StartingOffset + EltOffset);
163- }
164- return ;
165- }
166- // Given an array type, recursively traverse the elements.
167- if (ArrayType *ATy = dyn_cast<ArrayType>(&Ty)) {
168- Type *EltTy = ATy->getElementType ();
169- uint64_t EltSize = DL.getTypeAllocSize (EltTy).getFixedValue ();
170- for (unsigned i = 0 , e = ATy->getNumElements (); i != e; ++i)
171- computeValueLLTs (DL, *EltTy, ValueTys, Offsets,
172- StartingOffset + i * EltSize);
173- return ;
150+ SmallVectorImpl<LLT> &ValueLLTs,
151+ SmallVectorImpl<TypeSize> *Offsets,
152+ TypeSize StartingOffset) {
153+ SmallVector<Type *> ValTys;
154+ ComputeValueTypes (DL, &Ty, ValTys, Offsets, StartingOffset);
155+ for (Type *ValTy : ValTys)
156+ ValueLLTs.push_back (getLLTForType (*ValTy, DL));
157+ }
158+
159+ void llvm::computeValueLLTs (const DataLayout &DL, Type &Ty,
160+ SmallVectorImpl<LLT> &ValueLLTs,
161+ SmallVectorImpl<uint64_t > *FixedOffsets,
162+ uint64_t FixedStartingOffset) {
163+ TypeSize StartingOffset = TypeSize::getFixed (FixedStartingOffset);
164+ if (FixedOffsets) {
165+ SmallVector<TypeSize, 4 > Offsets;
166+ computeValueLLTs (DL, Ty, ValueLLTs, &Offsets, StartingOffset);
167+ for (TypeSize Offset : Offsets)
168+ FixedOffsets->push_back (Offset.getFixedValue ());
169+ } else {
170+ computeValueLLTs (DL, Ty, ValueLLTs, nullptr , StartingOffset);
174171 }
175- // Interpret void as zero return values.
176- if (Ty.isVoidTy ())
177- return ;
178- // Base case: we can get an LLT for this LLVM IR type.
179- ValueTys.push_back (getLLTForType (Ty, DL));
180- if (Offsets)
181- Offsets->push_back (StartingOffset);
182172}
183173
184174// / ExtractTypeInfo - Returns the type info, possibly bitcast, encoded in V.
0 commit comments