| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
[mlir][core|ptr] Add PtrLikeTypeInterface and casting ops to the ptr dialect (#137469) This patch adds the PtrLikeTypeInterface type interface to identify pointer-like types. This interface is defined as: `` A ptr-like type represents an object storing a memory address. This object is constituted by: - A memory address called the base pointer. This pointer is treated as a bag of bits without any assumed structure. The bit-width of the base pointer must be a compile-time constant. However, the bit-width may remain opaque or unavailable during transformations that do not depend on the base pointer. Finally, it is considered indivisible in the sense that as a PtrLikeTypeInterface value, it has no metadata. - Optional metadata about the pointer. For example, the size of the memory region associated with the pointer. Furthermore, all ptr-like types have two properties: - The memory space associated with the address held by the pointer. - An optional element type. If the element type is not specified, the pointer is considered opaque. ` This patch adds this interface to !ptr.ptr and the memref type. Furthermore, this patch adds necessary ops and type to handle casting between !ptr.ptr and ptr-like types. First, it defines the !ptr.ptr_metadata type. An opaque type to represent the metadata of a ptr-like type. The rationale behind adding this type, is that at high-level the metadata of a type like memref cannot be specified, as its structure is tied to its lowering. The ptr.get_metadata operation was added to extract the opaque pointer metadata. The concrete structure of the metadata is only known when the op is lowered. Finally, this patch adds the ptr.from_ptr and ptr.to_ptr operations. Allowing to cast back and forth between !ptr.ptr and ptr-like types. mlir func.func @func(%mr: memref<f32, #ptr.generic_space>) -> memref<f32, #ptr.generic_space> { %ptr = ptr.to_ptr %mr : memref<f32, #ptr.generic_space> -> !ptr.ptr<#ptr.generic_space> %mda = ptr.get_metadata %mr : memref<f32, #ptr.generic_space> %res = ptr.from_ptr %ptr metadata %mda : !ptr.ptr<#ptr.generic_space> -> memref<f32, #ptr.generic_space> return %res : memref<f32, #ptr.generic_space> } It's future work to replace and remove the bare-ptr-convention` through the use of these ops. --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com> | 1 年前 | |
[mlir][ptr] Add ptr.ptr_diff operation (#157354) Thi patch introduces the ptr.ptr_diff operation for computing pointer differences. The semantics of the operation are given by: `` The ptr_diff operation computes the difference between two pointers, returning an integer or index value representing the number of bytes between them. The operation supports both scalar and shaped types with value semantics: - When both operands are scalar: produces a single difference value - When both are shaped: performs element-wise subtraction, shapes must be the same The operation also supports the following flags: - none: No flags are set. - nuw: No Unsigned Wrap, if the subtraction causes an unsigned overflow, the result is a poison value. - nsw: No Signed Wrap, if the subtraction causes a signed overflow, the result is a poison value. NOTE: The pointer difference is calculated using an integer type specified by the data layout. The final result will be sign-extended or truncated to fit the result type as necessary. ` This patch also adds translation to LLVM IR hooks for the ptr_diff op. This translation uses the ptrtoaddr builder to compute only index bits difference. Example: mlir llvm.func @ptr_diff_vector_i32(%ptrs1: vector<8x!ptr.ptr<#llvm.address_space<0>>>, %ptrs2: vector<8x!ptr.ptr<#llvm.address_space<0>>>) -> vector<8xi32> { %diffs = ptr.ptr_diff %ptrs1, %ptrs2 : vector<8x!ptr.ptr<#llvm.address_space<0>>> -> vector<8xi32> llvm.return %diffs : vector<8xi32> } Translation to LLVM IR: llvm define <8 x i32> @ptr_diff_vector_i32(<8 x ptr> %0, <8 x ptr> %1) { %3 = ptrtoint <8 x ptr> %0 to <8 x i64> %4 = ptrtoint <8 x ptr> %1 to <8 x i64> %5 = sub <8 x i64> %3, %4 %6 = trunc <8 x i64> %5 to <8 x i32> ret <8 x i32> %6 } ` --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com> | 10 个月前 | |
[mlir][Ptr] Add the MemorySpaceAttrInterface interface and dependencies. (#86870) This patch introduces the MemorySpaceAttrInterface interface. This interface is responsible for handling the semantics of ptr operations. For example, this interface can be used to create read-only memory spaces, making any other operation other than a load a verification error, see TestConstMemorySpaceAttr for a possible implementation of this concept. This patch also introduces Enum dependencies AtomicOrdering, and AtomicBinOp, both enumerations are clones of the Enums with the same name in the LLVM Dialect. Also, see: - [[RFC] ptr dialect & modularizing ptr ops in the LLVM dialect](https://discourse.llvm.org/t/rfc-ptr-dialect-modularizing-ptr-ops-in-the-llvm-dialect/75142) for rationale. - https://github.com/llvm/llvm-project/pull/73057 for a prototype implementation of the full change. **Note: Ignore the first commit, that's being reviewed in https://github.com/llvm/llvm-project/pull/86860 .** | 1 年前 | |
[mlir][ptr] Add ptr.ptr_diff operation (#157354) Thi patch introduces the ptr.ptr_diff operation for computing pointer differences. The semantics of the operation are given by: `` The ptr_diff operation computes the difference between two pointers, returning an integer or index value representing the number of bytes between them. The operation supports both scalar and shaped types with value semantics: - When both operands are scalar: produces a single difference value - When both are shaped: performs element-wise subtraction, shapes must be the same The operation also supports the following flags: - none: No flags are set. - nuw: No Unsigned Wrap, if the subtraction causes an unsigned overflow, the result is a poison value. - nsw: No Signed Wrap, if the subtraction causes a signed overflow, the result is a poison value. NOTE: The pointer difference is calculated using an integer type specified by the data layout. The final result will be sign-extended or truncated to fit the result type as necessary. ` This patch also adds translation to LLVM IR hooks for the ptr_diff op. This translation uses the ptrtoaddr builder to compute only index bits difference. Example: mlir llvm.func @ptr_diff_vector_i32(%ptrs1: vector<8x!ptr.ptr<#llvm.address_space<0>>>, %ptrs2: vector<8x!ptr.ptr<#llvm.address_space<0>>>) -> vector<8xi32> { %diffs = ptr.ptr_diff %ptrs1, %ptrs2 : vector<8x!ptr.ptr<#llvm.address_space<0>>> -> vector<8xi32> llvm.return %diffs : vector<8xi32> } Translation to LLVM IR: llvm define <8 x i32> @ptr_diff_vector_i32(<8 x ptr> %0, <8 x ptr> %1) { %3 = ptrtoint <8 x ptr> %0 to <8 x i64> %4 = ptrtoint <8 x ptr> %1 to <8 x i64> %5 = sub <8 x i64> %3, %4 %6 = trunc <8 x i64> %5 to <8 x i32> ret <8 x i32> %6 } ` --------- Co-authored-by: Mehdi Amini <joker.eph@gmail.com> | 10 个月前 | |
[mlir][Ptr] Add the MemorySpaceAttrInterface interface and dependencies. (#86870) This patch introduces the MemorySpaceAttrInterface interface. This interface is responsible for handling the semantics of ptr operations. For example, this interface can be used to create read-only memory spaces, making any other operation other than a load a verification error, see TestConstMemorySpaceAttr for a possible implementation of this concept. This patch also introduces Enum dependencies AtomicOrdering, and AtomicBinOp, both enumerations are clones of the Enums with the same name in the LLVM Dialect. Also, see: - [[RFC] ptr dialect & modularizing ptr ops in the LLVM dialect](https://discourse.llvm.org/t/rfc-ptr-dialect-modularizing-ptr-ops-in-the-llvm-dialect/75142) for rationale. - https://github.com/llvm/llvm-project/pull/73057 for a prototype implementation of the full change. **Note: Ignore the first commit, that's being reviewed in https://github.com/llvm/llvm-project/pull/86860 .** | 1 年前 |
| 文件 | 最后提交记录 | 最后更新时间 |
|---|---|---|
| 1 年前 | ||
| 10 个月前 | ||
| 1 年前 | ||
| 10 个月前 | ||
| 1 年前 |