@@ -234,7 +234,12 @@ public struct TBAAStructField {
234
234
}
235
235
236
236
extension MDBuilder {
237
- /// Build a metadata node for the root of a TBAA hierarchy with the given name.
237
+ /// Build a metadata node for the root of a TBAA hierarchy with the given
238
+ /// name.
239
+ ///
240
+ /// The root node of a TBAA hierarchy describes a boundary for a source
241
+ /// language's type system. For the purposes of optimization, a TBAA analysis
242
+ /// pass must consider ancestors of two different root systems `mayalias`.
238
243
///
239
244
/// - Parameters:
240
245
/// - name: The name of the TBAA root node.
@@ -306,13 +311,51 @@ extension MDBuilder {
306
311
/// Builds a TBAA Type Descriptor.
307
312
///
308
313
/// Type descriptors describe the type system of the higher level language
309
- /// being compiled. Scalar type descriptors describe types that do not
310
- /// contain other types. Each scalar type has a parent type, which must also
311
- /// be a scalar type or the TBAA root. Via this parent relation, scalar types
312
- /// within a TBAA root form a tree. Struct type descriptors denote types that
313
- /// contain a sequence of other type descriptors, at known offsets. These
314
- /// contained type descriptors can either be struct type descriptors
315
- /// themselves or scalar type descriptors.
314
+ /// being compiled and come in two variants:
315
+ ///
316
+ /// Scalar Type Descriptors
317
+ /// =======================
318
+ ///
319
+ /// Scalar type descriptors describe types that do not contain other types,
320
+ /// such as fixed-width integral and floating-point types. A scalar type
321
+ /// has a single parent, which is required to be another scalar type or
322
+ /// the TBAA root node. For example, in C, `int32_t` would be described be
323
+ /// a scalar type node with a parent pointer to `unsigned char` which, in
324
+ /// turn, points to the root for C.
325
+ ///
326
+ /// ```
327
+ /// +----------+ +------+ +-----------+
328
+ /// | | | | | |
329
+ /// | uint32_t +---> char +---> TBAA Root |
330
+ /// | | | | | |
331
+ /// +----------+ +------+ +-----------+
332
+ /// ```
333
+ ///
334
+ /// Struct Type Descriptors
335
+ /// =======================
336
+ ///
337
+ /// Struct type descriptors describe types that contain a sequence of other
338
+ /// type descriptors, at known offsets, as fields. These field type
339
+ /// descriptors can either be struct type descriptors themselves or scalar
340
+ /// type descriptors.
341
+ ///
342
+ /// ```
343
+ /// +----------+
344
+ /// | |
345
+ /// +-------> uint32_t +----+
346
+ /// | | | |
347
+ /// | +----------+ |
348
+ /// +------------+ +---v--+ +-----------+
349
+ /// | | | | | |
350
+ /// | SomeStruct | | char +---> TBAA Root |
351
+ /// | | | | | |
352
+ /// +------------+ +---^--+ +-----------+
353
+ /// | +-------+ |
354
+ /// | | | |
355
+ /// +----------> float +----+
356
+ /// | |
357
+ /// +-------+
358
+ /// ```
316
359
///
317
360
/// - Parameters:
318
361
/// - parent: The parent type node of this type node or the TBAA root node
0 commit comments