Skip to content

Commit 4769da0

Browse files
committed
fix(conversion): lower shared S@/S! to NVVM shared address space
1 parent 3c63197 commit 4769da0

2 files changed

Lines changed: 7 additions & 5 deletions

File tree

lib/Conversion/ForthToMemRef/ForthToMemRef.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "mlir/Dialect/Func/Transforms/FuncConversions.h"
1212
#include "mlir/Dialect/GPU/IR/GPUDialect.h"
1313
#include "mlir/Dialect/LLVMIR/LLVMDialect.h"
14+
#include "mlir/Dialect/LLVMIR/NVVMDialect.h"
1415
#include "mlir/Dialect/MemRef/IR/MemRef.h"
1516
#include "mlir/IR/BuiltinTypes.h"
1617
#include "mlir/IR/PatternMatch.h"
@@ -28,8 +29,9 @@ namespace {
2829

2930
// Stack configuration constants
3031
constexpr int64_t kStackSize = 256;
32+
// NVPTX shared memory address space for LLVM ptr types.
3133
constexpr unsigned kWorkgroupAddressSpace =
32-
static_cast<unsigned>(gpu::AddressSpace::Workgroup);
34+
static_cast<unsigned>(NVVM::kSharedMemorySpace);
3335

3436
/// Type converter for forth.stack -> memref + index
3537
class ForthToMemRefTypeConverter : public TypeConverter {

test/Conversion/ForthToMemRef/memory-ops.mlir

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@
1616
// CHECK: llvm.store %{{.*}}, %{{.*}} : i64, !llvm.ptr
1717

1818
// shared load (S@): pop address, inttoptr shared addrspace, llvm.load
19-
// CHECK: llvm.inttoptr %{{.*}} : i64 to !llvm.ptr<{{[1-9][0-9]*}}>
20-
// CHECK: llvm.load %{{.*}} : !llvm.ptr<{{[1-9][0-9]*}}> -> i64
19+
// CHECK: llvm.inttoptr %{{.*}} : i64 to !llvm.ptr<3>
20+
// CHECK: llvm.load %{{.*}} : !llvm.ptr<3> -> i64
2121

2222
// shared store (S!): pop address + value, inttoptr shared addrspace, llvm.store
23-
// CHECK: llvm.inttoptr %{{.*}} : i64 to !llvm.ptr<{{[1-9][0-9]*}}>
24-
// CHECK: llvm.store %{{.*}}, %{{.*}} : i64, !llvm.ptr<{{[1-9][0-9]*}}>
23+
// CHECK: llvm.inttoptr %{{.*}} : i64 to !llvm.ptr<3>
24+
// CHECK: llvm.store %{{.*}}, %{{.*}} : i64, !llvm.ptr<3>
2525

2626
module {
2727
func.func private @main() {

0 commit comments

Comments
 (0)