Lines Matching full:field

18 using Field = OptimizedStructLayoutField;  typedef
21 static void checkValidLayout(ArrayRef<Field> Fields, uint64_t Size, in checkValidLayout()
25 for (auto &Field : Fields) { in checkValidLayout() local
26 assert(Field.hasFixedOffset() && in checkValidLayout()
27 "didn't assign a fixed offset to field"); in checkValidLayout()
28 assert(isAligned(Field.Alignment, Field.Offset) && in checkValidLayout()
29 "didn't assign a correctly-aligned offset to field"); in checkValidLayout()
30 assert(Field.Offset >= LastEnd && in checkValidLayout()
32 LastEnd = Field.getEndOffset(); in checkValidLayout()
33 assert(Field.Alignment <= MaxAlign && in checkValidLayout()
35 ComputedMaxAlign = std::max(Field.Alignment, MaxAlign); in checkValidLayout()
43 llvm::performOptimizedStructLayout(MutableArrayRef<Field> Fields) { in performOptimizedStructLayout()
49 for (auto &Field : Fields) { in performOptimizedStructLayout() local
50 assert(Field.Size > 0 && "field of zero size"); in performOptimizedStructLayout()
51 if (Field.hasFixedOffset()) { in performOptimizedStructLayout()
54 assert(LastEnd <= Field.Offset && in performOptimizedStructLayout()
56 LastEnd = Field.getEndOffset(); in performOptimizedStructLayout()
57 assert(LastEnd > Field.Offset && in performOptimizedStructLayout()
69 // Find the first flexible-offset field, tracking MaxAlign. in performOptimizedStructLayout()
107 [](const Field *lhs, const Field *rhs) -> int { in performOptimizedStructLayout()
175 // field before the gap, or 0 if the gap is at the beginning of the in performOptimizedStructLayout()
176 // structure. Find the "best" flexible-offset field according to the in performOptimizedStructLayout()
177 // criteria below. If no such field exists, proceed to the next gap. in performOptimizedStructLayout()
178 // Otherwise, add the field at the first properly-aligned offset for in performOptimizedStructLayout()
179 // that field that is >= LastEnd, then update LastEnd and repeat in in performOptimizedStructLayout()
180 // order to fill any remaining gap following that field. in performOptimizedStructLayout()
183 // last fixed-offset field, or 0 if there are no fixed-offset fields. in performOptimizedStructLayout()
185 // flexible-offset field according to the criteria below, add it at in performOptimizedStructLayout()
186 // the first properly-aligned offset for that field that is >= LastEnd, in performOptimizedStructLayout()
187 // and update LastEnd to the first byte following the field. in performOptimizedStructLayout()
189 // The "best" field is chosen by the following criteria, considered in performOptimizedStructLayout()
192 // - When filling a gap betweeen fields, the field must fit. in performOptimizedStructLayout()
193 // - A field is preferred if it requires less padding following LastEnd. in performOptimizedStructLayout()
194 // - A field is preferred if it is more aligned. in performOptimizedStructLayout()
195 // - A field is preferred if it is larger. in performOptimizedStructLayout()
196 // - A field is preferred if it appeared earlier in the initial order. in performOptimizedStructLayout()
216 // the last fixed-layout field, the objects fit in the bins; note that in performOptimizedStructLayout()
250 static Field *getNext(Field *Cur) { in performOptimizedStructLayout()
251 return static_cast<Field *>(Cur->Scratch); in performOptimizedStructLayout()
285 assert(I->Alignment == Queue.Alignment && "bad field in queue"); in performOptimizedStructLayout()
294 /// Helper function to remove a field from a queue. in performOptimizedStructLayout()
295 auto spliceFromQueue = [&](AlignmentQueue *Queue, Field *Last, Field *Cur) { in performOptimizedStructLayout()
303 // If Cur was the last field in the list, we need to update MinSize. in performOptimizedStructLayout()
304 // We can just use the last field's size because the list is in in performOptimizedStructLayout()
322 SmallVector<Field, 16> Layout; in performOptimizedStructLayout()
330 auto addToLayout = [&](AlignmentQueue *Queue, Field *Last, Field *Cur, in performOptimizedStructLayout()
346 // Helper function to try to find a field in the given queue that'll in performOptimizedStructLayout()
355 // Figure out the maximum size that a field can be, and ignore this in performOptimizedStructLayout()
362 // Find the matching field. Note that this should always find in performOptimizedStructLayout()
364 for (Field *Cur = Queue->Head, *Last = nullptr; true; in performOptimizedStructLayout()
374 // Helper function to find the "best" flexible-offset field according in performOptimizedStructLayout()
395 // satisfactory field. in performOptimizedStructLayout()
422 // flexible-offset field that fits. in performOptimizedStructLayout()
437 // Phase 2: repeatedly add the best flexible-offset field until in performOptimizedStructLayout()
441 assert(Success && "didn't find a field with no fixed limit?"); in performOptimizedStructLayout()