[Mlir-commits] [mlir] [mlir] Add the concept of ASM dialect aliases (PR #86033)

Markus Böck llvmlistbot at llvm.org
Thu Mar 28 09:16:26 PDT 2024


zero9178 wrote:

> > The `addDialectAlias` would simply be an alternative way to later give the printer the information that it has to check whether a `Ptr::PointerType` is an instance of `LLVMPointerType` or not prior to deciding which dialect to use when printing
> 
> The problem here is that we would need something like:
> 
> ```
> DenseMap<TypeID, SmallVector<Dialect*>> aliasedTypes;
> // Or
> DenseMap<TypeID, SmallVector<llvm::function_ref<Dialect*(Type)>>> aliasedTypes;
> ```
> 
> In `AsmPrinter` and every time a type gets printed we would need to check it, which would kill performance. This issue appears because only the alias knows how to distinguish itself from the base type.

The latter version is how I'd roughly had thought that's how it'd be done. I doubt it'd have killed performance or even been a lot different in that regard to your current version, given that the number of registered aliases would be very low in a program (so not a lot of elements in the SmallVector. E.g. just one for `LLVMPointerType`) and the map lookup isn't really more expensive than a `cast/dyn_cast/isa` to an interface either. Real performance numbers would obviously be useful, but I don't see any reason why it'd be more expensive than the current approach unless you have a huge number of registered alias types.

https://github.com/llvm/llvm-project/pull/86033


More information about the Mlir-commits mailing list