[Mlir-commits] [mlir] [mlir] Add the concept of ASM dialect aliases (PR #86033)
Markus Böck
llvmlistbot at llvm.org
Thu Mar 28 05:48:22 PDT 2024
https://github.com/zero9178 commented:
> With the current proposal it should be possible to support ODS, however, the core issue of aliases not always being printed would remain.
>
> After thinking about it a bit more, I think registering them is not going to help (I might be wrong). Let's agree in the following conditions:
>
> 1. If `type=!llvm.ptr`, then:
>
> * `isa<LLVMPointerType>(type) == isa<PtrType>(type)` and `TypeID::get<PtrType>() == type.getTypeID()`
> 2. If `type!=!llvm.ptr`, then:
>
> * `isa<LLVMPointerType>(type) != isa<PtrType>(type)` and `TypeID::get<PtrType>() == type.getTypeID()`
> 3. We also need that in all circumstances regardless of their origin:
>
> * `!ptr.ptr<#llvm.address_space> = !llvm.ptr`
> This condition refers to `LLVMPointerType::get(0) == PtrType::get(LLVMAddressSpace::get(0))`.
>
> If we want all three conditions, then, as types: an instance of `LLVMPointerType` must be indistinguishable from a `PtrType`. The only thing that could tell that something is a `LLVMPointerType` is `LLVMPointerType` itself.
>
> Which is what I'm currently doing manually, see: [LLVMTypes.cpp#L256-L294](https://github.com/llvm/llvm-project/blob/ed3de95c2fc823f703f8392e4839e9276bd47d4f/mlir/lib/Dialect/LLVMIR/IR/LLVMTypes.cpp#L256-L294)
That's great thank you!
> Hence, what would registration do?
>
> * It wouldn't affect printing because the type alone has no way to know it's a `LLVMPointerType` and testing to check if its, would be too time consuming. And using an extra `TypeID` or extra information is not possible without violating the 3rd condition.
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. That said, I am actually pretty happy with your interface and like the fact that it is opt-in, even if that makes it less powerful. I can also see how its more performant.
Left some comments about the implementation about the current approach then. It looks to me like it could be simplified if only allowing a different dialect to be used for printing and parsing through the interface.
https://github.com/llvm/llvm-project/pull/86033
More information about the Mlir-commits
mailing list