-
Notifications
You must be signed in to change notification settings - Fork 730
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support of memref of struct type (#44)
`SubIndexOpLowering` was unable to correctly handle memref of struct type. memref of struct type is only generated for struct that has at least one entry of SYCL type, otherwise a llvm pointer type is generated instead of a memref. (ref: https://github.com/InteonCo/Polygeist/blob/main/tools/cgeist/Lib/clang-mlir.cc#L5421) When a memref element type is a struct type, the return type of a `polygeist.subindex` should be a memref of the element type of the struct. (ref: https://github.com/InteonCo/Polygeist/blob/main/tools/cgeist/Lib/clang-mlir.cc#L703) Signed-off-by: Tsang, Whitney <whitney.tsang@intel.com>
- Loading branch information
1 parent
0402ca1
commit 178e944
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// RUN: polygeist-opt --convert-polygeist-to-llvm %s | FileCheck %s | ||
|
||
// CHECK: [[GEP:%.*]] = llvm.getelementptr {{.*}} : (!llvm.ptr<struct<([[SYCLIDSTRUCT:struct<"class.cl::sycl::id.1"]], {{.*}} -> !llvm.ptr<[[SYCLIDSTRUCT]], {{.*}} | ||
// CHECK: [[MEMREF:%.*]] = llvm.mlir.undef : !llvm.struct<(ptr<[[SYCLIDSTRUCT]], {{.*}} | ||
// CHECK: {{.*}} = llvm.insertvalue [[GEP]], [[MEMREF]][0] : !llvm.struct<(ptr<[[SYCLIDSTRUCT]], {{.*}} | ||
|
||
module { | ||
func.func @test(%arg0: memref<?x!llvm.struct<(!sycl.id<1>)>>) -> memref<?x!sycl.id<1>> { | ||
%c0 = arith.constant 0 : index | ||
%0 = "polygeist.subindex"(%arg0, %c0) : (memref<?x!llvm.struct<(!sycl.id<1>)>>, index) -> memref<?x!sycl.id<1>> | ||
return %0 : memref<?x!sycl.id<1>> | ||
} | ||
} |