MLIR 23.0.0git
AMDGPUEnums.h
Go to the documentation of this file.
1//===- Utils.h - General AMDGPU Enums utilities -----------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8#ifndef MLIR_DIALECT_AMDGPU_UTILS_AMDGPU_ENUMS_H_
9#define MLIR_DIALECT_AMDGPU_UTILS_AMDGPU_ENUMS_H_
10
11#include "mlir/Dialect/AMDGPU/IR/AMDGPUEnums.h.inc"
14#include "llvm/ADT/STLExtras.h"
15
16namespace mlir::amdgpu {
17
18inline int32_t getGlobalPrefetchLLVMEncoding(amdgpu::LoadTemporalHint hint,
19 amdgpu::Scope scope,
20 bool isSpeculative) {
21 int32_t immArg = static_cast<int32_t>(hint);
22
23 // Note that only RT and HT can operate in both speculative and
24 // non-speculative modes. The other variants (NT_RT, RT_NT, NT_HT, etc.)
25 // operate only in the speculative mode and, therefore, do not require
26 // toggling the least significant bit for mode changes
27 // Temporal hint is encoded in lower bits - i.e. [2:0]
28 if (llvm::is_contained({LoadTemporalHint::RT, LoadTemporalHint::HT}, hint))
29 immArg = isSpeculative ? immArg : immArg | 1;
30
31 // Prefetch scope level is encoded in upper bits - i.e., [4:3]
32 return static_cast<int32_t>(scope) << 3 | immArg;
33}
34
35} // namespace mlir::amdgpu
36
37#endif
int32_t getGlobalPrefetchLLVMEncoding(amdgpu::LoadTemporalHint hint, amdgpu::Scope scope, bool isSpeculative)
Definition AMDGPUEnums.h:18