[Mlir-commits] [mlir] [MLIR][NVVM] Add prefetch Ops (PR #141737)
Durgadoss R
llvmlistbot at llvm.org
Wed Jun 4 04:55:52 PDT 2025
================
@@ -1734,6 +1770,50 @@ NVVM::IDArgPair DotAccumulate2WayOp::getIntrinsicIDAndArgs(
return {ids[type], args};
}
+llvm::Intrinsic::ID PrefetchOp::getIntrinsicID(NVVM::PrefetchOp &op) {
+ using MemSpace = NVVM::NVVMMemorySpace;
+ using CacheLevel = NVVM::PrefetchCacheLevel;
+
+ NVVM::PrefetchCacheLevel cacheLevel = op.getCacheLevel();
+ std::optional<NVVM::CacheEvictionPriority> evictPriority =
+ op.getEvictPriority();
+ unsigned addressSpace =
+ llvm::cast<LLVM::LLVMPointerType>(op.getAddr().getType())
+ .getAddressSpace();
+
+ if (op.getUniform() && cacheLevel == CacheLevel::L1)
+ return llvm::Intrinsic::nvvm_prefetchu_L1;
+
+ if (evictPriority && cacheLevel == CacheLevel::L2) {
+ switch (*evictPriority) {
+ case NVVM::CacheEvictionPriority::EvictLast:
+ return llvm::Intrinsic::nvvm_prefetch_global_L2_evict_last;
+ case NVVM::CacheEvictionPriority::EvictNormal:
+ return llvm::Intrinsic::nvvm_prefetch_global_L2_evict_normal;
+ default:
+ llvm_unreachable("Invalid cache eviction priority");
+ }
+ }
+
+ switch (addressSpace) {
+ case MemSpace::kGenericMemorySpace:
+ return cacheLevel == CacheLevel::L1 ? llvm::Intrinsic::nvvm_prefetch_L1
+ : llvm::Intrinsic::nvvm_prefetch_L2;
+ case MemSpace::kGlobalMemorySpace:
+ return cacheLevel == CacheLevel::L1
+ ? llvm::Intrinsic::nvvm_prefetch_global_L1
+ : llvm::Intrinsic::nvvm_prefetch_global_L2;
+ case MemSpace::kLocalMemorySpace:
+ return cacheLevel == CacheLevel::L1
+ ? llvm::Intrinsic::nvvm_prefetch_local_L1
+ : llvm::Intrinsic::nvvm_prefetch_local_L2;
+ default:
+ llvm_unreachable("Invalid pointer address space");
+ }
+
+ llvm_unreachable("Invalid parameters for prefetch");
----------------
durga4github wrote:
nit: I wonder if we need this unreachable here..
In other words, when will we ever hit it? (instead of the unreachable on line 1811)
https://github.com/llvm/llvm-project/pull/141737
More information about the Mlir-commits
mailing list