This revision refactors the TypeConverter class to not use inheritance to add type conversions. It instead moves to a registration based system, where conversion callbacks are added to the converter with addConversion. This method takes a conversion callback, which must be convertible to any of the following forms(where T is a class derived from Type:
- Optional<Type> (T type)
- This form represents a 1-1 type conversion. It should return nullptr or llvm::None to signify failure. If llvm::None is returned, the converter is allowed to try another conversion function to perform the conversion.
- Optional<LogicalResult>(T type, SmallVectorImpl<Type> &results)
- This form represents a 1-N type conversion. It should return failure or llvm::None to signify a failed conversion. If the new set of types is empty, the type is removed and any usages of the existing value are expected to be removed during conversion. If llvm::None is returned, the converter is allowed to try another conversion function to perform the conversion.
When attempting to convert a type, the TypeConverter walks each of the registered converters starting with the one registered most recently.
checking resultOp for being non-null is redundant here, the if the previous line ensured that