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

Fabian Mora llvmlistbot at llvm.org
Thu Mar 28 05:28:59 PDT 2024


fabianmcg wrote:

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)

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.

Thus, I think this proposal might be as good as it gets (I might be wrong).

But again, it should be possible to generate ODS for the current proposal, for implementing a subclass with `classof`, `parse`, `print` and custom getters.

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


More information about the Mlir-commits mailing list