llvm-project
5781cc9b - [LLVM][Intrinsics] Refactor IIT encoding generation (#189790)

Commit
16 hours ago
[LLVM][Intrinsics] Refactor IIT encoding generation (#189790) Refactor IIT encoding generation. The core change here is that when generating IIT encodings, we pre-generate all the bits of the IIT encoding except cases where a type needs to encode its own overload index, which is patched in later in `TypeInfoGen`. In addition, this change introduces a class hierarchy for dependent types, so that the checks in `TypeInfoGen` are more meaningful, and renames/simplifies several other pieces of code, as listed below. 1. Change the encoding for IIT_ARG's ArgInfo byte to encode the overload slot index in lower 5 bits and the argument kind in upper 3 bits. This enabled generating the same packed format for all other dependent types that need to encode an overload slot index in the IIT encoding. Adjusted the corresponding C++ code in `IITDescriptor::getArgumentNumber` and `IIT_Descriptor::getArgumentKind`. 2. Introduce more descriptive classes to handle packing of the overload index + arg kind into the IIT encoding. `OverloadIndexPlaceholder` is used to generate a transient value in the type-signature that is patched in `TypeInfoGen` with that type's overload index. `PackOverloadIndex` is used to encapsulate the final packing of an overload index and argument kind in a single byte, and `PatchOverloadIndex` is the class that does the required patching of a `OverloadIndexPlaceholder` given the type's overload index. 3. Delete `isAny`, `ArgCode` and `Number` from base `LLVMType` class. Replace use of `isAny` with `isa<LLVMAnyType>`, `ArgCode` is not used anymore, and move `Number`, which was used to represent the overload index for a dependent type to the `LLVMDependentType` class and rename it to `OverloadIndex`. 4. Introduce `LLVMDependentType` as a base class of all dependent types. It holds the overload index of the type it depends on in its `OverloadIndex` field. Also introduce 2 subclasses, `LLVMFullyDependentType` to represent all fully dependent types (which encode just the appropriate IIT code and the dependent type's overload index) and `LLVMPartiallyDependentType` to represent partially dependent types, that encode the appropriate IIT code and both this type's overload index and the dependent type's overload index. 5. Change existing dependent type classes to derive from one of these classes and rename the `num` class argument to `oidx` to better reflect its meaning. 6. Rename various fields and classes used in `TypeInfoGen` to be more meaningful. `AssignOverloadIndex` to do overload index assignment, rename `ACIdxs` to `OverloadIdxs`, `ACTys` to `OverloadTypes` and use the `DoPatchOverloadIndex` to patch in assigned overload slot indexes.
Author
Parents
Loading